sábado, 19 de febrero de 2022

Tomb Raider (3)

I've spent some days looking at OpenLara source code to better understand how it works.

For now, it works like this, all is executed into the 68000. Although all boxes have the same size, they take different times of processing.



Now, I'm building a command list and using it to do all the transformations and rendering. Although it has to build this list for each frame it wouldn't impact the performance.


You may think that this solution is a waste of time, but now I have each frame "chewed" into some plain data for the GPU, as soon as the command list is built I can tell the GPU to execute it.

The advantage is that the 68000 doesn't need to wait for the GPU, it can process the next frame while the GPU is doing all 3D Transformations, and polygon drawing.

Running these steps in parallel means the frame rate will be as fast as the XForm + Render part, instead of Logic + XForm + Render.

I hope that all the 3D Transformations and rasterizer fit into GPU RAM, so no need to be assisted from the 68000 to do some code swapping.


jueves, 27 de enero de 2022

Tomb Raider (2)

Let's have a quick look at how (more or less) Tomb Raider works.

These are the steps of the render loop.

  1. Get camera room
  2. Set clipping area to the viewport
  3. For each room portal do:
    1. Project portal to screen
    2. Clip portal vertices to the current clipping area
    3. It's visible?
      1. Mark portal destination (another room) as visible
      2. Set clipping area to portal's bounding box
      3. go to 3 with that room.
  4. Render Lara
  5. For each visible room
    1. Render room's room
    2. Render room's sprites
    3. Render room's meshes
  6. Flush
All Render calls do the 3D transformations and include non culled polygons to a list, the actual rendering (pixels drawing) is done in the flush pass.

The next step will be to measure how much time takes each part (calculate visibility, render and flush), let's cross our fingers and hope that the first part (calculate visibility) is fast enough on the 68000, take in mind that the ARM in 3DO or GameBoy Advance is a lot faster than the 68000, so you have more free time to do the rendering.


sábado, 22 de enero de 2022

Tomb Raider (1)

 Yesterday (21-01-2022) I did a quick port of OpenLara to the Atari Jaguar. I'm just using the 68000, the other processors DSP, GPU, and blitter are stopped, of course, I'm using the OP or you won't see anything. 

You can see a small video here. Yes is running at 1FPS or maybe less.

I'm sure that the GPU is fast enough to do all 3D transformations for this game and most first-generation PS1/Saturn games but there are some problems.

  • The 68000 is too slow, is ok for a Genesis/Megadrive game, but it's too slow to make a modern shoot'em up (have a look at Sega Saturn games) with dozens of sprites, for a 3D game... forget it.
  • The more you use the Jaguar's hardware the fewer bus cycles are left for the 68000.
  • The Jaguar has only 2MB of RAM, the code takes 285Kb, and you have to store all textures, sounds, and 3D models. Just have a look at the filesize, almost none of them fit in RAM.