home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Crawly Crypt Collection 1
/
crawlyvol1.bin
/
apps
/
misc
/
zx_sp207
/
source
/
spshell.gfa
(
.txt
)
< prev
next >
Wrap
GFA-BASIC Atari
|
1993-06-29
|
8KB
|
359 lines
' ###################################################
' ZX-SPECTRUM EMULATOR SHELL 3/93 C. Gandler
'
' This is only thought as demonstration what can
' be done, and HOW it can be done.
'
' Feel free to modify and extend !
' ###################################################
$m20000
$C+
$B+
$E$
'
' ## INLINE:
' $0000: 48 79 00 00 00 1e 2f 08 48 79 00 00 00 1e 3f 3c
' $0010: 00 04 3f 3c 00 4b 4e 41 4f ef 00 10 4e 75 00 00
' $0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
' $0030: 00 00
' 50 Bytes.
INLINE exe%,50
' ## INLINE:
' $0000: 00 00
' 2 Bytes.
INLINE inst%,2
'
test&=0 ! Test-Switch, set to 1 to test with Interpreter
IF test&=1
RESERVE 20000
ENDIF
maxtool%=7
'
' When the shell is executed from desktop, it terminates, after
' issuing a request to load SPECCI.DAT afterwards.
'
smode|=0
IF BYTE{BASEPAGE+129}<>189 AND test&=0
IF SHEL_READ(ownpath$,cmd$)=0
ownpath$=""
ENDIF
cmd$=CHAR{BASEPAGE+129}
IF cmd$<>""
cmd$=cmd$+" "
ENDIF
cmd$=cmd$+"/s"+ownpath$
~SHEL_WRITE(1,1,1,CHR$(LEN(cmd$))+cmd$,"SPECCI.DAT")
'
' If called from SPECCI.DAT the commandline is saved and scanned
'
ELSE
IF test&=0
cmd$=CHAR{BASEPAGE+128}
FOR j&=0 TO 6
x$=""
FOR i&=0 TO 7
x$=x$+CHR$(BYTE{BASEPAGE+130+j&*8+i&})
NEXT i&
x%=VAL("&h"+x$)
SELECT j&
CASE 0
setup%=x%+8 ! Adress of setup-patch-area
CASE 1
zxpage%=x% ! Adress of the ZX-Page whithin emulator
CASE 2
zxregs%=x% ! Adress of the Z80-register-structure
CASE 3
sstore%=x% ! Adress of emulator-screen-buffer
CASE 4
sup_ret%=x% ! Adress for return-value(s)
CASE 5
setnr%=x% ! Number of active set (0..3)
CASE 6
specci%=x% ! Adress, where to call the emulator
ENDSELECT
NEXT j&
smode|=BYTE{zxregs%-13} ! Called in Shell-Mode?
ENDIF
'
IF smode|
CLS
PRINT
PRINT "ZX-SPECTRUM EMULATOR SHELL V1.00"
PRINT "(c) 1993 by Christian Gandler"
PRINT
PRINT "Wait, emulator beeing initialized..."
PRINT
@fm
ELSE
IF BYTE{inst%}=0 AND test&=0
@patch(BASEPAGE+256)
ELSE
V~H=V_OPNVWK(XBIOS(4)+2)
ENDIF
ENDIF
BYTE{inst%}=1
'
DIM resbp%(maxtool%)
DIM tool$(maxtool%)
DIM tmen$(maxtool%)
DIM fpal&(maxtool%)
DIM keys&(maxtool%)
DIM palette&(16)
anzres%=0
IF EXIST("SPSHELL.INF")
OPEN "i",#2,"SPSHELL.INF"
WHILE NOT EOF(#2)
EXIT IF anzres%=maxtool%
INPUT #2,n$
EXIT IF n$="***"
INPUT #2,t$,rf&,fp&,key&
IF smode|=0
rf&=0
ENDIF
IF rf& AND MALLOC(-1)>200000
t%=MALLOC(MALLOC(-1)-200000)
bp%=EXEC(3,n$,cmd$,"")
IF t%>0
~MFREE(t%)
ENDIF
IF bp%>0
PRINT n$;" is resident."
' @bpi(bp%)
INC anzres%
resbp%(anzres%)=bp%
tool$(anzres%)=n$
tmen$(anzres%)=t$
fpal&(anzres%)=fp&
keys&(anzres%)=key&
ELSE
PRINT "Error ";INT(bp%);" loading ";n$;"."
REPEAT
UNTIL INKEY$<>""
ENDIF
@fm
ELSE
INC anzres%
resbp%(anzres%)=-1
tool$(anzres%)=n$
tmen$(anzres%)=t$
fpal&(anzres%)=fp&
keys&(anzres%)=key&
ENDIF
WEND
CLOSE #2
ENDIF
FOR i&=0 TO 15
palette&(i&)=DPEEK(&HFF8240+2*i&)
NEXT i&
RESTORE exedat
x%=exe%
DO
READ r%
EXIT IF r%=&HFFFF
DPOKE x%,r%
ADD x%,2
LOOP
DIM reg%(16)
'
@make_bar
'
DO
exit&=0
DO
IF test&=1 OR smode|=0
r%=1
ELSE
r%=C:specci%()
ENDIF
EXIT IF r%=0
FOR i&=1 TO anzres%
IF r%=SHR(keys&(i&),8)
exit&=i&
ENDIF
NEXT i&
IF exit&=0
~FORM_DIAL(3,0,0,0,0,0,0,WORK_OUT(0),WORK_OUT(1))
moff&=0
SHOWM
DEFMOUSE 0
ON MENU KEY GOSUB mkey
ON MENU GOSUB menu
MENU bar$()
DO
ON MENU 1000
EXIT IF moff&<>0 OR exit&<>0
LOOP
MENU OFF
MENU KILL
ENDIF
IF smode|=0 AND test&=0
IF moff&
exit&=99
ELSE
IF exit&=99
WORD{sup_ret%}=1
ENDIF
ENDIF
ENDIF
EXIT IF exit&<>0
LOOP
EXIT IF exit&=99 OR r%=0
@swp
bp%=resbp%(exit&)
IF bp%=-1
~EXEC(0,tool$(exit&),cmd$,"")
ELSE
reg%(8)=bp%
CHAR{bp%+128}=cmd$
RCALL exe%,reg%()
@patch(bp%+256)
ENDIF
@swp
EXIT IF smode|=0 AND test&=0
LOOP
ENDIF
IF test&=1
RESERVE
ENDIF
END
'
PROCEDURE swp
LOCAL r%,t%
IF fpal&(exit&)
FOR r%=0 TO 15
t%=palette&(r%)
palette&(r%)=DPEEK(&HFF8240+r%*2)
SDPOKE &HFF8240+r%*2,t%
NEXT r%
ENDIF
RETURN
'
PROCEDURE patch(s%)
'
' Diese Prozedur patcht GFA-Basic 3.6 Compilate, damit
' sie wiederaufruf-fähig werden, wenn sie resident im
' Speicher stehen (Start mit EXEC-Mode 4).
' s% -> Startadresse TEXT-Segment im Speicher
'
DO
EXIT IF DPEEK(s%)=&H4EB9 ! JSR init
ADD s%,2
LOOP
s%=LPEEK(s%+2) ! init
DO
EXIT IF DPEEK(s%)=&HA000 ! nach LINE-A Initialisierung
ADD s%,2
LOOP
IF DPEEK(s%+14)=&H6100 ! BSR InitAES aus-NOPen
s%=s%+14
DPOKE s%,&H4E71
DPOKE s%+2,&H4E71
ENDIF
RETURN
'
PROCEDURE mkey
LOCAL i&,m&
m&=MENU(14)
IF BYTE(m&)=27
moff&=1
ENDIF
FOR i&=1 TO anzres%
IF m&=keys&(i&)
exit&=i&
ENDIF
NEXT i&
RETURN
'
PROCEDURE menu
LOCAL m&,f&,x%,y%,w%,h%,t%,dia%
m&=MENU(0)
IF m&>=tools%
exit&=m&-tools%+1
ELSE
SELECT m&
CASE 1
f&=0
IF RSRC_LOAD("SPECCI.RSC")
f&=1
IF XBIOS(4)=2
t%=0
ELSE
t%=1
ENDIF
~RSRC_GADDR(0,t%,dia%)
~FORM_CENTER(dia%,x%,y%,w%,h%)
~OBJC_DRAW(dia%,0,7,x%,y%,w%,h%)
~FORM_DO(dia%,0)
~RSRC_FREE()
~FORM_DIAL(3,0,0,0,0,0,0,WORK_OUT(0),WORK_OUT(1))
ENDIF
IF f&=0
ALERT 1,"* ZX-SPECTRUM EMULATOR SHELL *| V1.0 - Demo, (c) 1993| | by Christian Gandler",1," OK ",q&
ENDIF
MENU OFF
CASE 11
moff&=1
CASE 13
exit&=99
DEFAULT
MENU OFF
ENDSELECT
ENDIF
RETURN
'
PROCEDURE fm
PRINT MALLOC(-1);" Bytes of free memory"
RETURN
'
PROCEDURE bpi(x%)
PRINT "TEXT=";LONG{x%+12};", DATA=";LONG{x%+20};", BSS=";LONG{x%+28}
RETURN
'
PROCEDURE make_bar
LOCAL i&,j&
DIM bar$(60)
RESTORE bar
FOR i&=0 TO 60
READ bar$(i&)
EXIT IF bar$(i&)="***"
NEXT i&
tools%=i&
IF anzres%=0
DEC i&
ELSE
FOR j&=1 TO anzres%
bar$(i&)=tmen$(j&)
INC i&
NEXT j&
ENDIF
bar$(i&)=""
RETURN
'
bar:
DATA SPECCI, About... ,---------------------,1,2,3,4,5,6,
DATA Options, ⇨ Emulator,-------------------, Quit to desktop ,
DATA Tools
DATA ***
'
exedat:
DATA &H4879,&H0000,&H001E
' pea nullstrg
DATA &H2F08
' move.l a0,-(sp)
DATA &H4879,&H0000,&H001E
' pea nullstrg
DATA &H3F3C,&H0004
' move.w #4,-(sp)
DATA &H3F3C,&H004B
' move.w #pexec,-(sp)
DATA &H4E41
' trap #gemdos
DATA &H4FEF,&H0010
' lea 16(sp),sp
DATA &H4E75
' rts
DATA &H0000
' nullstrg: dc.b 0
DATA &HFFFF
' (Endmark)