Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Builderboy on November 05, 2010, 06:17:00 pm

Title: Smoothscrolling tilemapper
Post by: Builderboy on November 05, 2010, 06:17:00 pm
So one thing i have noticed in Axe is that smoothscrolling tilemappers tend to be fairly slow.  Slower that is than asm by far for some reason.  SO i am creating this thread for people to post their best efforts at making a smoothscrolling tilemapper.  Post the engines constraints, speed (frames per second) and any other facts.

Note that when measuring tilemapper framerate, have the tilemapper scroll in both directions so that allignment doesn't throw the readings off.

Here is my current fastest tilemapper stats:
12 frames per second
does *NOT* redraw screen every frame
Max of 4 pixels scrolling per frame

i'll upload the engine in a bit
Title: Re: Smoothscrolling tilemapper
Post by: ASHBAD_ALVIN on November 05, 2010, 06:17:55 pm
my best effort was lower than that, maybe I'll post it later :P
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 05, 2010, 06:20:19 pm
I actually never managed to make a proper one X.x

It would be nice if it was possible to have one that runs fast enough for something like Metroid or even Sonic at regular 83+ speed.
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 05, 2010, 06:22:07 pm
Wait didn't you make a smoothscrolling parallax scrolling mapper for your ball game? o.O
Title: Re: Smoothscrolling tilemapper
Post by: meishe91 on November 05, 2010, 06:25:40 pm
How do you measure frames-per-second anyways? I never really understood that.
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 05, 2010, 06:36:42 pm
The way i do it is have the engine quit after 500 frames or so, and start a timer right when i start the program.  When the program ends, i stop the timer.  Divide the 500 by the time and you have frames per second :D You can have an on screen counter of the frames as well, but then it lowers your framerate a bit too.
Title: Re: Smoothscrolling tilemapper
Post by: ASHBAD_ALVIN on November 05, 2010, 06:38:04 pm
just tried that with my old SOLDAT engine (from the summer, never really got far) and got ~11 FPS. :P
Title: Re: Smoothscrolling tilemapper
Post by: meishe91 on November 05, 2010, 06:39:41 pm
The way i do it is have the engine quit after 500 frames or so, and start a timer right when i start the program.  When the program ends, i stop the timer.  Divide the 500 by the time and you have frames per second :D You can have an on screen counter of the frames as well, but then it lowers your framerate a bit too.

Ah ok, never thought of that. Thanks :)
Title: Re: Smoothscrolling tilemapper
Post by: shmibs on November 05, 2010, 06:43:39 pm
sweet!
after a couple of tests, i've gotten
13.8 fps
consistently, and that's with some basic acceleration code included(as well as the engine itself being horribly messy because i was experimenting whilst writing it.)
this does not update the entire screen, can handle 256 tiles, and can jump1-8 pixels at a time
EDIT: oh right. this is at 6mhz
Title: Re: Smoothscrolling tilemapper
Post by: AngelFish on November 05, 2010, 06:44:08 pm
The way i do it is have the engine quit after 500 frames or so, and start a timer right when i start the program.  When the program ends, i stop the timer.  Divide the 500 by the time and you have frames per second :D You can have an on screen counter of the frames as well, but then it lowers your framerate a bit too.

<10 for Battle
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 05, 2010, 06:46:45 pm
thats awesome everybody :D shmibs looks like he is the current leader with 13.8 FPS :) I assume you incorporate screenshifting and filling in of edges like mine?
Title: Re: Smoothscrolling tilemapper
Post by: shmibs on November 05, 2010, 06:49:22 pm
/\yup(so vertical scrolling has to draw 26 sprites altogether o_0)
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 05, 2010, 06:52:51 pm
Huh, my engine has to draw 22 sprites max, no matter the scrolling direction o.O
Title: Re: Smoothscrolling tilemapper
Post by: shmibs on November 05, 2010, 06:57:50 pm
yeah, because(like i said) this has to draw two rows per direction(meaning my max is 44)
hopefully i'll be able to fix that.

