mirror of
https://github.com/libretro/Mu.git
synced 2026-09-23 07:05:37 +00:00
Almost have opcodes executing in cyclone, made endianess cyclone compatible
Almost certainly broke the RetroArch build
This commit is contained in:
@@ -22,52 +22,53 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
windows {
|
||||
windows{
|
||||
RC_ICONS = windows/Mu.ico
|
||||
QMAKE_CFLAGS += -openmp
|
||||
QMAKE_CXXFLAGS += -openmp
|
||||
DEFINES += "_Pragma=__pragma"
|
||||
DEFINES += EMU_MULTITHREADED
|
||||
CONFIG += use_c_68k
|
||||
}
|
||||
|
||||
macx {
|
||||
macx{
|
||||
CONFIG += sdk_no_version_check # using 10.14 SDK which Qt only unofficialy supports
|
||||
ICON = macos/Mu.icns
|
||||
QMAKE_INFO_PLIST = macos/Info.plist
|
||||
DEFINES += EMU_MULTITHREADED
|
||||
CONFIG += use_c_68k
|
||||
}
|
||||
|
||||
linux-g++ {
|
||||
message(This really shouldent trigger yet!)
|
||||
linux-g++{
|
||||
message(This really shouldnt trigger yet!)
|
||||
QMAKE_CFLAGS += -fopenmp
|
||||
QMAKE_CXXFLAGS += -fopenmp
|
||||
QMAKE_LFLAGS += -fopenmp
|
||||
DEFINES += EMU_MULTITHREADED
|
||||
CONFIG += use_c_68k
|
||||
}
|
||||
|
||||
android {
|
||||
android{
|
||||
QMAKE_CFLAGS += -fopenmp
|
||||
QMAKE_CXXFLAGS += -fopenmp
|
||||
QMAKE_LFLAGS += -fopenmp
|
||||
DEFINES += EMU_MULTITHREADED
|
||||
CONFIG += use_arm_asm_68k # for now, later this will check if building for arm
|
||||
CONFIG += optimize_for_arm # for now, later this will check if building for ARM
|
||||
}
|
||||
|
||||
ios {
|
||||
ios{
|
||||
QMAKE_INFO_PLIST = ios/Info.plist
|
||||
DEFINES += EMU_MULTITHREADED
|
||||
CONFIG += use_arm_asm_68k
|
||||
CONFIG += optimize_for_arm
|
||||
}
|
||||
|
||||
|
||||
CONFIG(debug, debug|release){
|
||||
# debug build, be accurate and add logging
|
||||
# DEFINES += EMU_DEBUG EMU_CUSTOM_DEBUG_LOG_HANDLER
|
||||
# DEFINES += EMU_SANDBOX
|
||||
# DEFINES += EMU_SANDBOX_OPCODE_LEVEL_DEBUG
|
||||
# DEFINES += EMU_SANDBOX_LOG_APIS
|
||||
}else{
|
||||
# release build, go fast
|
||||
DEFINES += EMU_NO_SAFETY
|
||||
}
|
||||
|
||||
QMAKE_CFLAGS += -std=c99
|
||||
@@ -75,12 +76,10 @@ CONFIG += c++11
|
||||
|
||||
INCLUDEPATH += $$PWD/qt-common/include
|
||||
|
||||
use_arm_asm_68k {
|
||||
optimize_for_arm{
|
||||
SOURCES += src/m68k/cyclone/Cyclone.s
|
||||
DEFINES += EMU_OPTIMIZE_FOR_ARM
|
||||
}
|
||||
|
||||
use_c_68k {
|
||||
}else{
|
||||
SOURCES += src/m68k/musashi/m68kcpu.c \
|
||||
src/m68k/musashi/m68kdasm.c \
|
||||
src/m68k/musashi/m68kopac.c \
|
||||
@@ -126,7 +125,6 @@ HEADERS += \
|
||||
src/specs/sed1376RegisterNames.h \
|
||||
src/ads7846.h \
|
||||
src/emulator.h \
|
||||
src/endianness.h \
|
||||
src/flx68000.h \
|
||||
src/hardwareRegisters.h \
|
||||
src/hardwareRegistersAccessors.c.h \
|
||||
|
||||
@@ -153,15 +153,18 @@ uint32_t EmuWrapper::init(const QString& romPath, const QString& bootloaderPath,
|
||||
if(ramFile.exists()){
|
||||
if(ramFile.open(QFile::ReadOnly | QFile::ExistingOnly)){
|
||||
QByteArray ramData;
|
||||
buffer_t emuRam = emulatorGetRamBuffer();
|
||||
buffer_t emuRam;
|
||||
|
||||
ramData = ramFile.readAll();
|
||||
ramFile.close();
|
||||
|
||||
emuRam.data = (uint8_t*)ramData.data();
|
||||
emuRam.size = ramData.size();
|
||||
|
||||
//only copy in data if its the correct size, the file will be overwritten on exit with the devices RAM either way
|
||||
//(changing RAM size requires a factory reset for now and always will when going from 128mb back to 16mb)
|
||||
if(ramData.size() == emuRam.size)
|
||||
memcpy(emuRam.data, ramData.data(), emuRam.size);
|
||||
if(emuRam.size == emulatorGetRamSize())
|
||||
emulatorLoadRam(emuRam);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,13 +224,19 @@ void EmuWrapper::exit(){
|
||||
if(emuInited){
|
||||
if(emuRamFilePath != ""){
|
||||
QFile ramFile(emuRamFilePath);
|
||||
buffer_t emuRam = emulatorGetRamBuffer();
|
||||
buffer_t emuRam;
|
||||
emuRam.size = emulatorGetRamSize();
|
||||
emuRam.data = new uint8_t[emuRam.size];
|
||||
|
||||
emulatorSaveRam(emuRam);
|
||||
|
||||
//save out RAM before exit
|
||||
if(ramFile.open(QFile::WriteOnly | QFile::Truncate)){
|
||||
ramFile.write((const char*)emuRam.data, emuRam.size);
|
||||
ramFile.close();
|
||||
}
|
||||
|
||||
delete[] emuRam.data;
|
||||
}
|
||||
if(emuSdCardFilePath != ""){
|
||||
buffer_t emuSdCard = emulatorGetSdCardBuffer();
|
||||
|
||||
@@ -13,11 +13,11 @@ static uint16_t ads7846OutputValue;
|
||||
static bool ads7846ChipSelect;
|
||||
|
||||
|
||||
static inline double ads7846RangeMap(double oldMin, double oldMax, double value, double newMin, double newMax){
|
||||
static double ads7846RangeMap(double oldMin, double oldMax, double value, double newMin, double newMax){
|
||||
return (value - oldMin) / (oldMax - oldMin) * (newMax - newMin) + newMin;
|
||||
}
|
||||
|
||||
static inline bool ads7846GetAdcBit(){
|
||||
static bool ads7846GetAdcBit(){
|
||||
bool bit = ads7846OutputValue & 0x8000;
|
||||
ads7846OutputValue <<= 1;
|
||||
return bit;
|
||||
|
||||
@@ -87,10 +87,12 @@ uint32_t emulatorInit(buffer_t palmRomDump, buffer_t palmBootDump, uint32_t spec
|
||||
memcpy(palmRom, palmRomDump.data, uMin(palmRomDump.size, ROM_SIZE));
|
||||
if(palmRomDump.size < ROM_SIZE)
|
||||
memset(palmRom + palmRomDump.size, 0x00, ROM_SIZE - palmRomDump.size);
|
||||
swap16_buffer_if_little(palmRom, ROM_SIZE / 2);
|
||||
if(palmBootDump.data){
|
||||
memcpy(palmReg + REG_SIZE - 1 - BOOTLOADER_SIZE, palmBootDump.data, uMin(palmBootDump.size, BOOTLOADER_SIZE));
|
||||
if(palmBootDump.size < BOOTLOADER_SIZE)
|
||||
memset(palmReg + REG_SIZE - 1 - BOOTLOADER_SIZE + palmBootDump.size, 0x00, BOOTLOADER_SIZE - palmBootDump.size);
|
||||
swap16_buffer_if_little(palmReg + REG_SIZE - 1 - BOOTLOADER_SIZE, BOOTLOADER_SIZE / 2);
|
||||
}
|
||||
else{
|
||||
memset(palmReg + REG_SIZE - 1 - BOOTLOADER_SIZE, 0x00, BOOTLOADER_SIZE);
|
||||
@@ -228,13 +230,16 @@ bool emulatorSaveState(buffer_t buffer){
|
||||
//memory
|
||||
if(palmSpecialFeatures & FEATURE_RAM_HUGE){
|
||||
memcpy(buffer.data + offset, palmRam, SUPERMASSIVE_RAM_SIZE);
|
||||
swap16_buffer_if_little(buffer.data + offset, SUPERMASSIVE_RAM_SIZE / 2);
|
||||
offset += SUPERMASSIVE_RAM_SIZE;
|
||||
}
|
||||
else{
|
||||
memcpy(buffer.data + offset, palmRam, RAM_SIZE);
|
||||
swap16_buffer_if_little(buffer.data + offset, RAM_SIZE / 2);
|
||||
offset += RAM_SIZE;
|
||||
}
|
||||
memcpy(buffer.data + offset, palmReg, REG_SIZE);
|
||||
swap16_buffer_if_little(buffer.data + offset, REG_SIZE / 2);
|
||||
offset += REG_SIZE;
|
||||
memcpy(buffer.data + offset, bankType, TOTAL_MEMORY_BANKS);
|
||||
offset += TOTAL_MEMORY_BANKS;
|
||||
@@ -381,13 +386,16 @@ bool emulatorLoadState(buffer_t buffer){
|
||||
//memory
|
||||
if(palmSpecialFeatures & FEATURE_RAM_HUGE){
|
||||
memcpy(palmRam, buffer.data + offset, SUPERMASSIVE_RAM_SIZE);
|
||||
swap16_buffer_if_little(palmRam, SUPERMASSIVE_RAM_SIZE / 2);
|
||||
offset += SUPERMASSIVE_RAM_SIZE;
|
||||
}
|
||||
else{
|
||||
memcpy(palmRam, buffer.data + offset, RAM_SIZE);
|
||||
swap16_buffer_if_little(palmRam, RAM_SIZE / 2);
|
||||
offset += RAM_SIZE;
|
||||
}
|
||||
memcpy(palmReg, buffer.data + offset, REG_SIZE);
|
||||
swap16_buffer_if_little(palmReg, REG_SIZE / 2);
|
||||
offset += REG_SIZE;
|
||||
memcpy(bankType, buffer.data + offset, TOTAL_MEMORY_BANKS);
|
||||
offset += TOTAL_MEMORY_BANKS;
|
||||
@@ -505,13 +513,32 @@ bool emulatorLoadState(buffer_t buffer){
|
||||
return true;
|
||||
}
|
||||
|
||||
buffer_t emulatorGetRamBuffer(){
|
||||
buffer_t ramInfo;
|
||||
uint64_t emulatorGetRamSize(){
|
||||
return palmSpecialFeatures & FEATURE_RAM_HUGE ? SUPERMASSIVE_RAM_SIZE : RAM_SIZE;
|
||||
}
|
||||
|
||||
ramInfo.data = palmRam;
|
||||
ramInfo.size = palmSpecialFeatures & FEATURE_RAM_HUGE ? SUPERMASSIVE_RAM_SIZE : RAM_SIZE;
|
||||
bool emulatorSaveRam(buffer_t buffer){
|
||||
uint64_t size = palmSpecialFeatures & FEATURE_RAM_HUGE ? SUPERMASSIVE_RAM_SIZE : RAM_SIZE;
|
||||
|
||||
return ramInfo;
|
||||
if(buffer.size < size)
|
||||
return false;
|
||||
|
||||
memcpy(buffer.data, palmRam, size);
|
||||
swap16_buffer_if_little(buffer.data, size / 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool emulatorLoadRam(buffer_t buffer){
|
||||
uint64_t size = palmSpecialFeatures & FEATURE_RAM_HUGE ? SUPERMASSIVE_RAM_SIZE : RAM_SIZE;
|
||||
|
||||
if(buffer.size < size)
|
||||
return false;
|
||||
|
||||
memcpy(palmRam, buffer.data, size);
|
||||
swap16_buffer_if_little(palmRam, size / 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
buffer_t emulatorGetSdCardBuffer(){
|
||||
|
||||
@@ -18,6 +18,7 @@ extern "C" {
|
||||
//define EMU_MULTITHREADED to speed up long loops
|
||||
//define EMU_OPTIMIZE_FOR_ARM to use ASM CPU core
|
||||
//define EMU_NO_SAFETY to remove all safety checks
|
||||
//define EMU_BIG_ENDIAN on big endian systems
|
||||
//to enable degguging define EMU_DEBUG, all options below do nothing unless EMU_DEBUG is defined
|
||||
//to enable sandbox debugging define EMU_SANDBOX
|
||||
//to enable opcode level debugging define EMU_SANDBOX_OPCODE_LEVEL_DEBUG
|
||||
@@ -146,7 +147,9 @@ void emulatorSetRtc(uint16_t days, uint8_t hours, uint8_t minutes, uint8_t secon
|
||||
uint64_t emulatorGetStateSize();
|
||||
bool emulatorSaveState(buffer_t buffer);//true = success
|
||||
bool emulatorLoadState(buffer_t buffer);//true = success
|
||||
buffer_t emulatorGetRamBuffer();//this is a direct pointer to RAM, do not free it
|
||||
uint64_t emulatorGetRamSize();
|
||||
bool emulatorSaveRam(buffer_t buffer);//true = success
|
||||
bool emulatorLoadRam(buffer_t buffer);//true = success
|
||||
buffer_t emulatorGetSdCardBuffer();//this is a direct pointer to the SD card data, do not free it
|
||||
uint32_t emulatorInsertSdCard(buffer_t image);//use (NULL, desired size) to create a new empty SD card
|
||||
void emulatorEjectSdCard();
|
||||
|
||||
101
src/endianness.h
101
src/endianness.h
@@ -37,97 +37,22 @@
|
||||
| (((uint64_t)(val) & 0xff00000000000000ULL) >> 56))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* is_little_endian:
|
||||
*
|
||||
* Checks if the system is little endian or big-endian.
|
||||
*
|
||||
* Returns: greater than 0 if little-endian,
|
||||
* otherwise big-endian.
|
||||
**/
|
||||
#if defined(MSB_FIRST)
|
||||
#if defined(EMU_BIG_ENDIAN)
|
||||
#define is_little_endian() (0)
|
||||
#elif defined(__x86_64) || defined(__i386) || defined(_M_IX86) || defined(_M_X64) || defined(LSB_FIRST)
|
||||
#define is_little_endian() (1)
|
||||
#else
|
||||
static inline uint8_t is_little_endian(void)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint16_t x;
|
||||
uint8_t y[2];
|
||||
} u;
|
||||
|
||||
u.x = 1;
|
||||
return u.y[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* swap_if_little64:
|
||||
* @val : unsigned 64-bit value
|
||||
*
|
||||
* Byteswap unsigned 64-bit value if system is little-endian.
|
||||
*
|
||||
* Returns: Byteswapped value in case system is little-endian,
|
||||
* otherwise returns same value.
|
||||
**/
|
||||
|
||||
#if defined(MSB_FIRST)
|
||||
#define swap_if_little64(val) (val)
|
||||
#elif defined(__x86_64) || defined(__i386) || defined(_M_IX86) || defined(_M_X64) || defined(LSB_FIRST)
|
||||
#define swap_if_little64(val) (SWAP64(val))
|
||||
#else
|
||||
static inline uint64_t swap_if_little64(uint64_t val)
|
||||
{
|
||||
if (is_little_endian())
|
||||
return SWAP64(val);
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* swap_if_little32:
|
||||
* @val : unsigned 32-bit value
|
||||
*
|
||||
* Byteswap unsigned 32-bit value if system is little-endian.
|
||||
*
|
||||
* Returns: Byteswapped value in case system is little-endian,
|
||||
* otherwise returns same value.
|
||||
**/
|
||||
|
||||
#if defined(MSB_FIRST)
|
||||
#define swap_if_little32(val) (val)
|
||||
#elif defined(__x86_64) || defined(__i386) || defined(_M_IX86) || defined(_M_X64) || defined(LSB_FIRST)
|
||||
#define swap_if_little32(val) (SWAP32(val))
|
||||
#else
|
||||
static inline uint32_t swap_if_little32(uint32_t val)
|
||||
{
|
||||
if (is_little_endian())
|
||||
return SWAP32(val);
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* swap_if_little16:
|
||||
* @val : unsigned 16-bit value
|
||||
*
|
||||
* Byteswap unsigned 16-bit value if system is little-endian.
|
||||
*
|
||||
* Returns: Byteswapped value in case system is little-endian,
|
||||
* otherwise returns same value.
|
||||
**/
|
||||
|
||||
#if defined(MSB_FIRST)
|
||||
#define swap_if_little16(val) (val)
|
||||
#elif defined(__x86_64) || defined(__i386) || defined(_M_IX86) || defined(_M_X64) || defined(LSB_FIRST)
|
||||
#define swap_if_little16(val) (SWAP16(val))
|
||||
|
||||
#else
|
||||
static inline uint16_t swap_if_little16(uint16_t val)
|
||||
{
|
||||
if (is_little_endian())
|
||||
return SWAP16(val);
|
||||
return val;
|
||||
}
|
||||
#define is_little_endian() (1)
|
||||
#define swap_if_little64(val) (SWAP64(val))
|
||||
#define swap_if_little32(val) (SWAP32(val))
|
||||
#define swap_if_little16(val) (SWAP16(val))
|
||||
#endif
|
||||
|
||||
static inline void swap16_buffer_if_little(uint16_t* buffer, uint64_t count){
|
||||
#if !defined(EMU_BIG_ENDIAN)
|
||||
for(uint64_t index = 0; index < count; index++)
|
||||
buffer[index] = SWAP16(buffer[index]);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -25,20 +25,30 @@ extern void m68k_write_memory_16(unsigned int address, unsigned short value);
|
||||
extern void m68k_write_memory_32(unsigned int address, unsigned int value);
|
||||
|
||||
unsigned int checkPc(unsigned int pc){
|
||||
pc -= cycloneCpu.membase;//Get the real program counter
|
||||
unsigned int dataBuffer;
|
||||
unsigned int dataBufferAddress;
|
||||
unsigned int windowSize;
|
||||
|
||||
if(chips[CHIP_A0_ROM].inBootMode || pc >= chips[CHIP_A0_ROM].start && pc < chips[CHIP_A0_ROM].start + chips[CHIP_A0_ROM].lineSize)
|
||||
cycloneCpu.membase = (int)palmRom - (pc & ~chips[CHIP_A0_ROM].mask);
|
||||
else if(pc >= chips[CHIP_DX_RAM].start && pc < chips[CHIP_DX_RAM].start + chips[CHIP_DX_RAM].lineSize)
|
||||
cycloneCpu.membase = (int)palmRam - (pc & ~chips[CHIP_DX_RAM].mask);
|
||||
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){
|
||||
dataBuffer = (unsigned int)palmRom;
|
||||
dataBufferAddress = 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){
|
||||
dataBuffer = (unsigned int)palmRam;
|
||||
dataBufferAddress = chips[CHIP_DX_RAM].start;
|
||||
windowSize = chips[CHIP_DX_RAM].mask + 1;
|
||||
}
|
||||
else{
|
||||
//really shouldnt be executing from anywhere else
|
||||
bool breakpoint = true;
|
||||
//executing from anywhere else is not supported
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//unsigned int membse = cycloneCpu.membase;
|
||||
cycloneCpu.membase = dataBuffer - dataBufferAddress - windowSize * ((pc - dataBufferAddress) / windowSize);
|
||||
|
||||
return cycloneCpu.membase + pc;//New program counter
|
||||
return cycloneCpu.membase + pc;//new program counter
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -154,7 +164,7 @@ void flx68000SetIrq(uint8_t irqLevel){
|
||||
|
||||
void flx68000RefreshAddressing(){
|
||||
#if defined(EMU_OPTIMIZE_FOR_ARM)
|
||||
cycloneCpu.pc = cycloneCpu.checkpc(cycloneCpu.pc);
|
||||
//cycloneCpu.pc = cycloneCpu.checkpc(cycloneCpu.pc);
|
||||
#else
|
||||
//C implimentation doesnt cache address information
|
||||
#endif
|
||||
@@ -170,7 +180,7 @@ bool flx68000IsSupervisor(){
|
||||
|
||||
void flx68000BusError(uint32_t address, bool isWrite){
|
||||
#if defined(EMU_OPTIMIZE_FOR_ARM)
|
||||
//no bus error yet
|
||||
//no bus error callback
|
||||
#else
|
||||
//never call outsize of a 68k opcode, behavior is undefined due to longjmp
|
||||
m68ki_trigger_bus_error(address, isWrite ? MODE_WRITE : MODE_READ, FLAG_S | m68ki_get_address_space());
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
//declare I/O port functions in advance
|
||||
static inline uint8_t getPortAValue();
|
||||
static inline uint8_t getPortBValue();
|
||||
static inline uint8_t getPortCValue();
|
||||
static inline uint8_t getPortDValue();
|
||||
static inline uint8_t getPortEValue();
|
||||
static inline uint8_t getPortFValue();
|
||||
static inline uint8_t getPortGValue();
|
||||
static inline uint8_t getPortJValue();
|
||||
static inline uint8_t getPortKValue();
|
||||
static inline uint8_t getPortMValue();
|
||||
static uint8_t getPortAValue();
|
||||
static uint8_t getPortBValue();
|
||||
static uint8_t getPortCValue();
|
||||
static uint8_t getPortDValue();
|
||||
static uint8_t getPortEValue();
|
||||
static uint8_t getPortFValue();
|
||||
static uint8_t getPortGValue();
|
||||
static uint8_t getPortJValue();
|
||||
static uint8_t getPortKValue();
|
||||
static uint8_t getPortMValue();
|
||||
|
||||
//basic accessors
|
||||
static inline uint8_t registerArrayRead8(uint32_t address){return BUFFER_READ_8(palmReg, address, 0xFFF);}
|
||||
static inline uint16_t registerArrayRead16(uint32_t address){return BUFFER_READ_16(palmReg, address, 0xFFF);}
|
||||
static inline uint32_t registerArrayRead32(uint32_t address){return BUFFER_READ_32(palmReg, address, 0xFFF);}
|
||||
static inline void registerArrayWrite8(uint32_t address, uint8_t value){BUFFER_WRITE_8(palmReg, address, 0xFFF, value);}
|
||||
static inline void registerArrayWrite16(uint32_t address, uint16_t value){BUFFER_WRITE_16(palmReg, address, 0xFFF, value);}
|
||||
static inline void registerArrayWrite32(uint32_t address, uint32_t value){BUFFER_WRITE_32(palmReg, address, 0xFFF, value);}
|
||||
static uint8_t registerArrayRead8(uint32_t address){return BUFFER_READ_8(palmReg, address, 0xFFF);}
|
||||
static uint16_t registerArrayRead16(uint32_t address){return BUFFER_READ_16(palmReg, address, 0xFFF);}
|
||||
static uint32_t registerArrayRead32(uint32_t address){return BUFFER_READ_32(palmReg, address, 0xFFF);}
|
||||
static void registerArrayWrite8(uint32_t address, uint8_t value){BUFFER_WRITE_8(palmReg, address, 0xFFF, value);}
|
||||
static void registerArrayWrite16(uint32_t address, uint16_t value){BUFFER_WRITE_16(palmReg, address, 0xFFF, value);}
|
||||
static void registerArrayWrite32(uint32_t address, uint32_t value){BUFFER_WRITE_32(palmReg, address, 0xFFF, value);}
|
||||
|
||||
//interrupt setters
|
||||
static inline void setIprIsrBit(uint32_t interruptBit){
|
||||
static void setIprIsrBit(uint32_t interruptBit){
|
||||
//allows for setting an interrupt with masking by IMR and logging in IPR
|
||||
uint32_t newIpr = registerArrayRead32(IPR) | interruptBit;
|
||||
registerArrayWrite32(IPR, newIpr);
|
||||
registerArrayWrite32(ISR, newIpr & ~registerArrayRead32(IMR));
|
||||
}
|
||||
|
||||
static inline void clearIprIsrBit(uint32_t interruptBit){
|
||||
static void clearIprIsrBit(uint32_t interruptBit){
|
||||
uint32_t newIpr = registerArrayRead32(IPR) & ~interruptBit;
|
||||
registerArrayWrite32(IPR, newIpr);
|
||||
registerArrayWrite32(ISR, newIpr & ~registerArrayRead32(IMR));
|
||||
}
|
||||
|
||||
//SPI1 FIFO accessors
|
||||
static inline uint16_t spi1RxFifoRead(){
|
||||
static uint16_t spi1RxFifoRead(){
|
||||
uint16_t value = spi1RxFifo[spi1RxReadPosition];
|
||||
spi1RxReadPosition = (spi1RxReadPosition + 1) % 9;
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline void spi1RxFifoWrite(uint16_t value){
|
||||
static void spi1RxFifoWrite(uint16_t value){
|
||||
spi1RxFifo[spi1RxWritePosition] = value;
|
||||
spi1RxWritePosition = (spi1RxWritePosition + 1) % 9;
|
||||
}
|
||||
|
||||
static inline uint8_t spi1RxFifoEntrys(){
|
||||
static uint8_t spi1RxFifoEntrys(){
|
||||
//check for wraparound
|
||||
if(spi1RxWritePosition < spi1RxReadPosition)
|
||||
return spi1RxWritePosition + 9 - spi1RxReadPosition;
|
||||
return spi1RxWritePosition - spi1RxReadPosition;
|
||||
}
|
||||
|
||||
static inline uint16_t spi1TxFifoRead(){
|
||||
static uint16_t spi1TxFifoRead(){
|
||||
uint16_t value = spi1TxFifo[spi1TxReadPosition];
|
||||
spi1TxReadPosition = (spi1TxReadPosition + 1) % 9;
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline void spi1TxFifoWrite(uint16_t value){
|
||||
static void spi1TxFifoWrite(uint16_t value){
|
||||
spi1TxFifo[spi1TxWritePosition] = value;
|
||||
spi1TxWritePosition = (spi1TxWritePosition + 1) % 9;
|
||||
}
|
||||
|
||||
static inline uint8_t spi1TxFifoEntrys(){
|
||||
static uint8_t spi1TxFifoEntrys(){
|
||||
//check for wraparound
|
||||
if(spi1TxWritePosition < spi1TxReadPosition)
|
||||
return spi1TxWritePosition + 9 - spi1TxReadPosition;
|
||||
@@ -70,7 +70,7 @@ static inline uint8_t spi1TxFifoEntrys(){
|
||||
}
|
||||
|
||||
//PWM1 FIFO accessors
|
||||
static inline uint8_t pwm1FifoEntrys(){
|
||||
static uint8_t pwm1FifoEntrys(){
|
||||
//check for wraparound
|
||||
if(pwm1WritePosition < pwm1ReadPosition)
|
||||
return pwm1WritePosition + 6 - pwm1ReadPosition;
|
||||
@@ -115,20 +115,20 @@ int32_t pwm1FifoRunSample(int32_t now, int32_t clockOffset){
|
||||
return audioSampleDuration * repeat;
|
||||
}
|
||||
|
||||
static inline void pwm1FifoWrite(uint8_t value){
|
||||
static void pwm1FifoWrite(uint8_t value){
|
||||
if(pwm1FifoEntrys() < 5){
|
||||
pwm1Fifo[pwm1WritePosition] = value;
|
||||
pwm1WritePosition = (pwm1WritePosition + 1) % 6;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void pwm1FifoFlush(){
|
||||
static void pwm1FifoFlush(){
|
||||
pwm1ReadPosition = 0;
|
||||
pwm1WritePosition = 0;
|
||||
}
|
||||
|
||||
//register setters
|
||||
static inline void setCsa(uint16_t value){
|
||||
static void setCsa(uint16_t value){
|
||||
chips[CHIP_A0_ROM].enable = value & 0x0001;
|
||||
chips[CHIP_A0_ROM].readOnly = value & 0x8000;
|
||||
chips[CHIP_A0_ROM].lineSize = 0x20000/*128kb*/ << (value >> 1 & 0x0007);
|
||||
@@ -145,7 +145,7 @@ static inline void setCsa(uint16_t value){
|
||||
registerArrayWrite16(CSA, value & 0x81FF);
|
||||
}
|
||||
|
||||
static inline void setCsb(uint16_t value){
|
||||
static void setCsb(uint16_t value){
|
||||
uint16_t csControl1 = registerArrayRead16(CSCTRL1);
|
||||
|
||||
chips[CHIP_B0_SED].enable = value & 0x0001;
|
||||
@@ -163,7 +163,7 @@ static inline void setCsb(uint16_t value){
|
||||
registerArrayWrite16(CSB, value & 0xF9FF);
|
||||
}
|
||||
|
||||
static inline void setCsd(uint16_t value){
|
||||
static void setCsd(uint16_t value){
|
||||
uint16_t csControl1 = registerArrayRead16(CSCTRL1);
|
||||
|
||||
chips[CHIP_DX_RAM].enable = value & 0x0001;
|
||||
@@ -184,7 +184,7 @@ static inline void setCsd(uint16_t value){
|
||||
registerArrayWrite16(CSD, value);
|
||||
}
|
||||
|
||||
static inline void setCsgba(uint16_t value){
|
||||
static void setCsgba(uint16_t value){
|
||||
uint16_t csugba = registerArrayRead16(CSUGBA);
|
||||
|
||||
//add extra address bits if enabled
|
||||
@@ -198,7 +198,7 @@ static inline void setCsgba(uint16_t value){
|
||||
registerArrayWrite16(CSGBA, value & 0xFFFE);
|
||||
}
|
||||
|
||||
static inline void setCsgbb(uint16_t value){
|
||||
static void setCsgbb(uint16_t value){
|
||||
uint16_t csugba = registerArrayRead16(CSUGBA);
|
||||
|
||||
//add extra address bits if enabled
|
||||
@@ -210,7 +210,7 @@ static inline void setCsgbb(uint16_t value){
|
||||
registerArrayWrite16(CSGBB, value & 0xFFFE);
|
||||
}
|
||||
|
||||
static inline void setCsgbd(uint16_t value){
|
||||
static void setCsgbd(uint16_t value){
|
||||
uint16_t csugba = registerArrayRead16(CSUGBA);
|
||||
|
||||
//add extra address bits if enabled
|
||||
@@ -222,7 +222,7 @@ static inline void setCsgbd(uint16_t value){
|
||||
registerArrayWrite16(CSGBD, value & 0xFFFE);
|
||||
}
|
||||
|
||||
static inline void updateCsdAddressLines(){
|
||||
static void updateCsdAddressLines(){
|
||||
uint16_t dramc = registerArrayRead16(DRAMC);
|
||||
uint16_t sdctrl = registerArrayRead16(SDCTRL);
|
||||
|
||||
@@ -244,7 +244,7 @@ static inline void updateCsdAddressLines(){
|
||||
}
|
||||
}
|
||||
|
||||
static inline void setPllfsr(uint16_t value){
|
||||
static void setPllfsr(uint16_t value){
|
||||
uint16_t oldPllfsr = registerArrayRead16(PLLFSR);
|
||||
if(!(oldPllfsr & 0x4000)){
|
||||
//frequency protect bit not set
|
||||
@@ -253,7 +253,7 @@ static inline void setPllfsr(uint16_t value){
|
||||
}
|
||||
}
|
||||
|
||||
static inline void setScr(uint8_t value){
|
||||
static void setScr(uint8_t value){
|
||||
uint8_t oldScr = registerArrayRead8(SCR);
|
||||
uint8_t newScr = value & 0x1F;
|
||||
|
||||
@@ -274,7 +274,7 @@ static inline void setScr(uint8_t value){
|
||||
}
|
||||
}
|
||||
|
||||
static inline void setIlcr(uint16_t value){
|
||||
static void setIlcr(uint16_t value){
|
||||
uint16_t oldIlcr = registerArrayRead16(ILCR);
|
||||
uint16_t newIlcr = 0;
|
||||
|
||||
@@ -305,7 +305,7 @@ static inline void setIlcr(uint16_t value){
|
||||
registerArrayWrite16(ILCR, newIlcr);
|
||||
}
|
||||
|
||||
static inline void setSpiCont1(uint16_t value){
|
||||
static void setSpiCont1(uint16_t value){
|
||||
//only master mode is implemented!!!
|
||||
uint16_t oldSpiCont1 = registerArrayRead16(SPICONT1);
|
||||
|
||||
@@ -346,7 +346,7 @@ static inline void setSpiCont1(uint16_t value){
|
||||
registerArrayWrite16(SPICONT1, value);
|
||||
}
|
||||
|
||||
static inline void setSpiCont2(uint16_t value){
|
||||
static void setSpiCont2(uint16_t value){
|
||||
//the ENABLE bit must be set before the transfer and in the transfer command
|
||||
//important bits are ENABLE, XCH, IRQ, IRQEN and BITCOUNT
|
||||
uint16_t oldSpiCont2 = registerArrayRead16(SPICONT2);
|
||||
@@ -401,7 +401,7 @@ static inline void setSpiCont2(uint16_t value){
|
||||
registerArrayWrite16(SPICONT2, value & 0xE3FF);
|
||||
}
|
||||
|
||||
static inline void setTstat1(uint16_t value){
|
||||
static void setTstat1(uint16_t value){
|
||||
uint16_t oldTstat1 = registerArrayRead16(TSTAT1);
|
||||
uint16_t newTstat1 = (value & timerStatusReadAcknowledge[0]) | (oldTstat1 & ~timerStatusReadAcknowledge[0]);
|
||||
|
||||
@@ -416,7 +416,7 @@ static inline void setTstat1(uint16_t value){
|
||||
registerArrayWrite16(TSTAT1, newTstat1);
|
||||
}
|
||||
|
||||
static inline void setTstat2(uint16_t value){
|
||||
static void setTstat2(uint16_t value){
|
||||
uint16_t oldTstat2 = registerArrayRead16(TSTAT2);
|
||||
uint16_t newTstat2 = (value & timerStatusReadAcknowledge[1]) | (oldTstat2 & ~timerStatusReadAcknowledge[1]);
|
||||
|
||||
@@ -431,7 +431,7 @@ static inline void setTstat2(uint16_t value){
|
||||
registerArrayWrite16(TSTAT2, newTstat2);
|
||||
}
|
||||
|
||||
static inline void setPwmc1(uint16_t value){
|
||||
static void setPwmc1(uint16_t value){
|
||||
uint16_t oldPwmc1 = registerArrayRead16(PWMC1);
|
||||
|
||||
//dont allow manually setting FIFOAV
|
||||
@@ -465,7 +465,7 @@ static inline void setPwmc1(uint16_t value){
|
||||
registerArrayWrite16(PWMC1, value);
|
||||
}
|
||||
|
||||
static inline void setIsr(uint32_t value, bool useTopWord, bool useBottomWord){
|
||||
static void setIsr(uint32_t value, bool useTopWord, bool useBottomWord){
|
||||
//Palm OS uses this 32 bit register as 2 16 bit registers
|
||||
|
||||
//prevent any internal hardware interrupts from being cleared
|
||||
@@ -508,7 +508,7 @@ static inline void setIsr(uint32_t value, bool useTopWord, bool useBottomWord){
|
||||
}
|
||||
|
||||
//register getters
|
||||
static inline uint8_t getPortDInputPinValues(){
|
||||
static uint8_t getPortDInputPinValues(){
|
||||
uint8_t requestedRow = ~getPortKValue();
|
||||
uint8_t portDInputValues = 0x00;
|
||||
|
||||
@@ -533,21 +533,21 @@ static inline uint8_t getPortDInputPinValues(){
|
||||
return ~portDInputValues;
|
||||
}
|
||||
|
||||
static inline uint8_t getPortAValue(){
|
||||
static uint8_t getPortAValue(){
|
||||
//not attached, used as data lines
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
static inline uint8_t getPortBValue(){
|
||||
static uint8_t getPortBValue(){
|
||||
return ((registerArrayRead8(PBDATA) & registerArrayRead8(PBDIR)) | ~registerArrayRead8(PBDIR)) & registerArrayRead8(PBSEL);
|
||||
}
|
||||
|
||||
static inline uint8_t getPortCValue(){
|
||||
static uint8_t getPortCValue(){
|
||||
//port c uses pull downs not pull ups
|
||||
return registerArrayRead8(PCDATA) & registerArrayRead8(PCDIR) & registerArrayRead8(PCSEL);
|
||||
}
|
||||
|
||||
static inline uint8_t getPortDValue(){
|
||||
static uint8_t getPortDValue(){
|
||||
uint8_t portDValue = getPortDInputPinValues();
|
||||
uint8_t portDData = registerArrayRead8(PDDATA);
|
||||
uint8_t portDDir = registerArrayRead8(PDDIR);
|
||||
@@ -560,11 +560,11 @@ static inline uint8_t getPortDValue(){
|
||||
return portDValue;
|
||||
}
|
||||
|
||||
static inline uint8_t getPortEValue(){
|
||||
static uint8_t getPortEValue(){
|
||||
return ((registerArrayRead8(PEDATA) & registerArrayRead8(PEDIR)) | ~registerArrayRead8(PEDIR)) & registerArrayRead8(PESEL);
|
||||
}
|
||||
|
||||
static inline uint8_t getPortFValue(){
|
||||
static uint8_t getPortFValue(){
|
||||
uint8_t portFValue = 0x00;
|
||||
uint8_t portFData = registerArrayRead8(PKDATA);
|
||||
uint8_t portFDir = registerArrayRead8(PKDIR);
|
||||
@@ -579,7 +579,7 @@ static inline uint8_t getPortFValue(){
|
||||
return portFValue;
|
||||
}
|
||||
|
||||
static inline uint8_t getPortGValue(){
|
||||
static uint8_t getPortGValue(){
|
||||
//port g only has 6 pins not 8
|
||||
uint8_t portGValue = 0x00;
|
||||
uint8_t portGData = registerArrayRead8(PGDATA);
|
||||
@@ -594,11 +594,11 @@ static inline uint8_t getPortGValue(){
|
||||
return portGValue;
|
||||
}
|
||||
|
||||
static inline uint8_t getPortJValue(){
|
||||
static uint8_t getPortJValue(){
|
||||
return ((registerArrayRead8(PJDATA) & registerArrayRead8(PJDIR)) | ~registerArrayRead8(PJDIR)) & registerArrayRead8(PJSEL);
|
||||
}
|
||||
|
||||
static inline uint8_t getPortKValue(){
|
||||
static uint8_t getPortKValue(){
|
||||
uint8_t portKValue = 0x00;
|
||||
uint8_t portKData = registerArrayRead8(PKDATA);
|
||||
uint8_t portKDir = registerArrayRead8(PKDIR);
|
||||
@@ -612,12 +612,12 @@ static inline uint8_t getPortKValue(){
|
||||
return portKValue;
|
||||
}
|
||||
|
||||
static inline uint8_t getPortMValue(){
|
||||
static uint8_t getPortMValue(){
|
||||
//bit 5 has a pull up not pull down, bits 4-0 have a pull down, bit 7-6 are not active at all
|
||||
return ((registerArrayRead8(PMDATA) & registerArrayRead8(PMDIR)) | (~registerArrayRead8(PMDIR) & 0x20)) & registerArrayRead8(PMSEL);
|
||||
}
|
||||
|
||||
static inline void samplePwm1(bool forClk32, double sysclks){
|
||||
static void samplePwm1(bool forClk32, double sysclks){
|
||||
//clear PWM1 FIFO values if enough time has passed
|
||||
uint16_t pwmc1 = registerArrayRead16(PWMC1);
|
||||
int32_t audioNow;
|
||||
@@ -677,7 +677,7 @@ static inline void samplePwm1(bool forClk32, double sysclks){
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint16_t getPwmc1(){
|
||||
static uint16_t getPwmc1(){
|
||||
uint16_t returnValue = registerArrayRead16(PWMC1);
|
||||
|
||||
//have FIFOAV set if a slot is available
|
||||
@@ -698,23 +698,23 @@ static inline uint16_t getPwmc1(){
|
||||
}
|
||||
|
||||
//updaters
|
||||
static inline void updatePowerButtonLedStatus(){
|
||||
static void updatePowerButtonLedStatus(){
|
||||
palmMisc.powerButtonLed = (bool)(getPortBValue() & 0x40) != palmMisc.batteryCharging;
|
||||
}
|
||||
|
||||
static inline void updateVibratorStatus(){
|
||||
static void updateVibratorStatus(){
|
||||
palmMisc.vibratorOn = getPortKValue() & 0x10;
|
||||
}
|
||||
|
||||
static inline void updateAds7846ChipSelectStatus(){
|
||||
static void updateAds7846ChipSelectStatus(){
|
||||
ads7846SetChipSelect(getPortGValue() & 0x04);
|
||||
}
|
||||
|
||||
static inline void updateBacklightAmplifierStatus(){
|
||||
static void updateBacklightAmplifierStatus(){
|
||||
palmMisc.backlightLevel = (palmMisc.backlightLevel > 0) ? (1 + backlightAmplifierState()) : 0;
|
||||
}
|
||||
|
||||
static inline void updateTouchState(){
|
||||
static void updateTouchState(){
|
||||
if(!(registerArrayRead8(PFSEL) & 0x02)){
|
||||
uint16_t icr = registerArrayRead16(ICR);
|
||||
bool penIrqPin = !(ads7846PenIrqEnabled && palmInput.touchscreenTouched);//penIrqPin pulled low on touch
|
||||
|
||||
@@ -165,7 +165,7 @@ static double sysclksPerClk32(){
|
||||
return dmaclksPerClk32() / (2 << sysclkSelect);
|
||||
}
|
||||
|
||||
static inline void rtiInterruptClk32(){
|
||||
static void rtiInterruptClk32(){
|
||||
//this function is part of endClk32();
|
||||
uint16_t triggeredRtiInterrupts = 0x0000;
|
||||
|
||||
@@ -209,7 +209,7 @@ static inline void rtiInterruptClk32(){
|
||||
}
|
||||
}
|
||||
|
||||
static inline void watchdogSecondTickClk32(){
|
||||
static void watchdogSecondTickClk32(){
|
||||
//this function is part of endClk32();
|
||||
uint16_t watchdogState = registerArrayRead16(WATCHDOG);
|
||||
|
||||
@@ -234,7 +234,7 @@ static inline void watchdogSecondTickClk32(){
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rtcAddSecondClk32(){
|
||||
static void rtcAddSecondClk32(){
|
||||
//this function is part of endClk32();
|
||||
if(registerArrayRead16(RTCCTL) & 0x0080){
|
||||
//RTC enable bit set
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,63 +14,63 @@ uint8_t bankType[TOTAL_MEMORY_BANKS];
|
||||
|
||||
|
||||
//RAM accesses
|
||||
static inline uint8_t ramRead8(uint32_t address){return BUFFER_READ_8(palmRam, address, chips[CHIP_DX_RAM].mask);}
|
||||
static inline uint16_t ramRead16(uint32_t address){return BUFFER_READ_16(palmRam, address, chips[CHIP_DX_RAM].mask);}
|
||||
static inline uint32_t ramRead32(uint32_t address){return BUFFER_READ_32(palmRam, address, chips[CHIP_DX_RAM].mask);}
|
||||
static inline void ramWrite8(uint32_t address, uint8_t value){BUFFER_WRITE_8(palmRam, address, chips[CHIP_DX_RAM].mask, value);}
|
||||
static inline void ramWrite16(uint32_t address, uint16_t value){BUFFER_WRITE_16(palmRam, address, chips[CHIP_DX_RAM].mask, value);}
|
||||
static inline void ramWrite32(uint32_t address, uint32_t value){BUFFER_WRITE_32(palmRam, address, chips[CHIP_DX_RAM].mask, value);}
|
||||
static uint8_t ramRead8(uint32_t address){return BUFFER_READ_8(palmRam, address, chips[CHIP_DX_RAM].mask);}
|
||||
static uint16_t ramRead16(uint32_t address){return BUFFER_READ_16(palmRam, address, chips[CHIP_DX_RAM].mask);}
|
||||
static uint32_t ramRead32(uint32_t address){return BUFFER_READ_32(palmRam, address, chips[CHIP_DX_RAM].mask);}
|
||||
static void ramWrite8(uint32_t address, uint8_t value){BUFFER_WRITE_8(palmRam, address, chips[CHIP_DX_RAM].mask, value);}
|
||||
static void ramWrite16(uint32_t address, uint16_t value){BUFFER_WRITE_16(palmRam, address, chips[CHIP_DX_RAM].mask, value);}
|
||||
static void ramWrite32(uint32_t address, uint32_t value){BUFFER_WRITE_32(palmRam, address, chips[CHIP_DX_RAM].mask, value);}
|
||||
|
||||
//ROM accesses
|
||||
static inline uint8_t romRead8(uint32_t address){return BUFFER_READ_8(palmRom, address, chips[CHIP_A0_ROM].mask);}
|
||||
static inline uint16_t romRead16(uint32_t address){return BUFFER_READ_16(palmRom, address, chips[CHIP_A0_ROM].mask);}
|
||||
static inline uint32_t romRead32(uint32_t address){return BUFFER_READ_32(palmRom, address, chips[CHIP_A0_ROM].mask);}
|
||||
static uint8_t romRead8(uint32_t address){return BUFFER_READ_8(palmRom, address, chips[CHIP_A0_ROM].mask);}
|
||||
static uint16_t romRead16(uint32_t address){return BUFFER_READ_16(palmRom, address, chips[CHIP_A0_ROM].mask);}
|
||||
static uint32_t romRead32(uint32_t address){return BUFFER_READ_32(palmRom, address, chips[CHIP_A0_ROM].mask);}
|
||||
|
||||
//SED1376 accesses
|
||||
static inline uint8_t sed1376Read8(uint32_t address){
|
||||
static uint8_t sed1376Read8(uint32_t address){
|
||||
if(sed1376PowerSaveEnabled())
|
||||
return 0x00;
|
||||
if(address & SED1376_MR_BIT)
|
||||
return BUFFER_READ_8(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask);
|
||||
return BUFFER_READ_8_ENDIANLESS(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask);
|
||||
else
|
||||
return sed1376GetRegister(address & chips[CHIP_B0_SED].mask);
|
||||
}
|
||||
static inline uint16_t sed1376Read16(uint32_t address){
|
||||
static uint16_t sed1376Read16(uint32_t address){
|
||||
if(sed1376PowerSaveEnabled())
|
||||
return 0x0000;
|
||||
if(address & SED1376_MR_BIT)
|
||||
return BUFFER_READ_16(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask);
|
||||
return BUFFER_READ_16_ENDIANLESS(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask);
|
||||
else
|
||||
return sed1376GetRegister(address & chips[CHIP_B0_SED].mask);
|
||||
}
|
||||
static inline uint32_t sed1376Read32(uint32_t address){
|
||||
static uint32_t sed1376Read32(uint32_t address){
|
||||
if(sed1376PowerSaveEnabled())
|
||||
return 0x00000000;
|
||||
if(address & SED1376_MR_BIT)
|
||||
return BUFFER_READ_32(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask);
|
||||
return BUFFER_READ_32_ENDIANLESS(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask);
|
||||
else
|
||||
return sed1376GetRegister(address & chips[CHIP_B0_SED].mask);
|
||||
}
|
||||
static inline void sed1376Write8(uint32_t address, uint8_t value){
|
||||
static void sed1376Write8(uint32_t address, uint8_t value){
|
||||
if(address & SED1376_MR_BIT)
|
||||
BUFFER_WRITE_8(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask, value);
|
||||
BUFFER_WRITE_8_ENDIANLESS(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask, value);
|
||||
else
|
||||
sed1376SetRegister(address & chips[CHIP_B0_SED].mask, value);
|
||||
}
|
||||
static inline void sed1376Write16(uint32_t address, uint16_t value){
|
||||
static void sed1376Write16(uint32_t address, uint16_t value){
|
||||
if(address & SED1376_MR_BIT)
|
||||
BUFFER_WRITE_16(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask, value);
|
||||
BUFFER_WRITE_16_ENDIANLESS(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask, value);
|
||||
else
|
||||
sed1376SetRegister(address & chips[CHIP_B0_SED].mask, value);
|
||||
}
|
||||
static inline void sed1376Write32(uint32_t address, uint32_t value){
|
||||
static void sed1376Write32(uint32_t address, uint32_t value){
|
||||
if(address & SED1376_MR_BIT)
|
||||
BUFFER_WRITE_32(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask, value);
|
||||
BUFFER_WRITE_32_ENDIANLESS(sed1376Framebuffer, address, chips[CHIP_B0_SED].mask, value);
|
||||
else
|
||||
sed1376SetRegister(address & chips[CHIP_B0_SED].mask, value);
|
||||
}
|
||||
|
||||
static inline bool probeRead(uint8_t bank, uint32_t address){
|
||||
static bool probeRead(uint8_t bank, uint32_t address){
|
||||
if(chips[bank].supervisorOnlyProtectedMemory){
|
||||
uint32_t index = address - chips[bank].start;
|
||||
if(index >= chips[bank].unprotectedSize && !flx68000IsSupervisor()){
|
||||
@@ -81,7 +81,7 @@ static inline bool probeRead(uint8_t bank, uint32_t address){
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool probeWrite(uint8_t bank, uint32_t address){
|
||||
static bool probeWrite(uint8_t bank, uint32_t address){
|
||||
if(chips[bank].readOnly){
|
||||
setWriteProtectViolation(address);
|
||||
return false;
|
||||
|
||||
@@ -27,12 +27,29 @@
|
||||
#define SED1376_MR_BIT 0x20000
|
||||
|
||||
//the read/write stuff looks messy here but makes the memory access functions alot cleaner
|
||||
#define BUFFER_READ_8(segment, accessAddress, mask) segment[(accessAddress) & (mask)]
|
||||
#define BUFFER_READ_16(segment, accessAddress, mask) (segment[(accessAddress) & (mask)] << 8 | segment[(accessAddress) + 1 & (mask)])
|
||||
#define BUFFER_READ_32(segment, accessAddress, mask) (segment[(accessAddress) & (mask)] << 24 | segment[(accessAddress) + 1 & (mask)] << 16 | segment[(accessAddress) + 2 & (mask)] << 8 | segment[(accessAddress) + 3 & (mask)])
|
||||
#define BUFFER_WRITE_8(segment, accessAddress, mask, value) segment[(accessAddress) & (mask)] = (value)
|
||||
#define BUFFER_WRITE_16(segment, accessAddress, mask, value) (segment[(accessAddress) & (mask)] = (value) >> 8, segment[(accessAddress) + 1 & (mask)] = (value) & 0xFF)
|
||||
#define BUFFER_WRITE_32(segment, accessAddress, mask, value) (segment[(accessAddress) & (mask)] = (value) >> 24, segment[(accessAddress) + 1 & (mask)] = ((value) >> 16) & 0xFF, segment[(accessAddress) + 2 & (mask)] = ((value) >> 8) & 0xFF, segment[(accessAddress) + 3 & (mask)] = (value) & 0xFF)
|
||||
#if defined(EMU_BIG_ENDIAN)
|
||||
#define BUFFER_READ_8(segment, accessAddress, mask) (*(uint8_t*)(segment + ((accessAddress) & (mask))))
|
||||
#define BUFFER_READ_16(segment, accessAddress, mask) (*(uint16_t*)(segment + ((accessAddress) & (mask))))
|
||||
#define BUFFER_READ_32(segment, accessAddress, mask) (*(uint32_t*)(segment + ((accessAddress) & (mask))))
|
||||
#define BUFFER_WRITE_8(segment, accessAddress, mask, value) (*(uint8_t*)(segment + ((accessAddress) & (mask))) = (value))
|
||||
#define BUFFER_WRITE_16(segment, accessAddress, mask, value) (*(uint16_t*)(segment + ((accessAddress) & (mask))) = (value))
|
||||
#define BUFFER_WRITE_32(segment, accessAddress, mask, value) (*(uint32_t*)(segment + ((accessAddress) & (mask))) = (value))
|
||||
#else
|
||||
//optimize for opcode fetches(16 bit reads)
|
||||
#define BUFFER_READ_8(segment, accessAddress, mask) (*(uint8_t*)(segment + ((accessAddress) & (mask) ^ 1)))
|
||||
#define BUFFER_READ_16(segment, accessAddress, mask) (*(uint16_t*)(segment + ((accessAddress) & (mask))))
|
||||
#define BUFFER_READ_32(segment, accessAddress, mask) (*(uint16_t*)(segment + ((accessAddress) & (mask))) << 16 | *(uint16_t*)(segment + ((accessAddress) + 2 & (mask))))
|
||||
#define BUFFER_WRITE_8(segment, accessAddress, mask, value) (*(uint8_t*)(segment + ((accessAddress) & (mask) ^ 1)) = (value))
|
||||
#define BUFFER_WRITE_16(segment, accessAddress, mask, value) (*(uint16_t*)(segment + ((accessAddress) & (mask))) = (value))
|
||||
#define BUFFER_WRITE_32(segment, accessAddress, mask, value) (*(uint16_t*)(segment + ((accessAddress) & (mask))) = (value) >> 16 , *(uint16_t*)(segment + ((accessAddress) + 2 & (mask))) = (value) & 0xFFFF)
|
||||
#endif
|
||||
|
||||
#define BUFFER_READ_8_ENDIANLESS(segment, accessAddress, mask) segment[(accessAddress) & (mask)]
|
||||
#define BUFFER_READ_16_ENDIANLESS(segment, accessAddress, mask) (segment[(accessAddress) & (mask)] << 8 | segment[(accessAddress) + 1 & (mask)])
|
||||
#define BUFFER_READ_32_ENDIANLESS(segment, accessAddress, mask) (segment[(accessAddress) & (mask)] << 24 | segment[(accessAddress) + 1 & (mask)] << 16 | segment[(accessAddress) + 2 & (mask)] << 8 | segment[(accessAddress) + 3 & (mask)])
|
||||
#define BUFFER_WRITE_8_ENDIANLESS(segment, accessAddress, mask, value) segment[(accessAddress) & (mask)] = (value)
|
||||
#define BUFFER_WRITE_16_ENDIANLESS(segment, accessAddress, mask, value) (segment[(accessAddress) & (mask)] = (value) >> 8, segment[(accessAddress) + 1 & (mask)] = (value) & 0xFF)
|
||||
#define BUFFER_WRITE_32_ENDIANLESS(segment, accessAddress, mask, value) (segment[(accessAddress) & (mask)] = (value) >> 24, segment[(accessAddress) + 1 & (mask)] = ((value) >> 16) & 0xFF, segment[(accessAddress) + 2 & (mask)] = ((value) >> 8) & 0xFF, segment[(accessAddress) + 3 & (mask)] = (value) & 0xFF)
|
||||
|
||||
extern uint8_t bankType[];
|
||||
|
||||
|
||||
@@ -19,18 +19,18 @@ static uint8_t pdiUsbD12ReadIndex;
|
||||
static uint8_t pdiUsbD12WriteIndex;
|
||||
|
||||
|
||||
static inline uint8_t pdiUsbD12FifoRead(){
|
||||
static uint8_t pdiUsbD12FifoRead(){
|
||||
uint8_t value = pdiUsbD12FifoBuffer[pdiUsbD12ReadIndex];
|
||||
pdiUsbD12ReadIndex = (pdiUsbD12ReadIndex + 1) % PDIUSBD12_TRANSFER_BUFFER_SIZE;
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline void pdiUsbD12FifoWrite(uint8_t value){
|
||||
static void pdiUsbD12FifoWrite(uint8_t value){
|
||||
pdiUsbD12FifoBuffer[pdiUsbD12WriteIndex] = value;
|
||||
pdiUsbD12WriteIndex = (pdiUsbD12WriteIndex + 1) % PDIUSBD12_TRANSFER_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
static inline void pdiUsbD12FifoStartNewCommand(){
|
||||
static void pdiUsbD12FifoStartNewCommand(){
|
||||
pdiUsbD12ReadIndex = 0;
|
||||
pdiUsbD12WriteIndex = 0;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,60 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "endianness.h"
|
||||
|
||||
//endian
|
||||
#define SWAP16(x) ((uint16_t)( \
|
||||
(((uint16_t)(x) & 0x00ff) << 8) | \
|
||||
(((uint16_t)(x) & 0xff00) >> 8) \
|
||||
))
|
||||
#define SWAP32(x) ((uint32_t)( \
|
||||
(((uint32_t)(x) & 0x000000ff) << 24) | \
|
||||
(((uint32_t)(x) & 0x0000ff00) << 8) | \
|
||||
(((uint32_t)(x) & 0x00ff0000) >> 8) | \
|
||||
(((uint32_t)(x) & 0xff000000) >> 24) \
|
||||
))
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1200
|
||||
#define SWAP64(val) \
|
||||
((((uint64_t)(val) & 0x00000000000000ff) << 56) \
|
||||
| (((uint64_t)(val) & 0x000000000000ff00) << 40) \
|
||||
| (((uint64_t)(val) & 0x0000000000ff0000) << 24) \
|
||||
| (((uint64_t)(val) & 0x00000000ff000000) << 8) \
|
||||
| (((uint64_t)(val) & 0x000000ff00000000) >> 8) \
|
||||
| (((uint64_t)(val) & 0x0000ff0000000000) >> 24) \
|
||||
| (((uint64_t)(val) & 0x00ff000000000000) >> 40) \
|
||||
| (((uint64_t)(val) & 0xff00000000000000) >> 56))
|
||||
#else
|
||||
#define SWAP64(val) \
|
||||
((((uint64_t)(val) & 0x00000000000000ffULL) << 56) \
|
||||
| (((uint64_t)(val) & 0x000000000000ff00ULL) << 40) \
|
||||
| (((uint64_t)(val) & 0x0000000000ff0000ULL) << 24) \
|
||||
| (((uint64_t)(val) & 0x00000000ff000000ULL) << 8) \
|
||||
| (((uint64_t)(val) & 0x000000ff00000000ULL) >> 8) \
|
||||
| (((uint64_t)(val) & 0x0000ff0000000000ULL) >> 24) \
|
||||
| (((uint64_t)(val) & 0x00ff000000000000ULL) >> 40) \
|
||||
| (((uint64_t)(val) & 0xff00000000000000ULL) >> 56))
|
||||
#endif
|
||||
|
||||
#if defined(EMU_BIG_ENDIAN)
|
||||
#define is_little_endian() (0)
|
||||
#define swap_if_little64(val) (val)
|
||||
#define swap_if_little32(val) (val)
|
||||
#define swap_if_little16(val) (val)
|
||||
|
||||
#else
|
||||
#define is_little_endian() (1)
|
||||
#define swap_if_little64(val) (SWAP64(val))
|
||||
#define swap_if_little32(val) (SWAP32(val))
|
||||
#define swap_if_little16(val) (SWAP16(val))
|
||||
#endif
|
||||
|
||||
static inline void swap16_buffer_if_little(uint16_t* buffer, uint64_t count){
|
||||
#if !defined(EMU_BIG_ENDIAN)
|
||||
for(uint64_t index = 0; index < count; index++)
|
||||
buffer[index] = SWAP16(buffer[index]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//threads
|
||||
|
||||
@@ -42,7 +42,7 @@ static uint16_t (*renderPixel)(uint16_t x, uint16_t y);
|
||||
|
||||
#include "sed1376Accessors.c.h"
|
||||
|
||||
static inline uint32_t getBufferStartAddress(){
|
||||
static uint32_t getBufferStartAddress(){
|
||||
uint32_t screenStartAddress = sed1376Registers[DISP_ADDR_2] << 16 | sed1376Registers[DISP_ADDR_1] << 8 | sed1376Registers[DISP_ADDR_0];
|
||||
switch((sed1376Registers[SPECIAL_EFFECT] & 0x03) * 90){
|
||||
case 0:
|
||||
@@ -74,7 +74,7 @@ static inline uint32_t getBufferStartAddress(){
|
||||
return screenStartAddress;
|
||||
}
|
||||
|
||||
static inline uint32_t getPipStartAddress(){
|
||||
static uint32_t getPipStartAddress(){
|
||||
uint32_t pipStartAddress = sed1376Registers[PIP_ADDR_2] << 16 | sed1376Registers[PIP_ADDR_1] << 8 | sed1376Registers[PIP_ADDR_0];
|
||||
switch((sed1376Registers[SPECIAL_EFFECT] & 0x03) * 90){
|
||||
case 0:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//data access
|
||||
static inline uint32_t handlePanelDataSwaps(uint32_t address){
|
||||
static uint32_t handlePanelDataSwaps(uint32_t address){
|
||||
//word swap
|
||||
if(sed1376Registers[SPECIAL_EFFECT] & 0x80)
|
||||
address ^= 0x00000002;
|
||||
@@ -10,20 +10,20 @@ static inline uint32_t handlePanelDataSwaps(uint32_t address){
|
||||
}
|
||||
|
||||
//color conversion
|
||||
static inline uint16_t makeRgb16FromSed666(uint8_t r, uint8_t g, uint8_t b){
|
||||
static uint16_t makeRgb16FromSed666(uint8_t r, uint8_t g, uint8_t b){
|
||||
//the Palm m515 display controller -> LCD color lines are swapped for red and blue, so blue is put at the top
|
||||
uint16_t color = r >> 2 << 10 & 0xF800;
|
||||
color |= g >> 2 << 5 & 0x07E0;
|
||||
color |= b >> 2 >> 1 & 0x001F;
|
||||
return color;
|
||||
}
|
||||
static inline uint16_t makeRgb16FromGreenComponent(uint16_t g){
|
||||
static uint16_t makeRgb16FromGreenComponent(uint16_t g){
|
||||
uint16_t color = g;
|
||||
color |= g >> 6;
|
||||
color |= g << 5 & 0xF1;
|
||||
return color;
|
||||
}
|
||||
static inline uint16_t lutMonochromeValue(uint8_t lutIndex){
|
||||
static uint16_t lutMonochromeValue(uint8_t lutIndex){
|
||||
return makeRgb16FromSed666(sed1376GLut[lutIndex], sed1376GLut[lutIndex], sed1376GLut[lutIndex]);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ static uint16_t get16BppColor(uint16_t x, uint16_t y){
|
||||
return sed1376Framebuffer[handlePanelDataSwaps(screenStartAddress + (y * lineSize + x) * 2)] << 8 | sed1376Framebuffer[handlePanelDataSwaps(screenStartAddress + (y * lineSize + x) * 2 + 1)];
|
||||
}
|
||||
|
||||
static inline void selectRenderer(bool color, uint8_t bpp){
|
||||
static void selectRenderer(bool color, uint8_t bpp){
|
||||
renderPixel = NULL;
|
||||
if(color){
|
||||
switch(bpp){
|
||||
@@ -113,7 +113,7 @@ static inline void selectRenderer(bool color, uint8_t bpp){
|
||||
}
|
||||
|
||||
//updaters
|
||||
static inline void updateLcdStatus(){
|
||||
static void updateLcdStatus(){
|
||||
bool backlightEnabled = sed1376Registers[GPIO_CONT_0] & sed1376Registers[GPIO_CONF_0] & 0x10;
|
||||
|
||||
palmMisc.lcdOn = sed1376Registers[GPIO_CONT_0] & sed1376Registers[GPIO_CONF_0] & 0x20;
|
||||
|
||||
Reference in New Issue
Block a user