Questions about the 'Rotate that sprite'

Moderator: MaxCoderz Staff

User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post 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).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post 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.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post 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).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post 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 :$
Image
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

No, the cheat is that you have to ld part of the routine into its place before calling it. :lol:
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post 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.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
kv83
Maxcoderz Staff
Posts: 2735
Joined: Wed 15 Dec, 2004 7:26 pm
Location: The Hague, Netherlands
Contact:

Post by kv83 »

Ah, I understand. Tr1p, can you re-post it here? I want to re-read the routine again :)
Image
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post 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>
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

Okay I cut it down to 17 bytes, though I kinda perfer my first, it's seems more useful.
Image
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post 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
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post 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.
Image
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post 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?
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post 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. :)
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post 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.
Image
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post 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 :).*
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
Post Reply