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