Compare commits

..

No commits in common. "d32386b6219e0102dc62ddf6af966355a85de1fe" and "4fe5bd2e151745a2fbc81e712a83d8fbdba19eed" have entirely different histories.

3 changed files with 26 additions and 19 deletions

View File

@ -24,9 +24,9 @@ typedef struct gb_timers_t {
bool check_fedge;
} 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_fini(GBTimers *timers, RIO *io);
void gb_timers_close(GBTimers *timers, RIO *io);
typedef struct gb_joypad_t {
ut8 *keys;
@ -43,9 +43,9 @@ typedef struct gb_joypad_t {
ut8 odata;
} GBJoypad;
bool gb_joypad_init(GBJoypad *joypad, RIO *io);
GBJoypad *gb_joypad_open(RIO *io);
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 {
ut64 seek; //17 bit seek and some flags
@ -172,8 +172,8 @@ typedef struct gb_dmg_ppu_t {
typedef struct gameboy_t {
RIO *io;
RArch *arch;
GBTimers timers;
GBJoypad joypad;
GBTimers *timers;
GBJoypad *joypad;
GBDMA *dma;
GBPPU *ppu;
ut64 addr;

View File

@ -80,18 +80,19 @@ RIOPlugin r_io_plugin_gb_joypad = {
.write = __write,
};
bool gb_joypad_init (GBJoypad *joypad, RIO *io) {
if (!joypad || !io) {
return false;
GBJoypad *gb_joypad_open (RIO *io) {
GBJoypad *joypad = R_NEW0 (GBJoypad);
if (!joypad) {
return NULL;
}
joypad[0] = (const GBJoypad){0};
char uri[64];
memset (uri, 0x00, sizeof (char) * 64);
sprintf (uri, "gb_joypad://%p", joypad);
RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_joypad,
uri, R_PERM_RWX, 0);
if (!desc) {
return false;
free (joypad);
return NULL;
}
joypad->fd = desc->fd;
const ut8 *keys = SDL_GetKeyboardState (NULL);
@ -104,7 +105,7 @@ bool gb_joypad_init (GBJoypad *joypad, RIO *io) {
joypad->b = SDL_SCANCODE_K;
joypad->start = SDL_SCANCODE_SPACE;
joypad->select = SDL_SCANCODE_KP_ENTER;
return true;;
return 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) {
return;
}
r_io_fd_close (io, joypad->fd);
free (joypad);
}

View File

@ -101,28 +101,33 @@ RIOPlugin r_io_plugin_gb_timers = {
.write = __write,
};
bool gb_timers_init (GBTimers *timers, RIO *io) {
if (!timers || !io) {
return false;
GBTimers *gb_timers_open (RIO *io) {
if (!io) {
return NULL;
}
GBTimers *timers = R_NEW0 (GBTimers);
if (!timers) {
return NULL;
}
timers[0] = (const GBTimers){0};
char uri[64];
memset (uri, 0x00, sizeof (char) * 64);
sprintf (uri, "gb_timers://%p", timers);
RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_timers,
uri, R_PERM_RWX, 0);
if (!desc) {
free (timers);
return NULL;
}
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) {
return;
}
r_io_fd_close (io, timers->fd);
free (timers);
}
void gb_timers_continue (GBTimers *timers, ut32 cycles) {