diff --git a/.gitignore b/.gitignore index 6c08c3d..a1541a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.d *.gch *.o *.elf diff --git a/Makefile b/Makefile index 7068c31..9397f81 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ common/keyboard.hpp: common/keyboard.py common/keyboard.cpp: common/keyboard.py common/keyboard.hpp python common/keyboard.py definition > $@ -smpc/input_keyboard.o: common/keyboard.hpp +smpc/input_keyboard.cpp.d: common/keyboard.hpp smpc/input_keyboard.elf: smpc/input_keyboard.o sh/lib1funcs.o res/dejavusansmono.font.bin.o common/keyboard.o common/draw_font.o common/palette.o @@ -90,7 +90,7 @@ wordle/main_saturn.o: common/keyboard.hpp wordle/word_list.hpp: wordle/word_list.csv wordle/word_list.py python wordle/word_list.py > $@ -wordle/wordle.o: wordle/word_list.hpp +wordle/wordle.cpp.d: wordle/word_list.hpp wordle/wordle.elf: wordle/main_saturn.o wordle/wordle.o wordle/draw.o sh/lib1funcs.o res/dejavusansmono.font.bin.o common/keyboard.o common/draw_font.o common/palette.o diff --git a/editor/main_saturn.cpp b/editor/main_saturn.cpp index 0a8be84..0fc0e85 100644 --- a/editor/main_saturn.cpp +++ b/editor/main_saturn.cpp @@ -325,8 +325,8 @@ void main() 2-word: value of bit 5-0 * 0x4000 */ vdp2.reg.MPOFN = MPOFN__N0MP(0); // bits 8~6 - vdp2.reg.MPABN0 = MPABN0__N0MPB(0) | MPABN0__N0MPA(plane_a); // bits 5~0 - vdp2.reg.MPCDN0 = MPABN0__N0MPD(0) | MPABN0__N0MPC(0); // bits 5~0 + vdp2.reg.MPABN0 = MPABN0__N0MPB(plane_a) | MPABN0__N0MPA(plane_a); // bits 5~0 + vdp2.reg.MPCDN0 = MPCDN0__N0MPD(plane_a) | MPCDN0__N0MPC(plane_a); // bits 5~0 // zeroize character/cell data from 0 up to plane_a_offset fill(&vdp2.vram.u32[(0 / 4)], 0, plane_offset(plane_a)); diff --git a/m68k/Makefile b/m68k/Makefile index 0ccf28d..503b0a7 100644 --- a/m68k/Makefile +++ b/m68k/Makefile @@ -15,6 +15,14 @@ include $(LIB)/m68k/common.mk synth 101s $* 441 vol -10dB mv $@.raw $@ +# 88200 bytes +%-44100-s16be-1ch-1sec.pcm: Makefile + sox \ + -r 44100 -e signed-integer -b 16 -c 1 -n -B \ + $@.raw \ + synth 1 sin 440 vol -10dB + mv $@.raw $@ + %.pcm.o: %.pcm $(BUILD_BINARY_O) diff --git a/m68k/interrupt.cpp b/m68k/interrupt.cpp index c43c7e9..c0a416d 100644 --- a/m68k/interrupt.cpp +++ b/m68k/interrupt.cpp @@ -4,7 +4,7 @@ extern void * _jojo_start __asm("_binary_jojo_11025_s16be_1ch_pcm_start"); -static volatile int32_t frame = 0x0; +static int32_t frame = 0x0; constexpr int32_t tactl = 7; constexpr int32_t frame_size = ((1 << tactl) * 256) / (44100 / 11025); diff --git a/m68k/slot.cpp b/m68k/slot.cpp index c798dcc..6b602ab 100644 --- a/m68k/slot.cpp +++ b/m68k/slot.cpp @@ -2,7 +2,7 @@ #include "scsp.h" -extern void * _sine_start __asm("_binary_sine_44100_s16be_1ch_pcm_start"); +extern void * _sine_start __asm("_binary_sine_44100_s16be_1ch_1sec_pcm_start"); void main() { diff --git a/raytracing/main-saturn.cpp b/raytracing/main-saturn.cpp index 6698f5e..b546b52 100644 --- a/raytracing/main-saturn.cpp +++ b/raytracing/main-saturn.cpp @@ -4,7 +4,7 @@ #include "smpc.h" #include "sh2.h" -#include "vec.hpp" +#include "vec3.hpp" #include "fp.hpp" #include "raytracing.hpp" @@ -22,9 +22,9 @@ inline constexpr T rgb(const vec3& color) vec3 c = functor1(clamp, color) * fp16_16(channel_mask); - T red = static_cast(c.r.value >> 16); - T green = static_cast(c.g.value >> 16); - T blue = static_cast(c.b.value >> 16); + T red = static_cast(c.x.value >> 16); + T green = static_cast(c.y.value >> 16); + T blue = static_cast(c.z.value >> 16); return (1 << last_bit) | (blue << (P * 2)) @@ -84,7 +84,8 @@ void start_slave() */ sh2_vec[0x94] = (uint32_t)(&slave_main); - for (volatile int i = 0; i < 10; i++); + for (int i = 0; i < 10; i++) + asm volatile ("nop"); smpc.reg.SF = 1; smpc.reg.COMREG = COMREG__SSHON; @@ -92,7 +93,7 @@ void start_slave() while ((smpc.reg.SF & 0x01) == 1); } -void main_asdf() +void main() { // DISP: Please make sure to change this bit from 0 to 1 during V blank. vdp2.reg.TVMD = ( TVMD__DISP | TVMD__LSMD__NON_INTERLACE @@ -131,10 +132,3 @@ void main_asdf() render(0, put_pixel); } - -extern "C" -void start(void) -{ - main_asdf(); - while (1) {} -} diff --git a/raytracing/raytracing.cpp b/raytracing/raytracing.cpp index 8a600d9..1d29472 100644 --- a/raytracing/raytracing.cpp +++ b/raytracing/raytracing.cpp @@ -1,6 +1,6 @@ #include -#include "vec.hpp" +#include "vec3.hpp" #include "fp.hpp" #include "raytracing.hpp" diff --git a/scsp/slot.cpp b/scsp/slot.cpp index 900a477..8627dd7 100644 --- a/scsp/slot.cpp +++ b/scsp/slot.cpp @@ -33,10 +33,3 @@ void main() slot.LOOP |= LOOP__KYONEX; } - -extern "C" -void start(void) -{ - main(); - while (1); -} diff --git a/scsp/sound_cpu__interrupt.cpp b/scsp/sound_cpu__interrupt.cpp index 33c8f86..e2d35ab 100644 --- a/scsp/sound_cpu__interrupt.cpp +++ b/scsp/sound_cpu__interrupt.cpp @@ -239,10 +239,3 @@ void main() init_sound(); } - -extern "C" -void start(void) -{ - main(); - while (1); -} diff --git a/scsp/sound_cpu__slot.cpp b/scsp/sound_cpu__slot.cpp index 0f3a772..605da9d 100644 --- a/scsp/sound_cpu__slot.cpp +++ b/scsp/sound_cpu__slot.cpp @@ -43,10 +43,3 @@ void main() // do nothing while the sound CPU manipulates the SCSP } - -extern "C" -void start(void) -{ - main(); - while (1); -} diff --git a/smpc/input_intback.cpp b/smpc/input_intback.cpp index 114e64b..ce5ff8c 100644 --- a/smpc/input_intback.cpp +++ b/smpc/input_intback.cpp @@ -373,10 +373,3 @@ void main() scu.reg.IST = 0; scu.reg.IMS &= ~(IMS__SMPC); } - -extern "C" -void start(void) -{ - main(); - while (1); -} diff --git a/smpc/input_keyboard.cpp b/smpc/input_keyboard.cpp index 8f94d27..b1d68e8 100644 --- a/smpc/input_keyboard.cpp +++ b/smpc/input_keyboard.cpp @@ -462,10 +462,3 @@ void main() scu.reg.IST = 0; scu.reg.IMS = ~(IMS__SMPC | IMS__V_BLANK_IN); } - -extern "C" -void start(void) -{ - main(); - while (1); -} diff --git a/vdp1/kana.cpp b/vdp1/kana.cpp index ecd9fa9..7f61cbc 100644 --- a/vdp1/kana.cpp +++ b/vdp1/kana.cpp @@ -204,10 +204,3 @@ void main() // start drawing (execute the command list) on every frame vdp1.reg.PTMR = PTMR__PTM__FRAME_CHANGE; } - -extern "C" -void start(void) -{ - main(); - while (1) {} -} diff --git a/vdp1/normal_sprite.cpp b/vdp1/normal_sprite.cpp index e0c2646..76000f3 100644 --- a/vdp1/normal_sprite.cpp +++ b/vdp1/normal_sprite.cpp @@ -150,10 +150,3 @@ void main() // start drawing (execute the command list) on every frame vdp1.reg.PTMR = PTMR__PTM__FRAME_CHANGE; } - -extern "C" -void start(void) -{ - main(); - while (1) {} -} diff --git a/vdp1/normal_sprite_animated.cpp b/vdp1/normal_sprite_animated.cpp index 6ed7b05..9009b93 100644 --- a/vdp1/normal_sprite_animated.cpp +++ b/vdp1/normal_sprite_animated.cpp @@ -193,10 +193,3 @@ void main() scu.reg.IST = 0; scu.reg.IMS = ~(IMS__V_BLANK_IN); } - -extern "C" -void start(void) -{ - main(); - while (1) {} -} diff --git a/vdp1/normal_sprite_color_bank.cpp b/vdp1/normal_sprite_color_bank.cpp index ef4663f..0daf77e 100644 --- a/vdp1/normal_sprite_color_bank.cpp +++ b/vdp1/normal_sprite_color_bank.cpp @@ -146,10 +146,3 @@ void main() // start drawing (execute the command list) on every frame vdp1.reg.PTMR = PTMR__PTM__FRAME_CHANGE; } - -extern "C" -void start(void) -{ - main(); - while (1) {} -} diff --git a/vdp1/polygon.cpp b/vdp1/polygon.cpp index ff59eb5..86ccae6 100644 --- a/vdp1/polygon.cpp +++ b/vdp1/polygon.cpp @@ -73,10 +73,3 @@ void main() // start drawing (execute the command list) on every frame vdp1.reg.PTMR = PTMR__PTM__FRAME_CHANGE; } - -extern "C" -void start(void) -{ - main(); - while (1) {} -} diff --git a/vdp1/rgb.cpp b/vdp1/rgb.cpp index c0529b1..4ffdc49 100644 --- a/vdp1/rgb.cpp +++ b/vdp1/rgb.cpp @@ -103,10 +103,3 @@ void main() // start drawing (execute the command list) on every frame vdp1.reg.PTMR = PTMR__PTM__FRAME_CHANGE; } - -extern "C" -void start(void) -{ - main(); - while (1) {} -} diff --git a/vdp2/nbg0.cpp b/vdp2/nbg0.cpp index 21f560e..8969d19 100644 --- a/vdp2/nbg0.cpp +++ b/vdp2/nbg0.cpp @@ -12,7 +12,7 @@ #include #include "vdp2.h" -#include "../common/vdp2_func.h" +#include "../common/vdp2_func.hpp" extern void * _butterfly_data_pal_start __asm("_binary_res_butterfly_data_pal_start"); extern void * _butterfly_data_pal_size __asm("_binary_res_butterfly_data_pal_size"); @@ -107,8 +107,8 @@ void main() constexpr int plane_size = page_size * 1; vdp2.reg.MPOFN = MPOFN__N0MP(0); // bits 8~6 - vdp2.reg.MPABN0 = MPABN0__N0MPB(0) | MPABN0__N0MPA(plane_a); // bits 5~0 - vdp2.reg.MPCDN0 = MPABN0__N0MPD(0) | MPABN0__N0MPC(0); // bits 5~0 + vdp2.reg.MPABN0 = MPABN0__N0MPB(plane_a) | MPABN0__N0MPA(plane_a); // bits 5~0 + vdp2.reg.MPCDN0 = MPCDN0__N0MPD(plane_a) | MPCDN0__N0MPC(plane_a); // bits 5~0 constexpr int cell_size = (8 * 8) * 2; // N0CHCN__2048_COLOR (16-bit) constexpr int character_size = cell_size * (1 * 1); // N0CHSZ__1x1_CELL diff --git a/wordle/main_saturn.cpp b/wordle/main_saturn.cpp index 5952c7b..c0babbc 100644 --- a/wordle/main_saturn.cpp +++ b/wordle/main_saturn.cpp @@ -248,10 +248,3 @@ void main() scu.reg.IST = 0; scu.reg.IMS = ~(IMS__SMPC | IMS__V_BLANK_IN); } - -extern "C" -void start(void) -{ - main(); - while (1); -}