Skip to content

Commit 380126e

Browse files
committed
Initial commit
0 parents  commit 380126e

File tree

5 files changed

+702
-0
lines changed

5 files changed

+702
-0
lines changed

Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
EE_BIN = disc-launcher-raw.elf
2+
EE_BIN_STRIPPED = disc-launcher-stripped.elf
3+
EE_BIN_PACKED = disc-launcher.elf
4+
EE_OBJS = main.o cnf_lite.o $(EE_C_DIR)ps2dev9.o $(EE_C_DIR)ps2atad.o $(EE_C_DIR)ps2fs.o $(EE_C_DIR)ps2hdd.o $(EE_C_DIR)iomanx.o $(EE_C_DIR)filexio.o $(EE_C_DIR)usbd.o $(EE_C_DIR)usbmass.o
5+
6+
EE_C_DIR = modules/
7+
8+
EE_INCS := -I$(PS2SDK)/ports/include -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I.
9+
EE_GPVAL = -G0
10+
EE_CFLAGS = -O2 -D_EE -Os -mgpopt -mno-gpopt $(EE_GPVAL) -Wall $(EE_INCS) -Wno-stringop-truncation -I$(PS2DEV)/gsKit/include
11+
EE_LDFLAGS = -L$(PS2SDK)/ee/lib -L$(PS2DEV)/gsKit/lib
12+
EE_LIBS += -lfileXio -lpatches -lelf-loader-nocolour -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib/ -ldmakit -lgskit -ldebug
13+
EE_NEWLIB_NANO ?= 1
14+
EE_COMPACT_EXECUTABLE ?= 1
15+
16+
BIN2C = $(PS2SDK)/bin/bin2c
17+
18+
all: create_dirs $(EE_BIN_PACKED)
19+
20+
create_dirs:
21+
mkdir -p $(EE_C_DIR)
22+
23+
$(EE_BIN_STRIPPED): $(EE_BIN)
24+
echo "Stripping..."
25+
$(EE_STRIP) -o $@ $<
26+
27+
$(EE_BIN_PACKED): $(EE_BIN_STRIPPED)
28+
echo "Compressing..."
29+
ps2-packer $< $@
30+
31+
clean:
32+
rm -rf $(EE_BIN) $(EE_BIN_STRIPPED) $(EE_BIN_PACKED) $(EE_OBJS) $(EE_C_DIR)
33+
34+
$(EE_C_DIR)ps2dev9.c: $(PS2SDK)/iop/irx/ps2dev9.irx
35+
$(BIN2C) $< $@ ps2dev9_irx
36+
37+
$(EE_C_DIR)ps2atad.c: $(PS2SDK)/iop/irx/ps2atad.irx
38+
$(BIN2C) $< $@ ps2atad_irx
39+
40+
$(EE_C_DIR)ps2fs.c: $(PS2SDK)/iop/irx/ps2fs.irx
41+
$(BIN2C) $< $@ ps2fs_irx
42+
43+
$(EE_C_DIR)ps2hdd.c: $(PS2SDK)/iop/irx/ps2hdd-osd.irx
44+
$(BIN2C) $< $@ ps2hdd_irx
45+
46+
$(EE_C_DIR)iomanx.c: $(PS2SDK)/iop/irx/iomanX.irx
47+
$(BIN2C) $< $@ iomanx_irx
48+
49+
$(EE_C_DIR)usbd.c: $(PS2SDK)/iop/irx/usbd.irx
50+
$(BIN2C) $< $@ usbd_irx
51+
52+
$(EE_C_DIR)usbmass.c: $(PS2SDK)/iop/irx/usbmass_bd.irx
53+
$(BIN2C) $< $@ usbmass_bd_irx
54+
55+
$(EE_C_DIR)filexio.c: $(PS2SDK)/iop/irx/fileXio.irx
56+
$(BIN2C) $< $@ filexio_irx
57+
58+
include $(PS2SDK)/Defs.make
59+
include $(PS2SDK)/samples/Makefile.eeglobal

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Retro GEM Disc Launcher for PlayStation 2
2+
3+
This application launches PlayStation and PlayStation 2 game discs on your PlayStation 2 console and sets the Retro GEM Game ID accordingly, allowing per-game settings for all your physical games.
4+
5+
## Features
6+
7+
### For PlayStation game discs
8+
- Sets Retro GEM Game ID.
9+
- Adjusts the video mode of the console's PlayStation driver to match that of the inserted disc if necessary.
10+
11+
### For PlayStation 2 game discs
12+
- Sets Retro GEM Game ID.
13+
- Skips the PlayStation 2 logo check, allowing MechaPwn users to launch imports and master discs.
14+
15+
## Instructions
16+
17+
`disc-launcher.elf` can be run from a Memory Card (PS2), USB, or HDD. For a seamless experience, insert the disc before launching the application.
18+
19+
### Recommended setup for Free MCBoot users:
20+
- Put `disc-launcher.elf` in the `APPS` folder on your Free MCBoot memory card.
21+
- To enable video mode switching for imported PlayStation games, place `PS1VModeNeg.elf` in the same location.
22+
- Go to `Free MCBoot Configurator` and select `Configure OSDSYS options...`
23+
- Turn on `Skip Disc Boot` to prevent the console from auto-booting game discs when they are inserted.
24+
- Configure the item `Launch disc` so that it points to `mc?:/APPS/disc-launcher.elf`.
25+
- Return to the previous screen. Save CNF to `MC0` or `MC2` (depending on where your Free MCBoot memory card is located) and exit.
26+
- To launch a game, simply insert the game disc, then select `Launch disc` from the Free MCBoot menu. Alternatively, select `Launch disc` and then insert the game disc.
27+
28+
## Notes
29+
30+
The Disc Launcher checks the region of both the PlayStation game disc and the console. If a mismatch is found (e.g., a PAL game in an NTSC console), then PS1VModeNeg is launched to adjust the video mode of the PlayStation driver. If no mismatch is found, the game is launched normally. PS1VModeNeg can be downloaded [here](https://github.com/ps2homebrew/PS1VModeNeg). `PS1VModeNeg.elf` should be placed in the same location as `disc-launcher.elf` (either on Memory Card (PS2), USB, or HDD). If `PS1VModeNeg.elf` is not found, then all PlayStation games will be launched normally.
31+
32+
## Credits
33+
34+
Written by [CosmicScale](https://github.com/CosmicScale)
35+
Uses Game ID code based on the [AppCakeLtd](https://github.com/AppCakeLtd) [gameid-with-gem](https://github.com/AppCakeLtd/Open-PS2-Loader/tree/gameid-with-gem) fork of Open-PS2-Loader.
36+
Also uses code modified from [PS1VModeNeg](https://github.com/ps2homebrew/PS1VModeNeg) and [wLaunchELF](https://github.com/ps2homebrew/wLaunchELF)

cnf_lite.c

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#include <malloc.h>
2+
#include <string.h>
3+
#include <stdio.h>
4+
5+
#define NEWLIB_PORT_AWARE
6+
#include <io_common.h>
7+
8+
#include "cnf_lite.h"
9+
10+
// Function prototypes.
11+
static int get_CNF_string(char **CNF_p_p, char **name_p_p, char **value_p_p);
12+
13+
static int file_exists(const char *file)
14+
{
15+
int fd, result;
16+
if ((fd = open(file, O_RDONLY)) >= 0) {
17+
result = 1;
18+
close(fd);
19+
} else
20+
result = 0;
21+
22+
return result;
23+
}
24+
25+
//________________ From uLaunchELF ______________________
26+
//---------------------------------------------------------------------------
27+
// get_CNF_string is the main CNF parser called for each CNF variable in a
28+
// CNF file. Input and output data is handled via its pointer parameters.
29+
// The return value flags 'false' when no variable is found. (normal at EOF)
30+
//---------------------------------------------------------------------------
31+
static int get_CNF_string(char **CNF_p_p, char **name_p_p, char **value_p_p)
32+
{
33+
char *np, *vp, *tp = *CNF_p_p;
34+
35+
start_line:
36+
while ((*tp <= ' ') && (*tp > '\0'))
37+
tp += 1; // Skip leading whitespace, if any
38+
if (*tp == '\0')
39+
return 0; // but exit at EOF
40+
np = tp; // Current pos is potential name
41+
if (*tp < 'A') // but may be a comment line
42+
{ // We must skip a comment line
43+
while ((*tp != '\r') && (*tp != '\n') && (*tp > '\0'))
44+
tp += 1; // Seek line end
45+
goto start_line; // Go back to try next line
46+
}
47+
48+
while ((*tp >= 'A') || ((*tp >= '0') && (*tp <= '9')))
49+
tp += 1; // Seek name end
50+
if (*tp == '\0')
51+
return 0; // but exit at EOF
52+
53+
while ((*tp <= ' ') && (*tp > '\0'))
54+
*tp++ = '\0'; // zero&skip post-name whitespace
55+
if (*tp != '=')
56+
return 0; // exit (syntax error) if '=' missing
57+
*tp++ = '\0'; // zero '=' (possibly terminating name)
58+
59+
while ((*tp <= ' ') && (*tp > '\0') // Skip pre-value whitespace, if any
60+
&& (*tp != '\r') && (*tp != '\n') // but do not pass the end of the line
61+
&& (*tp != '\7') // allow ctrl-G (BEL) in value
62+
)
63+
tp += 1;
64+
if (*tp == '\0')
65+
return 0; // but exit at EOF
66+
vp = tp; // Current pos is potential value
67+
68+
while ((*tp != '\r') && (*tp != '\n') && (*tp != '\0'))
69+
tp += 1; // Seek line end
70+
if (*tp != '\0')
71+
*tp++ = '\0'; // terminate value (passing if not EOF)
72+
while ((*tp <= ' ') && (*tp > '\0'))
73+
tp += 1; // Skip following whitespace, if any
74+
75+
*CNF_p_p = tp; // return new CNF file position
76+
*name_p_p = np; // return found variable name
77+
*value_p_p = vp; // return found variable value
78+
return 1; // return control to caller
79+
} // Ends get_CNF_string
80+
81+
//----------------------------------------------------------------
82+
int Read_SYSTEM_CNF(char *boot_path, char *ver)
83+
{
84+
// Returns disc type : 0 = failed; 1 = PS1; 2 = PS2;
85+
size_t CNF_size;
86+
char *RAM_p, *CNF_p, *name, *value;
87+
int fd = -1;
88+
int Disc_Type = -1; // -1 = Internal : Not Tested;
89+
90+
// place 3 question mark in ver string
91+
strcpy(ver, "???");
92+
93+
fd = open("cdrom0:\\SYSTEM.CNF;1", O_RDONLY);
94+
if (fd < 0) {
95+
failed_load:
96+
if (Disc_Type == -1) {
97+
// Test PS1 special cases
98+
if (file_exists("cdrom0:\\PSXMYST\\MYST.CCS;1")) {
99+
strcpy(boot_path, "SLPS_000.24");
100+
Disc_Type = 1;
101+
} else if (file_exists("cdrom0:\\CDROM\\LASTPHOT\\ALL_C.NBN;1")) {
102+
strcpy(boot_path, "SLPS_000.65");
103+
Disc_Type = 1;
104+
} else if (file_exists("cdrom0:\\PSX.EXE;1")) {
105+
// place 3 question mark in pathname
106+
strcpy(boot_path, "???");
107+
Disc_Type = 1;
108+
}
109+
}
110+
if (Disc_Type == -1)
111+
Disc_Type = 0;
112+
return Disc_Type;
113+
} // This point is only reached after succefully opening CNF
114+
115+
Disc_Type = 0;
116+
117+
CNF_size = lseek(fd, 0, SEEK_END);
118+
lseek(fd, 0, SEEK_SET);
119+
RAM_p = (char *)malloc(CNF_size);
120+
CNF_p = RAM_p;
121+
if (CNF_p == NULL) {
122+
close(fd);
123+
goto failed_load;
124+
}
125+
read(fd, CNF_p, CNF_size); // Read CNF as one long string
126+
close(fd);
127+
CNF_p[CNF_size] = '\0'; // Terminate the CNF string
128+
129+
strcpy(boot_path, "???"); // place 3 question mark in boot path
130+
131+
while (get_CNF_string(&CNF_p, &name, &value)) {
132+
// A variable was found, now we dispose of its value.
133+
if (!strcmp(name, "BOOT2")) { // check for BOOT2 entry
134+
strcpy(boot_path, value);
135+
Disc_Type = 2; // If found, PS2 disc type
136+
continue;
137+
}
138+
if (!strcmp(name, "BOOT")) { // check for BOOT entry
139+
strcpy(boot_path, value);
140+
Disc_Type = 1; // If found, PS1 disc type
141+
continue;
142+
}
143+
if (!strcmp(name, "VER")) { // check for VER entry
144+
strcpy(ver, value);
145+
continue;
146+
}
147+
} // ends for
148+
free(RAM_p);
149+
return Disc_Type;
150+
}

cnf_lite.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int Read_SYSTEM_CNF(char *boot_path, char *ver);

0 commit comments

Comments
 (0)