Omnimaga

Calculator Community => Major Community Projects => The Axe Parser Project => Topic started by: Matrefeytontias on July 11, 2014, 01:31:31 pm

Title: Scaled sprites axiom
Post by: Matrefeytontias on July 11, 2014, 01:31:31 pm
Hi guys,

This is something I could have done a while ago, but since Hayleia reminded me about it, I do it now.

So what is it, you ask. Well, it's an axiom that lets you draw scaled sprites, either clipped (for safety) or not clipped (for speed). Beware though, it only lets you draw sprites as a fraction of their size, that means that you can't widen sprites, only shrink them - but look at dem specs : it works for sprites up to 256*256 and have a precision of 0.4 in the resizing ratio.

Though this time again, I didn't do much ; like with AxeJh3D, I just ported ASM routines to axiom form. Code and appvar attached.

So here's how it works. The commands can be found near the Z entry of the catalog [2nd][0][2].

Command (token)UsageEffect
Scaled-On (Zoom In)Scaled-On(X * 256 + Y, original height * 256 + original witdh IN BYTES, scale factor, sprite)OR-s a sprite scaled to a fraction of its original dimensions on the graph buffer. Does no clipping, very fast. The scale factor goes from 1 to 256 (or 0 to 255, but keep reading). 1 is 0.4%, 128 is 50%, 256 (aka 0) is 100%.
Scaled-XOR (Zoom Out)Scaled-XOR(X * 256 + Y, original height * 256 + original width in bytes, scale factor, sprite)XOR-s a sprite scaled to a fraction of its original dimensions on the graph buffer. Does no clipping, very fast.
ScaledClip-On (ZoomFit)ScaledClip-On(X * 256 + Y, original height * 256 + original width in bytes, scale factor, sprite)OR-s a sprite scaled to a fraction of its original dimensions on the graph buffer. Does clipping, but still very fast, trust me. :P
ScaledClip-XOR (ZoomRcl)ScaledClip-XOR(X * 256 + Y, original height * 256 + original width in bytes, scale factor, sprite)XOR-s a sprite scaled to a fraction of its original dimensions on the graph buffer. Does clipping, but still very fast, trust me. :P

Original routines : http://www.ticalc.org/archives/files/fileinfo/192/19230.html (http://www.ticalc.org/archives/files/fileinfo/192/19230.html)

Enjoy =]
Title: Re: Scaled sprites axiom
Post by: Hayleia on July 12, 2014, 05:34:03 am
Thanks :D
You should mention if it doesn't work in apps due to using SMC though.
Title: Re: Scaled sprites axiom
Post by: DJ Omnimaga on July 15, 2014, 06:26:28 pm
Interesting. I wonder if there is an example screenshot or working demo? I wonder how fast it is?
Title: Re: Scaled sprites axiom
Post by: Matrefeytontias on July 15, 2014, 07:28:06 pm
Well there are still the screenshots of the ticalc.org page, it's exactly the same routine. You'll also see it's really fast :)
Title: Re: Scaled sprites axiom
Post by: DJ Omnimaga on July 15, 2014, 07:36:51 pm
Oh right, I didn't realize this used Badja's routine.
Title: Re: Scaled sprites axiom
Post by: Sorunome on July 16, 2014, 12:48:09 am
Sweat! This can allow for some nice animations :)
Title: Re: Scaled sprites axiom
Post by: Hayleia on July 29, 2014, 07:02:22 am
Bug report ! :P

Zoom In works.
Zoom Out works.
ZoomFit doesn't compile, says "Invalid token" and jumps to the first comma in the line starting with ZoomFit (in the sample program above, it is the comma just after the "32").
ZoomRcl doesn't compile either, says "Invalid Axiom" and jumps on "ZoomRcl" (not on "#Axiom(SCALESPR)").

Here's a sample program (in attachement to) if you want to test (yeah, I know the calculation of F could have been in the Zoom line but this one is already long enough, and it's just a program for testing :P). Just replace the "ZoomXXX" with the token you want.
Code: [Select]
.AA
Axiom(SCALESPR)

256->F
While 1
 max(min(F+getKey(4)-getKey(1),256),1)->F
 Zoom In 48*256+32,16*256+2,F,[FFFFFFFFF003F803DC03CE03C703C383C1C3C0E3C073C03BC01FC00FFFFFFFFF])
 DispGraphClrDraw
EndIf getKey(15)
Title: Re: Scaled sprites axiom
Post by: Matrefeytontias on July 29, 2014, 09:58:15 am
Problem solved, download the attachments of the first post again x.x I have no idea why but I put an extra .dw 0 in the header of the ScaledClip-On, thus shifting the whole program down 2 bytes. Sorry about that !
Title: Re: Scaled sprites axiom
Post by: Hayleia on July 29, 2014, 01:27:58 pm
I confirm that the other three work but ZoomRcl now says Invalid Token.