Bit much hair for Billy iirc (even in Zeo).psycopathicteen wrote:That's either Billy from Power Rangers finding where the Zeo Crystals are, or Glen Beck finding the Illuminati headquarters.
My two pieces of advice for neat code mostly apply to assembly programs: don't be afraid to comment plentifully, and if you ever find yourself wanting to use multiple branches of anonymous labels (like --,+++,) don't. Just don't. Why? Because I have no idea what this routine that I wrote does.
Code: Select all
calcrange:
ld c,a
ld a,b
sbc a,13
jr c,++
ld b,a
ld a,c
cp b
jr z,++
jr nc,+
jp calcno
+: ld c,a
ld a,b
adc a,35
jr c,++
ld b,a
ld a,c
cp b
jr z,++
jr c,++
jp calcno
++: ld a,2
ld [calc],a
ret
calcno:
ld a,1
ld [calc],a
ret
djnz -
++: dec hl
ld [board_loc],hl
ret
Of course, that little snippet's outdated, and I have added tons of comments since, so sweet, problem solved. It probably took me an hour to add them, though, because by the time I got around to it, I really couldn't remember what the code was doing or how. Not a fun situation.
Oh, and something I didn't care about back when I wrote that: don't put whitespace before label names, at least not as much as you would for opcodes. It's ugly.