Merge pull request #90 from meepingsnesroms/tungstenT3Support

Input updates
This commit is contained in:
meepingsnesroms
2019-06-07 13:23:31 -07:00
committed by GitHub
29 changed files with 346 additions and 194 deletions

6
bugs/fixed/T3Crash.txt Normal file
View File

@@ -0,0 +1,6 @@
10:32:11: Debugging starts
mincore\com\oleaut32\dispatch\ups.cpp(2125)\OLEAUT32.dll!00007FFE26F51D23: (caller: 00007FFE26F51E9A) ReturnHr(1) tid(1870) 8002801D Library not registered.
QObject::~QObject: Timers cannot be stopped from another thread
10:32:24: Debugging has finished
Just a crash from killing the program due to a buffer overflow.

View File

@@ -2,6 +2,9 @@ EMU_PATH := $(CORE_DIR)/../src
LIBRETRO_COMM_DIR := $(CORE_DIR)/libretro-common
COREDEFINES :=
# my first make function!!!
CHECK_ALL = $(strip $(foreach v,$(2),$(if $(findstring $(v),$(1)),$(v),)))
INCFLAGS := -I$(LIBRETRO_COMM_DIR)/include
ifeq ($(DEBUG), 1)
@@ -10,12 +13,13 @@ else
COREDEFINES += -DEMU_NO_SAFETY
endif
# "unix" is not specific enough, need to know the CPU arch too
this_system = $(platform)
ifeq ($(this_system), unix)
this_system = $(shell $(CC) -dumpmachine)
# "unix" or "win" is not specific enough, need to know the CPU arch too
this_system := $(platform)
ifneq (,$(filter unix win,$(this_system)))
this_system := $(shell $(CC) -dumpmachine)
endif
ifneq (,$(findstring msvc200,$(this_system)))
INCFLAGS += -I$(LIBRETRO_COMM_DIR)/include/compat/msvc
endif
@@ -26,12 +30,12 @@ ifneq (,$(findstring msvc20,$(this_system)))
COREDEFINES += -Dinline=_inline -DINLINE=_inline
endif
ifneq (,$(findstring windows,$(this_system)))
ifneq (,$(call CHECK_ALL,$(this_system),windows mingw))
# Windows
ifeq (,$(findstring msvc,$(this_system)))
EMU_SUPPORT_PALM_OS5 := 1
EMU_OS := windows
ifneq (,$(filter %x64 %x86_64,$(this_system)))
ifneq (,$(call CHECK_ALL,$(this_system),x86_64 x64))
EMU_ARCH := x86_64
else
EMU_ARCH := x86_32
@@ -40,24 +44,24 @@ ifneq (,$(findstring windows,$(this_system)))
# MSVC uses its own(incompatible) ASM syntax
EMU_SUPPORT_PALM_OS5 := 0
endif
else ifneq (,$(filter %armv8% %aarch64% rpi3,$(this_system)))
else ifneq (,$(call CHECK_ALL,$(this_system),armv8 aarch64))
# ARM Linux 64
EMU_SUPPORT_PALM_OS5 := 1
EMU_ARCH := armv8
EMU_OS := linux
else ifneq (,$(filter %armv% rpi2,$(this_system)))
# ARM Linux
else ifneq (,$(call CHECK_ALL,$(this_system),armv rpi2 rpi3))
# ARM Linux(rpi3 is aarch64 but its almost always used in 32bit mode)
EMU_SUPPORT_PALM_OS5 := 1
EMU_ARCH := armv7
EMU_OS := linux
else ifneq (,$(findstring armhf,$(this_system)))
# ARM Linux ARMv5
# this needs to be before "linux%" because it will trigger the linux case
# this needs to be before "linux" because it will trigger the linux case
EMU_SUPPORT_PALM_OS5 := 0
else ifneq (,$(filter osx% linux% ,$(this_system)))
else ifneq (,$(call CHECK_ALL,$(this_system),osx linux))
# x86_* Linux
EMU_SUPPORT_PALM_OS5 := 1
ifneq (,$(filter osx %x86_64% %x64%,$(this_system)))
ifneq (,$(call CHECK_ALL,$(this_system),osx x86_64 x64))
EMU_ARCH := x86_64
else
EMU_ARCH := x86_32
@@ -78,7 +82,7 @@ endif
# use all CPUs and optimize for the most likely outcome, Android is handled separately
# Apple broke OpenMP in there port of Clang so no Mac OS or iOS
ifneq (,$(filter %armv% windows% linux%,$(this_system)))
ifneq (,$(call CHECK_ALL,$(this_system),windows linux))
# none of libretros MSVC compilers work with these optimizations for multiple different reasons
# they dont have the library "VCOMP.lib"
# they are too old for the extension to exist

View File

