Split core into its own repository
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
#ifndef VB_H_
|
||||
#define VB_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef VBAPI
|
||||
#define VBAPI extern
|
||||
#endif
|
||||
|
||||
/* Header includes */
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
/**************************** Compilation Control ****************************/
|
||||
|
||||
/*
|
||||
VB_DIRECT_EXCEPTION
|
||||
VB_DIRECT_EXECUTE
|
||||
VB_DIRECT_FETCH
|
||||
VB_DIRECT_READ
|
||||
VB_DIRECT_WRITE
|
||||
|
||||
Implements callbacks as direct function calls with names in the form of
|
||||
vbxOn<callback>() with the same prototypes as the regular function pointer
|
||||
callbacks. If left undefined, the function pointers are used.
|
||||
*/
|
||||
|
||||
/*
|
||||
VB_DIV_GENERIC
|
||||
|
||||
Provides a generic implementation for the DIV instruction that guarantees the
|
||||
correct results for quotient and remainder. If left undefined, an accelerated
|
||||
implementation is used that depends on the compiler's behavior.
|
||||
*/
|
||||
|
||||
/*
|
||||
VB_LITTLE_ENDIAN
|
||||
|
||||
Accelerates simulated memory reads and writes on hosts with little-endian
|
||||
byte ordering. If left undefined, a generic implementation is used instead.
|
||||
*/
|
||||
|
||||
/*
|
||||
VB_SIGNED_PROPAGATE
|
||||
|
||||
Accelerates sign extension by assuming the >> operator propagates the sign
|
||||
bit for signed types and does not for unsigned types. If left undefined, a
|
||||
generic implementation is used instead.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************* Constants *********************************/
|
||||
|
||||
/* 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
|
||||
|
||||
/* System registers */
|
||||
#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
|
||||
|
||||
/* Memory access data types */
|
||||
#define VB_S8 0
|
||||
#define VB_U8 1
|
||||
#define VB_S16 2
|
||||
#define VB_U16 3
|
||||
#define VB_S32 4
|
||||
|
||||
|
||||
|
||||
/*********************************** Types ***********************************/
|
||||
|
||||
/* Simulation state */
|
||||
typedef struct VB VB;
|
||||
|
||||
/* Callbacks */
|
||||
typedef int (*vbOnException)(VB *sim, uint16_t *cause);
|
||||
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 vbOnException vbGetExceptionCallback(VB *sim);
|
||||
VBAPI vbOnExecute vbGetExecuteCallback (VB *sim);
|
||||
VBAPI vbOnFetch vbGetFetchCallback (VB *sim);
|
||||
VBAPI uint32_t vbGetProgramCounter (VB *sim);
|
||||
VBAPI int32_t vbGetProgramRegister (VB *sim, int index);
|
||||
VBAPI vbOnRead vbGetReadCallback (VB *sim);
|
||||
VBAPI uint32_t vbGetSystemRegister (VB *sim, int index);
|
||||
VBAPI void* vbGetUserData (VB *sim);
|
||||
VBAPI vbOnWrite vbGetWriteCallback (VB *sim);
|
||||
VBAPI VB* vbInit (VB *sim);
|
||||
VBAPI int32_t vbRead (VB *sim, uint32_t address, int type);
|
||||
VBAPI VB* vbReset (VB *sim);
|
||||
VBAPI int vbSetCartRAM (VB *sim, void *sram, uint32_t size);
|
||||
VBAPI int vbSetCartROM (VB *sim, void *rom, uint32_t size);
|
||||
VBAPI vbOnException vbSetExceptionCallback(VB *sim, vbOnException callback);
|
||||
VBAPI vbOnExecute vbSetExecuteCallback (VB *sim, vbOnExecute callback);
|
||||
VBAPI vbOnFetch vbSetFetchCallback (VB *sim, vbOnFetch callback);
|
||||
VBAPI uint32_t vbSetProgramCounter (VB *sim, uint32_t value);
|
||||
VBAPI int32_t vbSetProgramRegister (VB *sim, int index, int32_t value);
|
||||
VBAPI vbOnRead vbSetReadCallback (VB *sim, vbOnRead callback);
|
||||
VBAPI uint32_t vbSetSystemRegister (VB *sim, int index, uint32_t value);
|
||||
VBAPI void* vbSetUserData (VB *sim, void *tag);
|
||||
VBAPI vbOnWrite vbSetWriteCallback (VB *sim, vbOnWrite callback);
|
||||
VBAPI size_t vbSizeOf ();
|
||||
VBAPI int32_t vbWrite (VB *sim, uint32_t address, int type, int32_t value);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* VB_H_ */
|
||||
Reference in New Issue
Block a user