Re: A85: Drawing a menu


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

Re: A85: Drawing a menu




OK this is a lot so please don't be mad...


;;  HL already points to the string because right before this the program
draws the Title, etc.

	call   D_ZM_STR           ; Display option one
	ld     de, $281B          ; Cursor coordinates
	ld     ($8333), de        ; Save coordinates
	call   D_ZM_STR           ; Display option two
	ld     de, $2F29          ; Cursor coordinates
	ld     ($8333), de        ; Save coordinates
	call   D_ZM_STR           ; Display option three
	ld     hl, $FE13          ; Options menu cursor
	ld     a, 1               ; Preselect option one
	ld     (OPTION), a        ; Save option
	call   &Draw_Cursor       ; Draw cursor

Cursor_Loop:

	call   &Key_Loop          ; Loop until a key is pressed (Key_Loop
not included here)
	cp     K_UP               ; Check if user pressed up
	jr     z, Option_Up
	cp     K_DOWN             ; Check if user pressed down
	jr     z, Option_Down
	cp     K_ENTER            ; Check if user pressed enter
	jr     z, Begin_Game
	cp     K_EXIT             ; Check if user pressed EXIT
	jr     nz, Cursor_Loop    ; If not, loop again
	re

Draw_Cursor:

	ld     c, 7               ; Height of cursor

Draw_Cursor_2:

	ld     b, 10              ; Width in bytes of cursor

Draw_Cursor_3:

	ld     a, (hl)            ; Load first byte of cursor
	cpl                       ; Inverse pixels
	ld     (hl), a            ; Save modified byte
	inc    hl                 ; Point to next byte
	djnz   Draw_Cursor_3
	ld     de, 6              ; Add 6 to HL
	add    hl, de             ; HL now points to next row
	dec    c                  ; One less row left
	ld     a, c               ; Load C into A for finding rows left
	or     a                  ; Check if any rows are left
	jr     nz, Draw_Cursor_2
	ld     de, 112            ; Restore original value of HL
	sbc    hl, de             ; Now points to beginning of cursor
	ret

Option_Up:

	call   &Draw_Cursor       ; Erase old cursor
	ld     a, (OPTION)        ; Find out which option is selected
	cp     1                  ; Check if it is option one
	jr     nz, Option_Up_2    ; If not, go to next step

	ld     hl, $FEF3          ; Cursor points to last option
	ld     a, 3               ; Set to option three
	ld     (OPTION), a        ; Save option
	call   &Draw_Cursor
	jr     Cursor_Loop

Option_Up_2:

	dec    a                  ; Switch to next option up
	ld     (OPTION), a        ; Save option
	or     a                  ; Clear carry flag
	ld     de, 112            ; Difference in video mem from one
option to the next
	sbc    hl, de             ; HL now points to above cursor
	call   &Draw_Cursor       ; Draw updated cursor
	jr     Cursor_Loop

Option_Down:

	call   &Draw_Cursor       ; Erase old cursor
	ld     a, (OPTION)        ; Find out which option is selected
	cp     3                  ; Check if it is option one
	jr     nz, Option_Up_2    ; If not, go to next step

	ld     hl, $FE13          ; Cursor points to first option
	ld     a, 1               ; Set to option one
	ld     (OPTION), a        ; Save option
	call   &Draw_Cursor       ; Draw updated cursor
	jr     Cursor_Loop

Option_Down_2:

	inc    a                  ; Switch to next option down
	ld     (OPTION), a        ; Save option
	ld     de, 112            ; Difference in video mem from one
option to the next
	add    hl, de             ; HL now points to below cursor
	call   &Draw_Cursor       ; Draw updated cursor
	jr     Cursor_Loop

It draws the three options alright, then places the cursor onto the first
one, but then when I press up or down it doesn't really work.  I even
recompiled it with a "call  D_HL_DECI" in the Cursor_Loop if you press
alpha and it gave me a number that when doubled, was $10000 (one more
than the end of the video memory).  The problem lies in when you press up
or down and I can't seem to figure out why.

On Tue, 05 May 1998 17:56:56 GMT mgp4007@omega.uta.edu (Michael Pearce)
writes:
>
>post some of your code.
>
>-mike pearce
>
>On Tue, 05 May 1998 12:12:00 EDT, you wrote:
>
>>
>>
>>If I wanted to make a menu like Usgard Simple Shell has, I would load
>>each byte of the cursor into A, use cpl, and then load it back into
>>memory, right?  This will give it that white-on-black look.  And if I
>>wanted to unselect that item (or in Usgard's condition, that 
>preogram) I
>>would do the same process again, thereby making it black-on-white 
>text,
>>and then doing the same process on the now-selected item?  This seems 
>so
>>simple and I've checked the code so many times and I can't find 
>anything
>>wrong!  Please help because this is really vexing me.
>>
>>Justin Bosch
>>justin-b@juno.com
>>
>>_____________________________________________________________________
>>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]
>>
>
>

_____________________________________________________________________
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]


Follow-Ups: References: