mirror of
https://github.com/libretro/Mu.git
synced 2026-09-24 15:46:20 +00:00
Try to move cyclone speedups to musashi since cyclone is gone
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "emulator.h"
|
||||
#include "portability.h"
|
||||
@@ -8,22 +9,23 @@
|
||||
#include "m68k/m68kcpu.h"
|
||||
|
||||
|
||||
/*
|
||||
//saving this little snippet to optimize musashi
|
||||
unsigned int checkPc(unsigned int pc){
|
||||
unsigned int dataBufferHost;
|
||||
unsigned int dataBufferGuest;
|
||||
unsigned int windowSize;
|
||||
//memory speed hack, used by cyclone, cyclone always crashed so I decided to just port over one of its biggest speed ups and only use musashi
|
||||
#if M68K_SEPARATE_READS
|
||||
static uintptr_t memBase;
|
||||
|
||||
pc -= cycloneCpu.membase;//get the real program counter
|
||||
|
||||
if(chips[CHIP_A0_ROM].inBootMode || pc >= chips[CHIP_A0_ROM].start && pc < chips[CHIP_A0_ROM].start + chips[CHIP_A0_ROM].lineSize){
|
||||
dataBufferHost = (unsigned int)palmRom;
|
||||
void flx68000PcLongJump(uint32_t newPc){
|
||||
uintptr_t dataBufferHost;
|
||||
uint32_t dataBufferGuest;
|
||||
uint32_t windowSize;
|
||||
|
||||
if(chips[CHIP_A0_ROM].inBootMode || newPc >= chips[CHIP_A0_ROM].start && newPc < chips[CHIP_A0_ROM].start + chips[CHIP_A0_ROM].lineSize){
|
||||
dataBufferHost = (uintptr_t)palmRom;
|
||||
dataBufferGuest = chips[CHIP_A0_ROM].start;
|
||||
windowSize = chips[CHIP_A0_ROM].mask + 1;
|
||||
}
|
||||
else if(pc >= chips[CHIP_DX_RAM].start && pc < chips[CHIP_DX_RAM].start + chips[CHIP_DX_RAM].lineSize){
|
||||
dataBufferHost = (unsigned int)palmRam;
|
||||
else if(newPc >= chips[CHIP_DX_RAM].start && newPc < chips[CHIP_DX_RAM].start + chips[CHIP_DX_RAM].lineSize){
|
||||
dataBufferHost = (uintptr_t)palmRam;
|
||||
dataBufferGuest = chips[CHIP_DX_RAM].start;
|
||||
windowSize = chips[CHIP_DX_RAM].mask + 1;
|
||||
}
|
||||
@@ -32,11 +34,45 @@ unsigned int checkPc(unsigned int pc){
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cycloneCpu.membase = dataBufferHost - dataBufferGuest - windowSize * ((pc - dataBufferGuest) / windowSize);
|
||||
|
||||
return cycloneCpu.membase + pc;//new program counter
|
||||
memBase = dataBufferHost - dataBufferGuest - windowSize * ((newPc - dataBufferGuest) / windowSize);
|
||||
}
|
||||
*/
|
||||
|
||||
//everything must be 16 bit aligned(accept 8 bit accesses) due to m68k unaligned access rules,
|
||||
//32 bit reads are 2 16 bit reads because on some platforms 32 bit reads that arnt on 32 bit boundrys will crash the program
|
||||
#if defined(EMU_BIG_ENDIAN)
|
||||
uint16_t m68k_read_immediate_16(uint32_t address){
|
||||
return *(uint16_t*)(memBase + address);
|
||||
}
|
||||
uint32_t m68k_read_immediate_32(uint32_t address){
|
||||
return *(uint16_t*)(memBase + address) << 16 | *(uint16_t*)(memBase + address + 2);
|
||||
}
|
||||
uint8_t m68k_read_pcrelative_8(uint32_t address){
|
||||
return *(uint8_t*)(memBase + address);
|
||||
}
|
||||
uint16_t m68k_read_pcrelative_16(uint32_t address){
|
||||
return *(uint16_t*)(memBase + address);
|
||||
}
|
||||
uint32_t m68k_read_pcrelative_32(uint32_t address){
|
||||
return *(uint16_t*)(memBase + address) << 16 | *(uint16_t*)(memBase + address + 2);
|
||||
}
|
||||
#else
|
||||
uint16_t m68k_read_immediate_16(uint32_t address){
|
||||
return *(uint16_t*)(memBase + address);
|
||||
}
|
||||
uint32_t m68k_read_immediate_32(uint32_t address){
|
||||
return *(uint16_t*)(memBase + address) << 16 | *(uint16_t*)(memBase + address + 2);
|
||||
}
|
||||
uint8_t m68k_read_pcrelative_8(uint32_t address){
|
||||
return *(uint8_t*)(memBase + (address ^ 1));
|
||||
}
|
||||
uint16_t m68k_read_pcrelative_16(uint32_t address){
|
||||
return *(uint16_t*)(memBase + address);
|
||||
}
|
||||
uint32_t m68k_read_pcrelative_32(uint32_t address){
|
||||
return *(uint16_t*)(memBase + address) << 16 | *(uint16_t*)(memBase + address + 2);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void flx68000Init(void){
|
||||
static bool inited = false;
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#define INT_SPI2 0x00000001//level 4
|
||||
|
||||
//reasons a timer is triggered
|
||||
#define TIMER_REASON_SYSCLK 0x0000
|
||||
#define TIMER_REASON_TIN 0x0001
|
||||
#define TIMER_REASON_CLK32 0x0002
|
||||
#define TIMER_REASON_SYSCLK 0x00
|
||||
#define TIMER_REASON_TIN 0x01
|
||||
#define TIMER_REASON_CLK32 0x02
|
||||
|
||||
//chip names
|
||||
enum{
|
||||
|
||||
@@ -32,6 +32,12 @@
|
||||
#ifndef M68KCONF_HEADER
|
||||
#define M68KCONF_HEADER
|
||||
|
||||
/* Function declarations.
|
||||
* Declare any callback functions used by musashi that arnt called through
|
||||
* pointers.
|
||||
*/
|
||||
#include "m68kexternal.h"
|
||||
|
||||
/* Configuration switches.
|
||||
* Use OPT_SPECIFY_HANDLER for configuration options that allow callbacks.
|
||||
* OPT_SPECIFY_HANDLER causes the core to link directly to the function
|
||||
@@ -57,7 +63,11 @@
|
||||
* and m68k_read_pcrelative_xx() for PC-relative addressing.
|
||||
* If off, all read requests from the CPU will be redirected to m68k_read_xx()
|
||||
*/
|
||||
#if !defined(EMU_NO_SAFETY)
|
||||
#define M68K_SEPARATE_READS OPT_OFF
|
||||
#else
|
||||
#define M68K_SEPARATE_READS OPT_ON
|
||||
#endif
|
||||
|
||||
/* If ON, the CPU will call m68k_write_32_pd() when it executes move.l with a
|
||||
* predecrement destination EA mode instead of m68k_write_32().
|
||||
@@ -108,8 +118,8 @@
|
||||
* large value. This allows host programs to be nicer when it comes to
|
||||
* fetching immediate data and instructions on a banked memory system.
|
||||
*/
|
||||
#define M68K_MONITOR_PC OPT_OFF
|
||||
#define M68K_SET_PC_CALLBACK(A) your_pc_changed_handler_function(A)
|
||||
#define M68K_MONITOR_PC OPT_SPECIFY_HANDLER
|
||||
#define M68K_SET_PC_CALLBACK(A) flx68000PcLongJump(A)
|
||||
|
||||
|
||||
/* If ON, CPU will call the instruction hook callback before every
|
||||
|
||||
10
src/m68k/m68kexternal.h
Executable file
10
src/m68k/m68kexternal.h
Executable file
@@ -0,0 +1,10 @@
|
||||
#ifndef M68KEXTERNAL_HEADER
|
||||
#define M68KEXTERNAL_HEADER
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int32_t interruptAcknowledge(int32_t intLevel);
|
||||
void emulatorSoftReset(void);
|
||||
void flx68000PcLongJump(uint32_t newPc);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user