Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Ikkerens on October 07, 2010, 01:55:20 pm
-
Well, I've been trying to create this sprite editor.
(I failed at my attempt to export sprite data from runer's sprite editor)
Anyway, here's the code
:.SPREDIT Euh...
:GetCalc("Pic5")→P
:0→C
:ClrDraw
:ClrDrawr
:[FFFFFFFFFFFFFFFF]→Pic0
:.Main Loop
:sub(UI)
:Repeat getKey(15)
:DispGraphrr
:End
:Return
:.UI Sub
:Lbl UI
:Line(64,0,64,64)
:StorePic
:Pt-Off(72,48,C*16+P)
:Pt-Off(72,48,C*16+8+P)r
Well, then I've got this picture (pic5) which has 2 sprites, one at 0,0 and one at 8,0, the front buffer and the back buffer respectively.
But when the program is loaded, the picture looks all scrambled.
Am I doing anything wrong here?
-
The problem is that sprite data isn't stored in succession in picture variables. Picture variables store data line by line, with each line being 12 bytes. Each byte of an 8x8 sprite is on a different line, so there's a separation of 11 bytes between each byte of the sprite (as opposed to 0, which is what you want for sprite routines like Pt-Off).
Say your sprite was just a filled square. It's data would be [FFFFFFFFFFFFFFFF]. But when displayed in a picture variable, the data would look like this:
FF | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
FF | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
FF | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
FF | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
FF | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
FF | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
FF | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
FF | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 | 00 |
... 64 rows
This gives 11 bytes of non-sprite data on each row, resulting in 11 bytes of space between each byte in the sprite.
-
Allright, thx.
Just have to write a little routine to read/store it that way then.
-
You know there is a default command to turn pic data into sprite data right?
[Pic#r]->Str1
:D Unfortunately this only works on compile time and does not work with the picture variable directly during run time :(
-
I know about that, but I really want it to be read/stored into actual PicX files
-
Btw it's pretty hard to do stuff that isn't lined up conveniently x.x