also: i tested a more updated version with a basic character made of 4 or'd sprites and collision detection. it was a bit harder to get decent data from, but i'm seeing around 11.5 fps
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 05, 2010, 07:03:10 pm
Ooh i see what you mean, yeah i only draw in the direction the tilemap is moving.  Yours must be a lot more optimized then to get so much more speed than mine, its displaying twice as many sprites ;D Imagine when its only half O.O
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 05, 2010, 08:16:19 pm
Wait didn't you make a smoothscrolling parallax scrolling mapper for your ball game? o.O
Yeah but that isn't a real tilemapper. It's like two rows of tiles displayed at specific locations, not a full grid-based tilemapper.
Title: Re: Smoothscrolling tilemapper
Post by: squidgetx on November 06, 2010, 11:45:13 am
Ouch, the one I'm using for A:P is only 8 fps. Does not redraw every frame, walking up/down is slightly slower than right/left. But mine also uses 12x12 masked grayscale tiles..so that means it's drawing 64 masked tiles per frame walking up and 56 when walking side to side x.x
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 07, 2010, 01:08:42 am
Oh btw, I forgot to specify something, the thing Supersonic Ball to draw stuff that looks like a tilemap draws 65 tiles per frame.

1) The background (Parralax scrolling) is made of 13 tiles, which are copied on the rest of the screen with Copy() to save a considerable amount of time.
2) The ceiling, made of 26 tiles, 13 of which are always plain black, drawn on the back buffer, for collision detection.
3) The floor (same way) :P
Title: Re: Smoothscrolling tilemapper
Post by: squidgetx on November 07, 2010, 05:22:50 pm
Come to think of it, 8 fps is quite nice with having to draw over 50 tiles per frame with Pt-Mask() as opposed to Pt-On() or Pt-Off() and with 3lvl gray. Maybe I should try regular 8x8 monochrome and see how fast it gets :P
Title: Re: Smoothscrolling tilemapper
Post by: Runer112 on November 07, 2010, 05:46:19 pm
Regular 8x8 monochrome seems to work pretty fast for me. I get about 60 fps scrolling for the most part (about 75 for aligned vertical scrolling). The screen is updated after every arrow key has been checked and the buffer image has been scrolled for each pressed key.

The screenshot will probably appear to have more blocky movement and/or move slower, but the above statistics are correct.
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 07, 2010, 05:52:15 pm
Wow that's fast! Is that drawing 96 tiles per frame?

One thing I dislike with the calc data is that when not aligned, it takes much longer to display than when aligned, so horizontal scrolling games seems a bit slower than if they just scroll vertically.
Title: Re: Smoothscrolling tilemapper
Post by: ztrumpet on November 07, 2010, 05:53:39 pm
One thing I dislike with the calc data is that when not aligned, it takes much longer to display than when aligned, so horizontal scrolling games seems a bit slower than if they just scroll vertically.
If you want it to be the same, you can use ClrDraw:Pt-On() instead of Pt-Off(). :)

That looks great Runer.  Can you post the source?  It's sure fast. ;D
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 07, 2010, 05:56:35 pm
Could you clarify what you mean? ??? Do you mean Pt-On doesn't slow down when not aligned?
Title: Re: Smoothscrolling tilemapper
Post by: meishe91 on November 07, 2010, 05:57:14 pm
That looks really sweet Runer :)

Z, didn't you have a smoothscrolling engine a long time ago with an early Axe version?
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 07, 2010, 06:05:20 pm
Wow i am astounded by the speed you get! O.O How in the world do you do that?  I did some tests and displaying 96 sprites every frame yielded a 22 FPS at the worst case scenario, and 60 FPS at best case scenario (alligned)
Title: Re: Smoothscrolling tilemapper
Post by: ztrumpet on November 07, 2010, 06:06:30 pm
Could you clarify what you mean? ??? Do you mean Pt-On doesn't slow down when not aligned?
Pt-On has the same speed because it does not speed up if it is aligned. :)

Z, didn't you have a smoothscrolling engine a long time ago with an early Axe version?
http://ourl.ca/4161/79940
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 07, 2010, 06:09:55 pm
Pt-On has the same speed because it does not speed up if it is aligned. :)

Hmm tests would say otherwise, i got 60FPS with PtOn(0,0) 96 times, and 22 FPS with PtOn(7,7) 96 times
Title: Re: Smoothscrolling tilemapper
Post by: ztrumpet on November 07, 2010, 06:11:55 pm
Pt-On has the same speed because it does not speed up if it is aligned. :)

