TimeDate.c cleanup, add misc. WIP files

This commit is contained in:
InvisibleUp 2020-04-30 22:11:27 -04:00
parent c03084ea30
commit d3a1b5690d
4 changed files with 309 additions and 27 deletions

24
CMakeLists.txt.indev Normal file
View File

@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.10)
project(microvmac)
set_property(C_STANDARD 99)
set_property(C_STANDARD_REQUIRED True)
set(TARGET_PLATFORM AUTO CACHE STRING "Set platform to compile for")
set_property(CACHE TARGET_PLATFORM PROPERTY STRINGS WINDOWS X11 OSX OS9 NDS GTK SDL SDL2)
include_directories(cfg)
file(GLOB_RECURSE microvmac_SOURCES "src/*.cpp")
file(GLOB_RECURSE microvmac_HEADERS "src/*.h")
set (microvmac_INCLUDE_DIRS "")
foreach (_headerFile ${microvmac_HEADERS})
get_filename_component(_dir ${_headerFile} PATH)
list (APPEND microvmac_INCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES microvmac_INCLUDE_DIRS)
add_executable(microvmac VERSION 0.37.0 ${microvmac_SOURCES})
target_include_directories(microvmac PRIVATE ${microvmac_INCLUDE_DIRS})

237
cfg/EMCONFIG_MacII.h Normal file
View File

