diff --git a/Makefile b/Makefile index 7d3b41a03c..b6f7492006 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ SRC_DIRS := src src/os src/os/nusys ASM_DIRS := asm asm/os INCLUDE_DIRS := include include/PR src DATA_DIRS := bin +YAY0_DIRS := bin/Yay0 # Source code files C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) @@ -19,12 +20,14 @@ ifdef PM_HEADER_REBUILD H_FILES := $(foreach dir,$(INCLUDE_DIRS),$(wildcard $(dir)/*.h)) endif DATA_FILES := $(foreach dir,$(DATA_DIRS),$(wildcard $(dir)/*.bin)) +YAY0_FILES := $(foreach dir,$(YAY0_DIRS),$(wildcard $(dir)/*.bin)) # Object files O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \ $(foreach file,$(S_FILES),$(BUILD_DIR)/$(file:.s=.o)) \ $(foreach file,$(DATA_FILES),$(BUILD_DIR)/$(file:.bin=.o)) \ +YAY0_FILES := $(foreach file,$(YAY0_FILES),$(BUILD_DIR)/$(file:.bin=.bin.Yay0)) ####################### Other Tools ######################### @@ -68,7 +71,7 @@ submodules: git submodule update --init --recursive split: - rm -rf $(DATA_DIRS) && ./tools/n64splat/split.py baserom.z64 tools/splat.yaml . --modes ld bin + rm -rf $(DATA_DIRS) && ./tools/n64splat/split.py baserom.z64 tools/splat.yaml . --modes ld bin Yay0 split-all: rm -rf $(DATA_DIRS) && ./tools/n64splat/split.py baserom.z64 tools/splat.yaml . --modes all @@ -77,13 +80,14 @@ $(TARGET).ld: tools/splat.yaml ./tools/n64splat/split.py baserom.z64 tools/splat.yaml . --modes ld setup: clean submodules split + make -C tools print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true $(BUILD_DIR): mkdir -p $(BUILD_DIR) -$(BUILD_DIR)/$(TARGET).elf: $(O_FILES) $(LD_SCRIPT) +$(BUILD_DIR)/$(TARGET).elf: $(O_FILES) $(YAY0_FILES) $(LD_SCRIPT) @$(LD) $(LDFLAGS) -o $@ $(O_FILES) $(BUILD_DIR)/%.o: %.s @@ -95,6 +99,11 @@ $(BUILD_DIR)/%.o: %.c $(H_FILES) $(BUILD_DIR)/%.o: %.bin $(LD) -r -b binary -o $@ $< +$(BUILD_DIR)/%.bin.Yay0: %.bin + mkdir -p build/bin/Yay0 + tools/Yay0compress $< $<.Yay0 + $(LD) -r -b binary -o $@ $<.Yay0 + $(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf $(OBJCOPY) $< $@ -O binary diff --git a/asm/nonmatchings/code_16F740/end_battle.s b/asm/nonmatchings/code_16F740/end_battle.s index 60bb366684..57a9f4a015 100644 --- a/asm/nonmatchings/code_16F740/end_battle.s +++ b/asm/nonmatchings/code_16F740/end_battle.s @@ -189,8 +189,8 @@ glabel end_battle /* 1735E0 80244D00 3C04802A */ lui $a0, 0x802a /* 1735E4 80244D04 2484CAAC */ addiu $a0, $a0, -0x3554 /* 1735E8 80244D08 27A50010 */ addiu $a1, $sp, 0x10 -/* 1735EC 80244D0C 3C02800E */ lui $v0, 0x800e -/* 1735F0 80244D10 8C42C068 */ lw $v0, -0x3f98($v0) +/* 1735EC 80244D0C 3C02800E */ lui $v0, %hi(gBattleState) +/* 1735F0 80244D10 8C42C068 */ lw $v0, %lo(gBattleState)($v0) /* 1735F4 80244D14 3C01800E */ lui $at, 0x800e /* 1735F8 80244D18 AC22C4D0 */ sw $v0, -0x3b30($at) /* 1735FC 80244D1C 0C016AFE */ jal get_map_IDs_by_name @@ -207,8 +207,8 @@ glabel end_battle .L80244D48: /* 173628 80244D48 0C090464 */ jal func_80241190 /* 17362C 80244D4C 0000202D */ daddu $a0, $zero, $zero -/* 173630 80244D50 3C02800E */ lui $v0, 0x800e -/* 173634 80244D54 8C42C068 */ lw $v0, -0x3f98($v0) +/* 173630 80244D50 3C02800E */ lui $v0, %hi(gBattleState) +/* 173634 80244D54 8C42C068 */ lw $v0, %lo(gBattleState)($v0) /* 173638 80244D58 3C01800E */ lui $at, 0x800e /* 17363C 80244D5C AC22C4D0 */ sw $v0, -0x3b30($at) /* 173640 80244D60 0C00F945 */ jal func_8003E514 diff --git a/asm/nonmatchings/code_16F740/func_80241190.s b/asm/nonmatchings/code_16F740/func_80241190.s index 9452cfa8e9..fc069d84c5 100644 --- a/asm/nonmatchings/code_16F740/func_80241190.s +++ b/asm/nonmatchings/code_16F740/func_80241190.s @@ -5,8 +5,8 @@ glabel func_80241190 /* 16FA70 80241190 3C03800E */ lui $v1, 0x800e /* 16FA74 80241194 8C63C074 */ lw $v1, -0x3f8c($v1) /* 16FA78 80241198 24020001 */ addiu $v0, $zero, 1 -/* 16FA7C 8024119C 3C01800E */ lui $at, 0x800e -/* 16FA80 802411A0 AC24C068 */ sw $a0, -0x3f98($at) +/* 16FA7C 8024119C 3C01800E */ lui $at, %hi(gBattleState) +/* 16FA80 802411A0 AC24C068 */ sw $a0, %lo(gBattleState)($at) /* 16FA84 802411A4 3C01800E */ lui $at, 0x800e /* 16FA88 802411A8 AC22C4E0 */ sw $v0, -0x3b20($at) /* 16FA8C 802411AC 3C01800E */ lui $at, 0x800e @@ -36,8 +36,8 @@ glabel func_80241190 .L80241204: /* 16FAE4 80241204 24040007 */ addiu $a0, $zero, 7 .L80241208: -/* 16FAE8 80241208 3C01800E */ lui $at, 0x800e -/* 16FAEC 8024120C AC24C068 */ sw $a0, -0x3f98($at) +/* 16FAE8 80241208 3C01800E */ lui $at, %hi(gBattleState) +/* 16FAEC 8024120C AC24C068 */ sw $a0, %lo(gBattleState)($at) .L80241210: /* 16FAF0 80241210 03E00008 */ jr $ra /* 16FAF4 80241214 00000000 */ nop diff --git a/asm/nonmatchings/code_16F740/func_80248B08.s b/asm/nonmatchings/code_16F740/func_80248B08.s index a858e00857..acf01c1536 100644 --- a/asm/nonmatchings/code_16F740/func_80248B08.s +++ b/asm/nonmatchings/code_16F740/func_80248B08.s @@ -159,8 +159,8 @@ glabel func_80248B08 .L80248D40: /* 177620 80248D40 0C090464 */ jal func_80241190 /* 177624 80248D44 0000202D */ daddu $a0, $zero, $zero -/* 177628 80248D48 3C02800E */ lui $v0, 0x800e -/* 17762C 80248D4C 8C42C068 */ lw $v0, -0x3f98($v0) +/* 177628 80248D48 3C02800E */ lui $v0, %hi(gBattleState) +/* 17762C 80248D4C 8C42C068 */ lw $v0, %lo(gBattleState)($v0) /* 177630 80248D50 3C01800E */ lui $at, 0x800e /* 177634 80248D54 AC22C4D0 */ sw $v0, -0x3b30($at) /* 177638 80248D58 0C00CD3C */ jal set_game_mode diff --git a/asm/nonmatchings/code_16c8e0/draw_main_battle_ui.s b/asm/nonmatchings/code_16c8e0/draw_main_battle_ui.s index 83a53dda77..0056a774df 100644 --- a/asm/nonmatchings/code_16c8e0/draw_main_battle_ui.s +++ b/asm/nonmatchings/code_16c8e0/draw_main_battle_ui.s @@ -7,8 +7,8 @@ glabel draw_main_battle_ui /* 16D364 8023EA84 0000882D */ daddu $s1, $zero, $zero /* 16D368 8023EA88 AFBF0018 */ sw $ra, 0x18($sp) /* 16D36C 8023EA8C AFB00010 */ sw $s0, 0x10($sp) -/* 16D370 8023EA90 3C10800E */ lui $s0, 0x800e -/* 16D374 8023EA94 8E10C068 */ lw $s0, -0x3f98($s0) +/* 16D370 8023EA90 3C10800E */ lui $s0, %hi(gBattleState) +/* 16D374 8023EA94 8E10C068 */ lw $s0, %lo(gBattleState)($s0) /* 16D378 8023EA98 3C04800E */ lui $a0, 0x800e /* 16D37C 8023EA9C 2484C4D0 */ addiu $a0, $a0, -0x3b30 /* 16D380 8023EAA0 8C820000 */ lw $v0, ($a0) diff --git a/asm/nonmatchings/code_16c8e0/func_8023ED5C.s b/asm/nonmatchings/code_16c8e0/func_8023ED5C.s index 6063f962ca..ad38659215 100644 --- a/asm/nonmatchings/code_16c8e0/func_8023ED5C.s +++ b/asm/nonmatchings/code_16c8e0/func_8023ED5C.s @@ -2,8 +2,8 @@ .set noreorder # don't insert nops after branches glabel func_8023ED5C -/* 16D63C 8023ED5C 3C02800E */ lui $v0, 0x800e -/* 16D640 8023ED60 8C42C068 */ lw $v0, -0x3f98($v0) +/* 16D63C 8023ED5C 3C02800E */ lui $v0, %hi(gBattleState) +/* 16D640 8023ED60 8C42C068 */ lw $v0, %lo(gBattleState)($v0) /* 16D644 8023ED64 27BDFFB8 */ addiu $sp, $sp, -0x48 /* 16D648 8023ED68 AFB40030 */ sw $s4, 0x30($sp) /* 16D64C 8023ED6C 3C14800E */ lui $s4, %hi(gBattleStatus) diff --git a/asm/nonmatchings/code_16c8e0/update_battle_state.s b/asm/nonmatchings/code_16c8e0/update_battle_state.s index 5096f193f8..2718d53107 100644 --- a/asm/nonmatchings/code_16c8e0/update_battle_state.s +++ b/asm/nonmatchings/code_16c8e0/update_battle_state.s @@ -92,13 +92,13 @@ glabel update_battle_state /* 16CE64 8023E584 82030095 */ lb $v1, 0x95($s0) /* 16CE68 8023E588 10600005 */ beqz $v1, .L8023E5A0 /* 16CE6C 8023E58C 24110001 */ addiu $s1, $zero, 1 -/* 16CE70 8023E590 3C02800E */ lui $v0, 0x800e -/* 16CE74 8023E594 8C42C068 */ lw $v0, -0x3f98($v0) +/* 16CE70 8023E590 3C02800E */ lui $v0, %hi(gBattleState) +/* 16CE74 8023E594 8C42C068 */ lw $v0, %lo(gBattleState)($v0) /* 16CE78 8023E598 10620092 */ beq $v1, $v0, .L8023E7E4 /* 16CE7C 8023E59C 00000000 */ nop .L8023E5A0: -/* 16CE80 8023E5A0 3C02800E */ lui $v0, 0x800e -/* 16CE84 8023E5A4 8C42C068 */ lw $v0, -0x3f98($v0) +/* 16CE80 8023E5A0 3C02800E */ lui $v0, %hi(gBattleState) +/* 16CE84 8023E5A4 8C42C068 */ lw $v0, %lo(gBattleState)($v0) /* 16CE88 8023E5A8 24430001 */ addiu $v1, $v0, 1 /* 16CE8C 8023E5AC 2C620025 */ sltiu $v0, $v1, 0x25 /* 16CE90 8023E5B0 1040008C */ beqz $v0, .L8023E7E4 @@ -383,8 +383,8 @@ glabel update_battle_state .L8023E9E0: /* 16D2C0 8023E9E0 1485000A */ bne $a0, $a1, .L8023EA0C /* 16D2C4 8023E9E4 2462000A */ addiu $v0, $v1, 0xa -/* 16D2C8 8023E9E8 3C03800E */ lui $v1, 0x800e -/* 16D2CC 8023E9EC 8C63C068 */ lw $v1, -0x3f98($v1) +/* 16D2C8 8023E9E8 3C03800E */ lui $v1, %hi(gBattleState) +/* 16D2CC 8023E9EC 8C63C068 */ lw $v1, %lo(gBattleState)($v1) /* 16D2D0 8023E9F0 24020023 */ addiu $v0, $zero, 0x23 /* 16D2D4 8023E9F4 1062001B */ beq $v1, $v0, .L8023EA64 /* 16D2D8 8023E9F8 00000000 */ nop diff --git a/asm/nonmatchings/code_181810/ActorSpeak.s b/asm/nonmatchings/code_181810/ActorSpeak.s index 3ce3f4d62b..4b7235830f 100644 --- a/asm/nonmatchings/code_181810/ActorSpeak.s +++ b/asm/nonmatchings/code_181810/ActorSpeak.s @@ -30,13 +30,13 @@ glabel ActorSpeak /* 181874 80252F94 0260202D */ daddu $a0, $s3, $zero /* 181878 80252F98 0C0B1EAF */ jal get_variable /* 18187C 80252F9C 0040A02D */ daddu $s4, $v0, $zero -/* 181880 80252FA0 3C01802A */ lui $at, 0x802a -/* 181884 80252FA4 AC22FA6C */ sw $v0, -0x594($at) +/* 181880 80252FA0 3C01802A */ lui $at, %hi(gSpeakingActorTalkAnim) +/* 181884 80252FA4 AC22FA6C */ sw $v0, %lo(gSpeakingActorTalkAnim)($at) /* 181888 80252FA8 8E250000 */ lw $a1, ($s1) /* 18188C 80252FAC 0C0B1EAF */ jal get_variable /* 181890 80252FB0 0260202D */ daddu $a0, $s3, $zero -/* 181894 80252FB4 3C01802A */ lui $at, 0x802a -/* 181898 80252FB8 AC22FA70 */ sw $v0, -0x590($at) +/* 181894 80252FB4 3C01802A */ lui $at, %hi(gSpeakingActorIdleAnim) +/* 181898 80252FB8 AC22FA70 */ sw $v0, %lo(gSpeakingActorIdleAnim)($at) /* 18189C 80252FBC 2402FF81 */ addiu $v0, $zero, -0x7f /* 1818A0 80252FC0 16420002 */ bne $s2, $v0, .L80252FCC /* 1818A4 80252FC4 00000000 */ nop @@ -52,8 +52,8 @@ glabel ActorSpeak /* 1818C8 80252FE8 86230150 */ lh $v1, 0x150($s1) /* 1818CC 80252FEC C6200144 */ lwc1 $f0, 0x144($s1) /* 1818D0 80252FF0 8E220000 */ lw $v0, ($s1) -/* 1818D4 80252FF4 3C01802A */ lui $at, 0x802a -/* 1818D8 80252FF8 AC31FA74 */ sw $s1, -0x58c($at) +/* 1818D4 80252FF4 3C01802A */ lui $at, %hi(gSpeakingActor) +/* 1818D8 80252FF8 AC31FA74 */ sw $s1, %lo(gSpeakingActor)($at) /* 1818DC 80252FFC 3C01802A */ lui $at, 0x802a /* 1818E0 80253000 AC32FA78 */ sw $s2, -0x588($at) /* 1818E4 80253004 44831000 */ mtc1 $v1, $f2 @@ -106,23 +106,23 @@ glabel ActorSpeak /* 181998 802530B8 0C00B94E */ jal get_screen_coords /* 18199C 802530BC AFA20018 */ sw $v0, 0x18($sp) /* 1819A0 802530C0 0200202D */ daddu $a0, $s0, $zero -/* 1819A4 802530C4 3C05802A */ lui $a1, 0x802a -/* 1819A8 802530C8 24A5FA68 */ addiu $a1, $a1, -0x598 +/* 1819A4 802530C4 3C05802A */ lui $a1, %hi(gSpeakingActorPrintIsDone) +/* 1819A8 802530C8 24A5FA68 */ addiu $a1, $a1, %lo(gSpeakingActorPrintIsDone) /* 1819AC 802530CC 0C049640 */ jal load_string /* 1819B0 802530D0 ACA00000 */ sw $zero, ($a1) /* 1819B4 802530D4 8FA50020 */ lw $a1, 0x20($sp) /* 1819B8 802530D8 8FA60024 */ lw $a2, 0x24($sp) /* 1819BC 802530DC 0040202D */ daddu $a0, $v0, $zero -/* 1819C0 802530E0 3C01802A */ lui $at, 0x802a -/* 1819C4 802530E4 AC24FA60 */ sw $a0, -0x5a0($at) +/* 1819C0 802530E0 3C01802A */ lui $at, %hi(gSpeakingActorPrintCtx) +/* 1819C4 802530E4 AC24FA60 */ sw $a0, %lo(gSpeakingActorPrintCtx)($at) /* 1819C8 802530E8 0C0496AE */ jal clamp_printer_coords /* 1819CC 802530EC 00000000 */ nop /* 1819D0 802530F0 3C03800A */ lui $v1, %hi(D_8009A650) /* 1819D4 802530F4 2463A650 */ addiu $v1, $v1, %lo(D_8009A650) /* 1819D8 802530F8 AE600070 */ sw $zero, 0x70($s3) /* 1819DC 802530FC 8C620000 */ lw $v0, ($v1) -/* 1819E0 80253100 3C06802A */ lui $a2, 0x802a -/* 1819E4 80253104 8CC6FA6C */ lw $a2, -0x594($a2) +/* 1819E0 80253100 3C06802A */ lui $a2, %hi(gSpeakingActorTalkAnim) +/* 1819E4 80253104 8CC6FA6C */ lw $a2, %lo(gSpeakingActorTalkAnim)($a2) /* 1819E8 80253108 34420010 */ ori $v0, $v0, 0x10 /* 1819EC 8025310C 04C00004 */ bltz $a2, .L80253120 /* 1819F0 80253110 AC620000 */ sw $v0, ($v1) @@ -136,8 +136,8 @@ glabel ActorSpeak /* 181A08 80253128 8E620070 */ lw $v0, 0x70($s3) /* 181A0C 8025312C 14400060 */ bnez $v0, .L802532B0 /* 181A10 80253130 0000102D */ daddu $v0, $zero, $zero -/* 181A14 80253134 3C11802A */ lui $s1, 0x802a -/* 181A18 80253138 8E31FA74 */ lw $s1, -0x58c($s1) +/* 181A14 80253134 3C11802A */ lui $s1, %hi(gSpeakingActor) +/* 181A18 80253138 8E31FA74 */ lw $s1, %lo(gSpeakingActor)($s1) /* 181A1C 8025313C 3C12802A */ lui $s2, 0x802a /* 181A20 80253140 8E52FA78 */ lw $s2, -0x588($s2) /* 181A24 80253144 86220150 */ lh $v0, 0x150($s1) @@ -192,8 +192,8 @@ glabel ActorSpeak /* 181AE0 80253200 27A20028 */ addiu $v0, $sp, 0x28 /* 181AE4 80253204 0C00B94E */ jal get_screen_coords /* 181AE8 80253208 AFA20018 */ sw $v0, 0x18($sp) -/* 181AEC 8025320C 3C10802A */ lui $s0, 0x802a -/* 181AF0 80253210 2610FA60 */ addiu $s0, $s0, -0x5a0 +/* 181AEC 8025320C 3C10802A */ lui $s0, %hi(gSpeakingActorPrintCtx) +/* 181AF0 80253210 2610FA60 */ addiu $s0, $s0, %lo(gSpeakingActorPrintCtx) /* 181AF4 80253214 8E040000 */ lw $a0, ($s0) /* 181AF8 80253218 8FA50020 */ lw $a1, 0x20($sp) /* 181AFC 8025321C 0C0496AE */ jal clamp_printer_coords @@ -210,21 +210,21 @@ glabel ActorSpeak .L80253248: /* 181B28 80253248 10400005 */ beqz $v0, .L80253260 /* 181B2C 8025324C 00000000 */ nop -/* 181B30 80253250 3C06802A */ lui $a2, 0x802a -/* 181B34 80253254 8CC6FA6C */ lw $a2, -0x594($a2) +/* 181B30 80253250 3C06802A */ lui $a2, %hi(gSpeakingActorTalkAnim) +/* 181B34 80253254 8CC6FA6C */ lw $a2, %lo(gSpeakingActorTalkAnim)($a2) /* 181B38 80253258 08094C9A */ j .L80253268 /* 181B3C 8025325C 00000000 */ nop .L80253260: -/* 181B40 80253260 3C06802A */ lui $a2, 0x802a -/* 181B44 80253264 8CC6FA70 */ lw $a2, -0x590($a2) +/* 181B40 80253260 3C06802A */ lui $a2, %hi(gSpeakingActorIdleAnim) +/* 181B44 80253264 8CC6FA70 */ lw $a2, %lo(gSpeakingActorIdleAnim)($a2) .L80253268: /* 181B48 80253268 04C00003 */ bltz $a2, .L80253278 /* 181B4C 8025326C 0220202D */ daddu $a0, $s1, $zero /* 181B50 80253270 0C098F82 */ jal func_80263E08 /* 181B54 80253274 0240282D */ daddu $a1, $s2, $zero .L80253278: -/* 181B58 80253278 3C03802A */ lui $v1, 0x802a -/* 181B5C 8025327C 8C63FA68 */ lw $v1, -0x598($v1) +/* 181B58 80253278 3C03802A */ lui $v1, %hi(gSpeakingActorPrintIsDone) +/* 181B5C 8025327C 8C63FA68 */ lw $v1, %lo(gSpeakingActorPrintIsDone)($v1) /* 181B60 80253280 24020001 */ addiu $v0, $zero, 1 /* 181B64 80253284 1462000A */ bne $v1, $v0, .L802532B0 /* 181B68 80253288 0000102D */ daddu $v0, $zero, $zero diff --git a/asm/nonmatchings/code_181810/EndActorSpeech.s b/asm/nonmatchings/code_181810/EndActorSpeech.s index 6e5da8ba30..4a2ec08a22 100644 --- a/asm/nonmatchings/code_181810/EndActorSpeech.s +++ b/asm/nonmatchings/code_181810/EndActorSpeech.s @@ -24,13 +24,13 @@ glabel EndActorSpeech /* 181BFC 8025331C 0240202D */ daddu $a0, $s2, $zero /* 181C00 80253320 0C0B1EAF */ jal get_variable /* 181C04 80253324 0040982D */ daddu $s3, $v0, $zero -/* 181C08 80253328 3C01802A */ lui $at, 0x802a -/* 181C0C 8025332C AC22FA6C */ sw $v0, -0x594($at) +/* 181C08 80253328 3C01802A */ lui $at, %hi(gSpeakingActorTalkAnim) +/* 181C0C 8025332C AC22FA6C */ sw $v0, %lo(gSpeakingActorTalkAnim)($at) /* 181C10 80253330 8E050000 */ lw $a1, ($s0) /* 181C14 80253334 0C0B1EAF */ jal get_variable /* 181C18 80253338 0240202D */ daddu $a0, $s2, $zero -/* 181C1C 8025333C 3C01802A */ lui $at, 0x802a -/* 181C20 80253340 AC22FA70 */ sw $v0, -0x590($at) +/* 181C1C 8025333C 3C01802A */ lui $at, %hi(gSpeakingActorIdleAnim) +/* 181C20 80253340 AC22FA70 */ sw $v0, %lo(gSpeakingActorIdleAnim)($at) /* 181C24 80253344 2402FF81 */ addiu $v0, $zero, -0x7f /* 181C28 80253348 16220002 */ bne $s1, $v0, .L80253354 /* 181C2C 8025334C 00000000 */ nop @@ -42,10 +42,10 @@ glabel EndActorSpeech /* 181C40 80253360 0220202D */ daddu $a0, $s1, $zero /* 181C44 80253364 0C099117 */ jal get_actor_part /* 181C48 80253368 0260282D */ daddu $a1, $s3, $zero -/* 181C4C 8025336C 3C04802A */ lui $a0, 0x802a -/* 181C50 80253370 8C84FA60 */ lw $a0, -0x5a0($a0) -/* 181C54 80253374 3C01802A */ lui $at, 0x802a -/* 181C58 80253378 AC31FA74 */ sw $s1, -0x58c($at) +/* 181C4C 8025336C 3C04802A */ lui $a0, %hi(gSpeakingActorPrintCtx) +/* 181C50 80253370 8C84FA60 */ lw $a0, %lo(gSpeakingActorPrintCtx)($a0) +/* 181C54 80253374 3C01802A */ lui $at, %hi(gSpeakingActor) +/* 181C58 80253378 AC31FA74 */ sw $s1, %lo(gSpeakingActor)($at) /* 181C5C 8025337C 3C01802A */ lui $at, 0x802a /* 181C60 80253380 AC22FA78 */ sw $v0, -0x588($at) /* 181C64 80253384 0C04971C */ jal close_message @@ -56,8 +56,8 @@ glabel EndActorSpeech /* 181C74 80253394 8E420070 */ lw $v0, 0x70($s2) /* 181C78 80253398 14400060 */ bnez $v0, .L8025351C /* 181C7C 8025339C 0000102D */ daddu $v0, $zero, $zero -/* 181C80 802533A0 3C11802A */ lui $s1, 0x802a -/* 181C84 802533A4 8E31FA74 */ lw $s1, -0x58c($s1) +/* 181C80 802533A0 3C11802A */ lui $s1, %hi(gSpeakingActor) +/* 181C84 802533A4 8E31FA74 */ lw $s1, %lo(gSpeakingActor)($s1) /* 181C88 802533A8 3C12802A */ lui $s2, 0x802a /* 181C8C 802533AC 8E52FA78 */ lw $s2, -0x588($s2) /* 181C90 802533B0 86220150 */ lh $v0, 0x150($s1) @@ -112,8 +112,8 @@ glabel EndActorSpeech /* 181D4C 8025346C 27A20028 */ addiu $v0, $sp, 0x28 /* 181D50 80253470 0C00B94E */ jal get_screen_coords /* 181D54 80253474 AFA20018 */ sw $v0, 0x18($sp) -/* 181D58 80253478 3C10802A */ lui $s0, 0x802a -/* 181D5C 8025347C 2610FA60 */ addiu $s0, $s0, -0x5a0 +/* 181D58 80253478 3C10802A */ lui $s0, %hi(gSpeakingActorPrintCtx) +/* 181D5C 8025347C 2610FA60 */ addiu $s0, $s0, %lo(gSpeakingActorPrintCtx) /* 181D60 80253480 8E040000 */ lw $a0, ($s0) /* 181D64 80253484 8FA50020 */ lw $a1, 0x20($sp) /* 181D68 80253488 0C0496AE */ jal clamp_printer_coords @@ -130,21 +130,21 @@ glabel EndActorSpeech .L802534B4: /* 181D94 802534B4 10400005 */ beqz $v0, .L802534CC /* 181D98 802534B8 00000000 */ nop -/* 181D9C 802534BC 3C06802A */ lui $a2, 0x802a -/* 181DA0 802534C0 8CC6FA6C */ lw $a2, -0x594($a2) +/* 181D9C 802534BC 3C06802A */ lui $a2, %hi(gSpeakingActorTalkAnim) +/* 181DA0 802534C0 8CC6FA6C */ lw $a2, %lo(gSpeakingActorTalkAnim)($a2) /* 181DA4 802534C4 08094D35 */ j .L802534D4 /* 181DA8 802534C8 00000000 */ nop .L802534CC: -/* 181DAC 802534CC 3C06802A */ lui $a2, 0x802a -/* 181DB0 802534D0 8CC6FA70 */ lw $a2, -0x590($a2) +/* 181DAC 802534CC 3C06802A */ lui $a2, %hi(gSpeakingActorIdleAnim) +/* 181DB0 802534D0 8CC6FA70 */ lw $a2, %lo(gSpeakingActorIdleAnim)($a2) .L802534D4: /* 181DB4 802534D4 04C00003 */ bltz $a2, .L802534E4 /* 181DB8 802534D8 0220202D */ daddu $a0, $s1, $zero /* 181DBC 802534DC 0C098F82 */ jal func_80263E08 /* 181DC0 802534E0 0240282D */ daddu $a1, $s2, $zero .L802534E4: -/* 181DC4 802534E4 3C03802A */ lui $v1, 0x802a -/* 181DC8 802534E8 8C63FA68 */ lw $v1, -0x598($v1) +/* 181DC4 802534E4 3C03802A */ lui $v1, %hi(gSpeakingActorPrintIsDone) +/* 181DC8 802534E8 8C63FA68 */ lw $v1, %lo(gSpeakingActorPrintIsDone)($v1) /* 181DCC 802534EC 24020001 */ addiu $v0, $zero, 1 /* 181DD0 802534F0 1462000A */ bne $v1, $v0, .L8025351C /* 181DD4 802534F4 0000102D */ daddu $v0, $zero, $zero diff --git a/asm/nonmatchings/code_181810/LoadBattleDmaData.s b/asm/nonmatchings/code_181810/LoadBattleDmaData.s index b16584cf76..8e549b9480 100644 --- a/asm/nonmatchings/code_181810/LoadBattleDmaData.s +++ b/asm/nonmatchings/code_181810/LoadBattleDmaData.s @@ -19,8 +19,8 @@ glabel LoadBattleDmaData /* 181F3C 8025365C 00431021 */ addu $v0, $v0, $v1 /* 181F40 80253660 5040000E */ beql $v0, $zero, .L8025369C /* 181F44 80253664 24020002 */ addiu $v0, $zero, 2 -/* 181F48 80253668 3C068028 */ lui $a2, 0x8028 -/* 181F4C 8025366C 8CC64000 */ lw $a2, 0x4000($a2) +/* 181F48 80253668 3C068028 */ lui $a2, %hi(gBattleDmaDest) +/* 181F4C 8025366C 8CC64000 */ lw $a2, %lo(gBattleDmaDest)($a2) /* 181F50 80253670 14C00005 */ bnez $a2, .L80253688 /* 181F54 80253674 00000000 */ nop /* 181F58 80253678 8C440000 */ lw $a0, ($v0) diff --git a/asm/nonmatchings/code_181810/ShowBattleChoice.s b/asm/nonmatchings/code_181810/ShowBattleChoice.s index 70c4b30185..98bca31fee 100644 --- a/asm/nonmatchings/code_181810/ShowBattleChoice.s +++ b/asm/nonmatchings/code_181810/ShowBattleChoice.s @@ -23,8 +23,8 @@ glabel ShowBattleChoice /* 181E5C 8025357C 0000102D */ daddu $v0, $zero, $zero /* 181E60 80253580 3C02802A */ lui $v0, 0x802a /* 181E64 80253584 8C42FA64 */ lw $v0, -0x59c($v0) -/* 181E68 80253588 3C04802A */ lui $a0, 0x802a -/* 181E6C 8025358C 8C84FA60 */ lw $a0, -0x5a0($a0) +/* 181E68 80253588 3C04802A */ lui $a0, %hi(gSpeakingActorPrintCtx) +/* 181E6C 8025358C 8C84FA60 */ lw $a0, %lo(gSpeakingActorPrintCtx)($a0) /* 181E70 80253590 904304E8 */ lbu $v1, 0x4e8($v0) /* 181E74 80253594 24020001 */ addiu $v0, $zero, 1 /* 181E78 80253598 A08304E8 */ sb $v1, 0x4e8($a0) diff --git a/asm/nonmatchings/code_18F340/func_8026127C.s b/asm/nonmatchings/code_18F340/func_8026127C.s index 3896485a55..975765ae23 100644 --- a/asm/nonmatchings/code_18F340/func_8026127C.s +++ b/asm/nonmatchings/code_18F340/func_8026127C.s @@ -15,8 +15,8 @@ glabel func_8026127C /* 18FB84 802612A4 AFBF0018 */ sw $ra, 0x18($sp) /* 18FB88 802612A8 AFB10014 */ sw $s1, 0x14($sp) /* 18FB8C 802612AC A2000099 */ sb $zero, 0x99($s0) -/* 18FB90 802612B0 3C01800E */ lui $at, 0x800e -/* 18FB94 802612B4 AC22C068 */ sw $v0, -0x3f98($at) +/* 18FB90 802612B0 3C01800E */ lui $at, %hi(gBattleState) +/* 18FB94 802612B4 AC22C068 */ sw $v0, %lo(gBattleState)($at) /* 18FB98 802612B8 8E020000 */ lw $v0, ($s0) /* 18FB9C 802612BC 3C118011 */ lui $s1, %hi(gPlayerData) /* 18FBA0 802612C0 2631F290 */ addiu $s1, $s1, %lo(gPlayerData) diff --git a/asm/nonmatchings/code_190B20/func_80263464.s b/asm/nonmatchings/code_190B20/func_80263464.s index fa0d7781a9..574798d6fd 100644 --- a/asm/nonmatchings/code_190B20/func_80263464.s +++ b/asm/nonmatchings/code_190B20/func_80263464.s @@ -7,8 +7,8 @@ glabel func_80263464 /* 191D4C 8026346C 27BDFFE8 */ addiu $sp, $sp, -0x18 /* 191D50 80263470 1C40000D */ bgtz $v0, .L802634A8 /* 191D54 80263474 AFBF0010 */ sw $ra, 0x10($sp) -/* 191D58 80263478 3C02800E */ lui $v0, 0x800e -/* 191D5C 8026347C 8C42C068 */ lw $v0, -0x3f98($v0) +/* 191D58 80263478 3C02800E */ lui $v0, %hi(gBattleState) +/* 191D5C 8026347C 8C42C068 */ lw $v0, %lo(gBattleState)($v0) /* 191D60 80263480 3C03800E */ lui $v1, 0x800e /* 191D64 80263484 8C63C4DC */ lw $v1, -0x3b24($v1) /* 191D68 80263488 3C01800E */ lui $at, 0x800e diff --git a/asm/nonmatchings/code_197F40/func_8026E198.s b/asm/nonmatchings/code_197F40/func_8026E198.s index 55e77859c1..35733e152e 100644 --- a/asm/nonmatchings/code_197F40/func_8026E198.s +++ b/asm/nonmatchings/code_197F40/func_8026E198.s @@ -20,8 +20,8 @@ glabel func_8026E198 /* 19CAB0 8026E1D0 82030095 */ lb $v1, 0x95($s0) /* 19CAB4 8026E1D4 50600008 */ beql $v1, $zero, .L8026E1F8 /* 19CAB8 8026E1D8 24020002 */ addiu $v0, $zero, 2 -/* 19CABC 8026E1DC 3C02800E */ lui $v0, 0x800e -/* 19CAC0 8026E1E0 8C42C068 */ lw $v0, -0x3f98($v0) +/* 19CABC 8026E1DC 3C02800E */ lui $v0, %hi(gBattleState) +/* 19CAC0 8026E1E0 8C42C068 */ lw $v0, %lo(gBattleState)($v0) /* 19CAC4 8026E1E4 00431026 */ xor $v0, $v0, $v1 /* 19CAC8 8026E1E8 2C420001 */ sltiu $v0, $v0, 1 /* 19CACC 8026E1EC 0809B87E */ j .L8026E1F8 diff --git a/asm/nonmatchings/os/code_4ac90_len_3910/func_80072B30.s b/asm/nonmatchings/os/code_4ac90_len_3910/func_80072B30.s index f5f3b161fc..9f23aa6307 100644 --- a/asm/nonmatchings/os/code_4ac90_len_3910/func_80072B30.s +++ b/asm/nonmatchings/os/code_4ac90_len_3910/func_80072B30.s @@ -6,8 +6,8 @@ glabel func_80072B30 /* 4DF34 80072B34 8C42419C */ lw $v0, %lo(gGameStatusPtr)($v0) /* 4DF38 80072B38 A04000AA */ sb $zero, 0xaa($v0) /* 4DF3C 80072B3C 24020001 */ addiu $v0, $zero, 1 -/* 4DF40 80072B40 3C01800E */ lui $at, 0x800e -/* 4DF44 80072B44 AC20C068 */ sw $zero, -0x3f98($at) +/* 4DF40 80072B40 3C01800E */ lui $at, %hi(gBattleState) +/* 4DF44 80072B44 AC20C068 */ sw $zero, %lo(gBattleState)($at) /* 4DF48 80072B48 3C01800E */ lui $at, 0x800e /* 4DF4C 80072B4C AC22C4E0 */ sw $v0, -0x3b20($at) /* 4DF50 80072B50 3C01800E */ lui $at, 0x800e diff --git a/asm/nonmatchings/os/code_4ac90_len_3910/load_battle.s b/asm/nonmatchings/os/code_4ac90_len_3910/load_battle.s index 076b5ac9a4..5c5d3e18f9 100644 --- a/asm/nonmatchings/os/code_4ac90_len_3910/load_battle.s +++ b/asm/nonmatchings/os/code_4ac90_len_3910/load_battle.s @@ -9,8 +9,8 @@ glabel load_battle /* 4E0A0 80072CA0 0C00CD3C */ jal set_game_mode /* 4E0A4 80072CA4 24040008 */ addiu $a0, $zero, 8 /* 4E0A8 80072CA8 8FBF0010 */ lw $ra, 0x10($sp) -/* 4E0AC 80072CAC 3C01800E */ lui $at, 0x800e -/* 4E0B0 80072CB0 AC20C068 */ sw $zero, -0x3f98($at) +/* 4E0AC 80072CAC 3C01800E */ lui $at, %hi(gBattleState) +/* 4E0B0 80072CB0 AC20C068 */ sw $zero, %lo(gBattleState)($at) /* 4E0B4 80072CB4 3C01800E */ lui $at, 0x800e /* 4E0B8 80072CB8 AC20C4D0 */ sw $zero, -0x3b30($at) /* 4E0BC 80072CBC 3C01800E */ lui $at, 0x800e diff --git a/tools/Makefile b/tools/Makefile new file mode 100644 index 0000000000..d3edc74d33 --- /dev/null +++ b/tools/Makefile @@ -0,0 +1,9 @@ +default: all + +all: Yay0compress + +Yay0compress: + gcc Yay0compress.c -O3 -o Yay0compress + +clean: + rm -f Yay0compress diff --git a/tools/Yay0compress b/tools/Yay0compress new file mode 100755 index 0000000000..10b3c1c0c6 Binary files /dev/null and b/tools/Yay0compress differ diff --git a/tools/Yay0compress.c b/tools/Yay0compress.c new file mode 100644 index 0000000000..bbcae98760 --- /dev/null +++ b/tools/Yay0compress.c @@ -0,0 +1,316 @@ +#include +#include +#include + +int main(int argc, const char **argv, const char **envp); +void encode(); +void search(unsigned int a1, int a2, int *a3, unsigned int *a4); +int mischarsearch(unsigned char *a1, int a2, unsigned char *a3, int a4); +void initskip(unsigned char *a1, int a2); +void writeshort(short a1); +void writeint4(int a1); + +unsigned short skip[256]; // idb +int cp; // weak +int ndp; // weak +FILE *fp; // idb +unsigned char *def; +unsigned short *pol; +int pp; // weak +int insize; // idb +int ncp; // weak +int npp; // weak +unsigned char *bz; +int dp; // idb +unsigned int *cmd; + +int main(int argc, const char **argv, const char **envp) +{ + char src[999]; + char dest[999]; + + + if (argc < 3) + { + fprintf(stderr, "Yay0decompress [infile] [outfile]\n"); + return 1; + } + + strcpy(src, argv[1]); + strcpy(dest, argv[2]); + + if ((fp = fopen(src, "rb")) == NULL) + { + fprintf(stderr, "FILE OPEN ERROR![%s]\n", src); + return 1; + } + + fseek(fp, 0, SEEK_END); + insize = ftell(fp); + fseek(fp, 0, SEEK_SET); + + bz = malloc(insize); + fread(bz, 1, insize, fp); + fclose(fp); + + for (int i = 0; src[i]; i++) + { + if (src[i] == '.') + { + src[i] = 0; + break; + } + } + + if ((fp = fopen(dest, "wb")) == NULL) + { + fprintf(stderr, "FILE CREATE ERROR![%s]\n", dest); + exit(1); + } + + encode(); + + fprintf(fp, "Yay0"); + + writeint4(insize); + + writeint4(4 * cp + 16); + writeint4(2 * pp + 4 * cp + 16); + + for (int i = 0; i < cp; i++) + writeint4(cmd[i]); + + for (int i = 0; i < pp; i++) + writeshort(pol[i]); + + fwrite(def, 1u, dp, fp); + fclose(fp); + + return 0; +} + +void encode() +{ + unsigned int v0; // esi + unsigned int v1; // edi + int v2; // edx + int v3; // ebx + int v4; // edx + char v5; // [esp+Ch] [ebp-18h] + unsigned int v6; // [esp+10h] [ebp-14h] + unsigned int v7; // [esp+14h] [ebp-10h] + int v8; // [esp+18h] [ebp-Ch] + unsigned int a4; // [esp+1Ch] [ebp-8h] + int a3; // [esp+20h] [ebp-4h] + + dp = 0; + pp = 0; + cp = 0; + npp = 4096; + ndp = 4096; + ncp = 4096; + cmd = calloc(0x4000u, 1u); + pol = malloc(2 * npp); + def = malloc(4 * ndp); + v0 = 0; + v6 = 1024; + v1 = 2147483648; + while ( insize > v0 ) + { + if ( v6 < v0 ) + v6 += 1024; + search(v0, insize, &a3, &a4); + if ( a4 <= 2 ) + { + cmd[cp] |= v1; + def[dp++] = bz[v0++]; + if ( ndp == dp ) + { + ndp = dp + 4096; + def = realloc(def, dp + 4096); + } + } + else + { + search(v0 + 1, insize, &v8, &v7); + if ( v7 > a4 + 1 ) + { + cmd[cp] |= v1; + def[dp++] = bz[v0++]; + if ( ndp == dp ) + { + ndp = dp + 4096; + def = realloc(def, dp + 4096); + } + v1 >>= 1; + if ( !v1 ) + { + v1 = 2147483648; + v2 = cp++; + if ( cp == ncp ) + { + ncp = v2 + 1025; + cmd = realloc(cmd, 4 * (v2 + 1025)); + } + cmd[cp] = 0; + } + a4 = v7; + a3 = v8; + } + v3 = v0 - a3 - 1; + a3 = v0 - a3 - 1; + v5 = a4; + if ( a4 > 0x11 ) + { + pol[pp++] = v3; + def[dp++] = v5 - 18; + if ( ndp == dp ) + { + ndp = dp + 4096; + def = realloc(def, dp + 4096); + } + } + else + { + pol[pp++] = v3 | (((short)a4 - 2) << 12); + } + if ( npp == pp ) + { + npp = pp + 4096; + pol = realloc(pol, 2 * (pp + 4096)); + } + v0 += a4; + } + v1 >>= 1; + if ( !v1 ) + { + v1 = 2147483648; + v4 = cp++; + if ( cp == ncp ) + { + ncp = v4 + 1025; + cmd = realloc(cmd, 4 * (v4 + 1025)); + } + cmd[cp] = 0; + } + } + if ( v1 != 0x80000000 ) + ++cp; + //fprintf(stderr, "IN=%d OUT=%d\n", insize, dp + 2 * pp + 4 * cp + 16); +} + +void search(unsigned int a1, int a2, int *a3, unsigned int *a4) +{ + unsigned int v4; // ebx + unsigned int v5; // esi + unsigned int *v6; // edi + unsigned int v7; // [esp+Ch] [ebp-10h] + int v8; // [esp+14h] [ebp-8h] + unsigned int v9; // [esp+18h] [ebp-4h] + + v4 = 3; + v5 = 0; + if ( a1 > 0x1000 ) + v5 = a1 - 4096; + v9 = 273; + if ( a2 - a1 <= 0x111 ) + v9 = a2 - a1; + if ( v9 > 2 ) + { + while ( a1 > v5 ) + { + v7 = mischarsearch(&bz[a1], v4, &bz[v5], v4 + a1 - v5); + if ( v7 >= a1 - v5 ) + break; + for ( ; v9 > v4; ++v4 ) + { + if ( bz[v4 + v5 + v7] != bz[v4 + a1] ) + break; + } + if ( v9 == v4 ) + { + *a3 = v7 + v5; + goto LABEL_17; + } + v8 = v5 + v7; + ++v4; + v5 += v7 + 1; + } + *a3 = v8; + if ( v4 > 3 ) + { + --v4; +LABEL_17: + *a4 = v4; + return; + } + v6 = a4; + } + else + { + *a4 = 0; + v6 = a3; + } + *v6 = 0; +} + +int mischarsearch(unsigned char *pattern, int patternlen, unsigned char *data, int datalen) +{ + int result; // eax + int i; // ebx + int v6; // eax + int j; // ecx + + result = datalen; + if ( patternlen <= datalen ) + { + initskip(pattern, patternlen); + for ( i = patternlen - 1; ; i += v6 ) + { + if ( pattern[patternlen - 1] == data[i] ) + { + --i; + j = patternlen - 2; + if ( patternlen - 2 < 0 ) + return i + 1; + while ( pattern[j] == data[i] ) + { + --i; + if ( --j < 0 ) + return i + 1; + } + v6 = patternlen - j; + if ( skip[data[i]] > patternlen - j ) + v6 = skip[data[i]]; + } + else + { + v6 = skip[data[i]]; + } + } + } + return result; +} + +void initskip(unsigned char *pattern, int len) +{ + for (int i = 0; i < 256; i++) + skip[i] = len; + + for (int i = 0; i < len; i++) + skip[pattern[i]] = len - i - 1; +} + +void writeshort(short val) +{ + fputc((val & 0xff00) >> 8, fp); + fputc((val & 0x00ff) >> 0, fp); +} + +void writeint4(int val) +{ + fputc((val & 0x00ff000000) >> 24, fp); + fputc((val & 0x0000ff0000) >> 16, fp); + fputc((val & 0x000000ff00) >> 8, fp); + fputc((val & 0x00000000ff) >> 0, fp); +} diff --git a/tools/find_bogus_functions.py b/tools/find_bogus_functions.py deleted file mode 100755 index bc95fa5c5a..0000000000 --- a/tools/find_bogus_functions.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/python3 - -import os -import re - -script_dir = os.path.dirname(os.path.realpath(__file__)) -asm_dir = script_dir + "/../asm/" - -js = set() -jals = set() -bs = set() -bals = set() - -debug = False - -renames = [] - - -def dprint(string): - if debug: - print(string) - - -def scan_file(path): - with open(path) as f: - file_lines = f.readlines() - - for line in file_lines: - line = line.strip() - if re.findall(r'\sj\s+.*', line): - target = line.split()[-1] - js.add(target) - if re.findall(r'\sjal\s+.*', line): - target = line.split()[-1] - jals.add(target) - if re.findall(r'\sb.*', line): - target = line.split()[-1] - bs.add(target) - if re.findall(r'\sbal\s+.*', line): - target = line.split()[-1] - bals.add(target) - - -def get_linked_flags(label): - return (label in js or label in bs), (label in jals or label in bals) - - -def process_file(path): - print("Processing " + path) - with open(path) as fi: - file_lines = fi.readlines() - - skip_next = False - to_delete = [] - for i, line in enumerate(file_lines): - if skip_next: - skip_next = False - continue - line = line.strip() - - if line.endswith(":") and not line.startswith(".L"): - func_preamble = line.startswith("func_") - label = line[:-1] - linked_to, linked_al_to = get_linked_flags(label) - - if func_preamble: - # func_12345689 - - # Delete redundant label below - # if file_lines[i + 1].strip() == ".L" + label[5:13] + ":": - # to_delete.append(i + 1) - # skip_next = True - - if linked_al_to: - # Seems to be legit. Do nothing for now - continue - elif linked_to: - # j / b 'd to, rename as label - renames.append((label, ".L" + label[5:])) - else: - # Not referenced by anything. Delete - to_delete.append(i) - - if len(to_delete) > 0: - print("\tDeleting " + str(len(to_delete)) + " lines...") - for i in reversed(to_delete): - del file_lines[i] - with open(path, "w") as fo: - fo.writelines(file_lines) - - -# Collect all branches and jumps -for root, dirs, files in os.walk(asm_dir): - for file in files: - if file.endswith(".s"): - scan_file(os.path.join(root, file)) - -print("Scanned all files") - -# Process files -for root, dirs, files in os.walk(asm_dir): - for file in files: - if file.endswith(".s") and "boot" not in file: - process_file(os.path.join(root, file)) - -if len(renames) > 0: - print("Renaming " + str(len(renames)) + " labels...") - for root, dirs, files in os.walk(asm_dir): - for file in files: - if file.endswith(".s"): - file_path = os.path.join(root, file) - with open(file_path) as f: - orig_file_text = f.read() - file_text = orig_file_text - for rename in renames: - file_text = file_text.replace(rename[0], rename[1]) - if file_text != orig_file_text: - with open(file_path, "w") as f: - f.write(file_text) diff --git a/tools/find_yay0_size b/tools/find_yay0_size deleted file mode 100755 index b37664af3f..0000000000 Binary files a/tools/find_yay0_size and /dev/null differ diff --git a/tools/find_yay0_size.c b/tools/find_yay0_size.c deleted file mode 100644 index ec1175cbf4..0000000000 --- a/tools/find_yay0_size.c +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define U32(s) ((uint32_t)(*(s) << 24 | *((s) + 1) << 16 | *((s) + 2) << 8 | *((s) + 3))) -#define ALIGN(n, s) ((n) + (s)-1) & ~((s)-1) - -#define ERROR_UNSUPPORTED -1 -#define ERROR_CORRUPTED -2 -#define ERROR_UNRECOGNIZED -3 -#define ERROR_MEMORY -4 -#define ERROR_BACKREFERENCE_TOO_DISTANT -5 -#define ERROR_OVERFLOW -6 - - -uint8_t yay0_magic[] = {0x59, 0x61, 0x79, 0x30}; - -typedef struct __attribute__ ((packed)) yay0_header -{ - uint8_t magic[4]; - uint32_t size; - uint32_t count_offset; - uint32_t data_offset; -} yay0_header_t; - -typedef struct -{ - uint8_t *control; - uint8_t *count; - uint8_t *data; - int64_t error; -} yay0_info; - -yay0_info *yay0_decompress(void* _in, void** _out, int64_t stop_after_size); - -size_t get_file_size(char *filename) -{ - struct stat file_stat; - if(stat(filename, &file_stat) < 0) - { - printf("Failed to get file size!\n"); - exit(1); - } - - return file_stat.st_size; -} - -int main(int argc, char **argv) -{ - if(argc < 2) - return 1; - FILE *rom_f = fopen(argv[1], "rb"); - if(!rom_f) - printf("Failed to open input file...\n"); - size_t romSize = get_file_size(argv[1]); - uint8_t *romData = malloc(romSize); - fread(romData, 1, romSize, rom_f); - - for(int i = 0; i < romSize - 4; i++) - { - if(!memcmp(yay0_magic, &romData[i], 4)) - { - yay0_header_t *header = (yay0_header_t *)&romData[i]; - size_t decomp_size = U32((uint8_t *)&header->size); - uint8_t *dest = NULL; - yay0_info *info = yay0_decompress(&romData[i], (void **)&dest, decomp_size); - free(dest); - uintptr_t start = (uintptr_t)i; - uintptr_t end = ((uintptr_t)info->data - (uintptr_t)&romData[i]) + i; - printf(" - [0x%X, 0x%0X, \"COMPRESSED.YAY\", \"yay_%x_len_%x\"]\n", start, ALIGN(end, 2), start, ALIGN(end, 2) - start); - } - } - free(romData); - fclose(rom_f); - - return 0; -} - -yay0_info *yay0_decompress(void* _in, void** _out, int64_t stop_after_size) -{ - yay0_info *info = malloc(sizeof(yay0_info)); - yay0_header_t* header = (yay0_header_t*)_in; - if (memcmp(yay0_magic, &header->magic[0], 4)) - { - info->error = ERROR_UNRECOGNIZED; - return info; - } - - uint32_t total_size = U32((uint8_t *)&header->size); - if (total_size == 0) { - return info; - } - if (stop_after_size && total_size > stop_after_size) { - total_size = stop_after_size; - } - - *_out = malloc(total_size); - if (!*_out) - { - info->error = ERROR_MEMORY; - return info; - } - - uint32_t count_offset = U32((uint8_t *)&header->count_offset); - uint32_t data_offset = U32((uint8_t *)&header->data_offset); - - info->control = (uint8_t*)(_in + sizeof(yay0_header_t)); - info->count = (uint8_t*)_in + count_offset; - info->data = (uint8_t*)_in + data_offset; - uint8_t* out_stream = (uint8_t*)*_out; - - uint32_t bytes_written = 0; - uint8_t control_bits_remaining = 0; - uint8_t control_byte; - - while (bytes_written < total_size) { - - if (control_bits_remaining == 0) { - control_byte = *(info->control++); - control_bits_remaining = 8; - } - - if ((control_byte & 0x80) != 0) { - out_stream[bytes_written] = *(info->data++); - bytes_written++; - - } else { - uint16_t nr = (*(info->count++) << 8); - nr |= *(info->count++); - uint16_t r = (nr & 0x0FFF) + 1; - uint16_t n = (nr & 0xF000) >> 12; - if (n == 0) - n = *(info->data++) + 0x12; // TODO is this really read from the data stream? (not the count stream?) - else - n += 2; - - if (r > bytes_written) - { - info->error = ERROR_BACKREFERENCE_TOO_DISTANT; - return info; - } - - if (bytes_written + n > total_size && stop_after_size == total_size) - { - info->error = ERROR_OVERFLOW; - return info; - } - - for (; n > 0; n--) - { - out_stream[bytes_written] = out_stream[bytes_written - r]; - bytes_written++; - } - } - - control_byte <<= 1; - control_bits_remaining--; - } - - return info; -} \ No newline at end of file diff --git a/tools/glabel.py b/tools/glabel.py deleted file mode 100755 index 5911b6404e..0000000000 --- a/tools/glabel.py +++ /dev/null @@ -1,22 +0,0 @@ -import os -import re - -def replace_func(match): - match = match.group() - - if match.startswith("."): - return match - return "glabel " + match[:-1] - -for root, dirs, files in os.walk("asm"): - for file in files: - for file in files: - if file.endswith(".s"): - with open(os.path.join(root, file)) as f: - old_file_text = f.read() - - new_file_text = re.sub(".*:", replace_func, old_file_text) - - if old_file_text != new_file_text: - with open(os.path.join(root, file), "w", newline="\n") as f: - f.write(new_file_text) diff --git a/tools/n64splat b/tools/n64splat index 7abe8ac584..1d2c07c0a5 160000 --- a/tools/n64splat +++ b/tools/n64splat @@ -1 +1 @@ -Subproject commit 7abe8ac584c09cd1da6cdd5919b1904edcb7126a +Subproject commit 1d2c07c0a5749289d08aa991ab15ef356ddda96c diff --git a/tools/old/fix_asm.py b/tools/old/fix_asm.py deleted file mode 100755 index fb2b433b79..0000000000 --- a/tools/old/fix_asm.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/python3 - -import os -import re - -script_dir = os.path.dirname(os.path.realpath(__file__)) -asm_dir = script_dir + "/asm/" - - -def replace_move_daddu(match): - match = match.group() - match = re.sub("\\s+", " ", match) - match_split = match.split(" ") - ret = "daddu " + match_split[1] + " " + match_split[2] + ", $zero" - return ret - - -def replace_move_addu(match): - match = match.group() - match = re.sub("\\s+", " ", match) - match_split = match.split(" ") - ret = "addu " + match_split[1] + " " + match_split[2] + ", $zero" - return ret - - -def replace_move_or(match): - match = match.group() - match = re.sub("\\s+", " ", match) - match_split = match.split(" ") - ret = "or " + match_split[1] + " " + match_split[2] + ", $zero" - return ret - - -adds = ["4a140", "4a1b0"] -ors = ["4a360"] - -range_start = int("3bde0", 16) -range_end = int("48be0", 16) - -for root, dirs, files in os.walk(asm_dir): - for file in files: - if file.endswith(".s"): - dumb_split = file.split("_") - if len(dumb_split) > 2: - file_num = dumb_split[1] - try: - test = int(file_num, 16) - except ValueError: - file_num = "" - else: - file_num = "" - with open(os.path.join(root, file)) as f: - file_text_orig = f.read() - file_text = file_text_orig - - # Fix instructions - if file == "boot.s" or file_num in ors: - file_text = re.sub("move\\s+\\$.+,\\s\\$.+", replace_move_or, file_text) - elif file_num != "" and ((range_start <= int(file_num, 16) <= range_end) or file_num in adds): - file_text = re.sub("move\\s+\\$.+,\\s\\$.+", replace_move_addu, file_text) - else: - file_text = re.sub("move\\s+\\$.+,\\s\\$.+", replace_move_daddu, file_text) - - if file_text != file_text_orig: - with open(os.path.join(root, file), "w") as f: - f.write(file_text) diff --git a/tools/old/reg_convert.py b/tools/old/reg_convert.py deleted file mode 100755 index 94f58d2fa2..0000000000 --- a/tools/old/reg_convert.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/python3 -import fileinput -import os -import re - -script_dir = os.path.dirname(os.path.realpath(__file__)) -asm_dir = script_dir + "/asm/" - -regs = ["zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "s0", - "s1", "s2", "s3", "s4", "s5", "s6", "s7", "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra"] - - -for line in fileinput.input(): - for reg in regs: - regex = re.compile("\\$" + reg) - line = re.sub(regex, "$" + str(regs.index(reg)), line) - print(line.rstrip()) diff --git a/tools/postprocess.py b/tools/postprocess.py deleted file mode 100755 index 491b89d2e2..0000000000 --- a/tools/postprocess.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python3 -import fileinput -import os - -script_dir = os.path.dirname(os.path.realpath(__file__)) -asm_dir = script_dir + "/../asm/" - - -def tohex(val, nbits): - return hex((val + (1 << nbits)) % (1 << nbits)) - - -def gen_lui_addiu(line): - line = line.strip() - line_bits = line.split("\t")[1] - reg, addr = line_bits.split(",") - upper_addr = tohex(int(addr) >> 16, 16) - lower_addr = tohex(int(addr) & 0xFFFF, 16) - ret = "lui\t" + reg + "," + upper_addr + "\n" + \ - "addiu\t" + reg + ", $zero, " + lower_addr - return ret - - -def main(): - skip_next = False - for line in fileinput.input(): - line = line.strip() - if skip_next: - skip_next = False - continue - - # Don't print the line after this - if line == "#NO_APP": - skip_next = True - - # Transform la - if line.startswith("la\t"): - print(gen_lui_addiu(line)) - continue - - print(line) - - -if __name__ == '__main__': - main() diff --git a/tools/splat.yaml b/tools/splat.yaml index 19fdfb9b23..35265fc50d 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -516,253 +516,253 @@ segments: - [0xFAD8F0, "bin", "SMW_Remix_2F"] - [0xFADE70, "bin", "New_Partner_82"] # BGM end - [0xFAE860, "bin"] - - [0x19E09A8, "bin", "Yay0_19e09a8_len_1206"] - - [0x19E1390, "bin", "Yay0_19e1390_len_806"] - - [0x19E1888, "bin", "Yay0_19e1888_len_2324"] - - [0x19E2330, "bin", "Yay0_19e2330_len_cc0"] - - [0x19E2DE0, "bin", "Yay0_19e2de0_len_1206"] - - [0x19E3208, "bin", "Yay0_19e3208_len_9a6"] - - [0x19E3BA8, "bin", "Yay0_19e3ba8_len_456"] - - [0x19E3FD8, "bin", "Yay0_19e3fd8_len_4024"] - - [0x19E4828, "bin", "Yay0_19e4828_len_3c0"] - - [0x19E4BE0, "bin", "Yay0_19e4be0_len_1416"] - - [0x19E5758, "bin", "Yay0_19e5758_len_802"] - - [0x19E5950, "bin", "Yay0_19e5950_len_22a0"] - - [0x19E62A0, "bin", "Yay0_19e62a0_len_512"] + - [0x19E09A8, "Yay0"] + - [0x19E1390, "Yay0"] + - [0x19E1888, "Yay0"] + - [0x19E2330, "Yay0"] + - [0x19E2DE0, "Yay0"] + - [0x19E3208, "Yay0"] + - [0x19E3BA8, "Yay0"] + - [0x19E3FD8, "Yay0"] + - [0x19E4828, "Yay0"] + - [0x19E4BE0, "Yay0"] + - [0x19E5758, "Yay0"] + - [0x19E5950, "Yay0"] + - [0x19E62A0, "Yay0"] - [0x19E67B2, "bin"] - - [0x19E6B60, "bin", "Yay0_19e6b60_len_1406"] - - [0x19E7528, "bin", "Yay0_19e7528_len_8256"] - - [0x19E9778, "bin", "Yay0_19e9778_len_2800"] - - [0x19EAF38, "bin", "Yay0_19eaf38_len_40c0"] - - [0x19EC4E0, "bin", "Yay0_19ec4e0_len_1910"] - - [0x19EDD30, "bin", "Yay0_19edd30_len_2204"] - - [0x19EEB18, "bin", "Yay0_19eeb18_len_10062"] - - [0x19F0070, "bin", "Yay0_19f0070_len_158c"] - - [0x19F15A0, "bin", "Yay0_19f15a0_len_2252"] - - [0x19F26D8, "bin", "Yay0_19f26d8_len_5102"] - - [0x19F5390, "bin", "Yay0_19f5390_len_2002"] - - [0x19F7398, "bin", "Yay0_19f7398_len_8024"] - - [0x19FA128, "bin", "Yay0_19fa128_len_4ac6"] - - [0x19FCAE8, "bin", "Yay0_19fcae8_len_2502"] - - [0x19FED70, "bin", "Yay0_19fed70_len_200004"] - - [0x1A00958, "bin", "Yay0_1a00958_len_24a2"] - - [0x1A02D00, "bin", "Yay0_1a02d00_len_4000"] - - [0x1A04400, "bin", "Yay0_1a04400_len_114c"] - - [0x1A05550, "bin", "Yay0_1a05550_len_2280"] - - [0x1A06390, "bin", "Yay0_1a06390_len_c04"] - - [0x1A06F98, "bin", "Yay0_1a06f98_len_1066"] - - [0x1A07B68, "bin", "Yay0_1a07b68_len_8092"] - - [0x1A0A0A0, "bin", "Yay0_1a0a0a0_len_c46"] - - [0x1A0ACC8, "bin", "Yay0_1a0acc8_len_1300"] - - [0x1A0B780, "bin", "Yay0_1a0b780_len_85c"] - - [0x1A0BBE0, "bin", "Yay0_1a0bbe0_len_4000"] - - [0x1A0C000, "bin", "Yay0_1a0c000_len_438"] - - [0x1A0C438, "bin", "Yay0_1a0c438_len_842"] - - [0x1A0C860, "bin", "Yay0_1a0c860_len_1186"] - - [0x1A0D1E8, "bin", "Yay0_1a0d1e8_len_406"] - - [0x1A0D5B0, "bin", "Yay0_1a0d5b0_len_840"] - - [0x1A0D970, "bin", "Yay0_1a0d970_len_268e"] - - [0x1A0EF00, "bin", "Yay0_1a0ef00_len_11020"] - - [0x1A13920, "bin", "Yay0_1a13920_len_404c"] - - [0x1A15850, "bin", "Yay0_1a15850_len_83a4"] - - [0x1A183F8, "bin", "Yay0_1a183f8_len_2404"] - - [0x1A1A608, "bin", "Yay0_1a1a608_len_41e2"] - - [0x1A1C5E8, "bin", "Yay0_1a1c5e8_len_1202"] - - [0x1A1D6D0, "bin", "Yay0_1a1d6d0_len_2028"] - - [0x1A1E478, "bin", "Yay0_1a1e478_len_1306"] - - [0x1A1F370, "bin", "Yay0_1a1f370_len_2048c"] - - [0x1A226B0, "bin", "Yay0_1a226b0_len_4908"] - - [0x1A249B8, "bin", "Yay0_1a249b8_len_1644"] - - [0x1A25E78, "bin", "Yay0_1a25e78_len_2186"] - - [0x1A27FF0, "bin", "Yay0_1a27ff0_len_800a"] - - [0x1A28BE0, "bin", "Yay0_1a28be0_len_1400"] - - [0x1A29680, "bin", "Yay0_1a29680_len_2862"] - - [0x1A2BC68, "bin", "Yay0_1a2bc68_len_4112"] - - [0x1A2E120, "bin", "Yay0_1a2e120_len_12d8"] - - [0x1A2F3F8, "bin", "Yay0_1a2f3f8_len_10c06"] - - [0x1A31D18, "bin", "Yay0_1a31d18_len_22a6"] - - [0x1A33AB0, "bin", "Yay0_1a33ab0_len_4106"] - - [0x1A35BB8, "bin", "Yay0_1a35bb8_len_2006"] - - [0x1A369A8, "bin", "Yay0_1a369a8_len_9600"] - - [0x1A39600, "bin", "Yay0_1a39600_len_2014"] - - [0x1A3B018, "bin", "Yay0_1a3b018_len_4300"] - - [0x1A3C310, "bin", "Yay0_1a3c310_len_3cc2"] - - [0x1A3FCC8, "bin", "Yay0_1a3fcc8_len_40314"] - - [0x1A423D8, "bin", "Yay0_1a423d8_len_4822"] - - [0x1A449C0, "bin", "Yay0_1a449c0_len_2422"] - - [0x1A46568, "bin", "Yay0_1a46568_len_9212"] - - [0x1A49340, "bin", "Yay0_1a49340_len_2c88"] - - [0x1A4AC88, "bin", "Yay0_1a4ac88_len_5362"] - - [0x1A4D7E8, "bin", "Yay0_1a4d7e8_len_2006"] - - [0x1A4E028, "bin", "Yay0_1a4e028_len_1a56"] - - [0x1A4FA60, "bin", "Yay0_1a4fa60_len_10190"] - - [0x1A531D0, "bin", "Yay0_1a531d0_len_c08"] - - [0x1A53D48, "bin", "Yay0_1a53d48_len_4032"] - - [0x1A56C80, "bin", "Yay0_1a56c80_len_8358"] - - [0x1A58F58, "bin", "Yay0_1a58f58_len_20a4"] - - [0x1A5A5A8, "bin", "Yay0_1a5a5a8_len_20a14"] - - [0x1A62B40, "bin", "Yay0_1a62b40_len_40b6"] - - [0x1A641F8, "bin", "Yay0_1a641f8_len_2602"] - - [0x1A666F0, "bin", "Yay0_1a666f0_len_8800"] - - [0x1A68870, "bin", "Yay0_1a68870_len_460a"] - - [0x1A6C630, "bin", "Yay0_1a6c630_len_118c"] - - [0x1A6D5A0, "bin", "Yay0_1a6d5a0_len_2a4c"] - - [0x1A6EF50, "bin", "Yay0_1a6ef50_len_100ae"] - - [0x1A70FF0, "bin", "Yay0_1a70ff0_len_4000"] - - [0x1A74FC0, "bin", "Yay0_1a74fc0_len_803a"] - - [0x1A78A40, "bin", "Yay0_1a78a40_len_1100"] - - [0x1A79900, "bin", "Yay0_1a79900_len_4698"] - - [0x1A7D798, "bin", "Yay0_1a7d798_len_2804"] - - [0x1A7EEA0, "bin", "Yay0_1a7eea0_len_158"] - - [0x1A7EFD8, "bin", "Yay0_1a7efd8_len_81002"] - - [0x1A83450, "bin", "Yay0_1a83450_len_4226"] - - [0x1A85668, "bin", "Yay0_1a85668_len_2910"] - - [0x1A87958, "bin", "Yay0_1a87958_len_8680"] - - [0x1A8BF98, "bin", "Yay0_1a8bf98_len_4020"] - - [0x1A8FE28, "bin", "Yay0_1a8fe28_len_10096"] - - [0x1A93EA0, "bin", "Yay0_1a93ea0_len_4102"] - - [0x1A94188, "bin", "Yay0_1a94188_len_476"] - - [0x1A94480, "bin", "Yay0_1a94480_len_226"] - - [0x1A946A8, "bin", "Yay0_1a946a8_len_956"] - - [0x1A94A00, "bin", "Yay0_1a94a00_len_456"] - - [0x1A94C58, "bin", "Yay0_1a94c58_len_8184"] - - [0x1A98D98, "bin", "Yay0_1a98d98_len_3264"] - - [0x1A9BA80, "bin", "Yay0_1a9ba80_len_4168"] - - [0x1A9DB68, "bin", "Yay0_1a9db68_len_20004"] - - [0x1AA0048, "bin", "Yay0_1aa0048_len_692"] - - [0x1AA0698, "bin", "Yay0_1aa0698_len_1000"] - - [0x1AA1008, "bin", "Yay0_1aa1008_len_6d54"] - - [0x1AA6D58, "bin", "Yay0_1aa6d58_len_90a4"] - - [0x1AAD600, "bin", "Yay0_1aad600_len_109f0"] - - [0x1AB1BF0, "bin", "Yay0_1ab1bf0_len_2004"] - - [0x1AB2368, "bin", "Yay0_1ab2368_len_8086"] - - [0x1ABA290, "bin", "Yay0_1aba290_len_41422"] - - [0x1AC14A8, "bin", "Yay0_1ac14a8_len_2902"] - - [0x1AC3910, "bin", "Yay0_1ac3910_len_8488"] - - [0x1ACBC98, "bin", "Yay0_1acbc98_len_4042"] - - [0x1ACE058, "bin", "Yay0_1ace058_len_1902"] - - [0x1ACF910, "bin", "Yay0_1acf910_len_106c8"] - - [0x1AD06D8, "bin", "Yay0_1ad06d8_len_904"] - - [0x1AD0B98, "bin", "Yay0_1ad0b98_len_1400"] - - [0x1AD1E90, "bin", "Yay0_1ad1e90_len_2146"] - - [0x1AD2348, "bin", "Yay0_1ad2348_len_4b2"] - - [0x1AD27F8, "bin", "Yay0_1ad27f8_len_800"] - - [0x1AD28A8, "bin", "Yay0_1ad28a8_len_4446"] - - [0x1AD44F0, "bin", "Yay0_1ad44f0_len_304"] - - [0x1AD4758, "bin", "Yay0_1ad4758_len_1080"] - - [0x1AD57C0, "bin", "Yay0_1ad57c0_len_880c"] - - [0x1AD9D50, "bin", "Yay0_1ad9d50_len_2082"] - - [0x1ADA498, "bin", "Yay0_1ada498_len_4b26"] - - [0x1ADCFC0, "bin", "Yay0_1adcfc0_len_22024"] - - [0x1AE2168, "bin", "Yay0_1ae2168_len_e96"] - - [0x1AE2EA0, "bin", "Yay0_1ae2ea0_len_4058"] - - [0x1AE6A58, "bin", "Yay0_1ae6a58_len_9524"] - - [0x1AEB778, "bin", "Yay0_1aeb778_len_14802"] - - [0x1AF4958, "bin", "Yay0_1af4958_len_8202"] - - [0x1AFCB18, "bin", "Yay0_1afcb18_len_3442"] - - [0x1AFF748, "bin", "Yay0_1aff748_len_100000"] - - [0x1B00640, "bin", "Yay0_1b00640_len_118a"] - - [0x1B01390, "bin", "Yay0_1b01390_len_c04"] - - [0x1B01C08, "bin", "Yay0_1b01c08_len_2120"] - - [0x1B02128, "bin", "Yay0_1b02128_len_844"] - - [0x1B02970, "bin", "Yay0_1b02970_len_1004"] - - [0x1B03118, "bin", "Yay0_1b03118_len_c04"] - - [0x1B03C18, "bin", "Yay0_1b03c18_len_41e2"] - - [0x1B045E8, "bin", "Yay0_1b045e8_len_a12"] - - [0x1B04FC0, "bin", "Yay0_1b04fc0_len_1012"] - - [0x1B05998, "bin", "Yay0_1b05998_len_2400"] - - [0x1B06C88, "bin", "Yay0_1b06c88_len_1046"] - - [0x1B07C48, "bin", "Yay0_1b07c48_len_8034"] - - [0x1B09440, "bin", "Yay0_1b09440_len_228e"] - - [0x1B0B290, "bin", "Yay0_1b0b290_len_90c"] - - [0x1B0B9A0, "bin", "Yay0_1b0b9a0_len_4448"] - - [0x1B0C548, "bin", "Yay0_1b0c548_len_ab4"] - - [0x1B0CAC0, "bin", "Yay0_1b0cac0_len_1130"] - - [0x1B0D130, "bin", "Yay0_1b0d130_len_2a4c"] - - [0x1B0EB80, "bin", "Yay0_1b0eb80_len_1043e"] - - [0x1B10CC0, "bin", "Yay0_1b10cc0_len_2120"] - - [0x1B129A0, "bin", "Yay0_1b129a0_len_1444"] - - [0x1B13548, "bin", "Yay0_1b13548_len_4016"] - - [0x1B16420, "bin", "Yay0_1b16420_len_1104"] - - [0x1B17128, "bin", "Yay0_1b17128_len_814"] - - [0x1B17840, "bin", "Yay0_1b17840_len_8316"] - - [0x1B19318, "bin", "Yay0_1b19318_len_2020"] - - [0x1B1A030, "bin", "Yay0_1b1a030_len_18c6"] - - [0x1B1B8C8, "bin", "Yay0_1b1b8c8_len_402"] - - [0x1B1BC88, "bin", "Yay0_1b1bc88_len_4316"] - - [0x1B1C7A0, "bin", "Yay0_1b1c7a0_len_808"] - - [0x1B1CD28, "bin", "Yay0_1b1cd28_len_21040"] - - [0x1B21C48, "bin", "Yay0_1b21c48_len_2290"] - - [0x1B23290, "bin", "Yay0_1b23290_len_414c"] - - [0x1B253E0, "bin", "Yay0_1b253e0_len_241c"] - - [0x1B26660, "bin", "Yay0_1b26660_len_8192"] - - [0x1B283F8, "bin", "Yay0_1b283f8_len_1c02"] - - [0x1B29C60, "bin", "Yay0_1b29c60_len_2284"] - - [0x1B2A688, "bin", "Yay0_1b2a688_len_1166"] - - [0x1B2B3E8, "bin", "Yay0_1b2b3e8_len_4810"] - - [0x1B2C8D8, "bin", "Yay0_1b2c8d8_len_1722"] - - [0x1B2D7B0, "bin", "Yay0_1b2d7b0_len_2006"] - - [0x1B2E328, "bin", "Yay0_1b2e328_len_c52"] - - [0x1B2ED60, "bin", "Yay0_1b2ed60_len_1218"] - - [0x1B2FA18, "bin", "Yay0_1b2fa18_len_10002"] - - [0x1B31A18, "bin", "Yay0_1b31a18_len_25e2"] - - [0x1B33000, "bin", "Yay0_1b33000_len_4096"] - - [0x1B34098, "bin", "Yay0_1b34098_len_920"] - - [0x1B34928, "bin", "Yay0_1b34928_len_2d4"] - - [0x1B34C00, "bin", "Yay0_1b34c00_len_107e"] - - [0x1B35480, "bin", "Yay0_1b35480_len_2040"] - - [0x1B36440, "bin", "Yay0_1b36440_len_8306"] - - [0x1B38748, "bin", "Yay0_1b38748_len_1894"] - - [0x1B39A98, "bin", "Yay0_1b39a98_len_2062"] - - [0x1B3A2E8, "bin", "Yay0_1b3a2e8_len_816"] - - [0x1B3A818, "bin", "Yay0_1b3a818_len_4482"] - - [0x1B3C488, "bin", "Yay0_1b3c488_len_a44"] - - [0x1B3CAC8, "bin", "Yay0_1b3cac8_len_1012"] - - [0x1B3D0A0, "bin", "Yay0_1b3d0a0_len_91a"] - - [0x1B3D920, "bin", "Yay0_1b3d920_len_205c"] - - [0x1B3F060, "bin", "Yay0_1b3f060_len_40008"] - - [0x1B40048, "bin", "Yay0_1b40048_len_714"] - - [0x1B40720, "bin", "Yay0_1b40720_len_904e"] - - [0x1B49570, "bin", "Yay0_1b49570_len_4288"] - - [0x1B4C3E8, "bin", "Yay0_1b4c3e8_len_1c12"] - - [0x1B4DEA0, "bin", "Yay0_1b4dea0_len_2116"] - - [0x1B4FD98, "bin", "Yay0_1b4fd98_len_10040"] - - [0x1B50CD8, "bin", "Yay0_1b50cd8_len_1302"] - - [0x1B51B08, "bin", "Yay0_1b51b08_len_4052"] - - [0x1B54258, "bin", "Yay0_1b54258_len_8082"] - - [0x1B580A0, "bin", "Yay0_1b580a0_len_2242"] - - [0x1B5A248, "bin", "Yay0_1b5a248_len_1980"] - - [0x1B5BB88, "bin", "Yay0_1b5bb88_len_4406"] - - [0x1B5CC90, "bin", "Yay0_1b5cc90_len_2168"] - - [0x1B5E968, "bin", "Yay0_1b5e968_len_482"] - - [0x1B5ED88, "bin", "Yay0_1b5ed88_len_20040"] - - [0x1B608C0, "bin", "Yay0_1b608c0_len_2534"] - - [0x1B625F8, "bin", "Yay0_1b625f8_len_1202"] - - [0x1B633D0, "bin", "Yay0_1b633d0_len_4824"] - - [0x1B64878, "bin", "Yay0_1b64878_len_1786"] - - [0x1B657E0, "bin", "Yay0_1b657e0_len_808"] - - [0x1B65A08, "bin", "Yay0_1b65a08_len_444"] - - [0x1B65E50, "bin", "Yay0_1b65e50_len_2024"] - - [0x1B66238, "bin", "Yay0_1b66238_len_9542"] - - [0x1B69580, "bin", "Yay0_1b69580_len_4218"] - - [0x1B6C318, "bin", "Yay0_1b6c318_len_1c80"] - - [0x1B6DD98, "bin", "Yay0_1b6dd98_len_2046"] - - [0x1B6F150, "bin", "Yay0_1b6f150_len_10608"] - - [0x1B71618, "bin", "Yay0_1b71618_len_2882"] - - [0x1B72890, "bin", "Yay0_1b72890_len_1302"] - - [0x1B73B08, "bin", "Yay0_1b73b08_len_44b0"] - - [0x1B747B8, "bin", "Yay0_1b747b8_len_2800"] - - [0x1B76E30, "bin", "Yay0_1b76e30_len_808a"] - - [0x1B78EC0, "bin", "Yay0_1b78ec0_len_101c"] - - [0x1B79A20, "bin", "Yay0_1b79a20_len_508"] - - [0x1B79F08, "bin", "Yay0_1b79f08_len_2004"] - - [0x1B7AA08, "bin", "Yay0_1b7aa08_len_1000"] - - [0x1B7B008, "bin", "Yay0_1b7b008_len_b44"] - - [0x1B7BB50, "bin", "Yay0_1b7bb50_len_4424"] - - [0x1B7EC68, "bin", "Yay0_1b7ec68_len_1300"] - - [0x1B7FF48, "bin", "Yay0_1b7ff48_len_80086"] - - [0x1B81E88, "bin", "Yay0_1b81e88_len_2050"] - - [0x1B82058, "bin", "Yay0_1b82058_len_202"] + - [0x19E6B60, "Yay0"] + - [0x19E7528, "Yay0"] + - [0x19E9778, "Yay0"] + - [0x19EAF38, "Yay0"] + - [0x19EC4E0, "Yay0"] + - [0x19EDD30, "Yay0"] + - [0x19EEB18, "Yay0"] + - [0x19F0070, "Yay0"] + - [0x19F15A0, "Yay0"] + - [0x19F26D8, "Yay0"] + - [0x19F5390, "Yay0"] + - [0x19F7398, "Yay0"] + - [0x19FA128, "Yay0"] + - [0x19FCAE8, "Yay0"] + - [0x19FED70, "Yay0"] + - [0x1A00958, "Yay0"] + - [0x1A02D00, "Yay0"] + - [0x1A04400, "Yay0"] + - [0x1A05550, "Yay0"] + - [0x1A06390, "Yay0"] + - [0x1A06F98, "Yay0"] + - [0x1A07B68, "Yay0"] + - [0x1A0A0A0, "Yay0"] + - [0x1A0ACC8, "Yay0"] + - [0x1A0B780, "Yay0"] + - [0x1A0BBE0, "Yay0"] + - [0x1A0C000, "Yay0"] + - [0x1A0C438, "Yay0"] + - [0x1A0C860, "Yay0"] + - [0x1A0D1E8, "Yay0"] + - [0x1A0D5B0, "Yay0"] + - [0x1A0D970, "Yay0"] + - [0x1A0EF00, "Yay0"] + - [0x1A13920, "Yay0"] + - [0x1A15850, "Yay0"] + - [0x1A183F8, "Yay0"] + - [0x1A1A608, "Yay0"] + - [0x1A1C5E8, "Yay0"] + - [0x1A1D6D0, "Yay0"] + - [0x1A1E478, "Yay0"] + - [0x1A1F370, "Yay0"] + - [0x1A226B0, "Yay0"] + - [0x1A249B8, "Yay0"] + - [0x1A25E78, "Yay0"] + - [0x1A27FF0, "Yay0"] + - [0x1A28BE0, "Yay0"] + - [0x1A29680, "Yay0"] + - [0x1A2BC68, "Yay0"] + - [0x1A2E120, "Yay0"] + - [0x1A2F3F8, "Yay0"] + - [0x1A31D18, "Yay0"] + - [0x1A33AB0, "Yay0"] + - [0x1A35BB8, "Yay0"] + - [0x1A369A8, "Yay0"] + - [0x1A39600, "Yay0"] + - [0x1A3B018, "Yay0"] + - [0x1A3C310, "Yay0"] + - [0x1A3FCC8, "Yay0"] + - [0x1A423D8, "Yay0"] + - [0x1A449C0, "Yay0"] + - [0x1A46568, "Yay0"] + - [0x1A49340, "Yay0"] + - [0x1A4AC88, "Yay0"] + - [0x1A4D7E8, "Yay0"] + - [0x1A4E028, "Yay0"] + - [0x1A4FA60, "Yay0"] + - [0x1A531D0, "Yay0"] + - [0x1A53D48, "Yay0"] + - [0x1A56C80, "Yay0"] + - [0x1A58F58, "Yay0"] + - [0x1A5A5A8, "Yay0"] + - [0x1A62B40, "Yay0"] + - [0x1A641F8, "Yay0"] + - [0x1A666F0, "Yay0"] + - [0x1A68870, "Yay0"] + - [0x1A6C630, "Yay0"] + - [0x1A6D5A0, "Yay0"] + - [0x1A6EF50, "Yay0"] + - [0x1A70FF0, "Yay0"] + - [0x1A74FC0, "Yay0"] + - [0x1A78A40, "Yay0"] + - [0x1A79900, "Yay0"] + - [0x1A7D798, "Yay0"] + - [0x1A7EEA0, "Yay0"] + - [0x1A7EFD8, "Yay0"] + - [0x1A83450, "Yay0"] + - [0x1A85668, "Yay0"] + - [0x1A87958, "Yay0"] + - [0x1A8BF98, "Yay0"] + - [0x1A8FE28, "Yay0"] + - [0x1A93EA0, "Yay0"] + - [0x1A94188, "Yay0"] + - [0x1A94480, "Yay0"] + - [0x1A946A8, "Yay0"] + - [0x1A94A00, "Yay0"] + - [0x1A94C58, "Yay0"] + - [0x1A98D98, "Yay0"] + - [0x1A9BA80, "Yay0"] + - [0x1A9DB68, "Yay0"] + - [0x1AA0048, "Yay0"] + - [0x1AA0698, "Yay0"] + - [0x1AA1008, "Yay0"] + - [0x1AA6D58, "Yay0"] + - [0x1AAD600, "Yay0"] + - [0x1AB1BF0, "Yay0"] + - [0x1AB2368, "Yay0"] + - [0x1ABA290, "Yay0"] + - [0x1AC14A8, "Yay0"] + - [0x1AC3910, "Yay0"] + - [0x1ACBC98, "Yay0"] + - [0x1ACE058, "Yay0"] + - [0x1ACF910, "Yay0"] + - [0x1AD06D8, "Yay0"] + - [0x1AD0B98, "Yay0"] + - [0x1AD1E90, "Yay0"] + - [0x1AD2348, "Yay0"] + - [0x1AD27F8, "Yay0"] + - [0x1AD28A8, "Yay0"] + - [0x1AD44F0, "Yay0"] + - [0x1AD4758, "Yay0"] + - [0x1AD57C0, "Yay0"] + - [0x1AD9D50, "Yay0"] + - [0x1ADA498, "Yay0"] + - [0x1ADCFC0, "Yay0"] + - [0x1AE2168, "Yay0"] + - [0x1AE2EA0, "Yay0"] + - [0x1AE6A58, "Yay0"] + - [0x1AEB778, "Yay0"] + - [0x1AF4958, "Yay0"] + - [0x1AFCB18, "Yay0"] + - [0x1AFF748, "Yay0"] + - [0x1B00640, "Yay0"] + - [0x1B01390, "Yay0"] + - [0x1B01C08, "Yay0"] + - [0x1B02128, "Yay0"] + - [0x1B02970, "Yay0"] + - [0x1B03118, "Yay0"] + - [0x1B03C18, "Yay0"] + - [0x1B045E8, "Yay0"] + - [0x1B04FC0, "Yay0"] + - [0x1B05998, "Yay0"] + - [0x1B06C88, "Yay0"] + - [0x1B07C48, "Yay0"] + - [0x1B09440, "Yay0"] + - [0x1B0B290, "Yay0"] + - [0x1B0B9A0, "Yay0"] + - [0x1B0C548, "Yay0"] + - [0x1B0CAC0, "Yay0"] + - [0x1B0D130, "Yay0"] + - [0x1B0EB80, "Yay0"] + - [0x1B10CC0, "Yay0"] + - [0x1B129A0, "Yay0"] + - [0x1B13548, "Yay0"] + - [0x1B16420, "Yay0"] + - [0x1B17128, "Yay0"] + - [0x1B17840, "Yay0"] + - [0x1B19318, "Yay0"] + - [0x1B1A030, "Yay0"] + - [0x1B1B8C8, "Yay0"] + - [0x1B1BC88, "Yay0"] + - [0x1B1C7A0, "Yay0"] + - [0x1B1CD28, "Yay0"] + - [0x1B21C48, "Yay0"] + - [0x1B23290, "Yay0"] + - [0x1B253E0, "Yay0"] + - [0x1B26660, "Yay0"] + - [0x1B283F8, "Yay0"] + - [0x1B29C60, "Yay0"] + - [0x1B2A688, "Yay0"] + - [0x1B2B3E8, "Yay0"] + - [0x1B2C8D8, "Yay0"] + - [0x1B2D7B0, "Yay0"] + - [0x1B2E328, "Yay0"] + - [0x1B2ED60, "Yay0"] + - [0x1B2FA18, "Yay0"] + - [0x1B31A18, "Yay0"] + - [0x1B33000, "Yay0"] + - [0x1B34098, "Yay0"] + - [0x1B34928, "Yay0"] + - [0x1B34C00, "Yay0"] + - [0x1B35480, "Yay0"] + - [0x1B36440, "Yay0"] + - [0x1B38748, "Yay0"] + - [0x1B39A98, "Yay0"] + - [0x1B3A2E8, "Yay0"] + - [0x1B3A818, "Yay0"] + - [0x1B3C488, "Yay0"] + - [0x1B3CAC8, "Yay0"] + - [0x1B3D0A0, "Yay0"] + - [0x1B3D920, "Yay0"] + - [0x1B3F060, "Yay0"] + - [0x1B40048, "Yay0"] + - [0x1B40720, "Yay0"] + - [0x1B49570, "Yay0"] + - [0x1B4C3E8, "Yay0"] + - [0x1B4DEA0, "Yay0"] + - [0x1B4FD98, "Yay0"] + - [0x1B50CD8, "Yay0"] + - [0x1B51B08, "Yay0"] + - [0x1B54258, "Yay0"] + - [0x1B580A0, "Yay0"] + - [0x1B5A248, "Yay0"] + - [0x1B5BB88, "Yay0"] + - [0x1B5CC90, "Yay0"] + - [0x1B5E968, "Yay0"] + - [0x1B5ED88, "Yay0"] + - [0x1B608C0, "Yay0"] + - [0x1B625F8, "Yay0"] + - [0x1B633D0, "Yay0"] + - [0x1B64878, "Yay0"] + - [0x1B657E0, "Yay0"] + - [0x1B65A08, "Yay0"] + - [0x1B65E50, "Yay0"] + - [0x1B66238, "Yay0"] + - [0x1B69580, "Yay0"] + - [0x1B6C318, "Yay0"] + - [0x1B6DD98, "Yay0"] + - [0x1B6F150, "Yay0"] + - [0x1B71618, "Yay0"] + - [0x1B72890, "Yay0"] + - [0x1B73B08, "Yay0"] + - [0x1B747B8, "Yay0"] + - [0x1B76E30, "Yay0"] + - [0x1B78EC0, "Yay0"] + - [0x1B79A20, "Yay0"] + - [0x1B79F08, "Yay0"] + - [0x1B7AA08, "Yay0"] + - [0x1B7B008, "Yay0"] + - [0x1B7BB50, "Yay0"] + - [0x1B7EC68, "Yay0"] + - [0x1B7FF48, "Yay0"] + - [0x1B81E88, "Yay0"] + - [0x1B82058, "Yay0"] - [0x1B82202, "bin"] - [0x1E40000, "bin", "map_assets.fs"] # todo add fs support - [0x27FEE22, "bin"] diff --git a/tools/yay0_decompress b/tools/yay0_decompress deleted file mode 100755 index 74652f9f48..0000000000 Binary files a/tools/yay0_decompress and /dev/null differ diff --git a/tools/yay0_decompress.c b/tools/yay0_decompress.c deleted file mode 100644 index 3a89b2e6e7..0000000000 --- a/tools/yay0_decompress.c +++ /dev/null @@ -1,159 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define U32(s) ((uint32_t)(*(s) << 24 | *((s) + 1) << 16 | *((s) + 2) << 8 | *((s) + 3))) - -#define ERROR_UNSUPPORTED -1 -#define ERROR_CORRUPTED -2 -#define ERROR_UNRECOGNIZED -3 -#define ERROR_MEMORY -4 -#define ERROR_BACKREFERENCE_TOO_DISTANT -5 -#define ERROR_OVERFLOW -6 - -uint8_t yay0_magic[] = {0x59, 0x61, 0x79, 0x30}; - -typedef struct __attribute__ ((packed)) yay0_header -{ - uint8_t magic[4]; - uint32_t size; - uint32_t count_offset; - uint32_t data_offset; -} yay0_header_t; - -typedef struct -{ - uint8_t *control; - uint8_t *count; - uint8_t *data; - size_t error; -} yay0_info; - -size_t yay0_decompress(void* _in, void** _out, size_t stop_after_size); - -size_t get_file_size(char *filename) -{ - struct stat file_stat; - if(stat(filename, &file_stat) < 0) - { - printf("Failed to get file size!\n"); - exit(1); - } - - return file_stat.st_size; -} - -int main(int argc, char **argv) -{ - if(argc < 2) - return 1; - FILE *rom_f = fopen(argv[1], "rb"); - if(!rom_f) - { - printf("Failed to open input file...\n"); - return 1; - } - size_t romSize = get_file_size(argv[1]); - uint8_t *romData = malloc(romSize); - fread(romData, 1, romSize, rom_f); - yay0_header_t *header = (yay0_header_t *)romData; - size_t decomp_size = U32((uint8_t *)&header->size); - uint8_t *dest = NULL; - size_t bytes_written = yay0_decompress(&romData[0], (void **)&dest, decomp_size); - char *out_path = malloc(strlen(argv[1]) + strlen(".dec") + 2); - strcpy(out_path, argv[1]); - strcat(out_path, ".dec"); - FILE *out_f = fopen(out_path, "wb"); - fwrite(dest, 1, bytes_written, out_f); - free(dest); - free(romData); - fclose(rom_f); - fclose(out_f); - - return 0; -} - -size_t yay0_decompress(void* _in, void** _out, size_t stop_after_size) -{ - yay0_info *info = malloc(sizeof(yay0_info)); - yay0_header_t* header = (yay0_header_t*)_in; - - if (memcmp(yay0_magic, &header->magic[0], 4)) - return ERROR_UNRECOGNIZED; - - uint32_t total_size = U32((uint8_t *)&header->size); - if (total_size == 0) { - return 0; - } - if (stop_after_size && total_size > stop_after_size) { - total_size = stop_after_size; - } - - *_out = malloc(total_size); - if (!*_out) - return ERROR_MEMORY; - - uint32_t count_offset = U32((uint8_t *)&header->count_offset); - uint32_t data_offset = U32((uint8_t *)&header->data_offset); - - info->control = (uint8_t*)(_in + sizeof(yay0_header_t)); - info->count = (uint8_t*)_in + count_offset; - info->data = (uint8_t*)_in + data_offset; - uint8_t* out_stream = (uint8_t*)*_out; - - size_t bytes_written = 0; - uint8_t control_bits_remaining = 0; - uint8_t control_byte; - - while (bytes_written < total_size) - { - - if (control_bits_remaining == 0) - { - control_byte = *(info->control++); - control_bits_remaining = 8; - } - - if ((control_byte & 0x80) != 0) - { - out_stream[bytes_written] = *(info->data++); - bytes_written++; - - } - else - { - uint16_t nr = (*(info->count++) << 8); - nr |= *(info->count++); - uint16_t r = (nr & 0x0FFF) + 1; - uint16_t n = (nr & 0xF000) >> 12; - if (n == 0) - n = *(info->data++) + 0x12; // TODO is this really read from the data stream? (not the count stream?) - else - n += 2; - - if (r > bytes_written) - return ERROR_BACKREFERENCE_TOO_DISTANT; - - if (bytes_written + n > total_size && stop_after_size == total_size) - return ERROR_OVERFLOW; - - for (; n > 0; n--) - { - out_stream[bytes_written] = out_stream[bytes_written - r]; - bytes_written++; - } - } - - control_byte <<= 1; - control_bits_remaining--; - } - - return bytes_written; -} \ No newline at end of file