67 lines
1.3 KiB
C
67 lines
1.3 KiB
C
#ifndef GB_H
|
|
#define GB_H
|
|
#include <r_io.h>
|
|
|
|
enum {
|
|
GB_TIMERS_DIV = 0,
|
|
GB_TIMERS_TIMA,
|
|
GB_TIMERS_TMA,
|
|
GB_TIMERS_TAC,
|
|
};
|
|
|
|
typedef struct gb_timers_t {
|
|
ut64 seek;
|
|
ut32 fd;
|
|
ut16 odiv;
|
|
ut16 div;
|
|
ut8 buf[4];
|
|
ut8 otma;
|
|
st8 tima_wait;
|
|
bool check_fedge;
|
|
} GBTimers;
|
|
|
|
GBTimers *gb_timers_open(RIO *io);
|
|
void gb_timers_update(GBTimers *timers, ut32 cycles);
|
|
void gb_timers_close(GBTimers *timers, RIO *io);
|
|
|
|
typedef struct gb_joypad_t {
|
|
ut8 *keys;
|
|
int fd;
|
|
ut16 up;
|
|
ut16 down;
|
|
ut16 left;
|
|
ut16 right;
|
|
ut16 a;
|
|
ut16 b;
|
|
ut16 start;
|
|
ut16 select;
|
|
ut8 data;
|
|
ut8 odata;
|
|
} GBJoypad;
|
|
|
|
GBJoypad *gb_joypad_open(RIO *io);
|
|
void gb_joypad_update(GBJoypad *joypad);
|
|
void gb_joypad_close(GBJoypad *joypad, RIO *io);
|
|
|
|
typedef struct gb_dma_t {
|
|
int dma_fd; //fd representing the dma register
|
|
int dma_bus_fd; //fd representing the memory bus while dma occupies it
|
|
ut16 bus_occupancy_size;
|
|
ut8 buf[0xa0];
|
|
ut8 dst; //current dst addr low byte
|
|
ut8 todo; //cycles todo
|
|
ut8 frontrun; //cycles that read/write ops had frontrun the dma copy
|
|
ut8 val;
|
|
} GBDMA;
|
|
|
|
GBDMA *gb_dma_open(RIO *io);
|
|
void gb_dma_update(GBDMA *dma, RIO *io, ut32 cycles);
|
|
void gb_dma_close(GBDMA *dma, RIO *io);
|
|
|
|
extern RIOPlugin r_io_plugin_gb_timers;
|
|
extern RIOPlugin r_io_plugin_gb_mbc1;
|
|
extern RIOPlugin r_io_plugin_gb_mbc2;
|
|
extern RIOPlugin r_io_plugin_gb_joypad;
|
|
|
|
#endif
|