diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 9029aba..d9236f2 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -7,14 +7,10 @@ on: jobs: build: runs-on: ubuntu-latest - container: ps2dev/ps2dev:v1.0 + container: ghcr.io/ps2homebrew/ps2homebrew:main # instead of "ps2dev/ps2dev:latest" you can use different tags, for example for old projects you can use "ps2dev/ps2dev:v1.0" steps: - - name: Install dependencies - run: | - apk add build-base git zip - - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Compile project run: | @@ -44,7 +40,7 @@ jobs: - name: Create release if: github.ref == 'refs/heads/main' - uses: marvinpinto/action-automatic-releases@latest + uses: mathieucarbou/marvinpinto-action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" automatic_release_tag: "latest" diff --git a/Makefile b/Makefile index 7ca76aa..c9ddeb8 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,25 @@ -EE_BIN = PS1VModeNeg.elf +EE_BIN = PS1VModeNegRaw.elf +EE_BIN_PACKED = PS1VModeNeg.elf EE_OBJS = main.o cnf_lite.o EE_INCS := -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I. EE_GPVAL = -G0 EE_CFLAGS = -D_EE -Os -mno-gpopt $(EE_GPVAL) -Wall $(EE_INCS) -EE_LDFLAGS = -Tlinkfile -L$(PS2SDK)/ee/lib -s -EE_LIBS += -lcdvd -ldebug -lc -lkernel-nopatch +EE_LIBS += -ldebug +EE_NEWLIB_NANO ?= 1 +EE_COMPACT_EXECUTABLE ?= 1 -%.o : %.c - $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ +EE_LINKFILE ?= linkfile -%.o : %.S - $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ +all: $(EE_BIN_PACKED) -%.o : %.s - $(EE_AS) $(EE_ASFLAGS) $< -o $@ - -$(EE_BIN) : $(EE_OBJS) - $(EE_CC) $(EE_CFLAGS) $(EE_LDFLAGS) -o $(EE_BIN) $(EE_OBJS) $(EE_LIBS) - -all: $(EE_BIN) +$(EE_BIN_PACKED): $(EE_BIN) + echo "Compressing..." + ps2-packer $< $@ + rm -f $(EE_BIN) clean: - rm -f $(EE_OBJS) $(EE_BIN) + rm -f $(EE_OBJS) $(EE_BIN_PACKED) include $(PS2SDK)/Defs.make +include $(PS2SDK)/samples/Makefile.eeglobal \ No newline at end of file diff --git a/cnf_lite.c b/cnf_lite.c index 6e75f3e..c2ec88b 100644 --- a/cnf_lite.c +++ b/cnf_lite.c @@ -2,6 +2,9 @@ #include #include +#define NEWLIB_PORT_AWARE +#include + #include "cnf_lite.h" // Function prototypes. diff --git a/linkfile b/linkfile index fc2a08c..2d7fe5d 100644 --- a/linkfile +++ b/linkfile @@ -1,8 +1,35 @@ +/* +# _____ ___ ____ ___ ____ +# ____| | ____| | | |____| +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. +#----------------------------------------------------------------------- +# Copyright 2001-2004, ps2dev - http://www.ps2dev.org +# Licenced under Academic Free License version 2.0 +# Review ps2sdk README & LICENSE files for further details. +# +# Linkfile script for ee-ld +*/ + +ENTRY(__start); + +MEMORY { + bios : ORIGIN = 0x00000000, LENGTH = 592K /* 0x00000000 - 0x00094000: BIOS memory & patched area */ + bram : ORIGIN = 0x00094000, LENGTH = 432K /* 0x00094000 - 0x00100000: BIOS unused memory */ + gram : ORIGIN = 0x00100000, LENGTH = 31M /* 0x00100000 - 0x02000000: GAME memory */ + + high : ORIGIN = 0x01ee8000, LENGTH = 1120K /* 0x01ee8000 - 0x02000000: */ +} + +REGION_ALIAS("MAIN_REGION", bram); -ENTRY(_start); +END_MAIN_REGION = ORIGIN(MAIN_REGION) + LENGTH(MAIN_REGION); + +PHDRS { + text PT_LOAD; +} SECTIONS { - .text 0x00084000: { + .text : { _ftext = . ; *(.text) *(.text.*) @@ -10,33 +37,26 @@ SECTIONS { KEEP(*(.init)) KEEP(*(.fini)) QUAD(0) - } + } >MAIN_REGION :text PROVIDE(_etext = .); PROVIDE(etext = .); - .reginfo : { *(.reginfo) } - /* Global/static constructors and deconstructors. */ .ctors ALIGN(16): { KEEP(*crtbegin*.o(.ctors)) KEEP(*(EXCLUDE_FILE(*crtend*.o) .ctors)) KEEP(*(SORT(.ctors.*))) KEEP(*(.ctors)) - } + } >MAIN_REGION .dtors ALIGN(16): { KEEP(*crtbegin*.o(.dtors)) KEEP(*(EXCLUDE_FILE(*crtend*.o) .dtors)) KEEP(*(SORT(.dtors.*))) KEEP(*(.dtors)) - } + } >MAIN_REGION - /* Static data. */ - .rodata ALIGN(128): { - *(.rodata) - *(.rodata.*) - *(.gnu.linkonce.r*) - } + .reginfo : { *(.reginfo) } >MAIN_REGION .data ALIGN(128): { _fdata = . ; @@ -44,20 +64,27 @@ SECTIONS { *(.data.*) *(.gnu.linkonce.d*) SORT(CONSTRUCTORS) - } + } >MAIN_REGION - .rdata ALIGN(128): { *(.rdata) } - .gcc_except_table ALIGN(128): { *(.gcc_except_table) } + /* Static data. */ + .rodata ALIGN(128): { + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r*) + } >MAIN_REGION + + .rdata ALIGN(128): { *(.rdata) } >MAIN_REGION + .gcc_except_table ALIGN(128): { *(.gcc_except_table) } >MAIN_REGION _gp = ALIGN(128) + 0x7ff0; - .lit4 ALIGN(128): { *(.lit4) } - .lit8 ALIGN(128): { *(.lit8) } + .lit4 ALIGN(128): { *(.lit4) } >MAIN_REGION + .lit8 ALIGN(128): { *(.lit8) } >MAIN_REGION .sdata ALIGN(128): { *(.sdata) *(.sdata.*) *(.gnu.linkonce.s*) - } + } >MAIN_REGION _edata = .; PROVIDE(edata = .); @@ -69,29 +96,26 @@ SECTIONS { *(.sbss.*) *(.gnu.linkonce.sb*) *(.scommon) - } + } >MAIN_REGION .bss ALIGN(128) : { *(.bss) *(.bss.*) *(.gnu.linkonce.b*) *(COMMON) - } + } >MAIN_REGION _end_bss = .; - /* Symbols needed by crt0.s. */ - PROVIDE(_heap_size = 0x2000); - PROVIDE(_stack_size = 0x2000); - - _stack = ALIGN(128); - PROVIDE(_stack = .); - . = _stack + _stack_size; - - _end = .; + _end = . ; PROVIDE(end = .); - /* Unwanted stuff */ - /DISCARD/ : { - * ( .MIPS.abiflags ) - } -} + .spad 0x70000000: { + *(.spad) + } >MAIN_REGION + + /* Symbols needed by crt0.c. */ + /* We set a fixed stack size and the pointer for the stack, letting the remaining memory be the heap. */ + PROVIDE(_stack_size = 32 * 1024); + PROVIDE(_stack = END_MAIN_REGION - _stack_size); + PROVIDE(_heap_size = -1); +} \ No newline at end of file diff --git a/main.c b/main.c index fe30f35..f662ae0 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -8,13 +9,19 @@ #include #include + +#define NEWLIB_PORT_AWARE #include + #include #include #include "cnf_lite.h" +// Disable all the patched functions +DISABLE_PATCHED_FUNCTIONS(); + /* Some macros used for patching. */ #define JAL(addr) (0x0c000000 | (0x3ffffff & ((addr) >> 2))) #define JMP(addr) (0x08000000 | (0x3ffffff & ((addr) >> 2))) @@ -78,18 +85,18 @@ static int InitVideoModeParams(void) temp = (temp & 0xFFFFFC00) | 3; temp = (temp & 0xFFF003FF) | 0x1800; temp = (temp & 0xC00FFFFF) | 0x01200000; - temp = (temp & 0xFFFFFC00FFFFFFFF) | (0xC000L << 19); - temp = (temp & 0xFFE003FFFFFFFFFF) | (0xF300L << 35); - temp = (temp & 0x801FFFFFFFFFFFFF) | (0xC000L << 40); + temp = (temp & 0xFFFFFC00FFFFFFFF) | (0xC000LL << 19); + temp = (temp & 0xFFE003FFFFFFFFFF) | (0xF300LL << 35); + temp = (temp & 0x801FFFFFFFFFFFFF) | (0xC000LL << 40); *emu_SYNCHV_I = temp; // Nearly a repeat of the block above. temp = (temp & 0xFFFFFC00) | 4; temp = (temp & 0xFFF003FF) | 0x1800; temp = (temp & 0xC00FFFFF) | 0x01200000; - temp = (temp & 0xFFFFFC00FFFFFFFF) | (0xC000L << 19); - temp = (temp & 0xFFE003FFFFFFFFFF) | (0xF300L << 35); - temp = (temp & 0x801FFFFFFFFFFFFF) | (0xC000L << 40); + temp = (temp & 0xFFFFFC00FFFFFFFF) | (0xC000LL << 19); + temp = (temp & 0xFFE003FFFFFFFFFF) | (0xF300LL << 35); + temp = (temp & 0x801FFFFFFFFFFFFF) | (0xC000LL << 40); *emu_SYNCHV_NI = temp; }