Skip to content

Commit

Permalink
Merge branch 'master' into gfx-deprecated-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolf3s committed Oct 29, 2024
2 parents 6f79c3c + e95eb87 commit 6075a2a
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 111 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ jobs:
strategy:
fail-fast: false
matrix:
rtl: [RTL=0, RTL=1]
extra: [EXTRA_FEATURES=0, EXTRA_FEATURES=1]
pademu: [PADEMU=0, PADEMU=1]
igs: [IGS=0, IGS=1]
t10k: [DTL_T10000=0, DTL_T10000=1]
runs-on: ubuntu-latest
container: ghcr.io/ps2homebrew/ps2homebrew:main
steps:
Expand All @@ -66,18 +64,18 @@ jobs:
run: |
echo "OPL_VERSION=$(make oplversion)" >> $GITHUB_ENV
- name: Compile -> make ${{ matrix.t10k }} ${{ matrix.igs }} ${{ matrix.pademu }} ${{ matrix.rtl }} NOT_PACKED=1
- name: Compile -> make ${{ matrix.extra }} ${{ matrix.pademu }} ${{ matrix.extra }} NOT_PACKED=1
run: |
make --trace ${{ matrix.t10k }} ${{ matrix.igs }} ${{ matrix.pademu }} ${{ matrix.rtl }} NOT_PACKED=1
mv opl.elf OPNPS2LD-${{ env.OPL_VERSION }}-${{ matrix.t10k }}-${{ matrix.igs }}-${{ matrix.pademu }}-${{ matrix.rtl }}.ELF
make --trace ${{ matrix.pademu }} ${{ matrix.extra }} NOT_PACKED=1
mv opl.elf OPNPS2LD-${{ env.OPL_VERSION }}-${{ matrix.pademu }}-${{ matrix.extra }}.ELF
- name: Create detailed changelog
run: sh ./make_changelog.sh

- name: Upload variants artifact ELF
uses: actions/upload-artifact@v4
with:
name: OPNPS2LD-VARIANTS ${{ matrix.t10k }} ${{ matrix.igs }} ${{ matrix.pademu }} ${{ matrix.rtl }}
name: OPNPS2LD-VARIANTS ${{ matrix.pademu }} ${{ matrix.extra }}
path: OPNPS2LD*.ELF

merge-variants:
Expand Down Expand Up @@ -120,9 +118,11 @@ jobs:
strategy:
fail-fast: false
matrix:
debug: [iopcore_debug, ingame_debug, eesio_debug, iopcore_ppctty_debug, ingame_ppctty_debug]
debug: [iopcore_debug, ingame_debug, eesio_debug, iopcore_ppctty_debug, ingame_ppctty_debug, DTL_T10000=1]
# container_commit: [":main", "@sha256:1f00689809455d43b520e4cd4eea00c6be56d71819ae38efc6b55b56464cbd1e"] Replace with desired docker image hash or tag
container_commit: [":main"]
runs-on: ubuntu-latest
container: ghcr.io/ps2homebrew/ps2homebrew:main
container: ghcr.io/ps2homebrew/ps2homebrew${{ matrix.container_commit }}
steps:
- name: git checkout
uses: actions/checkout@v4
Expand All @@ -134,16 +134,20 @@ jobs:
- name: Get version
run: |
echo "OPL_VERSION=$(make oplversion)" >> $GITHUB_ENV
SHORT_COMMIT="${{ matrix.container_commit }}"
# Extract the last 4 characters
SHORT_COMMIT=${SHORT_COMMIT: -4}
echo "SHORT_COMMIT=$SHORT_COMMIT" >> $GITHUB_ENV
- name: Compile -> make debug
run: |
make ${{ matrix.debug }} --trace
mv opl.elf opl-${{ matrix.debug }}.elf
mv opl.elf opl-${{ matrix.debug }}-${{ env.OPL_VERSION }}-${{ env.SHORT_COMMIT }}.elf
- name: Upload variants artifact ELF
uses: actions/upload-artifact@v4
with:
name: opl-${{ matrix.debug }}-${{ env.OPL_VERSION }}
name: opl-${{ matrix.debug }}-${{ env.OPL_VERSION }}-${{ env.SHORT_COMMIT }}
path: opl-*.elf

merge-debug:
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ EXTRAVERSION = Beta
# Do not COMMENT out the variables!!
# You can also specify variables when executing make: "make RTL=1 IGS=1 PADEMU=1"

#Enables/disables Right-To-Left (RTL) language support
RTL ?= 0
# Check if EXTRA_FEATURES is set, default to 0
EXTRA_FEATURES ?= 0

# Set RTL and IGS based on EXTRA_FEATURES, but allow user overrides
#Enables/disables Right-To-Left (RTL) language support
RTL ?= $(EXTRA_FEATURES)
#Enables/disables In Game Screenshot (IGS). NB: It depends on GSM and IGR to work
IGS ?= 1
IGS ?= $(EXTRA_FEATURES)

#Enables/disables pad emulator
PADEMU ?= 1
Expand Down
48 changes: 22 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ Review the LICENSE file for further details.
## Introduction

Open PS2 Loader (OPL) is a 100% Open source game and application loader for
the PS2 and PS3 units. It supports three categories of devices: USB mass
storage devices, SMB shares and the PlayStation 2 HDD unit. USB devices and
SMB shares support USBExtreme and \*.ISO formats while PS2 HDD supports HDLoader
format, all devices also support ZSO format (compressed ISO). It's now the most compatible homebrew loader.
the PS2 and PS3 units. It supports five categories of devices: USB mass
storage devices, MX4SIO (SD card connected to memory card port via adapter), iLink (SBP2 compliant storage devices via IEE1394), SMBv1 shares and the PlayStation 2 HDD unit.
USB/SMB/MX4SIO/iLink support both USBExtreme and \*.ISO formats while PS2 HDD supports HDLoader format,
all devices also support ZSO format (compressed ISO). It's now the most compatible homebrew loader.

OPL developed continuously - anyone can contribute improvements to
the project due to its open-source nature.
OPL is developed continuously - anyone can contribute improvements to the project due to its open-source nature.

You can visit the Open PS2 Loader forum at:

Expand Down Expand Up @@ -60,7 +59,7 @@ USB modes:
| Folder | Description | Modes |
| ------ | ---------------------------------------------------- | ----------- |
| `CD` | for games on CD media - i.e. blue-bottom discs | USB and SMB |
| `DVD` | for DVD5 and DVD9 images if using the NTFS file system on USB or SMB; DVD9 images must be split and placed into the device root if using the FAT32 file system on USB or SMB | USB and SMB |
| `DVD` | for DVD5 and DVD9 images (if filesystem supports +4gb files) | USB and SMB |
| `VMC` | for Virtual Memory Card images - from 8MB up to 64MB | all |
| `CFG` | for saving per-game configuration files | all |
| `ART` | for game art images | all |
Expand All @@ -70,25 +69,24 @@ USB modes:

OPL will automatically create the above directory structure the first time you launch it and enable your favorite device.

For HDD users, OPL will read `hdd0:__common/OPL/conf_hdd.cfg` for the config entry "hdd_partition" to use as your OPL partition.
For HDD users, OPL will read `hdd0:__common/OPL/conf_hdd.cfg` for the config entry `hdd_partition` to use as your OPL partition.
If not found a config file, a 128Mb `+OPL` partition will be created. You can edit the config if you wish to use/create a different partition.
All partitions created by OPL will be 128Mb (it is not recommended to enlarge partitions as it will break LBAs, instead remove and recreate manually with uLaunchELF at a larger size if needed).

</p>
</details>

<details>
<summary> <b> USB </b> </summary>
<p>
<summary> <b> USB/MX4SIO/iLink </b> </summary>