Hmm tests would say otherwise, i got 60FPS with PtOn(0,0) 96 times, and 22 FPS with PtOn(7,7) 96 times
Okay, looks like I'm wrong.  :-[ Sorry.
(I think I must be remembering from a previous version of Axe or something.  :-\)
Title: Re: Smoothscrolling tilemapper
Post by: Runer112 on November 07, 2010, 06:24:24 pm
My program only draws tiles as they scroll onto the screen. That means it's drawing at most 13 8x8 tiles per frame. This means you couldn't have animated ground tiles, but it would work great for static ground tiles. It could also be easily extended to working with grayscale tilemaps.
Title: Re: Smoothscrolling tilemapper
Post by: nemo on November 07, 2010, 06:29:13 pm
My program only draws tiles as they scroll onto the screen. That means it's drawing at most 13 8x8 tiles per frame. This means you couldn't have animated ground tiles, but it would work great for static ground tiles. It could also be easily extended to working with grayscale tilemaps.

can you post the source? great job on the speed
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 07, 2010, 06:33:21 pm
Wow thats amazing, i tried to do that approach myself but i got a max of 18 FPS and the code looked horrible, i second the request for the source :D
Title: Re: Smoothscrolling tilemapper
Post by: Madskillz on November 07, 2010, 06:45:29 pm
That is awesome Runer, incredibly fast.
Title: Re: Smoothscrolling tilemapper
Post by: Runer112 on November 07, 2010, 06:47:24 pm
Some notes about this test program:

EDIT: By the way, sorry if the lowercase comments don't look right. I wrote this program with TI's Program Editor, which turns any lowercase letters that are also statistics variables into those special tokens instead of just treating them as lowercase letter tokens.
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 07, 2010, 06:52:54 pm
Thats very impressive, awesome work on this! 
Title: Re: Smoothscrolling tilemapper
Post by: Runer112 on November 07, 2010, 07:41:14 pm
I didn't comment it much, but hopefully it's still understandable. If not, just ask me about it.
Title: Re: Smoothscrolling tilemapper
Post by: shmibs on November 07, 2010, 08:27:22 pm
:!Ifθ+1→θ-10
:→θ

so... if, after being incremented, θ=10 then 1→θ?

runer, your optimisation is incredible.

EDIT: i just realised that i've been storing data to GDB1 or whatever, using another variable as the offset, and then calling GDB1 plus the variable (habit carried over from BASIC) when this whole time i could have just stored GDB1 to the variable initially. see, i'm learning already ;D

DOUBLE EDIT:0→θ, eh? so answer isn't carried from if statements. i should really learn the syntax BEFORE messing around with a code.
Title: Re: Smoothscrolling tilemapper
Post by: Runer112 on November 07, 2010, 08:28:55 pm
:!Ifθ+1→θ-10
:→θ

so... if, after being incremented, θ=10 then 1→θ?

runer, your optimisation is incredible.

Increment θ, and then if it equals θ=10, then 0→θ :P
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 07, 2010, 08:31:03 pm
Darn, I think you should maybe put this (and the sprite editor that came out a while ago) in the downloads section, that really could be useful in the future, and it might get lost in the Axe sub-forum. Nice job! :)
Title: Re: Smoothscrolling tilemapper
Post by: Runer112 on November 07, 2010, 09:07:23 pm
This isn't a project or anything, I just whipped this up as an example in all of 30 minutes or something. :P
Title: Re: Smoothscrolling tilemapper
Post by: ztrumpet on November 07, 2010, 10:59:44 pm
Wow, you're source is wonderful.  I like the optimizations... wow... ;D
I must learn to code like you in Axe! >:D
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 07, 2010, 11:02:34 pm
I wonder if this can be modified to scroll in arbitrary distances... (up to 8 pixels of course)
Title: Re: Smoothscrolling tilemapper
Post by: Runer112 on November 07, 2010, 11:02:35 pm
DOUBLE EDIT:0→θ, eh? so answer isn't carried from if statements. i should really learn the syntax BEFORE messing around with a code.

