Author Topic: [WIP] Trailblazer Prime  (Read 43676 times)

0 Members and 4 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: [WIP] Trailblazer Prime
« Reply #15 on: December 14, 2013, 08:37:59 pm »
By the way, just a suggestion to complete my other post on the other page: Would it impact performance if under each floor tile just in front of holes, you added a small wall to give the effect of depth to each floor tile? That said, there would be the issue about diagonal walls, though >.<

EDIT: I got an idea: Just BLIT_P two copies of the race track (with 4 and 8 pixels offset vertically respectively) then apply a black polygon over it with 70% opacity, then display a 3rd copy of the race track on top of everything, with the ball and other stuff. Make sure to set empty spaces as the transparent color. This would be enough to give a depth effect:



Or you can display them at a slightly smaller zoom, but this would slow the game down.

EDIT 2: I just tried it on calc with your older program and I still get 16 FPS most of the time. However, keep in mind that that program wasn't full screen and I did not try with zooming.
« Last Edit: December 14, 2013, 09:24:44 pm by DJ Omnimaga »

Offline MacBernick

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +3/-0
    • View Profile
Re: [WIP] Trailblazer Prime
« Reply #16 on: December 14, 2013, 10:03:47 pm »
You should probably move the level track to the bottom part of the screen and add some sky, though. :P
My first idea was to lower it a bit and add a starfield at the top, and the dashboard at the bottom. There's only two values to be modified in doRender() to do that (ray + 10 and ray +14). But a sky, as tiles now look (a bit) like mud and grass, why not...

Actually Trailblazer isn't by me, but by MacBernick ;)
By the way, is it me or that game reminds me of Plain Jump for the 83+? It was a 3D-looking game where you jumped from platform to platform with a ball.
I don't know the 83+ scene at all, but I wouldn't be surprised. This game is a 8 bits classic and there have been a lot of clones running on many plateforms.

Ooh that looks quite cool actually. :D Do you plan to add some animation or shadow for the ball?

Also, I like the gradient effect at the top. O.O Did it impact speed when adding it?
Yep I have plans to animate the ball, most likely rendering something quick in a few steps with Blender.

The code for the gradient is quite straightforward :

Code: [Select]
  FOR r FROM 10 to 20 DO
      FILLPOLY_P(G1, {{0, r}, {319, r}, {0, r + 1}, {319, r + 1}}, 0, (20 - r) * 255 / 10);
   END;

This FILLPOLY fuction seems to be really fast even with alpha blending, and only 10 iterations does not impact that much on performances. I can barely tell the difference on the virtual calc.

Wha, this is looking pretty awesome, keep up the great work! :D

Thank you :)

By the way, just a suggestion to complete my other post on the other page: Would it impact performance if under each floor tile just in front of holes, you added a small wall to give the effect of depth to each floor tile? That said, there would be the issue about diagonal walls, though >.<

EDIT: I got an idea: Just BLIT_P two copies of the race track (with 4 and 8 pixels offset vertically respectively) then apply a black polygon over it with 70% opacity, then display a 3rd copy of the race track on top of everything, with the ball and other stuff. Make sure to set empty spaces as the transparent color. This would be enough to give a depth effect:



Or you can display them at a slightly smaller zoom, but this would slow the game down.

EDIT 2: I just tried it on calc with your older program and I still get 16 FPS most of the time. However, keep in mind that that program wasn't full screen and I did not try with zooming.

I thought about some sort of gradient to give some deepness to the holes, but this is even better, you have great ideas for the game :) . Not sure if there is not something more efficient than drawing multiple copies of the track though. Maybe yet another precomputed table could easily store for which tiles  the last line of texture should be blended beneath.

I attach an intemrediate version here, since I was doing jump function when some friends suddenly came with beers so well... at least I started it ^^'
I'd be glad to know how framerate is improved on the real Prime.
« Last Edit: December 14, 2013, 10:05:47 pm by MacBernick »

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: [WIP] Trailblazer Prime
« Reply #17 on: December 14, 2013, 10:11:11 pm »
Thanks, I'm happy to help (of course I can't help much on optimizing though, since I'm still new to this calc :P), anyway I like your ideas as well. Gonna try the new version soon. :)

By the way, here's the TI-85 Plain Jump game from 1996: http://www.ticalc.org/archives/files/fileinfo/12/1252.html

It was ported to the more popular 83+ by Sam Heald around 1999-2001.

By the way, thank you for using the directional pad for movement. That one Tetris clone for the HP Prime used the number pad and it's quite hard to control. XD
« Last Edit: December 14, 2013, 10:12:19 pm by DJ Omnimaga »

