Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve how asset are manage #694

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions courses/all_course_offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
#define ALL_COURSE_OFFSETS_H

#include "course_offsets.h"
#include "asset_types.h"

extern Gfx* banshee_boardwalk_dls[];
extern Gfx* bowsers_castle_dls[];
extern Gfx* choco_mountain_dls[];
extern Gfx* kalimari_desert_dls[];
extern Gfx* luigi_raceway_dls[];
extern Gfx* mario_raceway_dls[];
extern Gfx* moo_moo_farm_dls[];
extern Gfx* royal_raceway_dls[];
extern Gfx* sherbet_land_dls[];
extern Gfx* sherbet_land_dls_2[];
extern Gfx* wario_stadium_dls[];
extern GfxAsset banshee_boardwalk_dls[];
extern GfxAsset bowsers_castle_dls[];
extern GfxAsset choco_mountain_dls[];
extern GfxAsset kalimari_desert_dls[];
extern GfxAsset luigi_raceway_dls[];
extern GfxAsset mario_raceway_dls[];
extern GfxAsset moo_moo_farm_dls[];
extern GfxAsset royal_raceway_dls[];
extern GfxAsset sherbet_land_dls[];
extern GfxAsset sherbet_land_dls_2[];
extern GfxAsset wario_stadium_dls[];

extern Gfx toads_turnpike_dl_0[];
extern Gfx toads_turnpike_dl_1[];
Expand Down
3 changes: 2 additions & 1 deletion courses/banshee_boardwalk/course_offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "course_offsets.h"
#include "courses/banshee_boardwalk/course_data.h"
#include <PR/gbi.h>
#include "asset_types.h"

extern u8 gTexture6447C4[];
extern u8 gTexture676FB0[];
Expand Down Expand Up @@ -53,7 +54,7 @@ const course_texture banshee_boardwalk_textures[] = {
{ 0x00000000, 0x0000, 0x0000, 0x0 },
};