The answer is carried from if statements, but that was an !If statement which activates when the expression following it equals zero, so zero carries to the next line.

Wow, you're source is wonderful.  I like the optimizations... wow... ;D
I must learn to code like you in Axe! >:D

I've been debating making a super-optimization guide for Axe. Should I?


I wonder if this can be modified to scroll in arbitrary distances... (up to 8 pixels of course)

I'll try my best :P
Title: Re: Smoothscrolling tilemapper
Post by: ztrumpet on November 07, 2010, 11:04:00 pm
Wow, you're source is wonderful.  I like the optimizations... wow... ;D
I must learn to code like you in Axe! >:D

I've been debating making a super-optimization guide for Axe. Should I?
Please do. :)  I'd love to learn to coding like this. :)
Title: Re: Smoothscrolling tilemapper
Post by: AngelFish on November 07, 2010, 11:05:16 pm
Yes, definitely.
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 07, 2010, 11:08:41 pm
I wonder if this can be modified to scroll in arbitrary distances... (up to 8 pixels of course)

I'll try my best :P

I've deduced that scrolling more that 1 pixel per frame means that you would have to display more than 1 column of sprites per scroll, so it would be slower for sure, but i don't think the speed difference would be that large hopefully.
Title: Re: Smoothscrolling tilemapper
Post by: Michael_Lee on November 07, 2010, 11:53:12 pm
I've been debating making a super-optimization guide for Axe. Should I?

