summaryrefslogtreecommitdiff
path: root/mknes.c
diff options
context:
space:
mode:
authorPeter Fors <peter.fors@mindkiller.com>2025-05-27 15:03:30 +0200
committerPeter Fors <peter.fors@mindkiller.com>2025-05-27 15:03:30 +0200
commit7cca3bdbec289328b537c8256b43dcfedc5d56b8 (patch)
tree181c22764d3d881ccd41d5c0282cd364d3f5197d /mknes.c
parenta8e0c141b0184d629504b9f0ee8dbc4fefb90934 (diff)
renaming
Diffstat (limited to 'mknes.c')
-rw-r--r--mknes.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/mknes.c b/mknes.c
index 9e87a33..29d705e 100644
--- a/mknes.c
+++ b/mknes.c
@@ -121,65 +121,63 @@ int main(int argc, char **argv) {
init_opcode_ud_lut();
// protect_opcode_lut();
- struct nes_state *nstate = aligned_alloc(4096, (sizeof(struct nes_state) + 4095) & ~4096);
-
+ struct nes_state *nstate = aligned_alloc(4096, (sizeof(struct nes_state) + 4095) & ~4095);
ppu_reset(nstate);
- // ines2_load(&nstate, "data/0000/10-Yard Fight (USA, Europe).nes");
- // ines2_load(&nstate, "data/0000/Balloon Fight (USA).nes");
- // ines2_load(&nstate, "data/0000/Excitebike (Japan, USA).nes");
- // ines2_load(&nstate, "data/0000/Ice Climber (USA, Europe, Korea).nes");
- // ines2_load(&nstate, "data/0000/Kung Fu (Japan, USA).nes");
+ // ines2_load(nstate, "data/0000/10-Yard Fight (USA, Europe).nes");
+ // ines2_load(nstate, "data/0000/Balloon Fight (USA).nes");
+ // ines2_load(nstate, "data/0000/Excitebike (Japan, USA).nes");
+ // ines2_load(nstate, "data/0000/Ice Climber (USA, Europe, Korea).nes");
+ // ines2_load(nstate, "data/0000/Kung Fu (Japan, USA).nes");
ines2_load(nstate, "data/0000/Super Mario Bros. (World) (HVC-SM).nes");
- // ines2_load(&nstate, "data/Super Mario Bros. (W) (V1.0) [!].nes");
- // ines2_load(&nstate, "data/Super Mario Bros. (JU) [!].nes");
- // ines2_load(&nstate, "data/0000/Urban Champion (World).nes");
- // ines2_load(&nstate, "data/0000/Wrecking Crew (World).nes");
- // ines2_load(&nstate, "data/0000/scanline.nes");
- // ines2_load(&nstate, "data/0000/Sayoonara!.NES");
- // ines2_load(&nstate, "data/0000/raster_demos/RasterChromaLuma.NES");
- // ines2_load(&nstate, "data/0000/raster_demos/RasterTest1.NES");
- // ines2_load(&nstate, "data/0000/raster_demos/RasterTest2.NES");
- // ines2_load(&nstate, "data/0000/raster_demos/RasterTest3.NES");
- // ines2_load(&nstate, "data/0000/raster_demos/RasterTest3a.NES");
- // ines2_load(&nstate, "data/0000/raster_demos/RasterTest3b.NES");
- // ines2_load(&nstate, "data/0000/raster_demos/RasterTest3c.NES");
- // ines2_load(&nstate, "data/0000/raster_demos/RasterTest3d.NES");
- // ines2_load(&nstate, "data/0000/raster_demos/RasterTest3e.NES");
- // ines2_load(&nstate, "data/0000/NEStress.NES");
- // ines2_load(&nstate, "data/0000/Super Mario Bros. (World) (HVC-SM).zip");
- // ines2_load(&nstate, "data/0042/Super Mario Bros. + Duck Hunt (USA).zip");
- // ines2_load(&nstate, "data/0000/Xevious - The Avenger (USA).zip");
- // ines2_load(&nstate, "data/tv.nes");
-
- // ines2_load(&nstate, "data/Life Force (USA).zip"); // 2002
-
- // ines2_load(&nstate, "data/0003/Flipull - An Exciting Cube Game (Japan) (En).zip");
- // ines2_load(&nstate, "data/0003/Friday the 13th (USA).zip");
- // ines2_load(&nstate, "data/0003/Ghostbusters (Japan).zip");
- // ines2_load(&nstate, "data/0003/Gradius (USA).zip");
+ // ines2_load(nstate, "data/Super Mario Bros. (W) (V1.0) [!].nes");
+ // ines2_load(nstate, "data/Super Mario Bros. (JU) [!].nes");
+ // ines2_load(nstate, "data/0000/Urban Champion (World).nes");
+ // ines2_load(nstate, "data/0000/Wrecking Crew (World).nes");
+ // ines2_load(nstate, "data/0000/scanline.nes");
+ // ines2_load(nstate, "data/0000/Sayoonara!.NES");
+ // ines2_load(nstate, "data/0000/raster_demos/RasterChromaLuma.NES");
+ // ines2_load(nstate, "data/0000/raster_demos/RasterTest1.NES");
+ // ines2_load(nstate, "data/0000/raster_demos/RasterTest2.NES");
+ // ines2_load(nstate, "data/0000/raster_demos/RasterTest3.NES");
+ // ines2_load(nstate, "data/0000/raster_demos/RasterTest3a.NES");
+ // ines2_load(nstate, "data/0000/raster_demos/RasterTest3b.NES");
+ // ines2_load(nstate, "data/0000/raster_demos/RasterTest3c.NES");
+ // ines2_load(nstate, "data/0000/raster_demos/RasterTest3d.NES");
+ // ines2_load(nstate, "data/0000/raster_demos/RasterTest3e.NES");
+ // ines2_load(nstate, "data/0000/NEStress.NES");
+ // ines2_load(nstate, "data/0000/Super Mario Bros. (World) (HVC-SM).zip");
+ // ines2_load(nstate, "data/0042/Super Mario Bros. + Duck Hunt (USA).zip");
+ // ines2_load(nstate, "data/0000/Xevious - The Avenger (USA).zip");
+ // ines2_load(nstate, "data/tv.nes");
+
+ // ines2_load(nstate, "data/Life Force (USA).zip"); // 2002
+
+ // ines2_load(nstate, "data/0003/Flipull - An Exciting Cube Game (Japan) (En).zip");
+ // ines2_load(nstate, "data/0003/Friday the 13th (USA).zip");
+ // ines2_load(nstate, "data/0003/Ghostbusters (Japan).zip");
+ // ines2_load(nstate, "data/0003/Gradius (USA).zip");
// ines2_load(nstate, "data/0007/Battletoads (USA).zip");
- // ines2_load(&nstate, "data/0007/Beetlejuice (USA).zip");
- // ines2_load(&nstate, "data/0007/Cabal (USA).zip");
-
- // ines2_load(&nstate, "data/000b/Baby Boomer (USA) (Unl).zip");
- // ines2_load(&nstate, "data/000b/Captain Comic - The Adventure (USA) (Unl).zip");
- // ines2_load(&nstate, "data/000b/King Neptune's Adventure (USA) (Unl).zip");
+ // ines2_load(nstate, "data/0007/Beetlejuice (USA).zip");
+ // ines2_load(nstate, "data/0007/Cabal (USA).zip");
- // ines2_load(&nstate, "data/2002/Attack Animal Gakuen (Japan).zip");
- // ines2_load(&nstate, "data/2002/Ballblazer (Japan).zip");
- // ines2_load(&nstate, "data/2002/Best of the Best - Championship Karate (USA).zip");
+ // ines2_load(nstate, "data/000b/Baby Boomer (USA) (Unl).zip");
+ // ines2_load(nstate, "data/000b/Captain Comic - The Adventure (USA) (Unl).zip");
+ // ines2_load(nstate, "data/000b/King Neptune's Adventure (USA) (Unl).zip");
- // ines2_load(&nstate, "data/Blaster Master (USA).zip");
+ // ines2_load(nstate, "data/2002/Attack Animal Gakuen (Japan).zip");
+ // ines2_load(nstate, "data/2002/Ballblazer (Japan).zip");
+ // ines2_load(nstate, "data/2002/Best of the Best - Championship Karate (USA).zip");
+ // ines2_load(nstate, "data/Blaster Master (USA).zip");
mapper_setup(nstate);
- uint32_t lo = nstate->mapper.prg_read(nstate, 0xfffc);
- uint32_t hi = nstate->mapper.prg_read(nstate, 0xfffd);
+ uint32_t lo = nstate->mapper_function.prg_rom_read(nstate, 0xfffc);
+ uint32_t hi = nstate->mapper_function.prg_rom_read(nstate, 0xfffd);
nstate->cpu.pc = (hi << 8) | lo;
#if 1
- for(uint32_t i = 0; i < 0x5000; ++ i) {
+ for(uint32_t i = 0; i < 0x5000; ++i) {
while(!nstate->ppu.frame_ready) {
// PROFILE_NAMED("nes emulator");
cpu_tick(nstate);
@@ -230,12 +228,15 @@ int main(int argc, char **argv) {
timer_start(timer);
- while(!glfwWindowShouldClose(window)) {
+ for(;;) {
timer_wait(timer);
glfwPollEvents();
- uint8_t input = 0;
+ // exit
+ if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) break;
+ // Joypad input
+ uint8_t input = 0;
if(glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS) { input |= (1 << 0); }
if(glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS) { input |= (1 << 1); }
if(glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) { input |= (1 << 2); }
@@ -244,7 +245,6 @@ int main(int argc, char **argv) {
if(glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS) { input |= (1 << 5); }
if(glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS) { input |= (1 << 6); }
if(glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS) { input |= (1 << 7); }
-
nstate->ppu.input[0] = input;
while(!nstate->ppu.frame_ready) {