mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-03-20 03:31:27 +00:00
Get Apple /// playing with SANE and FileIO
This commit is contained in:
parent
5fecde7eef
commit
42a58938b9
src
@ -36,24 +36,15 @@ struc t_fileio
|
||||
word readblock
|
||||
word writeblock
|
||||
end
|
||||
predef a1getpfx, a1setpfx, a1getfileinfo, a1open, a1close, a1read, a1write, a1create, a1destroy
|
||||
predef a1newline, a13readblock, a13writeblock
|
||||
predef a2getpfx, a23setpfx, a2getfileinfo, a2open, a23close, a23read, a2write, a2create, a23destroy
|
||||
predef a2getpfx, a23setpfx, a2getfileinfo, a2open, a23close
|
||||
predef a23read, a2write, a2create, a23destroy
|
||||
predef a23newline, a2readblock, a2writeblock
|
||||
predef a3getpfx, a3getfileinfo, a3open, a3write, a3create
|
||||
//
|
||||
// Exported function table.
|
||||
//
|
||||
export word fileio[]
|
||||
//
|
||||
// Platform specific function pointers (default to Apple II).
|
||||
//
|
||||
word a2io[] = @a2getpfx, @a23setpfx, @a2getfileinfo, @a2open, @a23close, @a23read, @a2write, @a2create, @a23destroy
|
||||
word = @a23newline, @a2readblock, @a2writeblock
|
||||
word a3io[] = @a3getpfx, @a23setpfx, @a3getfileinfo, @a3open, @a23close, @a23read, @a3write, @a3create, @a23destroy
|
||||
word = @a23newline, @a13readblock, @a13writeblock
|
||||
word a1io[] = @a1getpfx, @a1setpfx, @a1getfileinfo, @a1open, @a1close, @a1read, @a1write, @a1create, @a1destroy
|
||||
word = @a1newline, @a13readblock, @a13writeblock
|
||||
export word fileio[] = @a2getpfx, @a23setpfx, @a2getfileinfo, @a2open, @a23close
|
||||
word = @a23read, @a2write, @a2create, @a23destroy
|
||||
word = @a23newline, @a2readblock, @a2writeblock
|
||||
//
|
||||
// SOS/ProDOS error code
|
||||
//
|
||||
@ -132,15 +123,13 @@ def a2open(path)
|
||||
end
|
||||
def a3open(path)
|
||||
byte params[7]
|
||||
word access
|
||||
|
||||
access = O_READ_WRITE
|
||||
params.0 = 4
|
||||
params:1 = path
|
||||
params.3 = 0
|
||||
params:4 = @access
|
||||
params.6 = 1
|
||||
syscall($C8, @params)
|
||||
params:4 = 0
|
||||
params.6 = 0
|
||||
perr = syscall($C8, @params)
|
||||
return params.3
|
||||
end
|
||||
def a1close(refnum)
|
||||
@ -156,7 +145,7 @@ def a23close(refnum)
|
||||
end
|
||||
def a1read(refnum, buf, len)
|
||||
*CFFA1Dest = buf
|
||||
perr = syscall($22) // This reads the entire file on CFFA
|
||||
perr = syscall($22) // This reads the entire file from CFFA
|
||||
return perr
|
||||
end
|
||||
def a23read(refnum, buf, len)
|
||||
@ -281,10 +270,27 @@ end
|
||||
//
|
||||
when MACHID & $C8
|
||||
is $08 // Apple 1
|
||||
memcpy(fileio, a1io, t_fileio)
|
||||
fileio:getpfx = @a1getpfx
|
||||
fileio:setpfx = @a1setpfx
|
||||
fileio:getfileinfo = @a1getfileinfo
|
||||
fileio:open = @a1open
|
||||
fileio:close = @a1close
|
||||
fileio:read = @a1read
|
||||
fileio:write = @a1write
|
||||
fileio:create = @a1create
|
||||
fileio:destroy = @a1destroy
|
||||
fileio:newline = @a1newline
|
||||
fileio:readblock = @a13readblock
|
||||
fileio:writeblock = @a13writeblock
|
||||
break
|
||||
is $C0 // Apple ///
|
||||
memcpy(fileio, a3io, t_fileio)
|
||||
fileio:getpfx = @a3getpfx
|
||||
fileio:getfileinfo = @a3getfileinfo
|
||||
fileio:open = @a3open
|
||||
fileio:write = @a3write
|
||||
fileio:create = @a3create
|
||||
fileio:readblock = @a13readblock
|
||||
fileio:writeblock = @a13writeblock
|
||||
break
|
||||
otherwise // Apple ][
|
||||
wend
|
||||
|
@ -501,6 +501,21 @@ asm fixupXEL3
|
||||
STY ESTKH,X
|
||||
RTS
|
||||
end
|
||||
asm zpSaveX#1 // Save Apple /// XDATA
|
||||
XPAGE = $1600
|
||||
STX ESP
|
||||
LDX #$00
|
||||
LDY #$33
|
||||
- LDA XPAGE,Y
|
||||
end
|
||||
asm fixupXS
|
||||
STA $FFFF,Y
|
||||
TXA
|
||||
STA XPAGE,Y
|
||||
DEY
|
||||
BPL -
|
||||
LDX ESP
|
||||
end
|
||||
asm zpSave#1
|
||||
LDY #$33
|
||||
- LDA $00,Y
|
||||
@ -514,6 +529,15 @@ asm zpNopSave
|
||||
DEX
|
||||
RTS
|
||||
end
|
||||
asm zpRestoreX(passthru)#1 // Restore Apple /// XDATA
|
||||
LDY #$33
|
||||
end
|
||||
asm fixupXR
|
||||
- LDA $FFFF,Y
|
||||
STA XPAGE,Y
|
||||
DEY
|
||||
BPL -
|
||||
end
|
||||
asm zpRestore(passthru)#1
|
||||
LDY #$33
|
||||
end
|
||||
@ -588,13 +612,18 @@ end
|
||||
//
|
||||
// Utility test routines
|
||||
//
|
||||
//byte hexchar[] = '0','1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F'
|
||||
//def prhex(h)#0
|
||||
// putc(hexchar[(h>>4)&$0F]);putc(hexchar[h&$0F])
|
||||
//end
|
||||
//def prbyte(h)#0
|
||||
// putc('$')
|
||||
// call($FDDA, h, 0, 0, 0)
|
||||
// putc('$'); prhex(h)
|
||||
// //call($FDDA, h, 0, 0, 0)
|
||||
//end
|
||||
//def prword(h)#0
|
||||
// putc('$')
|
||||
// call($F941, h >> 8, h, 0, 0)
|
||||
// prhex(h>>8);prhex(h)
|
||||
// //call($F941, h >> 8, h, 0, 0)
|
||||
//end
|
||||
//def putname(pchr)#0
|
||||
// byte c
|
||||
@ -603,9 +632,6 @@ end
|
||||
// putc(pchr->[c])
|
||||
// next
|
||||
//end
|
||||
//def putln#0
|
||||
// putc('\n')
|
||||
//end
|
||||
//def dumpheader(phdr)#0
|
||||
// byte i
|
||||
//
|
||||
@ -704,14 +730,19 @@ def loadcode(codefile)
|
||||
//puts(codefile); puts(":\n")
|
||||
pcode = 0
|
||||
ref = fileio:open(codefile)
|
||||
//puts("ref = "); prbyte(ref); puts(" perr = "); prbyte(perr); putln
|
||||
if ref
|
||||
pcode = heapmark
|
||||
fileio:read(ref, pcode, 512)
|
||||
//puts("Read header bytes: "); puti(seglen)
|
||||
//if seglen == 0; puts(" perr = "); prbyte(perr); fin
|
||||
//getc; putln
|
||||
//dumpheader(pcode)
|
||||
//putname(pcode + segname + 8); putc('='); prword(pcode); putln
|
||||
seglen = fileio:read(ref, pcode, (pcode + t_diskinfo)=>codeaddr)
|
||||
//puts("Read segment bytes: "); puti(seglen); putln
|
||||
fileio:close(ref)
|
||||
if !fp6502 and (MACHID & $30 == $30)
|
||||
if !fp6502 and (MACHID & $F0 == $B0) // 128K Apple //e or //c
|
||||
seglen = fixup(AUXADDR, pcode + seglen - 2) - pcode
|
||||
auxmove(AUXADDR, pcode, seglen)
|
||||
pcode = AUXADDR
|
||||
@ -800,24 +831,32 @@ def fpInit()
|
||||
//
|
||||
// Fixup MAIN calls in interface routines
|
||||
//
|
||||
fpzpsave = heapalloc($0034)
|
||||
(@fixupZPS)=>1 = fpzpsave
|
||||
(@fixupZPR)=>1 = fpzpsave
|
||||
if MACHID & $F0 == $F0 // Apple ///
|
||||
fpzpsave = heapalloc($0034*2)
|
||||
(@fixupXS)=>1 = fpzpsave+$34
|
||||
(@fixupXR)=>1 = fpzpsave+$34
|
||||
sane[9] = @zpSaveX
|
||||
sane[10] = @zpRestoreX
|
||||
else // Apple II
|
||||
fpzpsave = heapalloc($0034)
|
||||
sane[9] = @zpSave
|
||||
sane[10] = @zpRestore
|
||||
fin
|
||||
(@fixupFP0)=>1 = fp6502
|
||||
(@fixupFP1)=>1 = fp6502
|
||||
(@fixupFP2)=>1 = fp6502
|
||||
(@fixupFP3)=>1 = fp6502
|
||||
(@fixupZPS)=>1 = fpzpsave
|
||||
(@fixupZPR)=>1 = fpzpsave
|
||||
sane[2] = @fpOp0
|
||||
sane[3] = @fpOp1
|
||||
sane[4] = @fpOp2
|
||||
sane[5] = @fpOp3
|
||||
sane[9] = @zpSave
|
||||
sane[10] = @zpRestore
|
||||
//
|
||||
// Install MAIN HALT handler
|
||||
//
|
||||
zpSave()
|
||||
zpRestore(fpOp1($0005, @fpHalt))
|
||||
sane[9]()
|
||||
sane[10](fpOp1($0005, @fpHalt))
|
||||
fin
|
||||
sane[6] = @elemsLoad1
|
||||
sane[7] = @elemsLoad2
|
||||
|
@ -682,14 +682,14 @@ def volume(devname, volname, ttlblks, freblks)#1
|
||||
*freblks = params:7
|
||||
return perr
|
||||
end
|
||||
def open(path, access)#1
|
||||
def open(path)#1
|
||||
byte params[7]
|
||||
|
||||
params.0 = 4
|
||||
params:1 = path
|
||||
params.3 = 0
|
||||
params:4 = @access
|
||||
params.6 = 1
|
||||
params:4 = 0
|
||||
params.6 = 0
|
||||
perr = syscall($C8, @params)
|
||||
return params.3
|
||||
end
|
||||
@ -809,7 +809,7 @@ end
|
||||
def init_cons()#0
|
||||
byte nlmode[2]
|
||||
if !refcons
|
||||
refcons = open(@console, O_READ_WRITE)
|
||||
refcons = open(@console)
|
||||
fin
|
||||
write(refcons, @textmode, 3)
|
||||
devcons = dev_getnum(@console)
|
||||
@ -982,7 +982,7 @@ def loadmod(mod)#1
|
||||
// Read the RELocatable module header (first 128 bytes)
|
||||
//
|
||||
dcitos(mod, @filename)
|
||||
refnum = open(@filename, O_READ)
|
||||
refnum = open(@filename)
|
||||
if refnum > 0
|
||||
rdlen = read(refnum, @header, 128)
|
||||
modsize = header:0
|
||||
@ -1023,7 +1023,7 @@ def loadmod(mod)#1
|
||||
//
|
||||
// Reset read pointer.
|
||||
//
|
||||
refnum = open(@filename, O_READ)
|
||||
refnum = open(@filename)
|
||||
rdlen = read(refnum, @header, 128)
|
||||
fin
|
||||
else
|
||||
@ -1197,7 +1197,7 @@ def catalog(optpath)#1
|
||||
prstr(@path)
|
||||
crout()
|
||||
fin
|
||||
refnum = open(@path, O_READ)
|
||||
refnum = open(@path)
|
||||
if perr
|
||||
return perr
|
||||
fin
|
||||
@ -1328,7 +1328,7 @@ loop
|
||||
//
|
||||
cmdptr = heap
|
||||
^cmdptr = 0
|
||||
autorun = open(@autorun, O_READ)
|
||||
autorun = open(@autorun)
|
||||
if autorun > 0
|
||||
^cmdptr = read(autorun, cmdptr + 1, 64)
|
||||
close(autorun)
|
||||
|
Loading…
x
Reference in New Issue
Block a user