Skip to content

Commit

Permalink
Merge pull request #4 from CosmicScale/main
Browse files Browse the repository at this point in the history
Fix error when compiling with latest PS2 SDK
  • Loading branch information
AKuHAK authored Jul 28, 2024
2 parents 61fc07d + 86553ab commit aa470fc
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 63 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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"
Expand Down
28 changes: 13 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions cnf_lite.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include <string.h>
#include <stdio.h>

#define NEWLIB_PORT_AWARE
#include <io_common.h>

#include "cnf_lite.h"

// Function prototypes.
Expand Down
94 changes: 59 additions & 35 deletions linkfile
Original file line number Diff line number Diff line change
@@ -1,63 +1,90 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ 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.*)
*(.gnu.linkonce.t*)
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 = . ;
*(.data)
*(.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 = .);
Expand All @@ -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);
}
19 changes: 13 additions & 6 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <kernel.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -8,13 +9,19 @@
#include <osd_config.h>

#include <kernel.h>

#define NEWLIB_PORT_AWARE
#include <fileio.h>

#include <sifrpc.h>

#include <loadfile.h>

#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)))
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit aa470fc

Please sign in to comment.