Page 2 of 3

Posted: Fri 25 Nov, 2005 12:43 pm
by tr1p1ea
CoBB, im pretty sure you will have to change your rotating otherwise the sprite will mirror itself as well as rotate.

rra \ rr (hl) instead of rla \ rr (hl).

Posted: Fri 25 Nov, 2005 2:38 pm
by CoBB
Yes, I realised it too, I just happened to test it with a symmetric sprite first. :)

Even if it isn't entirely serious, your third example raises an important concern. After all, we could technically create 0-byte routines by putting them all into the invocation. I saw a similar cheat once in a 256-byte intro: it used a directory structure full of zero-byte files as its data. :)

The solution would be to count the invocation in some way. We should probably not allow constant input at all, so e. g. if HL must be page aligned, it would be the routine's job to discard the initial value of L.

Posted: Fri 25 Nov, 2005 2:43 pm
by tr1p1ea
Yeah i put it there as a joke (:)), i consider it below the belt and wouldnt dare try to actually include it in the comp. Perhaps we need a tighter set of rules for future comps which specify the required input and required output (like hl must point to start of rotated sprite on exit).

Posted: Fri 25 Nov, 2005 2:49 pm
by kv83
tr1p, the 3rd attempt... the only thing it does it mirroring the sprite or something? I am sorry that I am not as good as you guys :$

Posted: Fri 25 Nov, 2005 2:52 pm
by CoBB
No, the cheat is that you have to ld part of the routine into its place before calling it. :lol:

Posted: Fri 25 Nov, 2005 2:54 pm
by tr1p1ea
The 3rd attempt will rotate correctly, left or right depending on a few inputs :x. Its basically like the first one ... but with a cheat, so its best that it is forgotten about :).

The second one is the best i have so far.

Posted: Fri 25 Nov, 2005 3:10 pm
by kv83
Ah, I understand. Tr1p, can you re-post it here? I want to re-read the routine again :)

Posted: Fri 25 Nov, 2005 3:16 pm
by tr1p1ea
(totally cheating, so dont count this one :)):

Code: Select all

;--------------------------------------------------
; RSprite by tr1p1ea - 13 bytes
;--------------------------------------------------
; Rotates an 8x8 sprite
;
; Input: de = SpriteData
;	     hl = TempBuffer (page aligned)
;	      b = # of rows to rotate (usually 8)
;    (_rsL) = $1F and (_rsL+2) = $1E for CW
;    (_rsL) = $17 and (_rsL+2) = $16 for CCW
;
; Output: hl + 1 = rotated sprite
;
; Remarks: TempBuffer must be page aligned.
;          For example equate $8700
;
RSprite:
	ld a,(de)
	inc de
	ld l,8
_rsL:
	rra
	rr (hl)
	dec l
	jr nz,_rsL
	djnz RSprite
	ret
</cheating>

Posted: Fri 25 Nov, 2005 8:10 pm
by Jim e
Okay I cut it down to 17 bytes, though I kinda perfer my first, it's seems more useful.

Posted: Fri 25 Nov, 2005 8:39 pm
by CoBB
Yes, it was nice of the designers of z80 to have inc/dec preserve the carry. ;)

You can shave off another byte by having BC=height*256+9 as the input... I'm not going to post that. :P

Posted: Fri 25 Nov, 2005 9:40 pm
by Jim e
Yeah but that seems like out right cheating since 9 never changes. :roll: But i knew you'd find the 16 byte routine.

Posted: Fri 25 Nov, 2005 9:46 pm
by tr1p1ea
Here i come to suggest just that and its already been suggested :).

Seems like this turned into a combined effort. Maybe next comp people should submit routines which will only be revealed when the comp ends?

Posted: Fri 25 Nov, 2005 9:55 pm
by CoBB
Jim e wrote:Yeah but that seems like out right cheating since 9 never changes. :roll: But i knew you'd find the 16 byte routine.
It's no worse than having rotationdir*$808+$1716 in IX. We can make a deep philosophical question about whether one is more legitimate than the other, but we all know the answer anyway. :)

Posted: Fri 25 Nov, 2005 10:02 pm
by Jim e
True, ix is in a similar situation, but it's more than just moving a byte out of the routine and into the user end, it actual detremines something. This contest seems more and more like how far we can bend the rules.


The next contest should be for speed.

Posted: Fri 25 Nov, 2005 10:06 pm
by tr1p1ea
Do you think we have done all we can?

Is there a 15 byte routine out there?

Maybe as an extension we could do a 360 rotating routine that will take an 8x8 sprite, rotate it and draw it to gbuf?

EDIT - ok maybe not 360 individual degrees, maybe in 8 degree increments or even 45?

*Also i know that i bent the rules like crazy :).*