Direct access to registers (#422)
This commit is contained in:
parent
c63ddbe771
commit
5127cb0022
@ -1750,6 +1750,11 @@ void *GB_get_direct_access(GB_gameboy_t *gb, GB_direct_access_t access, size_t *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GB_registers_t *GB_get_registers(GB_gameboy_t *gb)
|
||||||
|
{
|
||||||
|
return (GB_registers_t *)&gb->registers;
|
||||||
|
}
|
||||||
|
|
||||||
void GB_set_clock_multiplier(GB_gameboy_t *gb, double multiplier)
|
void GB_set_clock_multiplier(GB_gameboy_t *gb, double multiplier)
|
||||||
{
|
{
|
||||||
gb->clock_multiplier = multiplier;
|
gb->clock_multiplier = multiplier;
|
||||||
|
67
Core/gb.h
67
Core/gb.h
@ -321,6 +321,31 @@ typedef struct {
|
|||||||
char copyright[33];
|
char copyright[33];
|
||||||
} GB_gbs_info_t;
|
} GB_gbs_info_t;
|
||||||
|
|
||||||
|
/* Duplicated so it can remain anonymous in GB_gameboy_t */
|
||||||
|
typedef union {
|
||||||
|
uint16_t registers[GB_REGISTERS_16_BIT];
|
||||||
|
struct {
|
||||||
|
uint16_t af,
|
||||||
|
bc,
|
||||||
|
de,
|
||||||
|
hl,
|
||||||
|
sp;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
#ifdef GB_BIG_ENDIAN
|
||||||
|
uint8_t a, f,
|
||||||
|
b, c,
|
||||||
|
d, e,
|
||||||
|
h, l;
|
||||||
|
#else
|
||||||
|
uint8_t f, a,
|
||||||
|
c, b,
|
||||||
|
e, d,
|
||||||
|
l, h;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
} GB_registers_t;
|
||||||
|
|
||||||
/* When state saving, each section is dumped independently of other sections.
|
/* When state saving, each section is dumped independently of other sections.
|
||||||
This allows adding data to the end of the section without worrying about future compatibility.
|
This allows adding data to the end of the section without worrying about future compatibility.
|
||||||
Some other changes might be "safe" as well.
|
Some other changes might be "safe" as well.
|
||||||
@ -345,30 +370,29 @@ struct GB_gameboy_internal_s {
|
|||||||
GB_SECTION(core_state,
|
GB_SECTION(core_state,
|
||||||
/* Registers */
|
/* Registers */
|
||||||
uint16_t pc;
|
uint16_t pc;
|
||||||
union {
|
union {
|
||||||
uint16_t registers[GB_REGISTERS_16_BIT];
|
uint16_t registers[GB_REGISTERS_16_BIT];
|
||||||
struct {
|
struct {
|
||||||
uint16_t af,
|
uint16_t af,
|
||||||
bc,
|
bc,
|
||||||
de,
|
de,
|
||||||
hl,
|
hl,
|
||||||
sp;
|
sp;
|
||||||
};
|
};
|
||||||
struct {
|
struct {
|
||||||
#ifdef GB_BIG_ENDIAN
|
#ifdef GB_BIG_ENDIAN
|
||||||
uint8_t a, f,
|
uint8_t a, f,
|
||||||
b, c,
|
b, c,
|
||||||
d, e,
|
d, e,
|
||||||
h, l;
|
h, l;
|
||||||
#else
|
#else
|
||||||
uint8_t f, a,
|
uint8_t f, a,
|
||||||
c, b,
|
c, b,
|
||||||
e, d,
|
e, d,
|
||||||
l, h;
|
l, h;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
|
||||||
uint8_t ime;
|
uint8_t ime;
|
||||||
uint8_t interrupt_enable;
|
uint8_t interrupt_enable;
|
||||||
uint8_t cgb_ram_bank;
|
uint8_t cgb_ram_bank;
|
||||||
@ -801,6 +825,7 @@ typedef enum {
|
|||||||
/* Returns a mutable pointer to various hardware memories. If that memory is banked, the current bank
|
/* Returns a mutable pointer to various hardware memories. If that memory is banked, the current bank
|
||||||
is returned at *bank, even if only a portion of the memory is banked. */
|
is returned at *bank, even if only a portion of the memory is banked. */
|
||||||
void *GB_get_direct_access(GB_gameboy_t *gb, GB_direct_access_t access, size_t *size, uint16_t *bank);
|
void *GB_get_direct_access(GB_gameboy_t *gb, GB_direct_access_t access, size_t *size, uint16_t *bank);
|
||||||
|
GB_registers_t *GB_get_registers(GB_gameboy_t *gb);
|
||||||
|
|
||||||
void *GB_get_user_data(GB_gameboy_t *gb);
|
void *GB_get_user_data(GB_gameboy_t *gb);
|
||||||
void GB_set_user_data(GB_gameboy_t *gb, void *data);
|
void GB_set_user_data(GB_gameboy_t *gb, void *data);
|
||||||
|
Loading…
Reference in New Issue
Block a user