From 6155b6416a14ca9795ee4fb821c1a98305f855b0 Mon Sep 17 00:00:00 2001 From: Arceveti <73617174+Arceveti@users.noreply.github.com> Date: Mon, 27 Sep 2021 12:28:47 -0700 Subject: [PATCH] Some cleanup & fixes --- actors/bowser_flame/model.inc.c | 28 +- actors/common1.h | 2 +- actors/impact_smoke/model.inc.c | 16 +- actors/koopa/model.inc.c | 4 +- bin/title_screen_bg.c | 2 +- haveyourcake2.patch | 4 +- include/textures.h | 468 ++++++++++---------- levels/bbh/header.h | 2 +- levels/castle_inside/header.h | 6 +- levels/hmc/header.h | 4 +- levels/intro/leveldata.c | 4 +- levels/menu/header.h | 4 +- levels/ssl/header.h | 4 +- levels/ttc/header.h | 2 +- src/engine/level_script.h | 2 +- src/game/area.h | 2 +- src/game/behaviors/camera_lakitu.inc.c | 6 +- src/game/behaviors/chain_chomp.inc.c | 14 +- src/game/behaviors/intro_lakitu.inc.c | 49 +- src/game/behaviors/lll_hexagonal_ring.inc.c | 3 +- src/game/behaviors/tweester.inc.c | 9 +- src/game/behaviors/water_objs.inc.c | 27 +- src/game/camera.c | 331 +++++--------- src/game/camera.h | 12 +- src/game/debug_box.c | 53 +-- src/game/ingame_menu.c | 28 +- src/game/mario_actions_automatic.c | 8 +- src/game/mario_misc.c | 7 +- src/game/moving_texture.c | 170 +++---- src/game/obj_behaviors.c | 2 +- src/game/obj_behaviors_2.c | 94 +--- src/game/object_helpers.c | 5 +- src/game/object_list_processor.c | 43 +- src/game/paintings.c | 34 +- src/game/print.c | 128 ++---- src/game/puppycam2.h | 170 +++---- src/game/puppylights.h | 22 +- src/game/puppyprint.h | 16 +- src/game/rendering_graph_node.c | 22 +- src/game/segment7.h | 28 +- src/game/skybox.c | 4 +- src/game/sound_init.c | 1 - src/goddard/draw_objects.c | 51 ++- src/menu/intro_geo.c | 4 +- tools/skyconv.c | 2 +- 45 files changed, 782 insertions(+), 1115 deletions(-) diff --git a/actors/bowser_flame/model.inc.c b/actors/bowser_flame/model.inc.c index ae62573d..15c50d0a 100644 --- a/actors/bowser_flame/model.inc.c +++ b/actors/bowser_flame/model.inc.c @@ -120,7 +120,7 @@ const Gfx flame_seg6_dl_0601C108[] = { gsDPLoadTextureBlock(flame_seg6_texture_06000000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_06000000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_06000000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -132,7 +132,7 @@ const Gfx flame_seg6_dl_0601C1A8[] = { gsDPLoadTextureBlock(flame_seg6_texture_06002000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_06002000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_06002000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -144,7 +144,7 @@ const Gfx flame_seg6_dl_0601C248[] = { gsDPLoadTextureBlock(flame_seg6_texture_06004000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_06004000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_06004000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -156,7 +156,7 @@ const Gfx flame_seg6_dl_0601C2E8[] = { gsDPLoadTextureBlock(flame_seg6_texture_06006000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_06006000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_06006000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -168,7 +168,7 @@ const Gfx flame_seg6_dl_0601C388[] = { gsDPLoadTextureBlock(flame_seg6_texture_06008000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_06008000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_06008000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -180,7 +180,7 @@ const Gfx flame_seg6_dl_0601C428[] = { gsDPLoadTextureBlock(flame_seg6_texture_0600A000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_0600A000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_0600A000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -192,7 +192,7 @@ const Gfx flame_seg6_dl_0601C4C8[] = { gsDPLoadTextureBlock(flame_seg6_texture_0600C000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_0600C000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_0600C000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -204,7 +204,7 @@ const Gfx flame_seg6_dl_0601C568[] = { gsDPLoadTextureBlock(flame_seg6_texture_0600E000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_0600E000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_0600E000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -216,7 +216,7 @@ const Gfx flame_seg6_dl_0601C608[] = { gsDPLoadTextureBlock(flame_seg6_texture_06010000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_06010000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_06010000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -228,7 +228,7 @@ const Gfx flame_seg6_dl_0601C6A8[] = { gsDPLoadTextureBlock(flame_seg6_texture_06012000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_06012000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_06012000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -240,7 +240,7 @@ const Gfx flame_seg6_dl_0601C748[] = { gsDPLoadTextureBlock(flame_seg6_texture_06014000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_06014000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_06014000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -252,7 +252,7 @@ const Gfx flame_seg6_dl_0601C7E8[] = { gsDPLoadTextureBlock(flame_seg6_texture_06016000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_06016000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_06016000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -264,7 +264,7 @@ const Gfx flame_seg6_dl_0601C888[] = { gsDPLoadTextureBlock(flame_seg6_texture_06018000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_06018000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_06018000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), @@ -276,7 +276,7 @@ const Gfx flame_seg6_dl_0601C928[] = { gsDPLoadTextureBlock(flame_seg6_texture_0601A000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(flame_seg6_vertex_0601C000, 8, 0), gsSPDisplayList(flame_seg6_dl_0601C0B0), - gsDPLoadTextureBlock((u8*)flame_seg6_texture_0601A000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)flame_seg6_texture_0601A000 + 0x1000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(flame_seg6_dl_0601C0C8), gsSPDisplayList(flame_seg6_dl_0601C0E0), gsSPEndDisplayList(), diff --git a/actors/common1.h b/actors/common1.h index badf9808..e7a993cb 100644 --- a/actors/common1.h +++ b/actors/common1.h @@ -191,7 +191,7 @@ extern const GeoLayout number_geo[]; extern const Gfx pebble_seg3_dl_0301CB00[]; // power_meter -extern const u8 *const power_meter_health_segments_lut[]; +extern const Texture *const power_meter_health_segments_lut[]; extern const Gfx dl_power_meter_base[]; extern const Gfx dl_power_meter_health_segments_begin[]; extern const Gfx dl_power_meter_health_segments_end[]; diff --git a/actors/impact_smoke/model.inc.c b/actors/impact_smoke/model.inc.c index cf44016d..2c4b4ff9 100644 --- a/actors/impact_smoke/model.inc.c +++ b/actors/impact_smoke/model.inc.c @@ -3,22 +3,22 @@ // TODO: These 64x64 textures are referenced as two different texture addresses in the DLs // 0x0605AA28 -ALIGNED8 static const u8 impact_smoke_seg6_texture_0605AA28[] = { +ALIGNED8 static const Texture impact_smoke_seg6_texture_0605AA28[] = { #include "actors/impact_smoke/impact_smoke_0.ia16.inc.c" }; // 0x0605CA28 -ALIGNED8 static const u8 impact_smoke_seg6_texture_0605CA28[] = { +ALIGNED8 static const Texture impact_smoke_seg6_texture_0605CA28[] = { #include "actors/impact_smoke/impact_smoke_1.ia16.inc.c" }; // 0x0605EA28 -ALIGNED8 static const u8 impact_smoke_seg6_texture_0605EA28[] = { +ALIGNED8 static const Texture impact_smoke_seg6_texture_0605EA28[] = { #include "actors/impact_smoke/impact_smoke_2.ia16.inc.c" }; // 0x06060A28 -ALIGNED8 static const u8 impact_smoke_seg6_texture_06060A28[] = { +ALIGNED8 static const Texture impact_smoke_seg6_texture_06060A28[] = { #include "actors/impact_smoke/impact_smoke_3.ia16.inc.c" }; @@ -71,7 +71,7 @@ const Gfx impact_smoke_seg6_dl_06062B38[] = { gsDPLoadTextureBlock(impact_smoke_seg6_texture_0605AA28, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(impact_smoke_seg6_vertex_06062A28, 8, 0), gsSPDisplayList(impact_smoke_seg6_dl_06062AD8), - gsDPLoadTextureBlock((u8*)impact_smoke_seg6_texture_0605AA28 + 0x1000, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)impact_smoke_seg6_texture_0605AA28 + 0x1000, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(impact_smoke_seg6_dl_06062AF0), gsSPDisplayList(impact_smoke_seg6_dl_06062B08), gsSPEndDisplayList(), @@ -83,7 +83,7 @@ const Gfx impact_smoke_seg6_dl_06062BD8[] = { gsDPLoadTextureBlock(impact_smoke_seg6_texture_0605CA28, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(impact_smoke_seg6_vertex_06062A28, 8, 0), gsSPDisplayList(impact_smoke_seg6_dl_06062AD8), - gsDPLoadTextureBlock((u8*)impact_smoke_seg6_texture_0605CA28 + 0x1000, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)impact_smoke_seg6_texture_0605CA28 + 0x1000, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(impact_smoke_seg6_dl_06062AF0), gsSPDisplayList(impact_smoke_seg6_dl_06062B08), gsSPEndDisplayList(), @@ -95,7 +95,7 @@ const Gfx impact_smoke_seg6_dl_06062C78[] = { gsDPLoadTextureBlock(impact_smoke_seg6_texture_0605EA28, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(impact_smoke_seg6_vertex_06062A28, 8, 0), gsSPDisplayList(impact_smoke_seg6_dl_06062AD8), - gsDPLoadTextureBlock((u8*)impact_smoke_seg6_texture_0605EA28 + 0x1000, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)impact_smoke_seg6_texture_0605EA28 + 0x1000, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(impact_smoke_seg6_dl_06062AF0), gsSPDisplayList(impact_smoke_seg6_dl_06062B08), gsSPEndDisplayList(), @@ -107,7 +107,7 @@ const Gfx impact_smoke_seg6_dl_06062D18[] = { gsDPLoadTextureBlock(impact_smoke_seg6_texture_06060A28, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPVertex(impact_smoke_seg6_vertex_06062A28, 8, 0), gsSPDisplayList(impact_smoke_seg6_dl_06062AD8), - gsDPLoadTextureBlock((u8*)impact_smoke_seg6_texture_06060A28 + 0x1000, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), + gsDPLoadTextureBlock((Texture*)impact_smoke_seg6_texture_06060A28 + 0x1000, G_IM_FMT_IA, G_IM_SIZ_16b, 64, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPDisplayList(impact_smoke_seg6_dl_06062AF0), gsSPDisplayList(impact_smoke_seg6_dl_06062B08), gsSPEndDisplayList(), diff --git a/actors/koopa/model.inc.c b/actors/koopa/model.inc.c index 0332069d..9b2da641 100644 --- a/actors/koopa/model.inc.c +++ b/actors/koopa/model.inc.c @@ -2078,8 +2078,8 @@ const Gfx koopa_seg6_dl_0600C498[] = { gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP1Triangle( 6, 7, 8, 0x0), #ifdef KOOPA_KEEP_PINK_SHORTS - gsSPLight((u8*)koopa_seg6_texture_06002648 + 0x20, 1), // this malformed light results in a - gsSPLight((u8*)koopa_seg6_texture_06002648 + 0x18, 2), // koopa appearing to wear pink shorts. + gsSPLight((Texture*)koopa_seg6_texture_06002648 + 0x20, 1), // this malformed light results in a + gsSPLight((Texture*)koopa_seg6_texture_06002648 + 0x18, 2), // koopa appearing to wear pink shorts. #endif gsSPVertex(koopa_seg6_vertex_0600B5F0, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), diff --git a/bin/title_screen_bg.c b/bin/title_screen_bg.c index f7ee7d59..c52684bb 100644 --- a/bin/title_screen_bg.c +++ b/bin/title_screen_bg.c @@ -142,7 +142,7 @@ const Gfx title_screen_bg_dl_face_easter_egg_end[] = { #endif #if ENABLE_RUMBLE -ALIGNED8 static const u8 title_texture_rumble_pak[] = { +ALIGNED8 static const Texture title_texture_rumble_pak[] = { #include "textures/title_screen_bg/title_screen_bg.06648.rgba16.inc.c" }; diff --git a/haveyourcake2.patch b/haveyourcake2.patch index bf211006..4e529d20 100644 --- a/haveyourcake2.patch +++ b/haveyourcake2.patch @@ -739,9 +739,9 @@ index b515373..1fdf027 100644 } int numTiles = TABLE_DIMENSIONS[type].cols * TABLE_DIMENSIONS[type].rows; -+ fprintf(cFile, "ALIGNED8 static const u8 cake_end_texture_%sdata[] = {\n", euSuffx); ++ fprintf(cFile, "ALIGNED8 static const Texture cake_end_texture_%sdata[] = {\n", euSuffx); for (int i = 0; i < numTiles; ++i) { -- fprintf(cFile, "ALIGNED8 static const u8 cake_end_texture_%s%d[] = {\n", euSuffx, i); +- fprintf(cFile, "ALIGNED8 static const Texture cake_end_texture_%s%d[] = {\n", euSuffx, i); print_raw_data(cFile, &tiles[i]); - fputs("};\n\n", cFile); + fputc('\n', cFile); diff --git a/include/textures.h b/include/textures.h index 4df137cb..c64ccdd9 100644 --- a/include/textures.h +++ b/include/textures.h @@ -5,262 +5,262 @@ #include // cave -extern const u8 cave_09000000[]; -extern const u8 cave_09001000[]; -extern const u8 cave_09001800[]; -extern const u8 cave_09002800[]; -extern const u8 cave_09003000[]; -extern const u8 cave_09003800[]; -extern const u8 cave_09004800[]; -extern const u8 cave_09005800[]; -extern const u8 cave_09006800[]; -extern const u8 cave_09007000[]; -extern const u8 cave_09007800[]; -extern const u8 cave_09008800[]; -extern const u8 cave_09009800[]; -extern const u8 cave_0900A000[]; -extern const u8 cave_0900A800[]; -extern const u8 cave_0900B800[]; -extern const u8 cave_0900C000[]; +extern const Texture cave_09000000[]; +extern const Texture cave_09001000[]; +extern const Texture cave_09001800[]; +extern const Texture cave_09002800[]; +extern const Texture cave_09003000[]; +extern const Texture cave_09003800[]; +extern const Texture cave_09004800[]; +extern const Texture cave_09005800[]; +extern const Texture cave_09006800[]; +extern const Texture cave_09007000[]; +extern const Texture cave_09007800[]; +extern const Texture cave_09008800[]; +extern const Texture cave_09009800[]; +extern const Texture cave_0900A000[]; +extern const Texture cave_0900A800[]; +extern const Texture cave_0900B800[]; +extern const Texture cave_0900C000[]; // fire -extern const u8 fire_09000000[]; -extern const u8 fire_09000800[]; -extern const u8 fire_09001000[]; -extern const u8 fire_09001800[]; -extern const u8 fire_09002000[]; -extern const u8 fire_09002800[]; -extern const u8 fire_09003000[]; -extern const u8 fire_09003800[]; -extern const u8 fire_09004000[]; -extern const u8 fire_09004800[]; -extern const u8 fire_09005000[]; -extern const u8 fire_09005800[]; -extern const u8 fire_09006000[]; -extern const u8 fire_09006800[]; -extern const u8 fire_09007000[]; -extern const u8 fire_09007800[]; -extern const u8 fire_09008000[]; -extern const u8 fire_09008800[]; -extern const u8 fire_09009000[]; -extern const u8 fire_09009800[]; -extern const u8 fire_0900A000[]; -extern const u8 fire_0900A800[]; -extern const u8 fire_0900B000[]; -extern const u8 fire_0900B800[]; +extern const Texture fire_09000000[]; +extern const Texture fire_09000800[]; +extern const Texture fire_09001000[]; +extern const Texture fire_09001800[]; +extern const Texture fire_09002000[]; +extern const Texture fire_09002800[]; +extern const Texture fire_09003000[]; +extern const Texture fire_09003800[]; +extern const Texture fire_09004000[]; +extern const Texture fire_09004800[]; +extern const Texture fire_09005000[]; +extern const Texture fire_09005800[]; +extern const Texture fire_09006000[]; +extern const Texture fire_09006800[]; +extern const Texture fire_09007000[]; +extern const Texture fire_09007800[]; +extern const Texture fire_09008000[]; +extern const Texture fire_09008800[]; +extern const Texture fire_09009000[]; +extern const Texture fire_09009800[]; +extern const Texture fire_0900A000[]; +extern const Texture fire_0900A800[]; +extern const Texture fire_0900B000[]; +extern const Texture fire_0900B800[]; // generic -extern const u8 generic_09000000[]; -extern const u8 generic_09000800[]; -extern const u8 generic_09001000[]; -extern const u8 generic_09001800[]; -extern const u8 generic_09002000[]; -extern const u8 generic_09002800[]; -extern const u8 generic_09003000[]; -extern const u8 generic_09003800[]; -extern const u8 generic_09004000[]; -extern const u8 generic_09004800[]; -extern const u8 generic_09005000[]; -extern const u8 generic_09005800[]; -extern const u8 generic_09006000[]; -extern const u8 generic_09007000[]; -extern const u8 generic_09007800[]; -extern const u8 generic_09008000[]; -extern const u8 generic_09008800[]; -extern const u8 generic_09009000[]; -extern const u8 generic_09009800[]; -extern const u8 generic_0900A000[]; -extern const u8 generic_0900A800[]; -extern const u8 generic_0900B000[]; +extern const Texture generic_09000000[]; +extern const Texture generic_09000800[]; +extern const Texture generic_09001000[]; +extern const Texture generic_09001800[]; +extern const Texture generic_09002000[]; +extern const Texture generic_09002800[]; +extern const Texture generic_09003000[]; +extern const Texture generic_09003800[]; +extern const Texture generic_09004000[]; +extern const Texture generic_09004800[]; +extern const Texture generic_09005000[]; +extern const Texture generic_09005800[]; +extern const Texture generic_09006000[]; +extern const Texture generic_09007000[]; +extern const Texture generic_09007800[]; +extern const Texture generic_09008000[]; +extern const Texture generic_09008800[]; +extern const Texture generic_09009000[]; +extern const Texture generic_09009800[]; +extern const Texture generic_0900A000[]; +extern const Texture generic_0900A800[]; +extern const Texture generic_0900B000[]; // grass -extern const u8 grass_09000000[]; -extern const u8 grass_09000800[]; -extern const u8 grass_09001000[]; -extern const u8 grass_09001800[]; -extern const u8 grass_09002000[]; -extern const u8 grass_09002800[]; -extern const u8 grass_09003000[]; -extern const u8 grass_09003800[]; -extern const u8 grass_09004000[]; -extern const u8 grass_09004800[]; -extern const u8 grass_09005000[]; -extern const u8 grass_09005800[]; -extern const u8 grass_09006000[]; -extern const u8 grass_09006800[]; -extern const u8 grass_09007000[]; -extern const u8 grass_09007800[]; -extern const u8 grass_09008000[]; -extern const u8 grass_09008800[]; -extern const u8 grass_09009000[]; -extern const u8 grass_09009800[]; -extern const u8 grass_0900A000[]; -extern const u8 grass_0900A800[]; -extern const u8 grass_0900B000[]; -extern const u8 grass_0900B800[]; +extern const Texture grass_09000000[]; +extern const Texture grass_09000800[]; +extern const Texture grass_09001000[]; +extern const Texture grass_09001800[]; +extern const Texture grass_09002000[]; +extern const Texture grass_09002800[]; +extern const Texture grass_09003000[]; +extern const Texture grass_09003800[]; +extern const Texture grass_09004000[]; +extern const Texture grass_09004800[]; +extern const Texture grass_09005000[]; +extern const Texture grass_09005800[]; +extern const Texture grass_09006000[]; +extern const Texture grass_09006800[]; +extern const Texture grass_09007000[]; +extern const Texture grass_09007800[]; +extern const Texture grass_09008000[]; +extern const Texture grass_09008800[]; +extern const Texture grass_09009000[]; +extern const Texture grass_09009800[]; +extern const Texture grass_0900A000[]; +extern const Texture grass_0900A800[]; +extern const Texture grass_0900B000[]; +extern const Texture grass_0900B800[]; // inside -extern const u8 inside_09000000[]; -extern const u8 inside_09001000[]; -extern const u8 inside_09002000[]; -extern const u8 inside_09003000[]; -extern const u8 inside_09003800[]; -extern const u8 inside_09004000[]; -extern const u8 inside_09004800[]; -extern const u8 inside_09005000[]; -extern const u8 inside_09005800[]; -extern const u8 inside_09006000[]; -extern const u8 inside_09007000[]; -extern const u8 inside_09008000[]; -extern const u8 inside_09008800[]; -extern const u8 inside_09009000[]; -extern const u8 inside_0900A000[]; -extern const u8 inside_0900B000[]; -extern const u8 inside_0900B800[]; +extern const Texture inside_09000000[]; +extern const Texture inside_09001000[]; +extern const Texture inside_09002000[]; +extern const Texture inside_09003000[]; +extern const Texture inside_09003800[]; +extern const Texture inside_09004000[]; +extern const Texture inside_09004800[]; +extern const Texture inside_09005000[]; +extern const Texture inside_09005800[]; +extern const Texture inside_09006000[]; +extern const Texture inside_09007000[]; +extern const Texture inside_09008000[]; +extern const Texture inside_09008800[]; +extern const Texture inside_09009000[]; +extern const Texture inside_0900A000[]; +extern const Texture inside_0900B000[]; +extern const Texture inside_0900B800[]; // machine -extern const u8 machine_09000000[]; -extern const u8 machine_09000800[]; -extern const u8 machine_09001000[]; -extern const u8 machine_09001800[]; -extern const u8 machine_09002000[]; -extern const u8 machine_09002800[]; -extern const u8 machine_09003000[]; -extern const u8 machine_09003800[]; -extern const u8 machine_09004000[]; -extern const u8 machine_09005000[]; -extern const u8 machine_09005800[]; -extern const u8 machine_09006000[]; -extern const u8 machine_09006800[]; -extern const u8 machine_09007000[]; -extern const u8 machine_09007800[]; -extern const u8 machine_09008000[]; -extern const u8 machine_09008400[]; +extern const Texture machine_09000000[]; +extern const Texture machine_09000800[]; +extern const Texture machine_09001000[]; +extern const Texture machine_09001800[]; +extern const Texture machine_09002000[]; +extern const Texture machine_09002800[]; +extern const Texture machine_09003000[]; +extern const Texture machine_09003800[]; +extern const Texture machine_09004000[]; +extern const Texture machine_09005000[]; +extern const Texture machine_09005800[]; +extern const Texture machine_09006000[]; +extern const Texture machine_09006800[]; +extern const Texture machine_09007000[]; +extern const Texture machine_09007800[]; +extern const Texture machine_09008000[]; +extern const Texture machine_09008400[]; // mountain -extern const u8 mountain_09000000[]; -extern const u8 mountain_09000800[]; -extern const u8 mountain_09001800[]; -extern const u8 mountain_09002800[]; -extern const u8 mountain_09003000[]; -extern const u8 mountain_09003800[]; -extern const u8 mountain_09004000[]; -extern const u8 mountain_09004800[]; -extern const u8 mountain_09005000[]; -extern const u8 mountain_09005800[]; -extern const u8 mountain_09006800[]; -extern const u8 mountain_09007000[]; -extern const u8 mountain_09007800[]; -extern const u8 mountain_09008000[]; -extern const u8 mountain_09008800[]; -extern const u8 mountain_09009800[]; -extern const u8 mountain_0900A000[]; -extern const u8 mountain_0900A800[]; -extern const u8 mountain_0900B000[]; -extern const u8 mountain_0900B800[]; -extern const u8 mountain_0900C000[]; +extern const Texture mountain_09000000[]; +extern const Texture mountain_09000800[]; +extern const Texture mountain_09001800[]; +extern const Texture mountain_09002800[]; +extern const Texture mountain_09003000[]; +extern const Texture mountain_09003800[]; +extern const Texture mountain_09004000[]; +extern const Texture mountain_09004800[]; +extern const Texture mountain_09005000[]; +extern const Texture mountain_09005800[]; +extern const Texture mountain_09006800[]; +extern const Texture mountain_09007000[]; +extern const Texture mountain_09007800[]; +extern const Texture mountain_09008000[]; +extern const Texture mountain_09008800[]; +extern const Texture mountain_09009800[]; +extern const Texture mountain_0900A000[]; +extern const Texture mountain_0900A800[]; +extern const Texture mountain_0900B000[]; +extern const Texture mountain_0900B800[]; +extern const Texture mountain_0900C000[]; // outside -extern const u8 outside_09000000[]; -extern const u8 outside_09000800[]; -extern const u8 outside_09001000[]; -extern const u8 outside_09002000[]; -extern const u8 outside_09003000[]; -extern const u8 outside_09003800[]; -extern const u8 outside_09004000[]; -extern const u8 outside_09004800[]; -extern const u8 outside_09005800[]; -extern const u8 outside_09006000[]; -extern const u8 outside_09006800[]; -extern const u8 outside_09007800[]; -extern const u8 outside_09008000[]; -extern const u8 outside_09008800[]; -extern const u8 outside_09009000[]; -extern const u8 outside_09009800[]; -extern const u8 outside_0900A000[]; -extern const u8 outside_0900A800[]; -extern const u8 outside_0900B000[]; -extern const u8 outside_0900B400[]; -extern const u8 outside_0900BC00[]; +extern const Texture outside_09000000[]; +extern const Texture outside_09000800[]; +extern const Texture outside_09001000[]; +extern const Texture outside_09002000[]; +extern const Texture outside_09003000[]; +extern const Texture outside_09003800[]; +extern const Texture outside_09004000[]; +extern const Texture outside_09004800[]; +extern const Texture outside_09005800[]; +extern const Texture outside_09006000[]; +extern const Texture outside_09006800[]; +extern const Texture outside_09007800[]; +extern const Texture outside_09008000[]; +extern const Texture outside_09008800[]; +extern const Texture outside_09009000[]; +extern const Texture outside_09009800[]; +extern const Texture outside_0900A000[]; +extern const Texture outside_0900A800[]; +extern const Texture outside_0900B000[]; +extern const Texture outside_0900B400[]; +extern const Texture outside_0900BC00[]; // sky -extern const u8 sky_09000000[]; -extern const u8 sky_09000800[]; -extern const u8 sky_09001000[]; -extern const u8 sky_09001800[]; -extern const u8 sky_09002000[]; -extern const u8 sky_09003000[]; -extern const u8 sky_09003800[]; -extern const u8 sky_09004800[]; -extern const u8 sky_09005000[]; -extern const u8 sky_09005800[]; -extern const u8 sky_09006000[]; -extern const u8 texture_metal_hole[]; -extern const u8 sky_09007000[]; -extern const u8 sky_09007800[]; -extern const u8 sky_09008000[]; +extern const Texture sky_09000000[]; +extern const Texture sky_09000800[]; +extern const Texture sky_09001000[]; +extern const Texture sky_09001800[]; +extern const Texture sky_09002000[]; +extern const Texture sky_09003000[]; +extern const Texture sky_09003800[]; +extern const Texture sky_09004800[]; +extern const Texture sky_09005000[]; +extern const Texture sky_09005800[]; +extern const Texture sky_09006000[]; +extern const Texture texture_metal_hole[]; +extern const Texture sky_09007000[]; +extern const Texture sky_09007800[]; +extern const Texture sky_09008000[]; // snow -extern const u8 snow_09000000[]; -extern const u8 snow_09000800[]; -extern const u8 snow_09001000[]; -extern const u8 snow_09002000[]; -extern const u8 snow_09002800[]; -extern const u8 snow_09003000[]; -extern const u8 snow_09003800[]; -extern const u8 snow_09004000[]; -extern const u8 snow_09004800[]; -extern const u8 snow_09005000[]; -extern const u8 snow_09005800[]; -extern const u8 snow_09006000[]; -extern const u8 snow_09006800[]; -extern const u8 snow_09007000[]; -extern const u8 snow_09008000[]; -extern const u8 snow_09008800[]; -extern const u8 snow_09009000[]; -extern const u8 snow_09009800[]; +extern const Texture snow_09000000[]; +extern const Texture snow_09000800[]; +extern const Texture snow_09001000[]; +extern const Texture snow_09002000[]; +extern const Texture snow_09002800[]; +extern const Texture snow_09003000[]; +extern const Texture snow_09003800[]; +extern const Texture snow_09004000[]; +extern const Texture snow_09004800[]; +extern const Texture snow_09005000[]; +extern const Texture snow_09005800[]; +extern const Texture snow_09006000[]; +extern const Texture snow_09006800[]; +extern const Texture snow_09007000[]; +extern const Texture snow_09008000[]; +extern const Texture snow_09008800[]; +extern const Texture snow_09009000[]; +extern const Texture snow_09009800[]; // spooky -extern const u8 spooky_09000000[]; -extern const u8 spooky_09000800[]; -extern const u8 spooky_09001000[]; -extern const u8 spooky_09001800[]; -extern const u8 spooky_09002800[]; -extern const u8 spooky_09003800[]; -extern const u8 spooky_09004800[]; -extern const u8 spooky_09005000[]; -extern const u8 spooky_09006000[]; -extern const u8 spooky_09006800[]; -extern const u8 spooky_09007000[]; -extern const u8 spooky_09008000[]; -extern const u8 spooky_09008800[]; -extern const u8 spooky_09009000[]; -extern const u8 spooky_0900A000[]; -extern const u8 spooky_0900A800[]; -extern const u8 spooky_0900B000[]; -extern const u8 spooky_0900B800[]; +extern const Texture spooky_09000000[]; +extern const Texture spooky_09000800[]; +extern const Texture spooky_09001000[]; +extern const Texture spooky_09001800[]; +extern const Texture spooky_09002800[]; +extern const Texture spooky_09003800[]; +extern const Texture spooky_09004800[]; +extern const Texture spooky_09005000[]; +extern const Texture spooky_09006000[]; +extern const Texture spooky_09006800[]; +extern const Texture spooky_09007000[]; +extern const Texture spooky_09008000[]; +extern const Texture spooky_09008800[]; +extern const Texture spooky_09009000[]; +extern const Texture spooky_0900A000[]; +extern const Texture spooky_0900A800[]; +extern const Texture spooky_0900B000[]; +extern const Texture spooky_0900B800[]; // water -extern const u8 water_09000000[]; -extern const u8 water_09000800[]; -extern const u8 water_09001800[]; -extern const u8 water_09002800[]; -extern const u8 water_09003800[]; -extern const u8 water_09004800[]; -extern const u8 water_09005800[]; -extern const u8 water_09006000[]; -extern const u8 water_09006800[]; -extern const u8 water_09007800[]; -extern const u8 water_09008800[]; -extern const u8 water_09009000[]; -extern const u8 water_0900A000[]; -extern const u8 water_0900A800[]; -extern const u8 water_0900B800[]; +extern const Texture water_09000000[]; +extern const Texture water_09000800[]; +extern const Texture water_09001800[]; +extern const Texture water_09002800[]; +extern const Texture water_09003800[]; +extern const Texture water_09004800[]; +extern const Texture water_09005800[]; +extern const Texture water_09006000[]; +extern const Texture water_09006800[]; +extern const Texture water_09007800[]; +extern const Texture water_09008800[]; +extern const Texture water_09009000[]; +extern const Texture water_0900A000[]; +extern const Texture water_0900A800[]; +extern const Texture water_0900B800[]; // effect -extern const u8 *const flower_bubbles_textures_ptr_0B002008[]; -extern const u8 *const lava_bubble_ptr_0B006020[]; -extern const u8 *const bubble_ptr_0B006848[]; +extern const Texture *const flower_bubbles_textures_ptr_0B002008[]; +extern const Texture *const lava_bubble_ptr_0B006020[]; +extern const Texture *const bubble_ptr_0B006848[]; extern const Gfx tiny_bubble_dl_0B006A50[]; extern const Gfx tiny_bubble_dl_0B006AB0[]; extern const Gfx tiny_bubble_dl_0B006CD8[]; @@ -275,7 +275,7 @@ extern const Gfx title_screen_bg_dl_0A000148[]; extern const Gfx title_screen_bg_dl_0A000160[]; extern const Gfx title_screen_bg_dl_0A000178[]; extern const Gfx title_screen_bg_dl_end[]; -extern const u8 *const mario_title_texture_table[]; -extern const u8 *const game_over_texture_table[]; +extern const Texture *const mario_title_texture_table[]; +extern const Texture *const game_over_texture_table[]; #endif // TEXTURES_H diff --git a/levels/bbh/header.h b/levels/bbh/header.h index 74f49d83..de769e94 100644 --- a/levels/bbh/header.h +++ b/levels/bbh/header.h @@ -96,7 +96,7 @@ extern const Gfx bbh_seg7_dl_0701FFE8[]; extern const Gfx bbh_seg7_dl_070202F0[]; extern const Gfx bbh_seg7_dl_070206F0[]; extern const Collision bbh_seg7_collision_level[]; -extern const u8 bbh_seg7_rooms[]; +extern const RoomData bbh_seg7_rooms[]; extern const MacroObject bbh_seg7_macro_objs[]; extern const Collision bbh_seg7_collision_staircase_step[]; extern const Collision bbh_seg7_collision_tilt_floor_platform[]; diff --git a/levels/castle_inside/header.h b/levels/castle_inside/header.h index dfd63923..043e3383 100644 --- a/levels/castle_inside/header.h +++ b/levels/castle_inside/header.h @@ -141,9 +141,9 @@ extern const Collision inside_castle_seg7_collision_ddd_warp_2[]; extern const MacroObject inside_castle_seg7_area_1_macro_objs[]; extern const MacroObject inside_castle_seg7_area_2_macro_objs[]; extern const MacroObject inside_castle_seg7_area_3_macro_objs[]; -extern const u8 inside_castle_seg7_area_1_rooms[]; -extern const u8 inside_castle_seg7_area_2_rooms[]; -extern const u8 inside_castle_seg7_area_3_rooms[]; +extern const RoomData inside_castle_seg7_area_1_rooms[]; +extern const RoomData inside_castle_seg7_area_2_rooms[]; +extern const RoomData inside_castle_seg7_area_3_rooms[]; extern const Collision inside_castle_seg7_collision_floor_trap[]; extern const Collision inside_castle_seg7_collision_star_door[]; extern const Collision inside_castle_seg7_collision_water_level_pillar[]; diff --git a/levels/hmc/header.h b/levels/hmc/header.h index bc534cbc..fa913c11 100644 --- a/levels/hmc/header.h +++ b/levels/hmc/header.h @@ -74,11 +74,11 @@ extern const Gfx hmc_seg7_dl_07023E10[]; extern const Gfx hmc_seg7_dl_07024110[]; extern const Gfx hmc_seg7_dl_07024268[]; extern const Gfx hmc_seg7_dl_070242A0[]; -extern const u8 *const hmc_seg7_painting_textures_07025518[]; +extern const Texture *const hmc_seg7_painting_textures_07025518[]; extern struct Painting cotmc_painting; extern const Collision hmc_seg7_collision_level[]; extern const MacroObject hmc_seg7_macro_objs[]; -extern const u8 hmc_seg7_rooms[]; +extern const RoomData hmc_seg7_rooms[]; extern const Collision hmc_seg7_collision_elevator[]; extern const Collision hmc_seg7_collision_0702B65C[]; extern const Collision hmc_seg7_collision_controllable_platform[]; diff --git a/levels/intro/leveldata.c b/levels/intro/leveldata.c index 5f61dfe7..a817c293 100644 --- a/levels/intro/leveldata.c +++ b/levels/intro/leveldata.c @@ -3348,11 +3348,11 @@ ALIGNED8 static const Texture intro_seg7_texture_0700B4A0[] = { #if defined(VERSION_EU) // 0x0700C4A0 - 0x0700D4A0 -ALIGNED8 static const u8 intro_seg7_texture_0700C4A0[] = { +ALIGNED8 static const Texture intro_seg7_texture_0700C4A0[] = { #include "levels/intro/3_eu_tm.rgba16.inc.c" }; #elif defined(VERSION_SH) -ALIGNED8 static const u8 intro_seg7_texture_0700C4A0[] = { +ALIGNED8 static const Texture intro_seg7_texture_0700C4A0[] = { #include "levels/intro/3_sh_tm.rgba16.inc.c" }; #else diff --git a/levels/menu/header.h b/levels/menu/header.h index 59bfb341..e73f9650 100644 --- a/levels/menu/header.h +++ b/levels/menu/header.h @@ -30,8 +30,8 @@ extern const Gfx dl_menu_sound_button[]; extern const Gfx dl_menu_generic_button[]; extern const Gfx dl_menu_idle_hand[]; extern const Gfx dl_menu_grabbing_hand[]; -extern const u8 *const menu_hud_lut[]; -extern const u8 *const menu_font_lut[]; +extern const Texture *const menu_hud_lut[]; +extern const Texture *const menu_font_lut[]; extern const Gfx dl_menu_ia8_text_begin[]; extern const Gfx dl_menu_ia8_text_end[]; extern const Gfx dl_menu_rgba16_wood_course[]; diff --git a/levels/ssl/header.h b/levels/ssl/header.h index a38845cd..cf1b0c85 100644 --- a/levels/ssl/header.h +++ b/levels/ssl/header.h @@ -18,8 +18,8 @@ extern const GeoLayout ssl_geo_0007CC[]; extern const GeoLayout ssl_geo_00088C[]; // leveldata -extern const u8 ssl_pyramid_sand[]; -extern const u8 ssl_quicksand[]; +extern const Texture ssl_pyramid_sand[]; +extern const Texture ssl_quicksand[]; extern const Gfx ssl_dl_quicksand_pit_begin[]; extern const Gfx ssl_dl_quicksand_pit_end[]; extern const Gfx ssl_dl_pyramid_quicksand_pit_begin[]; diff --git a/levels/ttc/header.h b/levels/ttc/header.h index 30edd607..241d3685 100644 --- a/levels/ttc/header.h +++ b/levels/ttc/header.h @@ -55,7 +55,7 @@ extern const Collision ttc_seg7_collision_clock_platform[]; extern const Collision ttc_seg7_collision_clock_main_rotation[]; extern const Collision ttc_seg7_collision_rotating_clock_platform2[]; extern const MacroObject ttc_seg7_macro_objs[]; -extern const u8 ttc_yellow_triangle[]; +extern const Texture ttc_yellow_triangle[]; extern const Gfx ttc_dl_surface_treadmill_begin[]; extern const Gfx ttc_dl_surface_treadmill_end[]; extern Movtex ttc_movtex_tris_big_surface_treadmill[]; diff --git a/src/engine/level_script.h b/src/engine/level_script.h index d41a91c8..e7abe672 100644 --- a/src/engine/level_script.h +++ b/src/engine/level_script.h @@ -5,7 +5,7 @@ struct LevelCommand; -extern u8 level_script_entry[]; +extern LevelScript level_script_entry[]; struct LevelCommand *level_script_execute(struct LevelCommand *cmd); diff --git a/src/game/area.h b/src/game/area.h index c8f073c4..5ee2edad 100644 --- a/src/game/area.h +++ b/src/game/area.h @@ -67,7 +67,7 @@ struct Area /*0x02*/ u16 terrainType; // default terrain of the level (set from level script cmd 0x31) /*0x04*/ struct GraphNodeRoot *graphNode; // geometry layout data /*0x08*/ s16 *terrainData; // collision data (set from level script cmd 0x2E) - /*0x0C*/ s8 *surfaceRooms; // (set from level script cmd 0x2F) + /*0x0C*/ RoomData *surfaceRooms; // (set from level script cmd 0x2F) /*0x10*/ s16 *macroObjects; // Macro Objects Ptr (set from level script cmd 0x39) /*0x14*/ struct ObjectWarpNode *warpNodes; /*0x18*/ struct WarpNode *paintingWarpNodes; diff --git a/src/game/behaviors/camera_lakitu.inc.c b/src/game/behaviors/camera_lakitu.inc.c index 3d2ed702..a848a2ce 100644 --- a/src/game/behaviors/camera_lakitu.inc.c +++ b/src/game/behaviors/camera_lakitu.inc.c @@ -150,8 +150,8 @@ void bhv_camera_lakitu_update(void) { break; } } else { - f32 val0C = (f32) 0x875C3D / 0x800 - gLakituState.curPos[0]; - if (gLakituState.curPos[0] < 1700.0f || val0C < 0.0f) { + f32 mirroredX = CASTLE_MIRROR_X - gLakituState.curPos[0]; + if (gLakituState.curPos[0] < 1700.0f || mirroredX < 0.0f) { cur_obj_hide(); } else { cur_obj_unhide(); @@ -167,7 +167,7 @@ void bhv_camera_lakitu_update(void) { o->oFaceAnglePitch = atan2s(cur_obj_lateral_dist_to_home(), o->oPosY - gLakituState.curFocus[1]); - o->oPosX = (f32) 0x875C3D / 0x800 + val0C; + o->oPosX = CASTLE_MIRROR_X + mirroredX; } } } diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c index 74543a3c..38e97cbc 100644 --- a/src/game/behaviors/chain_chomp.inc.c +++ b/src/game/behaviors/chain_chomp.inc.c @@ -210,20 +210,20 @@ static void chain_chomp_sub_act_lunge(void) { obj_face_pitch_approach(o->oChainChompTargetPitch, 0x400); if (o->oForwardVel != 0.0f) { - f32 val04; + // f32 val04; if (o->oChainChompRestrictedByChain == TRUE) { o->oForwardVel = o->oVelY = 0.0f; o->oChainChompSignedMaxDistBetweenChainParts = 30.0f; } - // TODO: What is this - if ((val04 = 900.0f - o->oChainChompDistToPivot) > 220.0f) { - val04 = 220.0f; - } + // // TODO: What is this + // if ((val04 = 900.0f - o->oChainChompDistToPivot) > 220.0f) { + // val04 = 220.0f; + // } - o->oChainChompMaxDistBetweenChainParts = - val04 / 220.0f * o->oChainChompMaxDistFromPivotPerChainPart; + // o->oChainChompMaxDistBetweenChainParts = + // val04 / 220.0f * o->oChainChompMaxDistFromPivotPerChainPart; o->oTimer = 0; } else { // Turn toward pivot diff --git a/src/game/behaviors/intro_lakitu.inc.c b/src/game/behaviors/intro_lakitu.inc.c index 6fdf20b7..4593f7c5 100644 --- a/src/game/behaviors/intro_lakitu.inc.c +++ b/src/game/behaviors/intro_lakitu.inc.c @@ -24,13 +24,11 @@ void intro_lakitu_set_offset_from_camera(struct Object *o, Vec3f offset) { } void intro_lakitu_set_focus(struct Object *o, Vec3f newFocus) { - Vec3f origin; f32 dist; s16 pitch, yaw; // newFocus is an offset from lakitu's origin, not a point in the world. - vec3f_set(origin, 0.f, 0.f, 0.f); - vec3f_get_dist_and_angle(origin, newFocus, &dist, &pitch, &yaw); + vec3f_get_dist_and_angle(gVec3fZero, newFocus, &dist, &pitch, &yaw); o->oFaceAnglePitch = pitch; o->oFaceAngleYaw = yaw; } @@ -57,6 +55,7 @@ s32 intro_lakitu_set_pos_and_focus(struct Object *o, struct CutsceneSplinePoint void bhv_intro_lakitu_loop(void) { Vec3f offset, fromPoint, toPoint; + s16 yawToCam; switch (gCurrentObject->oAction) { case 0: @@ -94,18 +93,10 @@ void bhv_intro_lakitu_loop(void) { cur_obj_play_sound_2(SOUND_ACTION_INTRO_UNK45E); break; #endif - case 73: - gCurrentObject->oAnimState += 1; - break; - case 74: - gCurrentObject->oAnimState -= 1; - break; - case 82: - gCurrentObject->oAnimState += 1; - break; - case 84: - gCurrentObject->oAnimState -= 1; - break; + case 73: gCurrentObject->oAnimState++; break; + case 74: gCurrentObject->oAnimState--; break; + case 82: gCurrentObject->oAnimState++; break; + case 84: gCurrentObject->oAnimState--; break; } #ifdef VERSION_EU if (gCurrentObject->oTimer == 446) @@ -163,14 +154,14 @@ void bhv_intro_lakitu_loop(void) { #else #define TIMER 98 #endif - if (gCurrentObject->oTimer == TIMER) { obj_mark_for_deletion(gCurrentObject); obj_mark_for_deletion(gCurrentObject->oIntroLakituCloud); } #ifndef VERSION_JP - if (gCurrentObject->oTimer == 14) + if (gCurrentObject->oTimer == 14) { cur_obj_play_sound_2(SOUND_ACTION_INTRO_UNK45F); + } #endif break; case 100: @@ -188,13 +179,11 @@ void bhv_intro_lakitu_loop(void) { case 101: object_pos_to_vec3f(toPoint, gCurrentObject); if (gCurrentObject->oTimer > 60) { - gCurrentObject->oForwardVel = - approach_f32_asymptotic(gCurrentObject->oForwardVel, -10.f, 0.05f); + gCurrentObject->oForwardVel = approach_f32_asymptotic(gCurrentObject->oForwardVel, -10.f, 0.05f); gCurrentObject->oMoveAngleYaw += 0x78; gCurrentObject->oMoveAnglePitch += 0x40; - gCurrentObject->oFaceAngleYaw = camera_approach_s16_symmetric( - gCurrentObject->oFaceAngleYaw, (s16) calculate_yaw(toPoint, gCamera->pos), - 0x200); + vec3f_get_yaw(toPoint, gCamera->pos, &yawToCam); + gCurrentObject->oFaceAngleYaw = camera_approach_s16_symmetric(gCurrentObject->oFaceAngleYaw, yawToCam, 0x200); } if (gCurrentObject->oTimer > 105) { gCurrentObject->oAction += 1; @@ -206,15 +195,13 @@ void bhv_intro_lakitu_loop(void) { case 102: object_pos_to_vec3f(toPoint, gCurrentObject); - gCurrentObject->oForwardVel = - approach_f32_asymptotic(gCurrentObject->oForwardVel, 60.f, 0.05f); - gCurrentObject->oFaceAngleYaw = camera_approach_s16_symmetric( - gCurrentObject->oFaceAngleYaw, (s16) calculate_yaw(toPoint, gCamera->pos), 0x200); - if (gCurrentObject->oTimer < 62) - gCurrentObject->oMoveAngleYaw = - approach_s16_asymptotic(gCurrentObject->oMoveAngleYaw, 0x1800, 0x1E); - gCurrentObject->oMoveAnglePitch = - camera_approach_s16_symmetric(gCurrentObject->oMoveAnglePitch, -0x2000, 0x5A); + gCurrentObject->oForwardVel = approach_f32_asymptotic(gCurrentObject->oForwardVel, 60.f, 0.05f); + vec3f_get_yaw(toPoint, gCamera->pos, &yawToCam); + gCurrentObject->oFaceAngleYaw = camera_approach_s16_symmetric(gCurrentObject->oFaceAngleYaw, yawToCam, 0x200); + if (gCurrentObject->oTimer < 62) { + gCurrentObject->oMoveAngleYaw = approach_s16_asymptotic(gCurrentObject->oMoveAngleYaw, 0x1800, 0x1E); + } + gCurrentObject->oMoveAnglePitch = camera_approach_s16_symmetric(gCurrentObject->oMoveAnglePitch, -0x2000, 0x5A); gCurrentObject->oFaceAnglePitch = 0; cur_obj_set_pos_via_transform(); break; diff --git a/src/game/behaviors/lll_hexagonal_ring.inc.c b/src/game/behaviors/lll_hexagonal_ring.inc.c index 014da42b..dddc0d29 100644 --- a/src/game/behaviors/lll_hexagonal_ring.inc.c +++ b/src/game/behaviors/lll_hexagonal_ring.inc.c @@ -2,13 +2,12 @@ void hexagonal_ring_spawn_flames(void) { struct Object *flameObj; - f32 size; flameObj = spawn_object(o, MODEL_RED_FLAME, bhvVolcanoFlames); flameObj->oPosY += 550.0f; flameObj->oMoveAngleYaw = random_u16() << 0x10 >> 0x10; flameObj->oForwardVel = random_float() * 40.0f + 20.0f; flameObj->oVelY = random_float() * 50.0f + 10.0f; - size = random_float() * 6.0 + 3.0; + f32 size = random_float() * 6.0f + 3.0f; obj_scale_xyz(flameObj, size, size, size); if (random_float() < 0.1) cur_obj_play_sound_2(SOUND_GENERAL_VOLCANO_EXPLOSION); diff --git a/src/game/behaviors/tweester.inc.c b/src/game/behaviors/tweester.inc.c index 7abcbb7c..dda8c525 100644 --- a/src/game/behaviors/tweester.inc.c +++ b/src/game/behaviors/tweester.inc.c @@ -25,12 +25,9 @@ void tweester_scale_and_move(f32 preScale) { s16 dYaw = 0x2C00; f32 scale = preScale * 0.4; - o->header.gfx.scale[0] - = (( coss(o->oTweesterScaleTimer) + 1.0) * 0.5 * 0.3 + 1.0) * scale; - o->header.gfx.scale[1] - = ((-coss(o->oTweesterScaleTimer) + 1.0) * 0.5 * 0.5 + 0.5) * scale; - o->header.gfx.scale[2] - = (( coss(o->oTweesterScaleTimer) + 1.0) * 0.5 * 0.3 + 1.0) * scale; + o->header.gfx.scale[0] = (( coss(o->oTweesterScaleTimer) + 1.0f) * 0.5f * 0.3f + 1.0f) * scale; + o->header.gfx.scale[1] = ((-coss(o->oTweesterScaleTimer) + 1.0f) * 0.5f * 0.5f + 0.5f) * scale; + o->header.gfx.scale[2] = (( coss(o->oTweesterScaleTimer) + 1.0f) * 0.5f * 0.3f + 1.0f) * scale; o->oTweesterScaleTimer += 0x200; o->oForwardVel = 14.0f; diff --git a/src/game/behaviors/water_objs.inc.c b/src/game/behaviors/water_objs.inc.c index 4746cb84..b432b431 100644 --- a/src/game/behaviors/water_objs.inc.c +++ b/src/game/behaviors/water_objs.inc.c @@ -9,8 +9,8 @@ void bhv_water_air_bubble_init(void) { void bhv_water_air_bubble_loop(void) { s32 i; - o->header.gfx.scale[0] = sins(o->oWaterObjScaleXAngle) * 0.5 + 4.0; - o->header.gfx.scale[1] = -sins(o->oWaterObjScaleXAngle) * 0.5 + 4.0; + o->header.gfx.scale[0] = sins(o->oWaterObjScaleXAngle) * 0.5f + 4.0f; + o->header.gfx.scale[1] = -sins(o->oWaterObjScaleXAngle) * 0.5f + 4.0f; o->oWaterObjScaleXAngle += 0x400; if (o->oTimer < 30) { cur_obj_become_intangible(); @@ -45,20 +45,20 @@ void scale_bubble_random(void) { } void bhv_bubble_maybe_loop(void) { - o->oPosY += random_float() * 3.0f + 6.0f; + o->oPosY += random_float() * 3.0f + 6.0f; o->oPosX += random_float() * 10.0f - 5.0f; o->oPosZ += random_float() * 10.0f - 5.0f; - o->header.gfx.scale[0] = sins(o->oWaterObjScaleXAngle) * 0.2 + 1.0; + o->header.gfx.scale[0] = sins(o->oWaterObjScaleXAngle) * 0.2f + 1.0f; o->oWaterObjScaleXAngle += o->oWaterObjScaleXAngleVel; - o->header.gfx.scale[1] = sins(o->oWaterObjScaleYAngle) * 0.2 + 1.0; + o->header.gfx.scale[1] = sins(o->oWaterObjScaleYAngle) * 0.2f + 1.0f; o->oWaterObjScaleYAngle += o->oWaterObjScaleYAngleVel; } void bhv_small_water_wave_loop(void) { f32 waterLevel = find_water_level(o->oPosX, o->oPosZ); - o->header.gfx.scale[0] = sins(o->oWaterObjScaleXAngle) * 0.2 + 1.0; + o->header.gfx.scale[0] = sins(o->oWaterObjScaleXAngle) * 0.2f + 1.0f; o->oWaterObjScaleXAngle += o->oWaterObjScaleXAngleVel; - o->header.gfx.scale[1] = sins(o->oWaterObjScaleYAngle) * 0.2 + 1.0; + o->header.gfx.scale[1] = sins(o->oWaterObjScaleYAngle) * 0.2f + 1.0f; o->oWaterObjScaleYAngle += o->oWaterObjScaleYAngleVel; if (o->oPosY > waterLevel) { o->activeFlags = ACTIVE_FLAG_DEACTIVATED; @@ -71,9 +71,9 @@ void bhv_small_water_wave_loop(void) { } void scale_bubble_sin(void) { - o->header.gfx.scale[0] = sins(o->oWaterObjScaleXAngle) * 0.5 + 2.0; + o->header.gfx.scale[0] = sins(o->oWaterObjScaleXAngle) * 0.5f + 2.0f; o->oWaterObjScaleXAngle += o->oWaterObjScaleXAngleVel; - o->header.gfx.scale[1] = sins(o->oWaterObjScaleYAngle) * 0.5 + 2.0; + o->header.gfx.scale[1] = sins(o->oWaterObjScaleYAngle) * 0.5f + 2.0f; o->oWaterObjScaleYAngle += o->oWaterObjScaleYAngleVel; } @@ -102,13 +102,16 @@ void bhv_small_bubbles_loop(void) { } void bhv_fish_group_loop(void) { - if (gMarioCurrentRoom == 15 || gMarioCurrentRoom == 7) - if (gGlobalTimer & 1) + if (gMarioCurrentRoom == 15 || gMarioCurrentRoom == 7) { + if (gGlobalTimer & 1) { spawn_object(o, MODEL_WHITE_PARTICLE_SMALL, bhvSmallParticleBubbles); + } + } } void bhv_water_waves_init(void) { s32 i; - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { spawn_object(o, MODEL_WHITE_PARTICLE_SMALL, bhvSmallParticle); + } } diff --git a/src/game/camera.c b/src/game/camera.c index da7aff8c..3f9f871b 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -894,9 +894,11 @@ void radial_camera_move(struct Camera *c) { s32 avoidStatus; f32 areaDistX = sMarioCamState->pos[0] - c->areaCenX; f32 areaDistZ = sMarioCamState->pos[2] - c->areaCenZ; + s16 yawOffset; // How much the camera's yaw changed - s16 yawOffset = calculate_yaw(sMarioCamState->pos, c->pos) - atan2s(areaDistZ, areaDistX); + vec3f_get_yaw(sMarioCamState->pos, c->pos, &yawOffset); + yawOffset -= atan2s(areaDistZ, areaDistX); if (yawOffset > maxAreaYaw) { yawOffset = maxAreaYaw; @@ -1324,14 +1326,14 @@ s32 update_parallel_tracking_camera(struct Camera *c, Vec3f focus, Vec3f pos) { // Check if the camera should go to the next path if (sParTrackPath[sParTrackIndex + 1].startOfPath != 0) { // get Mario's distance to the next path - calculate_angles(sParTrackPath[sParTrackIndex + 1].pos, sParTrackPath[sParTrackIndex + 2].pos, &nextPitch, &nextYaw); + vec3f_get_angle(sParTrackPath[sParTrackIndex + 1].pos, sParTrackPath[sParTrackIndex + 2].pos, &nextPitch, &nextYaw); vec3f_set_dist_and_angle(sParTrackPath[sParTrackIndex + 1].pos, nextPathPos, 400.f, nextPitch, nextYaw); - distToPrev = calc_abs_dist_squared(marioPos, nextPathPos); + vec3f_get_dist_squared(marioPos, nextPathPos, &distToPrev); // get Mario's distance to the previous path - calculate_angles(sParTrackPath[sParTrackIndex + 1].pos, sParTrackPath[sParTrackIndex].pos, &prevPitch, &prevYaw); + vec3f_get_angle(sParTrackPath[sParTrackIndex + 1].pos, sParTrackPath[sParTrackIndex].pos, &prevPitch, &prevYaw); vec3f_set_dist_and_angle(sParTrackPath[sParTrackIndex + 1].pos, prevPathPos, 400.f, prevPitch, prevYaw); - distToNext = calc_abs_dist_squared(marioPos, prevPathPos); + vec3f_get_dist_squared(marioPos, prevPathPos, &distToNext); if (distToPrev < distToNext) { sParTrackIndex++; sStatusFlags |= CAM_FLAG_CHANGED_PARTRACK_INDEX; @@ -1341,14 +1343,14 @@ s32 update_parallel_tracking_camera(struct Camera *c, Vec3f focus, Vec3f pos) { // Check if the camera should go to the previous path if (sParTrackIndex != 0) { // get Mario's distance to the next path - calculate_angles((*(sParTrackPath + sParTrackIndex)).pos, (*(sParTrackPath + sParTrackIndex + 1)).pos, &nextPitch, &nextYaw); + vec3f_get_angle((*(sParTrackPath + sParTrackIndex)).pos, (*(sParTrackPath + sParTrackIndex + 1)).pos, &nextPitch, &nextYaw); vec3f_set_dist_and_angle(sParTrackPath[sParTrackIndex].pos, nextPathPos, 700.f, nextPitch, nextYaw); - distToPrev = calc_abs_dist_squared(marioPos, nextPathPos); + vec3f_get_dist_squared(marioPos, nextPathPos, &distToPrev); // get Mario's distance to the previous path - calculate_angles((*(sParTrackPath + sParTrackIndex)).pos, (*(sParTrackPath + sParTrackIndex - 1)).pos, &prevPitch, &prevYaw); + vec3f_get_angle((*(sParTrackPath + sParTrackIndex)).pos, (*(sParTrackPath + sParTrackIndex - 1)).pos, &prevPitch, &prevYaw); vec3f_set_dist_and_angle(sParTrackPath[sParTrackIndex].pos, prevPathPos, 700.f, prevPitch, prevYaw); - distToNext = calc_abs_dist_squared(marioPos, prevPathPos); + vec3f_get_dist_squared(marioPos, prevPathPos, &distToNext); if (distToPrev > distToNext) { sParTrackIndex--; sStatusFlags |= CAM_FLAG_CHANGED_PARTRACK_INDEX; @@ -1487,7 +1489,9 @@ s32 update_boss_fight_camera(struct Camera *c, Vec3f focus, Vec3f pos) { heldState = 0; } - focusDistance = calc_abs_dist(sMarioCamState->pos, secondFocus) * 1.6f; + vec3f_get_dist(sMarioCamState->pos, secondFocus, &focusDistance); + focusDistance *= 1.6f; + if (focusDistance < 800.f) { focusDistance = 800.f; } @@ -1875,8 +1879,7 @@ s16 update_slide_camera(struct Camera *c) { vec3f_set_dist_and_angle(c->focus, c->pos, distCamToFocus, camPitch, camYaw); } } - - camYaw = calculate_yaw(c->focus, c->pos); + vec3f_get_yaw(c->focus, c->pos, &camYaw); return camYaw; } @@ -1983,26 +1986,18 @@ s16 update_default_camera(struct Camera *c) { // Determine how fast to rotate the camera if (sCSideButtonYaw == 0) { - if (c->mode == CAMERA_MODE_FREE_ROAM) { - nextYawVel = 0xC0; - } else { - nextYawVel = 0x100; - } + nextYawVel = ((c->mode == CAMERA_MODE_FREE_ROAM) ? 0xC0 : 0x100); if ((gPlayer1Controller->stickX != 0.f || gPlayer1Controller->stickY != 0.f) != 0) { nextYawVel = 0x20; } } else { - if (sCSideButtonYaw < 0) { - yaw += 0x200; - } - if (sCSideButtonYaw > 0) { - yaw -= 0x200; - } + if (sCSideButtonYaw < 0) yaw += 0x200; + if (sCSideButtonYaw > 0) yaw -= 0x200; camera_approach_s16_symmetric_bool(&sCSideButtonYaw, 0, 0x100); nextYawVel = 0; } sYawSpeed = 0x400; - xzDist = calc_hor_dist(sMarioCamState->pos, c->pos); + vec3f_get_lateral_dist(sMarioCamState->pos, c->pos, &xzDist); if (sStatusFlags & CAM_FLAG_BEHIND_MARIO_POST_DOOR) { if (xzDist >= 250) { @@ -2162,7 +2157,8 @@ s16 update_default_camera(struct Camera *c) { // Make Lakitu fly above the gas gasHeight = find_poison_gas_level(cPos[0], cPos[2]); if (gasHeight != FLOOR_LOWER_LIMIT) { - if ((gasHeight += 130.f) > c->pos[1]) { + gasHeight += 130.f; + if (gasHeight > c->pos[1]) { c->pos[1] = gasHeight; } } @@ -2248,23 +2244,14 @@ void mode_mario_camera(struct Camera *c) { * Rotates the camera around the spiral staircase. */ s32 update_spiral_stairs_camera(struct Camera *c, Vec3f focus, Vec3f pos) { - /// The returned yaw - s16 camYaw; - // unused - s16 focPitch; /// The focus (Mario)'s yaw around the stairs s16 focYaw; - // unused - s16 posPitch; /// The camera's yaw around the stairs s16 posYaw; Vec3f cPos; Vec3f checkPos; struct Surface *floor; - // unused - f32 dist; - f32 focusHeight; - f32 floorHeight; + f32 focusHeight, floorHeight; f32 focY; handle_c_button_movement(c); @@ -2278,8 +2265,8 @@ s32 update_spiral_stairs_camera(struct Camera *c, Vec3f focus, Vec3f pos) { focus[2] = sMarioCamState->pos[2]; vec3f_copy(cPos, pos); - vec3f_get_dist_and_angle(sFixedModeBasePosition, focus, &dist, &focPitch, &focYaw); - vec3f_get_dist_and_angle(sFixedModeBasePosition, cPos, &dist, &posPitch, &posYaw); + vec3f_get_yaw(sFixedModeBasePosition, focus, &focYaw); + vec3f_get_yaw(sFixedModeBasePosition, cPos, &posYaw); sSpiralStairsYawOffset = posYaw - focYaw; // posYaw will change if Mario is more than 90 degrees around the stairs, relative to the camera @@ -2295,9 +2282,9 @@ s32 update_spiral_stairs_camera(struct Camera *c, Vec3f focus, Vec3f pos) { vec3f_set_dist_and_angle(sFixedModeBasePosition, cPos, 300.f, 0, posYaw); // Move the camera's y coord up/down the staircase - checkPos[0] = focus[0] + (cPos[0] - focus[0]) * 0.7f; - checkPos[1] = focus[1] + (cPos[1] - focus[1]) * 0.7f + 300.f; - checkPos[2] = focus[2] + (cPos[2] - focus[2]) * 0.7f; + checkPos[0] = focus[0] + ((cPos[0] - focus[0]) * 0.7f); + checkPos[1] = focus[1] + ((cPos[1] - focus[1]) * 0.7f) + 300.f; + checkPos[2] = focus[2] + ((cPos[2] - focus[2]) * 0.7f); floorHeight = find_floor(checkPos[0], checkPos[1] + 50.f, checkPos[2], &floor); if (floorHeight != FLOOR_LOWER_LIMIT) { @@ -2310,9 +2297,8 @@ s32 update_spiral_stairs_camera(struct Camera *c, Vec3f focus, Vec3f pos) { camera_approach_f32_symmetric_bool(&focus[1], focY, 30.f); pos[0] = cPos[0]; pos[2] = cPos[2]; - camYaw = calculate_yaw(focus, pos); - - return camYaw; + vec3f_get_yaw(focus, pos, &posYaw); + return posYaw; } /** @@ -2393,15 +2379,8 @@ s32 exit_c_up(struct Camera *c) { s16 curPitch; s16 curYaw; s16 checkYaw = 0; - Vec3f storePos; // unused - Vec3f storeFoc; // unused if ((gCameraMovementFlags & CAM_MOVE_C_UP_MODE) && !(gCameraMovementFlags & CAM_MOVE_STARTED_EXITING_C_UP)) { - // Copy the stored pos and focus. This is unused. - vec3f_copy(storePos, sCameraStoreCUp.pos); - vec3f_add(storePos, sMarioCamState->pos); - vec3f_copy(storeFoc, sCameraStoreCUp.focus); - vec3f_add(storeFoc, sMarioCamState->pos); vec3f_copy(checkFoc, c->focus); checkFoc[0] = sMarioCamState->pos[0]; @@ -2954,7 +2933,7 @@ void update_camera(struct Camera *c) { gLakituState.posHSpeed = 0.f; gLakituState.posVSpeed = 0.f; - c->nextYaw = calculate_yaw(gLakituState.focus, gLakituState.pos); + vec3f_get_yaw(gLakituState.focus, gLakituState.pos, &c->nextYaw); c->yaw = c->nextYaw; gCameraMovementFlags &= ~CAM_MOVE_FIX_IN_PLACE; } else { @@ -3224,7 +3203,7 @@ void init_camera(struct Camera *c) { set_fixed_cam_axis_sa_lobby(c->mode); } store_lakitu_cam_info_for_c_up(c); - gLakituState.yaw = calculate_yaw(c->focus, c->pos); + vec3f_get_yaw(c->focus, c->pos, &gLakituState.yaw); gLakituState.nextYaw = gLakituState.yaw; c->yaw = gLakituState.yaw; c->nextYaw = gLakituState.yaw; @@ -3251,8 +3230,6 @@ void init_camera(struct Camera *c) { * modulo-4's the result, because each 8-bit mask only has 4 area bits for each level */ void zoom_out_if_paused_and_outside(struct GraphNodeCamera *camera) { - UNUSED f32 dist; - UNUSED s16 pitch; s16 yaw; s32 areaMaskIndex = gCurrLevelArea / 32; s32 areaBit = 1 << (((gCurrLevelArea & 0x10) / 4) + (((gCurrLevelArea & 0xF) - 1) & 3)); @@ -3268,7 +3245,7 @@ void zoom_out_if_paused_and_outside(struct GraphNodeCamera *camera) { camera->focus[0] = gCamera->areaCenX; camera->focus[1] = (sMarioCamState->pos[1] + gCamera->areaCenY) / 2; camera->focus[2] = gCamera->areaCenZ; - vec3f_get_dist_and_angle(camera->focus, sMarioCamState->pos, &dist, &pitch, &yaw); + vec3f_get_yaw(camera->focus, sMarioCamState->pos, &yaw); vec3f_set_dist_and_angle(sMarioCamState->pos, camera->pos, 6000.f, 0x1000, yaw); if (gCurrLevelNum != LEVEL_THI) { find_in_bounds_yaw_wdw_bob_thi(camera->pos, camera->focus, 0); @@ -3346,16 +3323,14 @@ void vec3f_to_object_pos(struct Object *o, Vec3f src) { */ void evaluate_cubic_spline(f32 u, Vec3f Q, Vec3f a0, Vec3f a1, Vec3f a2, Vec3f a3) { f32 B[4]; - - if (u > 1.f) { - u = 1.f; - } - - B[0] = (1.f - u) * (1.f - u) * (1.f - u) / 6.f; - B[1] = u * u * u / 2.f - u * u + 0.6666667f; - B[2] = -u * u * u / 2.f + u * u / 2.f + u / 2.f + 0.16666667f; - B[3] = u * u * u / 6.f; - + if (u > 1.0f) u = 1.0f; + register f32 nu = (1.0f - u); + register f32 su = sqr(u); + register f32 hcu = (cube(u) / 2.0f); + B[0] = (cube(nu) / 6.0f); + B[1] = (( hcu ) - su + (2.0f / 3.0f)); + B[2] = ((-hcu ) + (su / 2.0f) + (u / 2.0f) + (5.0f / 3.0f)); + B[3] = ( hcu / 3.0f); Q[0] = B[0] * a0[0] + B[1] * a1[0] + B[2] * a2[0] + B[3] * a3[0]; Q[1] = B[0] * a0[1] + B[1] * a1[1] + B[2] * a2[1] + B[3] * a3[1]; Q[2] = B[0] * a0[2] + B[1] * a1[2] + B[2] * a2[2] + B[3] * a3[2]; @@ -3501,34 +3476,13 @@ s32 set_cam_angle(s32 mode) { */ void set_handheld_shake(u8 mode) { switch (mode) { - // They're not in numerical order because that would be too simple... - case HAND_CAM_SHAKE_CUTSCENE: // Lowest increment - sHandheldShakeMag = 0x600; - sHandheldShakeInc = 0.04f; - break; - case HAND_CAM_SHAKE_LOW: // Lowest magnitude - sHandheldShakeMag = 0x300; - sHandheldShakeInc = 0.06f; - break; - case HAND_CAM_SHAKE_HIGH: // Highest mag and inc - sHandheldShakeMag = 0x1000; - sHandheldShakeInc = 0.1f; - break; - case HAND_CAM_SHAKE_UNUSED: // Never used - sHandheldShakeMag = 0x600; - sHandheldShakeInc = 0.07f; - break; - case HAND_CAM_SHAKE_HANG_OWL: // exactly the same as UNUSED... - sHandheldShakeMag = 0x600; - sHandheldShakeInc = 0.07f; - break; - case HAND_CAM_SHAKE_STAR_DANCE: // Slightly steadier than HANG_OWL and UNUSED - sHandheldShakeMag = 0x400; - sHandheldShakeInc = 0.07f; - break; - default: - sHandheldShakeMag = 0x0; - sHandheldShakeInc = 0.f; + case HAND_CAM_SHAKE_CUTSCENE: sHandheldShakeMag = 0x600; sHandheldShakeInc = 0.04f; break; // Lowest increment + case HAND_CAM_SHAKE_UNUSED: sHandheldShakeMag = 0x600; sHandheldShakeInc = 0.07f; break; // Never used + case HAND_CAM_SHAKE_HANG_OWL: sHandheldShakeMag = 0x600; sHandheldShakeInc = 0.07f; break; // exactly the same as UNUSED... + case HAND_CAM_SHAKE_HIGH: sHandheldShakeMag = 0x1000; sHandheldShakeInc = 0.1f; break; // Highest mag and inc + case HAND_CAM_SHAKE_STAR_DANCE: sHandheldShakeMag = 0x400; sHandheldShakeInc = 0.07f; break; // Slightly steadier than HANG_OWL and UNUSED + case HAND_CAM_SHAKE_LOW: sHandheldShakeMag = 0x300; sHandheldShakeInc = 0.06f; break; // Lowest magnitude + default: sHandheldShakeMag = 0x0; sHandheldShakeInc = 0.f; } } @@ -3686,7 +3640,7 @@ s32 collide_with_walls(Vec3f pos, f32 offsetY, f32 radius) { normZ = wall->normal.z; originOffset = wall->originOffset; offset = normX * newPos[i][0] + normY * newPos[i][1] + normZ * newPos[i][2] + originOffset; - offsetAbsolute = ABS2(offset); + offsetAbsolute = ABS(offset); if (offsetAbsolute < radius) { newPos[i][0] += normX * (radius - offset); newPos[i][2] += normZ * (radius - offset); @@ -3713,9 +3667,10 @@ void clamp_pitch(Vec3f from, Vec3f to, s16 maxPitch, s16 minPitch) { } s32 is_within_100_units_of_mario(f32 posX, f32 posY, f32 posZ) { - Vec3f pos; - vec3f_set(pos, posX, posY, posZ); - return (calc_abs_dist_squared(sMarioCamState->pos, pos) < sqr(100.f)); + Vec3f pos = { posX, posY, posZ }; + f32 dist; + vec3f_get_dist_squared(sMarioCamState->pos, pos, &dist); + return (dist < sqr(100.f)); } s32 set_or_approach_f32_asymptotic(f32 *dst, f32 goal, f32 scale) { @@ -3866,7 +3821,7 @@ s16 reduce_by_dist_from_camera(s16 value, f32 maxDist, f32 posX, f32 posY, f32 p pos[2] = posZ; vec3f_get_dist_and_angle(gLakituState.goalPos, pos, &dist, &pitch, &yaw); if (dist < maxDist) { - calculate_angles(gLakituState.goalPos, gLakituState.goalFocus, &goalPitch, &goalYaw); + vec3f_get_angle(gLakituState.goalPos, gLakituState.goalFocus, &goalPitch, &goalYaw); pitch -= goalPitch; yaw -= goalYaw; dist -= 2000.f; @@ -3889,20 +3844,11 @@ s16 reduce_by_dist_from_camera(s16 value, f32 maxDist, f32 posX, f32 posY, f32 p s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin) { s16 yaw = gCamera->nextYaw; - - if (pos[0] >= xMax) { - pos[0] = xMax; - } - if (pos[0] <= xMin) { - pos[0] = xMin; - } - if (pos[2] >= zMax) { - pos[2] = zMax; - } - if (pos[2] <= zMin) { - pos[2] = zMin; - } - yaw = calculate_yaw(origin, pos); + if (pos[0] >= xMax) pos[0] = xMax; + if (pos[0] <= xMin) pos[0] = xMin; + if (pos[2] >= zMax) pos[2] = zMax; + if (pos[2] <= zMin) pos[2] = zMin; + vec3f_get_yaw(origin, pos, &yaw); return yaw; } @@ -3917,9 +3863,7 @@ s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f3 * developers just add 180 degrees to the result. */ s32 calc_avoid_yaw(s16 yawFromMario, s16 wallYaw) { - s16 yawDiff = wallYaw - yawFromMario + DEGREES(90); - - if (yawDiff < 0) { + if ((s16)(wallYaw - yawFromMario + DEGREES(90)) < 0) { // Deflect to the right yawFromMario = wallYaw; } else { @@ -3962,22 +3906,14 @@ s32 is_surf_within_bounding_box(struct Surface *surf, f32 xMax, f32 yMax, f32 zM sz[2] = surf->vertex3[2]; for (i = 0; i < 3; i++) { - j = i + 1; - if (j >= 3) { - j = 0; - } + j = (i + 1); + if (j >= 3) j = 0; dx = ABS(sx[i] - sx[j]); - if (dx > dxMax) { - dxMax = dx; - } + if (dx > dxMax) dxMax = dx; dy = ABS(sy[i] - sy[j]); - if (dy > dyMax) { - dyMax = dy; - } + if (dy > dyMax) dyMax = dy; dz = ABS(sz[i] - sz[j]); - if (dz > dzMax) { - dzMax = dz; - } + if (dz > dzMax) dzMax = dz; } if (yMax != -1.f) { if (dyMax < yMax) { @@ -4071,56 +4007,6 @@ s32 is_pos_in_bounds(Vec3f pos, Vec3f center, Vec3f bounds, s16 boundsYaw) { -bounds[2] < rel[2] && rel[2] < bounds[2]); } -s16 calculate_pitch(Vec3f from, Vec3f to) { - f32 dx = to[0] - from[0]; - f32 dy = to[1] - from[1]; - f32 dz = to[2] - from[2]; - return atan2s(sqrtf(sqr(dx) + sqr(dz)), dy); -} - -s16 calculate_yaw(Vec3f from, Vec3f to) { - f32 dx = to[0] - from[0]; - f32 dz = to[2] - from[2]; - return atan2s(dz, dx); -} - -/** - * Calculates the pitch and yaw between two vectors. - */ -void calculate_angles(Vec3f from, Vec3f to, s16 *pitch, s16 *yaw) { - f32 dx = to[0] - from[0]; - f32 dy = to[1] - from[1]; - f32 dz = to[2] - from[2]; - *pitch = atan2s(sqrtf(sqr(dx) + sqr(dz)), dy); - *yaw = atan2s(dz, dx); -} - -/** - * Finds the distance between two vectors. - */ -f32 calc_abs_dist(Vec3f a, Vec3f b) { - register f32 distX = b[0] - a[0]; - register f32 distY = b[1] - a[1]; - register f32 distZ = b[2] - a[2]; - return sqrtf(sqr(distX) + sqr(distY) + sqr(distZ)); -} - -f32 calc_abs_dist_squared(Vec3f a, Vec3f b) { - register f32 distX = b[0] - a[0]; - register f32 distY = b[1] - a[1]; - register f32 distZ = b[2] - a[2]; - return (sqr(distX) + sqr(distY) + sqr(distZ)); -} - -/** - * Finds the horizontal distance between two vectors. - */ -f32 calc_hor_dist(Vec3f a, Vec3f b) { - register f32 distX = b[0] - a[0]; - register f32 distZ = b[2] - a[2]; - return sqrtf(sqr(distX) + sqr(distZ)); -} - /** * Rotates a vector in the horizontal plane and copies it to a new vector. */ @@ -4268,6 +4154,7 @@ void shake_camera_roll(s16 *roll) { s32 offset_yaw_outward_radial(struct Camera *c, s16 areaYaw) { s16 yawGoal = DEGREES(60); s16 yaw = sModeOffsetYaw; + f32 distFromAreaCenter; Vec3f areaCenter; s16 dYaw; switch (gCurrLevelArea) { @@ -4275,7 +4162,8 @@ s32 offset_yaw_outward_radial(struct Camera *c, s16 areaYaw) { areaCenter[0] = c->areaCenX; areaCenter[1] = sMarioCamState->pos[1]; areaCenter[2] = c->areaCenZ; - if (sqr(800.f) > calc_abs_dist_squared(areaCenter, sMarioCamState->pos)) { + vec3f_get_dist_squared(areaCenter, sMarioCamState->pos, &distFromAreaCenter); + if (sqr(800.f) > distFromAreaCenter) { yawGoal = 0x3800; } break; @@ -4837,18 +4725,13 @@ void determine_pushing_or_pulling_door(s16 *rotation) { */ s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw) { - s16 yawVelocity; - s16 pitchVelocity; + s16 pitchVelocity, yawVelocity; f32 distVelocity; f32 goalDist; - s16 goalPitch; - s16 goalYaw; + s16 goalPitch, goalYaw; f32 distTimer = sModeTransition.framesLeft; s16 angleTimer = sModeTransition.framesLeft; - Vec3f nextPos; - Vec3f nextFoc; - Vec3f startPos; - Vec3f startFoc; + Vec3f startPos, nextPos, startFoc, nextFoc; s32 i; f32 floorHeight; struct Surface *floor; @@ -4866,10 +4749,8 @@ s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, } - vec3f_get_dist_and_angle(curFoc, startFoc, &sModeTransition.focDist, &sModeTransition.focPitch, - &sModeTransition.focYaw); - vec3f_get_dist_and_angle(curFoc, startPos, &sModeTransition.posDist, &sModeTransition.posPitch, - &sModeTransition.posYaw); + vec3f_get_dist_and_angle(curFoc, startFoc, &sModeTransition.focDist, &sModeTransition.focPitch, &sModeTransition.focYaw); + vec3f_get_dist_and_angle(curFoc, startPos, &sModeTransition.posDist, &sModeTransition.posPitch, &sModeTransition.posYaw); sStatusFlags &= ~CAM_FLAG_START_TRANSITION; } @@ -4910,7 +4791,7 @@ s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, f32_find_wall_collision(&newPos[0], &newPos[1], &newPos[2], 0.f, 100.f); } sModeTransition.framesLeft--; - yaw = calculate_yaw(newFoc, newPos); + vec3f_get_yaw(newFoc, newPos, &yaw); } else { sModeTransition.posDist = 0.f; sModeTransition.posPitch = 0; @@ -4986,13 +4867,15 @@ void set_camera_mode_close_cam(u8 *mode) { */ void set_camera_mode_radial(struct Camera *c, s16 transitionTime) { Vec3f focus; - s16 yaw; + s16 yawToMario, yawToCam, yaw; focus[0] = c->areaCenX; focus[1] = sMarioCamState->pos[1]; focus[2] = c->areaCenZ; if (c->mode != CAMERA_MODE_RADIAL) { - yaw = calculate_yaw(focus, sMarioCamState->pos) - calculate_yaw(c->focus, c->pos) + DEGREES(90); + vec3f_get_yaw(focus, sMarioCamState->pos, &yawToMario); + vec3f_get_yaw(c->focus, c->pos, &yawToCam); + yaw = yawToMario - yawToCam + DEGREES(90); if (yaw > 0) { transition_to_camera_mode(c, CAMERA_MODE_RADIAL, transitionTime); } else { @@ -5930,7 +5813,6 @@ s16 camera_course_processing(struct Camera *c) { // Camera trigger's bounding box Vec3f center, bounds; u32 insideBounds = FALSE; - UNUSED struct CameraTrigger unused; u8 oldMode = c->mode; if (c->mode == CAMERA_MODE_C_UP) { @@ -5978,8 +5860,7 @@ s16 camera_course_processing(struct Camera *c) { } } } - - b += 1; + b++; } } @@ -6053,18 +5934,14 @@ s16 camera_course_processing(struct Camera *c) { break; case AREA_WDW_MAIN: - switch (sMarioGeometry.currFloorType) { - case SURFACE_INSTANT_WARP_1B: - c->defMode = CAMERA_MODE_RADIAL; - break; + if (sMarioGeometry.currFloorType == SURFACE_INSTANT_WARP_1B) { + c->defMode = CAMERA_MODE_RADIAL; } break; case AREA_WDW_TOWN: - switch (sMarioGeometry.currFloorType) { - case SURFACE_INSTANT_WARP_1C: - c->defMode = CAMERA_MODE_CLOSE; - break; + if (sMarioGeometry.currFloorType == SURFACE_INSTANT_WARP_1C) { + c->defMode = CAMERA_MODE_CLOSE; } break; @@ -6346,7 +6223,7 @@ s16 cutscene_object(u8 cutscene, struct Object *o) { * Update the camera's yaw and nextYaw. This is called from cutscenes to ignore the camera mode's yaw. */ void update_camera_yaw(struct Camera *c) { - c->nextYaw = calculate_yaw(c->focus, c->pos); + vec3f_get_yaw(c->focus, c->pos, &c->nextYaw); c->yaw = c->nextYaw; } @@ -6584,7 +6461,7 @@ void rotate_and_move_vec3f(Vec3f to, Vec3f from, f32 incDist, s16 incPitch, s16 void set_flag_post_door(struct Camera *c) { sStatusFlags |= CAM_FLAG_BEHIND_MARIO_POST_DOOR; - sCameraYawAfterDoorCutscene = calculate_yaw(c->focus, c->pos); + vec3f_get_yaw(c->focus, c->pos, &sCameraYawAfterDoorCutscene); } void cutscene_soften_music(UNUSED struct Camera *c) { @@ -7255,23 +7132,15 @@ void cutscene_dance_fly_away_start(struct Camera *c) { if (c->mode == CAMERA_MODE_RADIAL) { vec3f_set(areaCenter, c->areaCenX, c->areaCenY, c->areaCenZ); - c->yaw = calculate_yaw(areaCenter, c->pos); + vec3f_get_yaw(areaCenter, c->pos, &c->yaw); c->nextYaw = c->yaw; } // Restrict the camera yaw in tight spaces - if ((gLastCompletedStarNum == 6) && (gCurrCourseNum == COURSE_CCM)) { - star_dance_bound_yaw(c, 0x5600, 0x800); - } - if ((gLastCompletedStarNum == 2) && (gCurrCourseNum == COURSE_TTM)) { - star_dance_bound_yaw(c, 0x0, 0x800); - } - if ((gLastCompletedStarNum == 1) && (gCurrCourseNum == COURSE_SL)) { - star_dance_bound_yaw(c, 0x2000, 0x800); - } - if ((gLastCompletedStarNum == 3) && (gCurrCourseNum == COURSE_RR)) { - star_dance_bound_yaw(c, 0x0, 0x800); - } + if ((gLastCompletedStarNum == 6) && (gCurrCourseNum == COURSE_CCM)) star_dance_bound_yaw(c, 0x5600, 0x800); + if ((gLastCompletedStarNum == 2) && (gCurrCourseNum == COURSE_TTM)) star_dance_bound_yaw(c, 0x0, 0x800); + if ((gLastCompletedStarNum == 1) && (gCurrCourseNum == COURSE_SL )) star_dance_bound_yaw(c, 0x2000, 0x800); + if ((gLastCompletedStarNum == 3) && (gCurrCourseNum == COURSE_RR )) star_dance_bound_yaw(c, 0x0, 0x800); } void cutscene_dance_fly_away_approach_mario(struct Camera *c) { @@ -7727,8 +7596,8 @@ void cutscene_red_coin_star_warp(struct Camera *c) { vec3f_set(sCutsceneVars[1].point, o->oHomeX, o->oHomeY, o->oHomeZ); vec3f_get_dist_and_angle(sCutsceneVars[1].point, c->pos, &dist, &pitch, &yaw); - posYaw = calculate_yaw(sCutsceneVars[1].point, c->pos); - yaw = calculate_yaw(sCutsceneVars[1].point, sMarioCamState->pos); + vec3f_get_yaw(sCutsceneVars[1].point, c->pos, &posYaw); + vec3f_get_yaw(sCutsceneVars[1].point, sMarioCamState->pos, &yaw); if (ABS(yaw - posYaw + DEGREES(90)) < ABS(yaw - posYaw - DEGREES(90))) { yaw += DEGREES(90); @@ -7869,7 +7738,9 @@ void cannon_approach_prev(f32 *value, f32 target) { * Fly or warp back to the previous pos and focus, stored in sCameraStoreCutscene. */ void cutscene_prepare_cannon_fly_back(struct Camera *c) { - if (calc_abs_dist_squared(c->pos, sCameraStoreCutscene.pos) < sqr(8000.f)) { + f32 distToPrevPos; + vec3f_get_dist_squared(c->pos, sCameraStoreCutscene.pos, &distToPrevPos); + if (distToPrevPos < sqr(8000.f)) { cannon_approach_prev(&c->pos[0], sCameraStoreCutscene.pos[0]); cannon_approach_prev(&c->pos[1], sCameraStoreCutscene.pos[1]); cannon_approach_prev(&c->pos[2], sCameraStoreCutscene.pos[2]); @@ -8262,9 +8133,8 @@ void cutscene_dialog_start(struct Camera *c) { // Store gCutsceneFocus's position and yaw object_pos_to_vec3f(sCutsceneVars[9].point, gCutsceneFocus); sCutsceneVars[9].point[1] += gCutsceneFocus->hitboxHeight + 200.f; - sCutsceneVars[9].angle[1] = calculate_yaw(sCutsceneVars[8].point, sCutsceneVars[9].point); - - yaw = calculate_yaw(sMarioCamState->pos, gLakituState.curPos); + vec3f_get_yaw(sCutsceneVars[8].point, sCutsceneVars[9].point, &sCutsceneVars[9].angle[1]); + vec3f_get_yaw(sMarioCamState->pos, gLakituState.curPos, &yaw); if ((yaw - sCutsceneVars[9].angle[1]) & 0x8000) { sCutsceneVars[9].angle[1] -= 0x6000; } else { @@ -8283,7 +8153,7 @@ void cutscene_dialog_move_mario_shoulder(struct Camera *c) { scale_along_line(focus, sCutsceneVars[9].point, sMarioCamState->pos, 0.7f); vec3f_get_dist_and_angle(c->pos, focus, &dist, &pitch, &yaw); - pitch = calculate_pitch(c->pos, sCutsceneVars[9].point); + vec3f_get_pitch(c->pos, sCutsceneVars[9].point, &pitch); vec3f_set_dist_and_angle(c->pos, pos, dist, pitch, yaw); focus[1] = focus[1] + (sCutsceneVars[9].point[1] - focus[1]) * 0.1f; @@ -8299,8 +8169,8 @@ void cutscene_dialog_move_mario_shoulder(struct Camera *c) { vec3f_set_dist_and_angle(sCutsceneVars[8].point, pos, dist, pitch, yaw); // Move up if Mario is below the focus object, down is Mario is above - pos[1] = sCutsceneVars[8].point[1] - + sins(calculate_pitch(sCutsceneVars[9].point, sCutsceneVars[8].point)) * 100.f; + vec3f_get_pitch(sCutsceneVars[9].point, sCutsceneVars[8].point, &pitch); + pos[1] = sCutsceneVars[8].point[1] + (sins(pitch) * 100.f); approach_f32_asymptotic_bool(&c->pos[1], pos[1], 0.05f); c->pos[0] = pos[0]; @@ -8640,8 +8510,9 @@ void cutscene_non_painting_death(struct Camera *c) { * because cvar1 rotates until is reaches 0, so it's important that it's a multiple of 0x100. */ void cutscene_cap_switch_press_start(struct Camera *c) { + s16 yaw; store_info_star(c); - s16 yaw = calculate_yaw(sMarioCamState->pos, c->pos); + vec3f_get_yaw(sMarioCamState->pos, c->pos, &yaw); sCutsceneVars[3].angle[1] = 0x1200; // Basically the amount of rotation to get from behind Mario to in front of Mario sCutsceneVars[1].angle[1] = (yaw - (sMarioCamState->faceAngle[1] + sCutsceneVars[3].angle[1])) & 0xFF00; diff --git a/src/game/camera.h b/src/game/camera.h index 0695f808..b4bf74e6 100644 --- a/src/game/camera.h +++ b/src/game/camera.h @@ -11,14 +11,16 @@ #include "level_table.h" +// X position of the mirror +// 0x875C3D = 8870973, 0x800 = 2048, 8870973 / 2048 = ~4331.52978515625 +#define CASTLE_MIRROR_X ((f32)0x875C3D / 0x800) + /** * @file camera.h * Constants, defines, and structs used by the camera system. * @see camera.c */ -#define ABS2(x) ((x) >= 0.f ? (x) : -(x)) - /** * Converts an angle in degrees to sm64's s16 angle units. For example, DEGREES(90) == 0x4000 * This should be used mainly to make camera code clearer at first glance. @@ -709,12 +711,6 @@ void random_vec3s(Vec3s dst, s16 xRange, s16 yRange, s16 zRange); s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin); s32 is_range_behind_surface(Vec3f from, Vec3f to, struct Surface *surf, s16 range, s16 surfType); void scale_along_line(Vec3f dest, Vec3f from, Vec3f to, f32 scale); -s16 calculate_pitch(Vec3f from, Vec3f to); -s16 calculate_yaw(Vec3f from, Vec3f to); -void calculate_angles(Vec3f from, Vec3f to, s16 *pitch, s16 *yaw); -f32 calc_abs_dist(Vec3f a, Vec3f b); -f32 calc_abs_dist_squared(Vec3f a, Vec3f b); -f32 calc_hor_dist(Vec3f a, Vec3f b); void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw); void rotate_in_yz(Vec3f dst, Vec3f src, s16 pitch); void set_camera_pitch_shake(s16 mag, s16 decay, s16 inc); diff --git a/src/game/debug_box.c b/src/game/debug_box.c index 5272b553..42fe79ec 100644 --- a/src/game/debug_box.c +++ b/src/game/debug_box.c @@ -100,8 +100,8 @@ Gfx dl_debug_cylinder_verts[] = { gsSPEndDisplayList(), }; -u8 hitboxView = 0; -u8 surfaceView = 0; +u8 hitboxView = FALSE; +u8 surfaceView = FALSE; /** * Internal struct containing box info @@ -189,22 +189,15 @@ static const Gfx dl_visual_surface[] = { u8 viewCycle = 0; -//Puppyprint will call this from elsewhere. -void debug_box_input(void) -{ - if (gPlayer1Controller->buttonPressed & R_JPAD) - { +// Puppyprint will call this from elsewhere. +void debug_box_input(void) { + if (gPlayer1Controller->buttonPressed & R_JPAD) { viewCycle++; - if (viewCycle > 3) + if (viewCycle > 3) { viewCycle = 0; - - hitboxView = 0; - surfaceView = 0; - - if (viewCycle == 1 || viewCycle == 3) - hitboxView = 1; - if (viewCycle == 2 || viewCycle == 3) - surfaceView = 1; + } + hitboxView = (viewCycle == 1 || viewCycle == 3); + surfaceView = (viewCycle == 2 || viewCycle == 3); } } @@ -213,8 +206,7 @@ s32 gVisualOffset; extern s32 gSurfaceNodesAllocated; extern s32 gSurfacesAllocated; -void iterate_surfaces_visual(s32 x, s32 z, Vtx *verts) -{ +void iterate_surfaces_visual(s32 x, s32 z, Vtx *verts) { struct SurfaceNode *node; struct Surface *surf; s32 cellX, cellZ; @@ -231,22 +223,19 @@ void iterate_surfaces_visual(s32 x, s32 z, Vtx *verts) cellX = ((x + LEVEL_BOUNDARY_MAX) / CELL_SIZE) & NUM_CELLS_INDEX; cellZ = ((z + LEVEL_BOUNDARY_MAX) / CELL_SIZE) & NUM_CELLS_INDEX; - for (i = 0; i < 8; i++) - { - switch (i) - { - case 0: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next; col[0] = 0x00; col[1] = 0xFF; col[2] = 0x00; break; - case 1: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next; col[0] = 0x00; col[1] = 0xFF; col[2] = 0x00; break; - case 2: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; col[0] = 0x00; col[1] = 0x00; col[2] = 0xFF; break; - case 3: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; col[0] = 0x00; col[1] = 0x00; col[2] = 0xFF; break; - case 4: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS].next; col[0] = 0xFF; col[1] = 0x00; col[2] = 0x00; break; - case 5: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS].next; col[0] = 0xFF; col[1] = 0x00; col[2] = 0x00; break; - case 6: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER].next; col[0] = 0xFF; col[1] = 0xFF; col[2] = 0x00; break; - case 7: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER].next; col[0] = 0xFF; col[1] = 0xFF; col[2] = 0x00; break; + for (i = 0; i < 8; i++) { + switch (i) { + case 0: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; col[0] = 0x00; col[1] = 0xFF; col[2] = 0x00; break; + case 1: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS ].next; col[0] = 0x00; col[1] = 0xFF; col[2] = 0x00; break; + case 2: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; col[0] = 0x00; col[1] = 0x00; col[2] = 0xFF; break; + case 3: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_FLOORS].next; col[0] = 0x00; col[1] = 0x00; col[2] = 0xFF; break; + case 4: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; col[0] = 0xFF; col[1] = 0x00; col[2] = 0x00; break; + case 5: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_CEILS ].next; col[0] = 0xFF; col[1] = 0x00; col[2] = 0x00; break; + case 6: node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; col[0] = 0xFF; col[1] = 0xFF; col[2] = 0x00; break; + case 7: node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WATER ].next; col[0] = 0xFF; col[1] = 0xFF; col[2] = 0x00; break; } - while (node != NULL) - { + while (node != NULL) { surf = node->surface; node = node->next; diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index ebb18b3a..491f7ba3 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -221,10 +221,10 @@ void create_dl_ortho_matrix(void) { #if !defined(VERSION_JP) && !defined(VERSION_SH) UNUSED #endif -static u8 *alloc_ia8_text_from_i1(u16 *in, s16 width, s16 height) { +static Texture *alloc_ia8_text_from_i1(u16 *in, s16 width, s16 height) { //! Texture type for *in? s32 inPos; u16 bitMask; - u8 *out; + Texture *out; s16 outPos = 0; out = alloc_display_list((u32) width * (u32) height); @@ -251,15 +251,15 @@ static u8 *alloc_ia8_text_from_i1(u16 *in, s16 width, s16 height) { return out; } -u8 *alloc_ia4_tex_from_i1(u8 *in, s16 width, s16 height) { +Texture *alloc_ia4_tex_from_i1(Texture *in, s16 width, s16 height) { u32 size = (u32) width * (u32) height; - u8 *out; + Texture *out; s32 inPos; s16 outPos; u8 bitMask; outPos = 0; - out = (u8 *) alloc_display_list(size); + out = (Texture *) alloc_display_list(size); if (out == NULL) { return NULL; @@ -555,21 +555,11 @@ void handle_menu_scrolling(s8 scrollDirection, s8 *currentIndex, s8 minIndex, s8 u8 index = 0; if (scrollDirection == MENU_SCROLL_VERTICAL) { - if (gPlayer3Controller->rawStickY > 60) { - index++; - } - - if (gPlayer3Controller->rawStickY < -60) { - index += 2; - } + if (gPlayer3Controller->rawStickY > 60) index++; + if (gPlayer3Controller->rawStickY < -60) index += 2; } else if (scrollDirection == MENU_SCROLL_HORIZONTAL) { - if (gPlayer3Controller->rawStickX > 60) { - index += 2; - } - - if (gPlayer3Controller->rawStickX < -60) { - index++; - } + if (gPlayer3Controller->rawStickX > 60) index += 2; + if (gPlayer3Controller->rawStickX < -60) index++; } if (((index ^ gMenuHoldKeyIndex) & index) == 2) { diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index 0e75239d..96340613 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -148,13 +148,7 @@ s32 act_holding_pole(struct MarioState *m) { m->faceAngle[1] += marioObj->oMarioPoleYawVel; marioObj->oMarioPolePos -= marioObj->oMarioPoleYawVel / 0x100; - if (m->usedObj->behavior == segmented_to_virtual(bhvTree)) { - //! The Shifting Sand Land palm tree check is done climbing up in - // add_tree_leaf_particles, but not here, when climbing down. - if (m->pos[1] - m->floorHeight > 100.0f) { - m->particleFlags |= PARTICLE_LEAF; - } - } + add_tree_leaf_particles(m); play_climbing_sounds(m, 2); #if ENABLE_RUMBLE reset_rumble_timers_slip(); diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index 6e268766..8e6f720a 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -589,9 +589,6 @@ Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 * return NULL; } -// X position of the mirror -#define MIRROR_X 4331.53 - /** * Geo node that creates a clone of Mario's geo node and updates it to becomes * a mirror image of the player. @@ -620,8 +617,8 @@ Gfx *geo_render_mirror_mario(s32 callContext, struct GraphNode *node, UNUSED Mat vec3f_copy(gMirrorMario.scale, mario->header.gfx.scale); gMirrorMario.animInfo = mario->header.gfx.animInfo; - mirroredX = MIRROR_X - gMirrorMario.pos[0]; - gMirrorMario.pos[0] = mirroredX + MIRROR_X; + mirroredX = CASTLE_MIRROR_X - gMirrorMario.pos[0]; + gMirrorMario.pos[0] = mirroredX + CASTLE_MIRROR_X; gMirrorMario.angle[1] = -gMirrorMario.angle[1]; gMirrorMario.scale[0] *= -1.0f; ((struct GraphNode *) &gMirrorMario)->flags |= GRAPH_RENDER_ACTIVE; diff --git a/src/game/moving_texture.c b/src/game/moving_texture.c index 7e99d473..9a5adf55 100644 --- a/src/game/moving_texture.c +++ b/src/game/moving_texture.c @@ -109,8 +109,8 @@ s16 gMovtexCounterPrev = 0; // Vertex colors for rectangles. Used to give mist a tint #define MOVTEX_VTX_COLOR_DEFAULT 0 // no tint (white vertex colors) -#define MOVTEX_VTX_COLOR_YELLOW 1 // used for Hazy Maze Cave toxic haze -#define MOVTEX_VTX_COLOR_RED 2 // used for Shifting Sand Land around the Tox box maze +#define MOVTEX_VTX_COLOR_YELLOW 1 // used for Hazy Maze Cave toxic haze +#define MOVTEX_VTX_COLOR_RED 2 // used for Shifting Sand Land around the Tox box maze s8 gMovtexVtxColor = MOVTEX_VTX_COLOR_DEFAULT; @@ -120,71 +120,71 @@ float gPaintingMarioYEntry = 0.0f; /// Variable to ensure the initial Wet-Dry World water level is set only once s32 gWdwWaterLevelSet = FALSE; -extern u8 ssl_quicksand[]; -extern u8 ssl_pyramid_sand[]; -extern u8 ttc_yellow_triangle[]; +extern Texture ssl_quicksand[]; +extern Texture ssl_pyramid_sand[]; +extern Texture ttc_yellow_triangle[]; /** * An array for converting a movtex texture id to a pointer that can * be passed to gDPSetTextureImage. */ -u8 *gMovtexIdToTexture[] = { texture_waterbox_water, texture_waterbox_mist, - texture_waterbox_jrb_water, texture_waterbox_unknown_water, - texture_waterbox_lava, ssl_quicksand, - ssl_pyramid_sand, ttc_yellow_triangle }; +Texture *gMovtexIdToTexture[] = { texture_waterbox_water, texture_waterbox_mist, + texture_waterbox_jrb_water, texture_waterbox_unknown_water, + texture_waterbox_lava, ssl_quicksand, + ssl_pyramid_sand, ttc_yellow_triangle }; -extern Gfx castle_grounds_dl_waterfall[]; -extern s16 castle_grounds_movtex_tris_waterfall[]; -extern s16 ssl_movtex_tris_pyramid_sand_pathway_front[]; -extern Gfx ssl_dl_pyramid_sand_pathway_begin[]; -extern Gfx ssl_dl_pyramid_sand_pathway_end[]; -extern Gfx ssl_dl_pyramid_sand_pathway_front_end[]; -extern s16 ssl_movtex_tris_pyramid_sand_pathway_floor[]; -extern Gfx ssl_dl_pyramid_sand_pathway_floor_begin[]; -extern Gfx ssl_dl_pyramid_sand_pathway_floor_end[]; -extern s16 ssl_movtex_tris_pyramid_sand_pathway_side[]; -extern Gfx ssl_dl_pyramid_sand_pathway_side_end[]; -extern s16 bitfs_movtex_tris_lava_first_section[]; -extern Gfx bitfs_dl_lava_sections[]; -extern s16 bitfs_movtex_tris_lava_second_section[]; -extern s16 bitfs_movtex_tris_lava_floor[]; -extern Gfx bitfs_dl_lava_floor[]; -extern s16 lll_movtex_tris_lava_floor[]; -extern Gfx lll_dl_lava_floor[]; -extern s16 lll_movtex_tris_lavafall_volcano[]; -extern Gfx lll_dl_lavafall_volcano[]; -extern s16 cotmc_movtex_tris_water[]; -extern Gfx cotmc_dl_water_begin[]; -extern Gfx cotmc_dl_water_end[]; -extern Gfx cotmc_dl_water[]; -extern s16 ttm_movtex_tris_begin_waterfall[]; -extern Gfx ttm_dl_waterfall[]; -extern s16 ttm_movtex_tris_end_waterfall[]; -extern s16 ttm_movtex_tris_begin_puddle_waterfall[]; -extern Gfx ttm_dl_bottom_waterfall[]; -extern s16 ttm_movtex_tris_end_puddle_waterfall[]; -extern s16 ttm_movtex_tris_puddle_waterfall[]; -extern Gfx ttm_dl_puddle_waterfall[]; -extern s16 ssl_movtex_tris_pyramid_quicksand[]; -extern Gfx ssl_dl_quicksand_begin[]; -extern Gfx ssl_dl_quicksand_end[]; -extern Gfx ssl_dl_pyramid_quicksand[]; -extern s16 ssl_movtex_tris_pyramid_corners_quicksand[]; -extern Gfx ssl_dl_pyramid_corners_quicksand[]; -extern s16 ssl_movtex_tris_sides_quicksand[]; -extern Gfx ssl_dl_sides_quicksand[]; -extern s16 ttc_movtex_tris_big_surface_treadmill[]; -extern Gfx ttc_dl_surface_treadmill_begin[]; -extern Gfx ttc_dl_surface_treadmill_end[]; -extern Gfx ttc_dl_surface_treadmill[]; -extern s16 ttc_movtex_tris_small_surface_treadmill[]; -extern s16 ssl_movtex_tris_quicksand_pit[]; -extern Gfx ssl_dl_quicksand_pit_begin[]; -extern Gfx ssl_dl_quicksand_pit_end[]; -extern Gfx ssl_dl_quicksand_pit[]; -extern s16 ssl_movtex_tris_pyramid_quicksand_pit[]; -extern Gfx ssl_dl_pyramid_quicksand_pit_begin[]; -extern Gfx ssl_dl_pyramid_quicksand_pit_end[]; +extern Gfx castle_grounds_dl_waterfall[]; +extern Movtex castle_grounds_movtex_tris_waterfall[]; +extern Movtex ssl_movtex_tris_pyramid_sand_pathway_front[]; +extern Gfx ssl_dl_pyramid_sand_pathway_begin[]; +extern Gfx ssl_dl_pyramid_sand_pathway_end[]; +extern Gfx ssl_dl_pyramid_sand_pathway_front_end[]; +extern Movtex ssl_movtex_tris_pyramid_sand_pathway_floor[]; +extern Gfx ssl_dl_pyramid_sand_pathway_floor_begin[]; +extern Gfx ssl_dl_pyramid_sand_pathway_floor_end[]; +extern Movtex ssl_movtex_tris_pyramid_sand_pathway_side[]; +extern Gfx ssl_dl_pyramid_sand_pathway_side_end[]; +extern Movtex bitfs_movtex_tris_lava_first_section[]; +extern Gfx bitfs_dl_lava_sections[]; +extern Movtex bitfs_movtex_tris_lava_second_section[]; +extern Movtex bitfs_movtex_tris_lava_floor[]; +extern Gfx bitfs_dl_lava_floor[]; +extern Movtex lll_movtex_tris_lava_floor[]; +extern Gfx lll_dl_lava_floor[]; +extern Movtex lll_movtex_tris_lavafall_volcano[]; +extern Gfx lll_dl_lavafall_volcano[]; +extern Movtex cotmc_movtex_tris_water[]; +extern Gfx cotmc_dl_water_begin[]; +extern Gfx cotmc_dl_water_end[]; +extern Gfx cotmc_dl_water[]; +extern Movtex ttm_movtex_tris_begin_waterfall[]; +extern Gfx ttm_dl_waterfall[]; +extern Movtex ttm_movtex_tris_end_waterfall[]; +extern Movtex ttm_movtex_tris_begin_puddle_waterfall[]; +extern Gfx ttm_dl_bottom_waterfall[]; +extern Movtex ttm_movtex_tris_end_puddle_waterfall[]; +extern Movtex ttm_movtex_tris_puddle_waterfall[]; +extern Gfx ttm_dl_puddle_waterfall[]; +extern Movtex ssl_movtex_tris_pyramid_quicksand[]; +extern Gfx ssl_dl_quicksand_begin[]; +extern Gfx ssl_dl_quicksand_end[]; +extern Gfx ssl_dl_pyramid_quicksand[]; +extern Movtex ssl_movtex_tris_pyramid_corners_quicksand[]; +extern Gfx ssl_dl_pyramid_corners_quicksand[]; +extern Movtex ssl_movtex_tris_sides_quicksand[]; +extern Gfx ssl_dl_sides_quicksand[]; +extern Movtex ttc_movtex_tris_big_surface_treadmill[]; +extern Gfx ttc_dl_surface_treadmill_begin[]; +extern Gfx ttc_dl_surface_treadmill_end[]; +extern Gfx ttc_dl_surface_treadmill[]; +extern Movtex ttc_movtex_tris_small_surface_treadmill[]; +extern Movtex ssl_movtex_tris_quicksand_pit[]; +extern Gfx ssl_dl_quicksand_pit_begin[]; +extern Gfx ssl_dl_quicksand_pit_end[]; +extern Gfx ssl_dl_quicksand_pit[]; +extern Movtex ssl_movtex_tris_pyramid_quicksand_pit[]; +extern Gfx ssl_dl_pyramid_quicksand_pit_begin[]; +extern Gfx ssl_dl_pyramid_quicksand_pit_end[]; /** * MovtexObjects that have no color attributes per vertex (though the mesh @@ -509,30 +509,30 @@ Gfx *movtex_gen_quads_id(s16 id, s16 y, void *movetexQuadsSegmented) { return NULL; } -extern u8 bbh_movtex_merry_go_round_water_entrance[]; -extern u8 bbh_movtex_merry_go_round_water_side[]; -extern u8 ccm_movtex_penguin_puddle_water[]; -extern u8 inside_castle_movtex_green_room_water[]; -extern u8 inside_castle_movtex_moat_water[]; -extern u8 hmc_movtex_dorrie_pool_water[]; -extern u8 hmc_movtex_toxic_maze_mist[]; -extern u8 ssl_movtex_puddle_water[]; -extern u8 ssl_movtex_toxbox_quicksand_mist[]; -extern u8 sl_movtex_water[]; -extern u8 wdw_movtex_area1_water[]; -extern u8 wdw_movtex_area2_water[]; -extern u8 jrb_movtex_water[]; -extern u8 jrb_movtex_intial_mist[]; -extern u8 jrb_movtex_sinked_boat_water[]; -extern u8 thi_movtex_area1_water[]; -extern u8 thi_movtex_area2_water[]; -extern u8 castle_grounds_movtex_water[]; -extern u8 lll_movtex_volcano_floor_lava[]; -extern u8 ddd_movtex_area1_water[]; -extern u8 ddd_movtex_area2_water[]; -extern u8 wf_movtex_water[]; -extern u8 castle_courtyard_movtex_star_statue_water[]; -extern u8 ttm_movtex_puddle[]; +extern Movtex bbh_movtex_merry_go_round_water_entrance[]; +extern Movtex bbh_movtex_merry_go_round_water_side[]; +extern Movtex ccm_movtex_penguin_puddle_water[]; +extern Movtex inside_castle_movtex_green_room_water[]; +extern Movtex inside_castle_movtex_moat_water[]; +extern Movtex hmc_movtex_dorrie_pool_water[]; +extern Movtex hmc_movtex_toxic_maze_mist[]; +extern Movtex ssl_movtex_puddle_water[]; +extern Movtex ssl_movtex_toxbox_quicksand_mist[]; +extern Movtex sl_movtex_water[]; +extern Movtex wdw_movtex_area1_water[]; +extern Movtex wdw_movtex_area2_water[]; +extern Movtex jrb_movtex_water[]; +extern Movtex jrb_movtex_intial_mist[]; +extern Movtex jrb_movtex_sinked_boat_water[]; +extern Movtex thi_movtex_area1_water[]; +extern Movtex thi_movtex_area2_water[]; +extern Movtex castle_grounds_movtex_water[]; +extern Movtex lll_movtex_volcano_floor_lava[]; +extern Movtex ddd_movtex_area1_water[]; +extern Movtex ddd_movtex_area2_water[]; +extern Movtex wf_movtex_water[]; +extern Movtex castle_courtyard_movtex_star_statue_water[]; +extern Movtex ttm_movtex_puddle[]; /** * Find the quadCollection for a given quad collection id. diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index 64ec80da..ec1a72c4 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -710,7 +710,7 @@ void obj_check_floor_death(s16 collisionFlags, struct Surface *floor) { case SURFACE_BURNING: o->oAction = OBJ_ACT_LAVA_DEATH; break; - //! @BUG Doesn't check for the vertical wind death floor. + case SURFACE_VERTICAL_WIND: // fall through case SURFACE_DEATH_PLANE: o->oAction = OBJ_ACT_DEATH_PLANE_DEATH; break; diff --git a/src/game/obj_behaviors_2.c b/src/game/obj_behaviors_2.c index ddd945b0..63c61322 100644 --- a/src/game/obj_behaviors_2.c +++ b/src/game/obj_behaviors_2.c @@ -47,7 +47,9 @@ #include "spawn_sound.h" #include "puppylights.h" -#define POS_OP_SAVE_POSITION 0 +//! TODO: remove static + +#define POS_OP_SAVE_POSITION 0 #define POS_OP_COMPUTE_VELOCITY 1 #define POS_OP_RESTORE_POSITION 2 @@ -56,9 +58,6 @@ /* BSS (declared to force order) */ extern s32 sNumActiveFirePiranhaPlants; extern s32 sNumKilledFirePiranhaPlants; -extern f32 sObjSavedPosX; -extern f32 sObjSavedPosY; -extern f32 sObjSavedPosZ; extern struct Object *sMontyMoleHoleList; extern s32 sMontyMoleKillStreak; extern f32 sMontyMoleLastKilledPosX; @@ -71,20 +70,13 @@ extern struct Object *sMasterTreadmill; */ struct Object *sMasterTreadmill; - -f32 sObjSavedPosX; -f32 sObjSavedPosY; -f32 sObjSavedPosZ; +Vec3f sObjSavedPos; void wiggler_jumped_on_attack_handler(void); void huge_goomba_weakly_attacked(void); static s32 obj_is_rendering_enabled(void) { - if (o->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) { - return TRUE; - } else { - return FALSE; - } + return (o->header.gfx.node.flags & GRAPH_RENDER_ACTIVE); } static s16 obj_get_pitch_from_vel(void) { @@ -117,34 +109,16 @@ static void obj_set_dist_from_home(f32 distFromHome) { } static s32 obj_is_near_to_and_facing_mario(f32 maxDist, s16 maxAngleDiff) { - if (o->oDistanceToMario < maxDist - && abs_angle_diff(o->oMoveAngleYaw, o->oAngleToMario) < maxAngleDiff) { - return TRUE; - } - return FALSE; + return (o->oDistanceToMario < maxDist && abs_angle_diff(o->oMoveAngleYaw, o->oAngleToMario) < maxAngleDiff); } //! Although having no return value, this function //! must be u32 to match other functions on -O2. static void obj_perform_position_op(s32 op) { switch (op) { - case POS_OP_SAVE_POSITION: - sObjSavedPosX = o->oPosX; - sObjSavedPosY = o->oPosY; - sObjSavedPosZ = o->oPosZ; - break; - - case POS_OP_COMPUTE_VELOCITY: - o->oVelX = o->oPosX - sObjSavedPosX; - o->oVelY = o->oPosY - sObjSavedPosY; - o->oVelZ = o->oPosZ - sObjSavedPosZ; - break; - - case POS_OP_RESTORE_POSITION: - o->oPosX = sObjSavedPosX; - o->oPosY = sObjSavedPosY; - o->oPosZ = sObjSavedPosZ; - break; + case POS_OP_SAVE_POSITION: vec3_copy(sObjSavedPos, &o->oPosVec); break; + case POS_OP_COMPUTE_VELOCITY: vec3_diff(&o->oVelVec, &o->oPosVec, sObjSavedPos); break; + case POS_OP_RESTORE_POSITION: vec3_copy(&o->oPosVec, sObjSavedPos); break; } } @@ -154,9 +128,7 @@ static void platform_on_track_update_pos_or_spawn_ball(s32 ballIndex, f32 x, f32 struct Waypoint *nextWaypoint; struct Waypoint *prevWaypoint; f32 amountToMove; - f32 dx; - f32 dy; - f32 dz; + f32 dx, dy, dz; f32 distToNextWaypoint; if (ballIndex == 0 || ((u16)(o->oBehParams >> 16) & 0x0080)) { @@ -229,15 +201,10 @@ static void platform_on_track_update_pos_or_spawn_ball(s32 ballIndex, f32 x, f32 } o->oPlatformOnTrackPrevWaypoint = prevWaypoint; } - - o->oPosX = x; - o->oPosY = y; - o->oPosZ = z; - + vec3_set(&o->oPosVec, x, y, z); obj_perform_position_op(POS_OP_COMPUTE_VELOCITY); - o->oPlatformOnTrackPitch = - atan2s(sqrtf(o->oVelX * o->oVelX + o->oVelZ * o->oVelZ), -o->oVelY); + o->oPlatformOnTrackPitch = atan2s(sqrtf(sqr(o->oVelX) + sqr(o->oVelZ)), -o->oVelY); o->oPlatformOnTrackYaw = atan2s(o->oVelZ, o->oVelX); } } @@ -315,7 +282,6 @@ static s32 clamp_s16(s16 *value, s16 minimum, s16 maximum) { } else { return FALSE; } - return TRUE; } @@ -327,7 +293,6 @@ static s32 clamp_f32(f32 *value, f32 minimum, f32 maximum) { } else { return FALSE; } - return TRUE; } @@ -403,42 +368,22 @@ static s32 obj_y_vel_approach(f32 target, f32 delta) { static s32 obj_move_pitch_approach(s16 target, s16 delta) { o->oMoveAnglePitch = approach_s16_symmetric(o->oMoveAnglePitch, target, delta); - - if ((s16) o->oMoveAnglePitch == target) { - return TRUE; - } - - return FALSE; + return ((s16) o->oMoveAnglePitch == target); } static s32 obj_face_pitch_approach(s16 targetPitch, s16 deltaPitch) { o->oFaceAnglePitch = approach_s16_symmetric(o->oFaceAnglePitch, targetPitch, deltaPitch); - - if ((s16) o->oFaceAnglePitch == targetPitch) { - return TRUE; - } - - return FALSE; + return ((s16) o->oFaceAnglePitch == targetPitch); } static s32 obj_face_yaw_approach(s16 targetYaw, s16 deltaYaw) { o->oFaceAngleYaw = approach_s16_symmetric(o->oFaceAngleYaw, targetYaw, deltaYaw); - - if ((s16) o->oFaceAngleYaw == targetYaw) { - return TRUE; - } - - return FALSE; + return ((s16) o->oFaceAngleYaw == targetYaw); } static s32 obj_face_roll_approach(s16 targetRoll, s16 deltaRoll) { o->oFaceAngleRoll = approach_s16_symmetric(o->oFaceAngleRoll, targetRoll, deltaRoll); - - if ((s16) o->oFaceAngleRoll == targetRoll) { - return TRUE; - } - - return FALSE; + return ((s16) o->oFaceAngleRoll == targetRoll); } static s32 obj_smooth_turn(s16 *angleVel, s32 *angle, s16 targetAngle, f32 targetSpeedProportion, @@ -585,12 +530,7 @@ static s32 obj_bounce_off_walls_edges_objects(s32 *targetYaw) { static s32 obj_resolve_collisions_and_turn(s16 targetYaw, s16 turnSpeed) { obj_resolve_object_collisions(NULL); - - if (cur_obj_rotate_yaw_toward(targetYaw, turnSpeed)) { - return FALSE; - } else { - return TRUE; - } + return (!cur_obj_rotate_yaw_toward(targetYaw, turnSpeed)); } static void obj_die_if_health_non_positive(void) { diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index 4d96afc5..472c30c8 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -1606,9 +1606,8 @@ static void cur_obj_update_floor(void) { if (floor != NULL) { if (floor->type == SURFACE_BURNING) { o->oMoveFlags |= OBJ_MOVE_ABOVE_LAVA; - } - else if (floor->type == SURFACE_DEATH_PLANE) { - //! This misses SURFACE_VERTICAL_WIND (and maybe SURFACE_WARP) + } else if ((floor->type == SURFACE_DEATH_PLANE) || (floor->type == SURFACE_VERTICAL_WIND)) { + //! This maybe misses SURFACE_WARP o->oMoveFlags |= OBJ_MOVE_ABOVE_DEATH_BARRIER; } diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index a584b709..02b5fefd 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -9,6 +9,7 @@ #include "engine/graph_node.h" #include "engine/surface_collision.h" #include "engine/surface_load.h" +#include "engine/math_util.h" #include "interaction.h" #include "level_update.h" #include "mario.h" @@ -224,28 +225,13 @@ void copy_mario_state_to_object(void) { s32 i = 0; // L is real if (gCurrentObject != gMarioObject) { - i += 1; + i++; } - - gCurrentObject->oVelX = gMarioStates[i].vel[0]; - gCurrentObject->oVelY = gMarioStates[i].vel[1]; - gCurrentObject->oVelZ = gMarioStates[i].vel[2]; - - gCurrentObject->oPosX = gMarioStates[i].pos[0]; - gCurrentObject->oPosY = gMarioStates[i].pos[1]; - gCurrentObject->oPosZ = gMarioStates[i].pos[2]; - - gCurrentObject->oMoveAnglePitch = gCurrentObject->header.gfx.angle[0]; - gCurrentObject->oMoveAngleYaw = gCurrentObject->header.gfx.angle[1]; - gCurrentObject->oMoveAngleRoll = gCurrentObject->header.gfx.angle[2]; - - gCurrentObject->oFaceAnglePitch = gCurrentObject->header.gfx.angle[0]; - gCurrentObject->oFaceAngleYaw = gCurrentObject->header.gfx.angle[1]; - gCurrentObject->oFaceAngleRoll = gCurrentObject->header.gfx.angle[2]; - - gCurrentObject->oAngleVelPitch = gMarioStates[i].angleVel[0]; - gCurrentObject->oAngleVelYaw = gMarioStates[i].angleVel[1]; - gCurrentObject->oAngleVelRoll = gMarioStates[i].angleVel[2]; + vec3_copy(&gCurrentObject->oVelVec, gMarioStates[i].vel); + vec3_copy(&gCurrentObject->oPosVec, gMarioStates[i].pos); + vec3_copy(&gCurrentObject->oMoveAngleVec, gCurrentObject->header.gfx.angle); + vec3_copy(&gCurrentObject->oFaceAngleVec, gCurrentObject->header.gfx.angle); + vec3_copy(&gCurrentObject->oAngleVelVec, gMarioStates[i].angleVel); } /** @@ -497,18 +483,9 @@ void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo) { } geo_obj_init_spawninfo(&object->header.gfx, spawnInfo); - - object->oPosX = spawnInfo->startPos[0]; - object->oPosY = spawnInfo->startPos[1]; - object->oPosZ = spawnInfo->startPos[2]; - - object->oFaceAnglePitch = spawnInfo->startAngle[0]; - object->oFaceAngleYaw = spawnInfo->startAngle[1]; - object->oFaceAngleRoll = spawnInfo->startAngle[2]; - - object->oMoveAnglePitch = spawnInfo->startAngle[0]; - object->oMoveAngleYaw = spawnInfo->startAngle[1]; - object->oMoveAngleRoll = spawnInfo->startAngle[2]; + vec3_copy(&object->oPosVec, spawnInfo->startPos); + vec3_copy(&object->oFaceAngleVec, spawnInfo->startAngle); + vec3_copy(&object->oMoveAngleVec, spawnInfo->startAngle); object->oFloorHeight = find_floor(object->oPosX, object->oPosY, object->oPosZ, &object->oFloor); } diff --git a/src/game/paintings.c b/src/game/paintings.c index 3ed2543b..9c2b0152 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -4,6 +4,7 @@ #include "area.h" #include "engine/graph_node.h" #include "engine/surface_collision.h" +#include "engine/math_util.h" #include "game_init.h" #include "geo_misc.h" #include "levels/castle_inside/header.h" @@ -575,16 +576,12 @@ void painting_update_floors(struct Painting *painting) { void painting_update_ripple_state(struct Painting *painting) { if (gPaintingUpdateCounter != gLastPaintingUpdateCounter) { painting->currRippleMag *= painting->rippleDecay; - - //! After ~6.47 days, paintings with RIPPLE_TRIGGER_CONTINUOUS will increment this to - //! 16777216 (1 << 24), at which point it will freeze (due to floating-point - //! imprecision?) and the painting will stop rippling. This happens to HMC, DDD, and - //! CotMC. - painting->rippleTimer += 1.0; + if (painting->rippleTimer >= ((1 << 24) - 1.0f)) painting->rippleTimer = 0.0f; + painting->rippleTimer += 1.0f; } if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { // if the painting is barely rippling, make it stop rippling - if (painting->currRippleMag <= 1.0) { + if (painting->currRippleMag <= 1.0f) { painting->state = PAINTING_IDLE; gRipplingPainting = NULL; } @@ -621,14 +618,13 @@ s16 calculate_ripple_at_point(struct Painting *painting, f32 posX, f32 posY) { f32 rippleX = painting->rippleX; f32 rippleY = painting->rippleY; - f32 distanceToOrigin; - f32 rippleDistance; - posX *= painting->size / PAINTING_SIZE; posY *= painting->size / PAINTING_SIZE; - distanceToOrigin = sqrtf((posX - rippleX) * (posX - rippleX) + (posY - rippleY) * (posY - rippleY)); + f32 dx = (posX - rippleX); + f32 dy = (posY - rippleY); + f32 distanceToOrigin = sqrtf(sqr(dx) + sqr(dy)); // A larger dispersionFactor makes the ripple spread slower - rippleDistance = distanceToOrigin / dispersionFactor; + f32 rippleDistance = distanceToOrigin / dispersionFactor; if (rippleTimer < rippleDistance) { // if the ripple hasn't reached the point yet, make the point magnitude 0 return 0; @@ -647,12 +643,10 @@ s16 calculate_ripple_at_point(struct Painting *painting, f32 posX, f32 posY) { * else return 0 */ s16 ripple_if_movable(struct Painting *painting, s16 movable, s16 posX, s16 posY) { - s16 rippleZ = 0; - if (movable) { - rippleZ = calculate_ripple_at_point(painting, posX, posY); + return calculate_ripple_at_point(painting, posX, posY); } - return rippleZ; + return 0; } /** @@ -769,8 +763,7 @@ s8 normalize_component(f32 comp) { */ void painting_average_vertex_normals(s16 *neighborTris, s16 numVtx) { s16 tri; - s16 i; - s16 j; + s16 i, j; s16 neighbors; s16 entry = 0; @@ -795,7 +788,7 @@ void painting_average_vertex_normals(s16 *neighborTris, s16 numVtx) { nx /= neighbors; ny /= neighbors; nz /= neighbors; - nlen = sqrtf(nx * nx + ny * ny + nz * nz); + nlen = sqrtf(sqr(nx) + sqr(ny) + sqr(nz)); if (nlen == 0.0) { gPaintingMesh[i].norm[0] = 0; @@ -822,8 +815,7 @@ Gfx *render_painting(u8 *img, s16 tWidth, s16 tHeight, s16 *textureMap, s16 mapV s16 triGroup; s16 mapping; s16 meshVtx; - s16 tx; - s16 ty; + s16 tx, ty; // We can fit 15 (16 / 3) vertices in the RSP's vertex buffer. // Group triangles by 5, with one remainder group. diff --git a/src/game/print.c b/src/game/print.c index dcad8d40..de346548 100644 --- a/src/game/print.c +++ b/src/game/print.c @@ -106,8 +106,7 @@ void format_integer(s32 n, s32 base, char *dest, s32 *totalLength, u8 width, s8 n -= digit * powBase; } - } else // n is zero. - { + } else { // n is zero. numDigits = 1; if (width > numDigits) { for (len = 0; len < width - numDigits; len++) dest[len] = pad; @@ -134,11 +133,13 @@ void parse_width_field(const char *str, s32 *srcIndex, u8 *width, s8 *zeroPad) { } // Read width digits up until the 'd' or 'x' format specifier. - while (str[*srcIndex] != 'd' && str[*srcIndex] != 'x') { + while ((str[*srcIndex] != 'b') + && (str[*srcIndex] != 'o') + && (str[*srcIndex] != 'd') + && (str[*srcIndex] != 'x')) { digits[digitsLen] = str[*srcIndex] - '0'; - if (digits[digitsLen] < 0 || digits[digitsLen] >= 10) // not a valid digit - { + if (digits[digitsLen] < 0 || digits[digitsLen] >= 10) { // not a valid digit *width = 0; return; } @@ -192,15 +193,16 @@ void print_text_fmt_int(s32 x, s32 y, const char *str, s32 n) { parse_width_field(str, &srcIndex, &width, &zeroPad); - if (str[srcIndex] != 'd' && str[srcIndex] != 'x') { + if ((str[srcIndex] != 'b') + && (str[srcIndex] != 'o') + && (str[srcIndex] != 'd') + && (str[srcIndex] != 'x')) { break; } - if (str[srcIndex] == 'd') { - base = 10; - } - if (str[srcIndex] == 'x') { - base = 16; - } + if (str[srcIndex] == 'b') base = 2; + if (str[srcIndex] == 'o') base = 8; + if (str[srcIndex] == 'd') base = 10; + if (str[srcIndex] == 'x') base = 16; srcIndex++; @@ -283,66 +285,21 @@ void print_text_centered(s32 x, s32 y, const char *str) { * Converts a char into the proper colorful glyph for the char. */ s8 char_to_glyph_index(char c) { - if (c >= 'A' && c <= 'Z') { - return c - 55; - } - - if (c >= 'a' && c <= 'z') { - return c - 87; - } - - if (c >= '0' && c <= '9') { - return c - 48; - } - - if (c == ' ') { - return GLYPH_SPACE; - } - - if (c == '!') { - return GLYPH_EXCLAMATION_PNT; // !, JP only - } - - if (c == '#') { - return GLYPH_TWO_EXCLAMATION; // !!, JP only - } - - if (c == '?') { - return GLYPH_QUESTION_MARK; // ?, JP only - } - - if (c == '&') { - return GLYPH_AMPERSAND; // &, JP only - } - - if (c == '%') { - return GLYPH_PERCENT; // %, JP only - } - - if (c == '*') { - return GLYPH_MULTIPLY; // x - } - - if (c == '+') { - return GLYPH_COIN; // coin - } - - if (c == ',') { - return GLYPH_MARIO_HEAD; // Imagine I drew Mario's head - } - - if (c == '-') { - return GLYPH_STAR; // star - } - - if (c == '.') { - return GLYPH_PERIOD; // large shaded dot, JP only - } - - if (c == '/') { - return GLYPH_BETA_KEY; // beta key, JP only. Reused for Ü in EU. - } - + if (c >= 'A' && c <= 'Z') return c - 55; + if (c >= 'a' && c <= 'z') return c - 87; + if (c >= '0' && c <= '9') return c - 48; + if (c == ' ') return GLYPH_SPACE; + if (c == '!') return GLYPH_EXCLAMATION_PNT; // !, JP only + if (c == '#') return GLYPH_TWO_EXCLAMATION; // !!, JP only + if (c == '?') return GLYPH_QUESTION_MARK; // ?, JP only + if (c == '&') return GLYPH_AMPERSAND; // &, JP only + if (c == '%') return GLYPH_PERCENT; // %, JP only + if (c == '*') return GLYPH_MULTIPLY; // x + if (c == '+') return GLYPH_COIN; // coin + if (c == ',') return GLYPH_MARIO_HEAD; // Imagine I drew Mario's head + if (c == '-') return GLYPH_STAR; // star + if (c == '.') return GLYPH_PERIOD; // large shaded dot, JP only + if (c == '/') return GLYPH_BETA_KEY; // beta key, JP only. Reused for Ü in EU. return GLYPH_SPACE; } @@ -350,7 +307,7 @@ s8 char_to_glyph_index(char c) { * Adds an individual glyph to be rendered. */ void add_glyph_texture(s8 glyphIndex) { - const u8 *const *glyphs = segmented_to_virtual(main_hud_lut); + const Texture *const *glyphs = segmented_to_virtual(main_hud_lut); gDPPipeSync(gDisplayListHead++); gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, glyphs[glyphIndex]); @@ -362,21 +319,10 @@ void add_glyph_texture(s8 glyphIndex) { * Clips textrect into the boundaries defined. */ void clip_to_bounds(s32 *x, s32 *y) { - if (*x < TEXRECT_MIN_X) { - *x = TEXRECT_MIN_X; - } - - if (*x > TEXRECT_MAX_X) { - *x = TEXRECT_MAX_X; - } - - if (*y < TEXRECT_MIN_Y) { - *y = TEXRECT_MIN_Y; - } - - if (*y > TEXRECT_MAX_Y) { - *y = TEXRECT_MAX_Y; - } + if (*x < TEXRECT_MIN_X) *x = TEXRECT_MIN_X; + if (*x > TEXRECT_MAX_X) *x = TEXRECT_MAX_X; + if (*y < TEXRECT_MIN_Y) *y = TEXRECT_MIN_Y; + if (*y > TEXRECT_MAX_Y) *y = TEXRECT_MAX_Y; } #endif @@ -386,8 +332,7 @@ void clip_to_bounds(s32 *x, s32 *y) { void render_textrect(s32 x, s32 y, s32 pos) { s32 rectBaseX = x + pos * 12; s32 rectBaseY = 224 - y; - s32 rectX; - s32 rectY; + s32 rectX, rectY; #ifndef WIDESCREEN // For widescreen we must allow drawing outside the usual area @@ -404,8 +349,7 @@ void render_textrect(s32 x, s32 y, s32 pos) { * a for loop. */ void render_text_labels(void) { - s32 i; - s32 j; + s32 i, j; s8 glyphIndex; Mtx *mtx; diff --git a/src/game/puppycam2.h b/src/game/puppycam2.h index 158f5f5e..f81b72f0 100644 --- a/src/game/puppycam2.h +++ b/src/game/puppycam2.h @@ -6,8 +6,8 @@ //How many times to store the terrain pitch. This stores it over 10 frames to help smooth over changes in curvature. #define NUM_PITCH_ITERATIONS 10 -#define PUPPYCAM_FLAGS_CUTSCENE 0x0001 -#define PUPPYCAM_FLAGS_SMOOTH 0x0002 +#define PUPPYCAM_FLAGS_CUTSCENE (1 << 0) // 0x0001 +#define PUPPYCAM_FLAGS_SMOOTH (1 << 1) // 0x0002 #define PUPPY_ERROR_POOL_FULL 0x1 @@ -17,19 +17,19 @@ #define PUPPYCAM_BEHAVIOUR_TEMPORARY 0x0 #define PUPPYCAM_BEHAVIOUR_PERMANENT 0x1 -#define PUPPYVOLUME_SHAPE_BOX 0x0 -#define PUPPYVOLUME_SHAPE_CYLINDER 0x1 +#define PUPPYVOLUME_SHAPE_BOX 0x0 +#define PUPPYVOLUME_SHAPE_CYLINDER 0x1 -#define PUPPYCAM_MODE3_ZOOMED_IN 0x1 -#define PUPPYCAM_MODE3_ZOOMED_MED 0x2 -#define PUPPYCAM_MODE3_ZOOMED_OUT 0x4 -#define PUPPYCAM_MODE3_ENTER_FIRST_PERSON 0x8 +#define PUPPYCAM_MODE3_ZOOMED_IN (1 << 0) // 0x1 +#define PUPPYCAM_MODE3_ZOOMED_MED (1 << 1) // 0x2 +#define PUPPYCAM_MODE3_ZOOMED_OUT (1 << 2) // 0x4 +#define PUPPYCAM_MODE3_ENTER_FIRST_PERSON (1 << 3) // 0x8 -#define PUPPYSPLINE_NONE 1 //Will not write to focus at all. -#define PUPPYSPLINE_FOLLOW 2 //Focus will follow a separate spline, but will mirror the speed and progress of the pos. +#define PUPPYSPLINE_NONE (1 << 0) // 0x1 // Will not write to focus at all. +#define PUPPYSPLINE_FOLLOW (1 << 1) // 0x2 // Focus will follow a separate spline, but will mirror the speed and progress of the pos. -#define PUPPYDEBUG_LOCK_CONTROLS 0x1 -#define PUPPYDEBUG_TRACK_MARIO 0x2 +#define PUPPYDEBUG_LOCK_CONTROLS (1 << 0) // 0x1 +#define PUPPYDEBUG_TRACK_MARIO (1 << 1) // 0x2 #include "include/command_macros_base.h" @@ -55,54 +55,54 @@ struct gPuppyOptions struct gPuppyStruct { - s16 yaw; //Horizontal Direction the game reads as the active value. - s16 yawTarget; //Horizontal Direction that yaw tries to be. - f32 yawAcceleration; //Horizontal Direction that sets yawTarget. - s16 pitch; //Vertical Direction the game reads as the active value. - s16 pitchTarget; //Vertical Direction that pitch tries to be. - f32 pitchAcceleration; //Vertical Direction that sets pitchTarget. - s16 zoom; //How far the camera is currently zoomed out - u8 zoomSet; //The current setting of which zoompoint to set the target to. - s16 zoomTarget; //The value that zoom tries to be. - s16 zoomPoints[3]; //An array containing distances. - s16 targetFloorHeight; //Mario's current floor height - s16 lastTargetFloorHeight; //Mirror's mario's floor height when his velocity is not above 0. - Vec3s pos; //Where the camera is - Vec3s focus; //Where the camera's looking - Vec3s pan; //An offset of the camera's focus - s32 intendedFlags; //The flagset the camera tries to be when it's not held hostage. - s32 flags; //Behaviour flags that affect different properties of the camera's behaviour - Vec3s shake; //How much the camera's shaking - u8 shakeFrames; //How long the camera's shaking for - f32 shakeForce; //How violently the camera's shaking - s32 framesSinceC[2]; //Counts the number of frames since the last C left or right press, to track double presses. - s16 collisionDistance; //Tries to be zoom, but will be overwritten by collision detection - struct Object *targetObj; //The object that the focus will base its positioning off. Usually Mario. - struct Object *targetObj2; //This is the second focus point that the camera will focus on. It'll focus between them. - s16 povHeight; //An offset of the focus object's Y value. - s16 floorY[2]; //Floor offsets, to allow a grace period before following Mario into the air. - u8 opacity; //A value set by collision distance, to fade Mario out if you're too close. - s8 stick2[2];//The value that's set and read for analogue stick. - u8 stickN[2]; //This is set when the stick is neutral. It's to prevent rapidfire input. - u8 enabled : 1; //A boolean that decides whether to use vanilla camera or puppy camera. - s16 swimPitch; //Pitch adjustment that's applied when swimming. All pitch adjustment is clamped. - s16 edgePitch; //Pitch adjustment that's applied when stood near an edge. All pitch adjustment is clamped. - s16 moveZoom; //A small zoom value that's added on top of the regular zoom when moving. It's pretty subtle, but gives the feeling of a bit of speed. - u8 mode3Flags; //A flagset for classic mode. - u8 moveFlagAdd; //A bit that multiplies movement rate of axes when moving, to centre them faster. - s16 targetDist[2]; //Used with secondary view targets to smooth out the between status. - s16 intendedTerrainPitch; //The pitch that the game wants the game to tilt towards, following the terrain. - s16 terrainPitch; //The pitch the game tilts towards, when following terrain inclines. - u8 debugFlags; //Behaviour flags during free view. + s16 yaw; // Horizontal Direction the game reads as the active value. + s16 yawTarget; // Horizontal Direction that yaw tries to be. + f32 yawAcceleration; // Horizontal Direction that sets yawTarget. + s16 pitch; // Vertical Direction the game reads as the active value. + s16 pitchTarget; // Vertical Direction that pitch tries to be. + f32 pitchAcceleration; // Vertical Direction that sets pitchTarget. + s16 zoom; // How far the camera is currently zoomed out + u8 zoomSet; // The current setting of which zoompoint to set the target to. + s16 zoomTarget; // The value that zoom tries to be. + s16 zoomPoints[3]; // An array containing distances. + s16 targetFloorHeight; // Mario's current floor height + s16 lastTargetFloorHeight; // Mirror's mario's floor height when his velocity is not above 0. + Vec3s pos; // Where the camera is + Vec3s focus; // Where the camera's looking + Vec3s pan; // An offset of the camera's focus + s32 intendedFlags; // The flagset the camera tries to be when it's not held hostage. + s32 flags; // Behaviour flags that affect different properties of the camera's behaviour + Vec3s shake; // How much the camera's shaking + u8 shakeFrames; // How long the camera's shaking for + f32 shakeForce; // How violently the camera's shaking + s32 framesSinceC[2]; // Counts the number of frames since the last C left or right press, to track double presses. + s16 collisionDistance; // Tries to be zoom, but will be overwritten by collision detection + struct Object *targetObj; // The object that the focus will base its positioning off. Usually Mario. + struct Object *targetObj2; // This is the second focus point that the camera will focus on. It'll focus between them. + s16 povHeight; // An offset of the focus object's Y value. + s16 floorY[2]; // Floor offsets, to allow a grace period before following Mario into the air. + u8 opacity; // A value set by collision distance, to fade Mario out if you're too close. + s8 stick2[2]; // The value that's set and read for analogue stick. + u8 stickN[2]; // This is set when the stick is neutral. It's to prevent rapidfire input. + u8 enabled : TRUE; // A boolean that decides whether to use vanilla camera or puppy camera. + s16 swimPitch; // Pitch adjustment that's applied when swimming. All pitch adjustment is clamped. + s16 edgePitch; // Pitch adjustment that's applied when stood near an edge. All pitch adjustment is clamped. + s16 moveZoom; // A small zoom value that's added on top of the regular zoom when moving. It's pretty subtle, but gives the feeling of a bit of speed. + u8 mode3Flags; // A flagset for classic mode. + u8 moveFlagAdd; // A bit that multiplies movement rate of axes when moving, to centre them faster. + s16 targetDist[2]; // Used with secondary view targets to smooth out the between status. + s16 intendedTerrainPitch; // The pitch that the game wants the game to tilt towards, following the terrain. + s16 terrainPitch; // The pitch the game tilts towards, when following terrain inclines. + u8 debugFlags; // Behaviour flags during free view. - u8 cutscene; //A boolean that decides whether a cutscene is active + u8 cutscene; // A boolean that decides whether a cutscene is active s32 (*sceneFunc)(); - u8 sceneInput; //A boolean that decides whether the controller updates during the scene. - s32 sceneTimer; //The cutscene timer that goes up during a cutscene. - Vec3s scenePos; //Where the camera is during a cutscene - Vec3s sceneFocus; //Where the camera looks during a cutscene - u16 splineIndex; //Determines which point of the spline it's at. - f32 splineProgress; //Determines how far along the index the spline is. + u8 sceneInput; // A boolean that decides whether the controller updates during the scene. + s32 sceneTimer; // The cutscene timer that goes up during a cutscene. + Vec3s scenePos; // Where the camera is during a cutscene + Vec3s sceneFocus; // Where the camera looks during a cutscene + u16 splineIndex; // Determines which point of the spline it's at. + f32 splineProgress; // Determines how far along the index the spline is. struct gPuppyOptions options; @@ -121,22 +121,22 @@ struct sPuppyAngles //Structurally, it's exactly the same as CutsceneSplinePoint struct sPuppySpline { - s8 index; //The index of the spline. Ends with -1 - u8 speed; //The amount of frames it takes to get through this index. - Vec3s pos; //The vector pos of the spline index itself. + s8 index; // The index of the spline. Ends with -1 + u8 speed; // The amount of frames it takes to get through this index. + Vec3s pos; // The vector pos of the spline index itself. }; //A bounding volume for activating puppycamera scripts and angles. struct sPuppyVolume { - Vec3s pos; //The set position of the volume - Vec3s radius; //Where it extends. - s16 rot; //The rotational angle of the volume. - s32 (*func)(); //a pointer to a function. Optional. - struct sPuppyAngles *angles; //A pointer to a gPuppyAngles struct. Optional - s32 flagsAdd; //Adds behaviour flags. - s32 flagsRemove; //Removes behaviour flags. - u8 flagPersistance; //Decides if adding or removing the flags is temporary or permanent. + Vec3s pos; // The set position of the volume + Vec3s radius; // Where it extends. + s16 rot; // The rotational angle of the volume. + s32 (*func)(); // a pointer to a function. Optional. + struct sPuppyAngles *angles; // A pointer to a gPuppyAngles struct. Optional + s32 flagsAdd; // Adds behaviour flags. + s32 flagsRemove; // Removes behaviour flags. + u8 flagPersistance; // Decides if adding or removing the flags is temporary or permanent. u8 shape; s16 room; u8 area; @@ -144,27 +144,27 @@ struct sPuppyVolume enum gPuppyCamBeh { - PUPPYCAM_BEHAVIOUR_X_MOVEMENT = 0x0001, - PUPPYCAM_BEHAVIOUR_Y_MOVEMENT = 0x0002, - PUPPYCAM_BEHAVIOUR_Z_MOVEMENT = 0x0004, + PUPPYCAM_BEHAVIOUR_X_MOVEMENT = (1 << 0), // 0x0001 + PUPPYCAM_BEHAVIOUR_Y_MOVEMENT = (1 << 1), // 0x0002 + PUPPYCAM_BEHAVIOUR_Z_MOVEMENT = (1 << 2), // 0x0004 - PUPPYCAM_BEHAVIOUR_YAW_ROTATION = 0x0008, - PUPPYCAM_BEHAVIOUR_PITCH_ROTATION = 0x0010, - PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE = 0x0020, + PUPPYCAM_BEHAVIOUR_YAW_ROTATION = (1 << 3), // 0x0008 + PUPPYCAM_BEHAVIOUR_PITCH_ROTATION = (1 << 4), // 0x0010 + PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE = (1 << 5), // 0x0020 - PUPPYCAM_BEHAVIOUR_INPUT_NORMAL = 0x0040, - PUPPYCAM_BEHAVIOUR_INPUT_8DIR = 0x0080, - PUPPYCAM_BEHAVIOUR_INPUT_4DIR = 0x0100, - PUPPYCAM_BEHAVIOUR_INPUT_2D = 0x0200, + PUPPYCAM_BEHAVIOUR_INPUT_NORMAL = (1 << 6), // 0x0040 + PUPPYCAM_BEHAVIOUR_INPUT_8DIR = (1 << 7), // 0x0080 + PUPPYCAM_BEHAVIOUR_INPUT_4DIR = (1 << 8), // 0x0100 + PUPPYCAM_BEHAVIOUR_INPUT_2D = (1 << 9), // 0x0200 - PUPPYCAM_BEHAVIOUR_SLIDE_CORRECTION = 0x0400, - PUPPYCAM_BEHAVIOUR_TURN_HELPER = 0x0800, - PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER = 0x1000, - PUPPYCAM_BEHAVIOUR_PANSHIFT = 0x2000, + PUPPYCAM_BEHAVIOUR_SLIDE_CORRECTION = (1 << 10), // 0x0400 + PUPPYCAM_BEHAVIOUR_TURN_HELPER = (1 << 11), // 0x0800 + PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER = (1 << 12), // 0x1000 + PUPPYCAM_BEHAVIOUR_PANSHIFT = (1 << 13), // 0x2000 - PUPPYCAM_BEHAVIOUR_COLLISION = 0x4000, + PUPPYCAM_BEHAVIOUR_COLLISION = (1 << 14), // 0x4000 - PUPPYCAM_BEHAVIOUR_FREE = 0x8000, + PUPPYCAM_BEHAVIOUR_FREE = (1 << 15), // 0x8000 PUPPYCAM_BEHAVIOUR_DEFAULT = PUPPYCAM_BEHAVIOUR_X_MOVEMENT | PUPPYCAM_BEHAVIOUR_Y_MOVEMENT | PUPPYCAM_BEHAVIOUR_Z_MOVEMENT | PUPPYCAM_BEHAVIOUR_YAW_ROTATION | PUPPYCAM_BEHAVIOUR_PITCH_ROTATION | PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE | diff --git a/src/game/puppylights.h b/src/game/puppylights.h index c8a642a7..bd0bcbcf 100644 --- a/src/game/puppylights.h +++ b/src/game/puppylights.h @@ -5,20 +5,20 @@ #include "types.h" #include "command_macros_base.h" -//The maximum number of lights that can be loaded at once. Any further lights that attempt to be created past this will simply not spawn. +// The maximum number of lights that can be loaded at once. Any further lights that attempt to be created past this will simply not spawn. #define MAX_LIGHTS 32 -//The maximum number of dynamic lights available at one time. +// The maximum number of dynamic lights available at one time. #define MAX_LIGHTS_DYNAMIC 8 -//Two shapes. Choose your destiny. -#define PUPPYLIGHT_SHAPE_CUBE 0x1 -#define PUPPYLIGHT_SHAPE_CYLINDER 0x2 -#define PUPPYLIGHT_DYNAMIC 0x4 -#define PUPPYLIGHT_DIRECTIONAL 0x8 -#define PUPPYLIGHT_SHADOW 0x10 -#define PUPPYLIGHT_WET 0x20 -#define PUPPYLIGHT_DELETE 0x40 -#define PUPPYLIGHT_IGNORE_Y 0x80 +// Two shapes. Choose your destiny. +#define PUPPYLIGHT_SHAPE_CUBE (1 << 0) // 0x01 +#define PUPPYLIGHT_SHAPE_CYLINDER (1 << 1) // 0x02 +#define PUPPYLIGHT_DYNAMIC (1 << 2) // 0x04 +#define PUPPYLIGHT_DIRECTIONAL (1 << 3) // 0x08 +#define PUPPYLIGHT_SHADOW (1 << 4) // 0x10 +#define PUPPYLIGHT_WET (1 << 5) // 0x20 +#define PUPPYLIGHT_DELETE (1 << 6) // 0x40 +#define PUPPYLIGHT_IGNORE_Y (1 << 7) // 0x80 #define LIGHTFLAG_DIRECTIONAL_OFFSET 0x1 diff --git a/src/game/puppyprint.h b/src/game/puppyprint.h index cb54e509..19523668 100644 --- a/src/game/puppyprint.h +++ b/src/game/puppyprint.h @@ -3,19 +3,19 @@ #ifdef PUPPYPRINT -//This is how many indexes of timers are saved at once. higher creates a smoother average, but naturally uses more RAM. 15's fine. -#define NUM_PERF_ITERATIONS 15 +// This is how many indexes of timers are saved at once. higher creates a smoother average, but naturally uses more RAM. 15's fine. +#define NUM_PERF_ITERATIONS 15 #define NUM_BENCH_ITERATIONS 150 -#define LOG_BUFFER_SIZE 16 +#define LOG_BUFFER_SIZE 16 -#define BENCHMARK_GAME 1 -#define BENCHMARK_AUDIO 2 +#define BENCHMARK_GAME 1 +#define BENCHMARK_AUDIO 2 #define BENCHMARK_GRAPHICS 3 -#define PRINT_TEXT_ALIGN_LEFT 0 +#define PRINT_TEXT_ALIGN_LEFT 0 #define PRINT_TEXT_ALIGN_CENTRE 1 -#define PRINT_TEXT_ALIGN_RIGHT 2 -#define PRINT_ALL -1 +#define PRINT_TEXT_ALIGN_RIGHT 2 +#define PRINT_ALL -1 extern Texture small_font[]; extern s8 perfIteration; diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index a6ae802d..d1a859f6 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -287,9 +287,7 @@ void geo_process_master_list_sub(struct GraphNodeMasterList *node) { gSPClearGeometryMode(gDisplayListHead++, G_ZBUFFER); } #ifdef VISUAL_DEBUG - if (hitboxView) { - render_debug_boxes(DEBUG_UCODE_REJ); - } + if (hitboxView) render_debug_boxes(DEBUG_UCODE_REJ); #endif gSPLoadUcodeL(gDisplayListHead++, gspF3DZEX2_PosLight_fifo); init_rcp(KEEP_ZBUFFER); @@ -298,12 +296,8 @@ void geo_process_master_list_sub(struct GraphNodeMasterList *node) { #endif #ifdef VISUAL_DEBUG - if (hitboxView) { - render_debug_boxes(DEBUG_UCODE_DEFAULT | DEBUG_BOX_CLEAR); - } - if (surfaceView) { - visual_surface_loop(); - } + if ( hitboxView) render_debug_boxes(DEBUG_UCODE_DEFAULT | DEBUG_BOX_CLEAR); + if (surfaceView) visual_surface_loop(); #endif } #if SILHOUETTE @@ -326,7 +320,7 @@ void geo_append_display_list(void *displayList, s32 layer) { #if defined(F3DZEX_GBI_2) || (SILHOUETTE > 0) if (gCurGraphNodeObject != NULL) { #ifdef F3DZEX_GBI_2 - if (gCurGraphNodeObject->node.flags & GRAPH_RENDER_UCODE_REJ && ucodeTestSwitch) { + if ((gCurGraphNodeObject->node.flags & GRAPH_RENDER_UCODE_REJ) && ucodeTestSwitch) { index = 1; } #endif @@ -395,10 +389,10 @@ void geo_process_master_list(struct GraphNodeMasterList *node) { void geo_process_ortho_projection(struct GraphNodeOrthoProjection *node) { if (node->node.children != NULL) { Mtx *mtx = alloc_display_list(sizeof(*mtx)); - f32 left = (gCurGraphNodeRoot->x - gCurGraphNodeRoot->width ) / 2.0f * node->scale; - f32 right = (gCurGraphNodeRoot->x + gCurGraphNodeRoot->width ) / 2.0f * node->scale; - f32 top = (gCurGraphNodeRoot->y - gCurGraphNodeRoot->height) / 2.0f * node->scale; - f32 bottom = (gCurGraphNodeRoot->y + gCurGraphNodeRoot->height) / 2.0f * node->scale; + f32 left = (((gCurGraphNodeRoot->x - gCurGraphNodeRoot->width ) / 2.0f) * node->scale); + f32 right = (((gCurGraphNodeRoot->x + gCurGraphNodeRoot->width ) / 2.0f) * node->scale); + f32 top = (((gCurGraphNodeRoot->y - gCurGraphNodeRoot->height) / 2.0f) * node->scale); + f32 bottom = (((gCurGraphNodeRoot->y + gCurGraphNodeRoot->height) / 2.0f) * node->scale); guOrtho(mtx, left, right, bottom, top, -2.0f, 2.0f, 1.0f); gSPPerspNormalize(gDisplayListHead++, 0xFFFF); diff --git a/src/game/segment7.h b/src/game/segment7.h index c552be2e..72dccc3d 100644 --- a/src/game/segment7.h +++ b/src/game/segment7.h @@ -5,22 +5,22 @@ #include // from main menu segment 7 -extern u8 dl_menu_idle_hand[]; -extern u8 dl_menu_grabbing_hand[]; -extern u8 menu_hud_lut[]; -extern u8 menu_font_lut[]; -extern u8 dl_menu_ia8_text_begin[]; -extern u8 dl_menu_ia8_text_end[]; -extern u8 dl_menu_rgba16_wood_course[]; +extern Gfx dl_menu_idle_hand[]; +extern Gfx dl_menu_grabbing_hand[]; +extern Texture menu_hud_lut[]; +extern Texture menu_font_lut[]; +extern Gfx dl_menu_ia8_text_begin[]; +extern Gfx dl_menu_ia8_text_end[]; +extern Gfx dl_menu_rgba16_wood_course[]; #ifdef VERSION_EU -extern u8 dl_menu_rgba16_wood_course_end[]; -extern u8 dl_menu_texture_course_upper[]; -extern u8 dl_menu_texture_niveau_upper[]; -extern u8 dl_menu_texture_kurs_upper[]; +extern Gfx dl_menu_rgba16_wood_course_end[]; +extern Gfx dl_menu_texture_course_upper[]; +extern Gfx dl_menu_texture_niveau_upper[]; +extern Gfx dl_menu_texture_kurs_upper[]; -extern const u8 eu_course_strings_en_table[]; -extern const u8 eu_course_strings_fr_table[]; -extern const u8 eu_course_strings_de_table[]; +extern const Gfx eu_course_strings_en_table[]; +extern const Gfx eu_course_strings_fr_table[]; +extern const Gfx eu_course_strings_de_table[]; #endif // from intro_segment7 diff --git a/src/game/skybox.c b/src/game/skybox.c index 7875fea7..370f60fa 100644 --- a/src/game/skybox.c +++ b/src/game/skybox.c @@ -60,7 +60,7 @@ struct Skybox { struct Skybox sSkyBoxInfo[2]; -typedef const u8 *const SkyboxTexture[80 * SKYBOX_SIZE]; +typedef const Texture *const SkyboxTexture[80 * SKYBOX_SIZE]; extern SkyboxTexture bbh_skybox_ptrlist; extern SkyboxTexture bidw_skybox_ptrlist; @@ -223,7 +223,7 @@ void draw_skybox_tile_grid(Gfx **dlist, s8 background, s8 player, s8 colorIndex) for (row = 0; row < (3 * SKYBOX_SIZE); row++) { for (col = 0; col < (3 * SKYBOX_SIZE); col++) { s32 tileIndex = sSkyBoxInfo[player].upperLeftTile + row * SKYBOX_COLS + col; - const u8 *const texture = + const Texture *const texture = (*(SkyboxTexture *) segmented_to_virtual(sSkyboxTextures[background]))[tileIndex]; Vtx *vertices = make_skybox_rect(tileIndex, colorIndex); diff --git a/src/game/sound_init.c b/src/game/sound_init.c index 36492986..d8d50d2a 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -32,7 +32,6 @@ static u16 sCurrentMusic = MUSIC_NONE; static u16 sCurrentShellMusic = MUSIC_NONE; static u16 sCurrentCapMusic = MUSIC_NONE; static u8 sPlayingInfiniteStairs = FALSE; -UNUSED static u8 unused8032C6D8[16] = { 0 }; static s16 sSoundMenuModeToSoundMode[] = { SOUND_MODE_STEREO, SOUND_MODE_MONO, SOUND_MODE_HEADSET }; // Only the 20th array element is used. static u32 sMenuSoundsExtra[] = { diff --git a/src/goddard/draw_objects.c b/src/goddard/draw_objects.c index 360f1e0f..9ec05102 100644 --- a/src/goddard/draw_objects.c +++ b/src/goddard/draw_objects.c @@ -46,25 +46,24 @@ struct BetaVtx { }; // data -static struct GdColour sClrWhite = { 1.0, 1.0, 1.0 }; // @ 801A8070 -static struct GdColour sClrRed = { 1.0, 0.0, 0.0 }; // @ 801A807C -static struct GdColour sClrGreen = { 0.0, 1.0, 0.0 }; // @ 801A8088 -static struct GdColour sClrBlue = { 0.0, 0.0, 1.0 }; // @ 801A8094 -static struct GdColour sClrErrDarkBlue = { 0.0, 0.0, 6.0 }; // @ 801A80A0 -static struct GdColour sClrPink = { 1.0, 0.0, 1.0 }; // @ 801A80AC -static struct GdColour sClrBlack = { 0.0, 0.0, 0.0 }; // @ 801A80B8 -static struct GdColour sClrGrey = { 0.6, 0.6, 0.6 }; // @ 801A80C4 -static struct GdColour sClrDarkGrey = { 0.4, 0.4, 0.4 }; // @ 801A80D0 -static struct GdColour sClrYellow = { 1.0, 1.0, 0.0 }; // @ 801A80DC -static struct GdColour sLightColours[1] = { { 1.0, 1.0, 0.0 } }; // @ 801A80E8 -static struct GdColour *sSelectedColour = &sClrRed; // @ 801A80F4 -struct ObjCamera *gViewUpdateCamera = NULL; // @ 801A80F8 -static s32 sUnreadShapeFlag = 0; // @ 801A8100 -struct GdColour *sColourPalette[5] = { // @ 801A8104 +static struct GdColour sClrWhite = { 1.0f, 1.0f, 1.0f }; +static struct GdColour sClrRed = { 1.0f, 0.0f, 0.0f }; +static struct GdColour sClrGreen = { 0.0f, 1.0f, 0.0f }; +static struct GdColour sClrBlue = { 0.0f, 0.0f, 1.0f }; +static struct GdColour sClrErrDarkBlue = { 0.0f, 0.0f, 6.0f }; +static struct GdColour sClrPink = { 1.0f, 0.0f, 1.0f }; +static struct GdColour sClrBlack = { 0.0f, 0.0f, 0.0f }; +static struct GdColour sClrGrey = { 0.6f, 0.6f, 0.6f }; +static struct GdColour sClrDarkGrey = { 0.4f, 0.4f, 0.4f }; +static struct GdColour sClrYellow = { 1.0f, 1.0f, 0.0f }; +static struct GdColour sLightColours = { 1.0f, 1.0f, 0.0f }; +static struct GdColour *sSelectedColour = &sClrRed; +struct ObjCamera *gViewUpdateCamera = NULL; +static s32 sUnreadShapeFlag = 0; +struct GdColour *sColourPalette[5] = { &sClrWhite, &sClrYellow, &sClrRed, &sClrBlack, &sClrBlack }; struct GdColour *sWhiteBlack[2] = { - //@ 801A8118 &sClrWhite, &sClrBlack, }; @@ -260,9 +259,9 @@ void draw_light(struct ObjLight *light) { return; } - sLightColours[0].r = light->colour.r; - sLightColours[0].g = light->colour.g; - sLightColours[0].b = light->colour.b; + sLightColours.r = light->colour.r; + sLightColours.g = light->colour.g; + sLightColours.b = light->colour.b; if (light->flags & LIGHT_UNK02) { gd_set_identity_mat4(&sp54); @@ -386,7 +385,7 @@ struct GdColour *gd_get_colour(s32 idx) { return &sClrPink; break; case -1: - return &sLightColours[0]; + return &sLightColours; break; default: return NULL; @@ -834,14 +833,14 @@ void draw_particle(struct GdObj *obj) { white = sColourPalette[0]; black = sWhiteBlack[1]; brightness = ptc->timeout / 10.0; - sLightColours[0].r = (white->r - black->r) * brightness + black->r; - sLightColours[0].g = (white->g - black->g) * brightness + black->g; - sLightColours[0].b = (white->b - black->b) * brightness + black->b; + sLightColours.r = (white->r - black->r) * brightness + black->r; + sLightColours.g = (white->g - black->g) * brightness + black->g; + sLightColours.b = (white->b - black->b) * brightness + black->b; ; // needed to match } else { - sLightColours[0].r = 0.0f; - sLightColours[0].g = 0.0f; - sLightColours[0].b = 0.0f; + sLightColours.r = 0.0f; + sLightColours.g = 0.0f; + sLightColours.b = 0.0f; } if (ptc->timeout > 0) { diff --git a/src/menu/intro_geo.c b/src/menu/intro_geo.c index 934e89b3..7d2f463d 100644 --- a/src/menu/intro_geo.c +++ b/src/menu/intro_geo.c @@ -145,12 +145,12 @@ static Gfx *intro_backdrop_one_image(s32 index, s8 *backgroundTable) { }; // table that points to either the "Super Mario 64" or "Game Over" tables - static const u8 *const *textureTables[] = { mario_title_texture_table, game_over_texture_table }; + static const Texture *const *textureTables[] = { mario_title_texture_table, game_over_texture_table }; Mtx *mtx = alloc_display_list(sizeof(*mtx)); Gfx *displayList = alloc_display_list(36 * sizeof(*displayList)); Gfx *displayListIter = displayList; - const u8 *const *vIntroBgTable = segmented_to_virtual(textureTables[backgroundTable[index]]); + const Texture *const *vIntroBgTable = segmented_to_virtual(textureTables[backgroundTable[index]]); s32 i; guTranslate(mtx, xCoords[index], yCoords[index], 0.0f); diff --git a/tools/skyconv.c b/tools/skyconv.c index f04ffcff..48b1d8db 100644 --- a/tools/skyconv.c +++ b/tools/skyconv.c @@ -357,7 +357,7 @@ static void write_cake_c() { fputs("};\n\n", cFile); } } else { - fprintf(cFile, "ALIGNED8 static const u8 cake_end_texture_data[] = {\n"); + fprintf(cFile, "ALIGNED8 static const Texture cake_end_texture_data[] = {\n"); for (int i = 0; i < numTiles; ++i) { print_raw_data(cFile, &tiles[i]); fputc(',', cFile);