Author Topic: Smoothscrolling tilemapper  (Read 35668 times)

0 Members and 2 Guests are viewing this topic.

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: Smoothscrolling tilemapper
« Reply #75 on: November 11, 2010, 05:56:46 pm »
Do you mean like parralax scrolling? I kinda used such stuff in Supersonic Ball, although it's more basic.

Offline Ti-DkS

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 143
  • Rating: +21/-1
  • In retro, we trust !
    • View Profile
Re: Smoothscrolling tilemapper
« Reply #76 on: November 12, 2010, 02:32:04 am »
Yeah, it is that ! The tilemapper redraws the whole screen then it draws the background which scrolls 2 times slower using the "vertical" and "horizontal" method :)

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: Smoothscrolling tilemapper
« Reply #77 on: November 12, 2010, 04:04:39 am »
Ah nice. Also if your background is repeating vertically you can simply fill the first row of the screen with 8x8 tiles then use the copy command over the rest of the screen. It speeds things up a lot compared to when you just fill the screen with the tiles.

Offline Ti-DkS

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 143
  • Rating: +21/-1
  • In retro, we trust !
    • View Profile
Re: Smoothscrolling tilemapper
« Reply #78 on: November 12, 2010, 12:05:09 pm »
Yeah, it is a good idea !! I hadn't thought of it :)
But there is a thing I don't understand : how do you draw characters and ennemies on a tilemapper which uses "vertical"/"horizontal" commands without using the back buffer ?
« Last Edit: November 12, 2010, 03:22:38 pm by Ti-DkS »

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: Smoothscrolling tilemapper
« Reply #79 on: November 13, 2010, 12:58:01 am »
Hmm I'm not sure how to do that without using the back buffer. I think you need to redraw the tiles around the enemies to hide those enemies, scroll, then redraw the enemies. That may be complicated, though. The only other solution  is to redraw the tilemapper every frame. You could use another memory location and store a copy of the buffer (before drawing the enemies) there, then when it comes times to scroll, you display that copy on the screen, erasing the enemies in the process, scroll, then display the enemies.

Offline Ti-DkS

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 143
  • Rating: +21/-1
  • In retro, we trust !
    • View Profile
Re: Smoothscrolling tilemapper
« Reply #80 on: November 13, 2010, 11:53:21 am »
Okay ! It's why I think a tilemapper wich redraws the whole screen every frame is better for the main buffer, and a tilemapper with vert/hor commands for the background :) It is what I use for my Metroid :D

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Re: Smoothscrolling tilemapper
« Reply #81 on: November 13, 2010, 12:40:27 pm »
Hmm I'm not sure how to do that without using the back buffer. I think you need to redraw the tiles around the enemies to hide those enemies, scroll, then redraw the enemies. That may be complicated, though. The only other solution  is to redraw the tilemapper every frame. You could use another memory location and store a copy of the buffer (before drawing the enemies) there, then when it comes times to scroll, you display that copy on the screen, erasing the enemies in the process, scroll, then display the enemies.
I actually tried that, and I modified Runer's tilemapper to use 4 lvl greyscale and draw a character over the fore-ground, and it works pretty well.

What I did was copy both buffers from an appvar before moving, scrolled and stored the buffers to the appvar, then drew the player.

