;
;-----------
;I/O CONTROL
;-----------
;
;Print to command window
;
PCOMW	STA INDR 	;save address
	STY INDR+1
	LDY #0
PCA	LDA (INDR),Y 	;get a char
	STA COMND,Y 	;on screen
	CMP #31 	;a '?'?
	BEQ PCN 	;yes. done.
	INY  	;up count
	BNE PCA 	;try again
PCN	RTS  	;leave
;
;Position cursor at line 15
;
POS15	LDA #15
	STA ROWCRS
	RTS 
;
;Scroll Screen?
;
SCROLL	LDA ROWCRS 	;Y-pos
	CMP #14 	;14th line?
	BNE SCRL 	;no.
SCRL2	JSR MOVE32 	;yes. scroll
	LDA #13 	;pos. 13
	STA ROWCRS
SCRL	JMP IOL3 	;print buffer
;
;Pause screen scroll
;
PAUSE	LDA CH 	;key scan
	CMP #$FF 	;no touch?
	BEQ CLRKEY 	;yes.
	JSR CLRKEY 	;clear it.
	CMP #28 	;was it ESC?
	BEQ PA2 	;yup.
	CMP #33 	;space bar?
	BNE CLRKEY 	;no.
	JSR CLRKEY 	;clear.
PA3	LDA CH 	;wait again
	CMP #33 	;space?
	BEQ CLRKEY 	;yes.
	CMP #28 	;ESC?
	BNE PA3 	;no. wait.
PA2	PLA  	;have an ESC.
	PLA  	;pull RTS
;
;Clear key
;
CLRKEY	PHA  	;save A
	LDA #$FF 	;clear CH
	STA CH 	;to no touch
	PLA  	;restore A
	RTS  	;leave.
;
;Page thru Disa
;
PGTHRU	LDA # <PGTR 	;print option
	LDY # >PGTR 	;Up or Down?
	JSR PCOMW
PGL2	JSR GETKEY 	;get choice
	CMP #'U 	;Up?
	BNE TDN? 	;no.
	LDA #1 	;put scroll up
	STA PGWAY 	;flag
	BNE PGLOOP 	;do it!
TDN?	CMP #'D 	;Down?
	BNE PGL2 	;no.
	LDA #0 	;insert scroll
	STA PGWAY 	;down flag
PGLOOP	JSR CLRCMD 	;clear stuff
	JSR CLRWIN
PGJSR	JSR PAUSE 	;scroll!
	LDA PGWAY
	BEQ DWAY 	;pause screen?
	JSR SCRUP 	;do again.
	JMP PGJSR
DWAY	JSR SCRDN
	JMP PGJSR
;
;Disassemble to a device
;
DISDEV	JSR COPFIL 	;get filename
	JSR GADR 	;and start adr
	LDA #8 	;open IOCB for
	JSR OPENFIL 	;write only
	LDA FR0 	;copy in adr
	STA ADDR
	LDA FR0+1
	STA ADDR+1
OLP	JSR DISAMEM 	;disa a line
	LDA #32 	;remove arrow
	STA MYBUF+17 	;in disa
	LDA MYBUF+18 	;
	BPL DPR
	JSR INV2
DPR	JSR DPRINT 	;print it
	JSR ERASTAT 	;clear line
	JSR POS15 	;on status
	LDA #EOL 	;set so only
	STA MYBUF+6 	;addr is shown
	JSR IOL3 	;print disa
	LDA CH 	;key?
	CMP #$FF 	;no touch?
	BEQ OLP 	;yes. go again
	JSR CLRKEY 	;clear it
	JSR ERASTAT 	;clear line
	JMP DCLOSE 	;close IOCB
;
;Get device
;
GETDEV	JSR CLRWIN 	;no junk
	LDA # <DEVNAMS 	;copy devices
	LDY # >DEVNAMS 	;onto the
	JSR PCOMW 	;screen
DEV2	JSR GETKEY 	;get a key
	CMP #27 	;ESC?
	BNE FNDEV 	;no.
	PLA  	;pull of the 2
	PLA  	;RTS's from
	PLA  	;the stack
	PLA 
	RTS  	;and leave
FNDEV	LDY #1 	;check if legal
DEV3	CMP DEVS,Y 	;device
	BEQ HAVDEV 	;got one!
	DEY  	;not this
	BPL DEV3 	;try next one
	JSR GOTERR 	;sorry wrong
	JMP DEV2 	;go again
HAVDEV	RTS  	;bye.
;
;Scroll down
;
SCRDN	LDX #0 	;check if scr
SCK	TXA  	;has info all
	ASL A 	;the way down
	TAY  	;to the last
	LDA SCRN,Y 	;screen line.
	STA TEMP 	;get the line
	LDA SCRN+1,Y 	;address from
	STA TEMP+1 	;table.
	LDY #0 	;zero index
	LDA (TEMP),Y 	;get a char
	BEQ DOWHL 	;have a space
	INX  	;try next line
	CPX #14 	;at 14 yet?
	BNE SCK 	;no.
	JSR FINLIN
	JSR SCRL2
	LDX #1 	;copy the addr
