I've started experimenting with Gameboy programming using Z80 assembly, but I've found something kind of weird.
I found a snippet of code used to create a delay:
simpleDelay:
dec bc
ld a,b
or c
jr nz, simpleDelay
ret
While playing around with that, I discovered that writing dec bc twice shortens the delay, but writing it 3 times makes the delay longer than using it once or twice. Why does having an even number of dec
statements shorten the delay?
EDIT: Here's the snippet of code calling the delay:
ld hl,Title2
ld de, _SCRN0+3+(SCRN_VY_B*5) ;
ld bc, Title2End-Title2
call mem_CopyVRAM
call simpleDelay