Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Keoni29 on January 31, 2012, 05:06:46 am

Title: EXA: Scale up sprites
Post by: Keoni29 on January 31, 2012, 05:06:46 am
Have you ever wanted to scale up a sprite? Use this AXE subroutine:
Code: [Select]
Lbl SPR
For(A,0,7
{r5+A}->r6
For(B,0,7
If r6^2
Rect(B*r3+r1,A*r4+r2,r3,r4
End
r6/2->r6
End
End
Now use this code to call the subroutine:
Code: [Select]
SPR(x,y,w,h,pic
It uses rectangles of size w,h to display the sprite. I guess this code can be optimized, but it does the job.

For example:
Code: [Select]
.SPRITESC
[3C42A581A599423C]->Pic1
ClrDraw
For(A,2,10
SPR(5,5,C,C/2,Pic1
Pause 300
DispGraphClrDraw
End
Pause 1000
Return
Lbl SPR
For(A,0,7
{r5+A}->r6
For(B,0,7
If r6^2
Rect(B*r3+r1,A*r4+r2,r3,r4
End
r6/2->r6
End
End

I hope you find this information helpful. Please leave suggestions and or questions.
Title: Re: EXA: Scale up sprites
Post by: kindermoumoute on February 15, 2012, 07:11:29 am
I suppose that's like Pt-Off() command, you can't draw white pixels ?

Why you didn't use BYTEeBIT command ?
Code: [Select]
Lbl SPR
For(A,0,7
{r5+A}->r6
For(B,0,7
If r6eB
Rect(B*r3+r1,A*r4+r2,r3,r4
End
End
End

e = exp token.
Title: Re: EXA: Scale up sprites
Post by: DJ Omnimaga on February 16, 2012, 12:18:16 am
How fast does this runs by the way? I'm curious if it could be used in-game. I made a scaling routine for 8x8 sprites back then, which, however, used 8x8 plain white or black squares and thus, the bottom and right were weird if I remember. It ran at around 10 fps. Not really useable in a real-time animation, but one person could simply pre-render each instance of zoomed up sprite prior the main game loop then temporarily store them into a buffer and displayed when needed.
Title: Re: EXA: Scale up sprites
Post by: Keoni29 on February 17, 2012, 04:13:45 am
How fast does this runs by the way? I'm curious if it could be used in-game. I made a scaling routine for 8x8 sprites back then, which, however, used 8x8 plain white or black squares and thus, the bottom and right were weird if I remember. It ran at around 10 fps. Not really useable in a real-time animation, but one person could simply pre-render each instance of zoomed up sprite prior the main game loop then temporarily store them into a buffer and displayed when needed.
I will try to render it 1000 times and see how long it takes.
Title: Re: EXA: Scale up sprites
Post by: DJ Omnimaga on February 17, 2012, 09:32:27 am
Ok here was my routine. From what I remember now, I think I actually drew an extra row of white squares below. It was definitively not very reliable, due to erasing stuff below.

http://ourl.ca/6016/93657

(http://www.omnimaga.org/index.php?action=dlattach;topic=3419.0;attach=1499;image)
Title: Re: EXA: Scale up sprites
Post by: Keoni29 on February 17, 2012, 11:03:00 am
My routine is much quicker since it doesn't scale partially.