Re: A82: Variable storage


[Prev][Next][Index][Thread]

Re: A82: Variable storage



ilya winham <ilyamojo@geocities.com> writes:
>Is there any other places I can store pre-defined variables to other 
>than graph_mem 1 and 2, or text_mem 1 and 2???

Not sure what you mean about GRAPH_MEM 2, but....

Variables can also be declared in your program by setting aside memory.
If you want variables for high scores or if you need to save any
information, you MUST do this. However, temporary variables should just
be declared in TEXT_MEM and TEXT_MEM2....stay clear of using GRAPH_MEM,
as you'll probably need it. ;) There should be more than enough space in
TEXT_MEM for variables....what are you doing? To add variables by setting
aside memory, you would do something like this:

	ld HL, Variable
	ld DE, (PROGRAM_ADDR)
	add HL, DE

	; change whatever you want in the variable here 

	ld (HL), A		; assuming A contains the value you
want stored



	Variable:	.db 0

If you want a variable that functions as a matrix, this is very helpful.
You would simply do the following:

	Martrix_Variable:	.db 0,0,0,0,0,0
			.db 0,0,0,0,0,0
			.db 0,0,0,0,0,0
			.db 0,0,0,0,0,0

There's a 4x6 matrix. Remember that each element can only go up to 255.
If you want more, you have to set aside words instead. Ex.:

	Words:	.dw 0

Got it? I think using the calc's built-in matrix functions is still
little-known, so this is the only...and probably faster than using the
calc.'s abilities...way to do this.

For people who want to know about Sprite Routines: This is how you would
access the sprite for the routine. You add the program address and sprite
address and do logical ANDs and ORs with GRAPH_MEM. Once the sprite is
stored to GRAPH_MEM like this, you use something to copy GRAPH_MEM to the
LCD. I use Sam Davies function (distributed on the list some time ago),
but I think the _GRHBUFCPY_ copy, or whatever it's called, does the same.


			-Scoobie


References: