Merge branch 'master' into si

This commit is contained in:
Ethan Roseman 2020-08-14 22:50:30 -04:00
commit a414ce047b
17 changed files with 3061 additions and 933 deletions

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "n64splitter"]
path = tools/n64splitter
url = https://github.com/ethteck/sm64tools.git
[submodule "tools/star-rod"]
path = tools/star-rod
url = https://github.com/nanaian/star-rod.git

View File

@ -9,6 +9,7 @@ BUILD_DIR = build
SRC_DIRS := src src/os
ASM_DIRS := asm asm/os
INCLUDE_DIRS := include include/PR
DATA_DIRS := bin
COMPRESSED_DIRS := yay0
MAP_DIRS := Map_Assets.FS
@ -17,6 +18,9 @@ BGM_DIRS := bgm
# Source code files
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
ifdef PM_HEADER_REBUILD
H_FILES := $(foreach dir,$(INCLUDE_DIRS),$(wildcard $(dir)/*.h))
endif
DATA_FILES := $(foreach dir,$(DATA_DIRS),$(wildcard $(dir)/*.bin))
COMPRESSED_FILES := $(foreach dir,$(COMPRESSED_DIRS),$(wildcard $(dir)/*.yay0))
MAP_FILES := $(foreach dir,$(MAP_DIRS),$(wildcard $(dir)/*.FS))
@ -91,7 +95,7 @@ $(BUILD_DIR)/$(TARGET).elf: $(O_FILES) $(LD_SCRIPT)
$(BUILD_DIR)/%.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.c
$(BUILD_DIR)/%.o: %.c $(H_FILES)
cpp $(CPPFLAGS) $< | $(CC) $(CFLAGS) -o - | $(OLD_AS) $(OLDASFLAGS) - -o $@
$(BUILD_DIR)/%.o: %.bin

View File

@ -30,6 +30,7 @@ run `make setup` to set up tools and extract the rom
### Make
run `make` to rebuild the rom. Get `OK`? If so, you're all set! Otherwise, please feel free to reach out to us in the discord.
Use `PM_HEADER_REBUILD=1 make` to rebuild C sources when any header files change.
## FAQ
* If you received the following error when running `make setup`:

View File

@ -7,6 +7,6 @@
#include "functions.h"
#include "variables.h"
#include "macros.h"
#include "items.h"
#include "enums.h"
#endif

File diff suppressed because it is too large Load Diff

1431
include/enums.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,367 +0,0 @@
#ifndef _ITEMS_H_
#define _ITEMS_H_
#include "ultra64.h"
#include "types.h"
typedef enum eItem {
JUMP = 0x0001,
SPIN_JUMP = 0x0002,
TORNADO_JUMP = 0x0003,
HAMMER = 0x0004,
SUPER_HAMMER = 0x0005,
ULTRA_HAMMER = 0x0006,
LUCKY_STAR = 0x0007,
MAP = 0x0008, // unused
BIG_MAP = 0x0009, // unused
FIRST_DEGREE_CARD = 0x000A,
SECOND_DEGREE_CARD = 0x000B,
THIRD_DEGREE_CARD = 0x000C,
FOURTH_DEGREE_CARD = 0x000D,
DIPLOMA = 0x000E,
ULTRA_STONE = 0x000F,
FORTRESS_KEY = 0x0010,
RUINS_KEY = 0x0011,
PULSE_STONE = 0x0012,
CASTLE_KEY1 = 0x0013,
PALACE_KEY = 0x0014,
LUNAR_STONE = 0x0015,
PYRAMID_STONE = 0x0016,
DIAMOND_STONE = 0x0017,
GOLDEN_VASE = 0x0018, // unused
KOOPERS_SHELL = 0x0019,
CASTLE_KEY2 = 0x001A,
FOREST_PASS = 0x001B, // unused
WEIGHT = 0x001C,
BOOS_PORTRAIT = 0x001D,
CRYSTAL_BERRY = 0x001E,
MYSTICAL_KEY = 0x001F,
STOREROOM_KEY = 0x0020,
TOY_TRAIN = 0x0021,
RECORD = 0x0022,
FRYING_PAN = 0x0023,
DICTIONARY = 0x0024,
MYSTERY_NOTE = 0x0025,
SUSPICIOUS_NOTE = 0x0026, // unused
CRYSTAL_BALL = 0x0027,
SCREWDRIVER = 0x0028, // unused
COOKBOOK = 0x0029,
JADE_RAVEN = 0x002A,
MAGICAL_SEED1 = 0x002B,
MAGICAL_SEED2 = 0x002C,
MAGICAL_SEED3 = 0x002D,
MAGICAL_SEED4 = 0x002E,
TOAD_DOLL = 0x002F, // unused
CALCULATOR = 0x0030,
BUCKET = 0x0031,
SCARF = 0x0032,
RED_KEY = 0x0033,
BLUE_KEY = 0x0034,
LETTER01 = 0x0036,
LETTER02 = 0x0037,
LETTER03 = 0x0038,
LETTER04 = 0x0039,
LETTER05 = 0x003A,
LETTER06 = 0x003B,
LETTER07 = 0x003C,
LETTER08 = 0x003D,
LETTER09 = 0x003E,
LETTER10 = 0x0040,
LETTER11 = 0x0041,
LETTER12 = 0x0045,
LETTER13 = 0x0046,
LETTER14 = 0x0047,
LETTER15 = 0x0048,
LETTER16 = 0x0049,
LETTER17 = 0x004A,
LETTER18 = 0x004B,
LETTER19 = 0x004C,
LETTER20 = 0x004E,
LETTER21 = 0x004F,
LETTER22 = 0x0050,
LETTER23 = 0x0051,
LETTER24 = 0x0052,
ARTIFACT = 0x0053,
LETTER25 = 0x0054,
DOLLY = 0x0056,
WATER_STONE = 0x0057,
MAGICAL_BEAN = 0x0058,
FERTILE_SOIL = 0x0059,
MIRACLE_WATER = 0x005A,
VOLCANO_VASE = 0x005B,
TAPE = 0x005C,
SUGAR = 0x005D,
SALT = 0x005E,
EGG1 = 0x005F,
CREAM = 0x0060,
STRAWBERRY = 0x0061,
BUTTER = 0x0062,
CLEANSER = 0x0063,
WATER = 0x0064,
FLOUR = 0x0065,
MILK = 0x0066,
LYRICS = 0x0067,
MELODY = 0x0068,
MAILBAG = 0x0069,
CASTLE_KEY3 = 0x006A,
ODD_KEY = 0x006B,
STAR_STONE = 0x006C,
SNEAKY_PARASOL = 0x006D,
KOOPA_LEGENDS = 0x006E,
AUTOGRAPH1 = 0x006F,
EMPTY_WALLET = 0x0070,
AUTOGRAPH2 = 0x0071,
KOOPA_SHELL = 0x0072, // unused
OLD_PHOTO = 0x0073,
GLASSES = 0x0074,
PHOTOGRAPH = 0x0075, // unused
PACKAGE = 0x0076,
RED_JAR = 0x0077,
CASTLE_KEY4 = 0x0078,
WAREHOUSE_KEY = 0x0079,
PRISON_KEY1 = 0x007A,
SILVER_CREDIT = 0x007B,
GOLD_CREDIT = 0x007C,
PRISON_KEY2 = 0x007D, // unused
PRISON_KEY3 = 0x007E, // unused
PRISON_KEY4 = 0x007F, // unused
FIRE_FLOWER = 0x0080,
SNOWMAN_DOLL = 0x0081,
THUNDER_RAGE = 0x0082,
SHOOTING_STAR = 0x0083,
THUNDER_BOLT = 0x0084,
PEBBLE = 0x0085,
DUSTY_HAMMER = 0x0086,
INSECTICIDE_HERB = 0x0087,
STONE_CAP = 0x0088,
TASTY_TONIC = 0x0089,
MUSHROOM = 0x008A,
VOLT_SHROOM = 0x008B,
SUPER_SHROOM = 0x008C,
DRIED_SHROOM = 0x008D,
ULTRA_SHROOM = 0x008E,
SLEEPY_SHEEP = 0x008F,
POW_BLOCK = 0x0090,
HUSTLE_DRINK = 0x0091,
STOP_WATCH = 0x0092,
WHACKAS_BUMP = 0x0093,
APPLE = 0x0094,
LIFE_SHROOM = 0x0095,
MYSTERY = 0x0096,
REPEL_GEL = 0x0097,
FRIGHT_JAR = 0x0098,
PLEASE_COME_BACK = 0x0099,
DIZZY_DIAL = 0x009A,
SUPER_SODA = 0x009B,
LEMON = 0x009C,
LIME = 0x009D,
BLUE_BERRY = 0x009E,
RED_BERRY = 0x009F,
YELLOW_BERRY = 0x00A0,
BUBBLE_BERRY = 0x00A1,
JAMMIN_JELLY = 0x00A2,
MAPLE_SYRUP = 0x00A3,
HONEY_SYRUP = 0x00A4,
GOOMNUT = 0x00A5,
KOOPA_LEAF = 0x00A6,
DRIED_PASTA = 0x00A7,
DRIED_FRUIT = 0x00A8,
STRANGE_LEAF = 0x00A9,
CAKE_MIX = 0x00AA,
EGG2 = 0x00AB,
COCONUT = 0x00AC,
MELON = 0x00AD,
STINKY_HERB = 0x00AE,
ICED_POTATO = 0x00AF,
SPICY_SOUP = 0x00B0,
APPLE_PIE = 0x00B1,
HONEY_ULTRA = 0x00B2,
MAPLE_ULTRA = 0x00B3,
JELLY_ULTRA = 0x00B4,
KOOPASTA = 0x00B5,
FRIED_SHROOM = 0x00B6,
SHROOM_CAKE = 0x00B7,
SHROOM_STEAK = 0x00B8,
HOT_SHROOM = 0x00B9,
SWEET_SHROOM = 0x00BA,
YUMMY_MEAL = 0x00BB,
HEALTHY_JUICE = 0x00BC,
BLAND_MEAL = 0x00BD,
DELUXE_FEAST = 0x00BE,
SPECIAL_SHAKE = 0x00BF,
BIG_COOKIE = 0x00C0,
CAKE = 0x00C1,
MISTAKE = 0x00C2,
KOOPA_TEA = 0x00C3,
HONEY_SUPER = 0x00C4,
MAPLE_SUPER = 0x00C5,
JELLY_SUPER = 0x00C6,
SPAGHETTI = 0x00C7,
EGG_MISSILE = 0x00C8,
FRIED_EGG = 0x00C9,
HONEY_SHROOM = 0x00CA,
HONEY_CANDY = 0x00CB,
ELECTRO_POP = 0x00CC,
FIRE_POP = 0x00CD,
LIME_CANDY = 0x00CE,
COCO_POP = 0x00CF,
LEMON_CANDY = 0x00D0,
JELLY_POP = 0x00D1,
STRANGE_CAKE = 0x00D2,
KOOKY_COOKIE = 0x00D3,
FROZEN_FRIES = 0x00D4,
POTATO_SALAD = 0x00D5,
NUTTY_CAKE = 0x00D6,
MAPLE_SHROOM = 0x00D7,
BOILED_EGG = 0x00D8,
YOSHI_COOKIE = 0x00D9,
JELLY_SHROOM1 = 0x00DA,
JELLY_SHROOM2 = 0x00DB,
JELLY_SHROOM3 = 0x00DC,
JELLY_SHROOM4 = 0x00DD,
JELLY_SHROOM5 = 0x00DE,
JELLY_SHROOM6 = 0x00DF,
SPIN_SMASH = 0x00E0,
MULTIBOUNCE = 0x00E1,
POWER_PLUS_A = 0x00E2,
DODGE_MASTER = 0x00E3,
POWER_BOUNCE = 0x00E4,
SPIKE_SHIELD = 0x00E5,
FIRST_ATTACK = 0x00E6,
HP_PLUS_A = 0x00E7,
QUAKE_HAMMER = 0x00E8,
DOUBLE_DIP = 0x00E9,
MYSTERY_SCROLL = 0x00EA, // unused
SLEEP_STOMP = 0x00EB,
FIRE_SHIELD = 0x00EC,
QUICK_CHANGE = 0x00ED,
D_DOWN_POUND = 0x00EE,
DIZZY_STOMP = 0x00EF,
SMASH_CHARGE0 = 0x00F0, // unused
PRETTY_LUCKY = 0x00F1,
FEELING_FINE = 0x00F2,
ATTACK_FX_A = 0x00F3,
ALLOR_NOTHING = 0x00F4,
HP_DRAIN = 0x00F5,
JUMP_CHARGE0 = 0x00F6, // unused
SLOW_GO = 0x00F7,
FP_PLUS_A = 0x00F8,
MEGA_RUSH = 0x00F9,
ICE_POWER = 0x00FA,
DEFEND_PLUS_A = 0x00FB,
PAY_OFF = 0x00FC,
MONEY_MONEY = 0x00FD,
CHILL_OUT = 0x00FE,
HAPPY_HEART_A = 0x00FF,
ZAP_TAP = 0x0100,
BERSERKER = 0x0101, // unused
RIGHT_ON = 0x0102, // unused
RUNAWAY_PAY = 0x0103,
REFUND = 0x0104,
FLOWER_SAVER_A = 0x0105,
TRIPLE_DIP = 0x0106,
HAMMER_THROW = 0x0107,
MEGA_QUAKE = 0x0108,
SMASH_CHARGE = 0x0109,
JUMP_CHARGE = 0x010A,
S_SMASH_CHG = 0x010B,
S_JUMP_CHG = 0x010C,
POWER_RUSH = 0x010D,
AUTO_JUMP = 0x010E, // unused
AUTO_SMASH = 0x010F, // unused
CRAZY_HEART = 0x0110, // unused
LAST_STAND = 0x0111,
CLOSE_CALL = 0x0112,
P_UP_D_DOWN = 0x0113,
LUCKY_DAY = 0x0114,
MEGA_HP_DRAIN = 0x0115, // unused
P_DOWN_D_UP = 0x0116,
POWER_QUAKE = 0x0117,
AUTO_MULTIBOUNCE = 0x0118, // unused
FLOWER_FANATIC = 0x0119, // unused
HEART_FINDER = 0x011A,
FLOWER_FINDER = 0x011B,
SPIN_ATTACK = 0x011C,
DIZZY_ATTACK = 0x011D,
I_SPY = 0x011E,
SPEEDY_SPIN = 0x011F,
BUMP_ATTACK = 0x0120,
POWER_JUMP = 0x0121,
SUPER_JUMP = 0x0122, // unused
MEGA_JUMP = 0x0123,
POWER_SMASH1 = 0x0124,
SUPER_SMASH = 0x0125, // unused
MEGA_SMASH = 0x0126,
POWER_SMASH2 = 0x0127,
POWER_SMASH3 = 0x0128,
DEEP_FOCUS1 = 0x0129,
SUPER_FOCUS = 0x012A, // unused
SHRINK_SMASH = 0x012B,
SHELL_CRACK = 0x012C, // unused
KAIDEN = 0x012D, // unused
D_DOWN_JUMP = 0x012E,
SHRINK_STOMP = 0x012F,
DAMAGE_DODGE_A = 0x0130,
EARTHQUAKE_JUMP = 0x0131,
DEEP_FOCUS2 = 0x0132,
DEEP_FOCUS3 = 0x0133,
HP_PLUS_B = 0x0134,
FP_PLUS_B = 0x0135,
HAPPY_HEART_B = 0x0136,
HAPPY_HEART_X = 0x0137,
FLOWER_SAVER_B = 0x0138,
FLOWER_SAVER_X = 0x0139,
DAMAGE_DODGE_B = 0x013A,
DAMAGE_DODGE_X = 0x013B,
POWER_PLUS_B = 0x013C,
POWER_PLUS_X = 0x013D,
DEFEND_PLUS_X = 0x013E,
DEFEND_PLUS_Y = 0x013F,
HAPPY_FLOWER_A = 0x0140,
HAPPY_FLOWER_B = 0x0141,
HAPPY_FLOWER_X = 0x0142,
GROUP_FOCUS = 0x0143,
PEEKABOO = 0x0144,
ATTACK_FX_D = 0x0145,
ATTACK_FX_B = 0x0146,
ATTACK_FX_E = 0x0147,
ATTACK_FX_C = 0x0148,
ATTACK_FX_F = 0x0149,
HP_PLUS_C = 0x014A,
HP_PLUS_X = 0x014B,
HP_PLUS_Y = 0x014C,
FP_PLUS_C = 0x014D,
FP_PLUS_X = 0x014E,
FP_PLUS_Y = 0x014F,
HEALTHY_HEALTHY = 0x0150,
ATTACK_FX_F2 = 0x0151,
ATTACK_FX_F3 = 0x0152,
ATTACK_FX_F4 = 0x0153,
ATTACK_FX_F5 = 0x0154,
PARTNER_ATTACK = 0x0155, // placeholder with partner attack icon
HEART = 0x0156,
COIN = 0x0157,
HEART_PIECE = 0x0158, // unused, NOT functional
STAR_POINT = 0x0159, // unused, functional, makes coin sound
FULL_HEAL = 0x015A, // unused, functional, item inside healing block
FLOWER = 0x015B,
STAR_PIECE = 0x015C,
PRESENT = 0x015D,
COMPLETE_CAKE = 0x015E,
BARE_CAKE = 0x015F,
EMPTY_CAKE_PAN = 0x0160,
FULL_CAKE_PAN = 0x0161,
EMPTY_MIXING_BOWL = 0x0162,
FULL_MIXING_BOWL = 0x0163,
CAKE_WITH_ICING = 0x0164,
CAKE_WITH_BERRIES = 0x0165,
HAMMER1_ICON = 0x0166,
HAMMER2_ICON = 0x0167,
HAMMER3_ICON = 0x0168,
BOOTS1_ICON = 0x0169,
BOOTS2_ICON = 0x016A,
BOOTS3_ICON = 0x016B,
ITEMS_ICON = 0x016C
} eItem;
#endif

View File

@ -8,4 +8,6 @@
#define UNK_FUN_PTR(name) void(*name)(void)
#define UNK_ARGS
typedef s32* bytecode;
#endif

View File

@ -56,7 +56,7 @@ INCLUDE_ASM(code_6000, collision_heap_malloc);
INCLUDE_ASM(code_6000, collision_heap_free);
/*s32 collision_heap_free(s32 size) {
s32 unk_70 = (*gGameStatusPtr)->unk_70;
s32 isBattle = (*gGameStatusPtr)->isBattle;
return _heap_free((unk_70 == 0) ? (&D_80268000) : (&D_803DA800), size);
return _heap_free((isBattle == 0) ? (&D_80268000) : (&D_803DA800), size);
}*/

View File

@ -31,15 +31,15 @@ void clear_player_data(void) {
playerData->merleeTurnCount = -1;
playerData->maxStarPower = 0;
playerData->specialBarsFilled = 0;
playerData->unk_292 = 0;
playerData->unk_292[0] = 0;
playerData->currentPartner = 0;
for (i = 0; i < ARRAY_COUNT(playerData->partners); i++) {
playerData->partners[i].enabled = 0;
playerData->partners[i].level = 0;
playerData->partners[i].unk_2 = 0;
playerData->partners[i].unk_4 = 0;
playerData->partners[i].unk_6 = 0;
playerData->partners[i].unk_02[0] = 0;
playerData->partners[i].unk_02[1] = 0;
playerData->partners[i].unk_02[2] = 0;
}
for (i = ARRAY_COUNT(playerData->keyItems) - 1; i >= 0; i--) {
@ -70,10 +70,10 @@ void clear_player_data(void) {
playerData->enemyFirstStrikes = 0;
playerData->powerBounces = 0;
playerData->battlesCount = 0;
playerData->unk_2A4 = 0;
playerData->unk_2A6 = 0;
playerData->unk_2A8 = 0;
playerData->unk_2AA = 0;
playerData->unk_2A4[0] = 0;
playerData->unk_2A4[1] = 0;
playerData->unk_2A4[2] = 0;
playerData->unk_2A4[3] = 0;
playerData->unk_2AC = 0;
playerData->unk_2B0 = 0;
playerData->idleFrameCounter = 0;
@ -304,9 +304,9 @@ void update_coin_counter(void) {
do {} while(0); // Needed to match
if (uiStatus->unk_6D != 0) {
uiStatus->unk_6D -= 1;
if (((uiStatus->unk_6D << 24) == 0) && (uiStatus->iconIndex12 >= 0)) {
if (uiStatus->unk_6C[1] != 0) {
uiStatus->unk_6C[1] -= 1;
if (((uiStatus->unk_6C[1] << 24) == 0) && (uiStatus->iconIndex12 >= 0)) {
free_icon(uiStatus->iconIndex12);
free_icon(uiStatus->iconIndex13);
uiStatus->iconIndex12 = -1;
@ -314,24 +314,24 @@ void update_coin_counter(void) {
D_8010CD12 = 0;
}
if (uiStatus->unk_6C != 0) {
if ((uiStatus->displayCoins == playerData->coins) && (uiStatus->unk_6C > 30)) {
uiStatus->unk_6C = 30;
if (uiStatus->unk_6C[0] != 0) {
if ((uiStatus->displayCoins == playerData->coins) && (uiStatus->unk_6C[0] > 30)) {
uiStatus->unk_6C[0] = 30;
}
if ((uiStatus->displayCoins == playerData->coins) || (uiStatus->unk_6C <= 30)) {
uiStatus->unk_6C -= 1;
if (uiStatus->unk_6C == 0) {
if ((uiStatus->displayCoins == playerData->coins) || (uiStatus->unk_6C[0] <= 30)) {
uiStatus->unk_6C[0] -= 1;
if (uiStatus->unk_6C[0] == 0) {
func_80147E7C(20, &D_80147574);
uiStatus->unk_6D = 15;
uiStatus->unk_6C[1] = 15;
D_8010CD10 = 0;
D_8010CD12 = 1;
uiStatus->iconIndex12 = uiStatus->iconIndex10;
uiStatus->iconIndex13 = uiStatus->iconIndex11;
uiStatus->displayCoins = playerData->coins;
if (uiStatus->unk_6E > -1) {
uiStatus->ignoreChanges = uiStatus->unk_6E;
uiStatus->unk_6E = -1;
if (uiStatus->unk_6C[2] > -1) {
uiStatus->ignoreChanges = uiStatus->unk_6C[2];
uiStatus->unk_6C[2] = -1;
}
}
}
@ -350,13 +350,13 @@ void show_coin_counter(void) {
free_icon(uiStatus->iconIndex11);
uiStatus->iconIndex12 = -1;
}
uiStatus->unk_6C = 0;
uiStatus->unk_6D = 0;
uiStatus->unk_6C[0] = 0;
uiStatus->unk_6C[1] = 0;
*coinCounterUnk = 0;
D_8010CD12 = 0;
}
if (uiStatus->unk_6C == 0) {
if (uiStatus->unk_6C[0]== 0) {
func_80147CC8(0x14, 0x20, 0xa4, 0x40, 0x14, 0x15, &D_800E92D8, 0, -1);
func_80147E7C(0x14, &D_80147474);
index = create_icon(&D_80109270);
@ -367,10 +367,10 @@ void show_coin_counter(void) {
uiStatus->iconIndex11 = index;
set_icon_flags(index, 0x80);
func_80144EFC(index, 0xff, 0xff, 0xff);
uiStatus->unk_6C = 0;
uiStatus->unk_6C[0] = 0;
if (uiStatus->unk_6E < 0) {
uiStatus->unk_6E = uiStatus->ignoreChanges;
if (uiStatus->unk_6C[2] < 0) {
uiStatus->unk_6C[2] = uiStatus->ignoreChanges;
}
uiStatus->ignoreChanges = 1;
@ -382,16 +382,16 @@ void show_coin_counter(void) {
void hide_coin_counter(void) {
ui_status* uiStatus = &gUIStatus;
if ((D_8010CD10 != 0) && (uiStatus->unk_6C == 0)) {
uiStatus->unk_6C = 60;
if ((D_8010CD10 != 0) && (uiStatus->unk_6C[0]== 0)) {
uiStatus->unk_6C[0] = 60;
}
}
void func_800E96C8(void) {
ui_status* uiStatus = &gUIStatus;
if ((D_8010CD10 != 0) && (uiStatus->unk_6C == 0)) {
uiStatus->unk_6C = 1;
if ((D_8010CD10 != 0) && (uiStatus->unk_6C[0]== 0)) {
uiStatus->unk_6C[0]= 1;
}
}
@ -415,7 +415,7 @@ void open_status_menu_long(void) {
if (uiStatus->hidden) {
uiStatus->showTimer = 210;
uiStatus->hidden = 0;
uiStatus->unk_3B = 1;
uiStatus->unk_3B[0] = 1;
}
}
@ -425,7 +425,7 @@ void open_status_menu_short(void) {
if (uiStatus->hidden) {
uiStatus->showTimer = 105;
uiStatus->hidden = 0;
uiStatus->unk_3B = 1;
uiStatus->unk_3B[0] = 1;
}
}
@ -435,7 +435,7 @@ void func_800E97B8(void) {
if (uiStatus->hidden != 1) {
uiStatus->hidden = 1;
uiStatus->showTimer = 0;
uiStatus->unk_3B = 1;
uiStatus->unk_3B[0] = 1;
}
}
@ -446,8 +446,8 @@ void func_800E97E4(void) {
uiStatus->ignoreChanges = 0;
uiStatus->showTimer = 0;
uiStatus->hidden = 1;
uiStatus->unk_3B = 0;
uiStatus->unk_3C = 0;
uiStatus->unk_3B[0] = 0;
uiStatus->unk_3B[1] = 0;
}
void func_800E9810(void) {
@ -457,24 +457,24 @@ void func_800E9810(void) {
uiStatus->drawPosY = 0;
uiStatus->ignoreChanges = 0;
uiStatus->hidden = 0;
uiStatus->unk_3B = 1;
uiStatus->unk_3C = 0;
uiStatus->unk_3B[0] = 1;
uiStatus->unk_3B[1] = 0;
}
void func_800E983C(void) {
gUIStatus.unk_45 = 0;
gUIStatus.unk_45[0] = 0;
}
void func_800E984C(void) {
gUIStatus.unk_45 = 1;
gUIStatus.unk_45[0] = 1;
}
s32 func_800E9860(void) {
ui_status* uiStatus = &gUIStatus;
ui_status* uiStatus2 = &gUIStatus;
s32 ret = 1 - uiStatus->unk_45;
s32 ret = 1 - uiStatus->unk_45[0];
if (uiStatus->unk_46 != 0) {
if (uiStatus->unk_45[1] != 0) {
ret = 0;
}
if (uiStatus2->ignoreChanges) {
@ -501,15 +501,15 @@ void status_menu_disable_ignore_changes(void) {
s32 func_800E98D4(void) {
ui_status* uiStatus = &gUIStatus;
return uiStatus->unk_46 + uiStatus->ignoreChanges;
return uiStatus->unk_45[1] + uiStatus->ignoreChanges;
}
void func_800E98EC(void) {
gUIStatus.unk_46 = 1;
gUIStatus.unk_45[1] = 1;
}
void func_800E9900(void) {
gUIStatus.unk_46 = 0;
gUIStatus.unk_45[1] = 0;
}
s32 is_status_menu_visible(void) {
@ -672,10 +672,10 @@ void reset_status_menu(void) {
uiStatus->drawPosY = -100;
uiStatus->hidden = 0;
uiStatus->showTimer = 210;
uiStatus->unk_3B = 0;
uiStatus->unk_3B[0] = 0;
uiStatus->ignoreChanges = 0;
uiStatus->unk_45 = 0;
uiStatus->unk_46 = 0;
uiStatus->unk_45[0] = 0;
uiStatus->unk_45[1] = 0;
uiStatus->hpBlinking = 0;
uiStatus->hpBlinkCounter = 0;
uiStatus->hpBlinkTimer = 0;
@ -690,13 +690,13 @@ void reset_status_menu(void) {
uiStatus->disabled = 0;
uiStatus->starpointsBlinking = 0;
uiStatus->starpointsBlinkCounter = 0;
uiStatus->unk_6E = -1;
uiStatus->unk_6C[2] = -1;
uiStatus->displayHP = playerData->curHP;
uiStatus->displayFP = playerData->curFP;
uiStatus->displayCoins = playerData->coins;
uiStatus->displayStarpoints = playerData->starPoints;
uiStatus->displaySP = playerData->specialBarsFilled;
uiStatus->unk_3C = 0;
uiStatus->unk_3B[1] = 0;
for (i = 0; i < 2; i++) {
func_801452B4(uiStatus->hpIconIndexes[i], uiStatus->hpIconIndexes[i]);
@ -807,14 +807,14 @@ void add_SP(s32 amt) {
s32 phi_v1;
s32 blah;
uiStatus->unk_57 = 1;
uiStatus->unk_58 = 60;
uiStatus->unk_57[0] = 1;
uiStatus->unk_57[1] = 60;
phi_v1 = playerData->specialBarsFilled;
if (phi_v1 < 0) {
phi_v1 = playerData->specialBarsFilled + 31;
}
uiStatus->unk_59 = phi_v1 >> 5;
uiStatus->unk_57[2] = phi_v1 >> 5;
playerData->specialBarsFilled += amt;

View File

@ -28,7 +28,7 @@ void func_80145DF8(void) {
D_8014F12F = 0;
gameStatus->unk_15C = 0xB4;
gameStatus->backgroundFlags &= 0xF0;
gameStatus->enableBackground &= 0xF0;
}
void read_background_size(bg_header *bg) {
@ -40,13 +40,13 @@ void read_background_size(bg_header *bg) {
gameStatus->backgroundMinH = bg->startY;
gameStatus->backgroundRaster = bg->raster;
gameStatus->backgroundPalette = bg->palette;
gameStatus->backgroundFlags |= 1;
gameStatus->enableBackground |= 1;
}
void set_background_size(s16 startX, s16 startY, s16 sizeX, s16 sizeY) {
game_status* gameStatus = *gGameStatusPtr;
gameStatus->backgroundFlags &= ~1;
gameStatus->enableBackground &= ~1;
gameStatus->backgroundMaxW = startX;
gameStatus->backgroundMaxH = startY;
gameStatus->backgroundMinW = sizeX;

View File

@ -3,24 +3,24 @@
void func_800337D0(s16 new_alpha) {
game_status* gameStatus = *gGameStatusPtr;
gameStatus->boot_alpha = new_alpha;
gameStatus->bootAlpha = new_alpha;
}
void func_800337E0(s16 arg0) {
game_status* gameStatus = *gGameStatusPtr;
gameStatus->boot_red = arg0;
gameStatus->boot_green = arg0;
gameStatus->boot_blue = arg0;
gameStatus->bootRed = arg0;
gameStatus->bootGreen = arg0;
gameStatus->bootBlue = arg0;
}
s16 func_800337F8(subtract_val) {
game_status* gameStatus = *gGameStatusPtr;
if (gameStatus->boot_alpha != 0) {
gameStatus->boot_alpha -= subtract_val;
if (gameStatus->boot_alpha << 16 < 0) {
gameStatus->boot_alpha = 0;
if (gameStatus->bootAlpha != 0) {
gameStatus->bootAlpha -= subtract_val;
if (gameStatus->bootAlpha << 16 < 0) {
gameStatus->bootAlpha = 0;
}
} else {
return 1;
@ -31,10 +31,10 @@ s16 func_800337F8(subtract_val) {
s16 func_80033830(add_val) {
game_status* gameStatus = *gGameStatusPtr;
if (gameStatus->boot_alpha != 0xFF) {
gameStatus->boot_alpha += add_val;
if ((gameStatus->boot_alpha > 0xFF)) {
gameStatus->boot_alpha = 0xFF;
if (gameStatus->bootAlpha != 0xFF) {
gameStatus->bootAlpha += add_val;
if ((gameStatus->bootAlpha > 0xFF)) {
gameStatus->bootAlpha = 0xFF;
}
} else {
return 1;
@ -44,8 +44,8 @@ s16 func_80033830(add_val) {
void func_80033874(void) {
func_80137D88(0, (*gGameStatusPtr)->boot_alpha);
func_80137E10(0, (*gGameStatusPtr)->boot_blue, (*gGameStatusPtr)->boot_green, (*gGameStatusPtr)->boot_red);
func_80137D88(0, (*gGameStatusPtr)->bootAlpha);
func_80137E10(0, (*gGameStatusPtr)->bootBlue, (*gGameStatusPtr)->bootGreen, (*gGameStatusPtr)->bootRed);
}
void start_battle_countdown(void) {

View File

@ -114,7 +114,7 @@ s32 AddKeyItem(script_context* script, s32 initialCall) {
s32 itemID = get_variable(script, value);
s32 i;
if (itemID == FORTRESS_KEY) {
if (itemID == ITEM_FORTRESS_KEY) {
playerData->fortressKeyCount++;
return 2;
}

1
tools/star-rod Submodule

@ -0,0 +1 @@
Subproject commit 3a32d3d6dda7374e4f32ae86530444e45956d803

69
tools/starrod_enums_to_h.py Executable file
View File

@ -0,0 +1,69 @@
#!/usr/bin/env python3
import os
import re
from glob import glob
from stringcase import constcase # pip install stringcase
DIR = os.path.dirname(__file__)
SR_DATABASE = os.path.join(DIR, "star-rod/database")
FILES = (
glob(os.path.join(SR_DATABASE, "types/*.enum")) +
glob(os.path.join(SR_DATABASE, "types/**/*.enum")) +
glob(os.path.join(SR_DATABASE, "types/*.flags")) +
glob(os.path.join(SR_DATABASE, "types/**/*.flags"))
)
with open(os.path.join(DIR, "../include/enums.h"), "w") as h:
h.write("""#ifndef _ENUMS_H_
#define _ENUMS_H_
#include "ultra64.h"
#include "types.h"
""")
for filename in FILES:
with open(filename, "r") as file:
lines = file.readlines()
# Get enum attributes
namespace = constcase(re.match(r"[^ \t]*", lines[0]).group(0))
library_name = re.match(r"[^ \t]*", lines[1]).group(0)
reverse = True if re.match(r"[^ \t]*", lines[2]).group(0) == "true" else False
# Get a list of tuples containing (name, value)
items = []
name_max_len = 0
comment = False
for line in lines[4:]:
line = line.rstrip("\n")
if not comment and not line.startswith("%") and "=" in line:
m = re.match(r"[ \t]*?([^ \t]*)[ \t]*=[ \t]*([^ \t]*)", line)
if m:
if reverse:
name = m.group(1)
value = int(m.group(2), 16)
else:
name = m.group(2)
value = int(m.group(1), 16)
if value < 0:
str_value = f"{value}"
else:
str_value = "0x" + f"{value:08x}".upper()
name = constcase(name)
items.append((name, str_value))
name_max_len = max(len(name), name_max_len)
elif "/%" in line:
comment = True
elif "%/" in line:
comment = False
# Write a section to the header file for this enum
h.write(f"typedef UNK_TYPE {namespace};\n")
for (name, value) in items:
h.write(f"#define {namespace}_{name.ljust(name_max_len)} {value}\n")
h.write("\n")
h.write("#endif\n")

197
tools/starrod_structs_to_h.py Executable file
View File

@ -0,0 +1,197 @@
#!/usr/bin/env python3
from os import path
from glob import glob
import re
DIR = path.dirname(__file__)
SR_DATABASE = path.join(DIR, "star-rod/database")
# SR currently defines a struct with the "name" struct. This causes
# problems, so we'll call it the following instead.
STRUCT_STRUCT_ALIAS = "texture_header"
STRUCT_FILES = (
# structs which need to be forward declared (because they're used
# without indirection in other structs)
glob(path.join(SR_DATABASE, f"structs/**/matrix4f.struct")) +
glob(path.join(SR_DATABASE, f"structs/**/matrix4s.struct")) +
glob(path.join(SR_DATABASE, f"structs/**/cam_pos_settings.struct")) +
glob(path.join(SR_DATABASE, f"structs/**/partner_data.struct")) +
# other structs
glob(path.join(SR_DATABASE, f"structs/**/*.struct"))
)
def convert_type(type, structs):
size = 1
suffix = ""
# replace basic types
basic_types = [
("ubyte", "u8", 1),
("byte", "s8", 1),
("uchar", "u8", 1),
("char", "s8", 1),
("ushort", "u16", 2),
("short", "s16", 2),
("uint", "u32", 4),
("int", "s32", 4),
("ulong", "u64", 8),
("long", "s64", 8),
("float", "f32", 4),
("double", "f64", 8),
("ptr", "UNK_PTR", 4),
("struct", f"struct {STRUCT_STRUCT_ALIAS}", 0x30),
]
for name, size in structs:
basic_types.append((name, f"struct {name}", size))
for sr_name, decomp_name, basic_size in basic_types:
match = re.search(f"(\\b|^)({sr_name})(\\b|$)", type)
if match:
size = basic_size
start, end = match.span(2)
type = type[:start] + decomp_name + type[end:]
break
# array
while array_match := re.search(r"\[(([0-9]+)`|([a-fA-F0-9]+))\]", type):
bin_len_str = array_match.group(2)
hex_len_str = array_match.group(3)
array_len = int(bin_len_str) if bin_len_str else int(hex_len_str, 16)
size *= array_len
suffix += f"[{array_len}]"
# strip match from type
start, end = array_match.span()
type = type[:start] + type[end:]
# pointer
if "*" in type:
size = 4
return type, size, suffix
# read struct names and their sizes in advance
structs = []
for filename in STRUCT_FILES:
struct_name = path.splitext(path.basename(filename))[0]
if struct_name == "struct":
struct_name = STRUCT_STRUCT_ALIAS
with open(filename) as file:
for line in file.readlines():
if line.startswith("%"):
continue
parts = [x.strip() for x in line.split(":")]
if len(parts) == 0:
continue
if parts[0] == "size":
struct_size = int(parts[1], 16)
structs.append((struct_name, struct_size))
continue
with open(path.join(DIR, f"../include/common_structs.h"), "w") as h:
h.write(f"""#ifndef _COMMON_STRUCTS_H_
#define _COMMON_STRUCTS_H_
#include "ultra64.h"
#include "types.h"
""")
# write all structs out to common_structs.h
struct_names_seen = []
for filename in STRUCT_FILES:
struct_name = path.splitext(path.basename(filename))[0]
struct_size = None
offset_len = 2 # string length for hex offsets
if struct_name == "struct":
struct_name = STRUCT_STRUCT_ALIAS
# avoid repeat declarations
if struct_name.startswith("_") or struct_name.startswith("OS") or "." in struct_name or struct_name == "sprite":
continue
if struct_name in struct_names_seen:
continue
struct_names_seen.append(struct_name)
h.write(f"typedef struct {struct_name} {{\n")
with open(filename) as file:
in_fields = False
cur_offset = 0
def update_offset(offset):
global cur_offset
delta = offset - cur_offset
ofs_str = ("%X" % cur_offset).zfill(2)
ofs_str_z = ofs_str.zfill(offset_len)
# insert unknown char array
if delta == 1:
h.write(f" /* 0x{ofs_str_z} */ char unk_{ofs_str};\n")
elif delta > 0:
h.write(f" /* 0x{ofs_str_z} */ char unk_{ofs_str}[{delta}];\n")
cur_offset += delta
for line in file.readlines():
# read and strip line comment
comment = re.search(r"%(.*)$", line)
if comment:
pos = comment.span()[0]
line = line[0:pos]
comment = comment.group(1).strip()
parts = [x.strip() for x in line.split(":")]
if len(parts) == 0:
continue
if in_fields:
if parts[0] == "}":
in_fields = False
else:
offset, name, type = parts
# clean name
name = re.sub(r"[^a-zA-Z0-9_]", "", name)
offset = int(offset, 16)
ofs_str = ("%X" % offset).zfill(offset_len)
update_offset(offset)
if type == "code":
h.write(f" /* 0x{ofs_str} */ UNK_FUN_PTR({name});")
cur_offset += 4
else:
type, size, suffix = convert_type(type, structs)
h.write(f" /* 0x{ofs_str} */ {type} {name}{suffix};")
cur_offset += size
if comment:
h.write(f" /* {comment} */")
h.write("\n")
else:
if parts[0] == "size":
struct_size = int(parts[1], 16)
structs.append((struct_name, struct_size))
offset_len = max(2, len(parts[1]))
elif parts[0] == "{":
in_fields = True
update_offset(struct_size)
h.write(f"}} {struct_name}; // size = 0x{('%X' % struct_size).zfill(offset_len)}\n\n")
h.write("#endif\n")

View File

@ -1,60 +0,0 @@
#!/usr/bin/env python3
import os
import re
import stringcase
files = [filename for filename in os.listdir("./sr_enums") if filename.endswith(".enum")]
for filename in files:
with open(f"./sr_enums/{filename}", "r") as file:
lines = file.readlines()
# Get enum attributes
namespace = re.match(r"[^ \t]*", lines[0]).group(0)
library_name = re.match(r"[^ \t]*", lines[1]).group(0)
reverse = True if re.match(r"[^ \t]*", lines[2]).group(0) == "true" else False
# Get a list of tuples containing (name, value)
items = []
comment = False
for line in lines[4:]:
line = line.rstrip("\n")
if not comment and not line.startswith("%") and "=" in line:
m = re.match(r"[ \t]*?([^ \t]*)[ \t]*=[ \t]*([^ \t]*)", line)
if m:
if reverse:
name = m.group(1)
value = int(m.group(2), 16)
else:
name = m.group(2)
value = int(m.group(1), 16)
if value < 0:
str_value = "-0x" + f"{value*-1:08x}".upper()
else:
str_value = "0x" + f"{value:08x}".upper()
items.append((name, str_value))
elif "/%" in line:
comment = True
elif "%/" in line:
comment = False
# Create a header file for this enum
with open(f"./c_enums/{namespace}.h", "w") as file:
header = f"_{stringcase.constcase(namespace)}_"
file.write(f"#ifndef {header}\n#define {header}\n")
file.write("\n")
file.write("#include \"ultra64.h\"\n#include \"types.h\"\n")
file.write("\n")
file.write(f"typedef enum {namespace} {'{'}\n")
for i,(name,value) in enumerate(items):
name_const = stringcase.constcase(name)
if i < len(items) - 1:
file.write(f"\t{name_const} = {value},\n")
else:
file.write(f"\t{name_const} = {value}\n")
file.write(f"{'}'} {namespace};\n\n")
file.write("#endif")