Here's the code:
Code: [Select]
:.TILEMAPR
:prgmSERENA
:.TILEMAP
:[]→GDB0M
:det(1024)
:
:.TILES
:[]→GDB0T
:det(504)
:GetCalc("vSMBuff",1536)→B
:
:.CREATE TILEMAP
:GDB0M-1→D
:0→Y
:While -32
:  0→X
:  While -32
:    X+Y→{D+1→D}
:    X+1→X
:  End
:  Y+1→Y
:End
:
:.CREATE TILES
:Fix 5
:ClrDraw
:EF0→{L6}r→{L6+12}r
:GDB0T-1→D
:0→Z→θ-1
:While Z*10+θ-63
:  Fix 3
:  E0200→{E86D7}r
:  DrawF Z►Dec
:  Fix 2
:  E0204→{E86D7}r
:  DrawF θ►Dec
:  0→Y
:  While -8
:    {Y*12+L6}→{D+1→D}
:    Y+1→Y
:  End
:  !If θ+1→θ-10
:    →θ
:    Z+1→Z
:  End
:End
:Fix 4
:
:.DRAW INITIAL IMAGE
:GDB0M-1→D
:0→Y
:While -64
:  0→X
:  While -96
:    Pt-Off(X,Y,{D+1→D}*8+GDB0T)r
:    X+8→X
:  End
:  D+20→D
:  Y+8→Y
:End
:conj(L6,B,768
:conj(L3,B+768,768
:
:.INITIALIZE POSITION VARIABLES
:0→X→Y→Z→θ→D
:
:
:.MAIN LOOP
:FnInt(DG,2)
:Repeat getKey(15)
:
:  .MOVE DOWN
:  If Y-24
:    FnOff
:    If getKey(1) and (D=1
:conj(B,L6,768
:conj(B+768,L3,768
:      θ-1→θ
:      Vertical -
:      Vertical -r
:      Y+8*32+X-1+GDB0M→r5
:      0→r6
:      While -104
:        Pt-Off(r6+Z,θ+64,{r5+1→r5}*8+GDB0T)r
:        r6+8→r6
:      End
:      !If θ+8
:        →θ
:        Y+1→Y
:      End
:conj(L6,B,768
:conj(L3,B+768,768
:sub(SM)
:    End
:    FnOn
:  End
:
:  .MOVE LEFT
:  If X-Z
:    FnOff
:    If getKey(2) and (D=2
:conj(B,L6,768
:conj(B+768,L3,768
:      Z+1→Z
:      Horizontal(+
:      Horizontal(+r
:      Y-1*32+X+GDB0M→r5
:      0→r6
:      While -72
:        Pt-Off(Z,r6+θ,{r5+32→r5}*8+GDB0T)r
:        r6+8→r6
:      End
:      !If Z-1
:        ‾7→Z
:        X-1→X
:      End
:conj(L6,B,768
:conj(L3,B+768,768
:sub(SM)
:    End
:    FnOn
:  End
:
:  .MOVE RIGHT
:  If X-20
:    FnOff
:    If getKey(3) and (D=3
:conj(B,L6,768
:conj(B+768,L3,768
:      Z-1→Z
:      Horizontal(-
:      Horizontal(-r
:      Y-1*32+X+12+GDB0M→r5
:      0→r6
:      While -72
:        Pt-Off(Z+96,r6+θ,{r5+32→r5}*8+GDB0T)r
:        r6+8→r6
:      End
:      !If Z+8
:        →Z
:        X+1→X
:      End
:conj(L6,B,768
:conj(L3,B+768,768
:sub(SM)
:    End
:    FnOn
:  End
:
:  .MOVE UP
:  If Y-θ
:    FnOff
:    If getKey(4) and (D=4
:conj(B,L6,768
:conj(B+768,L3,768
:      θ+1→θ
:      Vertical +
:      Vertical +r
:      Y*32+X-1+GDB0M→r5
:      0→r6
:      While -104
:        Pt-Off(r6+Z,θ,{r5+1→r5}*8+GDB0T)r
:        r6+8→r6
:      End
:      !If θ-1
:        ‾7→θ
:        Y-1→Y
:      End
:conj(L6,B,768
:conj(L3,B+768,768
:sub(SM)
:    End
:    FnOn
:  End
:0→D
:If getKey(1) and (D=0
:1→D
:End
:If getKey(2) and (D=0
:2→D
:End
:If getKey(3) and (D=0
:3→D
:End
:If getKey(4) and (D=0
:4→D
:End
:End
:LnReg
:Return
:
:  .COPY IMAGE TO SCREEN
:Lbl SM
:0→D
:For(A,12,44
:For(C,36,52
:Pt-Off(C,A,D+Pic1S
:Pt-Off(C,A,D+8+Pic1S)r
:D+16→D
:C+7→C
:End
:A+7→A
:End
:Return
:
:Lbl DG
:Normal
:DispGraphrr
:Full
:Return
:
:.VARIABLES
:.D=Data pointer
:.X=X position in tilemap of top-left corner (0-20)
:.Y=Y position in tilemap of top-left corner (0-24)
:.Z=X offset of top-left corner (0-‾7)
:.θ=Y offset of top-left corner (0-‾7)
prgmSERENA holds the data for the sprite. I just grabbed a sprite from my computer and it turned out to be a Sailor Moon sprite.
Programs attached.


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

Offline Ti-DkS

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 143
  • Rating: +21/-1
  • In retro, we trust !
    • View Profile
Re: Smoothscrolling tilemapper
« Reply #82 on: November 13, 2010, 03:46:27 pm »
amazing engine :) Very nice job !!
« Last Edit: November 14, 2010, 10:44:30 am by Ti-DkS »

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: Smoothscrolling tilemapper
« Reply #83 on: November 14, 2010, 04:57:22 am »
Could you clarify what the code does? Does it do the first thing I said, does it do the second or does it do the last?

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Re: Smoothscrolling tilemapper
« Reply #84 on: November 14, 2010, 10:44:40 am »
Could you clarify what the code does? Does it do the first thing I said, does it do the second or does it do the last?
The last thing you said.


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

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: Smoothscrolling tilemapper
« Reply #85 on: November 14, 2010, 01:34:25 pm »
Ah ok thanks :)

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Smoothscrolling tilemapper
« Reply #86 on: November 15, 2010, 07:06:36 am »
Are byte-based tilemappers faster than nibble-based mappers?

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: Smoothscrolling tilemapper
« Reply #87 on: November 15, 2010, 11:57:00 am »
From what I remember, they were, but with the arrival of nibble commands in Axe, I wonder if this changed?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Smoothscrolling tilemapper
« Reply #88 on: November 15, 2010, 02:05:40 pm »
Its probably a bit slower and larger, but with the size advantage it is pretty significant ^^

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Smoothscrolling tilemapper
« Reply #89 on: November 15, 2010, 02:11:22 pm »
My problem is that I'm actually thinking about sacrificing the +100% in data size in exchange for the small amount of speed and executable size gain. It would also make my code a bit more flexible too, so I'm not sure :P