Compare commits
No commits in common. "d32386b6219e0102dc62ddf6af966355a85de1fe" and "4fe5bd2e151745a2fbc81e712a83d8fbdba19eed" have entirely different histories.
d32386b621
...
4fe5bd2e15
12
include/gb.h
12
include/gb.h
|
@ -24,9 +24,9 @@ typedef struct gb_timers_t {
|
||||||
bool check_fedge;
|
bool check_fedge;
|
||||||
} GBTimers;
|
} GBTimers;
|
||||||
|
|
||||||
bool gb_timers_init(GBTimers *timers, RIO *io);
|
GBTimers *gb_timers_open(RIO *io);
|
||||||
void gb_timers_continue(GBTimers *timers, ut32 cycles);
|
void gb_timers_continue(GBTimers *timers, ut32 cycles);
|
||||||
void gb_timers_fini(GBTimers *timers, RIO *io);
|
void gb_timers_close(GBTimers *timers, RIO *io);
|
||||||
|
|
||||||
typedef struct gb_joypad_t {
|
typedef struct gb_joypad_t {
|
||||||
ut8 *keys;
|
ut8 *keys;
|
||||||
|
@ -43,9 +43,9 @@ typedef struct gb_joypad_t {
|
||||||
ut8 odata;
|
ut8 odata;
|
||||||
} GBJoypad;
|
} GBJoypad;
|
||||||
|
|
||||||
bool gb_joypad_init(GBJoypad *joypad, RIO *io);
|
GBJoypad *gb_joypad_open(RIO *io);
|
||||||
void gb_joypad_continue(GBJoypad *joypad);
|
void gb_joypad_continue(GBJoypad *joypad);
|
||||||
void gb_joypad_fini(GBJoypad *joypad, RIO *io);
|
void gb_joypad_close(GBJoypad *joypad, RIO *io);
|
||||||
|
|
||||||
typedef struct gb_dma_t {
|
typedef struct gb_dma_t {
|
||||||
ut64 seek; //17 bit seek and some flags
|
ut64 seek; //17 bit seek and some flags
|
||||||
|
@ -172,8 +172,8 @@ typedef struct gb_dmg_ppu_t {
|
||||||
typedef struct gameboy_t {
|
typedef struct gameboy_t {
|
||||||
RIO *io;
|
RIO *io;
|
||||||
RArch *arch;
|
RArch *arch;
|
||||||
GBTimers timers;
|
GBTimers *timers;
|
||||||
GBJoypad joypad;
|
GBJoypad *joypad;
|
||||||
GBDMA *dma;
|
GBDMA *dma;
|
||||||
GBPPU *ppu;
|
GBPPU *ppu;
|
||||||
ut64 addr;
|
ut64 addr;
|
||||||
|
|
16
io/joypad.c
16
io/joypad.c
|
@ -80,18 +80,19 @@ RIOPlugin r_io_plugin_gb_joypad = {
|
||||||
.write = __write,
|
.write = __write,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool gb_joypad_init (GBJoypad *joypad, RIO *io) {
|
GBJoypad *gb_joypad_open (RIO *io) {
|
||||||
if (!joypad || !io) {
|
GBJoypad *joypad = R_NEW0 (GBJoypad);
|
||||||
return false;
|
if (!joypad) {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
joypad[0] = (const GBJoypad){0};
|
|
||||||
char uri[64];
|
char uri[64];
|
||||||
memset (uri, 0x00, sizeof (char) * 64);
|
memset (uri, 0x00, sizeof (char) * 64);
|
||||||
sprintf (uri, "gb_joypad://%p", joypad);
|
sprintf (uri, "gb_joypad://%p", joypad);
|
||||||
RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_joypad,
|
RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_joypad,
|
||||||
uri, R_PERM_RWX, 0);
|
uri, R_PERM_RWX, 0);
|
||||||
if (!desc) {
|
if (!desc) {
|
||||||
return false;
|
free (joypad);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
joypad->fd = desc->fd;
|
joypad->fd = desc->fd;
|
||||||
const ut8 *keys = SDL_GetKeyboardState (NULL);
|
const ut8 *keys = SDL_GetKeyboardState (NULL);
|
||||||
|
@ -104,7 +105,7 @@ bool gb_joypad_init (GBJoypad *joypad, RIO *io) {
|
||||||
joypad->b = SDL_SCANCODE_K;
|
joypad->b = SDL_SCANCODE_K;
|
||||||
joypad->start = SDL_SCANCODE_SPACE;
|
joypad->start = SDL_SCANCODE_SPACE;
|
||||||
joypad->select = SDL_SCANCODE_KP_ENTER;
|
joypad->select = SDL_SCANCODE_KP_ENTER;
|
||||||
return true;;
|
return joypad;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gb_joypad_continue(GBJoypad *joypad) {
|
void gb_joypad_continue(GBJoypad *joypad) {
|
||||||
|
@ -138,9 +139,10 @@ void gb_joypad_continue(GBJoypad *joypad) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gb_joypad_fini (GBJoypad *joypad, RIO *io) {
|
void gb_joypad_close (GBJoypad *joypad, RIO *io) {
|
||||||
if (!joypad || !io) {
|
if (!joypad || !io) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
r_io_fd_close (io, joypad->fd);
|
r_io_fd_close (io, joypad->fd);
|
||||||
|
free (joypad);
|
||||||
}
|
}
|
||||||
|
|
17
io/timers.c
17
io/timers.c
|
@ -101,28 +101,33 @@ RIOPlugin r_io_plugin_gb_timers = {
|
||||||
.write = __write,
|
.write = __write,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool gb_timers_init (GBTimers *timers, RIO *io) {
|
GBTimers *gb_timers_open (RIO *io) {
|
||||||
if (!timers || !io) {
|
if (!io) {
|
||||||
return false;
|
return NULL;
|
||||||
|
}
|
||||||
|
GBTimers *timers = R_NEW0 (GBTimers);
|
||||||
|
if (!timers) {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
timers[0] = (const GBTimers){0};
|
|
||||||
char uri[64];
|
char uri[64];
|
||||||
memset (uri, 0x00, sizeof (char) * 64);
|
memset (uri, 0x00, sizeof (char) * 64);
|
||||||
sprintf (uri, "gb_timers://%p", timers);
|
sprintf (uri, "gb_timers://%p", timers);
|
||||||
RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_timers,
|
RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_timers,
|
||||||
uri, R_PERM_RWX, 0);
|
uri, R_PERM_RWX, 0);
|
||||||
if (!desc) {
|
if (!desc) {
|
||||||
|
free (timers);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
timers->fd = desc->fd;
|
timers->fd = desc->fd;
|
||||||
return true;
|
return timers;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gb_timers_fini (GBTimers *timers, RIO *io) {
|
void gb_timers_close (GBTimers *timers, RIO *io) {
|
||||||
if (!timers || !io) {
|
if (!timers || !io) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
r_io_fd_close (io, timers->fd);
|
r_io_fd_close (io, timers->fd);
|
||||||
|
free (timers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gb_timers_continue (GBTimers *timers, ut32 cycles) {
|
void gb_timers_continue (GBTimers *timers, ut32 cycles) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user