Skip to content

Commit

Permalink
Fixed resample buffer overflow
Browse files Browse the repository at this point in the history
Fixed GetTN (fixes Disney's Hercules Action Game (USA))
  • Loading branch information
allkern committed Aug 5, 2024
1 parent 5a78ffe commit 77a5b94
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
12 changes: 6 additions & 6 deletions compat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Not working:
CTR - Crash Team Racing (USA) *16 (regression)
Fixed: Crash Bash (USA) *1 (2989bb6)
Fixed: Crime Crackers (Japan) *20 (e145a4e)
Disney's Hercules Action Game (USA) *22
Disney's The Emperor's New Groove (USA).cue *22
Fixed: Disney's Hercules Action Game (USA) *22
Fixed: Disney's The Emperor's New Groove (USA).cue *22
Fixed: Doom (All) *4 (e145a4e)
Fixed: Elder Gate (Japan) *1 (2989bb6)
Fixed: Fear Effect (USA) (Disc 1) *3
Fixed: Final Doom (All) *4 (e145a4e)
Fixed: Final Fantasy IX (USA) (Disc 1) *22
Fixed: Gran Turismo 2 - Music at the Speed of Sound - The Album (USA) (Bonus PlayStation Disc) *19 (regression)
Hello Kitty - Cube Frenzy (USA) *22
Initial D (Japan) *3 (regression)
Fixed: Hello Kitty - Cube Frenzy (USA) *22 (FMVs are very slow though)
Fixed: Initial D (Japan) *22
Fixed: Konami 80's Arcade Gallery (Japan) *1 (2989bb6)
Nagano Winter Olympics '98 (USA) *18
Need for Speed II (USA) *17
Expand All @@ -38,7 +38,7 @@ Tama - Adventurous Ball in Giddy Labyrinth (Japan) *5
Fixed: Time Gal & Ninja Hayate (Japan) (En,Ja) (Disc 2) (Ninja Hayate) *9
Fixed: Tokimeki Memorial 2 (Japan) *1 (2989bb6)
Fixed: Tomb Raider (USA) *8 (e145a4e)
Tony Hawk's Pro Skater (USA) *10
Fixed: Tony Hawk's Pro Skater (USA) *22
Vib-Ribbon (Japan) *8
WipeOut (USA) *7
Fixed: Yu-Gi-Oh! Forbidden Memories (USA) *1 (2989bb6)
Expand All @@ -65,7 +65,7 @@ Notes:
*19 Hangs on CdlSetloc deadloop
*20 GetlocP loop hangs
*21 Hangs after 0-sized CDROM DMA
*22 MDEC corruption (need to fix ASAP)
*22 MDEC corruption (fixed, XA resample buffer overflow)

Graphical issues:
Most graphical issues (black models, 1-pixel seams, polygon explosions, etc.) have been fixed!
Expand Down
12 changes: 7 additions & 5 deletions psx/dev/cdrom/cdrom.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@

#define XA_STEREO_SAMPLES 2016 // Samples per sector
#define XA_MONO_SAMPLES 4032 // Samples per sector
#define XA_STEREO_RESAMPLE_SIZE 2352 // 2352 * 2
#define XA_MONO_RESAMPLE_SIZE 4704 // 4704 * 2
#define XA_STEREO_RESAMPLE_SIZE 2352 // 2352
#define XA_MONO_RESAMPLE_SIZE 4704 // 4704
#define XA_STEREO_RESAMPLE_MAX_SIZE 4704 // 2352 * 2 (because of 18KHz mode)
#define XA_MONO_RESAMPLE_MAX_SIZE 9408 // 4704 * 2 (because of 18KHz mode)
#define XA_UPSAMPLE_SIZE 28224 // 4032 * 7
#define XA_RINGBUF_SIZE 32

Expand Down Expand Up @@ -252,9 +254,9 @@ typedef struct {
int16_t xa_right_buf[XA_STEREO_SAMPLES];
int16_t xa_mono_buf[XA_MONO_SAMPLES];
int16_t xa_upsample_buf[XA_UPSAMPLE_SIZE];
int16_t xa_left_resample_buf[XA_STEREO_RESAMPLE_SIZE];
int16_t xa_right_resample_buf[XA_STEREO_RESAMPLE_SIZE];
int16_t xa_mono_resample_buf[XA_MONO_RESAMPLE_SIZE];
int16_t xa_left_resample_buf[XA_STEREO_RESAMPLE_MAX_SIZE];
int16_t xa_right_resample_buf[XA_STEREO_RESAMPLE_MAX_SIZE];
int16_t xa_mono_resample_buf[XA_MONO_RESAMPLE_MAX_SIZE];
} psx_cdrom_t;

enum {
Expand Down
2 changes: 1 addition & 1 deletion psx/dev/cdrom/impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ void cdrom_cmd_gettn(psx_cdrom_t* cdrom) {
queue_push(cdrom->response, 1);
queue_push(cdrom->response, ITOB(tn));

cdrom_pause(cdrom);
cdrom_restore_state(cdrom);
}

void cdrom_cmd_gettd(psx_cdrom_t* cdrom) {
Expand Down

0 comments on commit 77a5b94

Please sign in to comment.