Page 1 of 1
INC instructions
Posted: Sat May 04, 2019 4:57 pm
by Limonadd
Hey! You said in your tutorial that the command INC -reg16- was bugged. But what kind of bug is it?
And if we use it with an 8 bits register, is there still a bug?
Re: INC instructions
Posted: Sat May 04, 2019 9:34 pm
by akuyou
I didn't really explain it well enough did I? I'll get that fixed.
Basically the only problem is if you have the 16 bit registers pointing to the &FE?? range - otherwise there is no problem.
To be honest, this isn't really something to worry about - if you're not using sprites, then you won't have an issue, and if you are, well you probably want to buffer the sprites, and copy them using DMA during Vblank anyway, so you won't need to use INC/DEC during any copy routine... I guess you still need to be careful about if you were using them as loop/score counters and they hit this range though.
Please see the link below for details of the bug:
http://www.devrs.com/gb/files/faqs.html#SpriteBug
here's my tutorial using DMA for sprites (so you won't have to worry about the bug if you use sprites):
http://www.chibiakumas.com/z80/platform3.php#LessonP30
If you want to be sure it won't be a problem, you could avoid the 16 bit commands with a function like this:
Code: Select all
addHL:
push af
ld a,1
add l
ld l,a
ld a,h
adc 0
ld h,a
pop af
ret
Re: INC instructions
Posted: Sat May 04, 2019 10:04 pm
by Limonadd
Oh ok, I see, thanks a lot!
