create a user-struct for gameboy emulation

This commit is contained in:
condret 2014-09-12 00:44:32 +02:00
parent ef8a2c6e16
commit b273b148c3
2 changed files with 77 additions and 0 deletions

66
libr/anal/arch/gb/gb.h Normal file
View File

@ -0,0 +1,66 @@
#ifndef GB_H
#define GB_H
#include <r_types.h>
typedef struct gb_user_t {
ut8 mbc_id;
ut8 romsz_id;
ut8 ramsz_id;
ut8 rombanks;
ut8 rambanks;
ut32 cycles;
} GBUser;
enum {
MBC_ROM = 0,
MBC1,
MBC1_RAM,
MBC1_RAM_BAT,
MBC2 = 0x5,
MBC2_BAT,
MBC_ROM_RAM = 0x8,
MBC_ROM_RAM_BAT,
MBC_MMM = 0x0b,
MBC_MMM_RAM,
MBC_MMM_RAM_BAT,
MBC3_BAT_TIM = 0x0f,
MBC3_RAM_BAT_TIM,
MBC3,
MBC3_RAM,
MBC3_RAM_BAT,
MBC4 = 0x15,
MBC4_RAM,
MBC4_RAM_BAT,
MBC5 = 0x19,
MBC5_RAM,
MBC5_RAM_BAT,
MBC5_RUM,
MBC5_RAM_RUM,
MBC5_RAM_BAT_RUM,
CAM = 0xfc,
TAMA5,
HUC3,
HUC1_RAM_BAT
};
enum {
NOBANK = 0,
BANK4,
BANK8,
BANK16,
BANK32,
BANK64,
BANK128,
BANK256,
BANK72 = 0x52,
BANK80,
BANK96
};
enum {
NORAM = 0,
RAM2K,
RAM8K,
RAM32K
};
#endif

View File

@ -13,6 +13,7 @@
#include "../../asm/arch/gb/gbdis.c"
#include <meta_gb_cmt.c>
#include <gb_makros.h>
#include <gb.h>
static const char *regs_1[] = { "Z", "N", "H", "C"};
static const char *regs_8[] = { "b", "c", "d", "e", "h", "l", "a", "a"}; //deprecate this and rename regs_x
@ -1430,12 +1431,22 @@ static int set_reg_profile(RAnal *anal) {
static int esil_gb_init (RAnalEsil *esil)
{
GBUser *user = R_NEW0 (GBUser);
r_anal_esil_set_op (esil, "daa", gb_custom_daa);
if (user) {
if (esil->anal) {
esil->anal->iob.read_at (esil->anal->iob.io, 0x147, &user->mbc_id, 1);
esil->anal->iob.read_at (esil->anal->iob.io, 0x148, &user->romsz_id, 1);
esil->anal->iob.read_at (esil->anal->iob.io, 0x149, &user->ramsz_id, 1);
}
esil->user = user;
}
return R_TRUE;
}
static int esil_gb_fini (RAnalEsil *esil)
{
R_FREE (esil->user);
return R_TRUE;
}