PLEASE.  I would love to code like this - I still treat Axe sort of like TI-Basic, and I never really learned how to optimize that either, beyond the normal tricks.
(I just printed out your code - I'm going to be poring over it before I go to bed! :))
Title: Re: Smoothscrolling tilemapper
Post by: shmibs on November 08, 2010, 12:10:04 am
Quote from: runer
The answer is carried from if statements, but that was an !If statement which activates when the expression following it equals zero, so zero carries to the next line.
wow, i don't think i've derped that badly in some time. thanks for your patience XD

Quote from: runer
Quote from: Builderboy on Today at 23:02:34
I wonder if this can be modified to scroll in arbitrary distances... (up to 8 pixels of course)

I'll try my best Tongue
that would be EXCEEDINGLY helpful!

Quote from: builderboy
I've deduced that scrolling more that 1 pixel per frame means that you would have to display more than 1 column of sprites per scroll, so it would be slower for sure, but i don't think the speed difference would be that large hopefully.
wait, so i got something right?
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 08, 2010, 12:18:12 am
Yeah, it seems i was unaware of how many sprites my engine was displaying O.O I was convinced i was only doing 1 column but it seems i was accidentally doing 2 columns.  I was mistaken before by what you meant by 2 columns, i thought you meant 1 column each side of the screen (for some reason o.O) since i was convinced only 1 column was needed for a scroll up to 8 pixels

Now to find out how i managed to write a scrolling tilemapper with this incorrect knowledge...
Title: Re: Smoothscrolling tilemapper
Post by: shmibs on November 08, 2010, 12:57:01 am
/\i do that type of thing all the time(get a hunch as to how something could work, write it out as quickly as possible, and, if it doesn't work[which is usually], fiddle with it blindly until it does). after this process, i usually fall asleep(it tends to occur when i'm really tired), and then read over it in the morning, try to understand it, and re-write it from scratch.
Title: Re: Smoothscrolling tilemapper
Post by: Quigibo on November 08, 2010, 01:28:00 am
Great job on the optimizations!  By the way, you can use this for convenience:

Zeros(1024)->GDB1

And it will work the way you expect it to, no need to use the [] before it.
Title: Re: Smoothscrolling tilemapper
Post by: Runer112 on November 08, 2010, 01:41:35 am
The old engine only scrolled 1 pixel per frame, so it got 60 fps, but therefore it only scrolled 60 pixels per second. Behold, the new engine that can scroll an arbitrary number of pixels from 1-8 per frame! In the example screenshot (which probably looks like crap and doesn't accurately reflect the realistic performance) I'm scrolling 3 pixels per frame (controlled by the value of S set in the program) and get about 35-40 fps, giving scrolling rates of 100-120 pixels per second!

Also, with the old engine I didn't realize how interested people would be in this so I didn't bother to optimize it much. This time I went ahead and optimized it to the fullest of my abilities.
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 08, 2010, 03:26:57 am
This is great! You should definitively write a small guide showcasing some hardcore optimizations.

One thing, though: make sure to provide both the optimized and unoptimized/easier piece of code that do something and screenshots. Try to not do this Axe optimizing guide the Asm28day way, where it provides no real example of code and just stuff that does nothing. That way, your tutorial will be useable not only by people who understand fast through text, but also visual people.
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS on November 08, 2010, 05:52:12 am
Hello there !
I have a question concerning the former ztrumpet's smooth scrolling tilemapper :
I tried to increase width by changing the right variable and adding bytes at the end of each line in GDB1 but it doesn't worked. Though to increase height I added some rows to GDB and it worked...
does anyone can help me please ?

ps: i'm not english nor american and I still learning that language then I apologize for my possible mistakes :)
Title: Re: Smoothscrolling tilemapper
Post by: TIfanx1999 on November 08, 2010, 08:43:48 am
@Runer: That really looks fantastic! Nice work!
@Ti-Dks: Hello, welcome to Omnimaga! I don't have much experience with Axe, but I'm sure someone here will be able to help you. Don't worry about the language too much. We have users from all over the place, many speaking French or Dutch as their first language. Have a look around, and we hope you enjoy your stay here. Feel free to introduce yourself in the introduction section here:http://www.omnimaga.org/index.php?board=10.0 (http://www.omnimaga.org/index.php?board=10.0)
Title: Re: Smoothscrolling tilemapper
Post by: shmibs on November 08, 2010, 08:53:42 am
hello!
do you mean the smoothscrolling engine in this topic (http://ourl.ca/4161/79940)?
if so then z is probably the best person to answer your question.

and don't worry about language stuff; everyone can understand you perfectly =D

also, you should introduce yourself here (http://www.omnimaga.org/index.php?board=10.0)!
Title: Re: Smoothscrolling tilemapper
Post by: ztrumpet on November 08, 2010, 11:02:36 am
Hello there !
I have a question concerning the former ztrumpet's smooth scrolling tilemapper :
I tried to increase width by changing the right variable and adding bytes at the end of each line in GDB1 but it doesn't worked. Though to increare height I added some rows to GDB and it worked...
does anyone can help me please ?

ps: i'm not english nor american and I still learning that language then I apologize for my possible mistakes :)
Hi, welcome to Omnimaga! :)
Adding bytes to the end works pretty easily, as you've noticed, but adding bytes on the side is much harder.  This is how to do it on my tilemapper:
Change W (I think this is what you did).
Change O to the number of total columns.  For example, the demo I made had 10 columns, so O=10.  If you want to add 3 columns, O would have to equal 13.
Finally, change the tilemap itself.  Let's say it looks like this:
Code: [Select]
00010203040506070809000102030405060708090001020304050607080900010203040506070809And let's also say that you want to add 3 new columns on the right.  Add those where I put 'XX's:
Code: [Select]
0001020304050607080900XXXXXX0001020304050607080900XXXXXX0001020304050607080900XXXXXX0001020304050607080900XXXXXX
I hope this made sense to you. :)  Good luck. ;D
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS on November 08, 2010, 12:12:29 pm
Okay ! Thanks for your answers  :D I will try this as soon as I can !
( I hadn't seen var O  :-\)
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 08, 2010, 02:08:12 pm
Hey Ti-DkS, welcome here :)
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS on November 08, 2010, 02:47:03 pm
thank you Dj ! I'm going on omnimaga for a while to find things about Axe, for example when I have problems in my code and I think its forum is very useful, mainly because there are many members with a very good knowledge of Axe, then I registered :)

ps for ztrumpet : your code worked perfectly of course :D
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 08, 2010, 02:58:47 pm
Ah glad to hear. I can't wait to see some of your programs :D
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS on November 09, 2010, 11:07:11 am
I'm working on one I wanted to achieve, precisely :) It's why I asked ztrumpet about his 16x16 smoothscrolling tilemapper ;D
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 09, 2010, 12:23:38 pm
Ooh I see in your signature. Sounds interesting. I hope you can manage to finish it. I made a Metroid game before that is called Metroid II: Evolution/Metroid II: The Last Chozo Expansion Set, but it used xLIB so it was pretty slow on a regular 83+ and controls were wonky (although when using Doors CS7 or Celtic III it was slightly faster). When you have some progress done, are you planning to post updates in a new topic about it? :)
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS on November 09, 2010, 04:35:06 pm
Metroid II is a very good game and very impressive regarding Ti-basic power and it's why I wanted to create another one (but more Fusion-like) with Axe because I think power of Axe sufficient to make this game. I tried to do it with xLib but after coding shooting system I was forced to stop because it was too slow :(
Then I wanted an ASM compiler and I found Axe ;D

For the topic it is a good idea and I will foresee that :)
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 09, 2010, 11:36:02 pm
Yeah with BASIC it's hard to keep things fast. Also data is pretty large. If bosses aren't hard-coded, I am sure it could remain pretty small. I think Metroid II was about 15 KB if we exclude map data and xLIB APP.
Title: Re: Smoothscrolling tilemapper
Post by: AngelFish on November 10, 2010, 12:56:29 am
Yeah with BASIC it's hard to keep things fast. Also data is pretty large.

