diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 41 |
1 files changed, 25 insertions, 16 deletions
@@ -184,7 +184,7 @@ init_uxn(Uxn *u) { | |||
184 | initppu(&ppu, 30, 20, 0); | 184 | initppu(&ppu, 30, 20, 0); |
185 | 185 | ||
186 | // Enable sound. | 186 | // Enable sound. |
187 | SOUND_STATUS = SOUND_ENABLE; | 187 | init_sound(); |
188 | 188 | ||
189 | // Copy rom to VM. | 189 | // Copy rom to VM. |
190 | memcpy(u->ram.dat + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); | 190 | memcpy(u->ram.dat + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); |
@@ -388,8 +388,8 @@ int main(void) { | |||
388 | 388 | ||
389 | // Register interrupts. | 389 | // Register interrupts. |
390 | irq_init(); | 390 | irq_init(); |
391 | irs_set(IRQ_VBLANK, irs_stub); | 391 | irs_set(IRQ_VBLANK, sound_vsync); |
392 | irs_set(IRQ_TIMER_1, irs_stop_sample); | 392 | // irs_set(IRQ_TIMER_1, irs_stop_sample); |
393 | 393 | ||
394 | // Initialize VM. | 394 | // Initialize VM. |
395 | memset(&u, 0, sizeof(u)); | 395 | memset(&u, 0, sizeof(u)); |
@@ -400,34 +400,43 @@ int main(void) { | |||
400 | txt_init(1, TEXT_LAYER); | 400 | txt_init(1, TEXT_LAYER); |
401 | txt_position(0,0); | 401 | txt_position(0,0); |
402 | 402 | ||
403 | // init_sound(&apu.chan_0); | 403 | init_sound(); |
404 | // reset_sound(&apu.chan_0); | 404 | // reset_sound(&apu.chan_0); |
405 | // txt_printf("DING\n"); | ||
406 | // sound_mix(); | ||
405 | 407 | ||
406 | // Main loop. | 408 | // Main loop. |
407 | int frame_counter = 0; | 409 | int frame_counter = 0; |
408 | evaluxn(&u, 0x0100); | 410 | // evaluxn(&u, 0x0100); |
409 | u32 flip_cycles = 0; | 411 | // u32 flip_cycles = 0; |
410 | while(true) { | 412 | while(true) { |
411 | bios_vblank_wait(); | 413 | bios_vblank_wait(); |
412 | profile_start(); | 414 | // profile_start(); |
413 | handle_input(&u); | 415 | // handle_input(&u); |
414 | u32 input_cycles = profile_stop(); | 416 | // u32 input_cycles = profile_stop(); |
415 | profile_start(); | 417 | // profile_start(); |
416 | evaluxn(&u, mempeek16(devscreen->dat, 0)); | 418 | // evaluxn(&u, mempeek16(devscreen->dat, 0)); |
417 | u32 eval_cycles = profile_stop(); | 419 | // u32 eval_cycles = profile_stop(); |
418 | txt_position(0, 8); | 420 | // txt_position(0, 8); |
419 | // txt_printf("INPUT: %lu \n", input_cycles); | 421 | // txt_printf("INPUT: %lu \n", input_cycles); |
420 | // txt_printf("EVAL: %lu \n", eval_cycles); | 422 | // txt_printf("EVAL: %lu \n", eval_cycles); |
421 | // txt_printf("FLIP: %lu \n", flip_cycles); | 423 | // txt_printf("FLIP: %lu \n", flip_cycles); |
422 | profile_start(); | 424 | // profile_start(); |
423 | flipbuf(&ppu); | 425 | // flip_cycles = profile_stop(); |
424 | flip_cycles = profile_stop(); | ||
425 | frame_counter++; | 426 | frame_counter++; |
426 | // if (frame_counter == 120) { | 427 | // if (frame_counter == 120) { |
427 | // init_sound(&apu.chan_0); | 428 | // init_sound(&apu.chan_0); |
428 | // reset_sound(&apu.chan_0); | 429 | // reset_sound(&apu.chan_0); |
429 | // frame_counter = 0; | 430 | // frame_counter = 0; |
430 | // } | 431 | // } |
432 | profile_start(); | ||
433 | sound_mix(); | ||
434 | u32 mix_cycles = profile_stop(); | ||
435 | |||
436 | txt_position(0, 18); | ||
437 | txt_printf("MIX CYCLES: %lu \n", mix_cycles); | ||
438 | txt_printf("FRAME: %lu \n", frame_counter); | ||
439 | flipbuf(&ppu); | ||
431 | } | 440 | } |
432 | 441 | ||
433 | return 0; | 442 | return 0; |