TriOS-alt/zubehör/sphinx/spinx100225-ori/sphinx2/isxfs.spn

80 lines
3.6 KiB
Plaintext
Raw Normal View History

2010-11-26 23:58:06 +01:00
SXTVRENDEZVOUS = $8000 - 4
SXKBRENDEZVOUS = SXTVRENDEZVOUS - 4
SDSPIRENDEZVOUS = SXKBRENDEZVOUS - 3 * 4
SXFS2RENDEZVOUS = SDSPIRENDEZVOUS - 4 * 4 ' four rendezvous variables
SXFSRENDEZVOUS = SXFS2RENDEZVOUS - 4 * 4 ' four rendezvous variables
METADATABUFFER = SXFSRENDEZVOUS - 512
_free = ($8000 - METADATABUFFER) / 4
SIZEOFFILESTUFF = 512 + 24
pCommand = SXFSRENDEZVOUS
pParam0 = pCommand+4
pParam1 = pCommand+8
pParam2 = pCommand+12
pub Open( pFilestuff, pFilename, mode ) | filenameBuffer[3], p, i
{{
mode is either "R" or "W".
Returns 0 on success, 1 if file not found (and opening for reading).
}}
return Command( "O", pFilestuff, pFilename, mode )
pub Close( pFilestuff )
Command( "C", pFilestuff, 0, 0 )
pub Read( pFilestuff, pBuffer, nBytes )
{{
Returns number of bytes actually read, -1 at EOF.
}}
long[pParam0] := pFilestuff
long[pParam1] := pBuffer
long[pParam2] := nBytes
long[pCommand] := "R"
repeat while long[pCommand]
if long[pParam0] < -2 ' don't abort for return code -1.
abort long[pParam0]
return long[pParam0]
pub Write( pFilestuff, pBuffer, nBytes )
return Command( "W", pFilestuff, pBuffer, nBytes )
pub Execute( pFilestuff, execmode )
{{
If execmode is non-0, all cogs are stopped except Spin interpreter.
If execmode is 0, running cogs are left running.
}}
Command( "X", pFilestuff, execmode, cogid )
pub Command( cmd, param0, param1, param2 )
long[pParam0] := param0
long[pParam1] := param1
long[pParam2] := param2
long[pCommand] := cmd
repeat while long[pCommand]
if long[pParam0] < 0
abort long[pParam0]
return long[pParam0]
{{
Copyright (c) 2009 Michael Park
+------------------------------------------------------------------------------------------------------------------------------+
| TERMS OF USE: MIT License |
+------------------------------------------------------------------------------------------------------------------------------+
|Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation |
|files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, |
|modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software|
|is furnished to do so, subject to the following conditions: |
| |
|The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.|
| |
|THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
|WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
|ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
+------------------------------------------------------------------------------------------------------------------------------+
}}