@ -0,0 +1,237 @@
/*
Configuration options used by platform independent code.
This file is automatically generated by the build system,
which tries to know what options are valid in what
combinations. Avoid changing this file manually unless
you know what you're doing.
*/
#define EmClassicKbrd 0
#define EmADB 1
#define EmRTC 1
#define EmPMU 0
#define EmVIA2 1
#define Use68020 1
#define EmFPU 1
#define EmMMU 0
#define EmASC 1
#define CurEmMd kEmMd_II
#define kMyClockMult 2
#define WantCycByPriOp 0
#define WantCloserCyc 0
#define r_regs "r4"
#define r_pc_p "r5"
#define r_MaxCyclesToGo "r6"
#define r_pc_pHi "r7"
#define kRAMa_Size 0x00400000
#define kRAMb_Size 0x00400000
#define IncludeVidMem 1
#define kVidMemRAM_Size 0x00040000
#define EmVidCard 1
#define kVidROM_Size 0x000800
#define MaxATTListN 20
#define IncludeExtnPbufs 0
#define IncludeExtnHostTextClipExchange 0
#define Sony_SupportDC42 1
#define Sony_SupportTags 0
#define Sony_WantChecksumsUpdated 0
#define Sony_VerifyChecksums 0
#define CaretBlinkTime 0x08
#define SpeakerVol 0x07
#define DoubleClickTime 0x08
#define MenuBlink 0x03
#define AutoKeyThresh 0x06
#define AutoKeyRate 0x03
/* the Wire variables are 1/0, not true/false */
enum {
Wire_unknown_SoundDisable,
#define SoundDisable (Wires[Wire_unknown_SoundDisable])
Wire_unknown_SoundVolb0,
#define SoundVolb0 (Wires[Wire_unknown_SoundVolb0])
Wire_unknown_SoundVolb1,
#define SoundVolb1 (Wires[Wire_unknown_SoundVolb1])
Wire_unknown_SoundVolb2,
#define SoundVolb2 (Wires[Wire_unknown_SoundVolb2])
Wire_VIA1_iA0_unknown,
#define VIA1_iA0 (Wires[Wire_VIA1_iA0_unknown])
Wire_VIA1_iA1_unknown,
#define VIA1_iA1 (Wires[Wire_VIA1_iA1_unknown])
Wire_VIA1_iA2_unknown,
#define VIA1_iA2 (Wires[Wire_VIA1_iA2_unknown])
Wire_VIA1_iB7_unknown, /* for compatibility with SoundDisable */
#define VIA1_iB7 (Wires[Wire_VIA1_iB7_unknown])
Wire_VIA2_InterruptRequest,
#define VIA2_InterruptRequest (Wires[Wire_VIA2_InterruptRequest])
#define VIA2_interruptChngNtfy VIAorSCCinterruptChngNtfy
Wire_VIA2_iA7_unknown,
#define VIA2_iA7 (Wires[Wire_VIA2_iA7_unknown])
#define VIA2_iA7_ChangeNtfy Addr32_ChangeNtfy
Wire_VIA2_iA6_unknown,
#define VIA2_iA6 (Wires[Wire_VIA2_iA6_unknown])
#define VIA2_iA6_ChangeNtfy Addr32_ChangeNtfy
Wire_VIA2_iB7_unknown,
#define VIA2_iB7 (Wires[Wire_VIA2_iB7_unknown])
Wire_VIA2_iCB2_unknown,
#define VIA2_iCB2 (Wires[Wire_VIA2_iCB2_unknown])
Wire_VIA2_iB2_PowerOff,
#define VIA2_iB2 (Wires[Wire_VIA2_iB2_PowerOff])
#define VIA2_iB2_ChangeNtfy PowerOff_ChangeNtfy
Wire_VIA2_iB3_Addr32,
#define VIA2_iB3 (Wires[Wire_VIA2_iB3_Addr32])
#define Addr32 (Wires[Wire_VIA2_iB3_Addr32])
#define VIA2_iB3_ChangeNtfy Addr32_ChangeNtfy
Wire_VIA1_iA4_MemOverlay,
#define MemOverlay (Wires[Wire_VIA1_iA4_MemOverlay])
#define VIA1_iA4 (Wires[Wire_VIA1_iA4_MemOverlay])
#define VIA1_iA4_ChangeNtfy MemOverlay_ChangeNtfy
Wire_VIA1_iA5_IWMvSel,
#define IWMvSel (Wires[Wire_VIA1_iA5_IWMvSel])
#define VIA1_iA5 (Wires[Wire_VIA1_iA5_IWMvSel])
Wire_VIA1_iA7_SCCwaitrq,
#define SCCwaitrq (Wires[Wire_VIA1_iA7_SCCwaitrq])
#define VIA1_iA7 (Wires[Wire_VIA1_iA7_SCCwaitrq])
Wire_VIA1_iB0_RTCdataLine,
#define RTCdataLine (Wires[Wire_VIA1_iB0_RTCdataLine])
#define VIA1_iB0 (Wires[Wire_VIA1_iB0_RTCdataLine])
#define VIA1_iB0_ChangeNtfy RTCdataLine_ChangeNtfy
Wire_VIA1_iB1_RTCclock,
#define RTCclock (Wires[Wire_VIA1_iB1_RTCclock])
#define VIA1_iB1 (Wires[Wire_VIA1_iB1_RTCclock])
#define VIA1_iB1_ChangeNtfy RTCclock_ChangeNtfy
Wire_VIA1_iB2_RTCunEnabled,
#define RTCunEnabled (Wires[Wire_VIA1_iB2_RTCunEnabled])
#define VIA1_iB2 (Wires[Wire_VIA1_iB2_RTCunEnabled])
#define VIA1_iB2_ChangeNtfy RTCunEnabled_ChangeNtfy
Wire_VIA1_iA3_SCCvSync,
#define VIA1_iA3 (Wires[Wire_VIA1_iA3_SCCvSync])
Wire_VIA1_iB3_ADB_Int,
#define ADB_Int (Wires[Wire_VIA1_iB3_ADB_Int])
#define VIA1_iB3 (Wires[Wire_VIA1_iB3_ADB_Int])
Wire_VIA1_iB4_ADB_st0,
#define ADB_st0 (Wires[Wire_VIA1_iB4_ADB_st0])
#define VIA1_iB4 (Wires[Wire_VIA1_iB4_ADB_st0])
#define VIA1_iB4_ChangeNtfy ADBstate_ChangeNtfy
Wire_VIA1_iB5_ADB_st1,
#define ADB_st1 (Wires[Wire_VIA1_iB5_ADB_st1])
#define VIA1_iB5 (Wires[Wire_VIA1_iB5_ADB_st1])
#define VIA1_iB5_ChangeNtfy ADBstate_ChangeNtfy
Wire_VIA1_iCB2_ADB_Data,
#define ADB_Data (Wires[Wire_VIA1_iCB2_ADB_Data])
#define VIA1_iCB2 (Wires[Wire_VIA1_iCB2_ADB_Data])
#define VIA1_iCB2_ChangeNtfy ADB_DataLineChngNtfy
Wire_VIA1_InterruptRequest,
#define VIA1_InterruptRequest (Wires[Wire_VIA1_InterruptRequest])
#define VIA1_interruptChngNtfy VIAorSCCinterruptChngNtfy
Wire_SCCInterruptRequest,
#define SCCInterruptRequest (Wires[Wire_SCCInterruptRequest])
#define SCCinterruptChngNtfy VIAorSCCinterruptChngNtfy
Wire_ADBMouseDisabled,
#define ADBMouseDisabled (Wires[Wire_ADBMouseDisabled])
Wire_VBLinterrupt,
#define Vid_VBLinterrupt (Wires[Wire_VBLinterrupt])
#define VIA2_iA0 (Wires[Wire_VBLinterrupt])
Wire_VBLintunenbl,
#define Vid_VBLintunenbl (Wires[Wire_VBLintunenbl])
kNumWires
};
/* VIA configuration */
#define VIA1_ORA_FloatVal 0xBF
/* bit 6 used to check version of hardware */
#define VIA1_ORB_FloatVal 0xFF
#define VIA1_ORA_CanIn 0x80
#define VIA1_ORA_CanOut 0x3F
#define VIA1_ORB_CanIn 0x09
#define VIA1_ORB_CanOut 0xB7
#define VIA1_IER_Never0 0x00
#define VIA1_IER_Never1 0x58
#define VIA1_CB2modesAllowed 0x01
#define VIA1_CA2modesAllowed 0x01
/* VIA 2 configuration */
#define VIA2_ORA_FloatVal 0xFF
#define VIA2_ORB_FloatVal 0xFF
#define VIA2_ORA_CanIn 0x01
#define VIA2_ORA_CanOut 0xC0
#define VIA2_ORB_CanIn 0x00
#define VIA2_ORB_CanOut 0x8C
#define VIA2_IER_Never0 0x00
#define VIA2_IER_Never1 0xED
#define VIA2_CB2modesAllowed 0x01
#define VIA2_CA2modesAllowed 0x01
#define Mouse_Enabled() (! ADBMouseDisabled)
#define VIA1_iCA1_PulseNtfy VIA1_iCA1_Sixtieth_PulseNtfy
#define Sixtieth_PulseNtfy VIA1_iCA1_Sixtieth_PulseNtfy
#define VIA1_iCA2_PulseNtfy VIA1_iCA2_RTC_OneSecond_PulseNtfy
#define RTC_OneSecond_PulseNtfy VIA1_iCA2_RTC_OneSecond_PulseNtfy
#define VIA2_iCA1_PulseNtfy VIA2_iCA1_Vid_VBLinterrupt_PulseNtfy
#define Vid_VBLinterrupt_PulseNotify VIA2_iCA1_Vid_VBLinterrupt_PulseNtfy
#define VIA2_iCB1_PulseNtfy VIA2_iCB1_ASC_interrupt_PulseNtfy
#define ASC_interrupt_PulseNtfy VIA2_iCB1_ASC_interrupt_PulseNtfy
#define GetSoundInvertTime VIA1_GetT1InvertTime
#define ADB_ShiftInData VIA1_ShiftOutData
#define ADB_ShiftOutData VIA1_ShiftInData
#define kCheckSumRom_Size kROM_Size
#define kExtn_Block_Base 0x50F0C000
#define kExtn_ln2Spc 5
#define kROM_Base 0x00800000
#define kROM_ln2Spc 20
#define WantDisasm 0
#define ExtraAbnormalReports 0

