home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CBM Funet Archive
/
cbm-funet-archive-2003.iso
/
cbm
/
programming
/
kosmon.zoo
/
kosmon.asm
Wrap
Assembly Source File
|
1996-03-16
|
33KB
|
2,365 lines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;kOSmON - a mACHINE lANGUAGE mONITOR FOR c64 AND pet.
;;
;;(c) 1986-1996 BY oLAF sEIBERT. aLL rIGHTS rESERVED.
;;mAY BE DISTRIBUTED UNDER THE gnu gENERAL pUBLIC lICENSE.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; hINTS FOR THE c64 $c000 VERSION:
; mOVE THE ENTRY POINT, MARKED WITH ///, TO THE INDICATED PLACE,
; AND CHANGE THE BASE AND brk ENTRY POINT ACCORDINGLY.
; fOR A <4k VERSION, SET THE SYMBOL HAVEECMD TO 0.
PROCESSOR 6502
MAC CSET; CONDITIONAL SET
IFNCONST {$7b}1{$7d}
{$7b}1{$7d}= {$7b}2{$7d}
ENDIF
ENDM
CSET BASE, $9000; /// -$CC
C64= 1
PET= 2
CSET TARGET, PET
; THE SETTINGS BELOW ARE FOR PETS ONLY.
; nOTE THERE IS ONLY ALLOWANCE FOR bASIC 2.0 (NEW ROMS) AND 4.0.
CSET PETB2,0; FLAG
CSET PETB4,1; FLAG
CSET PETB440,0; FLAG FOR PETB4 ONLY
CSET PETB480,1; FLAG FOR PETB4 ONLY
LINES= 25
#IF PETB4 && PETB480
COLUMNS = 80
#ELSE
COLUMNS = 40
#ENDIF
MINDISKDEV = 8
DISKDEV = 8; MY TASTE
PRINTDEV = 4; MY TASTE
PRINTSA = 7; MY TASTE
CSET HAVEDASHES, 1
#IF TARGET == C64
CSETHAVEECMD, 1
HAVEPFKEYS = 1
#ELSE
HAVEECMD = 0
HAVEPFKEYS = 0
#ENDIF
#IF [TARGET == PET] && PETB2
CSET AUTOREPEAT, 1
#ELSE
CSET AUTOREPEAT, 0
#ENDIF; (TARGET == PET) && PETB2
#IF AUTOREPEAT
SLOWREP = 23; TIME BEFORE FIRST REPEAT (IN JIFFIES)
FASTREP= 4; TIME BETWEEN REPEATS (IN JIFFIES)
#ENDIF; AUTOREPEAT
;+++ ABSOLUTE ADRESSES
#IF TARGET == C64
PPORT= $01
STATUS= $90
VERCK= 0; NOT NEEDED
MSGFLG= $9D
FNLEN= $B7
SA= $B9
FA= $BA
STAL= $C1
MEMUSS= STAL+2
NDX= $C6
INDX= $C8
LXSP= $C9
BLNSW= $CC
GDBLN= $CE
BLNON= $CF
EAL= $AE
CRSW= $D0
PNT= $D1
PNTR= $D3
QTSW= $D4
TBLX= $D6
DATAX= $D7
LDTBL= $D9
RTSP= $0200
RTSTACK = $0201
KEYD= $0277
GDCOL= $0287
HIBASE= $0288
AUTODN= $0292
TMPLIN= $02A5
CIRQV= $0314
CBRKV= $0316
;+++ EXTERNAL JUMPS
BASNMI= $A002
VICRESET = $E5A8
KBDGET= $E5B4
SCRCONT = $E602
SCRGET= $E63A
SCRPRINT = $E716
INSTLIN = $E981
POKCHR= $EA13
KBDINPUT = $F15B
BUSCLSE = $F651
IOINIT= $FDA3
SECOND= $FF93
TKSA= $FF96
IECIN= $FFA5
IECOUT= $FFA8
UNTLK= $FFAB
UNLSN= $FFAE
LISTEN= $FFB1
TALK= $FFB4
SETLFS= $FFBA
SETNAM= $FFBD
LOAD= $FFD5
SAVE= $FFD8
STOP= $FFE1
#ENDIF
#IF TARGET == PET
TIME= $8D
CIRQV= $90
CBRKV= $92
STATUS= $96
LSTX= $97
NOKEY= $FF; FOR LSTX
VERCK= $9D
NDX= $9E
INDX= $A1
LXSP= $A3
BLNSW= $A7
BLNCT= $A8
GDBLN= $A9
BLNON= $AA
CRSW= $AC
EAL= $C9
FNLEN= $D1
LA= $D2
SA= $D3
FA= $D4
PNT= $C4
PNTR= $C6
QTSW= $CD
TBLX= $D8
DATAX= $D7
FNADR= $DA
#IF PETB4 && PETB480
LDTBL= 0; NOT IMPLEMENTED
#ELSE
LDTBL= $E0
#ENDIF; PETB4 && PETB480
STAL= $FB
MEMUSS= STAL+2
RTSP= $0200
RTSTACK = $0201
KEYD= $026F
TMPLIN= 0; NOT IMPLEMENTED
MSGFLG= 0; NOT IMPLEMENTED
GDCOL= 0; NOT IMPLEMENTED
AUTODN= 0; NOT IMPLEMENTED
HIBASE= 0; NOT IMPLEMENTED
;+++ EXTERNAL JUMPS
SETNAM= 0; NOT IMPLEMENTED
SETLFS= 0; NOT IMPLEMENTED
#IF PETB2
BASREADY = $C389; BASIC ready.
IOINIT= 0
KBDGET= $E285
SCRPRINT = $E3D8; PRINT .a TO SCREEN (COULD USE ffd2)
VICRESET = 0
INSTLIN = $E5BA; REALLY: OPEN LINE ON SCREEN
TALK= $F0B6 ; SEND talk
LISTEN= $F0BA ; SEND listen
SECOND= $F128 ; SEND sa AFTER listen
TKSA= $F164 ; SEND sa AFTER talk
IECOUT= $F16F ; SEND BYTE TO ieee BUS
UNTLK= $F17F ; SEND untalk
UNLSN= $F183 ; SEND unlisten
IECIN= $F18C ; GET BYTE FROM ieee BUS
ROMLOAD = $F322 ; o/s VERSION OF load
SEARCHING = $F40A; PRINT searching for NAME
SENDNAME = $F466; SEND PROGRAM NAME TO BUS
LOADING = $F42E ; PRINT loading
SAVE= $F6A4 ; o/s VERSION OF save
BUSLSNCLSE = $F6F0; SEND listen, close AND unlisten
BUSCLSE = $F6FD ; SEND close AND unlisten
KBDINPUT = $F1E5; ffcf AFTER CHECKING FOR KEYBOARD
STOP= $F301 ; TEST stop KEY
SCRCONT = $E2CC ; CONTINUE input LOOP
SCRGET= $E2FC ; input (GET) BYTE FROM SCREEN
POKCHR= $E6EA ; PUT CHAR (AND COLOUR) IN SCREEN MEMORY
; THE n-KEYBD VERSION HAS AN EXTRA DELAY LOOP
; HERE BUT WE CAN'T AVOID THAT: WOULD NOT WORK
; WITH THE b VERSION.
#ENDIF; PETB2
#IF PETB4
; sIGH... THE e000 JUMPTABLE ENTRIES ARE NOT
; IN THE "UPGRADE" 4.0 VERSION FOR petS WITHOUT
; crt CONTROLLER... SIGH...
BASREADY = $B3FF
IOINIT= $E000
KBDGET= $E0A7 ; $E003 WOULD BE BETTER BUT LESS COMPATIBLE
SCRPRINT = $E202; $E009 PRINT .a TO SCREEN
VICRESET = $E018; LOWER CASE SETTINGS
INSTLIN = $E021
TALK= $F0D2
LISTEN= $F0D5
SECOND= $F143
TKSA= $F193
IECOUT= $F19E
UNTLK= $F1AE
UNLSN= $F1B9
IECIN= $F1C0
ROMLOAD = $F356
SEARCHING = $F449
SENDNAME = $F4A5
LOADING = $F46D
SAVE= $F6E3
BUSLSNCLSE = $F72F
BUSCLSE = $F73C
STOP= $F335
KBDINPUT = $F219
#IF PETB440
SCRCONT = $E0EE ; ACCIDENTALLY THE SAME IN 40 AND 80 COLUMS
SCRGET= $E11E
POKCHR= $E606 ; ACCIDENTALLY THE SAME IN 40 AND 80 COLUMS
#ENDIF; PETB440
#IF PETB480
SCRCONT = $E0EE ; ACCIDENTALLY THE SAME IN 40 AND 80 COLUMS
SCRGET= $E121
POKCHR= $E606 ; ACCIDENTALLY THE SAME IN 40 AND 80 COLUMS
#ENDIF; PETB480
#ENDIF; PETB4
;+++ TABLES AND HARDWARE ADDRESSES
SCREEN= $8000
#IF PETB4 && PETB480
RAM96LATCH = $FFF0; SET TO 0 TO NOT SUPPORT IT.
#ELSE
RAM96LATCH = 0; SET TO 0 TO NOT SUPPORT IT.
#ENDIF
#ENDIF; TARGET == PET
;+++ CONSTANTS
CR= $0D
CU= $91; "^q"
CD= $11; "^Q"
HOME= $13; "^S"
RVS= $12; "^R"
OFF= $92; "^r"
PF1= $85; "^e"
CRI= $1D; "^]"
CL= $9D; "^]"
QUOTE= 34
HEXWIDTH = COLUMNS / 5; 8 OR 16
ASCWIDTH = 4 * COLUMNS / 5; 32 OR 64
ORG BASE
; +++ PROGRAM
;///MARK WITH START
ENTRYPHP
PHA
LDA #<ROMIN
STA CBRKV
LDA #>ROMIN
STA CBRKV+1
LDA #0
STA RTSP
PLA
PLP
BRK
ROMIN
#IF TARGET == C64
LDA #$36
STA PPORT
#IF .ROMIN_END != RAMIN
JMP RAMIN
#ENDIF
.ROMIN_END
#ENDIF
;///MARK WITH END
SUBROUTINE
RAMINCLD
LDX #5
IC012PLA
STA RSPACE,X
DEX
BPL IC012
TSX
STX SPSAVE
STX STACKMK
LDA PCLO
BNE IC028
DEC PCHI
IC028DEC PCLO
LSR PFLAG
LDA FA
CMP #MINDISKDEV
BCS IC038
LDA #DISKDEV
STA FA
IC038
#IF MSGFLG
LDA #$C0
STA MSGFLG
#ENDIF
JSR DOCR
JMP RCMD
;LDA #"r"
;BNE DOCMD
ERRORLDA #"?"
JSR SCRPRINT
PROMPTJSR DOCR
LDA #"."
JSR SCRPRINT
LDA #0
STA OVFLOW
STA PFLAG
EXECUTE LDX STACKMK
TXS
IC05CJSR NEXTCHR
CMP #"."
BEQ IC05C
DOCMDLDX #ADRTAB-CMDTAB-1
CMDLOOP CMP CMDTAB,X
BNE CMDNXT
STA CMDCHR
TXA
ASL ;A
TAX
LDA ADRTAB+1,X
PHA
LDA ADRTAB,X
PHA
PHP
RTI ;DO THE COMMAND
CMDNXTDEX
BPL CMDLOOP
BMI ERROR
; THE P COMMAND IS A PREFIX FOR THE OTHERS.
; WHEN USED IT PRINTS ON BOTH THE SCREEN AND PRINTER #PRINTDEV.
PCMDSEC
ROR PFLAG; SET HIGH BIT
BNE EXECUTE
;+++ POINTER ROUTINES
STSTLINC
JSR STASTAL
INCSTAL INC STAL
BNE IC6A0
INC STAL+1
BNE IC6A0
INC OVFLOW
IC6A0RTS
DECMUSS LDX #2
DC.B $2C
DECSTAL LDX #0
LDY STAL,X
BNE IC09B
LDY STAL+1,X
BNE IC099
INC OVFLOW
IC099DEC STAL+1,X
IC09BDEC STAL,X
RTS
STALEQSV
LDA STALSAV
LDY STALSAV+1
JMP IC0CE
STEQEND LDA MEMUSS
LDY MEMUSS+1
IC0CESEC
SBC STAL
STA LOLEFT
TYA
SBC STAL+1
TAY ;HILEFT
ORA LOLEFT
RTS
SWSTEND LDX #2
IC5F0LDA STAL-1,X
PHA
LDA MEMUSS-1,X
STA STAL-1,X
PLA
STA MEMUSS-1,X
DEX
BNE IC5F0
RTS
STPCSTA PCLO
STX PCHI
RTS
;/// MOVE ENTRY FOR $C000 HERE
;+++ CONVERSION ROUTINES
SPHEX2PHA
JSR DOSPC
PLA
JMP HEX2
HEX4LDA STAL+1
JSR HEX2
LDA STAL
HEX2PHA
LSR ;A
LSR ;A
LSR ;A
LSR ;A
JSR HEX1
TAX
PLA
AND #$0F
JSR HEX1
PRINTXA PHA
TXA
JSR PRINT
PLA
JMP PRINT
A2HEXAX PHA
LSR ;A
LSR ;A
LSR ;A
LSR ;A
JSR HEX1
TAX
PLA
AND #$0F
HEX1CLC
ADC #$F6
BCC IC5EB
ADC #6
IC5EBADC #$3A
RTS
DECILDX #8
ICA3DSEC
LDA STAL
CMP TENPOW,X
LDA STAL+1
SBC TENPOW+1,X
BCS ICA4E
DEX
DEX
BNE ICA3D
ICA4ELDY #$30
SEC
ICA51LDA STAL
SBC TENPOW,X
PHA
LDA STAL+1
SBC TENPOW+1,X
BCC ICA66
STA STAL+1
PLA
STA STAL
INY
BNE ICA51
ICA66PLA
TYA
JSR PRINT
DEX
DEX
BPL ICA4E
RTS
; PRINT .sr
PRINTPS JSR DOSPC
LDA PSSAVE
BIN8LDX #8; PRINT .a BINARY
IC704ROL ;A
PHA
LDA #"*"
BCS IC70C
LDA #"."
IC70CJSR PRINT
PLA
DEX
BNE IC704
RTS
GETSTEND
JSR HEX2STAL
STA MEMUSS
STX MEMUSS+1
JSR EOL
BEQ IC3AB
JSR HEX2MUSS
IC3ABJMP DOCR
GET3ADRS; GET ADDRESSES TO MEMUSS, STALSAV, STAL.
JSR HEX2MUSS
;STA MEMUSS
;STX MEMUSS+1
JSR HEX2AX
STA STALSAV
STX STALSAV+1
HEX2STAL; GET ADDRESS TO STAL
JSR HEX2AX
STA STAL
STX STAL+1
RTS
HEX2MUSS; GET ADDRESS TO MEMUSS
JSR HEX2AX
STA MEMUSS
STX MEMUSS+1
RTS
HEX2AXJSR HEX2A; GET HEX ADDRESS TO A,X
;BCC ERRC6
TAX
;JSR HEX2A
;BCC ERRC6
;RTS
HEX2A;LDA #0 ; GET HEX BYTE TO .a
;STA NYBBLE
JSR NEXTCHR
HEXA2AJSR HEX2NYBB; GET HEX BYTE IN .a DECODED TO .a
ASL ;A
ASL ;A
ASL ;A
ASL ;A
STA NYBBLE
JSR NEXTCHR
JSR HEX2NYBB
ORA NYBBLE
SEC
RTS
ERRCDJMP ERROR
HEX2NYBB; CONVERT CHARACTER TO HEX NYBBLE
CMP #":"
BCC IC651
SBC #7
IC651AND #$0F
RTS
TST0FCMP #"0" ; TEST FOR 0-f
BCC IC50E
CMP #"g"
RTS ;C=0:MOGELIJK CIJFER
IC50ESEC ;GEEN CIJFER
RTS
; HEXADECIMAL OR DECIMAL INPUT
HDIN4LDY #0
STY $00,X
STY $01,X
CMP #"$"
BEQ HEXIN4
JSR TST09
BCS ERRCD
ICD14PHA; DECIMAL INPUT
ASL $00,X; * 10
LDA $00,X
ROL $01,X
LDY $01,X
ASL ;A
ROL $01,X
ASL ;A
ROL $01,X
CLC
ADC $00,X
STA $00,X
BCC ICD2C
INY
CLC
ICD2CPLA
ADC $00,X
STA $00,X
TYA
ADC $01,X
STA $01,X
JSR KBDINPUT
JSR TST09
BCC ICD14
RTS
HEXIN4JSR HEXIN1; INPUT 1-4 HEXADECIMAL DIGITS (4 SIGNIFICANT)
BCS ERRCD
ICD44LDY #4
ICD46ASL $00,X
ROL $01,X
DEY
BNE ICD46
ORA $00,X
STA $00,X
JSR HEXIN1
BCC ICD44
RTS
HEXIN1JSR KBDINPUT; INPUT 1 HEXADECIMAL DIGIT
CMP #"g"
BCS ICD74
CMP #"a"
BCS ICD70
TST09CMP #"0" ; TEST IF BETWEEN 0 AND 9
BCC ICD74
CMP #":"
BCS ICD74
AND #$0F
RTS
ICD70SBC #$37
CLC
RTS
ICD74SEC
RTS
BIN2ALDX #8; BINARY TO .a
IC752PHA
JSR NEXTCHR
CMP #"*"
BEQ IC75B
CLC
IC75BPLA
ROL ;A
DEX
BNE IC752
RTS
EOLLDA PNTR; TEST IF AT THE END OF INPUT
CMP INDX
RTS
NEXTCHR JSR INPSKSP; GET NEXT NOSPACE CHARACTER
BNE NOCR; ALWAYS
INPSKSP JSR INPUT; GET CHARACTER, SKIPPING SPACES
SKIPSPC CMP #" "
BEQ INPSKSP
IC653RTS
INPNOCR JSR INPUT; GET NEXT CHARACTER
NOCRCMP #CR ; ERROR IF CR
BNE IC653
JMP ERROR; PROMPT
;+++ COMMAND ROUTINES
CCMDLDA #0; cOMPARE COMMAND
DC.B $2C
TCMDLDA #1; tRANSFER COMMAND
STA CTFLAG; REMEMBER c OR t
JSR GET3ADRS; GET sTART, eND, dEST
JSR DOCR
JSR STEQEND
JSR SWSTEND
BCC IC10D
IC0F2JSR STALEQSV
BCS IC0FA
JMP PROMPT
IC0FAJSR CTBYTE
INC MEMUSS
BNE IC103
INC MEMUSS+1
IC103JSR INCSTAL
LDY OVFLOW
BNE IC153
BEQ IC0F2
IC10DJSR STALEQSV
CLC
LDA LOLEFT
ADC MEMUSS
STA MEMUSS
TYA
ADC MEMUSS+1
STA MEMUSS+1
;JSR SWPADRS WAS SUBR
SWPADRS LDX #2
IC0B1LDA STAL-1,X
PHA
LDA STALSAV-1,X
STA STAL-1,X
PLA
STA STALSAV-1,X
DEX
BNE IC0B1
;RTS
IC120JSR CTBYTE
JSR STALEQSV
BCS PRPTC1
JSR DECMUSS
JSR DECSTAL
LDY OVFLOW
BNE IC153
BEQ IC120
CTBYTEJSR LDASTAL
LDY CTFLAG
BEQ IC142
JMP STAMUSS
IC142JSR CMPMUSS
BEQ IC152
HEX4STOP; PRINT 4 HEX DIGITS, SPACE, TEST stop
JSR HEX4
JSR DOSPC
JSR STOP
BEQ IC153
IC152RTS
IC153JMP PROMPT
FCMDJSR HEX2STAL
JSR HEX2MUSS
JSR HEX2A
;BCC ERRC1
STA APOS
IC167LDX OVFLOW
BNE PRPTC1
JSR STEQEND
BCC PRPTC1
LDA APOS
JSR STASTAL
JSR INCSTAL
BNE IC167; ALWAYS
PRPTC1JMP PROMPT
HCMDJSR HEX2STAL
JSR HEX2MUSS
LDX #0
JSR NEXTCHR
CMP #"'"
BNE HUNTHEX
JSR NEXTCHR
IC197STA HUNTBUF,X
INX
JSR KBDINPUT
CMP #CR
BEQ IC1C4
CPX #END-HUNTBUF
BNE IC197
BEQ IC1C4
HUNTHEX ;STX NYBBLE
JSR HEXA2A
BCC ERRC1
IC1B0STA HUNTBUF,X
INX
JSR INPSKSP
CMP #CR
BEQ IC1C4
JSR HEXA2A
BCC ERRC1
CPX #END-HUNTBUF
BNE IC1B0
IC1C4STX HUNTLEN
JSR DOCR
HUNTLOOP
LDX #0
LDY #0
TESTNEXT
JSR LDASTALY
CMP HUNTBUF,X
BNE IC1E0
INY
INX
CPX HUNTLEN
BNE TESTNEXT
JSR HEX4STOP
IC1E0JSR INCSTAL
LDY OVFLOW
BNE PRPTC1E
JSR STEQEND
BCS HUNTLOOP
PRPTC1E JMP PROMPT
ERRC1JMP ERROR
YCMDLDA #0
STA HUNTLEN
JSR HEX2STAL
JSR HEX2MUSS
Y02JSR INPSKSP
CMP #CR
BEQ YLOOP
JSR TST0F
BCS ERRC1
JSR HEXA2A
LDY HUNTBUF
STY HUNTBUF+1
STA HUNTBUF
INC HUNTLEN
BNE Y02
YLOOPJSR STEQEND
BCC PRPTC1E
JSR OPREDU
LDY OPLEN
CPY HUNTLEN
BNE Y00
Y01JSR LDASTALY
CMP HUNTBUF-1,Y
BNE Y00
DEY
BNE Y01
JSR DLINECM
Y00JSR ADSTALEN
JSR STOP
BNE YLOOP
BEQ PRPTC1E
DCMDJSR GETSTEND; dISASSEMBLE COMMAND
DLOOPJSR STEQEND
BCC CUPRPT
JSR DDASHES
JSR ADSTALEN
JSR STOP
BNE DLOOP
CUPRPTJSR PRINTCU
BNE PRPTC1E
#IF HAVEDASHES
DDASHES JSR DLINECM
DASHESJSR LDASTAL
TAY
AND #%11011111;JMP/JMP()
CMP #%01001100
BEQ DODASHES
TYA
AND #%10011111;BRK/RTS/RTI/JSR
CMP #%00000000
BNE NODASHES
CPY #%00100000;JSR
BEQ NODASHES
DODASHES
JSR DOCR
LDX #35
LDA #"-"
ILI0JSR PRINT
DEX
BNE ILI0
NODASHES
#ELSE
DDASHES = DLINECM
#ENDIF; HAVEDASHES
RTS
DLINECM LDY #","
DLINEJSR DINSTR
LDX #9
DOXSPJSR DOSPC; PRINT .x SPACES
DEX
BNE DOXSP
RTS
DINSTRJSR CRDOTYSP; DISASSEMBLE ONE OPCODE
DINSTR2 JSR HEX4
JSR DOSPC
JSR OPREDU
PHA
JSR DDUMP
PLA
JSR UNPACK
LDX #6
IC220CPX #3
BNE IC239
LDY OPLEN
BEQ IC239
;PRINT HEX BYTE/S
IC229LDA MODE
CMP #$E8;RELATIVE
JSR LDASTALY; MUST PRESERVR CARRY
BCS PRTRELAD
JSR HEX2SAVX
DEY
BNE IC229
IC239ASL MODE
BCC IC24C ;842184
LDA MODES1-1,X;$(#,),
JSR PRTNOSUP
LDA MODES2-1,X; $$X Y
BEQ IC24C
JSR PRTNOSUP
IC24CDEX
BNE IC220
RTS
PRTRELAD
JSR ADCSTALA
TAX
INX ;LOW
BNE IC258
INY ;HI
IC258TYA
JSR HEX2SAVX
TXA
HEX2SAVX STX .+7
JSR HEX2
LDX #0; OPERAND MODIFIED
RTS
ADSTALEN LDA OPLEN
ADDSTAA JSR AD1STALA
STA STAL
STY STAL+1
RTS
AD1STALA SEC ;SIGNED ACCU
ADCSTALA LDY STAL+1
TAX
BPL IC279
DEY
IC279ADC STAL
BCC IC27E
INY
IC27ERTS
; rEDUCE OPCODE TO ESSENTIAL INSTRUCTION INFO
; USED BY A,D,Y,SCROLL
OPREDUJSR LDASTAL
REDUCETAY
LSR ;A
BCC IC28E
LSR ;A
BCS IC29D
CMP #$22
BEQ IC2A5
AND #7
ORA #$80
IC28ELSR ;A
TAX
LDA ILLTAB,X
BCS IC299
LSR ;A
LSR ;A
LSR ;A
LSR ;A
IC299AND #$0F
BNE IC2A9
IC29DLSR ;A
BCC IC2A5
AND #1
ADC #1;C=1
DC.B $2C
IC2A5LDA #0
LDY #$80
IC2A9TAX
LDA MODES,X
STA MODE
AND #3
STA OPLEN
TYA
AND #$8F
TAX
TYA
LDY #3
CPX #$8A
BEQ IC2CB
IC2C0LSR ;A
BCC IC2CB
LSR ;A
IC2C4LSR ;A
ORA #$20
DEY
BNE IC2C4
INY
IC2CBDEY
BNE IC2C0
RTS
DDUMPJSR LDASTALY
JSR HEX2SAVX
LDX #1
IC2D7JSR DOXSP
CPY OPLEN
INY
BCC DDUMP
LDX #3
CPY #3
BCC IC2D7
JMP DOSPC
UNPACKTAY
LDA RD2PKLO,Y
STA STALSAV
LDA RD2PKHI,Y
STA STALSAV+1
IC2F4LDA #0
LDY #5
IC2F8ASL STALSAV+1
ROL STALSAV
ROL ;A
DEY
BNE IC2F8
ADC #$3F
JSR PRINT
DEX
BNE IC2F4
JMP DOSPC
CMCMDJSR HEX2STAL
LDA #3
JSR DOCOLON
LDY #","
JMP FILLKEYD
SUBROUTINE
LTCMDCLC; < COMMAND
DC.B $24
HTCMDSEC; > COMMAND
PHP
JSR HEX2STAL
JSR INPSKSP
CMP #QUOTE
BNE ERRC2
PLP
PHP
BCC ICA8E
ICA82JSR KBDINPUT
LDX CRSW
BEQ ICA9D
JSR STSTLINC
BNE ICA82
ICA8ELDY PNTR
LDA (PNT),Y
INC PNTR
CPY INDX
BCS ICA9D
JSR STSTLINC
BNE ICA8E
ICA9DLDA #"<"
PLP
BCC ICAA4
LDA #">"
ICAA4STA KEYD
LDA #0
STA KEYD+1
LDA #QUOTE
JMP FILKEYD2
ERRC2JMP ERROR
SUBROUTINE
KCMDJSR GETSTEND; K COMMAND
.TOPLDX OVFLOW
BNE .END
JSR STEQEND
BCC .END
JSR CRASCDMP
JSR STOP
BNE .TOP
.ENDJMP CUPRPT
SUBROUTINE
CRASCDMP
JSR DOCR
DOASCDMP
LDX #"."
LDA #">"
JSR PRINTXA
JSR HEX4
LDA #QUOTE
JSR PRINT
LSR QTSW
LDY #ASCWIDTH
BNE ASCDMP
DOCOLON STA APOS
PHA
;IC31EJSR ABYTESIN
ABYTESIN
JSR INPNOCR
CMP #" "
BNE IC68E
JSR INPNOCR
JSR TST0F
BCS IC68E;IF NOT A DIGIT
JSR HEXA2A
;BCC IC68E
;LDX #0
JSR STASTAL
JSR CMPSTAL
BNE ERRC2
IC68EJSR INCSTAL
DEC APOS
;RTS
BNE ABYTESIN;IC31E
PLA
SBCSTAA EOR #$FF
JMP ADDSTAA
MCMDJSR GETSTEND
IC32FLDX OVFLOW
BNE IC341
JSR STEQEND
BCC IC341
JSR CRHEXDMP
JSR STOP
BNE IC32F
IC341JMP CUPRPT
CRHEXDMP; PRINT cr AND HEX DUMP
JSR DOCR
DOHEXDMP; DO HEX DUMP
LDX #"."
LDA #":"
JSR PRINTXA
JSR DOSPC
JSR HEX4
LDA #HEXWIDTH
;JSR AHEX2 WAS SUBROUTINE
AHEX2STA APOS
LDY #0
IC66AJSR DOSPC
JSR LDASTALY
JSR HEX2
JSR INCSTAL
DEC APOS
BNE IC66A
;RTS
LDA #HEXWIDTH
JSR SBCSTAA
LDY #HEXWIDTH
ASCDMPJSR LDASTAL
PHA
AND #$7F
CMP #$20
PLA
PHP
BCS IC374
PHA
LDA #RVS
JSR PRINT
PLA
ORA #$40
IC374JSR PRINT
LSR QTSW
PLP
BCS I300
LDA #OFF
JSR PRINT
I300JSR INCSTAL
DEY
BNE ASCDMP
RTS
COCMDJSR HEX2STAL; : COLON COMMAND
LDA #HEXWIDTH
JSR DOCOLON
JSR PRINTCU
JSR CRHEXDMP
LDA #":"
FILKEYD0
STA KEYD
JMP FILKEYD1
ACMDJSR HEX2AX
STA MEMUSS
STX MEMUSS+1
IC3B5LDX #0; FIND 3-LETTER WORD
STX HUNTBUF+1
IC3BAJSR INPNOCR
CMP #" "
BEQ IC3B5
STA ABUF,X
INX
CPX #3
BNE IC3BA
IC3C9DEX
BMI IC3E0
LDA ABUF,X
SEC
SBC #$3F
LDY #5; 5 BITS OF THE LETTER
IC3D4LSR ;A
ROR HUNTBUF+1
ROR HUNTBUF
DEY
BNE IC3D4
BEQ IC3C9
; 3*5 BITS FIT IN A WORD
IC3E0LDX #2
IC3E2JSR KBDINPUT
CMP #CR
BEQ IC40B
CMP #":"
BEQ IC40B
CMP #" "
BEQ IC3E2
; THERE IS AN OPERAND
JSR TST0F
BCS IC405
JSR HEXA2A
LDY STAL
STY STAL+1
STA STAL; SAVE LO/HI ORDER
LDA #$30
STA HUNTBUF,X
INX
IC405STA HUNTBUF,X
INX
BNE IC3E2
IC40BSTX STALSAV
LDX #0; TRIED OPCODE
STX OVFLOW
ALOOPLDX #0
STX APOS
LDA OVFLOW
JSR REDUCE
LDX MODE
STX STALSAV+1
TAX
LDA RD2PKHI,X
JSR AMATCH
LDA RD2PKLO,X
JSR AMATCH
LDX #6
IA433CPX #3
BNE IC44B
LDY OPLEN
BEQ IC44B
IC43CLDA MODE
CMP #$E8
LDA #$30
BCS IC463
JSR AMATCH2
DEY
BNE IC43C
IC44BASL MODE
BCC IC45E
LDA MODES1-1,X
JSR AMATCH
LDA MODES2-1,X
BEQ IC45E
JSR AMATCH
IC45EDEX
BNE IA433
BEQ IC469
IC463JSR AMATCH2
JSR AMATCH2
IC469LDA STALSAV
CMP APOS
BEQ IC474
JMP NXTOPC
IC474JSR SWSTEND
LDY OPLEN
BEQ IC4AB
LDA STALSAV+1
CMP #$9D
BNE IC4A2
JSR STEQEND
BCC IC492
TYA
BNE ERRC4
LDX LOLEFT
BMI ERRC4
BPL IC49A
IC492INY
BNE ERRC4
LDX LOLEFT
BPL ERRC4
IC49ADEX
DEX
TXA
LDY OPLEN
BNE IC4A5
IC4A2LDA STAL+1,Y
IC4A5JSR STASTALY
DEY
BNE IC4A2
IC4ABLDA OVFLOW
JSR STASTALY
LDY #"a"
FILLKEYD
STY KEYD
JSR PRINTCU
JSR DLINE
JSR ADSTALEN
FILKEYD1
LDA #" "
STA KEYD+1
FILKEYD2
STA KEYD+6
LDA STAL+1
JSR A2HEXAX
STX KEYD+2
STA KEYD+3
LDA STAL
JSR A2HEXAX
STX KEYD+4
STA KEYD+5
LDA #7
STA NDX
JMP PROMPT
AMATCH2 JSR AMATCH
AMATCHSTX HUNTLEN
LDX APOS
CMP HUNTBUF,X
BEQ IC4FF
PLA
PLA
NXTOPCINC OVFLOW ;TRIED OPCODE
BEQ ERRC4
JMP ALOOP
ERRC4JMP ERROR
IC4FFINX
STX APOS
LDX HUNTLEN
RTS
JCMDLDA #$20;JSR
DC.B $2C
GCMDLDA #$4C ;JMP
STA AC56B
JSR KBDINPUT
CMP #CR
BEQ IC54A
CMP #" "
BNE IC56F
JSR HEX2AX
JSR STPC
JSR KBDINPUT
CMP #CR
BNE ERRC4
IC54AJSR DOCR
LDX SPSAVE
TXS
LDA PCHI
STA AC56B+2
LDA PCLO
STA AC56B+1
LDA PSSAVE
PHA
LDA ACSAVE
LDX XRSAVE
LDY YRSAVE
PLP
AC56BJMP $FFFF; THIS ADDRESS WILL BE MOFIFIED
BRK
IC56FCMP #"f"
BNE ERRC4
;LDA AC56B
;CMP #$4C; JMP
;BNE ERRC4
JSR KBDINPUT
CMP #" "
BNE ERRC4
JSR HEX2AX
STA MEMLO
STX MEMHI
LDA #"e"
JSR DISKMRW
JSR UNLSN
JMP PROMPT
RCMDLDX #0; rEGISTER DUMP CMD
IC6B6LDA RTXT,X
JSR PRINT
INX
CPX #CMDTAB-RTXT
BNE IC6B6
LDA PCHI
JSR HEX2
LDA PCLO
JSR HEX2
JSR DOSPC
LDA CIRQV+1
JSR HEX2
LDA CIRQV
JSR HEX2
#IF TARGET == C64
LDA PPORT
#ENDIF
#IF TARGET == PET
LDA BANKPP
#ENDIF
JSR SPHEX2
LDA FA
JSR SPHEX2
LDY #0
IC6E8LDA ACSAVE,Y
JSR SPHEX2
INY
CPY #4
BCC IC6E8
JSR PRINTPS
JMP PROMPT
; SEMICOLON CMD
SCCMDJSR HEX2AX; PC
JSR STPC
JSR HEX2AX; IRQ
SEI
STA CIRQV
STX CIRQV+1
CLI
JSR HEX2A; PROCESSOR PORT
#IF TARGET == C64
STA PPORT
#ENDIF
#IF TARGET == PET
STA BANKPP
#ENDIF
JSR HEX2A; DRIVE
STA FA
LDY #0
IC739JSR HEX2A
STA ACSAVE,Y
INY
CPY #4
BCC IC739
JSR BIN2A
STA PSSAVE
JMP PROMPT
ICMD
#IF IOINIT
JSR IOINIT; iNITIALISE io COMMAND
#ENDIF
#IF HIBASE
LDA #4
STA HIBASE
#ENDIF
#IF VICRESET
JSR VICRESET
#ENDIF
JMP PROMPT
XCMD; ExIT CMD
#IF TARGET == C64
LDA #$37
STA PPORT
JMP (BASNMI)
#ENDIF
#IF TARGET == PET
#IF RAM96LATCH
LDA BANKPP
STA RAM96LATCH
#ENDIF
JMP BASREADY
#ENDIF
LSVCMD;LDA #0 ; lOAD, sAVE, OR vERIFY COMMAND
LDY #1; SA
#IF SETLFS
LDX FA
JSR SETLFS
#ELSE
STY SA
#ENDIF
LDA #0
STA STATUS
LDX #<HUNTBUF
LDY #>HUNTBUF
#IF SETNAM
JSR SETNAM
#ELSE
STA FNLEN
STX FNADR
STY FNADR+1
#ENDIF
LL00JSR INPSKSP; GET FILENAME
CMP #CR ; .l "FILENAME ONLY?
BEQ DO_LOAD
CMP #QUOTE
BNE LL00
LDY #0
IC78AJSR KBDINPUT
CMP #QUOTE
BEQ IC7A0
CMP #CR
BEQ DO_LOAD
INY
CPY #END-HUNTBUF
BCS ERRC7
STA HUNTBUF-1,Y
STY FNLEN
BNE IC78A
IC7A0JSR EOL
BNE IC7C6
DO_LOAD LDA CMDCHR
CMP #"s"
BEQ ERRC7
SEC
SBC #"l" ; SET .a <> 0 FOR vERIFY
#IF 0 && VERCK; NEEDED BY THE NORMAL pet ROM ROUTINE
STA VERCK; 1 IS VERIFY
#ENDIF
#IF 1 {$7c}{$7c} TARGET != PET; IGNORED BY THE NORMAL pet ROM ROUTINE
LDX STAL
LDY STAL+1
#ENDIF
JSR LOAD
BCS ERRC7
LDA STATUS
AND #$10; VERIFY ERROR
BNE ERRC7
JMP PROMPT
ERRC7JMP ERROR
IC7C6DEC SA; MAKE SA 0, FOR RELOCATING LOAD
JSR HEX2STAL; GET START ADDRESS TO SAVE
JSR EOL
#BEQ DO_LOAD; IF LOAD ADDRESS GIVEN, ATTEMPT TO LOAD THERE
JSR HEX2AX; GET END ADDRESS
STA EAL ; START IN STAL, END IN EAL, AS FOR pet
STX EAL+1
JSR EOL
BNE ERRC7
LDA CMDCHR
CMP #"s" ; SAVE
BNE ERRC7
#IF TARGET != PET
LDA #STAL; ADDRESS FOR SAVE START ADDRESS
LDX EAL ; SAVE END ADDRESS
LDY EAL+1
#ENDIF
JSR SAVE
JMP PROMPT
#IF HAVEECMD
ECMDJSR KBDINPUT
LDX #$7F
CMP #"c"
BEQ IC9D9
INX
CMP #"s"
BNE ERRC7
IC9D9STX LRBFLAG
JSR GETSTEND
IC9DFLDX OVFLOW
BNE IC9F1
JSR STEQEND
BCC IC9F1
JSR DOCRLRB
JSR STOP
BNE IC9DF
IC9F1JMP CUPRPT
DOCRLRB JSR DOCR
DOLRBLDX #"."
LDA #"]"
BIT LRBFLAG
BMI ICA02
LDA #"["
ICA02JSR PRINTXA
JSR DOSPC
JSR LRBADR
JSR DOSPC
LDY #0
ICA10JSR LDASTALY
JSR BIN8
BIT LRBFLAG
BPL ICA21
INY
CPY #3
BCC ICA10
DEY
ICA21TYA
JSR ADDSTAA
RTS
LRBADRBIT LRBFLAG
BPL ICA38
LDA STAL; FOR SPRITE ADD 1
AND #$3F
CMP #$3F
BNE ICA38
JSR INCSTAL
ICA38JMP HEX4
LBCMDLDX #$7F; LEFT BRACKET CMD [
DC.B $2C
RBCMDLDX #$80; RIGHT BRACKET CMD ]
STX LRBFLAG
JSR HEX2STAL
LDY #0
ICACEJSR BIN2A
JSR STASTALY
BIT LRBFLAG
BPL ICADE
INY
CPY #3
BCC ICACE
ICADEJSR PRINTCU
JSR DOCRLRB
LDA CMDCHR
JMP FILKEYD0
#ENDIF; HAVEECMD
ERRCAJMP ERROR
; bANK CMD.
; hAS A NYBBLE AS ARGUMENT ON THE 64, AND
; A BYTE ON THE pet.
BCMDJSR INPSKSP
CMP #CR
BEQ ICB07
#IF TARGET == C64
JSR HEX2NYBB
CMP #8; ONLY ALLOW BANKS 0-7 AND F
BCC ICB02
CMP #$0F
BNE ERRCA
LDA #$86; $80 TO FLAG DRIVE, BANK 6 IN THE 64
ICB02STA BANK
BNE PRPTCB
#ENDIF
#IF TARGET == PET
STA BANK0F; ATTEMPT TO CLEAR BIT 7
JSR HEXA2A
STA BANK
CMP #$0F
BNE PRPTCB
ROR BANK0F; C=1: BIT 7 := 1 IFF BANK == 0F
LDA #$00; SET BANK FOR NOT-IN-DRIVE MEMORY
STA BANK
BEQ PRPTCB
#ENDIF
ICB07LDA BANK
#IF TARGET == C64
BPL ICB0E
LDA #"f"-"0"; $16
ICB0ECLC
ADC #"0"
JSR PRINT
#ENDIF
#IF TARGET == PET
JSR HEX2
#ENDIF
PRPTCBJMP PROMPT
QMCMDJSR INPSKSP; QUESTION MARK ? CMD
CMP #CR
BNE ICD95
LDX #0; PROVIDE HELP ON JUST ?
ICD87LDA CMDTAB,X
JSR PRINT
INX
CPX #ADRTAB-CMDTAB
BNE ICD87
BEQ PRPTCB
ICD95LDX #STAL
JSR HDIN4
CALCLOOP
JSR SKIPSPC
CMP #CR
BEQ ICDD6
PHA
JSR INPSKSP
LDX #MEMUSS
JSR HDIN4
TAY
PLA
JSR DO_OP
TYA
JMP CALCLOOP
DO_OPLDX #4
ICDB5CMP OPTAB,X
BEQ ICDBF
DEX
BPL ICDB5
BMI ERRCA
ICDBFLDA OPCTAB,X
STA ACDCB
STA ACDD1
ASL ;A; C:=1 FOR SBC... *DIRTY*
LDA STAL
ACDCBAND MEMUSS; OPCODE MODIFIED
STA STAL
LDA STAL+1
ACDD1AND MEMUSS+1; OPCODE MODIFIED
STA STAL+1
RTS
ICDD6JSR DOCR
JSR HEX4
JSR DOSPC
JSR DECI
JMP PROMPT
;+++ BEGIN OF I/O ROUTINES
ADR2STAL
INY
JSR LDASTALY
TAX
INY
JSR LDASTALY
STA STAL+1
STX STAL
RTS
DOTRCRLDY RTSP; HANDLE RETURN DISASSEMBLY
BEQ NORETURN
DEY
LDA RTSTACK,Y
STA STAL+1
DEY
LDA RTSTACK,Y
STA STAL
STY RTSP
JMP SCROLLD
NORETURN
CMP #$60; RTS
BEQ IW02
DOTRCJSEC; UP
JSR GETCMD
BCS WAITPRTC
LDY #0
JSR LDASTAL
CMP #$60; RTS
BEQ DOTRCR
CMP #$20; JSR
BNE IW02
LDX RTSP
LDA STAL
;CLC C IS 1
ADC #3-1
STA RTSTACK,X
INX
LDA STAL+1
ADC #0
STA RTSTACK,X
INX
STX RTSP
BNE IWABS
IW02CMP #$4C; JMP
BNE IW03
IWABSJSR ADR2STAL
JMP SCROLLD
IW03CMP #$6C; JMP()
BNE IW04
JSR ADR2STAL
LDY #$FF
BNE IWABS
IW04AND #%00011111; BRANCH
CMP #%00010000
BNE IW05
INY
JSR LDASTALY
JSR AD1STALA
TAX
INX ;LO
BNE IW041
INY ;HI
IW041STX STAL
STY STAL+1
JMP SCROLLD
IW05JMP SCRD
#IF HAVEPFKEYS
DOFKEYS TAX
LDY PFLEN-PF1,X
STY NDX
LDA PFENDS-PF1,X
TAX
IC801LDA PF1TXT,X
STA KEYD-1,Y
DEX
DEY
BNE IC801
BEQ WAIT
#ENDIF; HAVEPFKEYS
SUBROUTINE
; THIS DUPLICATES THE ROM INPUT ROUTINE, INSERTING
; CODE FOR OUR SPECIAL KEYS (CU, CD, STOP).
; aLSO DOES AUTOREPEAT ON MODELS THAT DON'T HAVE IT THEMSELVES (3032)
INPUTTYA
PHA
TXA
PHA
LDA #0
STA LXSP+1
#IF AUTOREPEAT && 0; THIS PART SERVES TO GET THE INITIAL TIMING
LDA #SLOWREP; RIGHT. IT MAY BE REMOVED IN CASE OF
CLC; MEMORY SHORTAGE SINCE IT IS ALMOST NEVER
ADC TIME+2; *REALLY* NEEDED, BECAUSE USUALLY THIS FUNCTION
STA REPTIME; IS CALLED WITH NO KEY PRESSED.
#ENDIF
LDA CRSW; INPUT FROM SCREEN OR KEYBOARD (CR SWITCH)
BEQ WAIT
JMP SCRGET; GET FROM THE SCREEN IN ROM
WAITPRTC
LDA DATAX; KEY THAT HAS BEEN HIT
WAITPRT JSR SCRPRINT; PRINT IT
WAIT:
#IF 1 && AUTOREPEAT
; uSE JIFFY TIMER TO CHECK WHEN TO MAKE A KEY REPEAT.
; wHEN NO KEY WAS PRESSED, SET TO SLOW VALUE.
; wHEN ACTION IS TAKEN, SET TO FAST VALUE.
; a KEY IS MADE TO REPEAT BY MAKING THE KEYBOARD SCANNER THINK
; THE PREVIOUS KEY WAS DIFFERENT, WHICH IS DONE BY CHANGING LSTX.
LDA #SLOWREP
LDX #NOKEY
CPX LSTX
BEQ NOTPRESSED$
LDA TIME+2
CMP REPTIME
BMI ENDREPEAT$
#IF TARGET == PET
INC LSTX; NOT "STX LSTX" BECAUSE THAT WOULD FOOL US
; NEXT TIME AROUND...
#ELSE
DEC LSTX; FOR 64 USE DEC BECAUSE NOKEY==64 AND THIS
; WOULD BE BAD FOR SCANCODE 63, AS ABOVE...
#ENDIF
LDA #FASTREP
NOTPRESSED$
CLC
ADC TIME+2
STA REPTIME
ENDREPEAT$
#ENDIF
#IF 0 && AUTOREPEAT
LDA BLNCT; ABUSE CURSOR BLINK COUNTDOWN TO CHECK WHEN
CMP REPTIME; TO MAKE A KEY REPEAT.
BNE ENDREPEAT$; WHEN NO KEY WAS PRESSED, SET TO SLOW VALUE.
LDX #NOKEY; WHEN ACTION IS TAKEN, SET TO FAST VALUE.
CPX LSTX; A KEY IS MADE TO REPEAT BY FAKING THE RELEASE
BEQ NOTPRESSED$; OF THE KEY, BY SETTING LSTX TO #NOKEY.
STX LSTX
DEC BLNCT
LDA #20-3; FASTREP
STA REPTIME
BNE ENDREPEAT$
NOTPRESSED$
LDA #20-17; SLOWREP
STA REPTIME
ENDREPEAT$
#ENDIF
LDA NDX ; ANYTHING IN THE KEYBOARD BUFFER?
STA BLNSW; IF <>0, TURN OFF CURSOR
#IF AUTODN
STA AUTODN
#ENDIF
BEQ WAIT
LDA BLNON; RESTORE CHAR AND COLOUR UNDER CURSOR,
BEQ ICO00; IF NEEDED
LDA GDBLN
#IF GDCOL
LDX GDCOL
#ENDIF
LSR BLNON
JSR POKCHR
ICO00JSR KBDGET; GET CHAR FROM KEYBOARD BUFFER
LDX QTSW; QUOTE MODE SWITCH
BNE IC058; IF IN QUOTE MODE, DON'T BE FANCY
LDX TBLX; SCREEN LINE OF CURSOR
STA DATAX; KEY THAT HAS BEEN HIT
#IF HAVEPFKEYS
CMP #PF1; CHECK FOR PF KEYS
BCC IC847
CMP #PF1+8
BCC DOFKEYS
#ENDIF
IC847CMP #$03; "^C"
BEQ DOJUMP
CMP #$83; "^c"
BEQ DORETURN
CMP #CD ; CURSOR DOWN
BEQ DOCD
CMP #CU ; CURSOR UP
BEQ DOCU
IC058CMP #CR ; RETURN = DONE
BNE WAITPRT
JMP SCRCONT; CONTINUE INPUT FUNCTION IN ROM
DOJUMP
JMP DOTRCJ; FOLLOW CHANGED FLOW OF CONTROL
DORETURN
JMP DOTRCR; GO BACK TO PREVIOUS JSR
DOCDCPX #LINES-1; BOTTOM LINE
BCC WAITPRT
JSR GETCMD; C = 1: GO UP
BCS WAITPRTC
LDA CMDCHR
CMP #":"
BNE I800
; SCROLL UP MEM DUMP
;CLC
LDA STAL
ADC #HEXWIDTH-1 ;C=1
STA STAL
BCC IC871
INC STAL+1
IC871JSR CRHEXDMP
TAB1LDA #1
STA PNTR
JMP WAIT
I800CMP #">"
BNE IC87B
; SCROLL UP ASC DUMP
;CLC
LDA STAL
ADC #ASCWIDTH-1 ;C IS 1 (EQUAL)
STA STAL
BCC I801
INC STAL+1
I801JSR CRASCDMP
JMP TAB1
IC87BCMP #","
BNE IC892
; SCROLL UP DISASSEMBLY
SCRDJSR OPREDU
JSR ADSTALEN
SCROLLD ;LDY #","
JSR DDASHES
JMP TAB1
IC892
#IF HAVEECMD
; SCROLL UP [ OR ]
LDX #$7F
CMP #"["-$40
BEQ IC899
INX
IC899STX LRBFLAG
CLC
LDA #1
BIT LRBFLAG
BPL IC8A6
LDA #3
IC8A6ADC STAL
STA STAL
BCC IC8AE
INC STAL+1
IC8AEJSR DOCRLRB
JMP TAB1
#ENDIF; HAVEECMD
DOCUTXA
BNE IC8BD
CLC
JSR GETCMD
BCC IC8C0
IC8BDJMP WAITPRTC
IC8C0
#IF TMPLIN
LDA #0
STA TMPLIN
#ENDIF
#IF [TARGET == PET] && PETB2
DEC TBLX; ON BASIC 2.0, THIS FUNCTION IS MEANT FOR
JSR INSTLIN; INSERTING CHARS ONTO THE NEXT LINE, OPENING
INC TBLX; UP THE *NEXT* SCREEN LINE
#ELSE
JSR INSTLIN
#ENDIF
#IF LDTBL
#IF HIBASE
LDA HIBASE
#ELSE
LDA #<SCREEN
#ENDIF; HIBASE
ORA #$80
STA LDTBL
#ENDIF; LDTBL
JSR GOHOME
LDA CMDCHR
CMP #":"
BNE IC8ED
; SCROLL DOWN HEX DUMP
;SEC ; C IS ALREADY 1 (EQUAL)
LDA STAL
SBC #HEXWIDTH
STA STAL
BCS IC8E4
DEC STAL+1
IC8E4JSR DOHEXDMP
HMTAB1JSR GOHOME
JMP TAB1
IC8EDCMP #">"
BNE I803
; SCROLL DOWN ASC DUMP
;SEC C IS ALREADY 1
LDA STAL
SBC #ASCWIDTH
STA STAL
BCS I802
DEC STAL+1
I802JSR DOASCDMP
JSR GOHOME
JMP TAB1
I803CMP #","
BNE IC93A
; SCROLL DOWN DISSASS
LDA STAL
LDX STAL+1
STA MEMUSS
STX MEMUSS+1
LDA #$10; #BYTES BACKWARDS
STA DBACKUP
IC8FESEC
LDA MEMUSS
SBC DBACKUP
STA STAL
LDA MEMUSS+1
SBC #0
STA STAL+1
IC90CJSR OPREDU
JSR ADSTALEN
JSR STEQEND
BEQ IC91E
BCS IC90C
DEC DBACKUP
BNE IC8FE
IC91EINC OPLEN
LDA OPLEN
JSR SBCSTAA
JSR LDASTAL
LDA #","
JSR DODOTA
JSR DINSTR2
JMP HMTAB1
IC93A
#IF HAVEECMD
; SCROLL DOWN [ OR ]
IC93AJSR DECSTAL
CMP #"["-$40
BEQ IC953
JSR DECSTAL
JSR DECSTAL
LDA STAL
AND #$3F
CMP #$3D
BNE IC951
DEC STAL; FOR SPRITE, DECREMENT 1 EXTRA
IC951LDX #$80
IC953STX LRBFLAG
JSR DOLRB
JMP HMTAB1
#ENDIF; HAVEECMD
;;;;
;
; GETCMD IS CALLED WITH THE NUMBER OF THE CURRENT LINE IN .x
; WITH AUTOMATICALLY (PNT) POINTING TO THE SAME LINE.
SUBROUTINE
GETCMDROR STAL; REMEMBER DOWN (.c=0) OR UP (.c=1)
LDA PNT
STA MEMUSS
LDA PNT+1
STA MEMUSS+1
.TOPLDY #0
LDA (MEMUSS),Y
CMP #"." ; SCREEN CODE
BEQ IC98D
.NEXTLINE
BIT STAL; PL=GO DOWN
BPL .DOWN
SEC
LDA MEMUSS
SBC #COLUMNS
STA MEMUSS
BCS .2
DEC MEMUSS+1
.2DEX
BPL .TOP
SEC; .C=1: NOT FOUND
RTS
.DOWNCLC
LDA MEMUSS
ADC #COLUMNS
STA MEMUSS
BCC .1
INC MEMUSS+1
.1INX
CPX #LINES
BCC .TOP
RTS
IC98DINY
LDA (MEMUSS),Y
#IF HAVEECMD
CMP #"["-$40 ; SCREEN-[
BEQ .GOTCMD
CMP #"]"-$40 ; ]
BEQ .GOTCMD
#ENDIF
CMP #"," ; SCREEN CODE
BEQ .GOTCMD
CMP #">" ; SCREEN CODE
BEQ .GOTCMD
CMP #":" ; SCREEN CODE
BNE .NEXTLINE
.GOTCMD STA CMDCHR
INY
JSR SCR2STAL
STA STAL+1
; FALL THROUGH TO SCR2STAL
SUBROUTINE
SCR2STAL; CONVERT NUMBER IN SCREEN CODE
JSR SCR2NYBB
ASL ;A
ASL ;A
ASL ;A
ASL ;A
STA STAL
JSR SCR2NYBB
ORA STAL
STA STAL
CLC
RTS
SUBROUTINE
SCR2NYBB
LDA (MEMUSS),Y
INY
CMP #" "
BEQ SCR2NYBB
CMP #7; SCREEN CODE FOR "F"
BCS .1
ADC #9
.1AND #$0F
RTS
SUBROUTINE
USESTAL STA MEMBYT
LDA STAL
STA MEMLO
LDA STAL+1
STA MEMHI
RTS
USEMUSS STA MEMBYT
LDA MEMUSS
STA MEMLO
LDA MEMUSS+1
STA MEMHI
RTS
LDASTAL JSR USESTAL; *** NOTE: THESE FUNCS MUST PRESERVE THE cARRY!
LDA #$AD; LDA ABS
BNE SETOPC
STASTAL JSR USESTAL
LDA #$8D; STA ABS
BNE SETOPC
CMPSTAL JSR USESTAL
LDA #$CD; CMP ABS
BNE SETOPC
STAMUSS JSR USEMUSS
LDA #$8D; STA ABS
BNE SETOPC
CMPMUSS JSR USEMUSS
LDA #$CD; CMP ABS
BNE SETOPC
LDASTALY
JSR USESTAL
LDA #$B9; LDA A,Y
BNE SETOPC
STASTALY
JSR USESTAL
LDA #$99; STA A,Y
;BNE SETOPC
;
;CMPSTALY
;JSR USESTAL
;LDA #$D9; CMP A,Y
SETOPCSTA MEMOPC; MUST PRESERVE .a AND CARRY (FOR OPREDU)
STX MEM_SAVX
#IF TARGET == C64
BIT BANK
#ENDIF
#IF TARGET == PET
BIT BANK0F
#ENDIF
BMI DISKMEM
BPL ICB7F; ALWAYS
ICB79PLA
PLA
PLP
LDY MEM_SAVY
ICB7F
#IF TARGET == C64
LDX PPORT
TXA
AND #$38
BANK = .+1
ORA #7
SEI
STA PPORT
#ENDIF; TARGET == C64
#IF [TARGET == PET] && RAM96LATCH
SEI
LDX BANK
STX RAM96LATCH
LDX BANKPP
#ENDIF; TARGET == PET
MEMBYT = .+1
LDA #8; CONSTANT WILL BE MODIFIED
MEMHI= MEMOPC+2
MEMLO= MEMOPC+1
MEMOPCLDA $FFFF,Y; OPCODE AND ADDRESS WILL BE MODIFIED
#IF TARGET == C64
STX PPORT
CLI
#ENDIF
#IF [TARGET == PET] && RAM96LATCH
STX RAM96LATCH
CLI
#ENDIF; TARGET == PET
PHP
MEM_SAVX = .+1
LDX #3; CONSTANT WILL BE MODIFIED
PLP
RTS
DISKMEM
STY MEM_SAVY
PHP
PHA; OPCODE
AND #$10; TEST Y-INDEXING
BNE ICBA1
LDY #0
ICBA1CLC
TYA
ADC MEMLO; ADD .y
PHA
LDA #0
ADC MEMHI
#IF 1; WE DON'T WANT THIS...
CMP #$48; $4800-$C000
BCC ICBB4; FETCH FROM COMPUTER'S MEMORY ANYWAY
CMP #$C0
BCC ICB79
#ENDIF
ICBB4STA MEMHI
PLA
STA MEMLO
PLA; OPCODE, TEST R/W
AND #$60
CMP #1
ROR RWFLAG
ORA #$89; MAKE IT AN IMMEDIATE OPCODE
STA ACC07
LDA #"r"
BIT RWFLAG ;<0:R
BMI ICBD1
LDA #"w"
ICBD1JSR DISKMRW ;M-RW
LDA #1;1 BYTE
JSR IECOUT
BIT RWFLAG ;>0:W
BPL DISKW
JSR UNLSN
LDA FA
JSR TALK
LDA #$6F
JSR TKSA
ICBEBLDA #0
STA STATUS
JSR IECIN
STA DISKBYTIN
LDA STATUS
AND #2
BNE ICBEB; TIME-OUT
JSR IECIN
JSR UNTLK
PLP
MEM_SAVY = .+1
LDY #1; THIS CONSTANT WILL BE MODIFIED
LDA MEMBYT
DISKBYTIN = .+1
ACC07LDA #$14; THIS OPCODE AND CONSTANT WILL BE MODIFIED
RTS; SBC/CMP...
DISKWLDA