Author Topic: I'm doing something wrong (I think)  (Read 11702 times)

0 Members and 1 Guest are viewing this topic.

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
I'm doing something wrong (I think)
« 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
Code: [Select]
:.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?
« Last Edit: October 07, 2010, 02:01:46 pm by Ikkerens »

Splut for Android [----------]
Paused/halted indefinitely, might be abandoned, our graphic designer quit and the rest of us simply doesn't have the time to work on it...

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: I'm doing something wrong (I think)
« Reply #1 on: October 07, 2010, 03:01:09 pm »
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:


FF0000000000000000000000
FF0000000000000000000000
FF0000000000000000000000
FF0000000000000000000000
FF0000000000000000000000
FF0000000000000000000000
FF0000000000000000000000
FF0000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
... 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.
« Last Edit: October 07, 2010, 03:09:35 pm by Runer112 »

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: I'm doing something wrong (I think)
« Reply #2 on: October 07, 2010, 03:35:17 pm »
Allright, thx.
Just have to write a little routine to read/store it that way then.

Splut for Android [----------]
Paused/halted indefinitely, might be abandoned, our graphic designer quit and the rest of us simply doesn't have the time to work on it...

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: I'm doing something wrong (I think)
« Reply #3 on: October 07, 2010, 04:28:22 pm »
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 :(

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: I'm doing something wrong (I think)
« Reply #4 on: October 07, 2010, 04:36:57 pm »
I know about that, but I really want it to be read/stored into actual PicX files

Splut for Android [----------]
Paused/halted indefinitely, might be abandoned, our graphic designer quit and the rest of us simply doesn't have the time to work on it...

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: I'm doing something wrong (I think)
« Reply #5 on: October 07, 2010, 08:00:13 pm »
Btw it's pretty hard to do stuff that isn't lined up conveniently x.x