Add ui/emu interfaces

This commit is contained in:
meepingsnesroms
2018-03-29 20:19:31 -07:00
parent 8cd8303148
commit 0035dcb89a
4 changed files with 273 additions and 14 deletions

View File

@@ -195,7 +195,7 @@ bool retro_load_game(const struct retro_game_info *info)
fclose(romFile);
if(bytesRead == ROM_SIZE)
emulatorInit(palmRom);
emulatorInit(palmRom, ACCURATE);
else
return false;

View File

@@ -26,32 +26,46 @@ uint8_t palmRam[RAM_SIZE];
uint8_t palmRom[ROM_SIZE];
uint8_t palmReg[REG_SIZE];
input_t palmIo;
sdcard_t palmSdCard;
uint16_t palmFramebuffer[160 * (160 + 60)];//really 160*160, the extra pixels are the silkscreened digitizer area
double palmCrystalCycles;//how many cycles before toggling the 32.768 kHz crystal
double palmCycleCounter;//can be greater then 0 if too many cycles where run
double palmClockMultiplier;//used by the emulator to overclock the emulated palm
void emulatorInit(uint8_t* palmRomDump){
void emulatorInit(uint8_t* palmRomDump, uint16_t specialFeatures){
//cpu
m68k_init();
m68k_set_cpu_type(M68K_CPU_TYPE_68020);
m68k_set_reset_instr_callback(emulatorReset);
m68k_set_int_ack_callback(interruptAcknowledge);
patchMusashiOpcodeHandlerCpu32();
memset(palmRam, 0x00, RAM_SIZE);
memcpy(palmRom, palmRomDump, ROM_SIZE);
memcpy(palmRam, palmRom, 256);//copy ROM header
memset(&palmIo, 0x00, sizeof(input_t));
memcpy(&palmFramebuffer[160 * 160], silkscreenData, SILKSCREEN_WIDTH * SILKSCREEN_HEIGHT * (SILKSCREEN_BPP / 8));
resetHwRegisters();
sed1376Reset();
lowPowerStopActive = false;
palmCrystalCycles = 2.0 * (14.0 * (71.0/*p*/ + 1.0) + 3.0/*q*/ + 1.0) / 2.0/*prescaler1*/;
palmCycleCounter = 0.0;
palmClockMultiplier = 1.0;//Overclock disabled
lowPowerStopActive = false;
//memory
memset(palmRam, 0x00, RAM_SIZE);
memcpy(palmRom, palmRomDump, ROM_SIZE);
memcpy(palmRam, palmRom, 256);//copy ROM header
memcpy(&palmFramebuffer[160 * 160], silkscreenData, SILKSCREEN_WIDTH * SILKSCREEN_HEIGHT * (SILKSCREEN_BPP / 8));
sed1376Reset();
m68k_set_reset_instr_callback(emulatorReset);
m68k_set_int_ack_callback(interruptAcknowledge);
//interfaces
palmIo.buttonState = 0x0000;
palmIo.touchscreenX = 0;
palmIo.touchscreenY = 0;
palmIo.touchscreenTouched = false;
palmSdCard.getSdCardChunk = NULL;
palmSdCard.setSdCardChunk = NULL;
palmSdCard.inserted = false;
//config
palmClockMultiplier = 1.0;//Overclock disabled
//start running
m68k_pulse_reset();
}

View File

@@ -19,10 +19,22 @@ typedef struct{
bool touchscreenTouched;
}input_t;
typedef struct{
void (*getSdCardChunk)(uint8_t* data, uint32_t size);
void (*setSdCardChunk)(uint8_t* data, uint32_t size);
bool inserted;
}sdcard_t;
//buttons
#define buttonUp 0
//etc...
//special features, these make the emulator inaccurate in a good way, but still inaccurate and are therefore optional, they dont do anything yet
#define ACCURATE 0x0000 //no hacks/addons
#define INACCURATE_RAM_HUGE 0x0001 //128 mb ram
#define INACCURATE_FAST_CPU 0x0002 //doubles cpu speed
#define INACCURATE_HYBRID_CPU 0x0004 //allows running arm opcodes in an OS 4 enviroment
//config options
#define EMU_FPS 60.0
#define CRYSTAL_FREQUENCY 32768.0
@@ -47,13 +59,14 @@ extern uint8_t palmRam[];
extern uint8_t palmRom[];
extern uint8_t palmReg[];
extern input_t palmIo;
extern sdcard_t palmSdCard;
extern uint16_t palmFramebuffer[];
extern double palmCrystalCycles;
extern double palmCycleCounter;
extern double palmClockMultiplier;
//functions
void emulatorInit(uint8_t* palmRomDump);
void emulatorInit(uint8_t* palmRomDump, uint16_t specialFeatures);
void emulatorReset();
void emulatorSetRtc(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds);
uint32_t emulatorGetStateSize();

232
tests/HwRegTest13.txt Normal file
View File

@@ -0,0 +1,232 @@
New CPU frequency of:33161216.000000 cycles per second.
New clk32 cycle count of :1012.000000.
Cpu Wrote 8 bits of 0x00000020 to register 0x0409.
Cpu Wrote 8 bits of 0x00000000 to register 0x0411.
Cpu Wrote 8 bits of 0x0000000F to register 0x041C.
Cpu Wrote 8 bits of 0x000000F0 to register 0x0419.
Cpu Wrote 8 bits of 0x0000000F to register 0x041D.
Cpu Wrote 8 bits of 0x0000000F to register 0x041F.
Cpu Wrote 8 bits of 0x0000000F to register 0x0419.
Cpu Wrote 8 bits of 0x0000000F to register 0x041E.
Cpu Wrote 8 bits of 0x00000008 to register 0x0421.
Cpu Wrote 8 bits of 0x00000002 to register 0x0429.
Cpu Wrote 8 bits of 0x00000004 to register 0x0431.
Cpu Wrote 8 bits of 0x00000000 to register 0x0439.
Cpu Wrote 8 bits of 0x00000008 to register 0x0441.
Cpu Wrote 8 bits of 0x00000020 to register 0x0449.
Cpu Wrote 8 bits of 0x00000000 to register 0x0A27.
Cpu Wrote 8 bits of 0x000000F8 to register 0x0000.
Cpu Wrote 16 bits of 0x00008000 to register 0x0100.
Cpu Wrote 16 bits of 0x000001AB to register 0x0110.
Cpu Wrote 16 bits of 0x0000FFC0 to register 0x0102.
Cpu Wrote 16 bits of 0x000001F3 to register 0x0112.
Cpu Wrote 16 bits of 0x00008200 to register 0x0104.
Cpu Wrote 16 bits of 0x00000101 to register 0x0114.
Cpu Wrote 16 bits of 0x00000000 to register 0x0106.
Cpu Wrote 16 bits of 0x00001E83 to register 0x0116.
Cpu Wrote 16 bits of 0x00000040 to register 0x010A.
Cpu Wrote 16 bits of 0x00000000 to register 0x0C02.
Cpu Wrote 16 bits of 0x00004020 to register 0x0C00.
Cpu Wrote 16 bits of 0x00008000 to register 0x0C02.
Cpu Wrote 16 bits of 0x00001A81 to register 0x0116.
Cpu Wrote 16 bits of 0x00000000 to register 0x0C02.
Cpu Wrote 16 bits of 0x00008000 to register 0x0C02.
Cpu Read 16 bits from register 0x0310.
New CPU frequency of:33161216.000000 cycles per second.
New clk32 cycle count of :1012.000000.
New CPU frequency of:33161216.000000 cycles per second.
New clk32 cycle count of :1012.000000.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.
Ran frame, executed 552725.933333 cycles.
Ran frame, executed 553603.000000 cycles.
Ran frame, executed 553468.066667 cycles.
Ran frame, executed 553333.133333 cycles.
Ran frame, executed 553198.200000 cycles.
Ran frame, executed 553063.266667 cycles.
Ran frame, executed 552928.333333 cycles.
Ran frame, executed 552793.400000 cycles.
Ran frame, executed 553670.466667 cycles.
Ran frame, executed 553535.533333 cycles.
Ran frame, executed 553400.600000 cycles.
Ran frame, executed 553265.666667 cycles.
Ran frame, executed 553130.733333 cycles.
Ran frame, executed 552995.800000 cycles.
Ran frame, executed 552860.866667 cycles.