Author Topic: Mode 7 engine  (Read 22181 times)

0 Members and 1 Guest are viewing this topic.

Offline Stefan Bauwens

  • Creator of Myst 89 - סטיבן
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1799
  • Rating: +162/-24
  • 68k programmer
    • View Profile
    • Portfolio
Re: Mode 7 engine
« Reply #45 on: January 30, 2013, 02:29:21 pm »
Man, that looks really smooth. :D
Well done!


Very proud Ticalc.org POTY winner (2011 68k) with Myst 89!
Very proud TI-Planet.org DBZ winner(2013)

Interview with me

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #46 on: January 30, 2013, 03:54:08 pm »
Good news, I managed to push to a constant 40 FPS on CX, and over 70 FPS (!!) on Touchpad.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #47 on: January 30, 2013, 11:48:24 pm »
What is the format for colors with nSDL?

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #48 on: January 31, 2013, 05:05:17 am »
When using 8 bpp (when initializing SDL with 8 bpp) it's palettized (every color mapped to a certain RGB value; palette is located in screen->format->palette and can be changed using SDL_SetColors()). It generates some default palette which is the one I used.
When using 16 bpp, colors are just encoded as 16-bit high color.
« Last Edit: January 31, 2013, 05:09:18 am by hoffa »

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #49 on: January 31, 2013, 03:41:35 pm »
Good news!

I've now added real color support and with "real" textures! I removed the plain color/texture division and used the whole byte as a palette index (i.e., 8-bit, 256 colors). It was the best method speed/simplicity/size-wise.

After some nitpicky optimization, I managed to push the framerate to 90+ FPS on Touchpad/Clickpad, and to a constant 45 FPS on CX! ^-^ I believe it's soon pretty much the theoretical maximum performance you can expect.

Aaaand a screenshot because everyone loves 'em:



Source code and binary attached!
« Last Edit: January 31, 2013, 03:44:40 pm by hoffa »

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Mode 7 engine
« Reply #50 on: January 31, 2013, 04:18:23 pm »
Wow, looks awesome! :D

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #51 on: February 02, 2013, 10:22:06 am »


This'll be my final update (plane leaving for Australia tomorrow).

Changes:
- Performance (oncalc): 100 FPS on Touchpad, most probably ~50 FPS on CX (can't test it, lil' brother lost his calc)
- Separated the mode7 part more and renamed stuff for more consistency (resembles much more like an engine)
- Fixed some issue with positions on the map being wrong
- Added a simple function to load textures (only works with 8-bit surfaces, i.e. surface has to be converted first if necessary)
- Cleaned up stuff

Code & binary attached.

EDIT:
One thing I've noticed is that accessing global variables is much slower than accessing any other type of variable. Just using the global screen SDL_Surface in the rendering function decreased the framerate by nearly 10 FPS! It might be good to know if speed is of your concern. IIRC it also applied to accessing structure items.
« Last Edit: February 16, 2013, 01:00:46 am by hoffa »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #52 on: February 02, 2013, 12:53:39 pm »
I wonder why accessing global variables are slower.

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Mode 7 engine
« Reply #53 on: February 02, 2013, 01:13:43 pm »
I wonder why accessing global variables are slower.
Ndless fake relocation atm.
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Mode 7 engine
« Reply #54 on: February 02, 2013, 01:35:16 pm »
Darn this looks really nice. Someone should really make a racing game or use the engine for a game like Pilotwings or an RPG world map.
Dream of Omnimaga

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Mode 7 engine
« Reply #55 on: February 02, 2013, 03:32:51 pm »
Hoffa recommended to me to use it in my F-Zero game (see my sig). I think that it's what I gonna do, if t0xic_kitt3n agree.
« Last Edit: February 02, 2013, 03:33:15 pm by Matrefeytontias »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #56 on: February 02, 2013, 09:45:29 pm »
I don't have any problem with it, go ahead. However, I was planning on adding sprites, so you may want to wait before you build around it.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Mode 7 engine
« Reply #57 on: February 03, 2013, 03:51:14 am »
I guess it would be a good idea unless you manage to make yours faster or something. (Or if t0xic's stopped being updated regularly and it slowed you down in your project due to having to wait or something)
Dream of Omnimaga

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Mode 7 engine
« Reply #58 on: February 03, 2013, 06:47:35 am »
I gonna use it now, and if fortunately you add sprite support, I'll just update my project to work with the new engine.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #59 on: February 03, 2013, 09:42:23 pm »
What does __attribute__ do?
Code: [Select]
static __inline__ __attribute__((always_inline))
m7Vec_t* m7AddVec(m7Vec_t* a, m7Vec_t* b) {
    a->x += b->x;
    a->y += b->y;
    return a;
}