Progress thread for the current version (2010)

A DOOM-style 3D engine for TI-83 and TI-83+ series calculators.

Moderator: benryves

User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [Nostromo] Orginal Progress Thread

Post by benryves »

Thank you. :-) The BSP Tree FAQ may go some way towards explaining how I'm using a BSP tree to render a solid level.

I hope I've fixed the screen-scrambling issue calc84maniac pointed out. I have also enlarged the level somewhat:
Image    Image    Image

Image    Image    Image
The latest version of the demo can be downloaded here and there is also an animated screenshot.
User avatar
shmibs
New Member
Posts: 33
Joined: Thu 19 Nov, 2009 12:33 am
Location: you have a cute head

Re: [Nostromo] Orginal Progress Thread

Post by shmibs »

benryves wrote:I hope I've fixed the screen-scrambling issue calc84maniac pointed out. I have also enlarged the level somewhat:
sweet, i'll have to try it out later tonight to see if you were succesful!
oh, and i rather like the new level.

EDIT: i just realised that this topic is still in the 'discontinued projects' section
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [Nostromo] Orginal Progress Thread

Post by benryves »

Thank you. :) I'm sure you can spot the rooms on this rendering of the original level.

I guess I'll have to see about setting up a new forum for the project to resurrect it. :)
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Re: [Nostromo] Orginal Progress Thread

Post by tr1p1ea »

What i like most about this project is that it runs fullscreen. Also what are you using to draw the FPS counter?
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [Nostromo] Orginal Progress Thread

Post by benryves »

I don't think there would be a huge speed advantage when running in a reduced window; the sums are basically the same whether the window is 96 or 64 pixels wide. Most of the expensive operations (transforming, clipping and projecting walls) would be the same regardless of the size of the window. Drawing scaled sprites is quite expensive, though, and reducing the number of pixels drawn may help the frame rate a little.

The engine loads its own interrupt routine when you initialise it. It requires this anyway as the TI-OS ISR clobbers the shadow registers (which the engine needs for itself) but in addition it allows a timer to run in the background. This means that you generally walk around at the same speed, regardless of the current frame rate (actually, this is not true; there is a rounding error in the main movement code that means you move slightly more slowly when the frame rate is high - this has been fixed for looking left/right/up/down, but not moving). I need to do a lot of work on the movement code (walking through walls doesn't make the world feel especially solid) so this will hopefully be fixed in the future!

At the end of each frame the timer value is retrieved and the timer is reset. This gives you the number of timer ticks it took to draw the last frame. Dividing 335 by this value gives you the frame rate; I calculated this by comparing the timer tick value I was getting and the frame rate reported by WabbitEmu. According to WikiTI the default interrupt frequency is 353Hz (TI-83+) or 323.37Hz (TI-83+ SE) so the value I reached through experimentation is somewhere between the two.

I've got so much work on at the moment that I don't know if (or when) I'll be able to do any more work on this. I did take a few minutes out before going to bed last night to see what wall-aligned sprites might look like (these would sprites that are attached to walls, rather than sprites that always face the player). Without perspective-correct texturing they aren't likely to look great, but I don't think the distortion would be too bad.
Image    Image

Image    Image
The more extreme the angle you'd view the wall at, the more distorted the sprite would appear. I don't know if there is a decent (and fast) way to scale the textures in a perspective-correct manner, though.

As you can probably tell, the above screenshots are not from a TI-83+; I do a lot of prototyping in Evaldraw, a very handy tool for programming!

Code: Select all

// Wall sprite scaling demo.

()

// Clear the screen.
cls(0x6495ED);

// Get source width and height.
src_w = 0, src_h = 0;
getpicsiz(&src_w,&src_h);

// Set destination width.
dest_w = 2 * abs(mousx - xres / 2);

// Set the destination heights.

dest_h_a = 2 * abs(mousy - yres / 2);
dest_h_b = dest_w;

if (mousx > xres / 2) {
   s = dest_h_a; dest_h_a = dest_h_b; dest_h_b = s;
}

// Get height deltas.
dest_h_delta = dest_h_b - dest_h_a;
if (dest_h_delta > 0) {
   dest_h_inc = +1;
} else {
   dest_h_delta = -dest_h_delta;
   dest_h_inc = -1;
}

// Initialise X counters.
read_x = 0;
error_x = dest_w;

// Initialise height counters.
dest_h = dest_h_a;
error_h = dest_w;

for(x = 0; x < dest_w; x++) {

   // Initialise Y counters.
   read_y = 0; 
   error_y = dest_h;

   for (y = 0; y < dest_h; y++) {
      
      // Sample the source pixel.
      r = 0, g = 0, b = 0;
      pic(read_x, read_y, &r, &g, &b);
      
      // Plot the destination pixel.
      setcol(&r, &g, &b);
      setpix(x - dest_w / 2 + xres / 2, ceil(y - dest_h / 2 + yres / 2));
      
      // Advance read pointer if required.
      error_y -= src_h;
      while (error_y < 0) {
         read_y++;
         error_y += dest_h;
      }

   }
   
   // Advance read pointer if required.
   error_x -= src_w;
   while (error_x < 0) {
      read_x++;
      error_x += dest_w;
   }
   
   // Advance height if required.
   error_h -= dest_h_delta;
   while (error_h < 0) {
      dest_h += dest_h_inc;
      error_h += dest_w;
   }
}
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [Nostromo] Orginal Progress Thread

Post by benryves »

 
Image
Work has left me with little time to work on my own projects of late. I have, however, added simple collision detection to Nostromo, and you can read more about this and download a demo from my site. Failing that, click on the above screenshot to view an animated GIF.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [Nostromo] Orginal Progress Thread

Post by benryves »

I've done a little work on the project and added another room:
Image     Image

Image     Image

Image     Image

Image     Image
The map is now over 5,000 bytes and the rendering engine is approaching 7,000 bytes. Unfortunately, I think I've nearly run out of available RAM; if I enlarge the buffers slightly I start getting strange rendering glitches. This could be caused by the stack overwriting some of the dynamically-allocated tables (or it could be another issue, I'm not sure) - until I've investigated this bug further I'm afraid I'm not going to release a demo. I could turn this into an application, of course, but quite a lot of the code uses self-modifying tricks to boost performance.