Especially if you're manipulating a large amount of data. The full screen tilemapper in Battlefield takes a whole five seconds to run (optimized from 9 seconds). You really have to be conscious of how much of the screen you're trying to draw at once.
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 10, 2010, 03:00:45 am
Yeah that too. But by large data I meant for example if you use matrices or lists, each tile takes 9 bytes when stored in matrix files and in the program they take 2-3 bytes. With 300 12x8 maps that grows pretty fast compared to Axe's 1 bytes per tile (or 0.5 if you use 16 tiles per map). You can use strings, but if you use 2 byte tokens like lowercase letters in your maps, those takes more space in the string, plus pasting large strings containing 2 byte tokens with 2nd+RCL can cause RAM clear in the PRGM menu if you're low on memory due to an OS glitch. There are also pics, but then you're limited to 2 tiles, unless you use some form of dynamic tilemapping pixel-testing every side of the tile, which is slow.
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS on November 10, 2010, 03:22:35 pm
Yeah... Does anyone think it is possible to bring some optimizations to increase the speed of ztrumpet's 16x16 tilemapper, however without using "vertical" and "horizontal" commands ? (redrawing tiles each step)
Title: Re: Smoothscrolling tilemapper
Post by: squidgetx on November 10, 2010, 03:34:04 pm
What do you mean by 'redrawing tiles each step'?

as far as I know, vertical/horizontal method of tilemapping is the best one since then you can get away with only drawing the tiles at the edge every frame rather then having to redraw the whole screen.
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS on November 10, 2010, 04:18:09 pm
yes I know... But I want to preserve the back-buffer too :)
Title: Re: Smoothscrolling tilemapper
Post by: AngelFish on November 10, 2010, 04:31:18 pm
You can draw directly to the screen in Axe.
Title: Re: Smoothscrolling tilemapper
Post by: ztrumpet on November 10, 2010, 04:38:31 pm
Does anyone think it is possible to bring some optimizations to increase the speed of ztrumpet's 16x16 tilemapper?
I'm sure it's easily possible, just I don't want to wade my way through the code right now. :P