GX1	LDA MYSCRN,X 	;from the scr
	JSR IC2ASC 	;into mybuf
	CMP #32 	;a space?
	BEQ GX2 	;yes, done.
	STA MYBUF-1,X 	;save it
	INX  	;next char
	BNE GX1
GX2	LDA #EOL 	;insert EOL
	STA MYBUF-1,X 	;in mybuf
	LDY #0
	JSR GET4 	;make integer
	LDA FR0 	;now copy this
	STA TOPADR 	;to TOPADR
	LDA FR0+1 	;for next time.
	STA TOPADR+1
	RTS  	;done!
DOWHL	LDA LN2 	;put second
	STA FR0 	;address in FR0
	LDA LN2+1
	STA FR0+1 	;and disa all
	JMP TOEDEV 	;16 lines.
;
;Scroll up
;
SCRUP	LDA TOPADR 	;move down
	SEC  	;byte in memory
	SBC BBCK
	STA FR0 	;save in FR0
	LDA TOPADR+1
	SBC #0 	;take care of
	STA FR0+1 	;Hi byte
	JMP TOEDEV 	;do it!
;
;Clear Command type
;
CLRCMD	LDA #0 	;make command
	STA COMND 	;2 spaces
	STA COMND+1
	RTS  	;bye.
;
;Clear Command Window
;
CLRWIN	LDY #20 	;do 21 chars
	LDA #0 	;a blank
CW	STA COMLN,Y 	;in command
	DEY  	;line buffer
	BPL CW 	;do next
	RTS  	;so long.
;
;Free break points
;
FREBRK	LDY #0
	STY FREN 	;none free
FRE1	STY SAVEY 	;save Y
	LDA SETLO,Y 	;get addr
	STA FR0 	;and put in FR0
	LDA SETHI,Y
	STA FR0+1
	JSR BIN2HEX 	;convert to hex
	LDY SAVEY 	;get Y
	LDX BRKLN,Y 	;get pos on scr
	LDY #0
FRE2	LDA LBUFF,Y 	;hex digit
	SEC  	;make icode
	SBC #32
	STA FRLN,X 	;on screen
	INX 
	INY 
	CPY #4 	;4 chars?
	BNE FRE2 	;no.
	LDY SAVEY 	;restore Y
	LDA OPSET,Y 	;BRK set?
	BNE FRE3 	;yes.
	INC FREN 	;inc free points
FRE3	INY  	;up Y
	CPY #6 	;6 BRK's yet?
	BNE FRE1 	;no
	LDA FREN 	;get free
	CLC 
	ADC #16 	;make icode
	STA FRLN+31 	;on screen
	RTS  	;all done
;
;Break Point Handler
;
BKPHAN	JSR CLRCMD 	;clear comms
	LDA #34 	;a 'B'
	STA COMND
	JSR INPUT 	;get a line
	BCC BKG 	;good? yes!
	RTS  	;no. bye
BKG	LDA MYBUF 	;get number
	SEC  	;subtr 49 (0-5)
	SBC #49
	TAX  	;save in X
	CMP #6
	BCS NUMER 	;>5? yes.
	CMP #0 	;<0?
	BCC NUMER 	;yes.
	LDA MYBUF+1 	;next char
	CMP #EOL 	;EOL?
	BEQ DORESET 	;yes. reset it
	LDY #2
	STX CNTLO 	;save X
	JSR GTDR 	;get addr
	LDX CNTLO 	;restore X
	LDY #0
	LDA (FR0),Y 	;get opcode
	BEQ SETER 	;BRK? yes.
	LDA OPSET,X 	;set already?
	BEQ SETIT 	;no.
SETER	LDY #152
	JMP IOERR
NUMER	JMP GOTERR 	;BEEP!
SETIT	LDA FR0 	;save address
	STA SETLO,X
	LDA FR0+1
	STA SETHI,X
	LDA (FR0),Y 	;get opcode
	STA OLDOP,X 	;save it
	TYA  	;zero Acc
	STA (FR0),Y 	;insert BRK
	INC OPSET,X 	;show set
	JMP FREBRK 	;and leave
;
DORESET	JSR CLRCMD 	;no junk
	LDY #0 	;zero Y
	LDA OPSET,X 	;Set yet?
	BEQ RESER2 	;no. error
	LDA SETLO,X 	;get address
	STA INDR 	;of Bpoint
	LDA SETHI,X 	;and save in
	STA INDR+1 	;2 Zpage locs
	LDA OLDOP,X 	;get old opcode
	STA (INDR),Y 	;put it back.
	TYA  	;A = 0
	STA OPSET,X 	;not set.
	STA SETLO,X
	STA SETHI,X
	JMP FREBRK 	;update free
RESER2	LDY #150 	;give user
	JMP IOERR 	;Error # 150
;
;Find memory
;
FINDIT	JSR CLRCMD 	;clear line
	LDA #31 	;a '?'
	STA COMND
	STA NCHK 	;don't check
	JSR INPUT 	;keys on input
	BCC FCS 	;good input
	RTS  	;bye
FCS	LDY #0 	;check to see
FCP	LDA MYBUF,Y 	;if input ends
	CMP #EOL 	;with an EOL
	BEQ FCP2 	;or a comma.
	CMP #$2C 	;if comma the
	BEQ FCP2 	;get an address
	STA MBF2,Y 	;also copy line
	INY  	;into a temp
	CPY #12 	;buffer
	BNE FCP
FCP2	STY SLFS 	;save Y
	CMP #$2C 	;a comma?
	BNE FCP3 	;no.
	JSR GADR 	;get address
	LDA FR0 	;to start from
	SEC  	;subtract 1
	SBC #1 	;from it.
	STA SL 	;and save it
	LDA FR0+1
	SBC #0
	STA SL+1
	LDY #$FF 	;force a
	BNE FCP4 	;branch
FCP3	LDY #$FF 	;set up $FFFF
	STY SL
	STY SL+1
FCP4	INY 
	STY DISKC
	STY STL
	STY STL+1 	;end at $FFFF
	JSR CLRSCR
FC1	LDA SL 	;add one to
	CLC  	;current addr
	ADC #1
	STA SL
	LDA SL+1
	ADC #0
	STA SL+1
	CMP # >MYBUF 	;at buffers
	BNE FC9 	;yet? no.
	LDA SL
	CMP # <MYBUF
	BNE FC9 	;no.
	LDA # <ENDBUF 	;skip over
	STA SL 	;the input
	LDA # >ENDBUF 	;and page 0-2
	STA SL+1 	;buffers.
FC9	LDA DISKC 	;first run?
	BEQ FC3 	;yes.
	LDA SL 	;at $0000?
	ORA SL+1
	BNE FC3 	;no.
	RTS  	;yes. done.
FC3	LDY #1 	;second pass
	STY DISKC
	DEY  	;Y = 0
FC4	LDA (SL),Y 	;a char
	CMP MBF2,Y 	;= to mbf2?
	BNE FC1 	;no.
	INY  	;a match?
	CPY SLFS 	;done yet?
	BNE FC4 	;no.
	JSR ZBUF 	;set up buffer
	LDX #5 	;to show what
FC5	LDA FTXT,X 	;find this
	STA MYBUF,X 	;was and at
	DEX  	;what address
	BPL FC5 	;the string
	LDA SL 	;was found at.
	STA FR0
	LDA SL+1 	;address
	STA FR0+1
	JSR BIN2HEX
	LDY #3
	LDX #17
FC6	LDA LBUFF,Y 	;Hex address
	STA MYBUF,X
	DEX 
	DEY 
	BPL FC6
	LDA #'$ 	;add '$'
	STA MYBUF,X
	LDA #EOL 	;add in the
	STA MYBUF+18 	;eol
	INC STL 	;up # of finds
	BNE NH4
	INC STL+1
NH4	LDA STL 	;now add in
	STA FR0 	;the find #.
	LDA STL+1
	STA FR0+1
	LDX #7
	STX HXDC
	JSR COPYNUM
	JSR PAUSE 	;pause?
	JSR SCROLL 	;scroll screen
	JMP FC1 	;go again
;
;Load a binary file
;
DOLOAD	LDA #'D 	;filename
	JSR COPFL
	LDA #0 	;signal first
	STA SLFS 	;pass
	LDA #7 	;get bytes
	STA DISKC2 	;save
	LDA #4 	;read only
	JSR OPENFIL 	;open file!
	JSR READ2 	;get 2 bytes
	BMI BLO2 	;error? yes.
	LDA BAL 	;is header?
	CMP #$FF 	;$FF?
	BNE BDLO 	;no.
	CMP BAL+1 	;other one?
	BEQ DLOAD 	;yes. = $FF
BDLO	LDY #149 	;ERROR 149
BLO2	STY SAVEY 	;save it
	JSR DCLOSE 	;close Device
	LDY SAVEY 	;get error
	JMP IOERR 	;and leave
DLOAD	JSR READ2 	;2 more bytes
	LDA SLFS 	;pass = 1?
	BNE CHD 	;no.
	LDA BAL 	;copy load
	STA FR0 	;addr to safe
	LDA BAL+1 	;place
	STA FR0+1
	INC SLFS 	;pass = 2
CHD	JSR CHKHED 	;$FF?
	JSR STRAD 	;set start
	JSR READ2 	;2 more bytes
	JSR ENDAD 	;set end adr
	JSR BUFLEN 	;calc buf len
	JSR GETDAT 	;get stuff
	BMI LOADD 	;if error done
	JMP DLOAD 	;keep going.
LOADD	TYA  	;error in A
	PHA  	;save it
	JSR DCLOSE 	;close dev
	PLA  	;get error
	CMP #136 	;EOF?
	BNE LODERR 	;no. Error!
	JSR ZBUF 	;clear buffer
	LDY #6 	;'LOAD AT'
LLP	LDA LODAD,Y
	STA MYBUF,Y
	DEY 
	BPL LLP
	JSR BIN2HEX 	;convert addr
	LDY #3 	;to hex&copy
	LDX #12
LLP1	LDA LBUFF,Y 	;insert #
	STA MYBUF,X
	DEX 
	DEY 
	BPL LLP1
	LDA #'$ 	;add a '$'
	STA MYBUF,X
	LDA #EOL 	;install EOL
	STA MYBUF+13
	JSR POS15 	;on STAT:
	JMP IOL3 	;print it.
LODERR	TAY  	;in Y
	JMP IOERR 	;show error
;
;Read in 2 file bytes
;
READ2	LDA # <BAL 	;point to
	STA SL 	;2 byte buffer
	LDA # >BAL
	STA SL+1
	LDA #0 	;only 2 bytes
	STA BLL+1 	;in length
	LDA #2 	;and fall thru
	STA BLL 	;to getrec
;
;Get file segment
;
GETREC	LDX #DDEV 	;Device
	LDA DISKC2 	;command
	STA ICCOM,X
	LDA SL 	;buffer adr
	STA ICBAL,X
	LDA SL+1
	STA ICBAH,X
	LDA BLL 	;buffer length
	STA ICBLL,X
	LDA BLL+1
	STA ICBLH,X
	JMP CIOV 	;get it
;
;Calculate buffer length
;
BUFLEN	LDA ENL 	;take end and
	SEC  	;subtract start
	SBC STL 	;to calc length
	STA BLL
	LDA ENL+1
	SBC STL+1
	STA BLL+1
	LDA BLL 	;then add 1
	CLC  	;for CIO
	ADC #1
	STA BLL
	LDA BLL+1
	ADC #0 	;add carry
	STA BLL+1
	RTS  	;and leave
;
;Put in start addr
;
STRAD	LDA BAL 	;move in start
	STA STL 	;address
	LDA BAL+1
	STA STL+1
	RTS 
;
;Put in end addr
;
ENDAD	LDA BAL 	;move in end
	STA ENL 	;addr.
	LDA BAL+1
	STA ENL+1
	RTS 
;
;Check if header
;
CHKHED	LDX BAL 	;first byte
	INX  	;up by 1
	BEQ TNXT 	;zero? yes.
	RTS  	;nope.
TNXT	LDX BAL+1 	;second byte
	INX  	;up it
	BEQ ITSFF 	;zero? yes.
	RTS  	;no.
ITSFF	JMP READ2 	;2 more bytes
;
;Get DATA
;
GETDAT	LDA STL 	;set up start
	STA SL 	;loadind addr
	LDA STL+1
	STA SL+1
	JMP GETREC 	;and load it
;
;Open Disk
;
OPENFIL	STA DISKC 	;save I/O
	JSR DCLOSE 	;close IOCB
	LDA DISKC 	;get I/O type
	LDX #DDEV 	;device chan
	STA AUX1,X 	;in AUX1
	LDA #0 	;AUX2 = 0
	STA AUX2,X
	LDA #3 	;open command
	STA ICCOM,X
	LDA # <FILNAM 	;point to
	STA ICBAL,X 	;filename
	LDA # >FILNAM
	STA ICBAH,X
	JSR CIOV 	;open it!
	BMI OPENR 	;sorry error.
	RTS  	;good open.
OPENR	PLA  	;pull RTS
	PLA  	;and show error
	JMP IOERR
;
;Copy filename
;
COPFIL	JSR GETDEV 	;device.
COPFL	PHA  	;save it
	STA FILNAM 	;in filename
	LDA #EOL 	;3 char is EOL
	STA FILNAM+2
	PLA  	;device
	CMP #'D 	;to Disk?
	BEQ TOD 	;yes.
	RTS  	;no fname.
TOD	JSR CLRCMD 	;clr window
	LDA #31 	;a ?
	STA COMND
	JSR INPUT 	;get name
	BCC CQP1 	;if good branch
	PLA  	;pull RTS
	PLA 
	RTS  	;next command
CQP1	LDX #2 	;offset is 2
	LDY #0 	;zero Y
COPL	LDA MYBUF,Y 	;char
	CMP #', 	;a comma?
	BEQ GNAME 	;yes.
	CMP #EOL 	;EOL?
	BEQ GNAME 	;yes.
	STA FILNAM,X 	;save in name
	INY  	;up pointers
	INX 
	CPX #18 	;18 chars yet?
	BNE COPL 	;no.
	LDY #165 	;Fname error
	PLA 
	PLA 
	JMP IOERR 	;show it
GNAME	LDA #EOL 	;add EOL
	STA FILNAM,X 	;to Fname
	RTS  	;leave
