Author Topic: So I am porting Quake to the Nspire...  (Read 49289 times)

0 Members and 1 Guest are viewing this topic.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: So I am porting that first person shooter to the Nspire...
« Reply #15 on: June 25, 2014, 05:19:40 pm »
I took a quick look and the source code:
Is it really so slow that you had to use assembler for custom "incorrect" division  O.O ? How much was the speedup?
And if you want to make it as fast as possible without any source changes, I'd advise you to use the genzehn tool and the zehn format from
my ndless fork and the same optimization options in the Makefile that I use in crafti (especially -flto, -mcpu, -Ofast). In crafti there isn't anything in assembler yet, pure C++ and it runs fast enough (I may change the asm thing, if your "incorrect" version makes a significant difference).
But if you really want to dig into the "every cycle counts" I may point you to __builtin_prefetch or the "PLD"(preload) arm instruction.

I didn't follow any of the steps and actually ran it, though, too much work to do for a game I'm not really a fan of, sorry.  :/
It looks really awesome though  :o

Offline gameblabla

  • LV3 Member (Next: 100)
  • ***
  • Posts: 86
  • Rating: +17/-1
    • View Profile
    • Gameblabla's website
Re: So I am porting that first person shooter to the Nspire...
« Reply #16 on: June 26, 2014, 12:51:29 am »
Hello,
i tried it on my TI nspire CX and it's actually very playable , i'm impressed !
Here's how it runs on my calc :


(I have overclocked mine to 264 Mhz but it runs well too in 132 Mhz if you lower the screen size a bit)

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: So I am porting that first person shooter to the Nspire...
« Reply #17 on: June 26, 2014, 03:12:18 am »
This is awaiting in the Omnimaga front page headlines queue right now. I am astonished by how fast it runs in the video above (although I guess it helps that you overclocked your calc to 264 MHz. Mine can only go up to 242 or so before it goes unstable). Still, awesome work!


Does it work under OS 3.1?

Offline mdr1

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 303
  • Rating: +21/-2
    • View Profile
Re: So I am porting that first person shooter to the Nspire...
« Reply #18 on: June 26, 2014, 05:48:34 am »
I get the following:

Quote
Sys Error:
W_LoadWadFile: couldn't load gfx.wad

And then I have to reset. I followed your instructions.

Nota: I've got a TI-Nspire CX CAS with ndless 3.1.



Offline rwill

  • LV2 Member (Next: 40)
  • **
  • Posts: 29
  • Rating: +3/-0
    • View Profile
Re: So I am porting that first person shooter to the Nspire...
« Reply #19 on: June 26, 2014, 09:06:19 am »
Vogtinator: The assembler file is missing the following comment because I am not quite done yet:

@ Division routines are implemented with using the book
@ "ARM System Developer's Guide: Designing and Optimizing System Software"
@ by Andrew N. Sloss, Dominic Symes, Chris Wright
@ as a reference.
@ I am not good at math :(

The division routine is called _incorrect because I removed the error correction of the quotient and remainder at some point but added them back later because of.. issues. So it is actually providing correct results. If you are interested in the mathematical proof and more ARM optimizing shizzle I strongly recommend the book. Speedup is significant if you have to do a division every 8 pixels.

DJ Omnimaga: I do not know if it runs on 3.1. My emulator setup is 3.1 and my calc is 3.6 and it runs in/on both.

mdr1: Quake cannot find the pak0.pak(.tns) in the /quake/id1/ folder. Are you sure its there ? I identified the reason you had to reset instead of just having to press a key so thank you for your feedback :)

« Last Edit: June 26, 2014, 09:16:12 am by rwill »

Offline mdr1

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 303
  • Rating: +21/-2
    • View Profile
Re: So I am porting that first person shooter to the Nspire...
« Reply #20 on: June 26, 2014, 11:37:04 am »
I have a folder containing both pak0.pak and nquake (not only).



Offline rwill

  • LV2 Member (Next: 40)
  • **
  • Posts: 29
  • Rating: +3/-0
    • View Profile
Re: So I am porting that first person shooter to the Nspire...
« Reply #21 on: June 27, 2014, 03:38:26 am »
mdr1: Well it should look something like in the attached picture:



Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: So I am porting that first person shooter to the Nspire...
« Reply #22 on: June 27, 2014, 08:00:46 am »
Geezus, I didn't realize this was Quake. I kind of missed this topic since the title is really vague(I was also viewing it on my phone and the picture did not show up). This is fantastic! I can't believe how fast it runs in the video. I also didn't realize that quake could run at that low of a resolution. Anyhow, amazing job!!!

Offline rwill

  • LV2 Member (Next: 40)
  • **
  • Posts: 29
  • Rating: +3/-0
    • View Profile
Re: So I am porting that first person shooter to the Nspire...
« Reply #23 on: June 27, 2014, 12:30:46 pm »
New build. I fixed the system error message so you can exit graceful by keypress instead of having to reset. I also changed the keypad read routine for the touchpad which gave some speedup. I also added more keys for interpretation.

