Skip to content

Commit

Permalink
Fix MDEC CD speed, add FMV queue, remove release target
Browse files Browse the repository at this point in the history
  • Loading branch information
luksamuk committed Aug 30, 2024
1 parent 5832c60 commit 2b15945
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 57 deletions.
16 changes: 0 additions & 16 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@
"warnings": {
"dev": false
}
},
{
"name": "release",
"displayName": "Release configuration",
"description": "Build the project using PSn00bSDK on Release target",
"generator": "Unix Makefiles",
"toolchainFile": "$env{PSN00BSDK_LIBS}/cmake/sdk.cmake",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"PSN00BSDK_TC": "",
"PSN00BSDK_TARGET": "mipsel-none-elf"
},
"warnings": {
"dev": false
}
}
]
}
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ run: ./build/engine.cue
emu:
2>/dev/null 1>&2 pcsx-redux -gdb -gdb-port 3333 -run -interpreter -fastboot &

# Build as release target
release: purge cook
cmake --preset release .
cd build && make iso
tochd -d . -- ./build/engine.cue

# Run debugger
debug:
gdb-multiarch
Expand Down
1 change: 1 addition & 0 deletions assets/bgm/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
\rustyruin2.xa
\letmomsleep.xa
\letmomsleep2.xa
\youremyhero.xa
Binary file added assets/bgm/BGM003.XA
Binary file not shown.
4 changes: 4 additions & 0 deletions assets/bgm/BGM003.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1 xa youremyhero.xa 1 0
1 null
1 null
1 null
Binary file added assets/bgm/youremyhero.flac
Binary file not shown.
Binary file modified assets/fmv/INTRO.STR
Binary file not shown.
Binary file modified assets/fmv/SONICT.STR
Binary file not shown.
2 changes: 1 addition & 1 deletion assets/fmv/convert.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

for f in *.mp4; do
psxavenc -t str2 -f 37800 -b 4 -c 2 -s 320x240 -r 15 -x 1 "$f" "${f%%.mp4}.STR"
psxavenc -t str2 -f 37800 -b 4 -c 2 -s 320x240 -r 15 -x 2 "$f" "${f%%.mp4}.STR"
done

2 changes: 1 addition & 1 deletion include/screens/fmv.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ void screen_fmv_update();
void screen_fmv_draw();

void screen_fmv_set_next(ScreenIndex next);
void screen_fmv_set_path(const char *filepath);
void screen_fmv_enqueue(const char *filepath);

#endif
3 changes: 3 additions & 0 deletions iso.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
<file name="BGM002.XA"
type="xa"
source="${PROJECT_SOURCE_DIR}/assets/bgm/BGM002.XA" />
<file name="BGM003.XA"
type="xa"
source="${PROJECT_SOURCE_DIR}/assets/bgm/BGM003.XA" />
</dir>

<file name="INTRO.STR"
Expand Down
3 changes: 1 addition & 2 deletions src/mdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ mdec_start(const char *filepath)
// Read at 2x speed to play any XA-ADPCM sectors that could be
// interleaved with the data
// Start reading in real-time mode (doesn't retry in case of errors).
//uint8_t mode = CdlModeRT | CdlModeSpeed;
uint8_t mode = CdlModeRT;
uint8_t mode = CdlModeRT | CdlModeSpeed;
CdControl(CdlSetmode, (const uint8_t *)&mode, 0);
CdControl(CdlReadS, &file.pos, 0);

Expand Down
15 changes: 10 additions & 5 deletions src/screen_disclaimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ static uint16_t disclaimer_timer = 0;

extern int debug_mode;

void screen_disclaimer_load()
void
screen_disclaimer_load()
{
uint32_t length;
disclaimer_bg = file_read("\\MISC\\DISK.TIM;1", &length);
}

void screen_disclaimer_unload()
void
screen_disclaimer_unload()
{
free(disclaimer_bg);
disclaimer_bg = NULL;
disclaimer_timer = 0;
}

void screen_disclaimer_update()
void
screen_disclaimer_update()
{
if((pad_pressing(PAD_L1) && pad_pressed(PAD_R1)) ||
(pad_pressed(PAD_L1) && pad_pressing(PAD_R1))) {
Expand All @@ -44,13 +47,15 @@ void screen_disclaimer_update()
// Prepare intro, but also prepare level
screen_level_setlevel(0);
screen_fmv_set_next(SCREEN_LEVEL);
screen_fmv_set_path("\\SONICT.STR;1");
screen_fmv_enqueue("\\SONICT.STR;1");
screen_fmv_enqueue("\\INTRO.STR;1");
scene_change(SCREEN_FMV);
}
}
}