@@ -22,7 +22,7 @@
#define JOYSTICK_DEADZONE 4000
#define JOYSTICK_MULTIPLIER 0.0001
#define SCREEN_HIRES (!(palmFramebufferWidth == 160 && palmFramebufferHeight == 220))
#define SCREEN_HIRES (!(palmFramebufferWidth == 160))
static retro_log_printf_t log_cb = NULL;
@@ -36,16 +36,30 @@ static retro_input_state_t input_state_cb = NULL;
static uint32_t emuFeatures;
#if defined(EMU_SUPPORT_PALM_OS5)
static bool useOs5;
static bool firstRetroRunCall;
#endif
static bool firstRetroRunCall;
static bool dontRenderGraffiti;
static bool useJoystickAsMouse;
static float touchCursorX;
static float touchCursorY;
static char contentPath[PATH_MAX_LENGTH];
static uint16_t mouseCursorOldArea[32 * 32];
static bool runningImgFile;
static uint16_t screenYEnd;
static void frontendGetCurrentTime(uint8_t* writeBack){
time_t rawTime;
struct tm* timeInfo;
time(&rawTime);
timeInfo = localtime(&rawTime);
writeBack[0] = timeInfo->tm_hour;
writeBack[1] = timeInfo->tm_min;
writeBack[2] = timeInfo->tm_sec;
}
static void renderMouseCursor(int16_t screenX, int16_t screenY){
if(SCREEN_HIRES){
int8_t x;
@@ -151,6 +165,10 @@ static void check_variables(bool booting){
if(environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
useJoystickAsMouse = !strcmp(var.value, "enabled");
var.key = "palm_emu_disable_graffiti";
if(environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
dontRenderGraffiti = !strcmp(var.value, "enabled");
#if defined(EMU_SUPPORT_PALM_OS5)
var.key = "palm_emu_use_os5";
if(environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
@@ -215,22 +233,28 @@ void retro_set_environment(retro_environment_t cb){
{ "palm_emu_feature_hle_apis", "HLE API Implementations; disabled|enabled" },
{ "palm_emu_feature_durable", "Ignore Invalid Behavior; disabled|enabled" },
{ "palm_emu_use_joystick_as_mouse", "Use Left Joystick As Mouse; disabled|enabled" },
{ "palm_emu_disable_graffiti", "Disable Graffiti Area; disabled|enabled" },
#if defined(EMU_SUPPORT_PALM_OS5)
{ "palm_emu_use_os5", "Boot Apps In OS 5; disabled|enabled" },
{ "palm_emu_use_os5", "Boot Apps In OS 5(DEV ONLY); disabled|enabled" },
#endif
{ 0 }
};
struct retro_input_descriptor input_desc[] = {
{ 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Touchscreen Mouse X" },
{ 0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Touchscreen Mouse Y" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "Touchscreen Mouse Click" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Touchscreen Mouse Click" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Dpad Up" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Dpad Down" },
#if defined(EMU_SUPPORT_PALM_OS5)
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Dpad Left" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Dpad Right" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Dpad Center" },
#endif
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Power" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Date Book" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Address Book" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "To Do List" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Note Pad" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "Date Book" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Address Book" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "To Do List" },
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Note Pad" },
{ 0 }
};
bool no_rom = true;
@@ -283,22 +307,39 @@ void retro_reset(void){
void retro_run(void){
input_poll_cb();
#if defined(EMU_SUPPORT_PALM_OS5)
//some RetroArch functions can only be called from this function so call those if needed
if(unlikely(firstRetroRunCall)){
struct retro_game_geometry geometry;
#if defined(EMU_SUPPORT_PALM_OS5)
if(useOs5){
struct retro_game_geometry geometry;
geometry.base_width = 320;
geometry.base_height = 480;
geometry.max_width = 320;
geometry.max_height = 480;
geometry.aspect_ratio = 320.0 / 480.0;
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry);
if(dontRenderGraffiti){
geometry.base_width = 320;
geometry.base_height = 320;
geometry.max_width = 320;
geometry.max_height = 480;
}
else{
geometry.base_width = 320;
geometry.base_height = 480;
}
}
else{
#endif
if(dontRenderGraffiti){
geometry.base_width = 160;
geometry.base_height = 160;
}
else{
geometry.base_width = 160;
geometry.base_height = 220;
}
#if defined(EMU_SUPPORT_PALM_OS5)
}
#endif
geometry.aspect_ratio = (float)geometry.base_width / (float)geometry.base_height;
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry);
firstRetroRunCall = false;
}
#endif
//touchscreen
if(useJoystickAsMouse){
@@ -323,24 +364,31 @@ void retro_run(void){
palmInput.touchscreenX = touchCursorX / (palmFramebufferWidth - 1);
palmInput.touchscreenY = touchCursorY / (palmFramebufferHeight - 1);
palmInput.touchscreenTouched = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2);
palmInput.touchscreenTouched = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R);
}
else{
//use RetroArch internal pointer
palmInput.touchscreenX = ((float)input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X) / 0x7FFF + 1.0) / 2.0;
palmInput.touchscreenY = ((float)input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y) / 0x7FFF + 1.0) / 2.0;
palmInput.touchscreenY = ((float)input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y) / 0x7FFF + 1.0) / 2.0 * ((float)screenYEnd / palmFramebufferHeight);
palmInput.touchscreenTouched = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED);
}
//dpad
palmInput.buttonUp = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP);
palmInput.buttonDown = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN);
#if defined(EMU_SUPPORT_PALM_OS5)
if(useOs5){
palmInput.buttonLeft = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT);
palmInput.buttonRight = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT);
palmInput.buttonCenter = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT);
}
#endif
//app buttons
palmInput.buttonCalendar = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A);
palmInput.buttonAddress = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B);
palmInput.buttonTodo = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y);
palmInput.buttonNotes = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X);
palmInput.buttonCalendar = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y);
palmInput.buttonAddress = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X);
palmInput.buttonTodo = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B);
palmInput.buttonNotes = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A);
//special buttons
palmInput.buttonPower = input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START);
@@ -352,7 +400,7 @@ void retro_run(void){
if(useJoystickAsMouse)
renderMouseCursor(touchCursorX, touchCursorY);
video_cb(palmFramebuffer, palmFramebufferWidth, palmFramebufferHeight, palmFramebufferWidth * sizeof(uint16_t));
video_cb(palmFramebuffer, palmFramebufferWidth, screenYEnd, palmFramebufferWidth * sizeof(uint16_t));
audio_cb(palmAudio, AUDIO_SAMPLES_PER_FRAME);
if(led_cb)
led_cb(0, palmMisc.powerButtonLed);
@@ -562,13 +610,28 @@ bool retro_load_game(const struct retro_game_info *info){
return false;
}
//set the time callback
palmGetRtcFromHost = frontendGetCurrentTime;
//set mouse position
touchCursorX = palmFramebufferWidth / 2;
touchCursorY = palmFramebufferHeight / 2;
//make touches land on the correct spot and screen render the correct size when the graffiti area is off
if(dontRenderGraffiti){
#if defined(EMU_SUPPORT_PALM_OS5)
firstRetroRunCall = true;
if(useOs5)
screenYEnd = 320;
else
#endif
screenYEnd = 160;
}
else{
screenYEnd = palmFramebufferHeight;
}
//used to resize things properly
firstRetroRunCall = true;
return true;
}

View File

