Author Topic: Mode 7 engine  (Read 25723 times)

0 Members and 1 Guest 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: Mode 7 engine
« Reply #30 on: January 26, 2013, 07:32:55 pm »
Good to hear about the speed. Do you think you can move the camera up and display a little bit further so that we don't see the squares this big (like http://www.omnimaga.org/index.php?action=dlattach;topic=15526.0;attach=14553;image ) or would it slow it down too much?
« Last Edit: January 26, 2013, 07:33:27 pm by DJ_O »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #31 on: January 26, 2013, 07:36:51 pm »
I can do that, I just changed the height of the camera sometime between those two screenshots. The one you mentioned was taken with height = 16, and the last one I uploaded was at height = 2. Actually, when I plan on doing texture mapping, what is each square ATM will have a whole texture in it.

Here's a screenshot with height = 32:
« Last Edit: January 26, 2013, 07:45:04 pm by t0xic_kitt3n »

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: Mode 7 engine
« Reply #32 on: January 26, 2013, 08:20:58 pm »
Ah ok nice. I guess if it's slightly closer it would be fine, since the farthest pixels will get messed up anyway due to low calc resolution. How fast does it run on a 512x512 map?

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #33 on: January 26, 2013, 09:35:01 pm »
It should run at about the same speed no matter how large the map is, possibly a little slower because there would be more cache misses with a larger map.
« Last Edit: January 26, 2013, 09:52:45 pm by t0xic_kitt3n »

Offline Ranman

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1354
  • Rating: +83/-0
    • View Profile
Re: Mode 7 engine
« Reply #34 on: January 26, 2013, 11:02:38 pm »
Lookin' mighty fine t0xic_kitt3n!
Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator. Download available at Ticalc.

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 304
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #35 on: January 27, 2013, 11:47:14 am »
I'm pretty positive you could get a nice speed boost if you used one of the many available fixed-point math libraries in C, especially if the program messes around a lot with floating point data (the ARM doesn't have an FPU).
« Last Edit: January 27, 2013, 11:48:09 am by hoffa »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #36 on: January 27, 2013, 12:14:01 pm »
I am using my own 16.16 fixed point number routines in most of the code. It should be faster than using a library because I can write only the features I need for this.

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 304
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #37 on: January 27, 2013, 12:28:15 pm »
I am using my own 16.16 fixed point number routines in most of the code. It should be faster than using a library because I can write only the features I need for this.
Maybe, but I doubt it is faster. Many of the libraries use very clever hacks, such as this one that even uses ARM assembly.

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Mode 7 engine
« Reply #38 on: January 27, 2013, 02:09:31 pm »
And AFAICT functions from a lib are only included if they are acctually used, isn't it?
I don't know how the ndless sdk does it, but most compilers don't include functions that are not used, so having too much functions doesn't really matter, since they don't get compiled

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #39 on: January 28, 2013, 11:51:45 pm »
As promised, here are some textures! I also made movement dependent on the direction the camera is facing, rather than a fixed direction for each key as it was previously.

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 304
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #40 on: January 29, 2013, 03:35:16 pm »
Awesome!

BTW, about the SDL_GetTicks() issue you mentioned earlier, it was my fault. I had completely forgotten to uncomment a line in nSDL that enabled bus access for the timer, and consequently it worked on the emulator but not one the actual hardware (i.e., it returned always 0). It was extremely dumb and careless from me, but I've updated it now, SDL_GetTicks() should work now (I've tested it on both calculators, everything runs smoothly).

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #41 on: January 29, 2013, 08:28:24 pm »
Thanks! I haven't been using nSDL, so I just switched to reading the timer directly. However, back when I was using SDL_GetTicks(), it was returning zero on the emulator as well.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #42 on: January 29, 2013, 10:45:34 pm »
I believe you were asking for the source code hoffa, so here it is for anyone who wants to take a look. Also, now it supports multiple (crappy procedural) textures (but there's nothing stopping you from loading them from a file) as well as solid colors. On the map, squares with 0-15 in them are interpreted as the color, and when n >= 16, the texture with id n - 16 is used.

EDIT: Uploaded wrong version, fixed, and added screenshot.
« Last Edit: January 29, 2013, 11:37:33 pm by t0xic_kitt3n »

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 304
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #43 on: January 30, 2013, 06:51:30 am »
Thanks a lot! That's some pretty damn clean code, it's a pleasure to read/mess with. :ninja:

EDIT:
Purely for viewing pleasure, a CX color version:


And some on-calc footage to see how it runs:

(I edited a few lines to get it working with nSDL and got about 6 FPS extra at the same time)

It runs at a rather constant 28-31 FPS on CX (could certainly be pushed further if it was optimized for 16 bpp) and 45-47 FPS on Touchpad when the whole lower half of the screen is filled.

EDIT2: I added the TNS if somebody wants to play with it.
« Last Edit: Today at 07:52:08 am by hoffa »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #44 on: January 30, 2013, 11:21:21 am »
Thanks for adding CX support! I would do it myself, but I don't have a CX or the boot1 ROM for the emulator.
« Last Edit: January 30, 2013, 11:57:14 am by t0xic_kitt3n »