Author Topic: Full-Byte Tilemapping  (Read 5428 times)

0 Members and 3 Guests are viewing this topic.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Full-Byte Tilemapping
« on: February 13, 2011, 11:28:46 pm »
How come this code doesn't work for a 18 by 12 tilemap?

Lbl MAP
ClrDraw
For(Y,0,11
For(X,0,17
{Y*18+X+L}->A
Pt-On(X*5,Y*5,A*16+Pic1)
End
End
StorePic
Return
In-progress: Graviter (...)

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Full-Byte Tilemapping
« Reply #1 on: February 13, 2011, 11:49:10 pm »
Try putting in a dispgraph? (if the problem is it isn't showing anything)
It looks fine to me...
Hex pics are 8 bytes.  So, unless they're two-frame animated or something, it would be A*8+Pic1.
« Last Edit: February 13, 2011, 11:49:46 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Full-Byte Tilemapping
« Reply #2 on: February 13, 2011, 11:54:45 pm »
No, I already have a dispgraph. And the *16 is because i'm using SirCmpwn's sprite editor, which uses greyscale tiles (two *8) which I usually up ending up removing at the end.

But it's not working, oddly enough. I'll check my level data and get back to you.
In-progress: Graviter (...)

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Full-Byte Tilemapping
« Reply #3 on: February 14, 2011, 12:03:35 am »
I'm assuming it's 5*5 tiles, and that symbol is L1.
Or whatever list you're using.
« Last Edit: February 14, 2011, 12:03:59 am by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Full-Byte Tilemapping
« Reply #4 on: February 14, 2011, 12:54:09 am »
your X and Y are switched in the {} section.

here's how i would write this bit of code
:ClrDraw
:19While -1->X
:13While -1->Y
:Pt-On(X*5,Y*5,{X-1*18+Y-1+L1}*16+Pic1
:XEnd
:YEnd
:StorePic
:Return

EDIT: this time the code should actually work (although you should look below for runer's faster method)
« Last Edit: February 14, 2011, 01:44:37 am by shmibs »

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Full-Byte Tilemapping
« Reply #5 on: February 14, 2011, 01:00:19 am »
Shmibs, I think you are mixed up?  I guess it depends on how his tilemap data is read.  From the top left going to the right and down, or from top left going down and then right.

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Full-Byte Tilemapping
« Reply #6 on: February 14, 2011, 01:07:34 am »
herp-a-derp :P
post edited because i made the same mistake he did(although in a different spot).
thanks, builder

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Full-Byte Tilemapping
« Reply #7 on: February 14, 2011, 01:10:27 am »
X*18+Y

I was talking about this part ;)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Full-Byte Tilemapping
« Reply #8 on: February 14, 2011, 01:35:30 am »
By the way, loops like these:
:18While -1->X
:12While -1->Y

Will break as soon as the variable becomes 0, so a row and column of sprites would be missing.

Also, you using Pt-Off() to draw a 5*5 tilemap could (in this case will) overwrite already drawn tiles as it draws other tiles, so it's best (and faster anyways) to use Pt-On().


Here's the code I would use. It's size-optimized, but is still also quite speed-optimized, too.

Code: [Select]
Lbl MAP
  ClrDraw
  12*18+L₁→Z
  12*256
  Repeat 0
    -256→Y
    18
    Repeat 0
      -1→X
      Pt-On(*5,{°Y+1}ʳ*5,{Z-1→Z}*16+Pic1)
    End!If X
  End!If Y
  StorePic
Return

EDIT: 432 cycles saved with some pretty sweet high/low byte abuse of Y.
« Last Edit: February 14, 2011, 01:52:11 am by Runer112 »

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Full-Byte Tilemapping
« Reply #9 on: February 14, 2011, 01:36:52 am »
If you assume a non scrolling tilemap couldn't you just use a single variable for tilemap offset and increment it?  No multiplication needed.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Full-Byte Tilemapping
« Reply #10 on: February 14, 2011, 01:40:27 am »
I was thinking about that, but for some reason I thought it was a scrolling tilemapper and that that wouldn't work. But you're right, that's smaller and faster, so I've adjusted my code for that.