From 8d971cd81dee9cb1961c61b9aa972d9884a2b14d Mon Sep 17 00:00:00 2001 From: a Date: Sun, 22 Jun 2025 22:01:46 -0400 Subject: [PATCH] Add libdragon ipl3 as makefile option --- Makefile | 27 ++++++++++++++++++--------- asm/boot.s | 7 +++++-- asm/entry.s | 25 ++----------------------- asm/libdragon_ipl3.bin | Bin 0 -> 4032 bytes asm/rom_header.s | 2 +- sm64.ld | 2 ++ 6 files changed, 28 insertions(+), 35 deletions(-) create mode 100644 asm/libdragon_ipl3.bin diff --git a/Makefile b/Makefile index 9f112114..3e9579ca 100644 --- a/Makefile +++ b/Makefile @@ -5,9 +5,19 @@ include util.mk # Default target default: all +# Use Libdragon IPL3 +# WARNING: This CAN and WILL break certain (most) emulators. +# Use if you care about console or ares boot times. + +LIBDRAGON_IPL3 := 0 + # Preprocessor definitions DEFINES := +ifeq ($(LIBDRAGON_IPL3), 1) + DEFINES += LIBDRAGON_IPL3=1 +endif + #==============================================================================# # Build Options # #==============================================================================# @@ -111,7 +121,7 @@ ifeq ($(filter $(TARGET_STRING), sm64.jp.f3d_old sm64.us.f3d_old sm64.eu.f3d_new endif # Whether to hide commands or not -VERBOSE ?= 1 +VERBOSE ?= 0 ifeq ($(VERBOSE),0) V := @ endif @@ -125,15 +135,10 @@ ifeq ($(filter clean distclean,$(MAKECMDGOALS)),) $(info Version: $(VERSION)) $(info Microcode: $(GRUCODE)) $(info Target: $(TARGET)) - ifeq ($(COMPARE),1) - $(info Compare ROM: yes) + ifeq ($(LIBDRAGON_IPL3),1) + $(info IPL: Libdragon IPL3 Compat) else - $(info Compare ROM: no) - endif - ifeq ($(NON_MATCHING),1) - $(info Build Matching: no) - else - $(info Build Matching: yes) + $(info IPL: Nintendo IPL3) endif $(info =======================) endif @@ -657,8 +662,12 @@ $(ELF): $(LIBULTRA_BUILD_DIR)/libgultra_rom.a $(O_FILES) $(MIO0_OBJ_FILES) $(SEG $(ROM): $(ELF) $(call print,Building ROM:,$<,$@) +ifeq ($(LIBDRAGON_IPL3), 0) $(V)$(OBJCOPY) $(PAD_TO_GAP_FILL) $< $(@:.z64=.bin) -O binary $(V)$(N64CKSUM) $(@:.z64=.bin) $@ +else + $(V)$(OBJCOPY) $(PAD_TO_GAP_FILL) $< $@ -O binary +endif $(BUILD_DIR)/$(TARGET).objdump: $(ELF) $(OBJDUMP) -D $< > $@ diff --git a/asm/boot.s b/asm/boot.s index a8ae046f..5551ff03 100644 --- a/asm/boot.s +++ b/asm/boot.s @@ -4,7 +4,6 @@ #include "macros.inc" #include - #define PHYS_TO_CART(addr) ((addr) | 0xB0000000) .equ CART_ENTRYPOINT, 0x00000008 .equ CART_CHECKSUM0, 0x00000010 @@ -38,7 +37,7 @@ // 0xA4000000-0xA4000FFF: RSP DMEM .section .text, "ax" - +#ifndef LIBDRAGON_IPL3 // 0xA4000040-0xA4000B6F: IPL3 // IPL3 entry point jumped to from IPL2 @@ -1158,3 +1157,7 @@ func_A4000AD0: #endif .end ipl3_entry +#else +.section .text, "ax" +.incbin "asm/libdragon_ipl3.bin" +#endif diff --git a/asm/entry.s b/asm/entry.s index 80c593f1..bd102094 100644 --- a/asm/entry.s +++ b/asm/entry.s @@ -7,28 +7,7 @@ .section .text, "ax" glabel entry_point -#ifdef VERSION_CN - // Get main segment bss address and size - lui $t0, %lo(_mainSegmentNoloadStartHi) - ori $t0, %lo(_mainSegmentNoloadStartLo) - lui $t1, %lo(_mainSegmentNoloadSizeHi) - ori $t1, %lo(_mainSegmentNoloadSizeLo) -.clear_bytes: - // Clear bss section until they are zeroed out - sw $zero, ($t0) // Clear 4 bytes - sw $zero, 4($t0) // Clear the next 4 bytes - addi $t0, $t0, 8 // Increment the address of bytes to clear - addi $t1, $t1, -8 // Subtract 8 bytes from the amount remaining - bnez $t1, .clear_bytes // Continue clearing until clear_bytes is 0 - nop - // Get init function and idle thread stack - lui $sp, %lo(gIdleThreadStackHi) - ori $sp, %lo(gIdleThreadStackLo) - lui $t2, %lo(main_funcHi) - ori $t2, %lo(main_funcLo) - jr $t2 // Jump to the init function - nop -#else +#ifndef LIBDRAGON_IPL3 // Get main segment bss address and size lui $t0, %hi(_mainSegmentNoloadStart) lui $t1, %lo(_mainSegmentNoloadSizeHi) @@ -41,13 +20,13 @@ glabel entry_point sw $zero, 4($t0) // Clear the next 4 bytes bnez $t1, .clear_bytes // Continue clearing until clear_bytes is 0 addi $t0, $t0, 8 // Increment the address of bytes to clear +#endif // Get init function and idle thread stack lui $t2, %hi(main_func) lui $sp, %hi(gIdleThreadStack) addiu $t2, %lo(main_func) jr $t2 // Jump to the init function addiu $sp, %lo(gIdleThreadStack) -#endif nop nop nop diff --git a/asm/libdragon_ipl3.bin b/asm/libdragon_ipl3.bin new file mode 100644 index 0000000000000000000000000000000000000000..dffdc68a14082f01862257ec02a97da763862de1 GIT binary patch literal 4032 zcmXqTxnyP|yM)1fFaHPiz5gFDFx*gGzn?*7{YD0f^&1#OSOl4p99TRU7#IXp9hx#2 z9GW~B9GW5+9GWID*f1?I=m}(CQDI`(U}VVfK}d-q&W348L5~vykAMS%AOk~#stuEn zi4EHV1{J5U3L91i1sfKI1|~KM#We{G3~Q1Y7wJ?me{kEfkDNISzu2n1F}CEVg9sXs{e1|^#21x zlY$~c0s{v_!wXd#rUeW=0n8FTA4eS5^Dobk^Y*-dBFtKVVvIsJWskE>#2r&Hb1jVla!~gp>0t_`O z&H@Z7P6`a5w4##Cz!H-5{~w4g!0`VA$PAGE3O<=hDMg9t`FRSS0Y1hG3eNc{sVNFc zl?p+L#o3h#pm1SmQc&H{z`(Gjfq`9P5d)`)1B0Z>(*HjgmIx?raA08A;=sUe!^t3^ z(!#)@!u5f{hIt8#3Wop#!%71!fddSzHcSix8p{M2L=G@8F)R>JWmqMk(v!|0BJ$w> zKNa`?{}~o(D6h$2U|5sFz_KQtfk$S+|Bs-!VSd2C0dk`X)Bpb>O$7+9HI6j(rcQH2>C&I}+v zL#u`&1FJ@Z4b$Qe46Xu-Jo+netlz*O^L#sl%lfSh2J1I5s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}52`mX+YHQ0SbCBeBt#tkgXgRs4hsA zP-aMy&<;spU<9iHwVP5I1PqokFpDhs|JR090PG)7IkP5(fniN50}H5Z#cW?Otg>NU z!eZjIif_##1_2wUB^+xU7#P+pV2}ZowJNNvp=(?jc-FWwfYJ@qnp6e>8|EbqYZ4eF wY?zk>tVv+tQDNqQgbC9I1{EhR2L^{9oFM;>;?WQo4S|sy0$vYO6WVqH0J|CDcK`qY literal 0 HcmV?d00001 diff --git a/asm/rom_header.s b/asm/rom_header.s index d5d18467..bc2d35f3 100644 --- a/asm/rom_header.s +++ b/asm/rom_header.s @@ -16,7 +16,7 @@ .fill 0x30 #else -.word 0x4EAA3D0E /* Checksum 1 */ +.word _mainSegmentRomEnd /* Checksum 1 / Libdragon IPL3 load end */ .word 0x74757C24 /* Checksum 2 */ .word 0x00000000 /* Unknown */ .word 0x00000000 /* Unknown */ diff --git a/sm64.ld b/sm64.ld index 543abe5e..63506f42 100755 --- a/sm64.ld +++ b/sm64.ld @@ -17,7 +17,9 @@ SECTIONS { BUILD_DIR/asm/rom_header.o(.text); BUILD_DIR/asm/boot.o(.text); +#ifndef LIBDRAGON_IPL3 BUILD_DIR/asm/ipl3_font.o(.text); +#endif } END_SEG(boot)