mirror of https://github.com/inolen/redream.git
removed debug_menu callback from devices
This commit is contained in:
parent
e16994e356
commit
94a42ec0c2
|
@ -19,6 +19,7 @@
|
|||
#include "hw/arm7/arm7.h"
|
||||
#include "hw/dreamcast.h"
|
||||
#include "hw/gdrom/gdrom.h"
|
||||
#include "hw/holly/holly.h"
|
||||
#include "hw/maple/maple.h"
|
||||
#include "hw/memory.h"
|
||||
#include "hw/pvr/pvr.h"
|
||||
|
@ -467,8 +468,9 @@ static void emu_paint(struct emu *emu) {
|
|||
igEndMainMenuBar();
|
||||
}
|
||||
|
||||
/* add each devices's debug menu */
|
||||
dc_debug_menu(emu->dc);
|
||||
holly_debug_menu(emu->dc->holly);
|
||||
aica_debug_menu(emu->dc->aica);
|
||||
sh4_debug_menu(emu->dc->sh4);
|
||||
|
||||
/* add status */
|
||||
if (igBeginMainMenuBar()) {
|
||||
|
|
|
@ -797,25 +797,6 @@ static void aica_toggle_recording(struct aica *aica) {
|
|||
}
|
||||
}
|
||||
|
||||
static void aica_debug_menu(struct device *dev) {
|
||||
struct aica *aica = (struct aica *)dev;
|
||||
|
||||
if (igBeginMainMenuBar()) {
|
||||
if (igBeginMenu("AICA", 1)) {
|
||||
const char *recording_label =
|
||||
aica->recording ? "stop recording" : "start recording";
|
||||
|
||||
if (igMenuItem(recording_label, NULL, aica->recording, 1)) {
|
||||
aica_toggle_recording(aica);
|
||||
}
|
||||
|
||||
igEndMenu();
|
||||
}
|
||||
|
||||
igEndMainMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
static int aica_init(struct device *dev) {
|
||||
struct aica *aica = (struct aica *)dev;
|
||||
|
||||
|
@ -855,6 +836,23 @@ static int aica_init(struct device *dev) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
void aica_debug_menu(struct aica *aica) {
|
||||
if (igBeginMainMenuBar()) {
|
||||
if (igBeginMenu("AICA", 1)) {
|
||||
const char *recording_label =
|
||||
aica->recording ? "stop recording" : "start recording";
|
||||
|
||||
if (igMenuItem(recording_label, NULL, aica->recording, 1)) {
|
||||
aica_toggle_recording(aica);
|
||||
}
|
||||
|
||||
igEndMenu();
|
||||
}
|
||||
|
||||
igEndMainMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
void aica_destroy(struct aica *aica) {
|
||||
/* shutdown rtc */
|
||||
{
|
||||
|
@ -888,8 +886,8 @@ void aica_destroy(struct aica *aica) {
|
|||
struct aica *aica_create(struct dreamcast *dc) {
|
||||
aica_init_tables();
|
||||
|
||||
struct aica *aica = dc_create_device(dc, sizeof(struct aica), "aica",
|
||||
&aica_init, &aica_debug_menu);
|
||||
struct aica *aica =
|
||||
dc_create_device(dc, sizeof(struct aica), "aica", &aica_init);
|
||||
return aica;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,4 +15,6 @@ AM_DECLARE(aica_data_map);
|
|||
struct aica *aica_create(struct dreamcast *dc);
|
||||
void aica_destroy(struct aica *aica);
|
||||
|
||||
void aica_debug_menu(struct aica *aica);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -235,7 +235,7 @@ void arm7_destroy(struct arm7 *arm) {
|
|||
|
||||
struct arm7 *arm7_create(struct dreamcast *dc) {
|
||||
struct arm7 *arm =
|
||||
dc_create_device(dc, sizeof(struct arm7), "arm", &arm7_init, NULL);
|
||||
dc_create_device(dc, sizeof(struct arm7), "arm", &arm7_init);
|
||||
arm->execute_if = dc_create_execute_interface(&arm7_run, 0);
|
||||
arm->memory_if = dc_create_memory_interface(dc, &arm7_data_map);
|
||||
|
||||
|
|
|
@ -47,14 +47,6 @@ void dc_push_audio(struct dreamcast *dc, const int16_t *data, int frames) {
|
|||
dc->push_audio(dc->userdata, data, frames);
|
||||
}
|
||||
|
||||
void dc_debug_menu(struct dreamcast *dc) {
|
||||
list_for_each_entry(dev, &dc->devices, struct device, it) {
|
||||
if (dev->debug_menu) {
|
||||
dev->debug_menu(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dc_input(struct dreamcast *dc, int port, int button, int16_t value) {
|
||||
maple_handle_input(dc->maple, port, button, value);
|
||||
}
|
||||
|
@ -232,13 +224,12 @@ struct device *dc_get_device(struct dreamcast *dc, const char *name) {
|
|||
}
|
||||
|
||||
void *dc_create_device(struct dreamcast *dc, size_t size, const char *name,
|
||||
device_init_cb init, device_debug_menu_cb debug_menu) {
|
||||
device_init_cb init) {
|
||||
struct device *dev = calloc(1, size);
|
||||
|
||||
dev->dc = dc;
|
||||
dev->name = name;
|
||||
dev->init = init;
|
||||
dev->debug_menu = debug_menu;
|
||||
|
||||
list_add(&dc->devices, &dev->it);
|
||||
|
||||
|
|
|
@ -88,13 +88,11 @@ struct memory_interface {
|
|||
* device
|
||||
*/
|
||||
typedef int (*device_init_cb)(struct device *);
|
||||
typedef void (*device_debug_menu_cb)(struct device *);
|
||||
|
||||
struct device {
|
||||
struct dreamcast *dc;
|
||||
const char *name;
|
||||
device_init_cb init;
|
||||
device_debug_menu_cb debug_menu;
|
||||
|
||||
/* optional interfaces */
|
||||
struct debug_interface *debug_if;
|
||||
|
@ -161,7 +159,7 @@ struct dreamcast *dc_create();
|
|||
void dc_destroy(struct dreamcast *dc);
|
||||
|
||||
void *dc_create_device(struct dreamcast *dc, size_t size, const char *name,
|
||||
device_init_cb init, device_debug_menu_cb debug_menu);
|
||||
device_init_cb init);
|
||||
struct device *dc_get_device(struct dreamcast *dc, const char *name);
|
||||
void dc_destroy_device(struct device *dev);
|
||||
|
||||
|
@ -187,7 +185,6 @@ void dc_suspend(struct dreamcast *dc);
|
|||
void dc_resume(struct dreamcast *dc);
|
||||
void dc_tick(struct dreamcast *dc, int64_t ns);
|
||||
void dc_input(struct dreamcast *dc, int port, int button, int16_t value);
|
||||
void dc_debug_menu(struct dreamcast *dc);
|
||||
|
||||
/* client functionality */
|
||||
void dc_push_audio(struct dreamcast *dc, const int16_t *data, int frames);
|
||||
|
|
|
@ -759,7 +759,7 @@ void gdrom_destroy(struct gdrom *gd) {
|
|||
|
||||
struct gdrom *gdrom_create(struct dreamcast *dc) {
|
||||
struct gdrom *gd =
|
||||
dc_create_device(dc, sizeof(struct gdrom), "gdrom", &gdrom_init, NULL);
|
||||
dc_create_device(dc, sizeof(struct gdrom), "gdrom", &gdrom_init);
|
||||
return gd;
|
||||
}
|
||||
|
||||
|
|
|
@ -295,6 +295,11 @@ static uint32_t *holly_interrupt_status(struct holly *hl,
|
|||
}
|
||||
}
|
||||
|
||||
static int holly_init(struct device *dev) {
|
||||
struct holly *hl = (struct holly *)dev;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void holly_clear_interrupt(struct holly *hl, holly_interrupt_t intr) {
|
||||
enum holly_interrupt_type type = HOLLY_INTERRUPT_TYPE(intr);
|
||||
uint32_t irq = HOLLY_INTERRUPT_IRQ(intr);
|
||||
|
@ -320,9 +325,7 @@ void holly_raise_interrupt(struct holly *hl, holly_interrupt_t intr) {
|
|||
}
|
||||
}
|
||||
|
||||
static void holly_debug_menu(struct device *dev) {
|
||||
struct holly *hl = (struct holly *)dev;
|
||||
|
||||
void holly_debug_menu(struct holly *hl) {
|
||||
if (igBeginMainMenuBar()) {
|
||||
if (igBeginMenu("HOLLY", 1)) {
|
||||
if (igMenuItem("log reg access", NULL, hl->log_reg_access, 1)) {
|
||||
|
@ -348,18 +351,13 @@ static void holly_debug_menu(struct device *dev) {
|
|||
}
|
||||
}
|
||||
|
||||
static int holly_init(struct device *dev) {
|
||||
struct holly *hl = (struct holly *)dev;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void holly_destroy(struct holly *hl) {
|
||||
dc_destroy_device((struct device *)hl);
|
||||
}
|
||||
|
||||
struct holly *holly_create(struct dreamcast *dc) {
|
||||
struct holly *hl = dc_create_device(dc, sizeof(struct holly), "holly",
|
||||
&holly_init, &holly_debug_menu);
|
||||
struct holly *hl =
|
||||
dc_create_device(dc, sizeof(struct holly), "holly", &holly_init);
|
||||
|
||||
/* init registers */
|
||||
#define HOLLY_REG(addr, name, default, type) \
|
||||
|
|
|
@ -34,6 +34,8 @@ extern struct reg_cb holly_cb[NUM_HOLLY_REGS];
|
|||
struct holly *holly_create(struct dreamcast *dc);
|
||||
void holly_destroy(struct holly *hl);
|
||||
|
||||
void holly_debug_menu(struct holly *hl);
|
||||
|
||||
void holly_raise_interrupt(struct holly *hl, holly_interrupt_t intr);
|
||||
void holly_clear_interrupt(struct holly *hl, holly_interrupt_t intr);
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ void maple_destroy(struct maple *mp) {
|
|||
|
||||
struct maple *maple_create(struct dreamcast *dc) {
|
||||
struct maple *mp =
|
||||
dc_create_device(dc, sizeof(struct maple), "maple", &maple_init, NULL);
|
||||
dc_create_device(dc, sizeof(struct maple), "maple", &maple_init);
|
||||
|
||||
/* register a controller and vmu for all ports by default */
|
||||
for (int i = 0; i < MAPLE_NUM_PORTS; i++) {
|
||||
|
|
|
@ -236,8 +236,7 @@ void pvr_destroy(struct pvr *pvr) {
|
|||
}
|
||||
|
||||
struct pvr *pvr_create(struct dreamcast *dc) {
|
||||
struct pvr *pvr =
|
||||
dc_create_device(dc, sizeof(struct pvr), "pvr", &pvr_init, NULL);
|
||||
struct pvr *pvr = dc_create_device(dc, sizeof(struct pvr), "pvr", &pvr_init);
|
||||
|
||||
return pvr;
|
||||
}
|
||||
|
|
|
@ -674,7 +674,7 @@ void ta_destroy(struct ta *ta) {
|
|||
struct ta *ta_create(struct dreamcast *dc) {
|
||||
ta_init_tables();
|
||||
|
||||
struct ta *ta = dc_create_device(dc, sizeof(struct ta), "ta", &ta_init, NULL);
|
||||
struct ta *ta = dc_create_device(dc, sizeof(struct ta), "ta", &ta_init);
|
||||
|
||||
return ta;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ static int bios_init(struct device *dev) {
|
|||
|
||||
struct bios *bios_create(struct dreamcast *dc) {
|
||||
struct bios *bios =
|
||||
dc_create_device(dc, sizeof(struct bios), "bios", &bios_init, NULL);
|
||||
dc_create_device(dc, sizeof(struct bios), "bios", &bios_init);
|
||||
return bios;
|
||||
;
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ void flash_destroy(struct flash *flash) {
|
|||
|
||||
struct flash *flash_create(struct dreamcast *dc) {
|
||||
struct flash *flash =
|
||||
dc_create_device(dc, sizeof(struct flash), "flash", &flash_init, NULL);
|
||||
dc_create_device(dc, sizeof(struct flash), "flash", &flash_init);
|
||||
return flash;
|
||||
}
|
||||
|
||||
|
|
126
src/hw/sh4/sh4.c
126
src/hw/sh4/sh4.c
|
@ -102,40 +102,6 @@ static void sh4_invalid_instr(void *data) {
|
|||
LOG_FATAL("Unhandled invalid instruction at 0x%08x", sh4->ctx.pc);
|
||||
}
|
||||
|
||||
void sh4_clear_interrupt(struct sh4 *sh4, enum sh4_interrupt intr) {
|
||||
sh4->requested_interrupts &= ~sh4->sort_id[intr];
|
||||
sh4_intc_update_pending(sh4);
|
||||
}
|
||||
|
||||
void sh4_raise_interrupt(struct sh4 *sh4, enum sh4_interrupt intr) {
|
||||
sh4->requested_interrupts |= sh4->sort_id[intr];
|
||||
sh4_intc_update_pending(sh4);
|
||||
}
|
||||
|
||||
void sh4_reset(struct sh4 *sh4, uint32_t pc) {
|
||||
jit_free_blocks(sh4->jit);
|
||||
|
||||
/* reset context */
|
||||
memset(&sh4->ctx, 0, sizeof(sh4->ctx));
|
||||
sh4->ctx.pc = pc;
|
||||
sh4->ctx.r[15] = 0x8d000000;
|
||||
sh4->ctx.pr = 0x0;
|
||||
sh4->ctx.sr = 0x700000f0;
|
||||
sh4->ctx.fpscr = 0x00040001;
|
||||
|
||||
/* initialize registers */
|
||||
#define SH4_REG(addr, name, default, type) \
|
||||
sh4->reg[name] = default; \
|
||||
sh4->name = (type *)&sh4->reg[name];
|
||||
#include "hw/sh4/sh4_regs.inc"
|
||||
#undef SH4_REG
|
||||
|
||||
/* reset interrupts */
|
||||
sh4_intc_reprioritize(sh4);
|
||||
|
||||
sh4->execute_if->running = 1;
|
||||
}
|
||||
|
||||
static void sh4_run(struct device *dev, int64_t ns) {
|
||||
PROF_ENTER("cpu", "sh4_run");
|
||||
|
||||
|
@ -153,34 +119,6 @@ static void sh4_run(struct device *dev, int64_t ns) {
|
|||
PROF_LEAVE();
|
||||
}
|
||||
|
||||
static void sh4_debug_menu(struct device *dev) {
|
||||
struct sh4 *sh4 = (struct sh4 *)dev;
|
||||
struct jit *jit = sh4->jit;
|
||||
|
||||
if (igBeginMainMenuBar()) {
|
||||
if (igBeginMenu("SH4", 1)) {
|
||||
if (igMenuItem("clear cache", NULL, 0, 1)) {
|
||||
jit_invalidate_blocks(sh4->jit);
|
||||
}
|
||||
|
||||
if (!jit->dump_blocks) {
|
||||
if (igMenuItem("start dumping blocks", NULL, 0, 1)) {
|
||||
jit->dump_blocks = 1;
|
||||
jit_invalidate_blocks(jit);
|
||||
}
|
||||
} else {
|
||||
if (igMenuItem("stop dumping blocks", NULL, 1, 1)) {
|
||||
jit->dump_blocks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
igEndMenu();
|
||||
}
|
||||
|
||||
igEndMainMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
static int sh4_init(struct device *dev) {
|
||||
struct sh4 *sh4 = (struct sh4 *)dev;
|
||||
struct dreamcast *dc = sh4->dc;
|
||||
|
@ -233,6 +171,67 @@ static int sh4_init(struct device *dev) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
void sh4_clear_interrupt(struct sh4 *sh4, enum sh4_interrupt intr) {
|
||||
sh4->requested_interrupts &= ~sh4->sort_id[intr];
|
||||
sh4_intc_update_pending(sh4);
|
||||
}
|
||||
|
||||
void sh4_raise_interrupt(struct sh4 *sh4, enum sh4_interrupt intr) {
|
||||
sh4->requested_interrupts |= sh4->sort_id[intr];
|
||||
sh4_intc_update_pending(sh4);
|
||||
}
|
||||
|
||||
void sh4_reset(struct sh4 *sh4, uint32_t pc) {
|
||||
jit_free_blocks(sh4->jit);
|
||||
|
||||
/* reset context */
|
||||
memset(&sh4->ctx, 0, sizeof(sh4->ctx));
|
||||
sh4->ctx.pc = pc;
|
||||
sh4->ctx.r[15] = 0x8d000000;
|
||||
sh4->ctx.pr = 0x0;
|
||||
sh4->ctx.sr = 0x700000f0;
|
||||
sh4->ctx.fpscr = 0x00040001;
|
||||
|
||||
/* initialize registers */
|
||||
#define SH4_REG(addr, name, default, type) \
|
||||
sh4->reg[name] = default; \
|
||||
sh4->name = (type *)&sh4->reg[name];
|
||||
#include "hw/sh4/sh4_regs.inc"
|
||||
#undef SH4_REG
|
||||
|
||||
/* reset interrupts */
|
||||
sh4_intc_reprioritize(sh4);
|
||||
|
||||
sh4->execute_if->running = 1;
|
||||
}
|
||||
|
||||
void sh4_debug_menu(struct sh4 *sh4) {
|
||||
struct jit *jit = sh4->jit;
|
||||
|
||||
if (igBeginMainMenuBar()) {
|
||||
if (igBeginMenu("SH4", 1)) {
|
||||
if (igMenuItem("clear cache", NULL, 0, 1)) {
|
||||
jit_invalidate_blocks(sh4->jit);
|
||||
}
|
||||
|
||||
if (!jit->dump_blocks) {
|
||||
if (igMenuItem("start dumping blocks", NULL, 0, 1)) {
|
||||
jit->dump_blocks = 1;
|
||||
jit_invalidate_blocks(jit);
|
||||
}
|
||||
} else {
|
||||
if (igMenuItem("stop dumping blocks", NULL, 1, 1)) {
|
||||
jit->dump_blocks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
igEndMenu();
|
||||
}
|
||||
|
||||
igEndMainMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
void sh4_destroy(struct sh4 *sh4) {
|
||||
jit_destroy(sh4->jit);
|
||||
sh4_guest_destroy(sh4->guest);
|
||||
|
@ -246,8 +245,7 @@ void sh4_destroy(struct sh4 *sh4) {
|
|||
}
|
||||
|
||||
struct sh4 *sh4_create(struct dreamcast *dc) {
|
||||
struct sh4 *sh4 = dc_create_device(dc, sizeof(struct sh4), "sh", &sh4_init,
|
||||
&sh4_debug_menu);
|
||||
struct sh4 *sh4 = dc_create_device(dc, sizeof(struct sh4), "sh", &sh4_init);
|
||||
sh4->debug_if = dc_create_debug_interface(
|
||||
&sh4_dbg_num_registers, &sh4_dbg_step, &sh4_dbg_add_breakpoint,
|
||||
&sh4_dbg_remove_breakpoint, &sh4_dbg_read_memory, &sh4_dbg_read_register);
|
||||
|
|
|
@ -96,10 +96,11 @@ void sh4_intc_check_pending(void *data);
|
|||
void sh4_intc_reprioritize(struct sh4 *sh4);
|
||||
|
||||
struct sh4 *sh4_create(struct dreamcast *dc);
|
||||
void sh4_destroy(struct sh4 *sh);
|
||||
void sh4_destroy(struct sh4 *sh4);
|
||||
void sh4_debug_menu(struct sh4 *sh4);
|
||||
void sh4_reset(struct sh4 *sh4, uint32_t pc);
|
||||
void sh4_raise_interrupt(struct sh4 *sh, enum sh4_interrupt intr);
|
||||
void sh4_clear_interrupt(struct sh4 *sh, enum sh4_interrupt intr);
|
||||
void sh4_raise_interrupt(struct sh4 *sh4, enum sh4_interrupt intr);
|
||||
void sh4_clear_interrupt(struct sh4 *sh4, enum sh4_interrupt intr);
|
||||
void sh4_sr_updated(void *data, uint32_t old_sr);
|
||||
void sh4_fpscr_updated(void *data, uint32_t old_fpscr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue