diff --git a/Makefile b/Makefile index 7774a5f..974f828 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,11 @@ scsp/sine-44100-s16be-1ch.pcm: scsp/slot.elf: scsp/slot.o scsp/sine-44100-s16be-1ch.pcm.o +m68k: + +m68k/%.bin: m68k + $(MAKE) -C m68k $(notdir $@) + scsp/sound_cpu.elf: scsp/sound_cpu.o m68k/slot.bin.o # clean @@ -89,3 +94,6 @@ clean-sh: common/keyboard.cpp \ common/keyboard.hpp \ wordle/word_list.hpp + + +PHONY: m68k diff --git a/m68k/main.cpp b/m68k/main.cpp deleted file mode 100644 index a73c095..0000000 --- a/m68k/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -extern "C" -void start(void) -{ - while (1) {} -} diff --git a/m68k/slot.cpp b/m68k/slot.cpp index 353a739..28b405c 100644 --- a/m68k/slot.cpp +++ b/m68k/slot.cpp @@ -10,7 +10,7 @@ void main() { for (long i = 0; i < 807; i++) { asm volatile ("nop"); } // wait for (way) more than 30µs - scsp.reg.ctrl.MIXER = MIXER__MEM4MB | MIXER__DAC18B | MIXER__MVOL(0xf); + scsp.reg.ctrl.MIXER = MIXER__MEM4MB | MIXER__MVOL(0xf); const uint32_t sine_start = reinterpret_cast(&_sine_start); diff --git a/scsp/sound_cpu.cpp b/scsp/sound_cpu.cpp index c5128f9..1edd683 100644 --- a/scsp/sound_cpu.cpp +++ b/scsp/sound_cpu.cpp @@ -2,45 +2,35 @@ #include "smpc.h" #include "scsp.h" -#include "vdp2.h" #include "../common/copy.hpp" -#include "../common/vdp2_func.hpp" extern void * _binary_m68k_slot_bin_start __asm("_binary_m68k_slot_bin_start"); extern void * _binary_m68k_slot_bin_size __asm("_binary_m68k_slot_bin_size"); void main() { - v_blank_in(); + /* SEGA SATURN TECHNICAL BULLETIN # 51 - /* - while ((smpc.reg.SF & 1) != 0); - smpc.reg.SF = 1; - smpc.reg.COMREG = COMREG__SNDOFF; - while (smpc.reg.oreg[31] != 0b00000111); + The document suggests that Sound RAM is (somewhat) preserved + during SNDOFF. + */ while ((smpc.reg.SF & 1) != 0); smpc.reg.SF = 1; - smpc.reg.COMREG = COMREG__SNDON; - while (smpc.reg.oreg[31] != 0b00000110); - */ + smpc.reg.COMREG = COMREG__SNDOFF; + while (smpc.reg.oreg[31] != OREG31__SNDOFF); - scsp.reg.ctrl.MIXER = MIXER__MEM4MB | MIXER__DAC18B | MIXER__MVOL(0xf); + scsp.reg.ctrl.MIXER = MIXER__MEM4MB; uint32_t * m68k_main_start = (uint32_t *)&_binary_m68k_slot_bin_start; uint32_t m68k_main_size = (uint32_t)&_binary_m68k_slot_bin_size; copy(&scsp.ram.u32[0], m68k_main_start, m68k_main_size); - - while ((smpc.reg.SF & 1) != 0); - smpc.reg.SF = 1; - smpc.reg.COMREG = COMREG__SNDOFF; - while (smpc.reg.oreg[31] != 0b00000111); while ((smpc.reg.SF & 1) != 0); smpc.reg.SF = 1; smpc.reg.COMREG = COMREG__SNDON; - while (smpc.reg.oreg[31] != 0b00000110); + while (smpc.reg.oreg[31] != OREG31__SNDON); // do nothing while the sound CPU manipulates the SCSP }