diff options
Diffstat (limited to 'mknes.c')
| -rw-r--r-- | mknes.c | 102 |
1 files changed, 102 insertions, 0 deletions
@@ -0,0 +1,102 @@ + + +#include "base.c" + +#include "mknes.h" +// #include "apu.c" +#include "ppu.c" +#include "memory.c" +#include "cpu.c" +#include "ines2.c" + + + + +static void render_callback() { + +} + +static void audio_callback(int16_t *buffer, size_t frames) { + +} + +static void init_callback() { +} + +// int main(void) { +// struct nes_state state = {0}; + +// init_opcode_lut(); +// init_opcode_ud_lut(); +// state.cpu.sp = 0xfd; + +// // FILE *f = fopen("nestest.nes", "rb"); +// // fseek(f, 16, SEEK_SET); +// // fread(&state.memory[0xc000], 1, 0x4000, f); +// // fclose(f); +// // state.cpu.pc = 0xc000; + +// FILE *f = fopen("6502_functional_test.bin", "rb"); +// fread(state.memory, 1, 0x10000, f); +// fclose(f); +// state.cpu.pc = 0x0400; + +// size_t i; +// for(i = 0; i < 70000000; ++i) { +// cpu_tick(&state); +// if(state.cpu.pc == 0x3469) break; +// } +// // printf("%lld", i); +// return 0; +// } + + + + +// bool running = true; +// uint64_t next_update = mkfw_gettime(); +// int64_t frame_duration_ns = 16666667; // NTSC ~60.0988 Hz + +// audio_sync_init(next_update); // Initialize sync base time + +// while(running && !mkfw_should_close()) { +// mkfw_pump_messages(); +// if(key_pressed(MKS_KEY_ESCAPE)) { running = false; } + +// #ifdef PROFILER +// reset_profiling_data(); +// #endif + +// render_callback(); +// apply_phosphor_decay(); +// update_keyboard_state(); +// update_modifier_state(); +// update_mouse_state(); +// state.frame_number++; + +// #ifndef PERF_TEST +// render_frame(); +// #ifdef PROFILER +// debug_render(); +// #endif + +// audio_throttle_emulator(state.frame_number, &frame_duration_ns); + +// uint64_t now = mkfw_gettime(); +// int64_t remaining = next_update - now; + +// if(remaining > 0) { +// if(remaining > ONE_MILLISECOND_NS) { +// mkfw_sleep(remaining - ONE_MILLISECOND_NS); +// } +// while(mkfw_gettime() < next_update) { /**/ } +// } else { +// next_update = now; +// } + +// next_update += frame_duration_ns; + +// mkfw_swap_buffers(); +// #endif +// } + |