;
;Save a File
;
DOSAVE	LDA #'D 	;Fname
	JSR COPFL
	LDA #11 	;put bytes
	STA DISKC2
	JSR GADR 	;save start
	LDA FR0 	;copy it
	STA STL
	LDA FR0+1
	STA STL+1
	JSR GADR 	;save end
	LDA FR0 	;copy it
	STA ENL
	LDA FR0+1 	;is end<start?
	STA ENL+1
	CMP STL+1
	BCC SIOR2 	;yes.
	BEQ TESTLO 	;equal.
	BNE DSAV 	;save it.
TESTLO	LDA ENL 	;try LSB's
	CMP STL
	BCC SIOR2 	;error!
DSAV	LDA #8 	;write only
	JSR OPENFIL 	;open it!
	LDA #$FF 	;Install header
	STA BAL
	STA BAL+1
	JSR READ2 	;put it out
	BMI SIOR 	;error
	LDA STL 	;start bytes
	STA BAL
	LDA STL+1
	STA BAL+1
	JSR READ2 	;put them
	BMI SIOR
	LDA ENL 	;end bytes
	STA BAL
	LDA ENL+1
	STA BAL+1
	JSR READ2 	;put them
	BMI SIOR
	JSR BUFLEN 	;calc length
	JSR GETDAT 	;and save it
	BMI SIOR
	JMP DCLOSE 	;close it
SIOR2	LDY #153 	;ADR ERROR
SIOR	TYA 
	PHA 
	JSR DCLOSE
	PLA 
	TAY 
	JMP IOERR 	;show it
;
;This is the command text and
;addresses of routines
;plus string positions for
;Show command.
;
CMDTXT	.BYTE "QDRN*CGLS"
	.BYTE "BT-=FPH.E"
CMDADR	.WORD DOSCMD 	;Quit
	.WORD ALTER 	;Display
	.WORD DOREGS 	;Registers
	.WORD CREGS 	;New register
	.WORD DISMEM 	;*=addr
	.WORD CHGMEM 	;Change
	.WORD GMEM 	;Go
	.WORD DOLOAD 	;Load
	.WORD DOSAVE 	;Save
	.WORD BKPHAN 	;Break pnt han
	.WORD TRACE 	;Trace
	.WORD SCRUP 	;-
	.WORD SCRDN 	;=
	.WORD FINDIT 	;Find
	.WORD DISDEV 	;Print
	.WORD PGTHRU 	;High speed
	.WORD PRDH 	;.
	.WORD ERASE 	;Erase
;
;Disassembler Vectors
;
DCOMT	.WORD IMMED 	;immediate
	.WORD ZPAG 	;Zpage
	.WORD ZPAGX 	;Zpage,X
	.WORD ABSOL 	;Absolute
	.WORD ABSOLX 	;Absolute,X
	.WORD ABSOLY 	;Absolute,Y
	.WORD INDX 	;(indirect,X)
	.WORD INDY 	;(indirect),Y
	.WORD ACCUM 	;Accumulator
	.WORD RELA 	;Relative
	.WORD IMP 	;Implied
	.WORD INDI 	;(indirect)
	.WORD ZPAGY 	;Zpage,Y
STRPOS	.BYTE 5,8,11,14,17,20
;
;Screen line address table
;
SCRN	.WORD [MYSCRN+1] 	;ln 0
	.WORD [MYSCRN+33] 	;ln 1
	.WORD [MYSCRN+65] 	;ln 2
	.WORD [MYSCRN+97] 	;ln 3
	.WORD [MYSCRN+129] 	;ln 4
	.WORD [MYSCRN+161] 	;ln 5
	.WORD [MYSCRN+193] 	;ln 6
	.WORD [MYSCRN+225] 	;ln 7
	.WORD [MYSCRN+257] 	;ln 8
	.WORD [MYSCRN+289] 	;ln 9
	.WORD [MYSCRN+321] 	;ln 10
	.WORD [MYSCRN+353] 	;ln 11
	.WORD [MYSCRN+385] 	;ln 12
	.WORD [MYSCRN+417] 	;ln 13
	.WORD ERRLN 	;ln 14
	.WORD STATLN 	;ln 15
BAL	.BYTE 0,0
DRPOS	.BYTE 5,8,11,14,17
BRKS	.BYTE 0,0
EXEC	.BYTE 0
BRKLN	.BYTE 0,5,10,15,20,25
TKEY	.BYTE 0,0
;
;Branch Instrs + branch bits
;
BRAL	.BYTE $10,$50,$90,$D0
BRAH	.BYTE $30,$70,$B0,$F0
BBIT	.BYTE $80,$40,$01,$02
;
;Custom Display List
;
DLIST	.BYTE $70,$70,$70,$42
	.WORD LINE1
	.BYTE $00,$02,$20,$42
	.WORD MYSCRN
	.BYTE $02,$02,$02,$02
	.BYTE $02,$02,$02,$02
	.BYTE $02,$02,$02,$02
	.BYTE $02,$20,$42
	.WORD LINE2
	.BYTE $02,$00,$02
	.BYTE $00,$02,$00,$02
	.BYTE $00,$02,$02,$41
	.WORD DLIST
