1 Commits

Author SHA1 Message Date
Stephanie Gawroriski
e8f6529bec Initial attempt at serial port support. 2024-06-14 22:44:19 -04:00
38 changed files with 1869 additions and 1795 deletions

3
.gitignore vendored
View File

@@ -37,5 +37,4 @@ cmake-build-release-visual-studio-1/
userdata-palmos41-en-m515.ram
userdata-en-m515.ram
palmos41-en-m515.rom
default-palmos41-en-m515.ram
/build/
default-palmos41-en-m515.ram

View File

@@ -12,91 +12,94 @@
# Inclusion templates, required for the build to work
include:
- project: 'libretro-infrastructure/ci-templates'
file: '/android-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/android-jni.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/ctr-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/ctr-static.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/dingux-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/dingux-mips32.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/djgpp-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/emscripten-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/emscripten-static.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/ios-arm64.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/ios-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/ios9.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/libnx-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/libnx-static.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/linux-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/linux-x64.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/ngc-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/ngc-static.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/orbis-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/osx-arm64.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/osx-cmake-arm64.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/osx-cmake-ppc.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/osx-cmake-x86.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/osx-x64.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/ps2-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/ps2-static.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/psp-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/tvos-arm64.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/tvos-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/vita-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/vita-static.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/wii-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/wii-static.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/wiiu-static-cmake.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/wiiu-static.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-cmake-mingw.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-cmake-msvc19.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-mingw.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-msvc05-msys2.yml'
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-msvc10-msys2.yml'
################################## DESKTOPS ################################
# Windows 64-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-x64-mingw.yml'
# Windows 32-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-mingw.yml'
# Windows msvc10 64-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-x64-msvc10-msys2.yml'
# Windows msvc10 32-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-msvc10-msys2.yml'
# Windows msvc05 32-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/windows-i686-msvc05-msys2.yml'
# Linux 64-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/linux-x64.yml'
# MacOS 64-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/osx-x64.yml'
# MacOS ARM 64-bit
- project: 'libretro-infrastructure/ci-templates'
file: '/osx-arm64.yml'
################################## CELLULAR ################################
# Android
- project: 'libretro-infrastructure/ci-templates'
file: '/android-jni.yml'
# iOS 9
- project: 'libretro-infrastructure/ci-templates'
file: '/ios9.yml'
# iOS
- project: 'libretro-infrastructure/ci-templates'
file: '/ios-arm64.yml'
# tvOS
- project: 'libretro-infrastructure/ci-templates'
file: '/tvos-arm64.yml'
################################## CONSOLES ################################
# Dingux (GCW Zero)
- project: 'libretro-infrastructure/ci-templates'
file: '/dingux-mips32.yml'
# Nintendo 3DS
- project: 'libretro-infrastructure/ci-templates'
file: '/ctr-static.yml'
# Nintendo GameCube
- project: 'libretro-infrastructure/ci-templates'
file: '/ngc-static.yml'
# Nintendo Wii
- project: 'libretro-infrastructure/ci-templates'
file: '/wii-static.yml'
# Nintendo WiiU
- project: 'libretro-infrastructure/ci-templates'
file: '/wiiu-static.yml'
# Nintendo Switch
- project: 'libretro-infrastructure/ci-templates'
file: '/libnx-static.yml'
# PLayStation 2
- project: 'libretro-infrastructure/ci-templates'
file: '/ps2-static.yml'
# PlayStation Vita
- project: 'libretro-infrastructure/ci-templates'
file: '/vita-static.yml'
#################################### MISC ##################################
# Emscripten
- project: 'libretro-infrastructure/ci-templates'
file: '/emscripten-static.yml'
# Stages for building
stages:
- build-prepare
@@ -137,13 +140,7 @@ libretro-build-windows-msvc05-i686:
extends:
- .libretro-windows-i686-msvc05-msys2-make-default
- .core-defs
# linux-cmake.yml
libretro-build-linux-i686:
extends:
- .libretro-linux-cmake-x86
- .core-defs
# Linux 64-bit
libretro-build-linux-x64:
extends:
@@ -162,18 +159,6 @@ libretro-build-osx-arm64:
- .libretro-osx-arm64-make-default
- .core-defs
# osx-cmake-ppc.yml
libretro-build-osx-ppc:
extends:
- .libretro-osx-cmake-ppc
- .core-defs
# osx-cmake-x86.yml
libretro-build-osx-x86: # TODO: What should this be called?
extends:
- .libretro-osx-cmake-x86
- .core-defs
################################### CELLULAR #################################
# Android ARMv7a
android-armeabi-v7a:
@@ -260,12 +245,6 @@ libretro-build-ps2:
- .libretro-ps2-static-retroarch-master
- .core-defs
# psp-static-cmake.yml
libretro-build-psp:
extends:
- .libretro-psp-static-cmake-retroarch-master
- .core-defs
# PlayStation Vita
libretro-build-vita:
extends:
@@ -278,29 +257,3 @@ libretro-build-emscripten:
extends:
- .libretro-emscripten-static-retroarch-master
- .core-defs
libretro-build-dingux-odbeta-mips32:
extends:
- .libretro-dingux-odbeta-cmake-mips32
- .core-defs
libretro-build-miyoo-arm32:
extends:
- .libretro-miyoo-cmake-arm32
- .core-defs
libretro-build-retrofw-mips32:
extends:
- .libretro-retrofw-odbeta-cmake-mips32
- .core-defs
libretro-build-rs90-odbeta-mips32:
extends:
- .libretro-rs90-odbeta-cmake-mips32
- .core-defs
# djgpp-static-cmake.yml
libretro-build-djgpp: # TODO: What should this be called?
extends:
- .libretro-djgpp-static-cmake-retroarch-master
- .core-defs

3
.idea/misc.xml generated
View File

@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakePythonSetting">
<option name="pythonIntegrationState" value="YES" />
</component>
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
<component name="CidrRootsConfiguration">
<sourceRoots>

View File