Offline MacBernick

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +3/-0
    • View Profile
Re: [WIP] Trailblazer Prime
« Reply #18 on: December 14, 2013, 10:48:46 pm »
Yes a similar game exists on HP48 too, can't find it on hpcalc strangely. I can remember you could create and edit tracks by drawing it on a 5 pixels wide GROB, or something like that.


Looks like the simulator runs faster when freshly started than after some time running. Can't go more than 200 FPS now and I didn't modify the code that much.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: [WIP] Trailblazer Prime
« Reply #19 on: December 15, 2013, 12:38:31 am »
Are you calculating a lookup table for each pixel of the screen?

Not for each pixel. I use three tables :
rayTable stores the distance to the rendered plane for each screen line,
x1Table and x2Table are lists of lists of projected horizontal starts and ends of each square, for each screen line again.
Those are computed in init().
Good. I had originally done the naive per pixel look up table when writing my Nspire mode 7 engine, but I also came across a similar method. Instead of storing the start and end positions for each scanline, I stored the start position and a vector to increment the position by each pixel. I don't know the performance penalties for different calculations in HP-BASIC, but a vector addition per pixel should be cheaper than a vector linear interpolation (which involves multiple additions and multiplications) each pixel, so you may want to try it.

Offline MacBernick

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +3/-0
    • View Profile
Re: [WIP] Trailblazer Prime
« Reply #20 on: December 15, 2013, 06:45:54 am »
I see what you mean. But here, as screen lines are always parallels to lines of texels, the BLIT_P function of PPL does this for me even faster. Nothing is computed at pixel level in fact : BLIT_P scales and copies on screen a whole line of a tile at once.

One quick question : on the virtual calc, when you press two or more keys at the same time, only the last pressed key is actually active. Is it the case on the real calc too ? It could be a problem here since three keys could be pressed together if you want to accelerate, jump and move at the same time.
« Last Edit: December 15, 2013, 09:07:00 am by MacBernick »

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: Re: [WIP] Trailblazer Prime
« Reply #21 on: December 15, 2013, 12:06:45 pm »
From what I remember, diagonal arrow keypresses work on the real calc, but I'm unsure if multiple keypresses where one or more of the keys isn't an arrow will work. The 84+ BASIC add-in xLIB had the same problem, where the only multiple keypresses supported were with arrows.

Btw I tried the last version on-calc and it ran at 14-16 fps. However I can't figure out what's the jump key. D:

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: [WIP] Trailblazer Prime
« Reply #22 on: December 16, 2013, 12:24:52 am »
I see what you mean. But here, as screen lines are always parallels to lines of texels, the BLIT_P function of PPL does this for me even faster. Nothing is computed at pixel level in fact : BLIT_P scales and copies on screen a whole line of a tile at once.
Ah, so it will scale the textels automatically for you? That's even better.

Offline MacBernick

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +3/-0
    • View Profile
Re: [WIP] Trailblazer Prime
« Reply #23 on: December 16, 2013, 10:39:16 am »
From what I remember, diagonal arrow keypresses work on the real calc, but I'm unsure if multiple keypresses where one or more of the keys isn't an arrow will work. The 84+ BASIC add-in xLIB had the same problem, where the only multiple keypresses supported were with arrows.

Btw I tried the last version on-calc and it ran at 14-16 fps. However I can't figure out what's the jump key. D:

Mmm I was expecting a better framerate. PPL is cool because it has efficient native graphic functions, but I have this strange feeling that loops, tests and all this stuff are quite an overhead. There is still room for improvements in my program but I wonder if it will be enough... Going on anyway.

Jump was only partially implemented thus commented out. Now it's working, [Enter] is the key.

Ah, so it will scale the textels automatically for you? That's even better.

Yep, BLIT_P takes x1Table and x2Table values directly and do the job quite efficiently.

New version with jump attached on this post. Working on tile type detection at ball position for a new "major" release soon.

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: [WIP] Trailblazer Prime
« Reply #24 on: December 16, 2013, 11:21:29 am »
Actually it seems like the version you posted now is 14 FPS only at the beginning of the track where there's no hole at all in the floor. I notice right now that in certain parts, such as the Hello World part, I get up to 23 FPS (I even peaked at 27 once). But yeah, when I made my HP 39gII Tunnel game, it seemed like for loops and some maths slowed my game down more than any complex graphics. That said, on the HP Prime, sprite scaling/zooming isn't very fast either. You can display like 10 BLIT commands that are 320x240 pixels large and barely see any speed difference, but the minute they are stretched up by one pixel, it gets much slower.

