Author Topic: Smooth Scrolling Tilemapper  (Read 20196 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
Smooth Scrolling Tilemapper
« on: June 21, 2010, 05:20:32 am »
Well, so I have been trying some things with axe now (RAM clear every 2 minutes ftw  ;D)
And I came up with a scrolling tilemapper, which speed I think is fair.

I think it can be optimized in some ways, but I can't find any more ways.

P.S. I wanted to make a GIF for demonstration, but after loading the ROM with wabbitemu, nothing happens.

Edit: Uploaded the optimized version
« Last Edit: September 08, 2010, 03:16:59 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 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: Scrolling Tilemapper
« Reply #1 on: June 21, 2010, 05:48:25 am »
Awesome!  The code seems fairly simple.  As far as optimizations, one thing that stuck out at me was that you were using X-(X/8*8) to do what is more simply just X^8.  Same for Y.  Also, you store the pointer to the sprite in P but only use it once.  You can just put that whole expression where P is so that way you don't have to store and load to it.  Its more convenient for the programmer too when you use less variables.  Nice job again!
« Last Edit: June 21, 2010, 05:50:55 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: Scrolling Tilemapper
« Reply #2 on: June 21, 2010, 06:41:43 am »
I don't see why you're doing X^8
Code: [Select]
X/8->N
X-(N*8)->I    <-- The N given here is already rounded since axe doesn't support floating numbers, which im using in my advantage.
My guess is that X^8 would give all the wrong calculations,
N is my offset where to start drawing, where I would position it.

Could you please explain why you'd do that?

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 Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Scrolling Tilemapper
« Reply #3 on: June 21, 2010, 08:33:04 am »
Both X^8 and X-(N*8 ) come up with the same answer. X^8 is an optimization of what you have already. It's not changing the answer in any way.
If you didn't know already, Axe uses ^ as modulus instead of the normal 'to the power of...'
If you don't quite understand modulus, maybe this will help:

Say X is 25
(25)/8=3.125  (the decimal/remainder is dropped. No floating numbers here.)
(25)-[(3)*8]=1
Now using modulus
(25)^8=1 (25/8 is 3r1. Division takes the whole number while modulus takes the remainder.)

Lets try again with 39.
(39)/8=4r7(remember to drop the remainder for division)
(39)-[(4)*8]=7
Back to modulus
(39)^8=7 (4r7, whole number is dropped.)

Hope this explains to you what he's talking about.
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: Smooth Scrolling Tilemapper
« Reply #4 on: June 21, 2010, 08:36:35 am »
Well, I don't really understand it, but il just use it.

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 Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Smooth Scrolling Tilemapper
« Reply #5 on: June 21, 2010, 09:01:44 am »
Oh, I totally forgot to actually look at the program.  :P

...

Ok, I'm back. Looks nice. I'm sure this will help somebody out.

I think that this:
Code: [Select]
:If X≠64 and getKey(3)
:X+1→X
:End
:If X≠0 and getKey(2)
:X-1→X
:End

can be shortened to this:
Code: [Select]
:If X and (X≠64
:X+getkey(3)-Getkey(2)→X

Oh, another tiny optimization you can use is remove the Return at the bottom. Once it hits the bottom of your code, there is an implied Return.
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: Smooth Scrolling Tilemapper
« Reply #6 on: June 21, 2010, 09:06:55 am »
Those getkey things won't work, I need seperate checks.

And the bottom return, its part of a subroutine, u sure its safe to remove?
« Last Edit: June 21, 2010, 09:27:27 am 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 calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Smooth Scrolling Tilemapper
« Reply #7 on: June 21, 2010, 09:22:38 am »
Already got this in my own calc version:
Code: [Select]
:If X≠64 and X
:X+getkey(3)-Getkey(2)→X
:End
But can't get it to work.

And the bottom return, its part of a subroutine, u sure its safe to remove?
This is because the "and" is bitwise, not logical. This is why I wanted Quigibo to support logical and,or,xor statements...
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Smooth Scrolling Tilemapper
« Reply #8 on: June 21, 2010, 09:30:16 am »
Oh, and here I was thinking it was already supported.  :P
Guess I'll have to wait until he implements that.

From the Axe documentation:
'If the last line of your program is Return, then remove it. Even if it was part of a
subroutine, the return is automatically added at the end for you so there's no need to
have 2 returns at the end. Saves 1 byte.'

EDIT:100th post. Wee!  ;D
« Last Edit: June 21, 2010, 09:31:00 am by Magic Banana »
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: Smooth Scrolling Tilemapper
« Reply #9 on: June 21, 2010, 09:41:47 am »
Instead, I did this:
Code: [Select]
X-(X≠0 and getKey(2))+(X≠64 and getKey(3))→X

Which works.

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 Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Smooth Scrolling Tilemapper
« Reply #10 on: June 21, 2010, 09:57:14 am »
Awesome! Good to see that you worked it through. :)
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

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: Smooth Scrolling Tilemapper
« Reply #11 on: June 21, 2010, 09:57:42 am »
Here's a gif, for anyone who wants to see it.


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.

SirCmpwn

  • Guest
Re: Smooth Scrolling Tilemapper
« Reply #12 on: June 21, 2010, 09:58:30 am »
Nice, Ikkerens!

Offline Ikkerens

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 378
  • Rating: +28/-9
  • JavaScript Magician
    • View Profile
    • Walotech
Re: Smooth Scrolling Tilemapper
« Reply #13 on: June 21, 2010, 10:00:24 am »
Here's a gif, for anyone who wants to see it.

Alot more fluid on calc tho.

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 ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Smooth Scrolling Tilemapper
« Reply #14 on: June 21, 2010, 11:45:35 am »
Nice, Ikkerens!  Excellent job! ;D