memory: separate the memory-related code into it's own file
After doing a little reading about the way the memory banks are mapped, it looks like this code is going to grow. Separate it into it's own file. While we're at it, make gb_mem_read() a proper function instead of a callback. Because these functions are used so frequently, this corresponds to a ~10-20% performance benefit (due to LTO).
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#ifndef GB_CPU_H
|
||||
#define GB_CPU_H
|
||||
|
||||
#include "gbemu/memory.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define CPU_F_BIT_POS_C 4
|
||||
@@ -66,6 +68,9 @@ struct lr35902_event {
|
||||
};
|
||||
|
||||
struct lr35902_state {
|
||||
|
||||
struct gb_memory *memory;
|
||||
|
||||
union {
|
||||
/*
|
||||
* As a convenience, give ourselves a bunch of different ways to
|
||||
@@ -95,8 +100,6 @@ struct lr35902_state {
|
||||
int stall_cycles;
|
||||
int halted;
|
||||
|
||||
lr35902_mem_read_fn mem_read;
|
||||
lr35902_mem_write_fn mem_write;
|
||||
void (*undef_d3)(struct lr35902_state *reg);
|
||||
|
||||
lr35902_interrupt_state int_state;
|
||||
@@ -119,7 +122,8 @@ struct lr35902_ops {
|
||||
};
|
||||
|
||||
void lr35902_init(struct lr35902_state *cpu,
|
||||
const struct lr35902_ops *ops);
|
||||
struct gb_memory *memory,
|
||||
const struct lr35902_ops *ops);
|
||||
|
||||
uint16_t lr35902_get_reg_16(const struct lr35902_state *cpu,
|
||||
lr35902_regs_16 reg);
|
||||
|
||||
Reference in New Issue
Block a user