For 3D games I personally prefer just working on a 160x120 GROB then once I am done drawing everything there, I use BLIT_P(G0,0,0,320,240,G1,0,0,160,120). I wouldn't even mind doing using 96x64 stretched up to 288x192 with a frame around the screen for particularly complex 3D scenes with textures, since most people are used to old calculators with screens this small anyway.

That said, 15 FPS wouldn't be too bad per 3D standards IMHO, as long as it's not some sort of game where you move on ice and slip a lot, since it would then be very hard to control. For a plain jump game it would still be very enjoyable, plus some N64 games without the Expansion Pak sometimes ran at slower frame rate anyway (Mystical Ninja Starring Goemon, I'm looking at you).

By the way, to generate the floor, do you think that simply generating it in 2D with no stretching (with the textures displaying as 32x8 PNGs not stretched up) , then generating a 3D floor from it would be faster than calculating everything tile by tile?
I see what you mean. But here, as screen lines are always parallels to lines of texels, the BLIT_P function of PPL does this for me even faster. Nothing is computed at pixel level in fact : BLIT_P scales and copies on screen a whole line of a tile at once.
Ah, so it will scale the textels automatically for you? That's even better.
Yep, basically I'm pretty sure that anyone with the knowledge would be able to generate a raycaster from it and even with textures it would still run faster than the non-textured Lua one for the Nspire.

You can also do some interesting animations with BLIT_P scaling, like the fade in pixel effect and wavy text in http://img.ourl.ca//ssballfadein.gif , not to mention saving some space by displaying certain graphics larger than they really are.
« Last Edit: December 16, 2013, 11:28:41 am by DJ Omnimaga »

Offline MacBernick

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +3/-0
    • View Profile
Re: [WIP] Trailblazer Prime
« Reply #25 on: December 16, 2013, 01:31:21 pm »
Actually it seems like the version you posted now is 14 FPS only at the beginning of the track where there's no hole at all in the floor. I notice right now that in certain parts, such as the Hello World part, I get up to 23 FPS (I even peaked at 27 once). But yeah, when I made my HP 39gII Tunnel game, it seemed like for loops and some maths slowed my game down more than any complex graphics. That said, on the HP Prime, sprite scaling/zooming isn't very fast either. You can display like 10 BLIT commands that are 320x240 pixels large and barely see any speed difference, but the minute they are stretched up by one pixel, it gets much slower.

Let's call it Not Too Bad. Working on sim only is not ideal at all. Writing to Amazon right now to ask where the #@! my calc is stuck. Should have been here for one week at least now.

For 3D games I personally prefer just working on a 160x120 GROB then once I am done drawing everything there, I use BLIT_P(G0,0,0,320,240,G1,0,0,160,120). I wouldn't even mind doing using 96x64 stretched up to 288x192 with a frame around the screen for particularly complex 3D scenes with textures, since most people are used to old calculators with screens this small anyway.

That said, 15 FPS wouldn't be too bad per 3D standards IMHO, as long as it's not some sort of game where you move on ice and slip a lot, since it would then be very hard to control. For a plain jump game it would still be very enjoyable, plus some N64 games without the Expansion Pak sometimes ran at slower frame rate anyway (Mystical Ninja Starring Goemon, I'm looking at you).

What I'm thinking right now is that this machine would have enough horsepower to run the first Unreal full res @60fps... If only we could have access at least to some internal calls, a SysPPL just like we had SysRPL on the 48. Please HP, pretty pretty please ^^

Yep, basically I'm pretty sure that anyone with the knowledge would be able to generate a raycaster from it and even with textures it would still run faster than the non-textured Lua one for the Nspire.

You can also do some interesting animations with BLIT_P scaling, like the fade in pixel effect and wavy text in http://img.ourl.ca//ssballfadein.gif , not to mention saving some space by displaying certain graphics larger than they really are.

What I've done here is precalc raycasting for the vertical lookup already, and more traditional projection for the horizontal (no yaw control so no need for trigo here). The only knowledge to have is that, in a right rectangle(EDIT : triangle, obviously), TAN α = opposite / adjacent. And that's really it. Then it's a matter of playing with length and angles, and tedious optimization. I may write a how-to on the subject one day if people are interested. Be aware that a complete raycasting engine would not allow to precalc tables as much as here, so maybe don't expect more than 2 FPS ^^' (but lowering the resolution would have a better impact though).

By the way, to generate the floor, do you think that simply generating it in 2D with no stretching (with the textures displaying as 32x8 PNGs not stretched up) , then generating a 3D floor from it would be faster than calculating everything tile by tile?

Yes it would divide the number of iterations by 5. I'll definitely try it.


Other subject : I've just found out that TI has made some z80 based calc with machine language official support (yep, I didn't know... Maybe I'm too old for this stuff now ^^'). Are they still available ? As z80 ASM is the first I learned, and I was quite good at it well... more than 20 years ago, I'm pretty sure I could run this engine faster on the z80 than on the Prime ! I'm considering buying on maybe at the beginning of next year.
« Last Edit: December 16, 2013, 06:05:29 pm by MacBernick »

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: [WIP] Trailblazer Prime
« Reply #26 on: December 16, 2013, 01:47:51 pm »
Well, if you don't live in United States, I sometimes noticed that Ebay and Amazon can take several weeks to ship. On Ebay it usually takes a month during holiday rushes. However, you better ask them in case. Did you buy it from a marketplace seller? Those aren't very trustable there.

I agree, however, that having to rely on a simulator isn't very reliable when testing for speed. Thankfully, the new HP Prime firmware improves transfers a lot so I can test new versions, but sometimes I get busy and can be several months without monitoring new threads (especially during summer) D:.

Regarding SysRPL, I suspect that someone could just take the OS files, modify them to add a new command then you could run assembly or C programs compiled using a computer. However, I don't know how hard it is and if anyone ever tampers with the exam mode, they'll feel HP's wrath in the form of anti-ASM/C patches like TI is doing with Ndless on the TI-Nspire. >.<


By the way a tutorial would definitively be nice. It could possibly be useful for people who code for different calc models as well. :)



