# Re: A85: Drawing a menu

```
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
>	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:
>

```

Follow-Ups:
References: