53 lines
972 B
C
53 lines
972 B
C
//
|
|
// Created by william on 12/23/23.
|
|
//
|
|
|
|
#include "include/cpu.h"
|
|
#include "include/system.h"
|
|
#include "memory.h"
|
|
#include <unistd.h>
|
|
#include <assert.h>
|
|
#include "cpu.h"
|
|
#include "pattern_table.h"
|
|
|
|
System current_sys;
|
|
|
|
void system_init() {
|
|
cpu_init();
|
|
ppu_init();
|
|
|
|
current_sys.mapper = get_mapper(MAPPER_TYPE_SIMPLE);
|
|
current_sys.cycle_count = 7;
|
|
}
|
|
|
|
void system_start() {
|
|
address pc = mem_get_word(0xfffc);
|
|
cpu_get_state()->program_counter = pc;
|
|
}
|
|
|
|
void system_next_frame() {
|
|
for (int cpu_c = 0; cpu_c < CPU_CYCLE_PER_FRAME; cpu_c++) {
|
|
cpu_cycle();
|
|
|
|
for (int ppu_c = 0; ppu_c < PPU_CYCLE_PER_CPU_CYCLE; ppu_c++) {
|
|
ppu_cycle();
|
|
}
|
|
}
|
|
|
|
pt_debug();
|
|
}
|
|
|
|
void system_uninit() {
|
|
}
|
|
|
|
unsigned int system_get_cycles() {
|
|
return current_sys.cycle_count;
|
|
}
|
|
|
|
void system_add_cycles(unsigned int cycles) {
|
|
current_sys.cycle_count += cycles;
|
|
}
|
|
|
|
Mapper *system_get_mapper() {
|
|
return ¤t_sys.mapper;
|
|
} |