Skip to content

Commit

Permalink
Workaround for "Sonic & Kuckles All Emeralds"
Browse files Browse the repository at this point in the history
  • Loading branch information
Fujix1 committed Dec 7, 2024
1 parent 3aba4f4 commit dae509f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/fm/fm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ void FMChip::writeRaw(byte data, byte chipno, si5351Freq_t freq) {
// 3.579MHz : 0.2794us * 32 = 8.94 us
// 1.5MHz : 0.66us * 32 = 21.3 us
WR_LOW;

ets_delay_us((32000000 / freq));

WR_HIGH;
Expand Down
1 change: 1 addition & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#define USE_YM2612
#define USE_SN76489
#define USE_YM2203

#define CHIP0_CLOCK CLK_0
#define CHIP1_CLOCK CLK_1
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void setup() {
lcd.setFont(&fonts::Font2);
lcd.println("NANO DRIVE 6");
lcd.println("2024 [email protected]");
lcd.printf("Firmware: 1.82\n\n");
lcd.printf("Firmware: 1.83\n\n");

// PSRAM 初期化確認
if (psramInit()) {
Expand Down
15 changes: 9 additions & 6 deletions src/vgm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ bool VGM::ready() {

// version
version = get_ui32_at(8);

// total # samples
// totalSamples = get_ui32_at(0x18);

// loop offset
loopOffset = get_ui32_at(0x1c);

// vg3 offset
gd3Offset = get_ui32_at(0x14) + 0x14;

Expand Down Expand Up @@ -644,10 +642,15 @@ void VGM::vgmProcessMain() {
break;

case 0x50: // SN76489 CHIP 1
if (SN76489_Freq0is0X400) {
FM.writeRaw(get_ui8(), 1, freq[chipSlot[CHIP_SN76489_0]]);
} else {
FM.write(get_ui8(), 1, freq[chipSlot[CHIP_SN76489_0]]);

// WORKAROUND FOR COMMAND TO UNDEFINED SN CHIP
// Sonic & Knuckles 30th song
if (freq[chipSlot[CHIP_SN76489_0]] != SI5351_UNDEFINED) {
if (SN76489_Freq0is0X400) {
FM.writeRaw(get_ui8(), 1, freq[chipSlot[CHIP_SN76489_0]]);
} else {
FM.write(get_ui8(), 1, freq[chipSlot[CHIP_SN76489_0]]);
}
}
break;
#endif
Expand Down

0 comments on commit dae509f

Please sign in to comment.