pvbemu/core/vb.h

97 lines
2.7 KiB
C
Raw Normal View History

2023-03-11 00:44:57 +00:00
#ifndef VB_H_
#define VB_H_
2021-08-30 02:14:06 +00:00
#ifdef __cplusplus
extern "C" {
#endif
#ifndef VBAPI
#define VBAPI extern
#endif
/* Header includes */
#include <stddef.h>
#include <stdint.h>
/********************************* Constants *********************************/
2024-10-10 23:35:16 +00:00
/* Callback IDs */
#define VB_EXCEPTION 0
#define VB_EXECUTE 1
#define VB_FETCH 2
#define VB_FRAME 3
#define VB_READ 4
#define VB_WRITE 5
2021-08-30 02:14:06 +00:00
2023-03-11 00:44:57 +00:00
/* System registers */
2021-08-30 02:14:06 +00:00
#define VB_ADTRE 25
#define VB_CHCW 24
#define VB_ECR 4
#define VB_EIPC 0
#define VB_EIPSW 1
#define VB_FEPC 2
#define VB_FEPSW 3
#define VB_PIR 6
#define VB_PSW 5
#define VB_TKCW 7
2024-10-10 23:35:16 +00:00
/* Memory access data types */
#define VB_S8 0
#define VB_U8 1
#define VB_S16 2
#define VB_U16 3
#define VB_S32 4
2021-09-02 00:16:22 +00:00
2024-10-10 23:35:16 +00:00
/* CPU modes */
#define VB_ACCURACY 0
#define VB_DEBUG 1
#define VB_WHOLE 2
2021-09-30 17:33:55 +00:00
2021-08-30 02:14:06 +00:00
/*********************************** Types ***********************************/
2024-10-10 23:35:16 +00:00
/* Simulation state */
2021-08-30 02:14:06 +00:00
typedef struct VB VB;
2021-09-19 01:31:40 +00:00
2024-10-10 23:35:16 +00:00
/* Callbacks */
typedef int (*vbOnExecute)(VB *sim, uint32_t address, const uint16_t *code, int length);
typedef int (*vbOnFetch )(VB *sim, int fetch, uint32_t address, int32_t *value, uint32_t *cycles);
typedef int (*vbOnRead )(VB *sim, uint32_t address, int type, int32_t *value, uint32_t *cycles);
typedef int (*vbOnWrite )(VB *sim, uint32_t address, int type, int32_t *value, uint32_t *cycles, int *cancel);
/******************************* API Commands ********************************/
VBAPI int vbEmulate (VB *sim, uint32_t *clocks);
VBAPI int vbEmulateEx (VB **sims, int count, uint32_t *clocks);
VBAPI void* vbGetCallback (VB *sim, int id);
VBAPI void* vbGetCartRAM (VB *sim, uint32_t *size);
VBAPI void* vbGetCartROM (VB *sim, uint32_t *size);
VBAPI uint32_t vbGetProgramCounter (VB *sim);
VBAPI int32_t vbGetProgramRegister(VB *sim, int index);
VBAPI uint32_t vbGetSystemRegister (VB *sim, int index);
VBAPI VB* vbInit (VB *sim);
VBAPI int32_t vbRead (VB *sim, uint32_t address, int type);
VBAPI VB* vbReset (VB *sim);
VBAPI void* vbSetCallback (VB *sim, int index, void *callback);
VBAPI int vbSetCartRAM (VB *sim, void *sram, uint32_t size);
VBAPI int vbSetCartROM (VB *sim, void *rom, uint32_t size);
VBAPI uint32_t vbSetProgramCounter (VB *sim, uint32_t value);
VBAPI int32_t vbSetProgramRegister(VB *sim, int index, int32_t value);
VBAPI uint32_t vbSetSystemRegister (VB *sim, int index, uint32_t value);
VBAPI size_t vbSizeOf ();
VBAPI int32_t vbWrite (VB *sim, uint32_t address, int type, int32_t value);
2021-08-30 02:14:06 +00:00
#ifdef __cplusplus
}
#endif
2023-03-11 00:44:57 +00:00
#endif /* VB_H_ */