diff --git a/CMakeLists.txt b/CMakeLists.txt index 2268b83..a58f7c5 100644 --- a/CMakeLists.txt +++ b/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 diff --git a/atlas-e1m1.tim b/atlas-e1m1.tim deleted file mode 100644 index 9497325..0000000 Binary files a/atlas-e1m1.tim and /dev/null differ diff --git a/atlas-e2m2.tim b/atlas-e2m2.tim deleted file mode 100644 index e3be25b..0000000 Binary files a/atlas-e2m2.tim and /dev/null differ diff --git a/atlas-n64start.tim b/atlas-n64start.tim deleted file mode 100755 index 29bba63..0000000 Binary files a/atlas-n64start.tim and /dev/null differ diff --git a/main.c b/main.c index 60b9582..58fb59a 100644 --- a/main.c +++ b/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 diff --git a/n64e1m1.ps1bsp b/n64e1m1.ps1bsp new file mode 100755 index 0000000..11e0323 Binary files /dev/null and b/n64e1m1.ps1bsp differ diff --git a/n64e2m2.ps1bsp b/n64e2m2.ps1bsp new file mode 100755 index 0000000..7a6f64c Binary files /dev/null and b/n64e2m2.ps1bsp differ diff --git a/test.ps1bsp b/n64start.ps1bsp similarity index 71% rename from test.ps1bsp rename to n64start.ps1bsp index 65577e3..63275cc 100755 Binary files a/test.ps1bsp and b/n64start.ps1bsp differ diff --git a/ps1bsp.h b/ps1bsp.h index 0a7cffc..7dc494f 100755 --- a/ps1bsp.h +++ b/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) diff --git a/world.c b/world.c index 970fb9e..e3a4fc4 100644 --- a/world.c +++ b/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); diff --git a/world.h b/world.h index c4aeb50..d5d49cc 100644 --- a/world.h +++ b/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;