@@ -11,14 +11,14 @@ overlay0_desc2 = "up,0.504283,0.802938,radial,0.06852,0.04479"
overlay0_desc2_overlay = "X1_wswan.png"
overlay0_desc3 = "down,0.504283,0.964221,radial,0.06852,0.04479"
overlay0_desc3_overlay = "X3_wswan.png"
overlay0_desc4 = "a,0.0821626,0.960563,radial,0.07407,0.04167"
overlay0_desc4_overlay = "A.png"
overlay0_desc5 = "b,0.234211,0.960563,radial,0.07407,0.04167"
overlay0_desc5_overlay = "B.png"
overlay0_desc6 = "x,0.918421,0.960563,radial,0.07407,0.04167"
overlay0_desc6_overlay = "X.png"
overlay0_desc7 = "y,0.770469,0.960563,radial,0.07407,0.04167"
overlay0_desc7_overlay = "Y.png"
overlay0_desc4 = "y,0.0821626,0.960563,radial,0.07407,0.04167"
overlay0_desc4_overlay = "Y.png"
overlay0_desc5 = "x,0.234211,0.960563,radial,0.07407,0.04167"
overlay0_desc5_overlay = "X.png"
overlay0_desc6 = "a,0.918421,0.960563,radial,0.07407,0.04167"
overlay0_desc6_overlay = "A.png"
overlay0_desc7 = "b,0.770469,0.960563,radial,0.07407,0.04167"
overlay0_desc7_overlay = "B.png"
overlay0_desc8 = "start,0.860359,0.810741,rect,0.07037,0.03958"
overlay0_desc8_overlay = "start.png"
overlay0_desc9 = "menu_toggle,0.0552632,0.801573,radial,0.046296,0.02604"

View File