I also noticed that I never explained the key bindings. For the game you can bind any key nQuake understands. You can set these through the menus..
ESC opens the menu which you can navigate with the arrow keys. Enter goes to a sub-menu and ESC returns from it. In the sub-menu Options is "customize controls", if you select that you can remap all in game actions to different keys. nQuake currently understands the following keys:
Arrow Keys, A-Z, 0-9, SPACE, TAB, CTRL, SHIFT, SPACE, +/-/=, TRIG, ^, X^2, e^x, 10^x, (), .

The Quake console is bound to the "?!" key. There you can type commands like "map start" or "timedemo demo1" and other stuff from the 90s.

I included the Windows Visual Studio solution this time because its where I do development so it kind of belongs in the package.

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: So I am porting that first person shooter to the Nspire...
« Reply #24 on: June 30, 2014, 04:17:38 pm »
Welcome on Omnimaga rwill, keep up the good work :)
Ndless.me with the finest TI-Nspire programs

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: So I am porting that first person shooter to the Nspire...
« Reply #25 on: June 30, 2014, 04:37:33 pm »
Geezus, I didn't realize this was Quake. I kind of missed this topic since the title is really vague(I was also viewing it on my phone and the picture did not show up). This is fantastic! I can't believe how fast it runs in the video. I also didn't realize that quake could run at that low of a resolution. Anyhow, amazing job!!!
To be honest I'M not surprised, because Unreal Tournament GOTY came out 3 years after Quake, yet it supported resolutions as low as 320x200, which is smaller than calcs. :P

Geezus
At first I thought Drak (NSFW) was back on Omni O.O
« Last Edit: June 30, 2014, 04:39:11 pm by DJ Omnimaga »

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: So I am porting that first person shooter to the Nspire...
« Reply #26 on: June 30, 2014, 05:22:17 pm »
I included the Windows Visual Studio solution this time because its where I do development so it kind of belongs in the package.

Ha, pretty cool ! And nice job again in general :P

Just for fun, I ran PVS-Studio (static analyzer) on it :
33 level 1 warnings, 16 level 2, 379 level 3... Quake 1 source is fun .... :P

Examples:
Spoiler For Spoiler:
V583 The '?:' operator, regardless of its conditional expression, always returns one and the same value: m + 8. sbar.c 418
Code: [Select]
int Sbar_ColorForMap (int m)
{
return m < 128 ? m + 8 : m + 8;
}

V570 The 'r_drawsurf.surfwidth' variable is assigned to itself. d_surf.c 302
Code: [Select]
if( r_drawsurf.surfwidth & 3 )
{
r_drawsurf.surfwidth = r_drawsurf.surfwidth;
}

V501 There are identical sub-expressions to the left and to the right of the '-' operator: (byte *) sv.edicts - (byte *) sv.edicts pr_cmds.c 634


V523 The 'then' statement is equivalent to the 'else' statement. cl_input.c 190
Code: [Select]
if (impulseup && !impulsedown)
if (down)
val = 0; // I_Error ();
else
val = 0; // released this frame


V673 The '2000 << 24' expression evaluates to 33554432000. 35 bits are required to store the value, but the expression evaluates to the 'int' type which can only hold '32' bits. r_edge.c 700
I lol'd at this one :
Code: [Select]
// FIXME: do we need this now that we clamp x in r_draw.c?
edge_sentinel.u = 2000 << 24; // make sure nothing sorts past this
edge_sentinel.prev = &edge_aftertail;

« Last Edit: June 30, 2014, 05:35:12 pm by Adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline rwill

  • LV2 Member (Next: 40)
  • **
  • Posts: 29
  • Rating: +3/-0
    • View Profile
Re: So I am porting that first person shooter to the Nspire...
« Reply #27 on: July 04, 2014, 03:55:11 am »
So I did some more optimizations and submitted it to ticalc.org as I was able to play through the first episode without noticing anything wrong.

ExtendeD: A problem I noticed with Ndless 3.1 in the emulator is that the stack was not aligned to 8 bytes upon entry of main() which leads to failure of functions taking 8 byte datatypes. ARM EABI requires the stack to be aligned to 8 byte. I worked around that by aligning the stack myself so printf and the likes work. This could be related to http://www.omnimaga.org/calculator-c-language/nspire-printf-syscall-is-not-ansi-compliant/ as I got the same symptoms. I have not tested with Ndless 3.6 or on the real HW.

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: So I am porting that first person shooter to the Nspire...
« Reply #28 on: July 04, 2014, 01:55:26 pm »
Make sure to e-mail ticalc so they notice the game, because this is definitively something newsworthy.

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: So I am porting that first person shooter to the Nspire...
« Reply #29 on: July 05, 2014, 05:57:47 am »
rwill : thanks, I think Vogtinator's SDK fork ( https://github.com/Vogtinator/Ndless/ ) fixed this. It should hopefully be merged back soon.
Ndless.me with the finest TI-Nspire programs