From e6235422f3746683e679abd353d9385835c8187f Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Wed, 26 May 2021 15:08:23 +0200 Subject: [WIP] Prototype of audio mixer following deku tutorial --- src/main.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index a6fb761..6e7d3e5 100644 --- a/src/main.c +++ b/src/main.c @@ -184,7 +184,7 @@ init_uxn(Uxn *u) { initppu(&ppu, 30, 20, 0); // Enable sound. - SOUND_STATUS = SOUND_ENABLE; + init_sound(); // Copy rom to VM. memcpy(u->ram.dat + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); @@ -388,8 +388,8 @@ int main(void) { // Register interrupts. irq_init(); - irs_set(IRQ_VBLANK, irs_stub); - irs_set(IRQ_TIMER_1, irs_stop_sample); + irs_set(IRQ_VBLANK, sound_vsync); + // irs_set(IRQ_TIMER_1, irs_stop_sample); // Initialize VM. memset(&u, 0, sizeof(u)); @@ -400,34 +400,43 @@ int main(void) { txt_init(1, TEXT_LAYER); txt_position(0,0); - // init_sound(&apu.chan_0); + init_sound(); // reset_sound(&apu.chan_0); + // txt_printf("DING\n"); + // sound_mix(); // Main loop. int frame_counter = 0; - evaluxn(&u, 0x0100); - u32 flip_cycles = 0; + // evaluxn(&u, 0x0100); + // u32 flip_cycles = 0; while(true) { bios_vblank_wait(); - profile_start(); - handle_input(&u); - u32 input_cycles = profile_stop(); - profile_start(); - evaluxn(&u, mempeek16(devscreen->dat, 0)); - u32 eval_cycles = profile_stop(); - txt_position(0, 8); + // profile_start(); + // handle_input(&u); + // u32 input_cycles = profile_stop(); + // profile_start(); + // evaluxn(&u, mempeek16(devscreen->dat, 0)); + // u32 eval_cycles = profile_stop(); + // txt_position(0, 8); // txt_printf("INPUT: %lu \n", input_cycles); // txt_printf("EVAL: %lu \n", eval_cycles); // txt_printf("FLIP: %lu \n", flip_cycles); - profile_start(); - flipbuf(&ppu); - flip_cycles = profile_stop(); + // profile_start(); + // flip_cycles = profile_stop(); frame_counter++; // if (frame_counter == 120) { // init_sound(&apu.chan_0); // reset_sound(&apu.chan_0); // frame_counter = 0; // } + profile_start(); + sound_mix(); + u32 mix_cycles = profile_stop(); + + txt_position(0, 18); + txt_printf("MIX CYCLES: %lu \n", mix_cycles); + txt_printf("FRAME: %lu \n", frame_counter); + flipbuf(&ppu); } return 0; -- cgit v1.2.1