Maybe Runer would like to optimize it. ;D
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 10, 2010, 04:48:38 pm
I actually managed to get a tilemapper working at 22 FPS with total redraw, and while thats 3 times slower than Raylins its pretty darn good for complete redraw ^^ But its a bit weird right now because it is jerky because of the different speeds.  I'll see if i can smooth it out.
Title: Re: Smoothscrolling tilemapper
Post by: MRide on November 10, 2010, 04:56:57 pm
Wow, I didn't realize how much progress had been made on this.  Someone should give a final version to Sir for his Axe guide. (Which you should finish, btw, Sir O0)
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 11, 2010, 12:08:05 am
I think he was planning to rewrite a new guide at one point that was up to date and more complete, but I don't know what happened to it.
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS on November 11, 2010, 09:17:41 am
I think a powerful tilemapper what redraws the whole screen can be interesting to develop multi-level grayscale 2d sidescrolling plateformers because it uses only the main buffer and the other can be used to draw backgrounds using "horizontal" and "vertical" commands. Isn't it right ? :)
A guide will be interesting also  ;D
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga 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.
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS 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 :)
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga 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.
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS 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 ?
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga 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.
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS 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
Title: Re: Smoothscrolling tilemapper
Post by: FinaleTI 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.
Title: Re: Smoothscrolling tilemapper
Post by: Ti-DkS on November 13, 2010, 03:46:27 pm
amazing engine :) Very nice job !!
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga 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?
Title: Re: Smoothscrolling tilemapper
Post by: FinaleTI 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.
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 14, 2010, 01:34:25 pm
Ah ok thanks :)
Title: Re: Smoothscrolling tilemapper
Post by: squidgetx on November 15, 2010, 07:06:36 am
Are byte-based tilemappers faster than nibble-based mappers?
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga 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?
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 15, 2010, 02:05:40 pm
Its probably a bit slower and larger, but with the size advantage it is pretty significant ^^
Title: Re: Smoothscrolling tilemapper
Post by: squidgetx 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
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 15, 2010, 02:15:04 pm
Same here squidgetx :) Unless i was absolutely forced to use nibble maps, i would go full byte every time ^^
Title: Re: Smoothscrolling tilemapper
Post by: squidgetx on November 15, 2010, 02:17:48 pm
Thanks ;) That little bit of support has now convinced me to change it around. Ironically this will lessen the amount of free RAM I need since I will be changing map sizes from 100x100 to 50x50, and even with the change from nibbles to bytes that still means we're going from 5000 bytes per map to 2500 :)

