1 #ifndef GBA_H 2 #define GBA_H 3 4 #include <stdint.h> 5 #include "GBACheats.h" 6 #include "thread.h" 7 8 #define BITS_16 0 9 #define BITS_32 1 10 11 #define SAVE_GAME_VERSION_1 1 12 #define SAVE_GAME_VERSION_2 2 13 #define SAVE_GAME_VERSION_3 3 14 #define SAVE_GAME_VERSION_4 4 15 #define SAVE_GAME_VERSION_5 5 16 #define SAVE_GAME_VERSION_6 6 17 #define SAVE_GAME_VERSION_7 7 18 #define SAVE_GAME_VERSION_8 8 19 #define SAVE_GAME_VERSION_9 9 20 #define SAVE_GAME_VERSION_10 10 21 #define SAVE_GAME_VERSION SAVE_GAME_VERSION_10 22 23 #define R13_IRQ 18 24 #define R14_IRQ 19 25 #define SPSR_IRQ 20 26 #define R13_USR 26 27 #define R14_USR 27 28 #define R13_SVC 28 29 #define R14_SVC 29 30 #define SPSR_SVC 30 31 #define R13_ABT 31 32 #define R14_ABT 32 33 #define SPSR_ABT 33 34 #define R13_UND 34 35 #define R14_UND 35 36 #define SPSR_UND 36 37 #define R8_FIQ 37 38 #define R9_FIQ 38 39 #define R10_FIQ 39 40 #define R11_FIQ 40 41 #define R12_FIQ 41 42 #define R13_FIQ 42 43 #define R14_FIQ 43 44 #define SPSR_FIQ 44 45 46 typedef struct { 47 uint8_t *address; 48 uint32_t mask; 49 } memoryMap; 50 51 typedef union { 52 struct { 53 #ifdef MSB_FIRST 54 uint8_t B3; 55 uint8_t B2; 56 uint8_t B1; 57 uint8_t B0; 58 #else 59 uint8_t B0; 60 uint8_t B1; 61 uint8_t B2; 62 uint8_t B3; 63 #endif 64 } B; 65 struct { 66 #ifdef MSB_FIRST 67 uint16_t W1; 68 uint16_t W0; 69 #else 70 uint16_t W0; 71 uint16_t W1; 72 #endif 73 } W; 74 #ifdef MSB_FIRST 75 volatile uint32_t I; 76 #else 77 uint32_t I; 78 #endif 79 } reg_pair; 80 81 typedef struct 82 { 83 reg_pair reg[45]; 84 bool busPrefetch; 85 bool busPrefetchEnable; 86 uint32_t busPrefetchCount; 87 uint32_t armNextPC; 88 } bus_t; 89 90 typedef struct 91 { 92 int layerEnable; 93 int layerEnableDelay; 94 int lcdTicks; 95 } graphics_t; 96 97 extern uint64_t joy; 98 99 extern void (*cpuSaveGameFunc)(uint32_t,uint8_t); 100 101 extern bool CPUWriteBatteryFile(const char *); 102 extern bool CPUReadBatteryFile(const char *); 103 extern bool CPUReadState(const uint8_t * data, unsigned size); 104 extern unsigned CPUWriteState(uint8_t* data, unsigned size); 105 extern int CPULoadRom(const char *); 106 extern int CPULoadRomData(const char *data, int size); 107 extern void doMirroring(bool); 108 extern void CPUUpdateRegister(uint32_t, uint16_t); 109 extern void CPUInit(const char *,bool); 110 extern void CPUCleanUp (void); 111 extern void CPUReset (void); 112 extern void CPULoop(void); 113 extern void UpdateJoypad(void); 114 extern void CPUCheckDMA(int,int); 115 #if USE_FRAME_SKIP 116 extern void SetFrameskip(int); 117 #endif 118 119 #if THREADED_RENDERER 120 extern void ThreadedRendererStart(); 121 extern void ThreadedRendererStop(); 122 #endif 123 124 #if USE_MOTION_SENSOR 125 126 #define HARDWARE_SENSOR_NONE 0 127 #define HARDWARE_SENSOR_TILT 0x1 128 #define HARDWARE_SENSOR_GYRO 0x2 129 130 typedef struct { 131 int sensor; 132 133 int tilt_x; 134 int tilt_y; 135 136 uint16_t pinState; 137 uint16_t direction; 138 uint16_t gyroSample; 139 bool readWrite; 140 bool gyroEdge; 141 } hardware_t; 142 143 extern hardware_t hardware; 144 145 #endif 146 147 #endif // GBA_H 148