Browse Source

Embedded the texture atlas data inside the .ps1bsp file and name those files after the actual map.

Makes it a bit easier to switch between maps for testing, and this is the kind of direction we want to go in anyway.
unrollquadloop
Nico de Poel 3 years ago
parent
commit
3b89d01ec1
  1. 3
      CMakeLists.txt
  2. BIN
      atlas-e1m1.tim
  3. BIN
      atlas-e2m2.tim
  4. BIN
      atlas-n64start.tim
  5. 8
      main.c
  6. BIN
      n64e1m1.ps1bsp
  7. BIN
      n64e2m2.ps1bsp
  8. BIN
      n64start.ps1bsp
  9. 6
      ps1bsp.h
  10. 1
      world.c
  11. 3
      world.h

3
CMakeLists.txt

@ -14,8 +14,7 @@ project(
file(GLOB _sources *.c)
psn00bsdk_add_executable(ps1bsp STATIC ${_sources})
psn00bsdk_target_incbin(ps1bsp PRIVATE tim_start atlas-n64start.tim)
psn00bsdk_target_incbin(ps1bsp PRIVATE bsp_test test.ps1bsp)
psn00bsdk_target_incbin(ps1bsp PRIVATE bsp_test n64start.ps1bsp)
psn00bsdk_add_cd_image(
iso # Target name

BIN
atlas-e1m1.tim

BIN
atlas-e2m2.tim

BIN
atlas-n64start.tim

8
main.c

@ -5,7 +5,6 @@
#include "asset.h"
#include "world.h"
extern u_long tim_start[];
extern u_long bsp_test[];
VECTOR cam_pos = { 2176, 1152, 272 }; // START
@ -33,12 +32,13 @@ void init(void)
display_init();
time_init();
world_load(bsp_test, &world);
// Upload texture atlas to VRAM
ps1texture_t maptex;
asset_loadTexture(tim_start, &maptex);
asset_loadTexture(world.atlases[0].timData, &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

BIN
n64e1m1.ps1bsp

BIN
n64e2m2.ps1bsp

BIN
test.ps1bsp → n64start.ps1bsp

6
ps1bsp.h

@ -29,6 +29,7 @@ typedef struct
u_short version;
ps1bsp_dentry_t worldSpawn;
ps1bsp_dentry_t atlases;
ps1bsp_dentry_t textures;
ps1bsp_dentry_t vertices;
ps1bsp_dentry_t polygons;
@ -48,6 +49,11 @@ typedef struct
unsigned char skyColor[4];
} ps1bsp_worldspawn_t;
typedef struct
{
unsigned long timData[1]; // Variable length
} ps1bsp_atlas_t;
typedef struct
{
unsigned short tpage; // Texture page in PS1 VRAM (precalculated when generating the texture atlas)

1
world.c

@ -40,6 +40,7 @@ void world_load(const u_long *data, world_t *world)
ps1bsp_header_t* header = (ps1bsp_header_t*)bytes;
LOAD_CHUNK(ps1bsp_worldspawn_t, world->worldSpawn, world->numTextures, bytes, header->worldSpawn);
LOAD_CHUNK(ps1bsp_atlas_t, world->atlases, world->numAtlases, bytes, header->atlases); // numAtlases contains the number of 32-bit words in a single atlas now
LOAD_CHUNK(ps1bsp_texture_t, world->textures, world->numTextures, bytes, header->textures);
LOAD_CHUNK(ps1bsp_vertex_t, world->vertices, world->numVertices, bytes, header->vertices);
LOAD_CHUNK(ps1bsp_polygon_t, world->polygons, world->numPolygons, bytes, header->polygons);

3
world.h

@ -7,6 +7,9 @@ typedef struct
{
ps1bsp_worldspawn_t *worldSpawn;
u_short numAtlases;
ps1bsp_atlas_t *atlases;
u_short numTextures;
ps1bsp_texture_t *textures;

Loading…
Cancel
Save