mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-10-19 22:27:36 -04:00
ASM: simplify, document, start integrating with CMake
* Refactor entry point * Remove unused code * Reformat level header to be more clear, and add more comments Looks like assembling with CMake will require some changes to the assembler flags, and possibly some manual dependency specification.
This commit is contained in:
parent
1cb12690b8
commit
4e9e9d32d6
|
@ -22,6 +22,7 @@ find_program(VTF2PNG_EXECUTABLE vtf2png REQUIRED)
|
|||
set(SKELETOOL64 "${PROJECT_SOURCE_DIR}/skelatool64/skeletool64")
|
||||
|
||||
# Directories
|
||||
set(ASM_DIR "${PROJECT_SOURCE_DIR}/asm")
|
||||
set(ASSETS_DIR "${PROJECT_SOURCE_DIR}/assets")
|
||||
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
|
||||
set(VPK_DIR "${PROJECT_SOURCE_DIR}/vpk")
|
||||
|
@ -29,6 +30,7 @@ set(VPK_DIR "${PROJECT_SOURCE_DIR}/vpk")
|
|||
set(PAK_DIR "${PROJECT_SOURCE_DIR}/portal_pak_dir")
|
||||
set(PAK_MODIFIED_DIR "${PROJECT_SOURCE_DIR}/portal_pak_modified")
|
||||
|
||||
add_subdirectory(${ASM_DIR})
|
||||
add_subdirectory(${ASSETS_DIR})
|
||||
add_subdirectory(${SRC_DIR})
|
||||
add_subdirectory(${VPK_DIR})
|
||||
|
|
19
asm/CMakeLists.txt
Normal file
19
asm/CMakeLists.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
####################
|
||||
## Assembly files ##
|
||||
####################
|
||||
|
||||
# TODO: proper dependencies (defs.h, macros.inc, sounds)
|
||||
|
||||
set(ASM_FILES
|
||||
entry.s
|
||||
rom_header.s
|
||||
sound_data.s
|
||||
)
|
||||
|
||||
add_library(asm_sources OBJECT)
|
||||
add_dependencies(asm_sources
|
||||
sound_tables
|
||||
)
|
||||
target_sources(asm_sources PRIVATE
|
||||
${ASM_FILES}
|
||||
)
|
29
asm/entry.s
29
asm/entry.s
|
@ -1,30 +1,19 @@
|
|||
#include "../src/defs.h"
|
||||
# assembler directives
|
||||
.set noat # allow manual use of $at
|
||||
.set noreorder # don't insert nops after branches
|
||||
.set gp=64
|
||||
|
||||
.include "macros.inc"
|
||||
|
||||
.section .text, "ax"
|
||||
|
||||
glabel entry_point
|
||||
la $t0, _codeSegmentBssStart
|
||||
la $t1, _codeSegmentBssSize
|
||||
.glabel entry_point
|
||||
la $t0, _codeSegmentNoLoadStart
|
||||
la $t1, _codeSegmentNoLoadSize
|
||||
|
||||
.bss_clear:
|
||||
addi $t1, $t1, -8
|
||||
sw $zero, ($t0)
|
||||
sw $zero, 4($t0)
|
||||
bnez $t1, .bss_clear
|
||||
addi $t0, $t0, 8
|
||||
lui $t2, %hi(boot) # $t2, 0x8024
|
||||
lui $sp, %hi(mainStack + STACKSIZEBYTES) # $sp, 0x8020
|
||||
addiu $t2, %lo(boot) # addiu $t2, $t2, 0x6dc4
|
||||
jr $t2
|
||||
addiu $sp, %lo(mainStack + STACKSIZEBYTES) # addiu $sp, $sp, 0xa00
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
addi $t1, $t1, -8
|
||||
bnez $t1, .bss_clear
|
||||
|
||||
la $sp, mainStack + STACKSIZEBYTES
|
||||
j boot
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
# Assembly Macros
|
||||
|
||||
.set K0BASE, 0x80000000
|
||||
.set K1BASE, 0xA0000000
|
||||
.set K2BASE, 0xC0000000
|
||||
|
||||
.macro glabel label
|
||||
.macro .glabel label
|
||||
.global \label
|
||||
.balign 4
|
||||
\label:
|
||||
.endm
|
||||
|
||||
.macro .word32 x
|
||||
.word \x
|
||||
.endm
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
/*
|
||||
* ROM header
|
||||
* Only the first 0x18 bytes matter to the console.
|
||||
*/
|
||||
/* PI_BSD_DOM1 configuration */
|
||||
.byte 0x80 /* Big endian indicator */
|
||||
.byte 0x37 /* Upper nybble: release, lower nybble: page size */
|
||||
.byte 0x12 /* Pulse width */
|
||||
.byte 0x40 /* Latency */
|
||||
|
||||
.byte 0x80, 0x37, 0x12, 0x40 /* PI BSD Domain 1 register */
|
||||
.word 0x0000000F /* Clockrate setting*/
|
||||
.word entry_point /* Entrypoint */
|
||||
.word 0x0000000F /* Clock rate (masked to 0; default) */
|
||||
.word entry_point /* Entry point */
|
||||
.word 0x0000144C /* Libultra version (2.0L) */
|
||||
.skip 8 /* Checksum (OVERWRITTEN BY MAKEMASK) */
|
||||
.skip 8 /* Unused */
|
||||
|
||||
/* SDK Revision */
|
||||
.word 0x0000144C
|
||||
|
||||
.word 0x00000000 /* Checksum 1 (OVERWRITTEN BY MAKEMASK)*/
|
||||
.word 0x00000000 /* Checksum 2 (OVERWRITTEN BY MAKEMASK)*/
|
||||
.word 0x00000000 /* Unknown */
|
||||
.word 0x00000000 /* Unknown */
|
||||
.ascii "Portal 64 " /* Internal ROM name (Max 20 characters) */
|
||||
|
||||
.word 0x01000000 /* Unused officially / Advanced homebrew ROM header controller config */
|
||||
.word 0x0000004E /* Cartridge Type (N; cart)*/
|
||||
.ascii "ED" /* Cartridge ID (ED) / Advanced homebrew ROM header magic value */
|
||||
.byte 0x41 /* Region (A; All)*/
|
||||
.byte 0x32 /* Version / Advanced homebrew ROM header misc. (region-free + 256K SRAM) */
|
||||
.ascii "Portal 64 " /* Game title */
|
||||
.word 0x01000000 /* Unused / Homebrew header: 1 controller with rumble */
|
||||
.skip 3 /* Unused */
|
||||
.ascii "N" /* Game format (cartridge) */
|
||||
.ascii "ED" /* Game ID / Homebrew header: magic value */
|
||||
.ascii "A" /* Region (all) */
|
||||
.byte 0x32 /* Version / Homebrew header: region-free + 256K SRAM */
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
.section .data
|
||||
|
||||
glabel _soundsSegmentRomStart
|
||||
.glabel _soundsSegmentRomStart
|
||||
.incbin "build/assets/sound/sounds.sounds"
|
||||
.balign 16
|
||||
glabel _soundsSegmentRomEnd
|
||||
.glabel _soundsSegmentRomEnd
|
||||
|
||||
glabel _soundsTblSegmentRomStart
|
||||
.glabel _soundsTblSegmentRomStart
|
||||
.incbin "build/assets/sound/sounds.sounds.tbl"
|
||||
.balign 16
|
||||
glabel _soundsTblSegmentRomEnd
|
||||
.glabel _soundsTblSegmentRomEnd
|
||||
|
|
|
@ -11,12 +11,12 @@ OUTPUT_ARCH (mips)
|
|||
__romPos += SIZEOF(.name);
|
||||
|
||||
#define BEGIN_NOLOAD(name) \
|
||||
_##name##SegmentBssStart = ADDR(.name.noload); \
|
||||
_##name##SegmentNoLoadStart = ADDR(.name.noload); \
|
||||
.name.noload (NOLOAD) :
|
||||
|
||||
#define END_NOLOAD(name) \
|
||||
_##name##SegmentBssEnd = ADDR(.name.noload) + SIZEOF(.name.noload); \
|
||||
_##name##SegmentBssSize = SIZEOF(.name.noload);
|
||||
_##name##SegmentNoLoadEnd = ADDR(.name.noload) + SIZEOF(.name.noload); \
|
||||
_##name##SegmentNoLoadSize = SIZEOF(.name.noload);
|
||||
|
||||
|
||||
SECTIONS
|
||||
|
@ -48,6 +48,7 @@ SECTIONS
|
|||
CODE_SEGMENT(.rodata*);
|
||||
}
|
||||
END_SEG(code)
|
||||
|
||||
BEGIN_NOLOAD(code)
|
||||
{
|
||||
CODE_SEGMENT(COMMON);
|
||||
|
@ -57,7 +58,7 @@ SECTIONS
|
|||
}
|
||||
END_NOLOAD(code)
|
||||
|
||||
_codeSegmentBssEnd = .;
|
||||
_codeSegmentNoLoadEnd = .;
|
||||
|
||||
_heapStart = .;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ target_include_directories(portal PRIVATE
|
|||
|
||||
# Generated code
|
||||
target_link_libraries(portal
|
||||
asm_sources
|
||||
levels
|
||||
materials
|
||||
models
|
||||
|
|
Loading…
Reference in a new issue