Skip to content

Commit 36f2860

Browse files
author
Trulio
committed
Update Ps2 build workflow
1 parent caf1fa5 commit 36f2860

40 files changed

Lines changed: 413 additions & 223 deletions

‎.github/workflows/ps2.yml‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build PlayStation 2 ISO
2+
3+
on:
4+
push:
5+
paths:
6+
- '.github/workflows/ps2.yml'
7+
- 'CMakeLists.txt'
8+
- 'src/**'
9+
- 'thirdparty/**'
10+
- 'tools/ps2/**'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/ps2.yml'
14+
- 'CMakeLists.txt'
15+
- 'src/**'
16+
- 'thirdparty/**'
17+
- 'tools/ps2/**'
18+
workflow_dispatch:
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
env:
27+
PS2DEV: ${{ runner.temp }}/ps2dev
28+
29+
steps:
30+
- name: Check out the repository
31+
uses: actions/checkout@v6
32+
33+
- name: Install PS2DEV
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install --yes cmake genisoimage
37+
mkdir -p "$PS2DEV"
38+
curl --fail --location --retry 3 \
39+
--output /tmp/ps2dev.tar.gz \
40+
https://github.com/ps2dev/ps2dev/releases/download/latest/ps2dev-ubuntu-latest.tar.gz
41+
tar --extract --file /tmp/ps2dev.tar.gz --strip-components=1 --directory "$PS2DEV"
42+
43+
- name: Build the data-free ISO
44+
run: sh tools/ps2/build-iso.sh
45+
46+
- name: Verify the ISO
47+
run: |
48+
test -s build/ps2/openshadowflare.iso
49+
! isoinfo -i build/ps2/openshadowflare.iso -f | grep -qi 'SFGAME.BIN'
50+
51+
- name: Upload the ISO
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: openshadowflare-ps2-release
55+
path: build/ps2/openshadowflare.iso
56+
if-no-files-found: error

‎documentation/ps2-port.md‎

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,71 @@
1-
# PlayStation 2 port
1+
# PS2 port
22

3-
The PS2 port is packaged through Docker, so the repository does not need a
4-
local ps2dev toolchain. With the original game
5-
files present under `tmp/ShadowFlare`, run:
3+
## Build
4+
5+
Install PS2DEV and `genisoimage`, then set its environment variables:
6+
7+
```sh
8+
export PS2DEV="$HOME/ps2dev"
9+
export PS2SDK="$PS2DEV/ps2sdk"
10+
export GSKIT="$PS2DEV/gsKit"
11+
export PATH="$PATH:$PS2DEV/bin:$PS2DEV/ee/bin:$PS2DEV/iop/bin"
12+
```
13+
14+
On Ubuntu or WSL, install the PS2DEV prebuilt toolchain and build:
615

716
```sh
17+
sudo apt-get update && sudo apt-get install -y curl cmake genisoimage
18+
mkdir -p "$PS2DEV"
19+
curl -fL https://github.com/ps2dev/ps2dev/releases/download/latest/ps2dev-ubuntu-latest.tar.gz \
20+
| tar -xz --strip-components=1 -C "$PS2DEV"
821
sh tools/ps2/build-iso.sh
922
```
1023

11-
The first run builds the `openshadowflare-ps2` image from
12-
`tools/ps2/Dockerfile`; later runs reuse it. The generated disc files,
13-
including `openshadowflare.iso`, are written to `build/ps2`.
24+
The archive is published on [PS2DEV releases](https://github.com/ps2dev/ps2dev/releases).
25+
26+
The default output, `build/ps2/openshadowflare.iso`, is data-free and suitable
27+
for CI and distribution. It loads an owned `ShadowFlare` data directory placed
28+
beside the ISO in PCSX2, or at the root of a FAT32 USB drive on PS2 hardware:
29+
30+
```text
31+
<PCSX2 ISO folder>/
32+
openshadowflare.iso
33+
ShadowFlare/
34+
SFlare.Cfg
35+
System/
36+
Scenario/
37+
Save/
38+
Player/
39+
Map/
40+
Character/
41+
42+
FAT32 USB drive/
43+
ShadowFlare/
44+
SFlare.Cfg
45+
...
46+
```
47+
48+
PCSX2 maps its ISO folder to the `host0:` device. The PS2 ISO includes the
49+
USB drivers required to use `mass:` on hardware. Copy the owned game data:
50+
51+
```sh
52+
# PCSX2: copy next to build/ps2/openshadowflare.iso.
53+
cp -a /path/to/ShadowFlare build/ps2/
54+
55+
# PS2 hardware: copy to the root of a mounted FAT32 USB drive.
56+
cp -a /path/to/ShadowFlare /media/$USER/PS2USB/
57+
```
58+
59+
Alternatively, create a private all-in-one disc from an owned retail
60+
installation:
61+
62+
```sh
63+
sh tools/ps2/build-iso.sh --data-dir /path/to/ShadowFlare
64+
```
65+
66+
## Type portability
1467

15-
Use `--build-image` to force a rebuild of the Docker image after changing the
16-
toolchain setup, and `--data-dir` or `--out-dir` to override the default input
17-
or output locations.
68+
On PS2DEV, `std::int32_t` is `long`, not `int`. Use typed literals such as
69+
`std::int32_t{0}` with `std::min`, `std::max`, and `std::clamp`; their
70+
arguments must have the same type. Format fixed-width integers with `PRId32`
71+
from `<cinttypes>` rather than `%d`.

‎src/SF_EXE/cmake/platforms/PS2.cmake‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ function(osf_configure_ps2_platform target)
66
runtime/platform/ps2/ps2_data_backend.cpp
77
runtime/platform/ps2/surface_presenter.cpp
88
)
9-
target_link_libraries(${target} PRIVATE gskit dmakit)
9+
target_link_libraries(${target} PRIVATE gskit dmakit loadfile)
1010
endfunction()

