diff --git a/toolbox/os.cpp b/toolbox/os.cpp index 362a5d9..1d7a1f4 100644 --- a/toolbox/os.cpp +++ b/toolbox/os.cpp @@ -581,6 +581,35 @@ namespace OS return d0; } + uint16_t GetFPos(uint16_t trap) + { + uint32_t d0; + + uint32_t parm = cpuGetAReg(0); + + Log("%04x GetFPos(%08x)\n", trap, parm); + + //uint32_t ioCompletion = memoryReadLong(parm + 12); + uint16_t ioRefNum = memoryReadWord(parm + 24); + + int rv = ::lseek(ioRefNum, 0, SEEK_CUR); + if (rv < 0) + { + d0 = errno_to_oserr(errno); + } + else + { + memoryWriteLong(0, parm + 36); // ioReqCount + memoryWriteLong(0, parm + 40); // ioActCount + memoryWriteWord(0, parm + 44); // ioPosMode + memoryWriteLong(rv, parm + 46); // ioPosOffset + d0 = 0; + } + + memoryWriteWord(d0, parm + 16); + return d0; + } + uint16_t SetFPos(uint16_t trap) { uint32_t d0; diff --git a/toolbox/os.h b/toolbox/os.h index 60add94..3c56350 100644 --- a/toolbox/os.h +++ b/toolbox/os.h @@ -46,6 +46,7 @@ namespace OS uint16_t GetEOF(uint16_t trap); uint16_t SetEOF(uint16_t trap); + uint16_t GetFPos(uint16_t trap); uint16_t SetFPos(uint16_t trap); uint16_t GetVol(uint16_t trap); diff --git a/toolbox/toolbox.cpp b/toolbox/toolbox.cpp index faf5281..7fd6293 100644 --- a/toolbox/toolbox.cpp +++ b/toolbox/toolbox.cpp @@ -80,6 +80,10 @@ namespace ToolBox { d0 = OS::HGetVol(trap); break; + case 0xa018: + d0 = OS::GetFPos(trap); + break; + case 0xa044: d0 = OS::SetFPos(trap); break;