Page 1 of 1

Something small

Posted: Sun 17 Feb, 2008 2:56 pm
by driesguldolf
Attempt to bring some life into this place.

I guess you all know the code, but it has a bug. Find it!
Also present the solution (smallest size)

Code: Select all

getpixel:
	ld h, 0
	ld d, h
	ld e, l
	add hl, hl
	add hl, de
	add hl, hl
	add hl, hl
	ld de, gbuf
	add hl, de
	ld e, a
	srl e
	srl e
	srl e
	add hl, de
	and 7
	ld b, a
	ld a, %10000000
	ret z
-
	rrca
	djnz -
	ret
Have fun! (I certainly didn't...)

Re: Something small

Posted: Sun 17 Feb, 2008 3:43 pm
by CoBB
You forgot to zero d when adding the horizontal byte offset. A fix that doesn’t cost a single byte would be simply to move the addition of gbuf to the end of the address calculation.

Posted: Mon 18 Feb, 2008 9:45 pm
by driesguldolf
:drifter:
Congrats, oh well, it certainly was a short 'contest' :P
It took me 2 hours to find out... >_>