void screen_disclaimer_draw()
void
screen_disclaimer_draw()
{
TIM_IMAGE tim;
GetTimInfo((const uint32_t *)disclaimer_bg, &tim);
Expand Down
30 changes: 22 additions & 8 deletions src/screen_fmv.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,46 @@
#include "screen.h"
#include "mdec.h"

#define FMV_QUEUE_MAX 3

// Default screen to level select.
// Can't wait for hackers using ACE to manipulate this someday :)
static ScreenIndex next_screen = SCREEN_LEVELSELECT;
static const char *fmv_path = NULL;

static const char *fmv_queue[FMV_QUEUE_MAX];
static uint8_t fmv_count = 0;

void screen_fmv_load() {}

void screen_fmv_unload() {}
void
screen_fmv_unload()
{
fmv_count = 0;
}

void screen_fmv_update()
void
screen_fmv_update()
{
mdec_play(fmv_path); // TODO: Interrupt playback?
for(uint8_t i = 0; i < fmv_count; i++)
mdec_play(fmv_queue[i]);
scene_change(next_screen);
}

void screen_fmv_draw() {}


void screen_fmv_set_next(ScreenIndex next)
void
screen_fmv_set_next(ScreenIndex next)
{
next_screen = next;
}

void screen_fmv_set_path(const char *filepath)
void
screen_fmv_enqueue(const char *filepath)
{
fmv_path = filepath;
if(fmv_count < FMV_QUEUE_MAX) {
fmv_queue[fmv_count] = filepath;
fmv_count++;
}
}


46 changes: 28 additions & 18 deletions src/screen_levelselect.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "render.h"
#include "screens/level.h"
#include "screens/fmv.h"
#include "sound.h"

#define CHOICE_SONICT 4
#define CHOICE_INTRO 5
Expand All @@ -17,14 +18,22 @@ static uint8_t menu_choice = 0;

extern int debug_mode;

void screen_levelselect_load()
void
screen_levelselect_load()
{
menu_choice = 0;
sound_stop_xa();
sound_play_xa("\\BGM\\BGM003.XA;1", 0, 0, 0);
}

void screen_levelselect_unload() {}
void
screen_levelselect_unload()
{
sound_stop_xa();
}

void screen_levelselect_update()
void
screen_levelselect_update()
{
if((pad_pressing(PAD_L1) && pad_pressed(PAD_R1)) ||
(pad_pressed(PAD_L1) && pad_pressing(PAD_R1))) {
Expand All @@ -43,11 +52,11 @@ void screen_levelselect_update()
if(pad_pressed(PAD_START) || pad_pressed(PAD_CROSS)) {
if(menu_choice == CHOICE_INTRO) {
screen_fmv_set_next(SCREEN_LEVELSELECT);
screen_fmv_set_path("\\INTRO.STR;1");
screen_fmv_enqueue("\\INTRO.STR;1");
scene_change(SCREEN_FMV);
} else if(menu_choice == CHOICE_SONICT) {
screen_fmv_set_next(SCREEN_LEVELSELECT);
screen_fmv_set_path("\\SONICT.STR;1");
screen_fmv_enqueue("\\SONICT.STR;1");
scene_change(SCREEN_FMV);
} else {
screen_level_setlevel(menu_choice);
Expand All @@ -56,7 +65,8 @@ void screen_levelselect_update()
}
}

void screen_levelselect_draw()
void
screen_levelselect_draw()
{
char buffer[255] = { 0 };

Expand All @@ -65,20 +75,20 @@ void screen_levelselect_draw()
x = CENTERX - (strlen(title) * 4);
draw_text(x, 12, 0, title);

const char *subtitle = "https://luksamuk.codes/";
x = CENTERX - (strlen(subtitle) * 4);
draw_text(x, 24, 0, subtitle);

snprintf(buffer, 255, "%s %s", __DATE__, __TIME__);
x = SCREEN_XRES - (strlen(buffer) * 8) - 8;
draw_text(x, SCREEN_YRES - 24, 0, buffer);
x = CENTERX - (strlen(buffer) * 4);
draw_text(x, 24, 0, buffer);

const char *subtitle = "https://luksamuk.codes/";
x = SCREEN_XRES - (strlen(subtitle) * 8) - 8;
draw_text(x, SCREEN_YRES - 24, 0, subtitle);

snprintf(
buffer, 255,
"%c Round 0 Zone 1\n"
"%c Round 0 Zone 2\n"
"%c Round 1 Zone 1\n"
"%c Round 1 Zone 2\n"
"%c R0Z1\n"
"%c R0Z2\n"
"%c R1Z1\n"
"%c R1Z2\n"
"\n"
"\n"
"\n"
Expand All @@ -90,8 +100,8 @@ void screen_levelselect_draw()
"\n"
"\n"
"\n"
"%c SonicT\n"
"%c Intro",
"%c FMV:SONICT\n"
"%c FMV:INTRO",
(menu_choice == 0) ? '>' : ' ',
(menu_choice == 1) ? '>' : ' ',
(menu_choice == 2) ? '>' : ' ',
Expand Down

0 comments on commit 2b15945

Please sign in to comment.