Author Topic: Enlarging sprites?  (Read 28589 times)

0 Members and 2 Guests are viewing this topic.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Enlarging sprites?
« on: June 06, 2010, 11:43:58 am »
Is there a way to do it in Axe without losing resolution?
« Last Edit: June 06, 2010, 11:44:25 am by Raylin »
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Enlarging sprites?
« Reply #1 on: June 06, 2010, 12:25:50 pm »
What do you mean by enlarge? Draw a normally 8*8 sprite 16*16? You can't enlarge any image w/o losing resolution, though if you mean anti-aliasing it somewhat, you could write a program or do it by hand.
Sorry if that made no sense, I did the best I could considering I didn't completely understand you're question.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Enlarging sprites?
« Reply #2 on: June 06, 2010, 12:33:27 pm »
Basically.
Make an 8*8 sprite 16*16.

Or vice versa.
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Enlarging sprites?
« Reply #3 on: June 06, 2010, 12:38:02 pm »
I don't think there's an efficient, good-looking way to do it automatically. (Someone correct me if I'm wrong). If you just want to double the size of a sprite with no regard to de-pixelizing it, well, I can't think of an efficient way to do it. I'll think about it...
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Enlarging sprites?
« Reply #4 on: June 06, 2010, 03:51:01 pm »
the only way I can think about would be drawing the sprite on the buffer somewhere, and using pixel test to display it scaled up.

I think it would be very slow, though, especially if you want to draw an entire map or masked sprites

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Enlarging sprites?
« Reply #5 on: June 06, 2010, 03:51:42 pm »
Well the only way I can think of doing this is making a program that checks for a position of a pixel on one buffer and for ever pixel make a block of four pixels on the other buffer.

Example:

Code: [Select]
██
██

would be:
████
████
████
████

That's the only way I can think about. I don't have time to try and make a program in Axe for this right now but I can try later if no one else does. No idea if this helps though.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Enlarging sprites?
« Reply #6 on: June 06, 2010, 04:14:41 pm »
So we can't think of anything efficient. Does anyone know something that does it efficiently? (I'm asking our ASM experts here)
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Enlarging sprites?
« Reply #7 on: June 06, 2010, 04:24:32 pm »
Is it enlarging by 2 only? Then i can think of a way, let me pull something together...

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Enlarging sprites?
« Reply #8 on: June 06, 2010, 04:49:59 pm »
I would have given this a try, but given my recent Axe experiments, I seriously doubt I'll have any success getting anything to run at all

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Enlarging sprites?
« Reply #9 on: June 06, 2010, 05:14:26 pm »
I'm close to getting it to work. The result is just turning out skewed. I'll post the code to see if someone else can get it to work before me.

Got it to work!

Code: (x2 Magnification) [Select]
.TEST
ClrDraw
ClrDraw^r
[3C42A59999A5423C]→Pic1
[C0C0000000000000]→Pic2
Pt-On(0,0,Pic1)
DispGraph
0→C→D
For(A,0,7)
For(B,0,7)
If pxl-Test(B,A)
Pt-On(B+C+10,A+D,Pic2)
End
C+1→C
End
0→C+D+1→D
End
DispGraph^r

I realize some may not be optimized.

Note: Technically you don't have to use both buffers. I just did because it avoids colliding of pictures. It just depends where you want the end to display.

P.S. I would like to point out out the time when I made my first successful Axe program/routine ;D

Edit: If you want x8 magnification (like graphmastur did) you only have to make a few tweaks to my code. Once I figure it out you will be able to make any sized magnification with simple tweaks of mine, I just have to make sure I'm right.

Anywho, the tweak for x8.

-Change [C0C0000000000000]→Pic2 to [FFFFFFFFFFFFFFFF]→Pic2.
-Change Pt-On(B+C+10,A+D,Pic2) to Pt-On(B+C+17,A+D,Pic2).
-Change C+1→C to C+7→C.
-Change 0→C+D+1→D to 0→C+D+7→D.

Edit: Ok, so ya. This method does work with any level of magnification. (Well up to x8 since I use sprites to display the magnified version. You could do more if you started displaying multiple sprites for one magnified block.)

Here is what you do:

-You change the hex code into a block of either 1*1, 2*2, 3*3, 4*4, 5*5, 6*6, 7*7, or 8*8 (which ever level of magnification you want).
--x1: [8000000000000000]→Pic2
--x2: [C0C0000000000000]→Pic2
--x3: [E0E0E00000000000]→Pic2
--x4: [F0F0F0F000000000]→Pic2
--x5: [F8F8F8F8F8000000]→Pic2
--x6: [FCFCFCFCFCFC0000]→Pic2
--x7: [FEFEFEFEFEFEFE00]→Pic2
--x8: [FFFFFFFFFFFFFFFF]→Pic2
-Change the constant in the first part of the Pt-On( (that is in the For( loop) to 8+Level of Magnification+1.
--x1: Pt-On(B+C+10,A+D,Pic2)
--x2: Pt-On(B+C+11,A+D,Pic2)
--x3: Pt-On(B+C+12,A+D,Pic2)
--x4: Pt-On(B+C+13,A+D,Pic2)
--x5: Pt-On(B+C+14,A+D,Pic2)
--x6: Pt-On(B+C+15,A+D,Pic2)
--x7: Pt-On(B+C+16,A+D,Pic2)
--x8: Pt-On(B+C+17,A+D,Pic2)
-Change the constant that is added to the variable C to Level of Magnification-1.
--x1: C+0→C (Could technically take out at this point.)
--x2: C+1→C
--x3: C+2→C
--x4: C+3→C
--x5: C+4→C
--x6: C+5→C
--x7: C+6→C
--x8: C+7→C
-Change the constant that is added to the variable D to Level of Magnification-1.
--x1: 0→C+D+0→D (Can simplify to 0→C+D→D.)
--x2: 0→C+D+1→D
--x3: 0→C+D+2→D
--x4: 0→C+D+3→D
--x5: 0→C+D+4→D
--x6: 0→C+D+5→D
--x7: 0→C+D+6→D
--x8: 0→C+D+7→D

Example:

Code: (x6 Magnification) [Select]
.MAGX6
ClrDraw
ClrDraw^r
[3C42A59999A5423C]→Pic1
[FCFCFCFCFCFC0000]→Pic2
Pt-On(0,0,Pic1)
DispGraph
0→C→D
For(A,0,7)
For(B,0,7)
If pxl-Test(B,A)
Pt-On(B+C+15,A+D,Pic2)
End
C+5→C
End
0→C+D+5→D
End
DispGraph^r

I just realized that DispGraphr isn't technically used for displaying the back buffer (it works in this case though). Is there a command that does just display the back buffer? Or is DispGraphr used for this as long as it isn't in a loop?
« Last Edit: June 06, 2010, 08:29:12 pm by meishe91 »
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline BuckeyeDude

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 283
  • Rating: +42/-0
    • View Profile
Re: Enlarging sprites?
« Reply #10 on: June 06, 2010, 05:19:34 pm »
Even if you could do this, it probably wouldnt be a smart idea. Drawing anything takes a lot of time normally, and you will want to optimize it as much as possible. This is made even harder by the fact that it is stored as bits and not bytes. Much better to use the extra space and store the sprite blown up if you need that. This also lets you store extra detail instead of a blown up 8x8

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Enlarging sprites?
« Reply #11 on: June 06, 2010, 05:38:07 pm »
How about this for enlarging it 8 times.  Useful for editing I guess.  I did not use the back buffer at all.
Code: [Select]
ClrDraw
[C3A5555A242445AA5C3]->Pic1  // Your sprite
[0000000000000000]->Pic2
[FFFFFFFFFFFFFFFF]
For(A,0,7
{Pic1+A}->I
For(B,0,7
I^2->L
I/2->I
Pt-Off(8*(7-B),8*A,8*L+Pic2
End
End

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Enlarging sprites?
« Reply #12 on: June 06, 2010, 05:41:21 pm »
Pt-Off(8*(7-B),8*A,8*L+Pic2

To

Pt-Off(7-B*8,A*8,L*8+Pic2

For much faster/smaller optimization.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Enlarging sprites?
« Reply #13 on: June 06, 2010, 05:45:01 pm »
The trick when you just need 2x, 3x, 4x, 5x, up to 8x8, is to just use 8x8 sprites that contains square of those sizes (filled black) and use them instead of pixels. It's much faster than recalling each pixels one by one. It's much larger, though...

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Enlarging sprites?
« Reply #14 on: June 06, 2010, 05:46:34 pm »
True.  And this is for 8x8 to 16x16. with x,y location.
Code: [Select]
ClrDraw
[C3A5555A242445AA5C3]->Pic1  // Your sprite
[0000000000000000]->Pic2
[FFFFFFFFFFFFFFFF]
For(A,0,7
{Pic1+A}->I
For(B,0,7
I^2->L
I/2->I
For(C,0,1):For(D,0,1)
if L
Pxl-On(7-B*2+D+Y,2*A+C+x
else
Pxl-Off(7-B*2+D+y,2*A+C+x
End
End:End
End
End

How's that?