;
;Screen Memory
;
LINE1	.SBYTE +$80,"  DEBUG+    by: Bryan Schappel  "
	.SBYTE +$80," ADDR  B1  B2  B3  MNEMONICS    "
LINE2	.SBYTE +$80,"  PC| A| X| Y|SP|NV_BDIZC|MODE  "
PCNT	.SBYTE "    |  |  |  |  |        |DISA  "
	.SBYTE +$80," INPUT:"
	.BYTE 0
COMND	.SBYTE "  "
COMLN	.SBYTE "               "
	.SBYTE "       "
	.SBYTE +$80," ERROR:"
	.BYTE 0
ERRLN	.SBYTE "                        "
	.SBYTE +$80,"  STAT:"
	.BYTE 0
STATLN	.SBYTE "                        "
	.SBYTE +$80,"BRK1|BRK2|BRK3|BRK4|BRK5|BRK6|FR"
FRLN	.SBYTE "    |    |    |    |    |    |00"
;
;Run and trace data tables
;
USRA	.BYTE 0
USRX	.BYTE 0
USRY	.BYTE 0
USRS	.BYTE 0
USRP	.BYTE 0
USRPC	.BYTE 0,0
;
;Register Table
;
REGTAB	.WORD USRA
	.WORD USRX
	.WORD USRY
	.WORD USRS
	.WORD USRP
BITS	.BYTE 1,2,4,8,16,32,64,128
;
;Icode/Asc convert tables
;
A2I	.BYTE $40,$00,$20,$60
I2A	.BYTE $20,$40,$00,$60
;
;BRK point data tables
;
SETLO	.BYTE 0,0,0,0,0,0 	;LSB
SETHI	.BYTE 0,0,0,0,0,0 	;MSB
OLDOP	.BYTE 0,0,0,0,0,0 	;opcode
OPSET	.BYTE 0,0,0,0,0,0 	;flag
;
;Special Key presses
;
KEYS	.BYTE $FF,$FE,$FD,$9F,$9E
	.BYTE $9D,$9C,$9B,$7F,$7E
	.BYTE $7D,$1F,$1E,$1D,$1C
	.BYTE $1B
;
;Error codes numbers
;
ERRS	.BYTE 128,130,137,138,139
	.BYTE 144,146,162,164,165
	.BYTE 167,169,170,149
	.BYTE 150,151,152,153
;
;Error code addresses
;
ERRTAB	.WORD I128,I130,I137
	.WORD I138,I139,I144
	.WORD I146,I162,I164
	.WORD I165,I167,I169
	.WORD I170,I149,I150
	.WORD I151,I152,I153
;
;Miscellaneous Text & Devs
;
DEVNAMS	.SBYTE "(D,P)?"
PGTR	.SBYTE "(U,D)?"
SLOF	.SBYTE "(S,F,O)?"
REGTXT	.SBYTE "(AXYSP)?"
DEVS	.BYTE "DP"
FILNAM	.BYTE " :        "
	.BYTE "    ",EOL
REGIS	.BYTE "AXYSP"
BRKPNT	.BYTE "BRK POINT FOUND"
LEGAL	.BYTE $9B,$9C,$7E,",."
HEXDIG	.BYTE "0123456789ABCDEF"
	.BYTE "GHIJKLMNOPQRSTUVWXYZ"
FTXT	.BYTE "FIND #"
COMMAX	.BYTE ",X)"
COMMAY	.BYTE "Y,)"
LODAD	.BYTE "LOAD AT"
;
;English Error Codes
;
I128	.CBYTE "BREAK KEY ABORT"
I130	.CBYTE "NO DEVICE HANDLER"
I137	.CBYTE "TRUNCATED RECORD"
I138	.CBYTE "DEVICE TIMEOUT"
I139	.CBYTE "DEVICE NAK"
I144	.CBYTE "WRITE PROTECTED"
I146	.CBYTE "FUNCTION NOT DONE"
I162	.CBYTE "DISK FULL"
I164	.CBYTE "FILE NUM MISMATCH"
I165	.CBYTE "BAD FILE NAME"
I167	.CBYTE "FILE LOCKED"
I169	.CBYTE "DIRECTORY FULL"
I170	.CBYTE "FILE NOT FOUND"
I149	.CBYTE "FILE NOT BINARY"
I150	.CBYTE "NO SET BRK POINT"
I151	.CBYTE "INVALID OPCODE"
I152	.CBYTE "BRK POINT SET"
I153	.CBYTE "ADR RANGE ERROR"
;
;These are the mnemonics for
;the disassembler. They are
;arranged here in alphabetical
;order.
;
MNE	.BYTE "ADCANDASLBCCBCS"
	.BYTE "BEQBITBMIBNEBPL"
	.BYTE "BRKBVCBVSCLCCLD"	;!!!!!!!! INVERSE CHARS !!!!!!!!
	.BYTE "CLICLVCMPCPXCPY"
	.BYTE "DECDEXDEYEORINC"
	.BYTE "INXINYJMPJSRLDA"
	.BYTE "LDXLDYLSRNOPORA"
	.BYTE "PHAPHPPLAPLPROL"
	.BYTE "RORRTIRTSSBCSEC"
	.BYTE "SEDSEISTASTXSTY"
	.BYTE "TAXTAYTSXTXATXS"
	.BYTE "TYA???"