edit: actually maybe I'll make it 64x64 instead...
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 15, 2010, 02:28:54 pm
yeah powers of 2 make things a lot faster and simpler in some of the tile detection code
Title: Re: Smoothscrolling tilemapper
Post by: Binder News on November 15, 2010, 06:53:43 pm
About preserving the back-buffer: there are 3 saferam areas designated for saving the screen. They are plotSScreen (default buffer used w/ drawing bcalls, also is the buffer in Axe, L6), appBackUpScreen (back-buffer in Axe, L3), and saveSScreen (L1 in Axe). This is obviously all well and good, but Quigibo used the first 56 bytes for the A-Z+THETA vars. If you don't mind overwriting those, or don't mind adding free mem in-program to use as vars, you can use saveSScreen as a backup-back-buffer (it's L1-56).
Title: Re: Smoothscrolling tilemapper
Post by: SirCmpwn on November 15, 2010, 06:56:41 pm
I'm trying to figure out how best to RLE my maps for an upcoming game of mine, since I have little motivation to work on HL2.  Any suggestions?  The maps could get quite large, and tilemapping should be fast.
Title: Re: Smoothscrolling tilemapper
Post by: Binder News on November 15, 2010, 09:32:43 pm
RLE? HL2? (Sorry, I'm bad with acronyms)
Title: Re: Smoothscrolling tilemapper
Post by: calcdude84se on November 15, 2010, 09:37:15 pm
Run Length Encoding (Compression scheme)
Half-Life 2 (Video game)
Title: Re: Smoothscrolling tilemapper
Post by: Builderboy on November 15, 2010, 09:40:01 pm
Are you looking for a method or an explanation?
Title: Re: Smoothscrolling tilemapper
Post by: Binder News on November 15, 2010, 10:06:13 pm
Thanks calcdude. Here would be my suggestion for RLE, (I'll refer to the leftmost bit as bit 7), bit 7 will be 0 if that byte will include the data, or 1 if the next byte will give the length.
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 15, 2010, 10:12:05 pm
Didn't Nemo write a compression/decompression routine for tilemaps? You might want to ask him or run a search on the forums to see if you can find it. Maybe he just had compression, though.
/me thinks this is when we need a !call function on the forums.
Title: Re: Smoothscrolling tilemapper
Post by: ztrumpet on November 15, 2010, 11:44:00 pm
http://ourl.ca/7818
Look for "RLE". ;D
Title: Re: Smoothscrolling tilemapper
Post by: DJ Omnimaga on November 16, 2010, 12:25:25 am
Ah, right, decompression was done, too. I wasn't sure anymore. :)
Title: Re: Smoothscrolling tilemapper
Post by: Darl181 on February 16, 2011, 01:23:41 am
Okay, I'm having a problem with one.
It has a few display glitches...
Still can't figure out the tilemapper though.
When scrolling both horizontally and vertically, there's display issues.
To test: make a tio level using any of the versions, then run this.  It uses the Tio map for data.


attached is (non-playable) level that really shows the graphical problems...yay :P

EDIT have some code
Code: (STILEMPR) [Select]
:.DTILEMPR
:[F0F0F0F000000000]?Pic0N
:[A0A0505000000000]?Pic1J
:[6040206000000000]?Pic1S
:[6040604000000000]?Pic1F
:[9000009000000000]?Pic1R
:[A050A05000000000]?Pic1D
:[000C030000000000]?Pic1W
:DiagnosticOff
:"vTIOLVL"?Str1
:GetCalc(Str1)?P
:Return!If P
:conj(P,L1,384
:0?N?O?I?J-1?E
:.I and J are coordinates of top left corner
:.N and O are tile offsets
:
:ClrDraw
:.draw init image
:For(Y,0,15
:Y*4?T
:For(X,0,23
:X*4?S
:E+1?E
:sub(DRW
:End
:End
:DispGraph
:Repeat getKey(15)
:Repeat getKey(0):End
:If getKey(54)
:ClrHome
:.display stuff
:Disp "random info",i,"I",I?Dec," J",J?Dec,i,"N",N?Dec," O",O?Dec
:While getKey(54):Pause 10:End
:End
:
:If getKey(1) xor (getKey(4))
:.vert movement
:
:If getKey(4)
:Vertical +
:O+1?O
:If O>>3
:J-1?J
:O-4?O
:For(A,0,23
:A*4-N?S
:0-O?T
:J*24+I+A?E
:sub(DRW
:End
:End
:End
:
:If getKey(1)
:Vertical -
:O-1?O
:If O<<1
:J+1?J
:O+4?O
:For(A,0,23
:A*4-N?S
:64-O?T
:J*24+I+A+360?E
:sub(DRW
:End
:End
:End
:
:End
:
:If getKey(2) xor (getKey(3))
:.horiz movement
:If getKey(2)
:Horizontal +
:N+1?N
:If N>>3
:N-4?N
:I-1?I
:For(A,0,15
:0-N?S
:A*4-O?T
:J*24+I+(A*24)?E
:sub(DRW
:End
:End
:End
:If getKey(3)
:Horizontal -
:N-1?N
:If N<<1
:N+4?N
:I+1?I
:For(A,0,15
:96-N?S
:A*4-O?T
:J*24+I+(A+1*24)?E
:sub(DRW
:End
:End
:End
:
:
:
:End
:DispGraph
:End
:
:
:Lbl DRW
:Pt-On(S,T,Pic0N
:Pt-Change(S,T,Pic0N
:.pt-on stuff
:!If {L1+E}-1
:Pt-On(S,T,Pic0N
:Else!If {L1+E}-2
:Pt-On(S,T,Pic1J
:Else!If {L1+E}-3
:Pt-On(S,T,Pic1S
:Else!If {L1+E}-4
:Pt-On(S,T,Pic1F
:Else!If {L1+E}-5
:Pt-On(S,T,Pic1R
:Else!If {L1+E}-6
:Pt-On(S,T,Pic1D
:Else!If {L1+E}-7
:Pt-On(S,T,Pic1W
:End
:.Return
See this post for screenshot and attachments (http://ourl.ca/8025/174482)
Title: Re: Smoothscrolling tilemapper
Post by: Darl181 on February 17, 2011, 02:49:25 pm
Ok, that's been taken care of since, and I have a pretty good idea of how it works.
A random idea I got was to make simply written, heavily commented source code, so other people can learn from them.
So far, I have basic 8*8 tilemapping (no scrolling) covered.

Quick question: there's a type of scrolling, not smoothscrolling, but it scrolls like 8 pixels at a time.  Kind of like, say, pyyrix did scrolling.  What's that called?

btw yes, i'm still working on Tio, I'm just trying to learn more on how to do this so i don't screw up big time then i try to add it.