Game files on USB must be perfectly defragmented either file by file or
by whole drive, and Dual Layer DVD9 images must be split to avoid the 4GB
limitations of the FAT32 file system. We do not recommend using any programs.
The best way for defragmenting - copy all files to pc, format USB, copy all files back.
Game files should be *ideally* defragmented either file by file or by whole drive,
and games larger than 4gb must use USBExtreme format if device uses FAT32 format (see OPLUtil or USBUtil programs).
We do **not** recommend using any defrag programs. The best way for defragmenting - copy all files to pc, format USB, copy all files back.
Repeat it once you faced defragmenting problem again.

You also need a PC program to convert or split games into USB Advance/Extreme
format, such as USBUtil 2.0.
> NOTE: partial file fragmentation is supported (up to 64 fragments!) since OPL v1.2.0 - rev1893

</p>
</details>
Expand All @@ -100,9 +98,7 @@ format, such as USBUtil 2.0.
For loading games by SMB protocol, you need to share a folder (ex: PS2SMB)
on the host machine or NAS device and make sure that it has full read and
write permissions. USB Advance/Extreme format is optional - \*.ISO images
are supported using the folder structure above with the bonus that
DVD9 images don't have to be split if your SMB device uses the NTFS or
EXT3/4 file system.
are supported using the folder structure above.

</p>
</details>
Expand Down Expand Up @@ -233,26 +229,26 @@ As of version 1.2.0, compressed ISO files in ZSO format is supported by OPL.

To handle ZSO files, a python script (ziso.py) is included in the pc folder of this repository.
It requires Python 3 and the LZ4 library:

```sh
pip install lz4
```

To compress an ISO file to ZSO:

```sh
python ziso.py -c 2 "input.iso" "output.zso"
```

To decompress a ZSO back to the original ISO:

```sh
python ziso.py -c 0 "input.zso" "output.iso"
```

You can copy ZSO files to the same folder as your ISOs and they will be detected by OPL.
To install onto internal HDD, you can use the latest version of HDL-Dump.

</p>
</details>

