Re: A85: Drawing a menu


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

Re: A85: Drawing a menu




Here's how I did it.  Note that Draw_Currsor_4 is the part of the routine
that actually draws the cursor.  The push af is so that you don't have to
load a a second time to draw the updated register.  I jus tried it with
your suggestion and it saved 11 bytes, so ignore all of the code below,
because I'm using the djnz idea.  It's amazing how effiecient loops are. 
Thanks again.

Draw_Cursor:

	push   af                 ; Save current option for easy
retrieval
	cp     1                  ; Check if option one is set
	jr     nz, Draw_Cursor_2
	ld     hl, $FE13          ; If so, inverse first option
	jr     Draw_Cursor_4

Draw_Cursor_2:

	cp     2                  ; Check if option two is set
	jr     nz, Draw_Cursor_3
	ld     hl, $FE83          ; If so, inverse second option
	jr     Draw_Cursor_4

Draw_Cursor_3:

	ld     hl, $FEF3

Draw_Cursor_4:


On Tue, 05 May 1998 21:06:13 GMT mgp4007@omega.uta.edu (Michael Pearce)
writes:
>
>all right, i will give a little bit more explanation of what is going
>on here.  you say that the location of where the cursor should start
>drawing for the first column is FE13.  the position for the 2nd row
>will be FE13 + 112 and for the third row, it will be FE13 + 112*2.  so
>this value is calculated at the beginning of the function using the a
>register to determine which row.  so if you call the routine with a=1
>this is what will happen,
>1. hl starts out as FE13-112
>2. add 112 to hl to get hl=FE13
>3. register b=0 so stop looping with hl=FE13, which is where you want
>to start inverting row 1
>
>when a=2,
>1. hl starts out as FE13 - 112
>2. add 112 to hl to get hl=FE13
>3. subtract one from b to get 1, so loop
>4. add 112 to hl to get hl=FE13 + 112
>5. register b=0 so stop looping with hl=FE13 + 112, which is where you
>want to start inverting row 2
>
>when a=3
>1. hl starts out as FE13 - 112
>2. add 112 to hl to get hl=FE13
>3. subtract one from b to get 2, so loop
>4. add 112 to hl to get hl=FE13 + 112
>5. subtract one from b to get 1, so loop
>6. add 112 to hl to get hl=FE13 + 112 + 112
>7. register b=0 so stop looping with hl=FE13 + 112*2, which is where
>you want to start inverting row 3
>
>maybe that helps more, maybe not.
>
>-mike pearce
>
>>
>>;input:
>>;  a = the row to inverse
>>
>>Draw_Cursor:
>>	ld     hl, $FE13 - 112    ; Options menu cursor - 112
>>	                          ; (the 112 gets added back)
>>	ld     de, 112            ; # of bytes for each row
>>	ld     b,a                ; put row number in b for djnz
>>D_C_CalcVidMem:                   ; must go through loop at least 
>once
>>	add    hl, de             ; for each row, add 112 bytes
>>	djnz D_C_CalcVidMem
>>
>>;hl now has correct address of where to start drawing
>>
>>	ld     c, 7               ; Height of cursor
>>Draw_Cursor_2:
>>	ld     b, 10              ; Width in bytes of cursor
>>Draw_Cursor_3:
>>
>
>

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]


References: