From d0715138f98b7282166822ab44d111eea343e9fb Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Thu, 23 May 2013 21:42:06 -0400 Subject: [PATCH] SetVol (Link) --- toolbox/os.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ toolbox/os.h | 4 ++++ toolbox/toolbox.cpp | 5 +++++ 3 files changed, 53 insertions(+) diff --git a/toolbox/os.cpp b/toolbox/os.cpp index 086bc72..0555202 100644 --- a/toolbox/os.cpp +++ b/toolbox/os.cpp @@ -641,6 +641,50 @@ namespace OS return 0; } + + uint16_t SetVol(uint16_t trap) + { + + enum { // WDPBRec + _qLink = 0, + _qType = 4, + _ioTrap = 6, + _ioCmdAddr = 8, + _ioCompletion = 12, + _ioResult = 16, + _ioNamePtr = 18, + _ioVRefNum = 22, + + _ioWDDirID = 48, + }; + + uint16_t d0; + + uint32_t parm = cpuGetAReg(0); + + Log("%04x SetVol(%08x)\n", trap, parm); + + + uint32_t ioNamePtr = memoryReadLong(parm + _ioNamePtr); + uint32_t ioVRefNum = memoryReadWord(parm + _ioVRefNum); + uint32_t ioWDDirID = trap & 0x0200 ? memoryReadLong(parm + _ioWDDirID) : 0; + + + std::string name = ToolBox::ReadPString(ioNamePtr); + + Log(" SetVol(%s, %d, %d)\n", name.c_str(), ioVRefNum, ioWDDirID); + + if (name.length() || ioVRefNum || ioWDDirID) + { + fprintf(stderr, "SetVol(%s, %d, %d) is not supported yet.\n", name.c_str(), ioVRefNum, ioWDDirID); + exit(1); + } + d0 = 0; + memoryWriteWord(d0, parm + _ioResult); + return d0; + } + + #if 0 uint16_t GetFileInfo(uint16_t trap) { diff --git a/toolbox/os.h b/toolbox/os.h index c73be83..3cebd30 100644 --- a/toolbox/os.h +++ b/toolbox/os.h @@ -52,6 +52,10 @@ namespace OS uint16_t GetVol(uint16_t trap); uint16_t HGetVol(uint16_t trap); + uint16_t SetVol(uint16_t trap); + + + uint16_t Open(uint16_t trap); uint16_t OpenRF(uint16_t trap); uint16_t HOpen(uint16_t trap); diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index e23d3ed..8b7e128 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -83,6 +83,11 @@ namespace ToolBox { d0 = OS::GetVol(trap); break; + case 0xa015: // SetVol + case 0xa215: // HSetVol + d0 = OS::SetVol(trap); + break; + case 0xa214: d0 = OS::HGetVol(trap); break;