From e4ad003bc77f16045013143da21277d53bf195f4 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Tue, 20 Jan 2015 14:07:38 -0500 Subject: [PATCH] SysEnvirons ($a090) OS Trap --- toolbox/os.h | 1 + toolbox/os_gestalt.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++ toolbox/toolbox.cpp | 6 ++++- 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/toolbox/os.h b/toolbox/os.h index 277a3d5..b041a09 100644 --- a/toolbox/os.h +++ b/toolbox/os.h @@ -99,6 +99,7 @@ namespace OS #pragma mark - Gestalt Manager uint16_t Gestalt(uint16_t trap); + uint16_t SysEnvirons(uint16_t trap); #pragma mark - XP Ram uint16_t ReadXPRam(uint16_t trap); diff --git a/toolbox/os_gestalt.cpp b/toolbox/os_gestalt.cpp index 00ba179..5d61717 100644 --- a/toolbox/os_gestalt.cpp +++ b/toolbox/os_gestalt.cpp @@ -46,6 +46,8 @@ #include #include +#include + #include "os.h" #include "os_internal.h" #include "toolbox.h" @@ -96,5 +98,60 @@ namespace OS { return 0; } + + uint16_t SysEnvirons(uint16_t trap) + { + // FUNCTION SysEnvirons (versionRequested: Integer; + // VAR theWorld: SysEnvRec): OSErr; + + /* + * on entry: + * D0 Version requested + * A0 SysEnvRec pointer + * + * on exit: + * D0 Result code + * + */ + + enum { + /* SysEnvRec */ + _environsVersion = 0, + _machineType = 2, + _systemVersion = 4, + _processor = 6, + _hasFPU = 8, + _hasColorQD = 9, + _keyBoardType = 10, + _atDrvrVersNum = 12, + _sysVRefNum = 14, + }; + + uint16_t versionRequested = cpuGetDReg(0); + uint32_t theWorld = cpuGetAReg(0); + + Log("%04x SysEnvirons(%04x, %08x)\n", trap, versionRequested, theWorld); + + memoryWriteWord(2, theWorld + _environsVersion); + + // negative version. + if (versionRequested >= 0x8000) + return MacOS::envBadVers; + + if (versionRequested > 2) + return MacOS::envVersTooBig; + + memoryWriteWord(0, theWorld + _machineType); // 0 = unknown model newer than the IIci (v1) or IIfx (v2) + memoryWriteWord(1 + cpuGetModelMajor(), theWorld + _processor); + memoryWriteWord(0x0700, theWorld + _systemVersion); // system 7 + memoryWriteWord(0, theWorld + _hasFPU); + memoryWriteWord(0, theWorld + _hasColorQD); + memoryWriteWord(5, theWorld + _keyBoardType); // standard adb I guess + memoryWriteWord(0, theWorld + _atDrvrVersNum); // no appletalk + memoryWriteWord(-1, theWorld + _sysVRefNum); // System folder # + + return 0; + } + } diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index 5aa74df..4f42975 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -218,6 +218,10 @@ namespace ToolBox { d0 = OS::Gestalt(trap); break; + case 0xa090: + d0 = OS::SysEnvirons(trap); + break; + // SetPtrSize (p: Ptr; newSize: Size); case 0xa020: d0 = MM::SetPtrSize(trap); @@ -793,4 +797,4 @@ namespace ToolBox { return tmp; } #endif -} \ No newline at end of file +}