As for TI calcs, the TI-83 Plus, TI-84 Plus and TI-84 Plus C Silver Editions are still available. They all natively supports ASM and there are ASM tools made to enhance TI-BASIC as well. The last one came out this year and has a color screen. They are 15 MHz (except the 83+ which is 6), but it seems like people can still do very good stuff on them. As for the 83+/84+ monochrome models, there is also Axe Parser available as a language, or Grammer.

And yeah I suspect that you could get some good speed from this engine on the monochrome models or in 160x240 mode on the color one, although some particularly complex stuff like fade-in/out might be much harder. Hopefully you don't stop making HP Prime programs in the future, though O.O
« Last Edit: December 16, 2013, 02:14:21 pm by DJ Omnimaga »

Offline MacBernick

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +3/-0
    • View Profile
Re: [WIP] Trailblazer Prime
« Reply #27 on: December 17, 2013, 11:05:00 pm »
Hi !

Lot of work, finding time is hard at the moment. I made quickly a "one big grob for the whole track" version. Framerate seems more stable and higher. What do you think ?

Thanks for the info on TI z80. No I won't stop Prime dev, I have ideas for a few more games. But I really need to receive mine now. If I can't see how the timing goes by my eyes, gameplay will be terrible.

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: [WIP] Trailblazer Prime
« Reply #28 on: December 17, 2013, 11:59:41 pm »
Yeah I understand what you mean about work. I just worked 8 days in a row and was exhausted this weekend, so I hardly felt like doing anything. Thankfully I am off tomorrow and Saturday, but Saturday I'll most likely be very exhausted >.< (and I think I work Sunday).

I'm gonna try the new version now. By the way, we really need to find a way to ensure that games run at the frame rate we want, in both the emulator and the real calc. I was thinking about using two TICK commands combined with a WAIT command, where the elapsed time for rendering is calculated, then the WAIT command pauses execution until it reaches a specific amount of time (from which the rendering time is substracted). It could also solve the issue about inconsistent speed in some programs.

Also yeah I hope you get your prime soon too. To be honest, I had the emu for a while but I did not feel like developing as much for it because I had to get Critor to test my programs before release and it wasn't as entertaining. I hope you didn't get ripped or anything. If that's the case, you mighjt need to report the seller and try to get a refund from Amazon then buy the calc from Hpcalc.org or something. I got mine from Hpcalc.org, although you might want to check the calc page to make sure it isn't backordered.


EDIT: WOAH! The new version runs at 38 FPS on calc! O.O (31-34 when holding down a key).



EDIT 2: If graphic quality is set to 2 pixels height, 31 FPS and if it's set at max resolution like the original version, 22 FPS.
« Last Edit: December 18, 2013, 12:28:19 pm by DJ Omnimaga »

Offline MacBernick

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +3/-0
    • View Profile
Re: [WIP] Trailblazer Prime
« Reply #29 on: December 18, 2013, 10:42:08 pm »
Hey it seems to work not bad at all. Thanks again for feedback.
Updating first post with new versions, some tiles are working, but jump is disabled for now.