Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 60483fb

Browse files
authored
Merge branch 'main' into develop
2 parents 5ddd995 + a94488c commit 60483fb

File tree

11 files changed

+80
-77
lines changed

11 files changed

+80
-77
lines changed

.github/workflows/cmake.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ name: CMake
22

33
on:
44
push:
5-
branches: [ "main", "develop" ]
6-
pull_request:
7-
branches: [ "main", "develop" ]
5+
branches:
6+
- '*'
7+
tags:
8+
- 'v*'
89

910
env:
1011
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
@@ -35,12 +36,10 @@ jobs:
3536
echo "SD2PSX_RLS_TAG=nightly" >> $GITHUB_ENV
3637
echo "nightly"
3738
fi
38-
39+
3940
- name: add build essential
4041
run: sudo apt update && sudo apt install -y build-essential gcc-arm-none-eabi
4142

42-
43-
4443
- name: Configure CMake
4544
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
4645
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
@@ -49,7 +48,7 @@ jobs:
4948
- name: Build
5049
# Build your program with the given configuration
5150
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
52-
51+
5352
- name: Configure CMake for Debug USB
5453
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
5554
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
@@ -58,21 +57,26 @@ jobs:
5857
- name: Build Debug USB
5958
# Build your program with the given configuration
6059
run: cmake --build ${{github.workspace}}/build_usb --config ${{env.BUILD_TYPE}}
61-
60+
6261
- name: Rename Debug USB uf2
6362
run: mv build_usb/sd2psx.uf2 build/sd2psx_usb_debug.uf2
6463

64+
- name: Upload artifacts
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: SD2PSX-${{ github.sha }}
68+
path: |
69+
build/*.uf2
70+
71+
6572
- uses: marvinpinto/action-automatic-releases@v1.2.1
66-
if: github.event_name != 'pull_request'
67-
# uses: marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0
73+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') #only release on tag or master branch
6874
with:
6975
# GitHub secret token
7076
title: "${{ env.SD2PSX_VERSION }}"
7177
repo_token: "${{ secrets.GITHUB_TOKEN }}"
7278
automatic_release_tag: ${{ env.SD2PSX_RLS_TAG }}
73-
prerelease: true
79+
prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') }}
7480
# Assets to upload to the release
7581
files: |
7682
build/*.uf2
77-
78-

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ build
33
keys.c
44
.cache
55
gamedbps*.dat
6-
src/version/version.c
6+
src/version/version.c

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ set(CMAKE_C_STANDARD 11)
88
set(CMAKE_CXX_STANDARD 17)
99
# set(PICO_COPY_TO_RAM 1)
1010

11-
if (CMAKE_C_BYTE_ORDER EQUAL BIG_ENDIAN)
12-
add_compile_definitions("-DBIG_ENDIAN")
13-
endif()
14-
1511
pico_sdk_init()
1612

1713
set(LV_CONF_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/lv_conf.h CACHE STRING "" FORCE)

database/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ add_custom_command(OUTPUT "${GAMEDB_PS1_OBJ}"
1414

1515
add_custom_target(gamedbobjs DEPENDS "${GAMEDB_PS1_OBJ}")
1616

17+
1718
add_library(gamedb INTERFACE)
1819
add_dependencies(gamedb gamedbobjs)
1920

database/db_obj_builder.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
string(TIMESTAMP date "%Y%m%d")
2+
3+
if(NOT EXISTS "${OUTPUT_DIR}/gamedb${SYSTEM}_${date}.o")
4+
5+
find_package (Python COMPONENTS Interpreter)
6+
7+
file(GLOB files "${OUTPUT_DIR}/gamedb${SYSTEM}_*")
8+
foreach(file ${files})
9+
file(REMOVE "${file}")
10+
endforeach()
11+
12+
13+
set(GAMEDB_${SYSTEM}_BIN "gamedb${SYSTEM}.dat")
14+
set(GAMEDB_${SYSTEM}_OBJ "${OUTPUT_DIR}/gamedb${SYSTEM}_${date}.o")
15+
16+
execute_process(
17+
COMMAND ${Python_EXECUTABLE} ${PYTHON_SCRIPT} ${SYSTEM} ${OUTPUT_DIR}
18+
WORKING_DIRECTORY ${OUTPUT_DIR}
19+
OUTPUT_QUIET
20+
)
21+
execute_process(
22+
COMMAND ${CMAKE_OBJCOPY} --input-target=binary --output-target=elf32-littlearm --binary-architecture arm --rename-section .data=.rodata "${GAMEDB_${SYSTEM}_BIN}" "${GAMEDB_${SYSTEM}_OBJ}"
23+
WORKING_DIRECTORY ${OUTPUT_DIR}
24+
OUTPUT_QUIET
25+
)
26+
27+
file(CREATE_LINK ${GAMEDB_${SYSTEM}_OBJ} "${OUTPUT_DIR}/gamedb${SYSTEM}.o" SYMBOLIC)
28+
file(REMOVE_RECURSE "${OUTPUT_DIR}/${SYSTEM}")
29+
30+
endif()

src/ps1/ps1_cardman.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ static bool ps1_cardman_sanity_check_game_id(const char* const game_id) {
6464
return (i > 0);
6565
}
6666

67+
#pragma GCC diagnostic ignored "-Warray-bounds"
6768
static uint32_t ps1_cardman_char_array_to_uint32(const char in[4]) {
68-
#if BIG_ENDIAN
6969
char inter[4] = {in[3], in[2], in[1], in[0]};
70-
#else
71-
char* inter = in;
72-
#endif
73-
return *(uint32_t*)inter;
70+
uint32_t tgt;
71+
memcpy(&tgt, inter, sizeof(tgt));
72+
return tgt;
7473
}
74+
#pragma GCC diagnostic pop
7575

7676
static uint32_t ps1_cardman_find_prefix_offset(uint32_t numericPrefix) {
7777
uint32_t offset = 0;
@@ -156,11 +156,7 @@ static bool ps1_cardman_update_game_data(const char* const id) {
156156

157157
void ps1_cardman_init(void) {
158158
card_idx = settings_get_ps1_card();
159-
if (card_idx < IDX_MIN)
160-
card_idx = IDX_MIN;
161159
card_chan = settings_get_ps1_channel();
162-
if (card_chan < CHAN_MIN || card_chan > CHAN_MAX)
163-
card_chan = CHAN_MIN;
164160
memset(card_game_id, 0, sizeof(card_game_id));
165161
}
166162

src/ps2/ps2_cardman.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
static uint8_t flushbuf[BLOCK_SIZE];
2020
static int fd = -1;
2121

22-
#define IDX_MIN 1
23-
#define IDX_BOOT 0
24-
#define CHAN_MIN 1
25-
#define CHAN_MAX 8
26-
2722
static int card_idx;
2823
static int card_chan;
2924
static uint32_t card_size;
@@ -38,11 +33,7 @@ void ps2_cardman_init(void) {
3833
card_chan = CHAN_MIN;
3934
} else {
4035
card_idx = settings_get_ps2_card();
41-
if (card_idx < IDX_MIN)
42-
card_idx = IDX_MIN;
4336
card_chan = settings_get_ps2_channel();
44-
if (card_chan < CHAN_MIN || card_chan > CHAN_MAX)
45-
card_chan = CHAN_MIN;
4637
}
4738
}
4839

@@ -68,7 +59,7 @@ static void ensuredirs(void) {
6859
char cardpath[32];
6960
if (IDX_BOOT == card_idx)
7061
snprintf(cardpath, sizeof(cardpath), "MemoryCards/PS2/BOOT");
71-
else
62+
else
7263
snprintf(cardpath, sizeof(cardpath), "MemoryCards/PS2/Card%d", card_idx);
7364

7465
sd_mkdir("MemoryCards");
@@ -219,10 +210,9 @@ void ps2_cardman_open(void) {
219210
char path[64];
220211

221212
ensuredirs();
222-
if (IDX_BOOT == card_idx)
213+
if (IDX_BOOT == card_idx) {
223214
snprintf(path, sizeof(path), "MemoryCards/PS2/BOOT/BootCard.mcd");
224-
else
225-
{
215+
} else {
226216
snprintf(path, sizeof(path), "MemoryCards/PS2/Card%d/Card%d-%d.mcd", card_idx, card_idx, card_chan);
227217
/* this is ok to do on every boot because it wouldn't update if the value is the same as currently stored */
228218
settings_set_ps2_card(card_idx);
@@ -270,13 +260,13 @@ void ps2_cardman_open(void) {
270260
fatal("cannot open card");
271261

272262
card_size = sd_filesize(fd);
273-
if ((card_size != PS2_CARD_SIZE_512K)
274-
&& (card_size != PS2_CARD_SIZE_1M)
275-
&& (card_size != PS2_CARD_SIZE_2M)
276-
&& (card_size != PS2_CARD_SIZE_4M)
263+
if ((card_size != PS2_CARD_SIZE_512K)
264+
&& (card_size != PS2_CARD_SIZE_1M)
265+
&& (card_size != PS2_CARD_SIZE_2M)
266+
&& (card_size != PS2_CARD_SIZE_4M)
277267
&& (card_size != PS2_CARD_SIZE_8M))
278268
fatal("Card %d Channel %d is corrupted", card_idx, card_chan);
279-
269+
280270
/* read 8 megs of card image */
281271
printf("reading card (%lu KB).... ", (uint32_t)(card_size / 1024));
282272
cardprog_start = time_us_64();

src/ps2/ps2_memory_card.c

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static inline void __time_critical_func(mc_respond_slow)(uint8_t ch) {
178178
pio_sm_put_blocking(pio0, dat_writer_slow.sm, ch);
179179
}
180180

181-
static uint8_t Table[] = {
181+
static uint8_t EccTable[] = {
182182
0x00, 0x87, 0x96, 0x11, 0xa5, 0x22, 0x33, 0xb4,0xb4, 0x33, 0x22, 0xa5, 0x11, 0x96, 0x87, 0x00,
183183
0xc3, 0x44, 0x55, 0xd2, 0x66, 0xe1, 0xf0, 0x77,0x77, 0xf0, 0xe1, 0x66, 0xd2, 0x55, 0x44, 0xc3,
184184
0xd2, 0x55, 0x44, 0xc3, 0x77, 0xf0, 0xe1, 0x66,0x66, 0xe1, 0xf0, 0x77, 0xc3, 0x44, 0x55, 0xd2,
@@ -197,33 +197,6 @@ static uint8_t Table[] = {
197197
0x00, 0x87, 0x96, 0x11, 0xa5, 0x22, 0x33, 0xb4,0xb4, 0x33, 0x22, 0xa5, 0x11, 0x96, 0x87, 0x00
198198
};
199199

200-
void calcECC(uint8_t *ecc, const uint8_t *data)
201-
{
202-
int i, c;
203-
204-
ecc[0] = ecc[1] = ecc[2] = 0;
205-
206-
for (i = 0 ; i < 0x80 ; i ++) {
207-
c = Table[data[i]];
208-
209-
ecc[0] ^= c;
210-
if (c & 0x80) {
211-
ecc[1] ^= ~i;
212-
ecc[2] ^= i;
213-
}
214-
}
215-
ecc[0] = ~ecc[0];
216-
ecc[0] &= 0x77;
217-
218-
ecc[1] = ~ecc[1];
219-
ecc[1] &= 0x7f;
220-
221-
ecc[2] = ~ecc[2];
222-
ecc[2] &= 0x7f;
223-
224-
return;
225-
}
226-
227200
// keysource and key are self generated values
228201
uint8_t keysource[] = { 0xf5, 0x80, 0x95, 0x3c, 0x4c, 0x84, 0xa9, 0xc0 };
229202
uint8_t dex_key[16] = { 0x17, 0x39, 0xd3, 0xbc, 0xd0, 0x2c, 0x18, 0x07, 0x4b, 0x17, 0xf0, 0xea, 0xc4, 0x66, 0x30, 0xf9 };

src/ps2/ps2_memory_card.in.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ if (ch == 0x11) {
182182
send(b);
183183

184184
if (readptr <= 512) {
185-
uint8_t c = Table[b];
185+
uint8_t c = EccTable[b];
186186
eccptr[0] ^= c;
187187
if (c & 0x80) {
188188
eccptr[1] ^= ~(readptr & 0x7F);

src/settings.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ void settings_update_part(void *settings_ptr, uint32_t sz) {
6565
#define SETTINGS_UPDATE_FIELD(field) settings_update_part(&settings.field, sizeof(settings.field))
6666

6767
int settings_get_ps2_card(void) {
68+
if (settings.ps2_card < IDX_MIN)
69+
return IDX_MIN;
6870
return settings.ps2_card;
6971
}
7072

7173
int settings_get_ps2_channel(void) {
74+
if (settings.ps2_channel < CHAN_MIN || settings.ps2_channel > CHAN_MAX)
75+
return CHAN_MIN;
7276
return settings.ps2_channel;
7377
}
7478

@@ -87,10 +91,14 @@ void settings_set_ps2_channel(int chan) {
8791
}
8892

8993
int settings_get_ps1_card(void) {
94+
if (settings.ps1_card < IDX_MIN)
95+
return IDX_MIN;
9096
return settings.ps1_card;
9197
}
9298

9399
int settings_get_ps1_channel(void) {
100+
if (settings.ps1_channel < CHAN_MIN || settings.ps1_channel > CHAN_MAX)
101+
return CHAN_MIN;
94102
return settings.ps1_channel;
95103
}
96104

@@ -131,5 +139,5 @@ bool settings_get_ps2_autoboot(void) {
131139
void settings_set_ps2_autoboot(bool autoboot) {
132140
if (autoboot != settings_get_ps2_autoboot())
133141
settings.ps2_flags ^= SETTINGS_FLAGS_AUTOBOOT;
134-
SETTINGS_UPDATE_FIELD(ps2_flags);
135-
}
142+
SETTINGS_UPDATE_FIELD(ps2_flags);
143+
}

0 commit comments

Comments
 (0)