home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 6
/
AACD06.ISO
/
AACD
/
Emulation
/
ZXAMSpectrum
/
ZXAM_Rexx
/
English
/
ZXAM_Tape.zxam
< prev
next >
Wrap
Text File
|
1995-07-31
|
3KB
|
139 lines
/* This script is used to load/save from .TAP files */
/* To convert .header/.bytes files to .TAP you must use a block copier, */
/* like DUPLITAPE, using 'Load Mode -> Disk' and 'Save Mode -> ARexx' */
/* check if the emulator is present */
address command
if ~show(ports,ZXAM_REXX) then do
requestchoice 'title "ZXAM Script error..." body "I couldnt find the emulator port!!" gadgets "AARGH!"'
exit
end
ZXAMTapeSetResult(2) /* result=error */
/* Check the operation that must be done */
oper=ZXAMTapeAction()
if oper=0 then exit /* Script started manually */
if oper=3 then signal actionsave /* SAVE */
/* LOAD or VERIFY */
actionload:
nombre=ZXAMTapeLoadName() /* Name of the .TAP actually selected */
ZXAMTapeSetLoadName('')
/* LOAD requester if no .TAP file is selected */
if nombre='' then do
oldpath=zxamactloadpath()
oldpattern=zxamactpattern()
zxamloadpath("ram:")
zxampattern('#?.TAP')
ZXAMControlToFront()
nombre=zxamloadrequester("Select the .TAP file for LOAD...")
ZXAMTapeSetLoadOffset(0)
ZXAMEmulToFront()
zxamloadpath(oldpath)
zxampattern(oldpattern)
end
if nombre='' then exit 0 /* CANCEL */
/* open the file */
if ~open('fichero',nombre,'R') then exit 0
/* Move to the adequate place of the file */
filepos=ZXAMTapeLoadOffset()
/* If there are problems, select another .TAP file */
if filepos~=seek('fichero',filepos,'B') then do
dummy=close('fichero')
signal actionload
end
/* read the size of the actual block */
size=readch('fichero',2)
if length(size)~=2 then do
dummy=close('fichero')
signal actionload
end
/* open the temporary file */
if ~open('destino','t:zxamtemp','W') then exit 0
size=c2d(reverse(size)) /* fomato invertido Z80 */
/* load the block */
block=readch('fichero',size)
/* save it to the temporary file */
dummy=writech('destino',block)
ZXAMTapeSetLoadName(nombre)
ZXAMTapeSetLoadOffset(seek('fichero',0,'C'))
ZXAMTapeSetResult(1,'t:zxamtemp')
dummy=close('fichero')
dummy=close('destino')
exit
/* SAVE */
actionsave:
nombre=ZXAMTapeSaveName()
ZXAMTapeSetSaveName("")
if ((zxamtapeflag()=0)&(zxampeek(zxamtapeaddress())=0)&(zxamtapesize()=17)) then nombre=''
/* SAVE requester */
if nombre='' then do
oldpath=zxamactsavepath()
oldpattern=zxamactpattern()
zxamsavepath("ram:")
zxampattern('#?.TAP')
ZXAMControlToFront()
nombre=zxamsaverequester("Select the .TAP file for SAVE...")
ZXAMTapeSetSaveOffset(0)
ZXAMEmulToFront()
zxamsavepath(oldpath)
zxampattern(oldpattern)
end
if nombre='' then exit 0 /* CANCEL */
if ~exists(nombre) then
/* create the file */
if ~open('fichero',nombre,'WRITE') then exit
else nop
else
/* open the file in APPEND mode */
if ~open('fichero',nombre,'APPEND') then exit
else nop
endif
/* Extract from the spectrum's memory the block to save */
block=d2c(zxamtapeflag())
if zxamtapesize()~=0 then block=insert(block,zxamgetmem(zxamtapeaddress(),zxamtapesize()))
block=insert(block,d2c(zxamchecksumstring(block)))
/* append the block size */
size=zxamtapesize()+2
size=d2c(size)
if length(size)=1 then size=insert(d2c(0),size)
/* convert to inverted Z80 format */
size=reverse(size)
block=insert(size,block)
/* save the block */
dummy=writech('fichero',block)
ZXAMTapeSetSaveName(nombre)
ZXAMTapeSetResult(1)
dummy=close('fichero')
exit