Specifying variable addess
PatM
Posts: 72
In Bascom AVR I can create a variable and tell it where to reside in memory. For example:
DIM screen_bitmap AS byte * 19200 AT $3000
Is there an equivilent in spin? Been searching the manual and I don't see it (which probably means no).
·
DIM screen_bitmap AS byte * 19200 AT $3000
Is there an equivilent in spin? Been searching the manual and I don't see it (which probably means no).
·
Comments
Yes, this is a bit messy, but it works and using BYTE[noparse]/noparse and LONG[noparse]/noparse to access HUB memory is actually very nice and clean looking in my opinion.
Harrison
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 7/8/2007 3:47:58 AM GMT
When I did use an array, the top left was garbled. I did some experimenting and found it was the LSB problem. So, it seemed to make sense to declare at a specific location.
The 512x384 demo is straightforward and simple to figure out, change a color table entry and that tile changes colours. The way other demos like mars lander handle the colours is a lot harder to understand.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 7/8/2007 6:38:39 AM GMT
Generally two soulutions are used:
(1)
LONG padding [noparse][[/noparse]16]
LONG buffer[noparse][[/noparse]x_tiles*y_tiles*16]
bitmap := buffer & $ffc0
(2)
LONG buffer[noparse][[/noparse]x_tiles*y_tiles*16+15]
bitmap := (@buffer+15)& $ffc0
In TV_text.spin the screen buffer is defined as
VAR
·· word screen[noparse][[/noparse]cols*rows] 'at 32x13 screen it's 416 words
now, if I need to define a custom font, I do it's this way:
VAR
·· long user_fontbase
...
user_fontbase := (@cfont >> 2)
...
DAT
padding long 0[noparse][[/noparse]x]
cfont
······ 32 longs of 32bit (4 color) custom character 1 bitmap
······ 32 longs of 32bit (4 color) custom character·2 bitmap
······ ................32longs of 32bit (4 color) custom character·n bitmap
=================
screen[noparse][[/noparse]416] array contains color pointers and character map pointers (as·user_fontbase + offset in a font)
If I understand it right, it's the cfont·(bitmap) that should be aligned at·64 boundary - am I wrong?
I am trying to do alignment by changing x in the above padding long 0[noparse][[/noparse]x].
The problem is that x should be changed any time the preceeding code changes..
That's where assignment of the cfont block to a particular address could help tremendously (AFAIU)
And the whole thing·doesn't work, but it's probably a different story..
Gennady
I would use a "brute force" approach just to make it go:
Looks a little bit clumpsy though...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 7/11/2007 12:02:00 AM GMT
Since each character comprises 32 LONGs that is multipled with·the number of user defined characters. The first argument strips out the portion of the address which is less than 64 thereby finding the 64 byte boundry preceeding the address @cfont, and since that lies somewhere in the padding no data is trampled on and all user characters are aligned to a 64 byte boundry at run time alieviating the need to·hand align.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
perhaps useful in some cases.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Just in case other new folks see this thread and think you have to jump through hoops to get the video. Works fine without it, I just like seeing the memory use reflected in the graph.
·