Improve key highlight routine to save a few bytes

This commit is contained in:
Neil McPhail 2024-10-21 21:53:06 +00:00
parent 6c29091fcb
commit 7e02520c24

View File

@ -26,52 +26,49 @@ read_keyboard:
jr read_keyboard jr read_keyboard
key_1: key_1:
ld c, 0 ld e, 0
call highlight_key call highlight_key
ld a, (counter) ld a, (counter)
call play call play
ld c, 0 ld e, 0
call highlight_key jr keyoff
jr inc_counter
key_2: key_2:
ld c, 3 ld e, 3
call highlight_key call highlight_key
ld a, (counter) ld a, (counter)
inc a inc a
call play call play
ld c, 3 ld e, 3
call highlight_key jr keyoff
jr inc_counter
key_3: key_3:
ld c, 6 ld e, 6
call highlight_key call highlight_key
ld a, (counter) ld a, (counter)
inc a inc a
inc a inc a
call play call play
ld c, 6 ld e, 6
call highlight_key jr keyoff
jr inc_counter
key_4: key_4:
ld c, 9 ld e, 9
call highlight_key call highlight_key
ld a, (counter) ld a, (counter)
add a, 3 add a, 3
call play call play
ld c, 9 ld e, 9
call highlight_key jr keyoff
jr inc_counter
key_5: key_5:
ld c, 12 ld e, 12
call highlight_key call highlight_key
ld a, (counter) ld a, (counter)
add a, 4 add a, 4
call play call play
ld c, 12 ld e, 12
keyoff:
call highlight_key call highlight_key
inc_counter: inc_counter:
@ -79,26 +76,25 @@ inc_counter:
add a, 5 add a, 5
cp 25 cp 25
jr nz, set_counter jr nz, set_counter
jp zero_counter jr zero_counter
highlight_key: highlight_key:
ld hl, xylo ld hl, xylo
ld b, 0 ld d, 0
add hl, bc add hl, de
ld d, 15 ld b, 15
highlight_row: highlight_row:
ld e, 3 ld c, 3
highlight_block: highlight_block:
ld a, (hl) ld a, (hl)
xor %01000000 xor %01000000
ld (hl), a ld (hl), a
inc hl inc hl
dec e dec c
jr nz, highlight_block jr nz, highlight_block
ld c, 29 ld e, 29
add hl, bc add hl, de
dec d djnz highlight_row
jr nz, highlight_row
ret ret
INCLUDE "sample.asm" INCLUDE "sample.asm"