add m68k example
This commit is contained in:
parent
29e049ab69
commit
8246b94aee
20
Makefile
20
Makefile
@ -1,18 +1,11 @@
|
||||
CFLAGS = -Isaturn
|
||||
OPT = -Og
|
||||
LIBGCC = $(shell $(CC) -print-file-name=libgcc.a)
|
||||
|
||||
all: raytracing/raytracing.iso vdp2/nbg0.iso
|
||||
|
||||
LIB = ./saturn
|
||||
include $(LIB)/common.mk
|
||||
|
||||
define BUILD_BINARY_O
|
||||
$(OBJCOPY) \
|
||||
-I binary -O elf32-sh -B sh2 \
|
||||
--rename-section .data=.data.$(basename $@) \
|
||||
$< $@
|
||||
endef
|
||||
all:
|
||||
|
||||
include $(LIB)/common.mk
|
||||
|
||||
%.data.o: %.data
|
||||
$(BUILD_BINARY_O)
|
||||
@ -81,6 +74,8 @@ scsp/sine-44100-s16be-1ch.pcm:
|
||||
|
||||
scsp/slot.elf: scsp/slot.o scsp/sine-44100-s16be-1ch.pcm.o
|
||||
|
||||
scsp/sound_cpu.elf: scsp/sound_cpu.o m68k/slot.bin.o
|
||||
|
||||
# clean
|
||||
clean: clean-sh
|
||||
clean-sh:
|
||||
@ -90,4 +85,7 @@ clean-sh:
|
||||
-regextype posix-egrep \
|
||||
-regex '.*\.(iso|o|bin|elf|cue)$$' \
|
||||
-exec rm {} \;
|
||||
rm -f common/keyboard.cpp common/keyboard.hpp wordle/word_list.hpp
|
||||
rm -f \
|
||||
common/keyboard.cpp \
|
||||
common/keyboard.hpp \
|
||||
wordle/word_list.hpp
|
||||
|
12
m68k/Makefile
Normal file
12
m68k/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
CFLAGS = -I../saturn
|
||||
OPT = -Og
|
||||
LIB = ../saturn
|
||||
|
||||
all:
|
||||
|
||||
include $(LIB)/m68k/common.mk
|
||||
|
||||
%.pcm.o: %.pcm
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
slot.elf: $(LIB)/m68k/vectors.o slot.o sine-44100-s16be-1ch.pcm.o
|
5
m68k/main.cpp
Normal file
5
m68k/main.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
extern "C"
|
||||
void start(void)
|
||||
{
|
||||
while (1) {}
|
||||
}
|
1
m68k/sine-44100-s16be-1ch.pcm
Symbolic link
1
m68k/sine-44100-s16be-1ch.pcm
Symbolic link
@ -0,0 +1 @@
|
||||
../scsp/sine-44100-s16be-1ch.pcm
|
37
m68k/slot.cpp
Normal file
37
m68k/slot.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include <stdint.h>
|
||||
#include "smpc.h"
|
||||
#include "scsp.h"
|
||||
|
||||
#include "../common/copy.hpp"
|
||||
|
||||
extern void * _sine_start __asm("_binary_sine_44100_s16be_1ch_pcm_start");
|
||||
|
||||
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);
|
||||
|
||||
const uint32_t sine_start = reinterpret_cast<uint32_t>(&_sine_start);
|
||||
|
||||
scsp_slot& slot = scsp.reg.slot[0];
|
||||
slot.LOOP = LOOP__KYONB | LOOP__LPCTL__NORMAL | LOOP__SA(sine_start); // kx kb sbctl[1:0] ssctl[1:0] lpctl[1:0] 8b sa[19:16]
|
||||
slot.SA = SA__SA(sine_start); // start address (bytes)
|
||||
slot.LSA = 0; // loop start address (samples)
|
||||
slot.LEA = 44100; // loop end address (samples)
|
||||
slot.EG = EG__AR(0x1f) | EG__EGHOLD; // d2r d1r ho ar krs dl rr
|
||||
slot.VOLUME = 0; // stwinh sdir tl
|
||||
slot.FM = 0; // mdl mdxsl mdysl
|
||||
slot.PITCH = PITCH__OCT(0) | PITCH__FNS(0); // oct fns
|
||||
slot.LFO = 0; // lfof plfows
|
||||
slot.MIXER = MIXER__DISDL(0b101); // disdl dipan efsdl efpan
|
||||
|
||||
slot.LOOP |= LOOP__KYONEX;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void start(void)
|
||||
{
|
||||
main();
|
||||
while (1);
|
||||
}
|
@ -15,7 +15,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 * buf = reinterpret_cast<uint32_t*>(&_sine_start);
|
||||
copy<uint32_t>(&scsp.ram.u32[0], buf, 44100 * 2);
|
||||
|
53
scsp/sound_cpu.cpp
Normal file
53
scsp/sound_cpu.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#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();
|
||||
|
||||
/*
|
||||
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);
|
||||
*/
|
||||
|
||||
scsp.reg.ctrl.MIXER = MIXER__MEM4MB | MIXER__DAC18B | MIXER__MVOL(0xf);
|
||||
|
||||
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<uint32_t>(&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);
|
||||
|
||||
// do nothing while the sound CPU manipulates the SCSP
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void start(void)
|
||||
{
|
||||
main();
|
||||
while (1);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user