Expand Down
58 changes: 45 additions & 13 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ static int splitAssignment(char *line, char *key, size_t keymax, char *val, size

if (eqpos) {
// copy the name and the value
size_t keylen = min(keymax, eqpos - line);
size_t keylen = min(keymax - 1, eqpos - line);

strncpy(key, line, keylen);
key[keylen] = '\0';

eqpos++;

size_t vallen = min(valmax, strlen(line) - (eqpos - line));
size_t vallen = min(valmax - 1, strlen(line) - (eqpos - line));
strncpy(val, eqpos, vallen);
val[vallen] = '\0';
}

return (int)eqpos;
Expand Down Expand Up @@ -125,6 +127,9 @@ static int configKeyValidate(const char *key)
static struct config_value_t *allocConfigItem(const char *key, const char *val)
{
struct config_value_t *it = (struct config_value_t *)malloc(sizeof(struct config_value_t));
if (it == NULL)
return NULL;

strncpy(it->key, key, sizeof(it->key));
it->key[sizeof(it->key) - 1] = '\0';
strncpy(it->val, val, sizeof(it->val));
Expand Down Expand Up @@ -233,8 +238,11 @@ void configEnd()

config_set_t *configAlloc(int type, config_set_t *configSet, char *fileName)
{
if (!configSet)
if (!configSet) {
configSet = (config_set_t *)malloc(sizeof(config_set_t));
if (configSet == NULL)
return NULL;
}

configSet->uid = ++currentUID;
configSet->type = type;
Expand All @@ -243,17 +251,30 @@ config_set_t *configAlloc(int type, config_set_t *configSet, char *fileName)
if (fileName) {
int length = strlen(fileName) + 1;
configSet->filename = (char *)malloc(length * sizeof(char));
memcpy(configSet->filename, fileName, length);
if (configSet->filename)
memcpy(configSet->filename, fileName, length);
else {
free(configSet);
return NULL;
}
} else
configSet->filename = NULL;

configSet->modified = 0;
return configSet;
}

void configMove(config_set_t *configSet, const char *fileName)
{
int length = strlen(fileName) + 1;
configSet->filename = realloc(configSet->filename, length);
char *tmp = realloc(configSet->filename, length);
if (tmp == NULL) {
free(configSet->filename);
configSet->filename = NULL;
return;
}

configSet->filename = tmp;
memcpy(configSet->filename, fileName, length);
}

Expand Down Expand Up @@ -286,6 +307,10 @@ int configSetStr(config_set_t *configSet, const char *key, const char *value)

if (it) {
if (strncmp(it->val, value, sizeof(it->val)) != 0) {
// make sure that value fits in the allocated space
if (strlen(value) >= sizeof(it->val) - 1)
return 0;

strncpy(it->val, value, sizeof(it->val));
it->val[sizeof(it->val) - 1] = '\0';
if (it->key[0] != '#')
Expand Down Expand Up @@ -377,23 +402,27 @@ int configRemoveKey(config_set_t *configSet, const char *key)
if (key[0] != '#')
configSet->modified = 1;

struct config_value_t *next = val->next;

if (val == configSet->head)
configSet->head = next;
else
prev->next = next;

if (val == configSet->tail)
configSet->tail = prev;

val = val->next;
if (prev) {
free(prev->next);
prev->next = val;
} else {
free(configSet->head);
configSet->head = val;
}
free(val);
val = next;
} else {
prev = val;
val = val->next;
}
}

if (configSet->head == NULL)
configSet->tail = NULL;

return 1;
}

Expand Down Expand Up @@ -574,6 +603,9 @@ int configGetStat(config_set_t *configSet, iox_stat_t *stat)

void configClear(config_set_t *configSet)
{
if (configSet == NULL)
return;

while (configSet->head) {
struct config_value_t *cur = configSet->head;
configSet->head = cur->next;
Expand Down
1 change: 1 addition & 0 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ int guiShowKeyboard(char *value, int maxLength)
{
char tmp[maxLength];
strncpy(tmp, value, maxLength);
tmp[maxLength - 1] = '\0';

int result = diaShowKeyb(tmp, maxLength, 0, NULL);
if (result) {
Expand Down
16 changes: 11 additions & 5 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,10 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv
AddHistoryRecordUsingFullPath(filename);
#endif

if (gExitPath[0] == '\0')
strncpy(gExitPath, "Browser", sizeof(gExitPath));
if (gExitPath[0] == '\0') {
strncpy(gExitPath, "Browser", sizeof(gExitPath) - 1);
gExitPath[sizeof(gExitPath) - 1] = '\0';
}

// Disable sound effects via libsd, to prevent some games with improper initialization from inadvertently using digital effect settings from other software.
LOG("[CLEAREFFECTS]:\n");
Expand Down Expand Up @@ -895,8 +897,11 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv
config->magic[0] = EE_CORE_MAGIC_0;
config->magic[1] = EE_CORE_MAGIC_1;

strncpy(config->ExitPath, gExitPath, CORE_EXIT_PATH_MAX_LEN);
strncpy(config->GameModeDesc, mode_str, CORE_GAME_MODE_DESC_MAX_LEN);
strncpy(config->ExitPath, gExitPath, CORE_EXIT_PATH_MAX_LEN - 1);
config->ExitPath[CORE_EXIT_PATH_MAX_LEN - 1] = '\0';

strncpy(config->GameModeDesc, mode_str, CORE_GAME_MODE_DESC_MAX_LEN - 1);
config->GameModeDesc[CORE_GAME_MODE_DESC_MAX_LEN - 1] = '\0';

config->EnableDebug = gEnableDebug;
config->HDDSpindown = gHDDSpindown;
Expand Down Expand Up @@ -947,7 +952,8 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv
config->ModStorageStart = ModuleStorage;
config->ModStorageEnd = ModuleStorageEnd;

strncpy(config->GameID, filename, CORE_GAME_ID_MAX_LEN);
strncpy(config->GameID, filename, CORE_GAME_ID_MAX_LEN - 1);
config->GameID[CORE_GAME_ID_MAX_LEN - 1] = '\0';

config->_CompatMask = compatflags;

Expand Down
Loading

0 comments on commit 6075a2a

Please sign in to comment.