Author Topic: Tilemap scrolling  (Read 8634 times)

0 Members and 1 Guest are viewing this topic.

Offline MRide

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 711
  • Rating: +14/-0
  • You can't see this.
    • View Profile
Re: Tilemap scrolling
« Reply #15 on: July 30, 2010, 04:03:02 pm »
the subroutine GN definitely returns a 0 or a 1, based on the tile in the tilemap. could you post some code? and yes, the way grayscale is made is turning pixels on and off very quickly. so when you do DispGraphr, you actually turn on a checkerboard pattern on the backbuffer, and then the next time you call it the checkerboard pattern is shifted, making the appearance of gray. you probably see the checkerboard because the screen is not updating quickly enough. you could put an If getKey(0) around the part where you draw the tilemap to remedy this.

Won't this ruin the grayscale when you try to move, though?

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Tilemap scrolling
« Reply #16 on: July 30, 2010, 04:34:45 pm »
for a frame,  yes. quigibo already gave a better fix with the pause command.


Offline MRide

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 711
  • Rating: +14/-0
  • You can't see this.
    • View Profile
Re: Tilemap scrolling
« Reply #17 on: July 30, 2010, 06:07:59 pm »
GN does not explicitly return 1 or 0, it returns the half byte tile 0-F (0-15 in decimal).  Although personally, I don't like that routine since there is no X and Y its usage is confusing.

If you want a solid gameboy gray, you have to turn interrupts off for the entire code and you also need to make sure to adjust the pause time in between each DispGraph to the perfect amount.  It will take some tuning since every display is different unfortunately.  For me, I have a TI-84 Plus K-0108H and my perfect gray setting is this:

Code: [Select]
:FnOff
:Repeat getkey(15)
:
:Pause 7           ;Long pause
:For(A,0,15):End   ;Fine tuning
:
:DispGraphr
:End

By perfect, I mean like a gameboy, not even one of those slowly scanning lines that moves diagonally from one side to the other, I mean literal gray.  The pause times will of course have to be different depending on how much other code you have in your loop.

Hmm... If I use this without the If getKey(0), then it doesn't update fast enough.
Here is the code:
Code: [Select]
:.ATILMAP
:[11111111111111111111→GDB1
:[10001000000000000001
:[10000100000000000001
:[10000001000000000001
:[10000000001000000001
:[10001000000000000001
:[10000010000000000001
:[10000000000000000001
:[10010000000000000001
:[10100000000000000001
:[10000000000000000101
:[11111111111111111111
:[55AA55AA55AA55AA→Pic1
:[FFFFFFFFFFFFFFFF
:0→S→D
:ClrDraw
:ClrDrawr
:Shade(48)
:FnOff
:Repeat getKey(15)
:If D<80 and getKey(1)
:20+D→D
:End
:If D≠0 and getKey(4)
:D-20→D
:End
:S<8 and getKey(3)-(S≠0 and getKey(2))+S→S
:Pause 7
:sub(DS)
:DispGraphr
:End
:Return
:.Drawing sub
:Lbl DS
:ClrDraw
:ClrDrawr
:For(Y,0,7)
:For(X,0,11)
:sub(GN,Y*20+X+D+S)→W
:!If W
:Pt-Off(X*8,Y*8,sub(GN,Y*20+X+D+S)*8+Pic1)
:End
:Pt-Off(X*8,Y*8,sub(GN,Y*20+X+D+S)*8+Pic1)r
:End
:End
:.Extraction
:Lbl GN
:{r1/2+GDB1}→A
:If r1^2
:A^16:Else
:A/16:End

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Tilemap scrolling
« Reply #18 on: July 30, 2010, 06:31:09 pm »
You don't need that pause 7 there anymore.  That was only there originally because I didn't have enough pause in the example I gave.  Your drawing routine plus everything else in the loop already has a huge pause, probably longer than a pause 7 so you don't need that extra pausing since its just slowing it down.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline MRide

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 711
  • Rating: +14/-0
  • You can't see this.
    • View Profile
Re: Tilemap scrolling
« Reply #19 on: July 30, 2010, 07:50:30 pm »
Even if I remove the Pause 7, It still updates too slowly.  Is there a way to speed it up?

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Tilemap scrolling
« Reply #20 on: July 30, 2010, 07:57:19 pm »
You can put your sub(DS) in full speed mode.  Just add a :Full to the start of that subroutine and a :Normal at the end of it.  By the way, I just noticed you don't have a return at the end of it so its falling through to the next subroutine and returning after that.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline MRide

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 711
  • Rating: +14/-0
  • You can't see this.
    • View Profile
Re: Tilemap scrolling
« Reply #21 on: July 30, 2010, 09:10:22 pm »
Thanks.  would it be any faster to put the getkey tests inside one if statement. and put the rest of the repeat loop (except the DispGraphr) in Full Mode?

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Tilemap scrolling
« Reply #22 on: July 30, 2010, 09:23:25 pm »
The getkey's have to be in Normal speed otherwise they sometimes don't register the correct keys.  Your DS routine is taking up 99% of the CPU anyway so the other stuff is a negligible speed difference.  Don't forget, Full speed is not available for the regular TI-83+ which would still run at Normal speed after that command.  So your program won't be the same quality with that calculator.
___Axe_Parser___
Today the calculator, tomorrow the world!