You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.9 KiB
74 lines
1.9 KiB
#include "common.h"
|
|
#include "input.h"
|
|
#include "display.h"
|
|
#include "time.h"
|
|
#include "asset.h"
|
|
#include "world.h"
|
|
|
|
extern u_long tim_start[];
|
|
extern u_long bsp_test[];
|
|
|
|
VECTOR cam_pos = { 2176, 1152, 272 }; // START
|
|
//VECTOR cam_pos = { 1920, -1408, 352 }; // E1M1
|
|
SVECTOR cam_rot = { 0, 0, 0 };
|
|
SVECTOR cam_dir = { 0, ONE, 0 };
|
|
u_short cam_leaf = 0;
|
|
|
|
world_t world;
|
|
|
|
u_short quake_clut;
|
|
u_short water_clut;
|
|
|
|
// BSP face rendering:
|
|
// - Gather vertex data from face start index + length
|
|
// - Store vertex data in scratchpad memory (should be plenty of space for one face)
|
|
// - Perform camera offset and re-scaling operations to fit vertex data in signed 16-bit fixed point vectors
|
|
// - Note: may be possible to (ab)use 32-bit GTE registers & ops to do this calculation and downcast
|
|
// - Store rescaled vertex data in scratchpad memory
|
|
|
|
// Init function
|
|
void init(void)
|
|
{
|
|
input_init();
|
|
display_init();
|
|
time_init();
|
|
|
|
ps1texture_t maptex;
|
|
asset_loadTexture(tim_start, &maptex);
|
|
quake_clut = getClut(maptex.crect.x, maptex.crect.y);
|
|
water_clut = getClut(maptex.crect.x, maptex.crect.y + 1);
|
|
|
|
world_load(bsp_test, &world);
|
|
}
|
|
|
|
// Main function, program entrypoint
|
|
int main(int argc, const char *argv[])
|
|
{
|
|
// Init stuff
|
|
init();
|
|
|
|
// Main loop
|
|
while(1)
|
|
{
|
|
input_process();
|
|
|
|
display_start();
|
|
display_setClearColor(world.worldSpawn->skyColor);
|
|
|
|
u_short fps = time_getFrameRate();
|
|
FntPrint(-1, "Time: %d, frame: %d, delta time: %3d, fps: %d.%02d\n", (time_getRealTime() * 1000) >> 12, time_getFrameNumber(), time_getDeltaTime(), fps >> 8, ((fps & 0xFF) * 100) >> 8);
|
|
FntPrint(-1, "Camera pos: (%d, %d, %d) rot: (%d, %d, %d) leaf: %d\n", cam_pos.vx, cam_pos.vy, cam_pos.vz, cam_rot.vx, cam_rot.vy, cam_rot.vz, cam_leaf);
|
|
|
|
// Draw stuff
|
|
world_draw(&world);
|
|
|
|
FntPrint(-1, "Polycount: %d\n", polyCount);
|
|
FntFlush(-1);
|
|
|
|
display_finish();
|
|
|
|
time_tick();
|
|
}
|
|
|
|
return 0;
|
|
}
|