;
;Opcodes
;
OPCODE
	.BYTE $69,$65,$75,$6D 	;ADC
	.BYTE $7D,$79,$61,$71
	.BYTE $29,$25,$35,$2D 	;AND
	.BYTE $3D,$39,$21,$31
	.BYTE $0A,$06,$16,$0E 	;ASL
	.BYTE $1E
	.BYTE $90 	;BCC
	.BYTE $B0 	;BCS
	.BYTE $F0 	;BEQ
	.BYTE $24,$2C 	;BIT
	.BYTE $30 	;BMI
	.BYTE $D0 	;BNE
	.BYTE $10 	;BPL
	.BYTE $00 	;BRK
	.BYTE $50 	;BVC
	.BYTE $70 	;BVS
	.BYTE $18 	;CLC
	.BYTE $D8 	;CLD
	.BYTE $58 	;CLI
	.BYTE $B8 	;CLV
	.BYTE $C9,$C5,$D5,$CD 	;CMP
	.BYTE $DD,$D9,$C1,$D1
	.BYTE $E0,$E4,$EC 	;CPX
	.BYTE $C0,$C4,$CC 	;CPY
	.BYTE $C6,$D6,$CE,$DE 	;DEC
	.BYTE $CA 	;DEX
	.BYTE $88 	;DEY
	.BYTE $49,$45,$55,$4D 	;EOR
	.BYTE $5D,$59,$41,$51
	.BYTE $E6,$F6,$EE,$FE 	;INC
	.BYTE $E8 	;INX
	.BYTE $C8 	;INY
	.BYTE $4C,$6C 	;JMP
	.BYTE $20 	;JSR
	.BYTE $A9,$A5,$B5,$AD 	;LDA
	.BYTE $BD,$B9,$A1,$B1
	.BYTE $A2,$A6,$B6,$AE 	;LDX
	.BYTE $BE
	.BYTE $A0,$A4,$B4,$AC 	;LDY
	.BYTE $BC
	.BYTE $4A,$46,$56,$4E 	;LSR
	.BYTE $5E
	.BYTE $EA 	;NOP
	.BYTE $09,$05,$15,$0D 	;ORA
	.BYTE $1D,$19,$01,$11
	.BYTE $48 	;PHA
	.BYTE $08 	;PHP
	.BYTE $68 	;PLA
	.BYTE $28 	;PLP
	.BYTE $2A,$26,$36,$2E 	;ROL
	.BYTE $3E
	.BYTE $6A,$66,$76,$6E 	;ROR
	.BYTE $7E
	.BYTE $40 	;RTI
	.BYTE $60 	;RTS
	.BYTE $E9,$E5,$F5,$ED 	;SBC
	.BYTE $FD,$F9,$E1,$F1
	.BYTE $38 	;SEC
	.BYTE $F8 	;SED
	.BYTE $78 	;SEI
	.BYTE $85,$95,$8D 	;STA
	.BYTE $9D,$99,$81,$91
	.BYTE $86,$96,$8E 	;STX
	.BYTE $84,$94,$8C 	;STY
	.BYTE $AA 	;TAX
	.BYTE $A8 	;TAY
	.BYTE $BA 	;TSX
	.BYTE $8A 	;TXA
	.BYTE $9A 	;TXS
	.BYTE $98 	;TYA