@@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.13)
project(Mu
VERSION 1.3.3
VERSION 1.3.0
DESCRIPTION "Classic Palm OS Emulator."
HOMEPAGE_URL https://github.com/libretro/Mu
LANGUAGES C CXX)
@@ -17,92 +17,10 @@ message("that you are resting well.")
message(" -- Your friend, Stephanie")
message("******************************")
# Is this x86_32?
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "X86" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_32" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86-32" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i486" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i586" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ia32" OR
"$ENV{ARCH}" STREQUAL "x86")
set(MU_IS_X86_32 YES)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(EMU_DEBUG=1)
endif()
# Some platforms cannot use FPIC code
if(DJGPP OR PLATFORM_PSP OR PSP)
set(MU_FPIC OFF)
else()
set(MU_FPIC ON)
endif()
# Do not include experimental ARM core for some platforms
if(DJGPP OR PLATFORM_PSP OR PSP OR (APPLE AND MU_IS_X86_32))
set(MU_ARM OFF)
else()
set(MU_ARM ON)
endif()
# RetroArch must be static
if(DJGPP OR PLATFORM_PSP OR PSP)
set(MU_LIBRETRO_OBJECT_LIB ON)
else()
set(MU_LIBRETRO_OBJECT_LIB OFF)
endif()
if(MU_LIBRETRO_OBJECT_LIB)
set(MU_CORE_BUILD_TYPE OBJECT)
else()
set(MU_CORE_BUILD_TYPE STATIC)
endif()
# Where should dynamic libraries go when output?
if(NOT DEFINED MU_DYLIB_OUTPUT_DIR)
set(MU_DYLIB_OUTPUT_DIR
"${CMAKE_BINARY_DIR}")
endif()
# Force a specific name for the output resultant binary
macro(mu_target_binary_name target what)
# Base properties
set_target_properties(${target} PROPERTIES
RUNTIME_OUTPUT_NAME "${what}"
LIBRARY_OUTPUT_NAME "${what}"
ARCHIVE_OUTPUT_NAME "${what}")
# Then for each configuration
foreach(outputConfig ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${outputConfig}" outputConfig)
set_target_properties(${target} PROPERTIES
RUNTIME_OUTPUT_NAME_${outputConfig} "${what}"
LIBRARY_OUTPUT_NAME_${outputConfig} "${what}"
ARCHIVE_OUTPUT_NAME_${outputConfig} "${what}")
endforeach()
endmacro()
# Need to set specific locations for output libraries?
# Note that RUNTIME_OUTPUT_DIRECTORY is needed for the Windows build to output
# directories since .DLL files are output there and not where shared libraries
# go??? No idea really.
macro(mu_target_binary_output target where)
set_target_properties(${target} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${where}"
LIBRARY_OUTPUT_DIRECTORY "${where}"
ARCHIVE_OUTPUT_DIRECTORY "${where}")
foreach(outputConfig ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${outputConfig}" outputConfig)
set_target_properties(${target} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_${outputConfig} "${where}"
LIBRARY_OUTPUT_DIRECTORY_${outputConfig} "${where}"
ARCHIVE_OUTPUT_DIRECTORY_${outputConfig} "${where}")
endforeach()
endmacro()
# Main project sources
add_subdirectory(src)

View File

@@ -9,7 +9,7 @@ struct LiteralRef {
uintptr_t value;
};
static size_t MAX_LITERALS = 1024;
static constexpr size_t MAX_LITERALS = 1024;
static LiteralRef literals[MAX_LITERALS];
static size_t literals_count = 0;

View File

@@ -710,6 +710,7 @@ static void setUstcnt2(uint16_t value){
registerArrayWrite16(USTCNT2, value);
updateUart2Interrupt();
updateUart2PortState();
}
static void setTstat1(uint16_t value){

View File

@@ -404,6 +404,9 @@ static void dbvzEndClk32(void){
updateUart1Interrupt();
updateUart2Interrupt();
updateUart1PortState();
updateUart2PortState();
checkInterrupts();
}

View File

@@ -109,7 +109,7 @@ enum{
};
//types
typedef struct{
typedef struct {
bool enable;
bool enableParity;
bool oddParity;
@@ -215,7 +215,11 @@ extern void (*palmSerialDataFlush)(void);//called by the emulator to delete
extern void (*palmGetRtcFromHost)(uint8_t* writeBack);//[0] = hours, [1] = minutes, [2] = seconds
//functions
uint32_t emulatorInit(uint8_t emulatedDevice, uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmBootloaderData, uint32_t palmBootloaderSize, bool syncRtc, bool allowInvalidBehavior);
uint32_t emulatorInit(uint8_t emulatedDevice, uint8_t *palmRomData,
uint32_t palmRomSize, uint8_t *palmBootloaderData,
uint32_t palmBootloaderSize, bool syncRtc,
bool allowInvalidBehavior, const char *serialPortDev);
void emulatorDeinit(void);
void emulatorHardReset(void);
void emulatorSoftReset(void);

18
include/serial.h Normal file
View File

@@ -0,0 +1,18 @@
//
// Created by stephanie on 6/14/24.
//
#ifndef MU_SERIAL_H
#define MU_SERIAL_H
#include "emulator.h"
/**
* Opens and initializes the serial port.
*
* @param path The path of the serial port.
* @since 2024/06/14
*/
void mu_serial_open_and_init(const char* path);
#endif // MU_SERIAL_H

View File

@@ -1,15 +1,4 @@
if(MU_LIBRETRO_OBJECT_LIB)
set(MU_LIBRETRO_OBJECT_LIB_USE
$<TARGET_OBJECTS:MuCore>
$<TARGET_OBJECTS:MuCoreFileLauncher>
$<TARGET_OBJECTS:MuCoreAudio>
$<TARGET_OBJECTS:MuCoreM68k>)
else()
set(MU_LIBRETRO_OBJECT_LIB_USE)
endif()
add_library(mu_libretro SHARED
${MU_LIBRETRO_OBJECT_LIB_USE}
libretro.c
cursors.c
miniz.c
@@ -25,34 +14,19 @@ add_library(mu_libretro SHARED
# Remove the "lib" prefix always, RetroArch does not name in this way
set_target_properties(mu_libretro PROPERTIES PREFIX "")
# Define these
target_compile_definitions(mu_libretro PUBLIC
__LIBRETRO__=1)
# Bring all the sub-modules as needed
if(NOT MU_LIBRETRO_OBJECT_LIB)
target_link_libraries(mu_libretro
MuCore)
endif()
target_link_libraries(mu_libretro
MuCore)
# Include the required includes
target_include_directories(mu_libretro PUBLIC
"${PROJECT_SOURCE_DIR}/include"
"libretro-common/include")
# Name must be specifically set for RetroArch for it to work properly
if(ANDROID OR (DEFINED ANDROID_PLATFORM AND ANDROID_PLATFORM))
mu_target_binary_name(mu_libretro
"mu_libretro_android")
else()
mu_target_binary_name(mu_libretro
"mu_libretro${LIBRETRO_SUFFIX}")
endif()
# Library location must be placed in the build output for the RetroArch
# build system to pick up the library
# Note that RUNTIME_OUTPUT_DIRECTORY is needed for the Windows build to output
# directories since .DLL files are output there and not where shared libraries
# go??? No idea really.
mu_target_binary_output(mu_libretro
"${MU_DYLIB_OUTPUT_DIR}")
# Custom launching the core, tries to find RetroArch on the system
## Determine RetroArch directory
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
@@ -77,9 +51,4 @@ if(DEFINED MU_LIBRETRO_DIR)
COMMAND "${MU_LIBRETRO_DIR}/retroarch${MU_LIBRETRO_EXTENSION}" "-v" "-L" "$<TARGET_FILE:mu_libretro>"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
COMMENT "Starting RetroArch with Mu")
# Do not try running this by default
set_target_properties(RetroArch PROPERTIES
EXCLUDE_FROM_ALL TRUE
EXCLUDE_FROM_DEFAULT_BUILD TRUE)
endif()

View File

@@ -126,10 +126,9 @@ else ifeq ($(platform), osx)
ifeq ($(arch),ppc)
CFLAGS += -D__ppc__ -DMSB_FIRST -DWORDS_BIGENDIAN=1
endif
OSXMAJVER = $(shell sw_vers -productVersion | cut -d. -f 1)
OSXMINVER = $(shell sw_vers -productVersion | cut -d. -f 2)
OSX_LT_MAVERICKS = $(shell (( $(OSXMAJVER) == 10 )) && (( $(OSXMINVER) <= 9)) && echo "YES")
OSX_GT_MOJAVE = $(shell (( $(OSXMAJVER) > 10 )) || (( $(OSXMINVER) >= 14)) && echo "YES")
OSXVER = $(shell sw_vers -productVersion | cut -d. -f 2)
OSX_LT_MAVERICKS = $(shell (( $(OSXVER) <= 9)) && echo "YES")
OSX_GT_MOJAVE = $(shell (( $(OSXVER) >= 14)) && echo "YES")
ifeq ($(OSX_LT_MAVERICKS),"YES")
fpic += -mmacosx-version-min=10.5
@@ -147,7 +146,7 @@ endif
CFLAGS += $(TARGET_RULE)
CPPFLAGS += $(TARGET_RULE)
CXXFLAGS += $(TARGET_RULE)
LDFLAGS += $(TARGET_RULE) -lc++
LDFLAGS += $(TARGET_RULE)
endif
# iOS
@@ -189,8 +188,6 @@ ifeq ($(IOSSDK),)
endif
CC = clang -arch arm64 -isysroot $(IOSSDK)
CXX = clang++ -arch arm64 -isysroot $(IOSSDK)
CC += -mappletvos-version-min=11.0
CFLAGS += -mappletvos-version-min=11.0
# Theos iOS
else ifeq ($(platform), theos_ios)

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 2010-2020 The RetroArch team
/* Copyright (C) 2010-2018 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (memmap.h).
@@ -26,7 +26,7 @@
#include <stdio.h>
#include <stdint.h>
#if defined(PSP) || defined(PS2) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS) || defined(WIIU) || defined(SWITCH) || defined(HAVE_LIBNX) || defined(__PS3__) || defined(__PSL1GHT__) || defined(DJGPP)
#if defined(__PS3__) || defined(PSP) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS) || defined(WIIU) || defined(SWITCH)
/* No mman available */
#elif defined(_WIN32) && !defined(_XBOX)
#include <windows.h>
@@ -49,4 +49,4 @@ int memsync(void *start, void *end);
int memprotect(void *addr, size_t len);
#endif
#endif

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 2010-2020 The RetroArch team
/* Copyright (C) 2010-2018 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (memmap.c).
@@ -21,7 +21,6 @@
*/
#include <stdint.h>
#include <stdlib.h>
#include <memmap.h>
#ifndef PROT_READ
@@ -131,14 +130,14 @@ int mprotect(void *addr, size_t len, int prot)
#endif
#if defined(__MACH__) && (defined(__arm__) || defined(__arm64__))
#if defined(__MACH__) && defined(__arm__)
#include <libkern/OSCacheControl.h>
#endif
int memsync(void *start, void *end)
{
size_t len = (char*)end - (char*)start;
#if defined(__MACH__) && (defined(__arm__) || defined(__arm64__))
#if defined(__MACH__) && defined(__arm__)
sys_dcache_flush(start ,len);
sys_icache_invalidate(start, len);
return 0;
@@ -161,4 +160,4 @@ int memsync(void *start, void *end)
int memprotect(void *addr, size_t len)
{
return mprotect(addr, len, PROT_READ | PROT_WRITE | PROT_EXEC);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@ supported_extensions = "prc|pqa|img|pdb|zip"
corename = "Mu"
license = "CC BY-NC 3.0 US (Non-commercial)"
permissions = ""
display_version = "v1.3.4"
display_version = "v1.3.1"
categories = "Emulator"
# Hardware Information

View File

@@ -1,7 +1,7 @@
# Only include the sub-project if Qt was actually found
find_package(Qt5 COMPONENTS Core Gui Widgets Multimedia Svg)
find_package(Qt5 OPTIONAL_COMPONENTS Core Widgets)
if(Qt5_FOUND EQUAL 0)
message("Qt5 or one of their components were not found, check readme.md!")
message("Qt5 was not found by CMake, check readme.md!")
endif()
# Was this actually found now?

View File

@@ -167,60 +167,61 @@ support_palm_os5{
../../src/armv5te/mem.c \
../../src/armv5te/mmu.c \
../../src/tps65010.c \
../../src/pxa260/tsc2101.c \
../../src/tsc2101.c \
../../src/w86l488.c
HEADERS += \
../../include/pxa260/pxa260_CPU.h \
../../include/pxa260/pxa260_DMA.h \
../../include/pxa260/pxa260_DSP.h \
../../include/pxa260/pxa260_GPIO.h \
../../include/pxa260/pxa260_IC.h \
../../include/pxa260/pxa260_LCD.h \
../../include/pxa260/pxa260_PwrClk.h \
../../include/pxa260/pxa260_RTC.h \
../../include/pxa260/pxa260_TIMR.h \
../../include/pxa260/pxa260_UART.h \
../../include/pxa260/pxa260I2c.h \
../../include/pxa260/pxa260Memctrl.h \
../../include/pxa260/pxa260Timing.h \
../../include/pxa260/pxa260Ssp.h \
../../include/pxa260/pxa260Udc.h \
../../include/pxa260/pxa260_types.h \
../../include/pxa260/pxa260_math64.h \
../../include/pxa260/pxa260Accessors.c.h \
../../include/pxa260/pxa260.h \
../../include/armv5te/os/os.h \
../../include/armv5te/uArm/CPU_2.h \
../../include/armv5te/uArm/icache.h \
../../include/armv5te/uArm/uArmGlue.h \
../../include/armv5te/asmcode.h \
../../include/armv5te/bitfield.h \
../../include/armv5te/cpu.h \
../../include/armv5te/disasm.h \
../../include/armv5te/emu.h \
../../include/armv5te/mem.h \
../../include/armv5te/translate.h \
../../include/armv5te/cpudefs.h \
../../include/armv5te/debug.h \
../../include/armv5te/mmu.h \
../../include/armv5te/armsnippets.h \
../../include/armv5te/literalpool.h \
../../include/tungstenT3Bus.h \
../../include/tps65010.h \
../../include/tsc2101.h \
../../include/w86l488.h
../../src/pxa260/pxa260_CPU.h \
../../src/pxa260/pxa260_DMA.h \
../../src/pxa260/pxa260_DSP.h \
../../src/pxa260/pxa260_GPIO.h \
../../src/pxa260/pxa260_IC.h \
../../src/pxa260/pxa260_LCD.h \
../../src/pxa260/pxa260_PwrClk.h \
../../src/pxa260/pxa260_RTC.h \
../../src/pxa260/pxa260_TIMR.h \
../../src/pxa260/pxa260_UART.h \
../../src/pxa260/pxa260I2c.h \
../../src/pxa260/pxa260Memctrl.h \
../../src/pxa260/pxa260Timing.h \
../../src/pxa260/pxa260Ssp.h \
../../src/pxa260/pxa260Udc.h \
../../src/pxa260/pxa260_types.h \
../../src/pxa260/pxa260_math64.h \
../../src/pxa260/pxa260Accessors.c.h \
../../src/pxa260/pxa260.h \
../../src/armv5te/os/os.h \
../../src/armv5te/uArm/CPU_2.h \
../../src/armv5te/uArm/icache.h \
../../src/armv5te/uArm/uArmGlue.h \
../../src/armv5te/asmcode.h \
../../src/armv5te/bitfield.h \
../../src/armv5te/cpu.h \
../../src/armv5te/disasm.h \
../../src/armv5te/emu.h \
../../src/armv5te/mem.h \
../../src/armv5te/translate.h \
../../src/armv5te/cpudefs.h \
../../src/armv5te/debug.h \
../../src/armv5te/mmu.h \
../../src/armv5te/armsnippets.h \
../../src/armv5te/literalpool.h \
../../src/tungstenT3Bus.h \
../../src/tps65010.h \
../../src/tsc2101.h \
../../src/w86l488.h
}
CONFIG += c++11
INCLUDEPATH += $$PWD/../../include
INCLUDEPATH += $$PWD/qt-common/include
SOURCES += \
../../src/ads7846.c \
../../src/audio/blip_buf.c \
../../src/dbvz.c \
../../src/emulator.c \
../../src/serial.c \
../../src/fileLauncher/launcher.c \
../../src/flx68000.c \
../../src/m5XXBus.c \
@@ -243,32 +244,32 @@ SOURCES += \
settingsmanager.cpp
HEADERS += \
../../include/ads7846.h \
../../include/audio/blip_buf.h \
../../include/dbvz.h \
../../include/dbvzRegisterAccessors.c.h \
../../include/dbvzRegisterNames.c.h \
../../include/dbvzTiming.c.h \
../../include/emulator.h \
../../include/fileLauncher/launcher.h \
../../include/flx68000.h \
../../include/m5XXBus.h \
../../include/m68k/m68k.h \
../../include/m68k/m68kconf.h \
../../include/m68k/m68kcpu.h \
../../include/m68k/m68kexternal.h \
../../include/m68k/m68kops.h \
../../include/pdiUsbD12.h \
../../include/pdiUsbD12CommandNames.c.h \
../../include/portability.h \
../../include/sdCard.h \
../../include/sdCardAccessors.c.h \
../../include/sdCardCommandNames.c.h \
../../include/sdCardCrcTables.c.h \
../../include/sed1376.h \
../../include/sed1376Accessors.c.h \
../../include/sed1376RegisterNames.c.h \
../../include/silkscreen.h \
../../src/ads7846.h \
../../src/audio/blip_buf.h \
../../src/dbvz.h \
../../src/dbvzRegisterAccessors.c.h \
../../src/dbvzRegisterNames.c.h \
../../src/dbvzTiming.c.h \
../../src/emulator.h \
../../src/fileLauncher/launcher.h \
../../src/flx68000.h \
../../src/m5XXBus.h \
../../src/m68k/m68k.h \
../../src/m68k/m68kconf.h \
../../src/m68k/m68kcpu.h \
../../src/m68k/m68kexternal.h \
../../src/m68k/m68kops.h \
../../src/pdiUsbD12.h \
../../src/pdiUsbD12CommandNames.c.h \
../../src/portability.h \
../../src/sdCard.h \
../../src/sdCardAccessors.c.h \
../../src/sdCardCommandNames.c.h \
../../src/sdCardCrcTables.c.h \
../../src/sed1376.h \
../../src/sed1376Accessors.c.h \
../../src/sed1376RegisterNames.c.h \
../../src/silkscreen.h \
debugviewer.h \
emuwrapper.h \
mainwindow.h \

File diff suppressed because it is too large Load Diff

View File

@@ -54,7 +54,9 @@ public:
EmuWrapper();
~EmuWrapper();
uint32_t init(const QString& assetPath, const QString& osVersion, bool syncRtc = false, bool allowInvalidBehavior = false, bool fastBoot = false);
uint32_t init(const QString &assetPath, const QString &osVersion,
bool syncRtc = false, bool allowInvalidBehavior = false,
bool fastBoot = false, const QString &serialPortDev = "");
void exit();
void pause();
void resume();

View File

@@ -333,7 +333,14 @@ void MainWindow::on_center_released(){
void MainWindow::on_ctrlBtn_clicked(){
if(!emu.isInited()){
QString sysDir = settings->value("resourceDirectory", "").toString();
uint32_t error = emu.init(sysDir, settings->value("palmOsVersionString", "Palm m515/Palm OS 4.1").toString(), settings->value("featureSyncedRtc", false).toBool(), settings->value("featureDurable", false).toBool(), settings->value("fastBoot", false).toBool());
uint32_t error = emu.init(
sysDir,
settings->value("palmOsVersionString", "Palm m515/Palm OS 4.1")
.toString(),
settings->value("featureSyncedRtc", false).toBool(),
settings->value("featureDurable", false).toBool(),
settings->value("fastBoot", false).toBool(),
settings->value("serialPortDev", "").toString());
if(error == EMU_ERROR_NONE){
emu.setCpuSpeed(settings->value("cpuSpeed", 1.00).toDouble());

View File

@@ -31,6 +31,10 @@ SettingsManager::SettingsManager(QWidget* parent) :
ui->featureSyncedRtc->setChecked(settings->value("featureSyncedRtc", false).toBool());
ui->featureDurable->setChecked(settings->value("featureDurable", false).toBool());
ui->serialPortDev->setText(settings->value("serialPortDev",
"").toString());
connect(ui->serialPortDev, &QLineEdit::textChanged, this, &SettingsManager::on_serialPortDev_textChanged);
setKeySelectorState(-1);
updateButtonKeys();
}
@@ -166,3 +170,7 @@ void SettingsManager::on_palmOsVersion_currentIndexChanged(int index){
settings->setValue("palmOsVersionIndex", index);
settings->setValue("palmOsVersionString", ui->palmOsVersion->itemText(index));
}
void SettingsManager::on_serialPortDev_textChanged(const QString& arg1) {
settings->setValue("serialPortDev", ui->serialPortDev->text());
}

View File

@@ -51,6 +51,8 @@ private slots:
void on_cpuSpeed_valueChanged(double arg1);
void on_palmOsVersion_currentIndexChanged(int index);
void on_serialPortDev_textChanged(const QString& arg1);
private:
Ui::SettingsManager* ui;
QSettings* settings;

View File

@@ -29,9 +29,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-284</y>
<width>613</width>
<height>444</height>
<height>705</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -430,6 +430,16 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="serialPortDevLabel">
<property name="text">
<string>Serial Port Device</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="serialPortDev"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@@ -1,9 +1,9 @@
# Mu, a Palm OS Emulator
> The continuation of the Mu along with the RetroArch Core is dedicated to
The continuation of the Mu along with the RetroArch Core is dedicated to
Emily (1998-2020), your friendship was very important to me and I hope
that you are resting well.
> -- _Your friend, Stephanie_
-- Your friend, Stephanie
# The goal of this project
@@ -38,12 +38,6 @@ https://findicons.com/icon/164302/cursor (Libretro Port Joystick Cursor)
## Building
For systems supported by RetroArch, you may download builds
directly from and install them manually, if not using the
_Online Updater_ functionality:
* <https://git.libretro.com/libretro/Mu/-/pipelines>
#### Using CMake
Using CMake, you just need to do:
@@ -54,21 +48,6 @@ Using CMake, you just need to do:
#### For RetroArch
There are two options available for RetroArch, you can use CMake
to build the core, or you can use the older Makefile based setup.
The Makefile based setup is for the older RetroArch build system.
##### CMake
Same as above for _CMake_, the RetroArch specific target is
in this case `mu_libretro`. This will output a file accordingly.
Note that if you are using a system which uses static binaries,
such as the PS2 or 3DS, there are other steps you must complete,
although it is recommended to just download from
here <https://git.libretro.com/libretro/Mu/-/pipelines>.
##### Makefile
Make sure you have done all the steps here https://docs.libretro.com/ under "For Developers/Compilation" so you build environment works.
cd ./libretroBuildSystem
@@ -79,20 +58,12 @@ load that ZIP file. PDBs will be installed first followed by PRC files.
#### For Qt
First install _Qt 5.14.2_, you may optionally install as well _Qt Creator_.
First install _Qt 5.14.2_, you may optional install as well _Qt Creator_.
* Windows: <https://download.qt.io/archive/qt/5.14/5.14.2/qt-opensource-windows-x86-5.14.2.exe>
* Mac: <https://download.qt.io/archive/qt/5.14/5.14.2/qt-opensource-mac-x64-5.14.2.dmg>
* Linux: <https://download.qt.io/archive/qt/5.14/5.14.2/qt-opensource-linux-x64-5.14.2.run>
You need the following components of Qt5:
* Core
* Gui
* Widgets
* Multimedia
* Svg
When running _CMake_ you will need to pass `-DCMAKE_PREFIX_PATH` to the
location of `Qt5Config.cmake`.
@@ -123,42 +94,26 @@ Install prc-tools from the below link(self compiled or prepackaged VM)
./make.sh
## Running
#### Files
* `palmos40-en-m500.rom`:
* `f50e4d5e4d98dc831f2c34a9107651eb` (MD5)
* `palmos41-en-m515.rom`:
* `83cb1d1c76e568b916dc2e7c0bf669f6` (MD5)
* `palmos52-en-t3.rom`:
* `de46ec84d9aabf655eabdf9b00a3845d` (MD5)
* `bootloader-dbvz.rom`:
* `9da101cd2317830649a31f8fa46debec` (MD5)
palmos40-en-m500.rom: f50e4d5e4d98dc831f2c34a9107651eb (MD5)
palmos41-en-m515.rom: 83cb1d1c76e568b916dc2e7c0bf669f6 (MD5)
palmos52-en-t3.rom: de46ec84d9aabf655eabdf9b00a3845d (MD5)
bootloader-dbvz.rom: 9da101cd2317830649a31f8fa46debec (MD5)
#### For Qt
1. Run once to create the directory tree
2. Copy "palmos41-en-m515.rom" and "palmos52-en-t3.rom" to "~/Mu"
3. (Optional)Copy "bootloader-en-m515.rom" to "~/Mu"
4. Run emu and press start button
#### For RetroArch
1. Download "Palm OS(Mu)" from "Online Updater->Core Updater"
1. Alternatively, you can install a locally compiled or
downloaded core from another source and place it within
RetroArch's `cores/` directory. If you do this, remember
to also install `mu_libretro.info` (which is located
in `libretroBuildSystem`) to the directory as well so
it knows which files are supported.
2. Go back, select _Load Core_, select _Palm OS (Mu)_
3. Copy `palmos41-en-m515.rom` to the RetroArch system directory
1. For experimental Palm OS 5 support: `palmos52-en-t3.rom`.
4. (Optional) Copy "bootloader-en-m515.rom" to the RetroArch system directory
5. Load a `.prc`, `.img`, or `.zip` file.
1. Download "Palm OS(Mu)" from "Online Updater->Core Updater"
2. Go back, select "Load Core", select "Palm OS(Mu)"
3. Copy "palmos41-en-m515.rom" and "palmos52-en-t3.rom" to the RetroArch system directory
4. (Optional)Copy "bootloader-en-m515.rom" to the RetroArch system directory
5. Run a .prc or .img file
## Tools
[Prc-tools, Palm OS SDKs, pilrc, pilot-link](https://github.com/meepingsnesroms/prc-tools-remix)
## License

View File

@@ -1,8 +1,9 @@
# Base Mu library
add_library(MuCore ${MU_CORE_BUILD_TYPE}
add_library(MuCore STATIC
ads7846.c
dbvz.c
emulator.c
serial.c
flx68000.c
m5XXBus.c
pdiUsbD12.c
@@ -10,27 +11,19 @@ add_library(MuCore ${MU_CORE_BUILD_TYPE}
sed1376.c
silkscreen.c
tps65010.c
tsc2101.c
w86l488.c)
# Make this position independent so it can be linked into shared libraries
if(MU_FPIC)
set_property(TARGET MuCore
PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
set_property(TARGET MuCore
PROPERTY POSITION_INDEPENDENT_CODE ON)
# Bring all the sub-modules as needed
if(MU_ARM)
target_link_libraries(MuCore
MuCorePxa260Experimental
MuCoreFileLauncher
MuCoreAudio
MuCoreM68k)
else()
target_link_libraries(MuCore
MuCoreFileLauncher
MuCoreAudio
MuCoreM68k)
endif()
target_link_libraries(MuCore
MuCorePxa260Experimental
MuCoreFileLauncher
MuCoreAudio
MuCoreM68k)
# Includes for the project
target_include_directories(MuCore PUBLIC
@@ -45,7 +38,5 @@ add_subdirectory(fileLauncher)
add_subdirectory(m68k)
# Experimental ARM Cores
if(MU_ARM)
add_subdirectory(armv5te)
add_subdirectory(pxa260)
endif()
add_subdirectory(armv5te)
add_subdirectory(pxa260)

View File

@@ -14,10 +14,8 @@ add_library(MuCoreArmV5TEExperimental STATIC
thumb_interpreter.cpp)
# Make this position independent so it can be linked into shared libraries
if(MU_FPIC)
set_property(TARGET MuCoreArmV5TEExperimental
PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
set_property(TARGET MuCoreArmV5TEExperimental
PROPERTY POSITION_INDEPENDENT_CODE ON)
# Currently do not enable the dynamic recompiler
set(NO_TRANSLATION)
@@ -36,7 +34,7 @@ else()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES arm)
target_sources(MuCoreArmV5TEExperimental PUBLIC
translate_arm.cpp)
elseif(MU_IS_X86_32 OR CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(i386)")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(i386)")
target_sources(MuCoreArmV5TEExperimental PUBLIC
translate_x86.c)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(x86-64)|(amd64)|(AMD64)")

View File

@@ -219,7 +219,7 @@ void cpu_int_check()
cpu_events &= ~EVENT_FIQ;
}
static const uint8_t exc_flags[] = {
static const constexpr uint8_t exc_flags[] = {
MODE_SVC | 0xC0, /* Reset */
MODE_UND | 0x80, /* Undefined instruction */
MODE_SVC | 0x80, /* Software interrupt */

View File

@@ -3,7 +3,7 @@
#include "armv5te/debug.h"
#include "armv5te/disasm.h"
#include "armv5te/emu.h"
#include "armv5te/mmu.h"
char disasmReturnBuf[80];

View File

@@ -176,7 +176,7 @@ enum Reg : uint8_t {
static int8_t regmap_v2p[16];
/* R0 is used as scratch register. R10 is a pointer to struct arm_state, R11 contains flags. */
static const uint8_t regmap_first_phys = R1, regmap_last_phys = R9;
static constexpr const uint8_t regmap_first_phys = R1, regmap_last_phys = R9;
/* Shortcut. If anything has been mapped, this is true.
Set by regmap_next_preg, unset by regmap_flush. */

View File

@@ -1,12 +1,10 @@
# m68k Module
add_library(MuCoreAudio ${MU_CORE_BUILD_TYPE}
add_library(MuCoreAudio STATIC
blip_buf.c)
# Make this position independent so it can be linked into shared libraries
if(MU_FPIC)
set_property(TARGET MuCoreAudio
PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
set_property(TARGET MuCoreAudio
PROPERTY POSITION_INDEPENDENT_CODE ON)
# Includes for the project
target_include_directories(MuCoreAudio PUBLIC

View File

@@ -475,17 +475,26 @@ uint8_t dbvzGetRegister8(uint32_t address){
//PDSEL lacks the bottom 4 bits but that is handled on write
return registerArrayRead8(address);
case URX1:
case URX1 + 1:
case URX2:
case URX2 + 1:
return registerArrayRead16(address);
default:
printHwRegAccess(address, 0, 8, false);
//bootloader
if(address >= 0xE00)
return registerArrayRead8(address);
printHwRegAccess(address, 0, 8, false);
return 0x00;
}
}
uint16_t dbvzGetRegister16(uint32_t address){
uint16_t bit;
#if !defined(EMU_NO_SAFETY)
if((address & 0x0000F000) != 0x0000F000){
dbvzSetBusErrorTimeOut(address, false);
@@ -520,6 +529,16 @@ uint16_t dbvzGetRegister16(uint32_t address){
}
case UTX1:{
#if defined(EMU_DEBUG)
printHwRegAccess(address, 0, 16, false);
#endif
uint16_t dataFlag = 0;
if (palmIrDataSize != NULL)
if (palmIrDataSize() > 0) {
dataFlag = 0x4000; // byte swapped
updateUart1Interrupt();
}
uint16_t uart1TxStatus = registerArrayRead16(UTX1);
uint8_t entrys = uart1TxFifoEntrys();
@@ -527,10 +546,20 @@ uint16_t dbvzGetRegister16(uint32_t address){
uart1TxStatus |= (entrys < 4) << 14;
uart1TxStatus |= (entrys < 8) << 13;
return uart1TxStatus;
return uart1TxStatus | dataFlag;
}
case UTX2:{
#if defined(EMU_DEBUG)
printHwRegAccess(address, 0, 16, false);
#endif
uint16_t dataFlag = 0;
if (palmSerialDataSize != NULL)
if (palmSerialDataSize() > 0) {
dataFlag = 0x4000; // byte swapped
updateUart2Interrupt();
}
uint16_t uart2TxStatus = registerArrayRead16(UTX2);
uint8_t entrys = uart2TxFifoEntrys();
@@ -538,7 +567,7 @@ uint16_t dbvzGetRegister16(uint32_t address){
uart2TxStatus |= (entrys < 4) << 14;
uart2TxStatus |= (entrys < 8) << 13;
return uart2TxStatus;
return uart2TxStatus | dataFlag;
}
case PLLFSR:
@@ -599,11 +628,12 @@ uint16_t dbvzGetRegister16(uint32_t address){
return registerArrayRead16(address);
default:
printHwRegAccess(address, 0, 16, false);
//bootloader
if(address >= 0xE00)
return registerArrayRead16(address);
printHwRegAccess(address, 0, 16, false);
return 0x0000;
}
}
@@ -668,6 +698,7 @@ void dbvzSetRegister8(uint32_t address, uint8_t value){
if((registerArrayRead16(USTCNT2) & 0xA000) == 0xA000){
uart2TxFifoWrite(value);
updateUart2Interrupt();
updateUart2PortState();
}
return;
@@ -1128,6 +1159,7 @@ void dbvzSetRegister16(uint32_t address, uint16_t value){
if((registerArrayRead16(USTCNT2) & 0xA000) == 0xA000){
uart2TxFifoWrite(value & 0x1000 ? value & 0xFF : EMU_SERIAL_BREAK);
updateUart2Interrupt();
updateUart2PortState();
}
return;

View File

@@ -11,6 +11,7 @@
#include "ads7846.h"
#include "pdiUsbD12.h"
#include "sdCard.h"
#include "serial.h"
#include "silkscreen.h"
#include "portability.h"
#if defined(EMU_SUPPORT_PALM_OS5)
@@ -117,7 +118,10 @@ void mu_garbage_fill(uint8_t* ram, uint32_t size) {
}
}
uint32_t emulatorInit(uint8_t emulatedDevice, uint8_t* palmRomData, uint32_t palmRomSize, uint8_t* palmBootloaderData, uint32_t palmBootloaderSize, bool syncRtc, bool allowInvalidBehavior){
uint32_t emulatorInit(uint8_t emulatedDevice, uint8_t *palmRomData,
uint32_t palmRomSize, uint8_t *palmBootloaderData,
uint32_t palmBootloaderSize, bool syncRtc,
bool allowInvalidBehavior, const char *serialPortDev) {
if(emulatorInitialized)
return EMU_ERROR_RESOURCE_LOCKED;
@@ -132,13 +136,19 @@ uint32_t emulatorInit(uint8_t emulatedDevice, uint8_t* palmRomData, uint32_t pal
palmIrDataReceive = NULL;
palmIrDataSend = NULL;
palmIrDataFlush = NULL;
palmSerialSetPortProperties = NULL;
palmSerialDataSize = NULL;
palmSerialDataReceive = NULL;
palmSerialDataSend = NULL;
palmSerialDataFlush = NULL;
palmGetRtcFromHost = NULL;
// Setup serial port
palmSerialSetPortProperties = NULL;
palmSerialDataSize = NULL;
palmSerialDataReceive = NULL;
palmSerialDataSend = NULL;
palmSerialDataFlush = NULL;
if (serialPortDev != NULL) {
mu_serial_open_and_init(serialPortDev);
}
#if defined(EMU_SUPPORT_PALM_OS5)
palmEmulatingTungstenT3 = emulatedDevice == EMU_DEVICE_TUNGSTEN_T3;

View File

@@ -3,10 +3,8 @@ add_library(MuCoreFileLauncher STATIC
launcher.c)
# Make this position independent so it can be linked into shared libraries
if(MU_FPIC)
set_property(TARGET MuCoreFileLauncher
PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
set_property(TARGET MuCoreFileLauncher
PROPERTY POSITION_INDEPENDENT_CODE ON)
# Includes for the project
target_include_directories(MuCoreFileLauncher PUBLIC

View File

@@ -1,5 +1,5 @@
# m68k Module
add_library(MuCoreM68k ${MU_CORE_BUILD_TYPE}
add_library(MuCoreM68k STATIC
m68kcpu.c
m68kdasm.c
m68kopac.c
@@ -8,10 +8,8 @@ add_library(MuCoreM68k ${MU_CORE_BUILD_TYPE}
m68kops.c)
# Make this position independent so it can be linked into shared libraries
if(MU_FPIC)
set_property(TARGET MuCoreM68k
PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
set_property(TARGET MuCoreM68k
PROPERTY POSITION_INDEPENDENT_CODE ON)
# Includes for the project
target_include_directories(MuCoreM68k PUBLIC

View File

@@ -1,5 +1,6 @@
EMU_DEFINES :=
EMU_SOURCES_C := $(EMU_PATH)/emulator.c \
$(EMU_PATH)/serial.c \
$(EMU_PATH)/m5XXBus.c \
$(EMU_PATH)/dbvz.c \
$(EMU_PATH)/flx68000.c \
@@ -48,7 +49,7 @@ ifeq ($(EMU_SUPPORT_PALM_OS5), 1)
$(EMU_PATH)/armv5te/mem.c \
$(EMU_PATH)/armv5te/mmu.c \
$(EMU_PATH)/tps65010.c \
$(EMU_PATH)/pxa260/tsc2101.c \
$(EMU_PATH)/tsc2101.c \
$(EMU_PATH)/w86l488.c
EMU_SOURCES_CXX += $(EMU_PATH)/armv5te/arm_interpreter.cpp \
$(EMU_PATH)/armv5te/thumb_interpreter.cpp \

View File

@@ -14,14 +14,11 @@ add_library(MuCorePxa260Experimental STATIC
pxa260Memctrl.c
pxa260Ssp.c
pxa260Timing.c
pxa260Udc.c
tsc2101.c)
pxa260Udc.c)
# Make this position independent so it can be linked into shared libraries
if(MU_FPIC)
set_property(TARGET MuCorePxa260Experimental
PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
set_property(TARGET MuCorePxa260Experimental
PROPERTY POSITION_INDEPENDENT_CODE ON)
# Bring all the sub-modules as needed
target_link_libraries(MuCorePxa260Experimental

255
src/serial.c Normal file
View File

@@ -0,0 +1,255 @@
//
// Created by stephanie on 6/14/24.
//
#include <stdio.h>
#include <string.h>
#if defined(__LIBRETRO__)
#elif defined(_WIN32)
#include <windows.h>
#else
#include <errno.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#endif
#include "emulator.h"
#define MU_SERIAL_DEBUG
#define MU_SERIAL_BUF_SIZE 4096
static const char* mu_serial_path = NULL;
#if defined(__LIBRETRO__)
#elif defined(_WIN32)
#else
static int mu_serial_fd = -1;
#endif
static uint8_t mu_serial_buf[MU_SERIAL_BUF_SIZE];
static int32_t mu_serial_buf_len;
static serial_port_properties_t mu_serial_properties;
void mu_serial_palmSerialSetPortProperties(serial_port_properties_t* properties)
{
#if defined(__LIBRETRO__)
#elif defined(_WIN32)
#else
struct termios tty;
#endif
// Always use base properties
if (properties == NULL) {
properties = &mu_serial_properties;
}
// Did the properties not actually change?
if (0 == memcmp(properties, &mu_serial_properties,
sizeof(mu_serial_properties))) {
return;
}
#if defined(MU_SERIAL_DEBUG)
// Debug
fprintf(stderr, "Serial PROPERTIES\n");
#endif
// Write over new properties
memmove(&mu_serial_properties, properties,
sizeof(mu_serial_properties));
#if defined(__LIBRETRO__)
#elif defined(_WIN32)
#else
if (properties->enable && mu_serial_fd < 0) {
#if defined(MU_SERIAL_DEBUG)
// Debug
fprintf(stderr, "Serial OPEN %s\n", mu_serial_path);
#endif
mu_serial_fd = open(mu_serial_path,
O_RDWR | O_EXCL | O_NONBLOCK);
if (mu_serial_fd < 0) {
fprintf(stderr, "Serial FAIL %s\n",
strerror(errno));
return;
}
mu_serial_buf_len = 0;
} else if (!properties->enable && mu_serial_fd >= 0) {
#if defined(MU_SERIAL_DEBUG)
// Debug
fprintf(stderr, "Serial CLOSE %s\n", mu_serial_path);
#endif
close(mu_serial_fd);
mu_serial_fd = -1;
mu_serial_buf_len = 0;
}
if (mu_serial_fd >= 0) {
memset(&tty, 0, sizeof(tty));
cfsetspeed(&tty, properties->baudRate);
if (properties->enableParity) {
tty.c_cflag |= PARENB;
}
if (properties->oddParity) {
tty.c_cflag |= PARODD;
}
if (properties->stopBits > 1) {
tty.c_cflag |= CSTOPB;
} else {
tty.c_cflag &= (~CSTOPB);
}
if (properties->use8BitMode) {
tty.c_cflag |= CS8;
} else {
tty.c_lflag &= (~CSIZE);
tty.c_cflag |= CS7;
}
}
#endif
}
uint32_t mu_serial_palmSerialDataSize(void)
{
int32_t read_count;
// Do not read any more data if there is any
if (mu_serial_buf_len > 0) {
return mu_serial_buf_len;
}
#if defined(__LIBRETRO__)
#elif defined(_WIN32)
#else
if (mu_serial_fd >= 0) {
// Try reading in as much as possible
if (mu_serial_buf_len < MU_SERIAL_BUF_SIZE) {
read_count = read(mu_serial_fd,
&mu_serial_buf[mu_serial_buf_len],
MU_SERIAL_BUF_SIZE - mu_serial_buf_len);
if (read_count > 0) {
mu_serial_buf_len += read_count;
#if defined(MU_SERIAL_DEBUG)
// Debug
fprintf(stderr, "Serial FLOW %d < %d\n",
mu_serial_buf_len, read_count);
#endif
}
}
}
#endif
return mu_serial_buf_len;
}
uint16_t mu_serial_palmSerialDataReceive(void)
{
uint8_t data;
uint32_t buf_len;
// Get size of current buffer
buf_len = mu_serial_palmSerialDataSize();
#if defined(MU_SERIAL_DEBUG)
// Debug
fprintf(stderr, "Serial RECV TRY %d\n", mu_serial_buf_len);
#endif
// No data to read?
if (buf_len == 0 || mu_serial_buf_len == 0) {
return 0;
}
// Read in next byte
data = mu_serial_buf[0];
// Shift over
memmove(&mu_serial_buf[0], &mu_serial_buf[1],
mu_serial_buf_len - 1);
mu_serial_buf_len -= 1;
#if defined(MU_SERIAL_DEBUG)
// Debug
fprintf(stderr, "Serial RECV %02x %c\n", data, data);
#endif
// Give the byte we read
return data;
}
void mu_serial_palmSerialDataSend(uint16_t data)
{
uint8_t part;
// Only need to send the lower bit
part = data & 0xFF;
#if defined(__LIBRETRO__)
#elif defined(_WIN32)
#else
if (mu_serial_fd >= 0) {
#if defined(MU_SERIAL_DEBUG)
// Debug
fprintf(stderr, "Serial SEND %02x %c\n", part, part);
#endif
write(mu_serial_fd, &part, 1);
fsync(mu_serial_fd);
}
#endif
}
void mu_serial_palmSerialDataFlush(void)
{
#if defined(__LIBRETRO__)
#elif defined(_WIN32)
#else
if (mu_serial_fd >= 0) {
#if defined(MU_SERIAL_DEBUG)
// Debug
fprintf(stderr, "Serial DROP\n");
#endif
tcflush(mu_serial_fd, TCIFLUSH);
}
#endif
}
void mu_serial_open_and_init(const char* path)
{
mu_serial_path = strdup(path);
#if defined(__LIBRETRO__)
#elif defined(_WIN32)
#else
mu_serial_fd = -1;
#endif
#if defined(MU_SERIAL_DEBUG)
// Debug
fprintf(stderr, "Serial PORT %s\n", mu_serial_path);
#endif
// Set functions to use
palmSerialSetPortProperties = mu_serial_palmSerialSetPortProperties;
palmSerialDataSize = mu_serial_palmSerialDataSize;
palmSerialDataReceive = mu_serial_palmSerialDataReceive;
palmSerialDataSend = mu_serial_palmSerialDataSend;
palmSerialDataFlush = mu_serial_palmSerialDataFlush;
}