View File

@ -28,15 +28,6 @@
#define EnableGrabSpecialKeys (MayFullScreen && GrabKeysFullScreen)
#endif /* EnableGrabSpecialKeys */
/*
Setting TimeResolution to 1 seems to drastically slow down
the clock in Virtual PC 7.0.2 for Mac. Using 3 is more polite
anyway, and should not cause much observable difference.
*/
#ifndef TimeResolution
#define TimeResolution 3
#endif
/* Resource Ids */
#define IDI_VMAC 256

View File

@ -8,6 +8,31 @@ LOCALVAR DWORD TimeMilliBase;
LOCALVAR uint32_t NextFracTime;
bool HaveSetTimeResolution = false;
// API wrapper defines
/*
Timer resolution, as used by timeBeginPeriod(), in milliseconds.
Setting TimeResolution to 1 seems to drastically slow down
the clock in Virtual PC 7.0.2 for Mac. Using 3 is more polite
anyway, and should not cause much observable difference.
(note that 1/60 of a frame is 16.7 milliseconds)
*/
#ifndef TimeResolution
#define TimeResolution 3
#endif
/*
Windows NT: The default precision of the timeGetTime function can be five
milliseconds or more, depending on the machine. You can use the
timeBeginPeriod and timeEndPeriod functions to increase the precision of
timeGetTime. If you do so, the minimum difference between successive values
returned by timeGetTime can be as large as the minimum period value set using
timeBeginPeriod and timeEndPeriod. Use the QueryPerformanceCounter and
QueryPerformanceFrequency functions to measure short time intervals at a high
resolution. (MSDN for Visual Studio '97)
(TODO: use QueryPerformanceCounter instead? Always works on WinXP+)
*/
#define GetTimeMillisec timeGetTime
void IncrNextTime(void)
{
NextFracTime += InvTimeStep;
@ -27,7 +52,7 @@ bool UpdateTrueEmulatedTime(void)
DWORD LatestTime;
int32_t TimeDiff;
LatestTime = timeGetTime();
LatestTime = GetTimeMillisec();
if (LatestTime != LastTime) {
LastTime = LatestTime;
TimeDiff = (LatestTime - NextIntTime);
@ -39,8 +64,10 @@ bool UpdateTrueEmulatedTime(void)
InitNextTime();
#if dbglog_TimeStuff
dbglog_writelnNum("emulation interrupted",
TrueEmulatedTime);
dbglog_writelnNum(
"emulation interrupted",
TrueEmulatedTime
);
#endif
} else {
do {
@ -62,6 +89,7 @@ bool UpdateTrueEmulatedTime(void)
return false;
}
// Check that emulated clock equals real clock
bool CheckDateTime(void)
{
uint32_t NewMacDateInSecond;
@ -76,6 +104,7 @@ bool CheckDateTime(void)
}
}
// Initialize emulated RTC check
bool Init60thCheck(void)
{
SYSTEMTIME s;
@ -84,9 +113,12 @@ bool Init60thCheck(void)
DWORD t;
GetLocalTime(&s);
t = timeGetTime();
TimeSecBase = Date2MacSeconds(s.wSecond, s.wMinute, s.wHour,
s.wDay, s.wMonth, s.wYear);
t = GetTimeMillisec();
TimeSecBase = Date2MacSeconds(
s.wSecond, s.wMinute, s.wHour,
s.wDay, s.wMonth, s.wYear
);
TimeMilliBase = t - s.wMilliseconds;
if (AutoTimeZone) {
@ -100,7 +132,7 @@ bool Init60thCheck(void)
}
}
LastTime = timeGetTime();
LastTime = GetTimeMillisec();
InitNextTime();
OnTrueTime = TrueEmulatedTime;
@ -112,6 +144,7 @@ bool Init60thCheck(void)
void Timer_Suspend(void)
{
// If using higher-precision timer, stop
if (HaveSetTimeResolution) {
(void) timeEndPeriod(TimeResolution);
HaveSetTimeResolution = false;
@ -122,16 +155,13 @@ void Timer_Resume(void)
{
TIMECAPS tc;
if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) == TIMERR_NOERROR)
{
if ((TimeResolution >= tc.wPeriodMin)
&& (TimeResolution <= tc.wPeriodMax))
{
if (timeBeginPeriod(TimeResolution)
== TIMERR_NOERROR)
{
HaveSetTimeResolution = true;
}
}
// Try to use higher-precision timer
if (
timeGetDevCaps(&tc, sizeof(TIMECAPS)) == TIMERR_NOERROR &&
(TimeResolution >= tc.wPeriodMin) &&
(TimeResolution <= tc.wPeriodMax) &&
timeBeginPeriod(TimeResolution) == TIMERR_NOERROR
) {
HaveSetTimeResolution = true;
}
}