;
;Offsets into Mnemonic table
;
OFFSET
	.BYTE 0,0,0,0,0,0,0,0 	;ADC
	.BYTE 3,3,3,3,3,3,3,3 	;AND
	.BYTE 6,6,6,6,6 	;ASL
	.BYTE 9 	;BCC
	.BYTE 12 	;BCS
	.BYTE 15 	;BEQ
	.BYTE 18,18 	;BIT
	.BYTE 21 	;BMI
	.BYTE 24 	;BNE
	.BYTE 27 	;BPL
	.BYTE 30 	;BRK
	.BYTE 33 	;BVC
	.BYTE 36 	;BVS
	.BYTE 39 	;CLC
	.BYTE 42 	;CLD
	.BYTE 45 	;CLI
	.BYTE 48 	;CLV
	.BYTE 51,51,51,51 	;CMP
	.BYTE 51,51,51,51
	.BYTE 54,54,54 	;CPX
	.BYTE 57,57,57 	;CPY
	.BYTE 60,60,60,60 	;DEC
	.BYTE 63 	;DEX
	.BYTE 66 	;DEY
	.BYTE 69,69,69,69 	;EOR
	.BYTE 69,69,69,69
	.BYTE 72,72,72,72 	;INC
	.BYTE 75 	;INX
	.BYTE 78 	;INY
	.BYTE 81,81 	;JMP
	.BYTE 84 	;JSR
	.BYTE 87,87,87,87 	;LDA
	.BYTE 87,87,87,87
	.BYTE 90,90,90,90,90 	;LDX
	.BYTE 93,93,93,93,93 	;LDY
	.BYTE 96,96,96,96,96 	;LSR
	.BYTE 99 	;NOP
	.BYTE 102,102,102,102 	;ORA
	.BYTE 102,102,102,102
	.BYTE 105 	;PHA
	.BYTE 108 	;PHP
	.BYTE 111 	;PLA
	.BYTE 114 	;PLP
	.BYTE 117,117,117,117 	;ROL
	.BYTE 117
	.BYTE 120,120,120,120 	;ROR
	.BYTE 120
	.BYTE 123 	;RTI
	.BYTE 126 	;RTS
	.BYTE 129,129,129,129 	;SBC
	.BYTE 129,129,129,129
	.BYTE 132 	;SEC
	.BYTE 135 	;SED
	.BYTE 138 	;SEI
	.BYTE 141,141,141,141 	;STA
	.BYTE 141,141,141
	.BYTE 144,144,144 	;STX
	.BYTE 147,147,147 	;STY
	.BYTE 150 	;TAX
	.BYTE 153 	;TAY
	.BYTE 156 	;TSX
	.BYTE 159 	;TXA
	.BYTE 162 	;TXS
	.BYTE 165 	;TYA
	.BYTE 168 	;???
;
;Instruction Types
;
; 0 = Immediate
; 1 = Zero page
; 2 = Zero page,X
; 3 = Absolute
; 4 = Absolute,X
; 5 = Absolute,Y
; 6 = Indirect,X
; 7 = Indirect,Y
; 8 = Accumulator
; 9 = Relative
;10 = Implied
;11 = Indirect
;12 = Zero page,Y
;
ITYPE
	.BYTE 0,1,2,3,4,5,6,7 	;ADC
	.BYTE 0,1,2,3,4,5,6,7 	;AND
	.BYTE 8,1,2,3,4 	;ASL
	.BYTE 9 	;BCC
	.BYTE 9 	;BCS
	.BYTE 9 	;BEQ
	.BYTE 1,3 	;BIT
	.BYTE 9 	;BMI
	.BYTE 9 	;BNE
	.BYTE 9 	;BPL
	.BYTE 10 	;BRK
	.BYTE 9 	;BVC
	.BYTE 9 	;BVS
	.BYTE 10 	;CLC
	.BYTE 10 	;CLD
	.BYTE 10 	;CLI
	.BYTE 10 	;CLV
	.BYTE 0,1,2,3,4,5,6,7 	;CMP
	.BYTE 0,1,3 	;CPX
	.BYTE 0,1,3 	;CPY
	.BYTE 1,2,3,4 	;DEC
	.BYTE 10 	;DEX
	.BYTE 10 	;DEY
	.BYTE 0,1,2,3,4,5,6,7 	;EOR
	.BYTE 1,2,3,4 	;INC
	.BYTE 10 	;INX
	.BYTE 10 	;INY
	.BYTE 3,11 	;JMP
	.BYTE 3 	;JSR
	.BYTE 0,1,2,3,4,5,6,7 	;LDA
	.BYTE 0,1,12,3,5 	;LDX
	.BYTE 0,1,2,3,4 	;LDY
	.BYTE 8,1,2,3,4 	;LSR
	.BYTE 10 	;NOP
	.BYTE 0,1,2,3,4,5,6,7 	;ORA
	.BYTE 10 	;PHA
	.BYTE 10 	;PHP
	.BYTE 10 	;PLA
	.BYTE 10 	;PLP
	.BYTE 8,1,2,3,4 	;ROL
	.BYTE 8,1,2,3,4 	;ROR
	.BYTE 10 	;RTI
	.BYTE 10 	;RTS
	.BYTE 0,1,2,3,4,5,6,7 	;SBC
	.BYTE 10 	;SEC
	.BYTE 10 	;SED
	.BYTE 10 	;SEI
	.BYTE 1,2,3,4,5,6,7 	;STA
	.BYTE 1,12,3 	;STX
	.BYTE 1,2,3 	;STY
	.BYTE 10 	;TAX
	.BYTE 10 	;TAY
	.BYTE 10 	;TSX
	.BYTE 10 	;TXA
	.BYTE 10 	;TXS
	.BYTE 10 	;TYA
	.BYTE 10 	;???
;
MYBUF	    40 	;I/O buffer
MBF2	    15 	;temp save buff
MYZPG	    256 	;zero page
MYPG1	    256 	;stack
MYPG2	    256 	;page two
ENDBUF	= * 	;end of buffers
MYSCRN	= $BD00 	;scr mem 3pgs
;
	*= $02E0
	.WORD DISA
	.END 