const Gfx* banshee_boardwalk_dls[] = {
const GfxAsset banshee_boardwalk_dls[] = {
d_course_banshee_boardwalk_dl_A0, d_course_banshee_boardwalk_dl_210, d_course_banshee_boardwalk_dl_160,
d_course_banshee_boardwalk_dl_270, d_course_banshee_boardwalk_dl_358, d_course_banshee_boardwalk_dl_4F0,
d_course_banshee_boardwalk_dl_408, d_course_banshee_boardwalk_dl_540, d_course_banshee_boardwalk_dl_620,
Expand Down
3 changes: 2 additions & 1 deletion courses/bowsers_castle/course_offsets.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <PR/ultratypes.h>
#include "course_offsets.h"
#include "course_data.h"
#include "asset_types.h"

extern u8 gTexture64313C[];
extern u8 gTexture6528DC[];
Expand Down Expand Up @@ -63,7 +64,7 @@ const course_texture bowsers_castle_textures[] = {
{ 0x00000000, 0x0000, 0x0000, 0x0 },
};

const Gfx* bowsers_castle_dls[] = {
const GfxAsset bowsers_castle_dls[] = {
d_course_bowsers_castle_dl_0, d_course_bowsers_castle_dl_230, d_course_bowsers_castle_dl_110,
d_course_bowsers_castle_dl_398, d_course_bowsers_castle_dl_428, d_course_bowsers_castle_dl_640,
d_course_bowsers_castle_dl_4F0, d_course_bowsers_castle_dl_7A0, d_course_bowsers_castle_dl_860,
Expand Down
3 changes: 2 additions & 1 deletion courses/choco_mountain/course_offsets.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <PR/ultratypes.h>
#include "course_offsets.h"
#include "course_data.h"
#include "asset_types.h"

extern u8 gTexture64619C[];
extern u8 gTexture64647C[];
Expand Down Expand Up @@ -47,7 +48,7 @@ const course_texture choco_mountain_textures[] = {
{ 0x00000000, 0x0000, 0x0000, 0x0 },
};

const Gfx* choco_mountain_dls[] = {
const GfxAsset choco_mountain_dls[] = {
d_course_choco_mountain_dl_0, d_course_choco_mountain_dl_150, d_course_choco_mountain_dl_B0,
d_course_choco_mountain_dl_208, d_course_choco_mountain_dl_2A8, d_course_choco_mountain_dl_410,
d_course_choco_mountain_dl_330, d_course_choco_mountain_dl_4D8, d_course_choco_mountain_dl_588,
Expand Down
3 changes: 3 additions & 0 deletions courses/courseTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include "courseTable.h"
#include "all_course_model.h"
#include "all_course_packed.h"
#include "config.h"

#if !ENABLE_CUSTOM_COURSE_ENGINE
struct CourseTable gCourseTable[] = { {
_course_mario_raceway_dl_mio0SegmentRomStart,
_course_mario_raceway_dl_mio0SegmentRomEnd,
Expand Down Expand Up @@ -304,3 +306,4 @@ struct CourseTable gCourseTable[] = { {
0,
0x0000,
} };
#endif
2 changes: 2 additions & 0 deletions courses/courseTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ struct CourseTable {
u16 padding; // 0x2E
};

#if !ENABLE_CUSTOM_COURSE_ENGINE
extern struct CourseTable gCourseTable[];
#endif

//! @todo These should probably be ptr's instead of array's?
extern u8 _course_mario_raceway_dl_mio0SegmentRomStart[];
Expand Down
3 changes: 2 additions & 1 deletion courses/kalimari_desert/course_offsets.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <PR/ultratypes.h>
#include "course_offsets.h"
#include "course_data.h"
#include "asset_types.h"

extern u8 gTexture6684F8[];
extern u8 gTextureSignLuigis0[];
Expand Down Expand Up @@ -44,7 +45,7 @@ const course_texture kalimari_desert_textures[] = {
{ gTextureSignKoopaAir1, 0x0304, 0x1000, 0x0 }, { 0x00000000, 0x0000, 0x0000, 0x0 },
};

const Gfx* kalimari_desert_dls[] = {
const GfxAsset kalimari_desert_dls[] = {
d_course_kalimari_desert_dl_0, d_course_kalimari_desert_dl_258, d_course_kalimari_desert_dl_100,
d_course_kalimari_desert_dl_310, d_course_kalimari_desert_dl_4A0, d_course_kalimari_desert_dl_778,
d_course_kalimari_desert_dl_5C0, d_course_kalimari_desert_dl_858, d_course_kalimari_desert_dl_A58,
Expand Down
3 changes: 2 additions & 1 deletion courses/luigi_raceway/course_offsets.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <PR/ultratypes.h>
#include "course_offsets.h"
#include "course_data.h"
#include "asset_types.h"

extern u8 gTextureSignShellShot0[];
extern u8 gTextureSignShellShot1[];
Expand Down Expand Up @@ -87,7 +88,7 @@ const course_texture luigi_raceway_textures[] = {
{ 0x00000000, 0x0000, 0x0000, 0x0 },
};

const Gfx* luigi_raceway_dls[] = {
const GfxAsset luigi_raceway_dls[] = {
d_course_luigi_raceway_dl_0, d_course_luigi_raceway_dl_328, d_course_luigi_raceway_dl_1A8,
d_course_luigi_raceway_dl_480, d_course_luigi_raceway_dl_6E0, d_course_luigi_raceway_dl_9F8,
d_course_luigi_raceway_dl_868, d_course_luigi_raceway_dl_B48, d_course_luigi_raceway_dl_D80,
Expand Down
3 changes: 2 additions & 1 deletion courses/mario_raceway/course_offsets.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <PR/ultratypes.h>
#include "course_offsets.h"
#include "course_data.h"
#include "asset_types.h"

extern u8 gTextureCheckerboardYellowPink[];
extern u8 gTexture64619C[];
Expand Down Expand Up @@ -67,7 +68,7 @@ const course_texture mario_raceway_textures[] = {
{ 0x00000000, 0x0000, 0x0000, 0x0 },
};

const Gfx* mario_raceway_dls[] = {
const GfxAsset mario_raceway_dls[] = {
d_course_mario_raceway_dl_0, d_course_mario_raceway_dl_1D0, d_course_mario_raceway_dl_E8,
d_course_mario_raceway_dl_2C8, d_course_mario_raceway_dl_3A8, d_course_mario_raceway_dl_568,
d_course_mario_raceway_dl_478, d_course_mario_raceway_dl_668, d_course_mario_raceway_dl_750,
Expand Down
3 changes: 2 additions & 1 deletion courses/moo_moo_farm/course_offsets.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <PR/ultratypes.h>
#include "course_offsets.h"
#include "course_data.h"
#include "asset_types.h"

extern u8 gTextureWoodDoor0[];
extern u8 gTextureGrass2[];
Expand Down Expand Up @@ -63,7 +64,7 @@ const course_texture moo_moo_farm_textures[] = {
{ 0x00000000, 0x0000, 0x0000, 0x0 },
};

const Gfx* moo_moo_farm_dls[] = {
const GfxAsset moo_moo_farm_dls[] = {
d_course_moo_moo_farm_dl_88, d_course_moo_moo_farm_dl_598, d_course_moo_moo_farm_dl_338,
d_course_moo_moo_farm_dl_8A0, d_course_moo_moo_farm_dl_B00, d_course_moo_moo_farm_dl_FE0,
d_course_moo_moo_farm_dl_D70, d_course_moo_moo_farm_dl_12B8, d_course_moo_moo_farm_dl_1530,
Expand Down
3 changes: 2 additions & 1 deletion courses/royal_raceway/course_offsets.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <PR/ultratypes.h>
#include "course_offsets.h"
#include "course_data.h"
#include "asset_types.h"

extern u8 gTexture64619C[];
extern u8 gTexture645134[];
Expand Down Expand Up @@ -93,7 +94,7 @@ const course_texture royal_raceway_textures[] = {
{ 0x00000000, 0x0000, 0x0000, 0x0 },
};

const Gfx* royal_raceway_dls[] = {
const GfxAsset royal_raceway_dls[] = {
d_course_royal_raceway_dl_0, d_course_royal_raceway_dl_360, d_course_royal_raceway_dl_258,
d_course_royal_raceway_dl_470, d_course_royal_raceway_dl_6D0, d_course_royal_raceway_dl_A48,
d_course_royal_raceway_dl_8E0, d_course_royal_raceway_dl_B40, d_course_royal_raceway_dl_DA0,
Expand Down
5 changes: 3 additions & 2 deletions courses/sherbet_land/course_offsets.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <PR/ultratypes.h>
#include "course_offsets.h"
#include "course_data.h"
#include "asset_types.h"

extern u8 gTexture643B3C[];
extern u8 gTexture66D024[];
Expand All @@ -22,7 +23,7 @@ const course_texture sherbet_land_textures[] = {
{ 0x00000000, 0x0000, 0x0000, 0x0 },
};

const Gfx* sherbet_land_dls[] = {
const GfxAsset sherbet_land_dls[] = {
d_course_sherbet_land_dl_0, d_course_sherbet_land_dl_158, d_course_sherbet_land_dl_C0,
d_course_sherbet_land_dl_1A8, d_course_sherbet_land_dl_280, d_course_sherbet_land_dl_3B8,
d_course_sherbet_land_dl_310, d_course_sherbet_land_dl_400, d_course_sherbet_land_dl_4E8,
Expand All @@ -49,7 +50,7 @@ const Gfx* sherbet_land_dls[] = {
d_course_sherbet_land_dl_25A0, d_course_sherbet_land_dl_2530, d_course_sherbet_land_dl_25F8,
};

const Gfx* sherbet_land_dls_2[] = {
const GfxAsset sherbet_land_dls_2[] = {
d_course_sherbet_land_dl_26D0, d_course_sherbet_land_dl_28A0, d_course_sherbet_land_dl_27F0,
d_course_sherbet_land_dl_2918, d_course_sherbet_land_dl_2A38, d_course_sherbet_land_dl_2BE0,
d_course_sherbet_land_dl_2B08, d_course_sherbet_land_dl_2C58, d_course_sherbet_land_dl_2D78,
Expand Down
7 changes: 7 additions & 0 deletions include/asset_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#if !ENABLE_CUSTOM_ASSET_TYPE
typedef Gfx* GfxAsset;
typedef u8* TextureAsset;
typedef u8* TextureAssetList;
#else

#endif
2 changes: 2 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
*
*/
#define ENABLE_CUSTOM_COURSE_ENGINE 0

#define ENABLE_CUSTOM_ASSET_TYPE 0
#endif
22 changes: 22 additions & 0 deletions include/macros.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef _MACROS_H_
#define _MACROS_H_

#include "config.h"

#ifndef __sgi
#define GLOBAL_ASM(...)
#endif
Expand Down Expand Up @@ -92,6 +94,14 @@
// another way of converting virtual to physical
#define VIRTUAL_TO_PHYSICAL2(addr) ((u8*) (addr) - 0x80000000U)

#if !ENABLE_CUSTOM_ASSET_TYPE
#define VIRTUAL_TO_PHYSICAL_ASSET(addr) \
VIRTUAL_TO_PHYSICAL2(gSegmentTable[SEGMENT_NUMBER2(addr)] + SEGMENT_OFFSET(addr))
#else
#define VIRTUAL_TO_PHYSICAL_ASSET(addr)

#endif

// aligns an address to the next 16 bytes
#define ALIGN16(val) (((val) + 0xF) & ~0xF)

Expand All @@ -103,4 +113,16 @@
**/
#define GET_PACKED_END(dl) (((u8*) dl) + sizeof(dl) - sizeof(dl[0]) - 0x07000000)

#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif

#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif

#ifndef CLAMP
#define CLAMP(var, min, max) ((var) < (min) ? min : (var) > (max) ? max : var)
#endif

#endif
7 changes: 4 additions & 3 deletions include/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "spline.h"
#include <common_structs.h>
#include "asset_types.h"

#define OBJECT_LIST_SIZE 0x226
#define SOME_OBJECT_INDEX_LIST_SIZE 32
Expand All @@ -22,15 +23,15 @@ typedef struct {
/* 0x54 */ s32 status;
/* 0x58 */ s32 unk_058;
/* 0x5C */ s32 unk_05C;
/* 0x60 */ u8* activeTLUT;
/* 0x64 */ u8* activeTexture;
/* 0x60 */ TextureAsset activeTLUT;
/* 0x64 */ TextureAsset activeTexture;
/**
* "list" is something of a misnomer for the names here
* they can be pointers to just 1 tlut/texture, but it is common for one or the other
* to be a pointer to an array of tluts/textures.
**/
/* 0x68 */ u8* tlutList; // I feel like this should actually be `u8 (*tlutList)[512]`, but that causes mismatches
/* 0x6C */ u8* textureList;
/* 0x6C */ TextureAssetList textureList;
/* 0x70 */ Gfx* model;
/* 0x74 */ Vtx* vertex;
/* 0x78 */ s8 unk_078[0x04];
Expand Down
13 changes: 6 additions & 7 deletions src/actors/falling_rock/update.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include "courses/choco_mountain/course_data.h"

void func_8029CF0C(struct ActorSpawnData* spawnData, struct FallingRock* rock) {
s32 segment = SEGMENT_NUMBER2(spawnData);
s32 offset = SEGMENT_OFFSET(spawnData);
struct ActorSpawnData* temp_v0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset);
UNUSED u32 unk;
UNUSED u32 unk2;
struct ActorSpawnData* temp_v0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL_ASSET(spawnData);
Vec3s sp24 = { 60, 120, 180 };
temp_v0 += rock->unk_06;
rock->respawnTimer = sp24[rock->unk_06]; // * 2
Expand All @@ -24,10 +24,9 @@ void func_8029CF0C(struct ActorSpawnData* spawnData, struct FallingRock* rock) {
* @param spawnData
*/
void spawn_falling_rocks(struct ActorSpawnData* spawnData) {
s32 addr = SEGMENT_NUMBER2(spawnData);
s32 offset = SEGMENT_OFFSET(spawnData);
// Casting this to prevent warning does not work.
struct ActorSpawnData* temp_s0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr] + offset);
UNUSED u32 unk;
UNUSED u32 unk1;
struct ActorSpawnData* temp_s0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL_ASSET(spawnData);
struct FallingRock* temp_v1;
Vec3f startingPos;
Vec3f startingVelocity;
Expand Down
10 changes: 2 additions & 8 deletions src/code_80005FD0.c
Original file line number Diff line number Diff line change
Expand Up @@ -4345,9 +4345,7 @@ void func_80011EC0(s32 arg0, Player* player, s32 arg2, UNUSED u16 arg3) {
void generate_train_waypoints(void) {
s32 i;
Path2D* temp;
TrackWaypoint* waypoint =
(TrackWaypoint*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[SEGMENT_NUMBER2(d_course_kalimari_desert_train_waypoints)] +
SEGMENT_OFFSET(d_course_kalimari_desert_train_waypoints));
TrackWaypoint* waypoint = (TrackWaypoint*) VIRTUAL_TO_PHYSICAL_ASSET(d_course_kalimari_desert_train_waypoints);

GET_PATH_LENGTH(waypoint)

Expand All @@ -4357,13 +4355,9 @@ void generate_train_waypoints(void) {
}

void generate_ferry_waypoints(void) {
TrackWaypoint* waypoint;
TrackWaypoint* waypoint = (TrackWaypoint*) VIRTUAL_TO_PHYSICAL_ASSET(d_course_dks_jungle_parkway_ferry_waypoints);
s32 i;

waypoint = (TrackWaypoint*) VIRTUAL_TO_PHYSICAL2(
gSegmentTable[SEGMENT_NUMBER2(d_course_dks_jungle_parkway_ferry_waypoints)] +
(SEGMENT_OFFSET(d_course_dks_jungle_parkway_ferry_waypoints)));

GET_PATH_LENGTH(waypoint)

gVehicle2DWaypointLength = generate_2d_path(gVehicle2DWaypoint, waypoint, i - 1);
Expand Down
Loading