VGA example - passing data between code
retromicro
Posts: 24
in Propeller 1
Hi
I'm interested in passing data from a SPIN array into PASM so I've been looking at some example code.
Please correct me if I'm wrong here.
In one of the VGA examples, a block of characters (longs) is defined like so -
long screen[cols*rows/4]
It looks like the address of these characters (longs) is passed through to the main VGA set up routine like so -
vgatext.start(16, @screen, @colours, @cx0, @sync)
PUB start(BasePin, ScreenPtr, ColorPtr, CursorPtr, SyncPtr) : okay | i, j
This leaves ScreenPtr containing the address of the character block.
This is soon followed up with -
Not sure why they would do this, especially choosing to move 3 longs. Further down, screen_base looks to be the address of the next character to be rendered but why not just use ScreenPtr ?
Once inside the main video rendering PASM, we have -
mov screen_ptr,screen_base 'reset screen pointer to upper-left character
following soon after by -
:column rdbyte z,screen_ptr 'get character from screen memory
.
Intermediate code
.
add screen_ptr,#1 'increment screen memory address
It looks like screen_ptr is set up from screen_base as a destructible pointer into the original character block and this is incremented each time in the loop ready to get the next character.
However, I've got some questions about this -
RDBYTE is used to read byte of main memory but isn't the character block declared in the SPIN in Cog RAM ?
This almost looks like indexed addressing but without the self-modifying part.
I've got my own simple example with extracts below -
long inverse
inverse := 255
longmove(@inverse_flag, @inverse, 1)
The PASM code simply has the below and the value assigned in SPIN is seen by the PASM.
This looks like a simpler way than the VGA example for PASM to access data defined in SPIN.
So, after all the above rambling, what's the best way for a PASM loop to access a block of data as set up in the top SPIN example ?
Thanks
I'm interested in passing data from a SPIN array into PASM so I've been looking at some example code.
Please correct me if I'm wrong here.
In one of the VGA examples, a block of characters (longs) is defined like so -
It looks like the address of these characters (longs) is passed through to the main VGA set up routine like so -
This leaves ScreenPtr containing the address of the character block.
This is soon followed up with -
'implant pointers
longmove(@screen_base, @ScreenPtr, 3)
longmove(@screen_base, @ScreenPtr, 3)
Not sure why they would do this, especially choosing to move 3 longs. Further down, screen_base looks to be the address of the next character to be rendered but why not just use ScreenPtr ?
Once inside the main video rendering PASM, we have -
following soon after by -
:column rdbyte z,screen_ptr 'get character from screen memory
.
.
add screen_ptr,#1 'increment screen memory address
It looks like screen_ptr is set up from screen_base as a destructible pointer into the original character block and this is incremented each time in the loop ready to get the next character.
However, I've got some questions about this -
RDBYTE is used to read byte of main memory but isn't the character block declared in the SPIN in Cog RAM ?
This almost looks like indexed addressing but without the self-modifying part.
I've got my own simple example with extracts below -
long inverse
inverse := 255
longmove(@inverse_flag, @inverse, 1)
The PASM code simply has the below and the value assigned in SPIN is seen by the PASM.
XOR led_byte, inverse_flag ' Temporary inversion to test parameter passing
inverse_flag LONG 0
inverse_flag LONG 0
This looks like a simpler way than the VGA example for PASM to access data defined in SPIN.
So, after all the above rambling, what's the best way for a PASM loop to access a block of data as set up in the top SPIN example ?
Thanks
Comments
For vga character display the cog needs to know what pins to use for the signals, the start address of the bytes to display, the address of a lookup table to convert each character to pixels for display, and a color palette for the background/foreground colors.