Author Topic: Mode 7 engine  (Read 25567 times)

0 Members and 1 Guest are viewing this topic.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Mode 7 engine
« on: January 08, 2013, 09:18:21 pm »
Just something I've been working on the past couple days. The screenshot makes it look slow, but it is actually running in full resolution on the lower half of the screen at just over 60fps in the emulator. So far I haven't implemented turning, but that will come soon, and shouldn't be too much of a performance hit. The map is just a 64 x 64 array of random colors, I'll add proper texture tiles later. It's only in grayscale because I don't have a CX or a CX boot1 dump *cough* *cough*.
« Last Edit: January 08, 2013, 09:21:10 pm by t0xic_kitt3n »

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: Mode 7 engine
« Reply #1 on: January 08, 2013, 10:44:14 pm »
Looks cool!

Have you put any thought into implementing rotations?
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Mode 7 engine
« Reply #2 on: January 08, 2013, 11:37:43 pm »
Wow, this is looking awesome, it also runs smooth :D

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #3 on: January 09, 2013, 11:03:35 am »
I'll work on rotations today. Also, are there any functions to access the timer in Ndless, or do I have to read memory addresses directly? I'd like to make a proper FPS counter.

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #4 on: January 09, 2013, 11:19:43 am »
If you're using... *cough* *cough* nSDL, there is SDL_GetTicks().

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #5 on: January 09, 2013, 11:44:42 am »
I think I'm doing something wrong, because SDL_GetTicks always returns 0. Also, on my calculator, it only runs at 35 FPS :(. Of course, with the horrible LCD response times, it's not much of a difference. Can someone test this on their CX calculator, and let me know how long it takes in seconds to get from one end of the map to the other?
« Last Edit: January 09, 2013, 11:52:18 am by t0xic_kitt3n »

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 #6 on: January 09, 2013, 12:04:58 pm »
It takes about 26-27 seconds from bottom to top and the other way around. From left to right it takes about 24 seconds.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #7 on: January 09, 2013, 12:09:45 pm »
So it's even slower on a CX. Movement is done in increments of 1/8 of a pixel on the map, so you need 64 * 8 = 512 frames to cross the map, which works out to ~20FPS. Could it be because the screen buffer is stored in SDRAM on the CX instead of the SRAM on non-CX calcs?
« Last Edit: January 09, 2013, 12:10:37 pm by t0xic_kitt3n »

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #8 on: January 09, 2013, 12:29:00 pm »
I think I'm doing something wrong, because SDL_GetTicks always returns 0.
Are you sure about that? Did you try printing out the value it returns? I just tried it on the emulator and seems to be working.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #9 on: January 09, 2013, 12:56:19 pm »
I think I'm doing something wrong, because SDL_GetTicks always returns 0.
Are you sure about that? Did you try printing out the value it returns? I just tried it on the emulator and seems to be working.
Yes, I used uart_printf and it displayed 0. Anyways, I figured out how to read the timer value directly, and that works fine. However, the frame time to floats isn't working for some reason. I used:
Code: [Select]
float floatFrameTime = (float)(time - oldTime);
uart_printf("\n%u %f", time - oldTime, floatFrameTime);
time-oldTime displays correctly (it is usually in the range of 360 - 500, measured in 1/32768ths of a second), but floatFrameTime always prints 0.00.
« Last Edit: January 09, 2013, 12:57:32 pm by t0xic_kitt3n »

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Mode 7 engine
« Reply #10 on: January 09, 2013, 12:59:34 pm »
I think I'm doing something wrong, because SDL_GetTicks always returns 0.
Are you sure about that? Did you try printing out the value it returns? I just tried it on the emulator and seems to be working.
Yes, I used uart_printf and it displayed 0. Anyways, I figured out how to read the timer value directly, and that works fine. However, the frame time to floats isn't working for some reason. I used:
Code: [Select]
float floatFrameTime = (float)(time - oldTime);
uart_printf("\n%u %f", time - oldTime, floatFrameTime);
time-oldTime displays correctly, but floatFrameTime always prints 0.00.
Yeah that's because of a bug or some issue with printing floats. The nspire syscalls for some reason can't handle printing floats. Try casting it to an integer.
Also remember the value returned by SDL_GetTicks() is a Uint32.
EDIT: BTW, to get the timer value, did you read the RTC or the millisecond timer?
« Last Edit: January 09, 2013, 01:02:25 pm by hoffa »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #11 on: January 09, 2013, 01:04:53 pm »
Oh, so that's why. Now it works fine, but it only shows up as full numbers which I guess is good enough.
« Last Edit: January 09, 2013, 01:05:18 pm by t0xic_kitt3n »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: Mode 7 engine
« Reply #12 on: January 09, 2013, 09:31:52 pm »
Weird shit happens with rotation.  :P

Also, CalcCapture is acting weird. At the end, you can see that it inserted a picture of itself into a few frames.
« Last Edit: January 09, 2013, 09:34:21 pm by t0xic_kitt3n »

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Mode 7 engine
« Reply #13 on: January 09, 2013, 09:32:32 pm »
Looks like a fun ocean :P

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Mode 7 engine
« Reply #14 on: January 09, 2013, 09:40:07 pm »
Wow, nice, but is it a bug that the screen suddenly turns black?

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!