Check in makerom files (#1758)

* Check in makerom files

* Fix disasm for asm files in src
This commit is contained in:
Tharo 2024-12-22 23:48:13 +00:00 committed by GitHub
parent 187e75c441
commit 06b06ab507
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 156 additions and 10 deletions

View File

@ -315,7 +315,8 @@ TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG_EXTRACTED:.png=.inc.c),$(f:
ASSET_C_FILES_EXTRACTED := $(filter-out %.inc.c,$(foreach dir,$(ASSET_BIN_DIRS_EXTRACTED),$(wildcard $(dir)/*.c)))
ASSET_C_FILES_COMMITTED := $(filter-out %.inc.c,$(foreach dir,$(ASSET_BIN_DIRS_COMMITTED),$(wildcard $(dir)/*.c)))
C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS_C_FILES),$(wildcard $(dir)/*.c))
S_FILES := $(shell grep -F "\$$(BUILD_DIR)/asm" spec | sed 's/.*$$(BUILD_DIR)\/// ; s/\.o\".*/.s/') \
S_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.s)) \
$(shell grep -F "\$$(BUILD_DIR)/asm" spec | sed 's/.*$$(BUILD_DIR)\/// ; s/\.o\".*/.s/') \
$(shell grep -F "\$$(BUILD_DIR)/data" spec | sed 's/.*$$(BUILD_DIR)\/// ; s/\.o\".*/.s/')
SCHEDULE_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.schl))
BASEROM_FILES := $(shell grep -F "\$$(BUILD_DIR)/baserom" spec | sed 's/.*$$(BUILD_DIR)\/// ; s/\.o\".*//')

85
include/PR/asm.h Normal file
View File

@ -0,0 +1,85 @@
#ifndef PR_ASM_H
#define PR_ASM_H
#ifdef __sgi
#define _MIPS_ISA_MIPS1 1
#define _MIPS_ISA_MIPS2 2
#define _MIPS_ISA_MIPS3 3
#define _MIPS_ISA_MIPS4 4
#endif
#ifndef _LANGUAGE_C
#define LEAF(x) \
.balign 4 ;\
.globl x ;\
.type x, @function ;\
x: ;\
.ent x, 0 ;\
.frame $sp, 0, $ra
#define XLEAF(x) \
.balign 4 ;\
.globl x ;\
.type x, @function ;\
x: ;\
.aent x, 0
#define NESTED(x, fsize, ra) \
.globl x ;\
x: ;\
.ent x, 0 ;\
.frame $sp, fsize, ra
#define XNESTED(x) \
.globl x ;\
x: ;\
.aent x, 0
#define END(x) \
.size x, . - x ;\
.end x
#define IMPORT(x, size) \
.extern x, size
#define EXPORT(x) \
.globl x ;\
x:
#define DATA(x) \
.balign 4 ;\
.globl x ;\
.type x, @object ;\
x:
#define ENDDATA(x) \
.size x, . - x
#endif
/**
* Stack Alignment
*/
#if (_MIPS_SIM == _ABIO32)
#define NARGSAVE 4 // space for 4 args must be allocated
#define ALSZ (8-1)
#define ALMASK ~(8-1)
#elif (_MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64)
#define NARGSAVE 0 // no caller responsibilities
#define ALSZ (16-1)
#define ALMASK ~(16-1)
#endif
#define FRAMESZ(size) (((size) + ALSZ) & ALMASK)
/**
* Register Size
*/
#if (_MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2)
#define SZREG 4
#elif (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4)
#define SZREG 8
#endif
#endif

6
include/boot.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef BOOT_H
#define BOOT_H
#define BOOT_STACK_SIZE 0x400
#endif

6
spec
View File

@ -12,9 +12,9 @@ endseg
beginseg
name "makerom"
address 0x8007F000
include "$(BUILD_DIR)/asm/makerom/rom_header.o"
include "$(BUILD_DIR)/asm/makerom/ipl3.o"
include "$(BUILD_DIR)/asm/makerom/entry.o"
include "$(BUILD_DIR)/src/makerom/rom_header.o"
include "$(BUILD_DIR)/src/makerom/ipl3.o"
include "$(BUILD_DIR)/src/makerom/entry.o"
endseg
beginseg

View File

@ -1,3 +1,4 @@
#include "boot.h"
#include "carthandle.h"
#include "CIC6105.h"
#include "idle.h"
@ -9,7 +10,7 @@ StackEntry sBootStackInfo;
OSThread sIdleThread;
STACK(sIdleStack, 0x400);
StackEntry sIdleStackInfo;
STACK(sBootStack, 0x400);
STACK(sBootStack, BOOT_STACK_SIZE);
void bootproc(void) {
StackCheck_Init(&sBootStackInfo, sBootStack, STACK_TOP(sBootStack), 0, -1, "boot");

34
src/makerom/entry.s Normal file
View File

@ -0,0 +1,34 @@
#include "PR/asm.h"
#include "boot.h"
.set noreorder
.section .text
.balign 16
LEAF(entrypoint)
// Clear boot segment .bss
la $t0, _bootSegmentBssStart
#ifndef AVOID_UB
// UB: li only loads the lower 16 bits of _bootSegmentBssSize when it may be larger than this,
// so not all of bss may be cleared if it is too large
li $t1, _bootSegmentBssSize
#else
la $t1, _bootSegmentBssSize
#endif
.clear_bss:
addi $t1, $t1, -8
sw $zero, 0($t0)
sw $zero, 4($t0)
bnez $t1, .clear_bss
addi $t0, $t0, 8
// Set up stack and enter program code
lui $t2, %hi(bootproc)
lui $sp, %hi(sBootStack + BOOT_STACK_SIZE)
addiu $t2, %lo(bootproc)
jr $t2
addiu $sp, %lo(sBootStack + BOOT_STACK_SIZE)
END(entrypoint)
.fill 0x60 - (. - entrypoint)

2
src/makerom/ipl3.s Normal file
View File

@ -0,0 +1,2 @@
.text
.incbin "extracted/n64-us/baserom/makerom", 0x40, 0xFC0

15
src/makerom/rom_header.s Normal file
View File

@ -0,0 +1,15 @@
#include "rom_header.h"
/* 0x00 */ ENDIAN_IDENTIFIER
/* 0x01 */ PI_DOMAIN_1_CFG(64, 18, 7, 3)
/* 0x04 */ SYSTEM_CLOCK_RATE_SETTING(0xF)
/* 0x08 */ ENTRYPOINT(entrypoint)
/* 0x0C */ LIBULTRA_VERSION(2, 0, K)
/* 0x10 */ CHECKSUM()
/* 0x18 */ PADDING(8)
/* 0x20 */ ROM_NAME("ZELDA MAJORA'S MASK")
/* 0x34 */ PADDING(7)
/* 0x3B */ MEDIUM(CARTRIDGE)
/* 0x3C */ GAME_ID("ZS")
/* 0x3E */ REGION(US)
/* 0x3F */ GAME_REVISION(0)

View File

@ -118,9 +118,12 @@ def discard_decomped_files(files_spec, include_files):
.split("$(BUILD_DIR)/", 1)[1]
.replace(".o", ".c")[:-1]
)
with open(root_path / last_line, "r") as f2:
if "GLOBAL_ASM" in f2.read():
include = True
if os.path.exists(root_path / last_line):
with open(root_path / last_line, "r") as f2:
if "GLOBAL_ASM" in f2.read():
include = True
else:
assert os.path.exists(root_path / last_line.replace(".c", ".s"))
include |= force_include
if include:
@ -131,8 +134,7 @@ def discard_decomped_files(files_spec, include_files):
continue
if included:
f[4] = new_files
new_spec.append(f)
new_spec.append(f)
return new_spec