Omnimaga

Calculator Community => Major Community Projects => The Axe Parser Project => Topic started by: souvik1997 on February 17, 2011, 10:35:13 pm

Title: 16x16 sprite drawing routine request
Post by: souvik1997 on February 17, 2011, 10:35:13 pm
Could someone please write a routine to draw 16x16 sprites? It should accept arguments like sub(SPR,XCoord,YCoord,Pointer).
Title: Re: 16x16 sprite drawing routine request
Post by: Runer112 on February 17, 2011, 10:46:03 pm
The easiest thing to do is just to store the 16x16 sprites as 4 individual 8x8 sprites, as Axe has no built-in 16x16 sprite drawing capabilities. You would then store the 4 individual sprites in memory with the top left corner first, then the top right corner, then the bottom left corner, and finally the bottom right corner. You could then draw the whole sprite with something like the following:

Code: [Select]
Lbl SPR
  Pt-On(r₁,r₂,r₃)
  Pt-On(r₁+8,r₂,r₃+8)
  Pt-On(r₁,r₂+8→r₂,r₃+16)
  Pt-On(r₁+8,r₂,r₃+24)
Return
Title: Re: 16x16 sprite drawing routine request
Post by: aeTIos on February 26, 2011, 08:51:01 am
Just use Bitmap(. Doesn't work in apps, though.
Syntaxis:
Code: [Select]
[heightinhex,widthinhex,hexcode->pic1
bitmap(xpos,ypos,pic1
So for a 16x16 sprite:
Code: [Select]
[1010hexcode]->pic1
bitmap(0,0,pic1
If you want to draw an 8x8 sprite too, put fix9 at the start and fix 8 at the end of your program
NOTE: you cant draw bitmap('s offscreen. if you do, you get a BSOD. (just pull a battery, but you know this, I think ;D)

I have an sprite editor that gives the hex, i'll upload it.
I lost...
Title: Re: 16x16 sprite drawing routine request
Post by: Builderboy on February 26, 2011, 02:31:06 pm
I would recomend staying away from bitmaps for 16x16 personally, since the routine is an OS routine, its incredibly slow.  Using 4 Pt-On commands like runner suggested would be a lot faster.  Bitmaps would be easier however.  So whatever your needs are, speed or ease of use, you can choose :)
Title: Re: 16x16 sprite drawing routine request
Post by: Juju on February 26, 2011, 03:06:26 pm
Yeah, that's what I did yesterday, I stored my 16x16 sprite as 4 8x8 sprites and used 4 Pt-On commands.

Code: [Select]
[hexcode]->Pic1A
[hexcode]->Pic1B
[hexcode]->Pic1C
[hexcode]->Pic1D
Pt-On(A,B,Pic1A)
Pt-On(A+8,B,Pic1B)
Pt-On(A,B+8,Pic1C)
Pt-On(A+8,B+8,Pic1D)

Then I would convert this code to make use of routines and I would get something like Runer112's code.