nesemu/include/system.h

56 lines
1.2 KiB
C
Raw Normal View History

2024-01-06 14:27:09 -05:00
//
// Created by william on 12/23/23.
//
#include "types.h"
#include "mapper.h"
#include "ppu.h"
#ifndef NESEMULATOR_SYSTEM_H
#define NESEMULATOR_SYSTEM_H
2024-05-17 00:33:37 -04:00
#define FRAME_RATE 60
#define MASTER_CLOCK 21477272 // NTSC NES Master Clock (~21.47 MHz)
#define MASTER_CYCLE_PER_FRAME (MASTER_CLOCK / FRAME_RATE)
2024-01-06 14:27:09 -05:00
#define CPU_CLOCK_DIVISOR 12
2024-05-17 00:33:37 -04:00
#define CPU_CYCLE_PER_FRAME (MASTER_CYCLE_PER_FRAME / CPU_CLOCK_DIVISOR)
2024-01-06 14:27:09 -05:00
#define PPU_CLOCK_DIVISOR 4
2024-05-17 00:33:37 -04:00
#define PPU_CYCLE_PER_CPU_CYCLE (CPU_CLOCK_DIVISOR / PPU_CLOCK_DIVISOR)
2024-01-06 14:27:09 -05:00
#define PPU_REGISTERS_BASE_ADDR 0x2000
#define PPU_REGISTER_OAM_DMA_ADDR 0x4014
#define APU_REGISTERS_COUNT 24
typedef struct system {
void *rom_header;
Mapper mapper;
unsigned long cycle_count;
2024-08-03 21:51:31 -04:00
bool paused;
bool ppu_paused;
2024-01-06 14:27:09 -05:00
} System;
/**
* Initialize all components of a system.
*/
2024-05-06 20:23:44 -04:00
void system_init();
2024-01-06 14:27:09 -05:00
2024-05-06 20:23:44 -04:00
void system_start();
2024-01-06 14:27:09 -05:00
2024-05-17 00:33:37 -04:00
void system_next_frame();
2024-01-06 14:27:09 -05:00
/**
2024-08-03 21:51:31 -04:00
* Toggle pause for the system. If not paused, CPU and PPU cycles will be stopped until this method is called again.
2024-01-06 14:27:09 -05:00
*/
void system_toggle_pause(bool pause_ppu);
2024-01-06 14:27:09 -05:00
/**
* De-initialize the components of a system.
*/
2024-05-06 20:23:44 -04:00
void system_uninit();
unsigned int system_get_cycles();
2024-05-17 00:33:37 -04:00
2024-05-06 20:23:44 -04:00
Mapper *system_get_mapper();
2024-01-06 14:27:09 -05:00
#endif //NESEMULATOR_SYSTEM_H