Update lus (#16)

* Updates
This commit is contained in:
MegaMech
2024-06-11 09:49:44 -06:00
committed by GitHub
parent 78a7d156c9
commit b594f112e0
82 changed files with 1379 additions and 424 deletions
+23 -23
View File
@@ -333,16 +333,16 @@ void func_80297340(Camera *arg0) {
if (D_800DC5BC != 0) {
gDPSetFogColor(gDisplayListHead++, D_801625EC, D_801625F4, D_801625F0, 0xFF);
gSPDisplayList(gDisplayListHead++, &D_0D001C20);
gSPDisplayList(gDisplayListHead++, D_0D001C20);
} else {
gSPDisplayList(gDisplayListHead++, &D_0D001B90);
gSPDisplayList(gDisplayListHead++, D_0D001B90);
}
} else if (D_800DC5BC != 0) {
gDPSetFogColor(gDisplayListHead++, D_801625EC, D_801625F4, D_801625F0, 0xFF);
gSPDisplayList(gDisplayListHead++, &D_0D001C88);
gSPDisplayList(gDisplayListHead++, D_0D001C88);
} else {
gSPDisplayList(gDisplayListHead++, &D_0D001BD8);
gSPDisplayList(gDisplayListHead++, D_0D001BD8);
}
}
@@ -747,32 +747,32 @@ void func_8029AC18(Camera *camera, Mat4 arg1, struct Actor *arg2) {
arg1[3][2] = arg2->pos[2];
if (render_set_position(arg1, 0) != 0) {
gSPDisplayList(gDisplayListHead++, &D_0D001750);
gSPDisplayList(gDisplayListHead++, D_0D001750);
switch (arg2->state) {
case 0:
gSPDisplayList(gDisplayListHead++, &D_0D001780);
gSPDisplayList(gDisplayListHead++, D_0D001780);
break;
case 1:
gSPDisplayList(gDisplayListHead++, &D_0D001798);
gSPDisplayList(gDisplayListHead++, D_0D001798);
break;
case 2:
gSPDisplayList(gDisplayListHead++, &D_0D0017B0);
gSPDisplayList(gDisplayListHead++, D_0D0017B0);
break;
case 3:
gSPDisplayList(gDisplayListHead++, &D_0D0017C8);
gSPDisplayList(gDisplayListHead++, D_0D0017C8);
break;
case 4:
gSPDisplayList(gDisplayListHead++, &D_0D0017E0);
gSPDisplayList(gDisplayListHead++, D_0D0017E0);
break;
case 5:
gSPDisplayList(gDisplayListHead++, &D_0D0017F8);
gSPDisplayList(gDisplayListHead++, D_0D0017F8);
break;
case 6:
gSPDisplayList(gDisplayListHead++, &D_0D001810);
gSPDisplayList(gDisplayListHead++, D_0D001810);
break;
case 7:
gSPDisplayList(gDisplayListHead++, &D_0D001828);
gSPDisplayList(gDisplayListHead++, D_0D001828);
break;
}
}
@@ -1028,16 +1028,16 @@ void spawn_course_actors(void) {
struct ActorSpawnData *a_d_course_mario_raceway_piranha_plant_spawns = (struct ActorSpawnData *) LOAD_ASSET(d_course_mario_raceway_piranha_plant_spawns);
struct ActorSpawnData *a_d_course_mario_raceway_item_box_spawns = (struct ActorSpawnData *) LOAD_ASSET(d_course_mario_raceway_item_box_spawns);
spawn_foliage(a_d_course_mario_raceway_tree_spawns);
spawn_piranha_plants(a_d_course_mario_raceway_piranha_plant_spawns);
spawn_all_item_boxes(a_d_course_mario_raceway_item_box_spawns);
vec3f_set(position, 150.0f, 40.0f, -1300.0f);
position[0] *= gCourseDirection;
add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN);
vec3f_set(position, 2520.0f, 0.0f, 1240.0f);
position[0] *= gCourseDirection;
actor = &gActorList[add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN)];
actor->flags |= 0x4000;
//spawn_foliage(a_d_course_mario_raceway_tree_spawns);
//spawn_piranha_plants(a_d_course_mario_raceway_piranha_plant_spawns);
//spawn_all_item_boxes(a_d_course_mario_raceway_item_box_spawns);
// vec3f_set(position, 150.0f, 40.0f, -1300.0f);
// position[0] *= gCourseDirection;
// add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN);
// vec3f_set(position, 2520.0f, 0.0f, 1240.0f);
// position[0] *= gCourseDirection;
// actor = &gActorList[add_actor_to_empty_slot(position, rotation, velocity, ACTOR_MARIO_SIGN)];
// actor->flags |= 0x4000;
break;
case COURSE_CHOCO_MOUNTAIN:
spawn_all_item_boxes(d_course_choco_mountain_item_box_spawns);
+37 -8
View File
@@ -9,6 +9,7 @@
#include "collision.h"
#include "math_util.h"
#include "code_800029B0.h"
#include <assert.h>
// Used to delete the choco mountain guard rail
void nullify_displaylist(uintptr_t addr) {
@@ -1547,6 +1548,11 @@ void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionI
s16 y3;
s16 z3;
// printf("mesh index: %d ", D_8015F588);
// printf("sectionId: 0x%X ", sectionId);
// printf("surfaceType: 0x%X ", surfaceType);
/* Unused variables placed around doubles for dramatic effect */
UNUSED s32 pad2[7];
@@ -1676,6 +1682,11 @@ void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionI
gCourseMaxZ = maxZ;
}
// printf("X 0x%X\n ", normalX);
// printf("Y 0x%X\n ", normalY);
// printf("Z 0x%X\n ", normalZ);
// printf("dist 0x%X\n\n", distance);
tile->height = normalX;
tile->gravity = normalY;
tile->rotation = normalZ;
@@ -1747,6 +1758,17 @@ void set_vtx_from_tri2(u32 triangle1, u32 triangle2, s8 surfaceType, u16 section
u32 vert5 = ( ( triangle2 & 0x0000FF00 ) >> 8 ) / 2;
u32 vert6 = ( triangle2 & 0x000000FF ) / 2;
// printf("tr1: 0x%X \n", triangle1);
// printf("tr2: 0x%X \n", triangle2);
// printf("\nv1 0x%X ", vert1);
// printf("v2 0x%X ", vert2);
// printf("v3 0x%X ", vert3);
// printf("v4 0x%X ", vert4);
// printf("v5 0x%X ", vert5);
// printf("v6 0x%X\n", vert6);
Vtx *vtx1 = vtxBuffer[vert1];
Vtx *vtx2 = vtxBuffer[vert2];
Vtx *vtx3 = vtxBuffer[vert3];
@@ -1791,6 +1813,10 @@ void set_vtx_buffer(uintptr_t addr, u32 numVertices, u32 bufferIndex) {
u32 i;
Vtx *vtx = (Vtx *) addr;
for (i = 0; i < numVertices; i++) {
//printf("VTX: 0x%llX",vtx);
if (vtx == 0) {
assert(false);
}
vtxBuffer[bufferIndex] = vtx;
vtx++;
bufferIndex++;
@@ -1977,6 +2003,7 @@ void set_vertex_data_with_default_section_id(Gfx *gfx, s8 surfaceType) {
}
extern u32 D_8015F58C;
u32 numTimes = 0;
/**
* Recursive search and set for vertex data
@@ -1986,6 +2013,7 @@ void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) {
uintptr_t lo;
uintptr_t hi;
s32 i;
numTimes++;
//printf("Initial\n");
//printf("ptr 0x%llX\n", &addr);
//printf("w0 0x%llX\n", addr->words.w0);
@@ -2009,20 +2037,20 @@ void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) {
// printf("ptr 0x%llX\n", &addr);
// printf("op 0x%llX\n", opcode);
// printf("w0 0x%X\n", lo);
// printf("w1 0x%X\n", hi);
// printf("w0 0x%llX\n", lo);
// printf("w1 0x%llX\n", hi);
if (opcode == (G_DL << 24)) {
// G_DL's hi contains an addr to another DL.
Gfx *dl = segmented_gfx_to_virtual(hi);
// printf("DL: 0x%llX\n", &dl);
// printf(" w0 0x%X\n", dl->words.w0);
// printf(" w1 0x%X\n", dl->words.w1);
//Gfx *dl = segmented_gfx_to_virtual(hi);
// printf("DL: 0x%llX ", hi);
// printf(" w0 0x%llX", lo);
// printf(" w1 0x%llX\n", hi);
find_and_set_vertex_data((Gfx *) (dl), surfaceType, sectionId);
find_and_set_vertex_data((Gfx *) (hi), surfaceType, sectionId);
} else if (opcode == (G_VTX << 24)) {
set_vtx_buffer(segmented_gfx_to_virtual(hi), (lo >> 10) & 0x3F, ((lo >> 16) & 0xFF) >> 1);
set_vtx_buffer((hi), (lo >> 10) & 0x3F, ((lo >> 16) & 0xFF) >> 1);
} else if (opcode == (G_TRI1 << 24)) {
D_8015F58C += 1;
@@ -2030,6 +2058,7 @@ void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) {
} else if (opcode == (G_TRI2 << 24)) {
D_8015F58C += 2;
set_vtx_from_tri2(lo, hi, surfaceType, sectionId);
} else if (opcode == (G_QUAD << 24)) {
+103 -50
View File
@@ -2,6 +2,7 @@
#include <libultra/types.h>
#include <align_asset_macro.h>
#include <macros.h>
#include <string.h>
#include <common_structs.h>
#include <segments.h>
#include <decode.h>
@@ -15,7 +16,9 @@
#include "defines.h"
#include <assets/mario_raceway_displaylists.h>
#include <assets/mario_raceway_vertices.h>
#include <assets/mario_raceway_data.h>
#include <assert.h>
#include <course_offsets.h>
s32 sGfxSeekPosition;
s32 sPackedSeekPosition;
@@ -95,17 +98,44 @@ void *segmented_to_virtual(const void *addr) {
return (void *) ((gSegmentTable[segment] + offset));
}
void *segment_offset_to_virtual(uint32_t segment, uint32_t offset) {
return (void *) (gSegmentTable[segment] + ( (offset / 8) * sizeof(Gfx) ) );
}
void *segment_vtx_to_virtual(size_t offset) {
printf("seg_vtx_to_virt: 0x%llX to 0x%llX\n", offset, (gSegmentTable[0x04] + offset));
return (void *) (gSegmentTable[0x04] + (offset));
}
void *segmented_texture_to_virtual(size_t offset) {
printf("seg_texture_to_virt: 0x%llX to 0x%llX\n", offset, (gSegmentTable[0x05] + offset));
return (void *) (gSegmentTable[0x05] + (offset));
}
void *segmented_uintptr_t_to_virtual(uintptr_t addr) {
uint32_t newAddr = (uint32_t) addr;
size_t segment = (uintptr_t) newAddr >> 24;
size_t offset = (uintptr_t) newAddr & 0x00FFFFFF;
uint32_t numCommands = offset / 8;
offset = numCommands * sizeof(Gfx);
printf("seg_gfx_to_virt: 0x%llX to 0x%llX\n", newAddr, (gSegmentTable[segment] + offset));
return (void *) ((gSegmentTable[segment] + offset));
}
void *segmented_gfx_to_virtual(const void *addr) {
size_t segment = (uintptr_t) addr >> 24;
size_t offset = (uintptr_t) addr & 0x00FFFFFF;
offset = (offset / 8) * sizeof(Gfx);
uint32_t numCommands = offset / 8;
offset = numCommands * sizeof(Gfx);
printf("seg_gfx_to_virt: 0x%llX\n",addr);
printf("seg_gfx_to_virt: 0x%llX to 0x%llX\n", addr, (gSegmentTable[segment] + offset));
return (void *) ((gSegmentTable[segment] + offset));
}
@@ -143,7 +173,7 @@ void initialize_memory_pool() {
/**
* @brief Allocates memory and adjusts gFreeMemorySize.
*/
void *allocate_memory(uintptr_t size) {
void *allocate_memory(size_t size) {
uintptr_t freeSpace;
size = ALIGN16(size);
@@ -437,19 +467,22 @@ UNUSED u8 *func_802A841C(u8* arg0, s32 arg1, s32 arg2) {
}
u8 *dma_textures(u8 texture[], size_t arg1, size_t arg2) {
// u8 *temp_v0;
// void *temp_a0;
u8 *temp_v0;
void *temp_a0;
// temp_v0 = (u8 *) gNextFreeMemoryAddress;
// temp_a0 = temp_v0 + arg2;
// arg1 = ALIGN16(arg1);
// arg2 = ALIGN16(arg2);
// osInvalDCache((void *) temp_a0, arg1);
u8* tex = (u8 *) LOAD_ASSET(texture);
temp_v0 = (u8 *) gNextFreeMemoryAddress;
temp_a0 = temp_v0 + arg2;
arg1 = ALIGN16(arg1);
arg2 = ALIGN16(arg2);
//osInvalDCache((void *) temp_a0, arg1);
// osPiStartDma(&gDmaIoMesg, 0, 0, (uintptr_t) &_other_texturesSegmentRomStart[SEGMENT_OFFSET(texture)], (void *)temp_a0, arg1, &gDmaMesgQueue);
// osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, (int) 1);
// mio0decode((u8 *) temp_a0, temp_v0);
// gNextFreeMemoryAddress += arg2;
return texture;
memcpy(temp_v0, tex, arg2);
gNextFreeMemoryAddress += arg2;
return temp_v0;
}
uintptr_t MIO0_0F(u8 *arg0, uintptr_t arg1, uintptr_t arg2) {
@@ -550,13 +583,13 @@ void unpack_displaylist(Gfx *arg0, u8 *args, UNUSED s8 opcode) {
uintptr_t temp_t7 = ((args[sPackedSeekPosition++]) << 8 | temp_v0) * 8;
arg0[sGfxSeekPosition].words.w0 = 0x06000000;
// Segment seven addr
arg0[sGfxSeekPosition].words.w1 = 0x07000000 + temp_t7;
arg0[sGfxSeekPosition].words.w1 = segment_offset_to_virtual(0x07, temp_t7); // (0x07000000 + temp_t7); // (gSegmentTable[segment] + ( (offset / 8) * sizeof(Gfx) ) );
sGfxSeekPosition++;
}
// end displaylist
void unpack_end_displaylist(Gfx *arg0, UNUSED u8 *arg1, UNUSED s8 arg2) {
arg0[sGfxSeekPosition].words.w0 = G_ENDDL << 24;
arg0[sGfxSeekPosition].words.w0 = (uintptr_t)(uint8_t)G_ENDDL << 24;
arg0[sGfxSeekPosition].words.w1 = 0;
sGfxSeekPosition++;
}
@@ -731,7 +764,7 @@ void unpack_tile_sync(Gfx *gfx, u8 *args, s8 opcode) {
gfx[sGfxSeekPosition].words.w1 = tileSync->words.w1;
sGfxSeekPosition++;
lo = (G_SETTILE << 24) | (fmt << 21) | (siz << 19) | (line << 9) | tmem;
lo = ((uintptr_t)(uint8_t)G_SETTILE << 24) | (fmt << 21) | (siz << 19) | (line << 9) | tmem;
hi = ((cmt) << 18) | ((maskt) << 14) | ((cms) << 8) | ((masks) << 4);
gfx[sGfxSeekPosition].words.w0 = lo;
@@ -741,7 +774,7 @@ void unpack_tile_sync(Gfx *gfx, u8 *args, s8 opcode) {
lrs = (width - 1) << 2;
lrt = (height - 1) << 2;
lo = (G_SETTILESIZE << 24);
lo = ((uintptr_t)(uint8_t)G_SETTILESIZE << 24);
hi = (lrs << 12) | lrt;
gfx[sGfxSeekPosition].words.w0 = lo;
@@ -764,6 +797,7 @@ void unpack_tile_load_sync(Gfx *gfx, u8 *args, s8 opcode) {
uintptr_t siz;
uintptr_t tmem;
uintptr_t tile;
size_t offset;
switch (opcode) {
case 32:
@@ -803,7 +837,8 @@ void unpack_tile_load_sync(Gfx *gfx, u8 *args, s8 opcode) {
// Waa?
var = args[sPackedSeekPosition];
// Generates a texture address.
addr = SEGMENT_ADDR(0x05, args[sPackedSeekPosition++] << 11);
offset = args[sPackedSeekPosition++] << 11;
addr = SEGMENT_ADDR(0x05, offset);
sPackedSeekPosition++;
arg = args[sPackedSeekPosition++];
siz = G_IM_SIZ_16b;
@@ -812,16 +847,16 @@ void unpack_tile_load_sync(Gfx *gfx, u8 *args, s8 opcode) {
// Generate gfx
lo = (G_SETTIMG << 24) | (fmt << 21) | (siz << 19);
lo = ((uintptr_t)(uint8_t)G_SETTIMG << 24) | (fmt << 21) | (siz << 19);
gfx[sGfxSeekPosition].words.w0 = lo;
gfx[sGfxSeekPosition].words.w1 = addr;
gfx[sGfxSeekPosition].words.w1 = segmented_texture_to_virtual(offset);
sGfxSeekPosition++;
gfx[sGfxSeekPosition].words.w0 = tileSync->words.w0;
gfx[sGfxSeekPosition].words.w1 = tileSync->words.w1;
sGfxSeekPosition++;
lo = (G_SETTILE << 24) | (fmt << 21) | (siz << 19) | tmem;
lo = ((uintptr_t)(uint8_t)G_SETTILE << 24) | (fmt << 21) | (siz << 19) | tmem;
hi = tile << 24;
gfx[sGfxSeekPosition].words.w0 = lo;
@@ -832,7 +867,7 @@ void unpack_tile_load_sync(Gfx *gfx, u8 *args, s8 opcode) {
gfx[sGfxSeekPosition].words.w1 = loadSync->words.w1;
sGfxSeekPosition++;
lo = G_LOADBLOCK << 24;
lo = (uintptr_t)(uint8_t)G_LOADBLOCK << 24;
hi = (tile << 24) | (MIN((width * height) - 1, 0x7FF) << 12) | CALC_DXT(width, G_IM_SIZ_16b_BYTES);
gfx[sGfxSeekPosition].words.w0 = lo;
@@ -842,6 +877,7 @@ void unpack_tile_load_sync(Gfx *gfx, u8 *args, s8 opcode) {
void unpack_texture_on(Gfx *arg0, UNUSED u8 *args, UNUSED s8 arg2) {
Gfx macro[] = { gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON) };
arg0[sGfxSeekPosition].words.w0 = macro->words.w0;
arg0[sGfxSeekPosition].words.w1 = macro->words.w1;
sGfxSeekPosition++;
@@ -867,8 +903,8 @@ void unpack_vtx1(Gfx *gfx, u8 *args, UNUSED s8 arg2) {
temp = args[sPackedSeekPosition++];
temp_t7_2 = temp & 0x3F;
gfx[sGfxSeekPosition].words.w0 = (G_VTX << 24) | (temp_t7_2 * 2 << 16) | (((temp_t7 << 10) + ((0x10 * temp_t7) - 1)));
gfx[sGfxSeekPosition].words.w1 = 0x04000000 + temp2;
gfx[sGfxSeekPosition].words.w0 = ((uintptr_t)(uint8_t)G_VTX << 24) | (temp_t7_2 * 2 << 16) | (((temp_t7 << 10) + ((0x10 * temp_t7) - 1)));
gfx[sGfxSeekPosition].words.w1 = (uintptr_t) segment_vtx_to_virtual(temp2);
sGfxSeekPosition++;
}
@@ -882,8 +918,8 @@ void unpack_vtx2(Gfx *gfx, u8 *args, s8 arg2) {
temp_t9 = arg2 - 50;
gfx[sGfxSeekPosition].words.w0 = (G_VTX << 24) | ((temp_t9 << 10) + (((temp_t9) * 0x10) - 1));
gfx[sGfxSeekPosition].words.w1 = 0x4000000 + temp_v2;
gfx[sGfxSeekPosition].words.w0 = ((uintptr_t)(uint8_t)G_VTX << 24) | ((temp_t9 << 10) + (((temp_t9) * 0x10) - 1));
gfx[sGfxSeekPosition].words.w1 = (uintptr_t) segment_vtx_to_virtual(temp_v2);
sGfxSeekPosition++;
}
@@ -908,7 +944,7 @@ void unpack_triangle(Gfx *gfx, u8 *args, UNUSED s8 arg2) {
phi_a2 |= (temp_v0 & 3) * 8;
phi_a3 = (temp_v0 >> 2) & 0x1F;
}
gfx[sGfxSeekPosition].words.w0 = (G_TRI1 << 24);
gfx[sGfxSeekPosition].words.w0 = ((uintptr_t)(uint8_t)G_TRI1 << 24);
gfx[sGfxSeekPosition].words.w1 = ((phi_a0 * 2) << 16) | ((phi_a2 * 2) << 8) | (phi_a3 * 2);
sGfxSeekPosition++;
}
@@ -954,7 +990,7 @@ void unpack_quadrangle(Gfx *gfx, u8 *args, UNUSED s8 arg2) {
phi_a2 = (temp_v0 >> 2) & 0x1F;
}
gfx[sGfxSeekPosition].words.w0 =
(G_TRI2 << 24) | ((phi_a0 * 2) << 16) | ((phi_a3 * 2) << 8) | (phi_t0 * 2);
((uintptr_t)(uint8_t)G_TRI2 << 24) | ((phi_a0 * 2) << 16) | ((phi_a3 * 2) << 8) | (phi_t0 * 2);
gfx[sGfxSeekPosition].words.w1 = ((phi_t2 * 2) << 16) | ((phi_t1 * 2) << 8) | (phi_a2 * 2);
sGfxSeekPosition++;
}
@@ -987,7 +1023,7 @@ void unpack_spline_3D(Gfx *gfx, u8 *arg1, UNUSED s8 arg2) {
temp_v0 = arg1[sPackedSeekPosition++];
phi_a0 |= (temp_v0 & 0xF) * 2;
}
gfx[sGfxSeekPosition].words.w0 = (G_LINE3D << 24);
gfx[sGfxSeekPosition].words.w0 = ((uintptr_t)(uint8_t)G_LINE3D << 24);
gfx[sGfxSeekPosition].words.w1 =
((phi_a0 * 2) << 24) | ((phi_t0 * 2) << 16) | ((phi_a3 * 2) << 8) | (phi_a2 * 2);
sGfxSeekPosition++;
@@ -1027,6 +1063,7 @@ void displaylist_unpack(Gfx *gfx, u8 *data, uintptr_t arg2) {
while(true) {
// Seek to the next byte
opcode = packed_dl[sPackedSeekPosition++];
@@ -1367,6 +1404,14 @@ void *decompress_segments(u8 *start, u8 *end) {
return (void *)freeSpace;
}
extern const course_texture mario_raceway_textures[30];
/* To help verify if ptrs are pointing within segments see gfx_pc.cpp gfx_step() */
uintptr_t vtxSegEnd;
uintptr_t dlSegEnd;
uintptr_t texSegEnd; size_t texSegSize;
Gfx *testaaa;
/**
* @brief Loads & DMAs course data. Vtx, textures, displaylists, etc.
* @param courseId
@@ -1374,37 +1419,45 @@ void *decompress_segments(u8 *start, u8 *end) {
void load_course(s32 courseId) {
printf("Loading Course Data\n");
// Extract packed DLs
u8 *packed = (u8 *) LOAD_ASSET(d_course_mario_raceway_packed_dls);
Gfx *gfx = (Gfx *) allocate_memory(sizeof(Gfx) * 3366); // Size of unpacked DLs
displaylist_unpack(gfx, packed, 0);
gSegmentTable[7] = &gfx[0];
testaaa = (Gfx *) LOAD_ASSET(d_course_mario_raceway_dl_0);
// Convert course vtx to vtx
CourseVtx *cvtx = (CourseVtx *) LOAD_ASSET(d_course_mario_raceway_vertex);
Vtx *vtx = (Vtx *) allocate_memory(sizeof(Vtx) * 5757);
func_802A86A8(cvtx, vtx, 5757);
gSegmentTable[4] = &vtx[0];
func_802A86A8(cvtx, vtx, 5757);
vtxSegEnd = &vtx[5757];
// Load and allocate memory for course textures
course_texture *asset = mario_raceway_textures;
u8 *freeMemory = NULL;
u8 *texture = NULL;
size_t size = 0;
texSegSize = 0;
while (asset->addr) {
size = ResourceGetTexSizeByName(asset->addr);
freeMemory = (u8 *) allocate_memory(size);
texture = (u8 *) LOAD_ASSET(asset->addr);
if (texture) {
if (asset == &mario_raceway_textures[0]) {
gSegmentTable[5] = &freeMemory[0];
}
memcpy(freeMemory, texture, size);
texSegSize += size;
// printf("Texture Addr: 0x%llX, size 0x%X\n", &freeMemory[0], size);
}
asset++;
}
texSegEnd = &((u8 *)gSegmentTable[5])[texSegSize];
// __gSPSegment(gDisplayListHead++, 7, &gfx);
// Extract packed DLs
u8 *packed = (u8 *) LOAD_ASSET(d_course_mario_raceway_packed_dls);
Gfx *gfx = (Gfx *) allocate_memory(sizeof(Gfx) * 3367); // Size of unpacked DLs
gSegmentTable[7] = &gfx[0];
displaylist_unpack(gfx, packed, 0);
dlSegEnd = &gfx[3367];
//printf("Course Data Loaded!\n");
// Future implementation for Extra mode and course stretching.
// if (gIsMirrorMode) {
// for (size_t i = 0; i < sizeof(vtx); i++) {
// dest->v.ob[0] = -courseVtx->ob[0];
// }
// }
// if (vtxStretchY != 1.0f) {
// dest->v.ob[1] *= vtxStretchY;
// }
}
+4 -1
View File
@@ -46,11 +46,14 @@ uintptr_t set_segment_base_addr(s32, void*);
void *get_segment_base_addr(s32);
void *segmented_to_virtual(const void *);
void *segment_offset_to_virtual(uint32_t, uint32_t);
void *segment_vtx_to_virtual(size_t offset);
void *segmented_texture_to_virtual(size_t offset);
void *segmented_uintptr_t_to_virtual(uintptr_t);
void *segmented_gfx_to_virtual(const void *);
void move_segment_table_to_dmem(void);
void initialize_memory_pool(void);
void *decompress_segments(u8*, u8*);
void *allocate_memory(uintptr_t);
void *allocate_memory(size_t);
void *load_data(uintptr_t, uintptr_t);
void func_802A7D54(s32, s32);
+19 -12
View File
@@ -20,6 +20,7 @@
#include "courses/all_course_packed.h"
#include "courses/all_course_offsets.h"
#include <assets/mario_raceway_data.h>
#include <assets/mario_raceway_displaylists.h>
s16 D_802B87B0 = 995;
s16 D_802B87B4 = 1000;
@@ -47,12 +48,12 @@ s32 func_80290C20(Camera *camera) {
}
void parse_course_displaylists(TrackSections *addr) {
TrackSections *first = addr;
TrackSections *section = addr;
TrackSections *first = &addr[0];
TrackSections *section = &addr[0];
while (addr->addr != 0) {
section->addr = segmented_gfx_to_virtual(addr->addr);
addr++;
while (section->addr != 0) {
printf("SECTION ADDR: 0x%X\n", section->addr);
section->addr = segmented_uintptr_t_to_virtual(section->addr);
section++;
}
section = first;
@@ -83,16 +84,15 @@ void parse_course_displaylists(TrackSections *addr) {
extern u32 isFlycam;
void load_surface_map(Gfx *addr[], struct UnkStruct_800DC5EC *arg1) {
void load_surface_map(const char* addr[], struct UnkStruct_800DC5EC *arg1) {
Player *player = arg1->player;
Camera *camera = arg1->camera;
//! @todo Should be Gfx*
Gfx **gfx = &addr;
s16 var_a3;
s16 temp_v1;
s16 sp1E;
s16 temp_v0_3;
u16 rot;
//printf("--------Loading Collision Mesh--------\n");
if (gIsMirrorMode) {
rot = (u16) camera->rot[1];
if (rot < 0x2000) {
@@ -126,6 +126,7 @@ void load_surface_map(Gfx *addr[], struct UnkStruct_800DC5EC *arg1) {
arg1->playerDirection = var_a3;
if (D_80152300[camera - camera1] == 1) {
printf("LOGIC\n");
sp1E = func_802ABD40(camera->unk_54.unk3A);
temp_v0_3 = func_802ABD40(player->unk_110.unk3A);
temp_v1 = sp1E - temp_v0_3;
@@ -180,6 +181,7 @@ void load_surface_map(Gfx *addr[], struct UnkStruct_800DC5EC *arg1) {
}
}
} else {
printf("ELSE\n");
temp_v1 = func_802ABD40(camera->unk_54.unk3A);
if (camera->unk_54.unk3C[2] > 30.0f) {
temp_v1 = arg1->pathCounter;
@@ -191,7 +193,11 @@ void load_surface_map(Gfx *addr[], struct UnkStruct_800DC5EC *arg1) {
arg1->pathCounter = temp_v1;
temp_v1 = ((temp_v1 - 1) * 4) + var_a3;
gSPDisplayList(gDisplayListHead++, (Gfx *)&gfx[temp_v1]);
printf("----Collision DL Call----\n");
//printf("temp_v1: %d\n", temp_v1);
//printf("Call: %s\n", addr[temp_v1]);
gSPDisplayList(gDisplayListHead++, addr[0]);
printf("--------Collision Mesh Loaded--------\n");
}
void func_80291198(void) {
@@ -618,7 +624,8 @@ void render_mario_raceway(struct UnkStruct_800DC5EC *arg0) {
// d_course_mario_raceway_packed_dl_14A0
gSPDisplayList(gDisplayListHead++, ((uintptr_t) segmented_gfx_to_virtual(0x070014A0)));
printf("LOADING SURFACE MAP\n");
load_surface_map(&mario_raceway_dls, arg0);
load_surface_map(mario_raceway_dls, arg0);
printf("SURFACE MAP LOADED\n");
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2);
gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK);
@@ -631,7 +638,7 @@ void render_mario_raceway(struct UnkStruct_800DC5EC *arg0) {
gSPDisplayList(gDisplayListHead++, ((uintptr_t) segmented_gfx_to_virtual(0x070000E0)));
// d_course_mario_raceway_packed_dl_160
gSPDisplayList(gDisplayListHead++, ((uintptr_t) segmented_gfx_to_virtual(0x07000160)));
printf("SURFACE MAP LOADED\n");
printf("RENDERED COURSE\n");
}
void render_choco_mountain(struct UnkStruct_800DC5EC *arg0) {
@@ -1452,7 +1459,7 @@ void func_80295D88(void) {
set_vertex_data_with_defaults((Gfx *) segmented_gfx_to_virtual(0x07002D68));
}
TrackSections *section = (TrackSections *) LOAD_ASSET(d_course_mario_raceway_addr);
parse_course_displaylists(section);
func_80295C6C();
D_8015F8E4 = gCourseMinY - 10.0f;
+1 -1
View File
@@ -7,7 +7,7 @@
void func_8029122C(struct UnkStruct_800DC5EC*, s32);
s32 func_80290C20(Camera*);
void parse_course_displaylists(uintptr_t);
void load_surface_map(Gfx*, struct UnkStruct_800DC5EC*);
void load_surface_map(const char*[], struct UnkStruct_800DC5EC*);
void func_80291198(void);
void func_802911C4(void);
void render_mario_raceway(struct UnkStruct_800DC5EC*);
+2 -2
View File
@@ -321,7 +321,7 @@ UNUSED Gfx D_802B8A90[] = {
};
struct Skybox sSkyColors[] = {
#include "assets/course_metadata/sSkyColors.inc.c"
#include "course_metadata/sSkyColors.inc.c"
};
@@ -350,7 +350,7 @@ struct Skybox sSkyColors[] = {
// };
struct Skybox sSkyColors2[] = {
#include "assets/course_metadata/sSkyColors2.inc.c"
#include "course_metadata/sSkyColors2.inc.c"
};
void func_802A450C(Vtx *skybox) {