‎src/SF_EXE/items/item_information.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ std::int32_t itemSalePrice(
6262
std::int32_t itemPurchasePrice(
6363
const InventoryItem&,
6464
const ItemDefinition& definition) {
65-
return std::max(definition.base_price, 0);
65+
return std::max(definition.base_price, std::int32_t{0});
6666
}
6767

6868
std::string itemInformationText(

‎src/SF_EXE/items/item_repair.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ std::int32_t retailItemRepairPrice(
111111
}
112112
const std::int32_t current = std::clamp(
113113
itemCurrentDurability(item, definition),
114-
0,
114+
std::int32_t{0},
115115
definition.maximum_durability);
116116
if (current == definition.maximum_durability) {
117117
return 0;

‎src/SF_EXE/libs/RKC_DBFCONTROL/software_backend.cpp‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ std::uint8_t addChannel(
6161
std::min(
6262
static_cast<std::int32_t>(destination) +
6363
source_amount,
64-
255));
64+
std::int32_t{255}));
6565
}
6666

6767
std::uint8_t readPixelIndex(
@@ -158,7 +158,9 @@ bool SoftwareBackend::drawPattern(
158158
const bool additive =
159159
draw.blend_mode == PatternBlendMode::additive;
160160
const std::int32_t opacity = std::clamp(
161-
draw.opacity, 0, additive ? 2000 : 1000);
161+
draw.opacity,
162+
std::int32_t{0},
163+
additive ? std::int32_t{2000} : std::int32_t{1000});
162164

163165
for (const NjpPatternPart& item : pattern.parts) {
164166
if (item.part_index < 0 ||
@@ -480,7 +482,11 @@ bool SoftwareBackend::drawBitMask(
480482
}
481483

482484
const std::int32_t opacity =
483-
std::clamp(draw.opacity, 0, 1000) * draw.color.alpha / 255;
485+
std::clamp(
486+
draw.opacity,
487+
std::int32_t{0},
488+
std::int32_t{1000}) *
489+
draw.color.alpha / std::int32_t{255};
484490
if (opacity <= 0) {
485491
return true;
486492
}
@@ -674,7 +680,10 @@ bool SoftwareBackend::drawRectangle(
674680
return true;
675681
}
676682
const std::int32_t opacity =
677-
std::clamp(draw.opacity, 0, 1000);
683+
std::clamp(
684+
draw.opacity,
685+
std::int32_t{0},
686+
std::int32_t{1000});
678687
if (opacity >= 1000) {
679688
for (std::int32_t y = top; y < bottom; ++y) {
680689
Color* row = pixels_.data() +
@@ -713,7 +722,10 @@ bool SoftwareBackend::drawLine(const LineDraw& draw) {
713722
const bool clipped =
714723
draw.clip.width > 0 && draw.clip.height > 0;
715724
const std::int32_t opacity =
716-
std::clamp(draw.opacity, 0, 1000);
725+
std::clamp(
726+
draw.opacity,
727+
std::int32_t{0},
728+
std::int32_t{1000});
717729
const auto draw_point = [this, &draw, color, clipped, opacity](
718730
std::int32_t x,
719731
std::int32_t y) {

‎src/SF_EXE/render/character_select_renderer.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ void renderSavedGames(
327327
: brightness / 2;
328328
const bool selectedItem =
329329
index ==
330-
static_cast<std::size_t>(std::max(selected, 0));
330+
static_cast<std::size_t>(
331+
std::max(selected, std::int32_t{0}));
331332
const gapi::Color labelColor = selectedItem
332333
? gapi::Color{224, 192, 128, 255}
333334
: gapi::Color{112, 96, 64, 255};

‎src/SF_EXE/render/gameplay_magic_renderer.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <algorithm>
1212
#include <array>
1313
#include <cstddef>
14+
#include <cinttypes>
1415
#include <cstdio>
1516
#include <string>
1617
#include <string_view>
@@ -88,7 +89,7 @@ void drawShadowedText(
8889

8990
std::string number(std::int32_t value) {
9091
char buffer[32]{};
91-
std::snprintf(buffer, sizeof(buffer), "%d", value);
92+
std::snprintf(buffer, sizeof(buffer), "%" PRId32, value);
9293
return buffer;
9394
}
9495

‎src/SF_EXE/render/gameplay_overlay_renderer.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ gapi::Color scenarioObjectNameColor(
103103

104104
std::uint8_t colorChannel(std::int32_t value) {
105105
return static_cast<std::uint8_t>(
106-
std::clamp(value, 0, 255));
106+
std::clamp(
107+
value, std::int32_t{0}, std::int32_t{255}));
107108
}
108109

109110
void drawScenarioTextLabels(
@@ -140,7 +141,10 @@ void drawScenarioTextLabels(
140141
height + kMargin * 2,
141142
{0, 0, 0, 255},
142143
1000,
143-
std::clamp(label.background_opacity, 0, 1000),
144+
std::clamp(
145+
label.background_opacity,
146+
std::int32_t{0},
147+
std::int32_t{1000}),
144148
});
145149
renderer.drawText(
146150
*font,

‎src/SF_EXE/render/gameplay_status_renderer.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ void renderGameplayStatusPanel(
199199
static_cast<std::size_t>(
200200
36 + std::clamp(
201201
affinities[element] + 10,
202-
0,
203-
20)),
202+
std::int32_t{0},
203+
std::int32_t{20})),
204204
{0, static_cast<std::int32_t>(element) * 16});
205205
}
206206

0 commit comments

Comments
 (0)