Performance is also extremely poor in this build. I suspect that it's due to the BSP tree being poorly balanced; each room is fairly well partitioned internally, but with each room comes a more lopsided tree. The result is that when you're inside a room and can't see any other room performance is relatively good, but if you can see more than one room at a time performance can slow to a crawl (2FPS in places).

I hope to add debugging features which will allow me to check where the bottlenecks are. In their simplest form these could simply add up the total number of BSP tree nodes, subsectors and walls that are handled each frame.

One feature I have added is better handling of moving sectors. This currently maintains a list of sectors which are currently moving, with a pointer to the variable to update, the velocity of the movement, the minimum value and the maximum value. When the camera moves from one sector to another an event is fired specifying which sector the user has moved from and which they have moved from. The game logic then uses this information to tell doors to open or shut and a platform to raise or lower. This feature is demonstrated in this new animated screenshot. (Watching the screenshot makes me deeply jealous of TI-83+ Silver Edition owners). :(

One other feature which is not demonstrated (yet was quite a lot of work) is the ability to render more than one sprite in each convex sub-sector correctly. The convex sub-sectors are already sorted front-to-back by the BSP tree, so when rendering sprites these are drawn in the reverse order so sprites in the foreground occlude sprites in the background. To draw multiple sprites within each sub-sector correctly they need to be sorted from back-to-front, which I've done using a simple insertion sort. In addition, sprites are now assigned to sub-sectors using a linked list, which means that it will be possible to remove a sprite from one sub-sector and move it into another. This means that sprite objects will be able to be moved around the level, whereas they are currently static.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [Nostromo] Orginal Progress Thread

Post by benryves »

I've made some attempts to optimise the engine; only one (caching projected vertices) has been successful. I have, however, enlarged the level to the full 256 walls.
Image    Image    Image
More information can be found on the post on my website, along with a demo and an animated screenshot.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Re: Progress thread for the current version (2010)

Post by tr1p1ea »

:worship:

Pretty much sums it up, incredible work ben :)
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Progress thread for the current version (2010)

Post by benryves »

Thank you very much! :) I do hope I can turn this into something usable for a game, but I'm still a long way off. The size worries me, too.

With a bit more work I hope I can start publishing the source code, which may give people a better idea of what I'm doing. It's a fairly simple renderer, and given that my raycaster attempt was big, slow, buggy and didn't even have textured walls I'm sure others would be able to produce something far faster and lighter. The principle seems sound, at any rate, if not my implementation. :D
Galandros
Regular Member
Posts: 88
Joined: Sun 14 Sep, 2008 10:00 am

Re: [Nostromo] Orginal Progress Thread

Post by Galandros »

That makes us have a second thought about 3D in z80.
I am completely amused by the screenshots.

And Omnimaga published news about this engine.
Plus I bookmarked your journal (I have read many topics and gamedev page before though) to more closely follow your projects. :worship:
benryves wrote:Heh, cheers. Someone has to log in to delete the spam bot accounts, after all. :-)
Hey, I still log in from time to time to see activity. Now I tend to visit Revsoft and Maxcoderz.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Progress thread for the current version (2010)

Post by benryves »

Thank you very much. :) I've had virtually no time to work on my own projects recently (work has been keeping me busy as the year comes to an end) so there's been no progress since my last post I'm afraid. :(
User avatar
Madskillz
Calc Wizard
Posts: 745
Joined: Fri 17 Dec, 2004 10:22 pm
Location: Wandering around in the Jungle...
Contact:

Re: Progress thread for the current version (2010)

Post by Madskillz »

Looks better than what I saw last time. Looks like you added another sprite too.
The Revolution is here...
User avatar
Art_of_camelot
Regular Member
Posts: 124
Joined: Sun 09 Sep, 2007 8:50 pm
Location: The dark side of the moon
Contact:

Re: Progress thread for the current version (2010)

Post by Art_of_camelot »

Hmm... somehow I overlooked this project. This looks really nice Ben! =D
Projects:
Projects:TBA-Soonish. :)
Updated 5/3/12
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Progress thread for the current version (2010)

Post by benryves »

Thank you very much. I hope I get a chance to resume this project soon, but work is currently taking all of my time. :(
Image
I did spend a little time adding code to allow "things" to be moved around the map. This involves taking them out of their current sub-sector and moving them into their new sub-sector; as I'm using a linked list to assign things to sub-sectors this code is pretty straightforward. The above screenshot shows me moving a thing around the map. It also highlights one rendering bug I hadn't envisaged caused by the centre of the thing being in one sub-sector but overhanging into an adjacent one - this is responsible for the right hand side of the sprite being chopped off when viewed from certain positions in the above demonstration, as the right edge is in the nearer sub-sector (which is drawn first) and the rest of the object is in the further sub-sector (which is drawn afterwards, and so is clipped against the nearer sub-sector).
Post Reply