@@ -16,6 +16,7 @@
#include <string>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "emuwrapper.h"
#include "../../src/emulator.h"
@@ -58,6 +59,18 @@ void frontendHandleDebugPrint(){
}
}
static void frontendGetCurrentTime(uint8_t* writeBack){
time_t rawTime;
struct tm* timeInfo;
time(&rawTime);
timeInfo = localtime(&rawTime);
writeBack[0] = timeInfo->tm_hour;
writeBack[1] = timeInfo->tm_min;
writeBack[2] = timeInfo->tm_sec;
}
EmuWrapper::EmuWrapper(){
if(alreadyExists == true)
@@ -162,6 +175,7 @@ uint32_t EmuWrapper::init(const QString& assetPath, bool useOs5, uint32_t featur
if(error == EMU_ERROR_NONE){
QTime now = QTime::currentTime();
palmGetRtcFromHost = frontendGetCurrentTime;
emulatorSetRtc(QDate::currentDate().day(), now.hour(), now.minute(), now.second());
if(ramFile.open(QFile::ReadOnly | QFile::ExistingOnly)){
@@ -257,7 +271,6 @@ uint32_t EmuWrapper::bootFromFile(const QString& mainPath){
QFile ramFile(mainPath + "." + emuOsName + ".ram");
QFile sdCardFile(mainPath + "." + emuOsName + ".sd.img");
QString suffix = QFileInfo(mainPath).suffix().toLower();
uint32_t appId;
bool hasSaveRam;
bool hasSaveSdCard;
@@ -314,20 +327,15 @@ uint32_t EmuWrapper::bootFromFile(const QString& mainPath){
if(error != EMU_ERROR_NONE)
goto errorOccurred;
}
appId = launcherGetAppId((uint8_t*)fileBuffer.data(), fileBuffer.size());
error = launcherExecute(launcherGetAppId((uint8_t*)fileBuffer.data(), fileBuffer.size()));
if(error != EMU_ERROR_NONE)
goto errorOccurred;
}
}
//img files just boot to the homescreen
if(suffix != "img"){
error = launcherExecute(appId);
if(error != EMU_ERROR_NONE)
goto errorOccurred;
}
//everything worked, set output save files
emuRamFilePath = mainPath + "." + emuOsName + ".ram";
emuSdCardFilePath = mainPath + "." + emuOsName + ".sd.img";
emuSdCardFilePath = suffix != "img" ? mainPath + "." + emuOsName + ".sd.img" : "";//dont duplicate booted SD card images
emuSaveStatePath = mainPath + "." + emuOsName + ".states";
//make the place to store the saves

View File

@@ -19,9 +19,11 @@ v1.0.0 to v1.1.0(Feb 25 2019 - Easter 2019)
RetroArch GUI:
*allow mouse cursor to be rendered with multiple CPUs(removed for now)
*now launches content like cartridge based systems
*make default button layout match default controller layout better
//TODO: allow adding more content after boot
//TODO: get EMU_MANAGE_HOST_CPU_PIPELINE working on other platforms then the main 4
//TODO: when compiling with "make platform=windows_x86_64" the dll wont load(theres a really good chance its because "libgomp-1.dll"(the OpenMP handler library) is missing from the RetroArch folder)
*allow disabling the silkscreen area
*booting without game works again
*add multithreading and pipeline speedups
@@ -43,3 +45,4 @@ Core:
*add a launcher to load prc/pdb/pqa files
*add frameskip for really low power devices and when video is not needed
*added host CPU pipeline control for another speed up
*implement FEATURE_SYNCED_RTC to make the Palm clock always match the host system clock

View File

@@ -530,6 +530,8 @@ void do_arm_instruction(Instruction i)
}
else if((insn & 0xF000F10) == 0xE000F10)
do_cp15_instruction(i);
else if((insn & 0xF000F10) == 0xE000E10)
do_cp14_instruction(i);
else if((insn & 0xF000000) == 0xF000000)
cpu_exception(EX_SWI);
else

View File

@@ -2,13 +2,20 @@
#include "cpudefs.h"
#include "mmu.h"
extern "C" {
#include "../pxa255/pxa255.h"
#include "../pxa255/pxa255_PwrClk.h"
}
void do_cp15_mrc(uint32_t insn)
{
uint32_t value;
switch (insn & 0xEF00EF) {
case 0x000000: /* MRC p15, 0, <Rd>, c0, c0, 0: ID Code Register */
//value = 0x41069264; /* ARM926EJ-S revision 4 */
value = 0x69052100;//Intel PXA255 "01101001000001010010000100000000"
//value = 0x69052100;//Intel PXA255 "01101001000001010010000100000000"
value = 0x69052D05;//Intel PXA261 "01101001000001010010110100000101"
break;
case 0x000010: /* MRC p15, 0, <Rd>, c0, c0, 1: Cache Type Register */
value = 0x1D112152; /* ICache: 16KB 4-way 8 word, DCache: 8KB 4-way 8 word */
@@ -47,6 +54,10 @@ void do_cp15_mrc(uint32_t insn)
// Unimplemented
value = 0;
break;
case 0x0F0001: /* MRC p15, 0, <Rd>, c15, c1, 0: Unknown */
//TODO: Unknown(implmentation defined cp15 register)
value = 0;
break;
default:
warn("Unknown coprocessor instruction MRC %08X", insn);
value = 0;
@@ -67,8 +78,11 @@ void do_cp15_mcr(uint32_t insn)
switch (insn & 0xEF00EF) {
case 0x010000: { /* MCR p15, 0, <Rd>, c1, c0, 0: Control Register */
uint32_t change = value ^ arm.control;
//TODO: actually implement this register fully
/*
if ((value & 0xFFFF8CF0) != 0x00050070)
error("Bad or unimplemented control register value: %x (unsupported: %x)\n", value, (value & 0xFFFF8CF8) ^ 0x00050078);
*/
arm.control = value;
if (change & 1) // MMU is being turned on or off
addr_cache_flush();
@@ -120,6 +134,9 @@ void do_cp15_mcr(uint32_t insn)
addr_cache_flush();
#endif
break;
case 0x0F0001: /* MCR p15, 0, <Rd>, c15, c1, 0: Unknown */
//TODO: Unknown(implmentation defined cp15 register)
break;
default:
warn("Unknown coprocessor instruction MCR %08X", insn);
break;
@@ -135,3 +152,16 @@ void do_cp15_instruction(Instruction i)
return do_cp15_mcr(insn);
}
void do_cp14_instruction(Instruction i)
{
uint32_t instr = i.raw;
bool specialInstr = i.cond == 0xF;
bool success;
success = pxa255pwrClkPrvCoprocRegXferFunc(&pxa255PwrClk, specialInstr, (instr & 0x00100000) != 0, (instr >> 21) & 0x07, (instr >> 12) & 0x0F, (instr >> 16) & 0x0F, instr & 0x0F, (instr >> 5) & 0x07);
//fail if instr dosent actully exist
if(!success)
undefined_instruction();
}

View File

@@ -133,7 +133,10 @@ void data_abort(uint32_t mva, uint8_t status)
void undefined_instruction()
{
fix_pc_for_fault();
warn("Undefined instruction at %08x\n", arm.reg[15]);
if(current_instr_size == 4)
warn("Undefined instruction 0x%08X at 0x%08X\n", read_word(arm.reg[15]), arm.reg[15]);
else
warn("Undefined instruction 0x%04X at 0x%08X\n", read_half(arm.reg[15]), arm.reg[15]);
arm.reg[15] += current_instr_size;
cpu_exception(EX_UNDEFINED);
longjmp(restart_after_exception, 1);

View File

@@ -151,6 +151,7 @@ enum DataOp {
void do_arm_instruction(Instruction i);
// Defined in coproc.cpp
void do_cp15_instruction(Instruction i);
void do_cp14_instruction(Instruction i);
#endif // CPUDEFS_H

View File

@@ -477,6 +477,7 @@ void translate_deinit()
translate_end = translate_current = translate_buffer = nullptr;
}
/*
static __attribute__((unused)) void dump_translation(int index)
{
auto &translation = translation_table[index];
@@ -499,6 +500,7 @@ static __attribute__((unused)) void dump_translation(int index)
}
}
}
*/
void translate(uint32_t pc_start, uint32_t *insn_ptr_start)
{

View File

@@ -1166,7 +1166,7 @@ void dbvzLoadBootloader(uint8_t* data, uint32_t size){
if(!data)
size = 0;
size = uintMin(size, DBVZ_BOOTLOADER_SIZE);
size = FAST_MIN(size, DBVZ_BOOTLOADER_SIZE);
//copy size bytes from buffer to bootloader area
for(index = 0; index < size; index++)
@@ -1422,7 +1422,7 @@ void dbvzExecute(void){
double cyclesRemaining = dbvzSysclksPerClk32 / 2.0;
while(cyclesRemaining >= 1.0){
double sysclks = floatMin(cyclesRemaining, DBVZ_SYSCLK_PRECISION);
double sysclks = FAST_MIN(cyclesRemaining, DBVZ_SYSCLK_PRECISION);
int32_t cpuCycles = sysclks * pctlrCpuClockDivider * palmClockMultiplier;
if(cpuCycles > 0)

View File

@@ -107,7 +107,7 @@ int32_t pwm1FifoRunSample(int32_t now, int32_t clockOffset){
//try to get next sample, if none are available play old sample
if(pwm1FifoEntrys() > 0)
pwm1ReadPosition = (pwm1ReadPosition + 1) % 6;
dutyCycle = floatMin((float)pwm1Fifo[pwm1ReadPosition] / period, 1.00);
dutyCycle = FAST_MIN((float)pwm1Fifo[pwm1ReadPosition] / period, 1.00);
for(index = 0; index < repeat; index++){
#if !defined(EMU_NO_SAFETY)

View File

@@ -249,16 +249,36 @@ static void rtcAddSecondClk32(void){
uint8_t minutes = oldRtcTime >> 16 & 0x0000003F;
uint8_t seconds = oldRtcTime & 0x0000003F;
seconds++;
rtcInterruptEvents |= 0x0010;
if(seconds >= 60){
if(palmEmuFeatures.info & FEATURE_SYNCED_RTC && palmGetRtcFromHost){
//get new RTC value from system
uint16_t stopwatch = registerArrayRead16(STPWCH);
uint8_t alarmHours = rtcAlrm >> 24;
uint8_t alarmMinutes = rtcAlrm >> 16 & 0x0000003F;
uint8_t alarmSeconds = rtcAlrm & 0x0000003F;
uint8_t time[3];
palmGetRtcFromHost(time);
//day rollover happened
if(hours > time[0]){
days++;
rtcInterruptEvents |= 0x0008;
}
if(time[0] != hours)
rtcInterruptEvents |= 0x0020;
if(time[1] != minutes)
rtcInterruptEvents |= 0x0002;
if(time[2] != seconds)
rtcInterruptEvents |= 0x0010;
if(stopwatch != 0x003F){
if(stopwatch == 0x0000)
stopwatch -= FAST_ABS(time[1] - minutes);
if(stopwatch <= 0x0000)
stopwatch = 0x003F;
else
stopwatch--;
registerArrayWrite16(STPWCH, stopwatch);
}
@@ -266,27 +286,64 @@ static void rtcAddSecondClk32(void){
if(stopwatch == 0x003F)
rtcInterruptEvents |= 0x0001;
minutes++;
seconds = 0;
rtcInterruptEvents |= 0x0002;
if(minutes >= 60){
hours++;
minutes = 0;
rtcInterruptEvents |= 0x0020;
if(hours >= 24){
hours = 0;
days++;
rtcInterruptEvents |= 0x0008;
newRtcTime = time[2];//seconds
newRtcTime |= time[1] << 16;//minutes
newRtcTime |= time[0] << 24;//hours
//check alarm range to see if it triggered in the time that has passed
if(days == dayAlrm){
if(hours < alarmHours || hours == alarmHours && minutes < alarmMinutes || hours == alarmHours && minutes == alarmMinutes && seconds < alarmSeconds){
//old time is before alarm
if(time[0] > alarmHours || time[0] == alarmHours && time[1] > alarmMinutes || time[0] == alarmHours && time[1] == alarmMinutes && time[0] >= alarmSeconds){
//new time is after alarm
rtcInterruptEvents |= 0x0040;
}
}
}
}
else{
//standard frame based time increment
newRtcTime = seconds;
newRtcTime |= minutes << 16;
newRtcTime |= hours << 24;
seconds++;
rtcInterruptEvents |= 0x0010;
if(seconds >= 60){
uint16_t stopwatch = registerArrayRead16(STPWCH);
if(newRtcTime == rtcAlrm && days == dayAlrm)
rtcInterruptEvents |= 0x0040;
if(stopwatch != 0x003F){
if(stopwatch == 0x0000)
stopwatch = 0x003F;
else
stopwatch--;
registerArrayWrite16(STPWCH, stopwatch);
}
//if stopwatch ran out above or was enabled with 0x003F in the register trigger interrupt
if(stopwatch == 0x003F)
rtcInterruptEvents |= 0x0001;
minutes++;
seconds = 0;
rtcInterruptEvents |= 0x0002;
if(minutes >= 60){
hours++;
minutes = 0;
rtcInterruptEvents |= 0x0020;
if(hours >= 24){
hours = 0;
days++;
rtcInterruptEvents |= 0x0008;
}
}
}
newRtcTime = seconds;
newRtcTime |= minutes << 16;
newRtcTime |= hours << 24;
if(newRtcTime == rtcAlrm && days == dayAlrm)
rtcInterruptEvents |= 0x0040;
}
rtcInterruptEvents &= registerArrayRead16(RTCIENR);
if(rtcInterruptEvents){

View File

@@ -60,6 +60,7 @@ int16_t* palmAudio;
blip_t* palmAudioResampler;
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 (*palmGetRtcFromHost)(uint8_t* writeBack);//[0] = hours, [1] = minutes, [2] = seconds
uint32_t emulatorInit(uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmBootloaderData, uint32_t palmBootloaderSize, uint32_t enabledEmuFeatures){
@@ -77,6 +78,8 @@ uint32_t emulatorInit(uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmB
if(!palmRomData || palmRomSize < 0x8)
return EMU_ERROR_INVALID_PARAMETER;
palmGetRtcFromHost = NULL;
#if defined(EMU_SUPPORT_PALM_OS5)
//0x00000004 is boot program counter on 68k, its just 0x00000000 on ARM
palmEmulatingTungstenT3 = !(palmRomData[0x4] || palmRomData[0x5] || palmRomData[0x6] || palmRomData[0x7]);
@@ -96,7 +99,7 @@ uint32_t emulatorInit(uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmB
pxa255Deinit();
return EMU_ERROR_OUT_OF_MEMORY;
}
memcpy(palmRom, palmRomData, uintMin(palmRomSize, TUNGSTEN_T3_ROM_SIZE));
memcpy(palmRom, palmRomData, FAST_MIN(palmRomSize, TUNGSTEN_T3_ROM_SIZE));
if(palmRomSize < TUNGSTEN_T3_ROM_SIZE)
memset(palmRom + palmRomSize, 0x00, TUNGSTEN_T3_ROM_SIZE - palmRomSize);
memset(palmRam, 0x00, TUNGSTEN_T3_RAM_SIZE);
@@ -140,7 +143,7 @@ uint32_t emulatorInit(uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmB
}
//set default values
memcpy(palmRom, palmRomData, uintMin(palmRomSize, M515_ROM_SIZE));
memcpy(palmRom, palmRomData, FAST_MIN(palmRomSize, M515_ROM_SIZE));
if(palmRomSize < M515_ROM_SIZE)
memset(palmRom + palmRomSize, 0x00, M515_ROM_SIZE - palmRomSize);
swap16BufferIfLittle(palmRom, M515_ROM_SIZE / sizeof(uint16_t));

View File

@@ -176,7 +176,8 @@ extern uint16_t palmFramebufferHeight;//read allowed
extern int16_t* palmAudio;//read allowed, 2 channel signed 16 bit audio
extern blip_t* palmAudioResampler;//dont touch
extern double palmCycleCounter;//dont touch
extern double palmClockMultiplier;//dont touch
extern double palmClockMultiplier;//read/write allowed, setting by multiplication and cacheing the result is the best way
extern void (*palmGetRtcFromHost)(uint8_t* writeBack);//[0] = hours, [1] = minutes, [2] = seconds
//functions
uint32_t emulatorInit(uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmBootloaderData, uint32_t palmBootloaderSize, uint32_t enabledEmuFeatures);

View File

@@ -82,44 +82,9 @@ static inline uintmax_t rightShiftUse1s(uintmax_t value, uint8_t count){
}
//range capping
static inline uintmax_t uintMin(uintmax_t x, uintmax_t y){
return x < y ? x : y;
}
static inline uintmax_t uintMax(uintmax_t x, uintmax_t y){
return x > y ? x : y;
}
static inline uintmax_t uintClamp(uintmax_t low, uintmax_t value, uintmax_t high){
//low must always be less than high!
return uintMax(low, uintMin(value, high));
}
static inline intmax_t intMin(intmax_t x, intmax_t y){
return x < y ? x : y;
}
static inline intmax_t intMax(intmax_t x, intmax_t y){
return x > y ? x : y;
}
static inline intmax_t intClamp(intmax_t low, intmax_t value, intmax_t high){
//low must always be less than high!
return intMax(low, intMin(value, high));
}
static inline double floatMin(double x, double y){
return x < y ? x : y;
}
static inline double floatMax(double x, double y){
return x > y ? x : y;
}
static inline double floatClamp(double low, double value, double high){
//low must always be less than high!
return floatMax(low, floatMin(value, high));
}
#define FAST_MIN(x, y) ((x) < (y) ? (x) : (y))
#define FAST_MAX(x, y) ((x) > (y) ? (x) : (y))
#define FAST_ABS(x) ((x) < 0 ? -(x) : (x))
//float platform safety
static inline uint64_t getUint64FromDouble(double data){

View File

@@ -27,9 +27,11 @@
uint16_t* pxa255Framebuffer;
Pxa255pwrClk pxa255PwrClk;
static Pxa255ic pxa255Ic;
static Pxa255lcd pxa255Lcd;
static Pxa255timr pxa255Timer;
static Pxa255gpio pxa255Gpio;
#include "pxa255Accessors.c.h"
@@ -120,11 +122,6 @@ bool pxa255Init(uint8_t** returnRom, uint8_t** returnRam){
write_half_map[PXA255_START_BANK(PXA255_MEMCTRL_BASE)] = bad_write_half;
write_word_map[PXA255_START_BANK(PXA255_MEMCTRL_BASE)] = pxa255_memctrl_write_word;
//set up CPU hardware
pxa255icInit(&pxa255Ic);
pxa255lcdInit(&pxa255Lcd, &pxa255Ic);
pxa255timrInit(&pxa255Timer, &pxa255Ic);
*returnRom = mem_areas[0].ptr;
*returnRam = mem_areas[1].ptr;
@@ -162,6 +159,13 @@ void pxa255Reset(void){
}
*/
//set up extra CPU hardware
pxa255icInit(&pxa255Ic);
pxa255pwrClkInit(&pxa255PwrClk);
pxa255lcdInit(&pxa255Lcd, &pxa255Ic);
pxa255timrInit(&pxa255Timer, &pxa255Ic);
pxa255gpioInit(&pxa255Gpio, &pxa255Ic);
memset(&arm, 0, sizeof arm);
arm.control = 0x00050078;
arm.cpsr_low28 = MODE_SVC | 0xC0;
@@ -193,14 +197,15 @@ void pxa255LoadState(uint8_t* data){
}
void pxa255Execute(bool wantVideo){
uint32_t index;
#if OS_HAS_PAGEFAULT_HANDLER
os_exception_frame_t seh_frame = { NULL, NULL };
os_faulthandler_arm(&seh_frame);
#endif
//TODO: need to set cycle_count_delta with the amount of opcodes to run
cycle_count_delta = -500;//just a test value
//TODO: need to take the PLL into account still
cycle_count_delta = -1 * 60 * TUNGSTEN_T3_CPU_CRYSTAL_FREQUENCY / EMU_FPS;
while(setjmp(restart_after_exception)){};
@@ -230,13 +235,13 @@ void pxa255Execute(bool wantVideo){
#if OS_HAS_PAGEFAULT_HANDLER
os_faulthandler_unarm(&seh_frame);
#endif
//this needs to run at 3.6864 MHz
for(index = 0; index < TUNGSTEN_T3_CPU_CRYSTAL_FREQUENCY / EMU_FPS; index++)
pxa255timrTick(&pxa255Timer);
//render
if(likely(wantVideo))
pxa255lcdFrame(&pxa255Lcd);
//TODO: this needs to run at 3.6864 MHz
//pxa255timrTick(&pxa255Timer);
}
uint32_t pxa255GetRegister(uint8_t reg){

View File

@@ -7,7 +7,10 @@
#include <stdint.h>
#include <stdbool.h>
uint16_t* pxa255Framebuffer;
#include "pxa255_PwrClk.h"
extern uint16_t* pxa255Framebuffer;
extern Pxa255pwrClk pxa255PwrClk;
bool pxa255Init(uint8_t** returnRom, uint8_t** returnRam);
void pxa255Deinit(void);

View File

@@ -7,23 +7,36 @@ static uint32_t pxa255_io_read_word(uint32_t addr){
switch(addr >> 16){
case PXA255_CLOCK_MANAGER_BASE >> 16:
pxa255pwrClkPrvClockMgrMemAccessF(&pxa255PwrClk, addr, 4, false, &out);
break;
case PXA255_POWER_MANAGER_BASE >> 16:
case PXA255_DMA_BASE >> 16:
pxa255pwrClkPrvPowerMgrMemAccessF(&pxa255PwrClk, addr, 4, false, &out);
break;
case PXA255_TIMR_BASE >> 16:
pxa255timrPrvMemAccessF(&pxa255Timer, addr, 4, false, &out);
break;
case PXA255_GPIO_BASE >> 16:
pxa255gpioPrvMemAccessF(&pxa255Gpio, addr, 4, false, &out);
break;
case PXA255_DMA_BASE >> 16:
case PXA255_IC_BASE >> 16:
case PXA255_RTC_BASE >> 16:
case PXA255_TIMR_BASE >> 16:
case PXA255_FFUART_BASE >> 16:
case PXA255_BTUART_BASE >> 16:
case PXA255_STUART_BASE >> 16:
//need to implement these
debugLog("Unimplemented 32 bit PXA255 register read:0x%08X\n", addr);
return 0x00000000;
out = 0x00000000;
break;
default:
debugLog("Invalid 32 bit PXA255 register read:0x%08X\n", addr);
return 0x00000000;
out = 0x00000000;
break;
}
return out;
}
static void pxa255_io_write_byte(uint32_t addr, uint8_t value){
@@ -33,22 +46,31 @@ static void pxa255_io_write_byte(uint32_t addr, uint8_t value){
static void pxa255_io_write_word(uint32_t addr, uint32_t value){
switch(addr >> 16){
case PXA255_CLOCK_MANAGER_BASE >> 16:
pxa255pwrClkPrvClockMgrMemAccessF(&pxa255PwrClk, addr, 4, true, &value);
break;
case PXA255_POWER_MANAGER_BASE >> 16:
case PXA255_DMA_BASE >> 16:
pxa255pwrClkPrvPowerMgrMemAccessF(&pxa255PwrClk, addr, 4, true, &value);
break;
case PXA255_TIMR_BASE >> 16:
pxa255timrPrvMemAccessF(&pxa255Timer, addr, 4, true, &value);
break;
case PXA255_GPIO_BASE >> 16:
pxa255gpioPrvMemAccessF(&pxa255Gpio, addr, 4, true, &value);
break;
case PXA255_DMA_BASE >> 16:
case PXA255_IC_BASE >> 16:
case PXA255_RTC_BASE >> 16:
case PXA255_TIMR_BASE >> 16:
case PXA255_FFUART_BASE >> 16:
case PXA255_BTUART_BASE >> 16:
case PXA255_STUART_BASE >> 16:
//need to implement these
debugLog("Unimplemented 32 bit PXA255 register write:0x%08X, value:0x%08X\n", addr, value);
return;
break;
default:
debugLog("Invalid 32 bit PXA255 register write:0x%08X, value:0x%08X\n", addr, value);
return;
break;
}
}

View File

@@ -23,7 +23,7 @@ static void pxa255gpioPrvRecalcIntrs(Pxa255gpio* gpio){
pxa255icInt(gpio->ic, PXA255_I_GPIO_0, (gpio->levels[0] & 1) != 0);
}
static Boolean pxa255gpioPrvMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf){
Boolean pxa255gpioPrvMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf){
Pxa255gpio* gpio = userData;
UInt32 val = 0;
@@ -97,13 +97,14 @@ static Boolean pxa255gpioPrvMemAccessF(void* userData, UInt32 pa, UInt8 size, Bo
case 25:
case 26:
val = gpio->AFRs[pa - 21];
pa = (pa - 21) / 2;
goto recalc;
}
goto done;
recalc:
pxa255gpioPrvRecalcValues(gpio, pa);
pxa255gpioPrvRecalcValues(gpio, pa);
trigger_intrs:
pxa255gpioPrvRecalcIntrs(gpio);
@@ -167,12 +168,9 @@ done:
}
Boolean pxa255gpioInit(Pxa255gpio* gpio, ArmMem* physMem, Pxa255ic* ic){
void pxa255gpioInit(Pxa255gpio* gpio, Pxa255ic* ic){
__mem_zero(gpio, sizeof(Pxa255gpio));
gpio->ic = ic;
return memRegionAdd(physMem, PXA255_GPIO_BASE, PXA255_GPIO_SIZE, pxa255gpioPrvMemAccessF, gpio);
}
void pxa255gpioSetState(Pxa255gpio* gpio, UInt8 gpioNum, Boolean on){

View File

@@ -37,7 +37,8 @@ typedef struct{
#define PXA255_GPIO_AFR3 5
#define PXA255_GPIO_NOT_PRESENT 6
Boolean pxa255gpioInit(Pxa255gpio* gpio, ArmMem* physMem, Pxa255ic* ic);
Boolean pxa255gpioPrvMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf);
void pxa255gpioInit(Pxa255gpio* gpio, Pxa255ic* ic);
//for external use :)
UInt8 pxa255gpioGetState(Pxa255gpio* gpio, UInt8 gpioNum);

View File

@@ -1,7 +1,7 @@
#include "pxa255_PwrClk.h"
static Boolean pxa255pwrClkPrvCoprocRegXferFunc(struct ArmCpu* cpu, void* userData, Boolean two, Boolean read, UInt8 op1, UInt8 Rx, UInt8 CRn, UInt8 CRm, UInt8 op2){
Boolean pxa255pwrClkPrvCoprocRegXferFunc(void* userData, Boolean two, Boolean read, UInt8 op1, UInt8 Rx, UInt8 CRn, UInt8 CRm, UInt8 op2){
Pxa255pwrClk* pc = userData;
UInt32 val = 0;
@@ -45,7 +45,7 @@ success:
return true;
}
static Boolean pxa255pwrClkPrvClockMgrMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf){
Boolean pxa255pwrClkPrvClockMgrMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf){
Pxa255pwrClk* pc = userData;
UInt32 val = 0;
@@ -88,7 +88,7 @@ static Boolean pxa255pwrClkPrvClockMgrMemAccessF(void* userData, UInt32 pa, UInt
return true;
}
static Boolean pxa255pwrClkPrvPowerMgrMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf){
Boolean pxa255pwrClkPrvPowerMgrMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf){
Pxa255pwrClk* pc = userData;
UInt32 val = 0;
@@ -119,14 +119,9 @@ static Boolean pxa255pwrClkPrvPowerMgrMemAccessF(void* userData, UInt32 pa, UInt
return true;
}
Boolean pxa255pwrClkInit(Pxa255pwrClk* pc, ArmCpu* cpu, ArmMem* physMem){
ArmCoprocessor cp;
Boolean ok = true;
void pxa255pwrClkInit(Pxa255pwrClk* pc){
__mem_zero(pc, sizeof(Pxa255pwrClk));
pc->cpu = cpu;
pc->CCCR = 0x00000122UL; //set CCCR to almost default value (we use mult 32 not 27)
pc->CKEN = 0x000179EFUL; //set CKEN to default value
pc->OSCR = 0x00000003UL; //32KHz oscillator on and stable
@@ -135,20 +130,6 @@ Boolean pxa255pwrClkInit(Pxa255pwrClk* pc, ArmCpu* cpu, ArmMem* physMem){
pc->pwrRegs[4] = 3; //set PRER
pc->pwrRegs[5] = 3; //set PFER
pc->pwrRegs[12] = 1; //set RCSR
cp.regXfer = pxa255pwrClkPrvCoprocRegXferFunc;
cp.dataProcessing = NULL;
cp.memAccess = NULL;
cp.twoRegF = NULL;
cp.userData = pc;
cpuCoprocessorRegister(cpu, 14, &cp);
ok = ok && memRegionAdd(physMem, PXA255_CLOCK_MANAGER_BASE, PXA255_CLOCK_MANAGER_SIZE, pxa255pwrClkPrvClockMgrMemAccessF, pc);
ok = ok && memRegionAdd(physMem, PXA255_POWER_MANAGER_BASE, PXA255_POWER_MANAGER_SIZE, pxa255pwrClkPrvPowerMgrMemAccessF, pc);
return ok;
}

View File

@@ -4,15 +4,10 @@
#include "pxa255_mem.h"
#include "pxa255_CPU.h"
typedef struct{
ArmCpu* cpu;
UInt32 CCCR, CKEN, OSCR; //clocks manager regs
UInt32 pwrRegs[13]; //we care so little about these, we don't even name them
Boolean turbo;
}Pxa255pwrClk;
@@ -22,11 +17,9 @@ typedef struct{
#define PXA255_POWER_MANAGER_BASE 0x40F00000UL
#define PXA255_POWER_MANAGER_SIZE 0x00001000UL
Boolean pxa255pwrClkInit(Pxa255pwrClk* pc, ArmCpu* cpu, ArmMem* physMem);
Boolean pxa255pwrClkPrvCoprocRegXferFunc(void* userData, Boolean two, Boolean read, UInt8 op1, UInt8 Rx, UInt8 CRn, UInt8 CRm, UInt8 op2);
Boolean pxa255pwrClkPrvClockMgrMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf);
Boolean pxa255pwrClkPrvPowerMgrMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf);
void pxa255pwrClkInit(Pxa255pwrClk* pc);
#endif

View File

@@ -27,7 +27,7 @@ static void pxa255timrPrvUpdate(Pxa255timr* timr){
pxa255timrPrvCheckMatch(timr, 3);
}
static Boolean pxa255timrPrvMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf){
Boolean pxa255timrPrvMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf){
Pxa255timr* timr = userData;
UInt32 val = 0;

View File

@@ -29,6 +29,7 @@ typedef struct{
}Pxa255timr;
Boolean pxa255timrPrvMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf);
void pxa255timrInit(Pxa255timr* timr, Pxa255ic* ic);
void pxa255timrTick(Pxa255timr* timr);

View File

@@ -237,14 +237,14 @@ bool sdCardExchangeBit(bool bit){
break;
case SEND_STATUS:
//HACK, need to add real write protection, this command is also how the host reads the value of the little switch on the side
//TODO: need to add real write protection, this command is also how the host reads the value of the little switch on the side
sdCardDoResponseR2(palmSdCard.inIdleState, palmSdCard.sdInfo.writeProtectSwitch);
break;
case SEND_WRITE_PROT:{
const uint8_t writeProtBits[4] = {0x00, 0x00, 0x00, 0x00};
//HACK, need to add real write protection
//TODO: need to add real write protection
sdCardDoResponseR1(palmSdCard.inIdleState);
sdCardDoResponseDelay(1);
sdCardDoResponseDataPacket(DATA_TOKEN_DEFAULT, writeProtBits, sizeof(writeProtBits));
@@ -339,7 +339,7 @@ bool sdCardExchangeBit(bool bit){
case SET_WR_BLOCK_ERASE_COUNT:
sdCardDoResponseR1(palmSdCard.inIdleState);
//HACK, this command isnt actually supported yet, called when formmating the SD card
//TODO: this command isnt actually supported yet, called when formmating the SD card
break;
default:
@@ -374,7 +374,7 @@ bool sdCardExchangeBit(bool bit){
if(unlikely(palmSdCard.runningCommandVars[2] >= SD_CARD_BLOCK_DATA_PACKET_SIZE * 8)){
//packet finished, verify and write block to chip
if(likely(palmSdCard.allowInvalidCrc) || sdCardCrc16(palmSdCard.runningCommandPacket + 1, SD_CARD_BLOCK_SIZE) == (palmSdCard.runningCommandPacket[SD_CARD_BLOCK_DATA_PACKET_SIZE - 2] << 8 | palmSdCard.runningCommandPacket[SD_CARD_BLOCK_DATA_PACKET_SIZE - 1])){
//HACK, also need to check if block is write protected, not just the card as a whole
//TODO: also need to check if block is write protected, not just the card as a whole
if(likely(palmSdCard.runningCommandVars[0] < palmSdCard.flashChipSize && !palmSdCard.sdInfo.writeProtectSwitch)){
memcpy(palmSdCard.flashChipData + palmSdCard.runningCommandVars[0], palmSdCard.runningCommandPacket + 1, SD_CARD_BLOCK_SIZE);
sdCardDoResponseDataResponse(DR_ACCEPTED);

View File

@@ -391,8 +391,8 @@ void sed1376Render(void){
//debugLog("PIP state, start x:%d, end x:%d, start y:%d, end y:%d\n", pipStartX, pipEndX, pipStartY, pipEndY);
//render PIP only if PIP window is onscreen
if(pipStartX < 160 && pipStartY < 160){
pipEndX = uintMin(pipEndX, 160);
pipEndY = uintMin(pipEndY, 160);
pipEndX = FAST_MIN(pipEndX, 160);
pipEndY = FAST_MIN(pipEndY, 160);
screenStartAddress = getPipStartAddress();
lineSize = (sed1376Registers[PIP_LINE_SZ_1] << 8 | sed1376Registers[PIP_LINE_SZ_0]) * 4;
MULTITHREAD_DOUBLE_LOOP(pixelX, pixelY) for(pixelY = pipStartY; pixelY < pipEndY; pixelY++)

View File

@@ -4,8 +4,8 @@
#include <stdint.h>
#include <stdbool.h>
uint16_t* sed1376Framebuffer;
extern uint8_t sed1376Ram[];
extern uint16_t* sed1376Framebuffer;
extern uint8_t sed1376Ram[];
void sed1376Reset(void);
uint32_t sed1376StateSize(void);