-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathmanii4
352 lines (352 loc) · 6.96 KB
/
manii4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
.PAGE 'MANII4 11/03/80'
; ****** CONSTANTS ******
;
CR = $0D ;ASCII RETURN CODE
SPERR = $10 ;TAPE ERROR
LLEN = 40 ;40 COLUMNS
NLINES = 25 ;25 DISPLAY LINES
WLKNUM = 9 ;WALK CLOCK COUNT
MSIZE = 8 ;# MEMORY BYTES TO DISPLAY
ISIZE = 8 ;# INTERROGATE BYTES TO SHOW
.SKIP 3
; ****** Z-PAGE VARABLES ******
;
MEMSIZ = $283 ;TOP OF MEMORY FOR BASIC
CINV = $314 ;INDIRECT VECTOR FOR IRQ
CBINV = $316 ;BRK RAM VECTOR
NMINV = $318 ;NMI RAM VECTOR
SATUS = $90 ;I/O OPERATION STATUS BYTE
LSTX = $C5 ;LAST KEY INDEX
STKEY = $91 ;STOP KEY FLAG
VERCK = $93 ;LOAD OR VERIFY FLAG
NDX = $C6 ;# CHARS IN KEYBUFFER
INDX = $C8 ;LENGTH OF CURENT LINE ON SCREEN
BLNSW = $CC ;BLINK CURSOR SWITCH
BLNCT = $CD ;CURSOR BLINK CTR
GDBLN = $CE ;BEFORE BLINK CHAR
BLNON = $CF ;CHAR IS REVERSE FLAG
DFLTN = $99 ;DEFAULT INPUT DEVICE #
DFLTO = $9A ;DEFAULT OUTPUT DEVICE #
PNT = $D1 ;LINE ADDRESS OF CURSOR
PNTR = $D3 ;COLUMN OF CURSOR
SAL = $AC ;POINTER USED IN SCROLL DOWN
EAL = $AE ;USE THIS FOR COLOR SCROLL DOWN
CMP0 = $B0 ;AND THIS TOO
FNLEN = $B7 ;LENGTH OF CURRENT FILE NAME
SA = $B9 ;SECONDARY ADDRESS FOR IEEE I/O
FA = $BA ;IEEE-488 FIRST ADDRESS
TBLX = $D6 ;ACTIVE CURSOR LINE
FNADR = $BB ;OFFSET FOR NEW LOCATER
TMP0 = $C1 ;INDIRECT 1
TMP2 = $C3 ;INDIRECT 2
ZPAGE = $F7 ;INDIRECT FOR ZERO PAGE SWAP
SPAGE = $F9 ;BASE ADDRESS OF SWAP PAGE
.SKIP 3
*=$0000 ;ZERO PAGE VARIABLES ALL MY OWN
D6510 *=*+1 ;6510 DATA DIRECTION REGISTER
R6510 *=*+1 ;6510 DATA REGISTER
*=$0002
PCH *=*+1 ;PROGRAM COUNTER AND REGISTERS
PCL *=*+1
FLGS *=*+1
ACC *=*+1
XR *=*+1
YR *=*+1
SP *=*+1
INVH *=*+1
INVL *=*+1
TEMPX *=*+1 ;TEMPORARY X INDEX REGISTER STORAGE
TEMPY *=*+1 ;TEMPORARY Y INDEX REGISTER STORAGE
R0 *=*+2 ;RESULTANT RELOCATION REGISTER
NORELO *=*+1 ;NO RELOCATION FLAG
WSW *=*+1 ;WALK STATUS WORD
OLDNMI *=*+2 ;SYSTEM'S NMI VECTOR
FULSPD *=*+1 ;WALK THEN GO FLAG
BRKADR *=*+2 ;ADDRESS OF BREAK POINT
BRKCNT *=*+2 ;# OF OCCURENCES BEFORE BREAK
KEYS *=*+2 ;INDIRECT JUMP FOR MY IRQ HANDLER
OPCODE *=*+1 ;OPCODE IS STORED HERE WHEN BREAKPOINT IS ON
;
;
SAVLS *=*+1 ;SAVE OF LAST KEY INDEX
DELAY *=*+1 ;DELAY BEFORE REPEATS
REPDY *=*+1 ;DELAY BETWEEN REPEATS
SAVCMD *=*+1 ;LAST COMMAND LETTER
SAVX *=*+1 ;PLACE TO SAVE X
TMPC *=*+1
TMPC2 *=*+1
LENGTH *=*+1 ;DIS INSTR LENGTH
PTCH *=*+1 ;TEMP FOR DISA
MSAL *=*+2
DIFF *=*+1
TMP10 *=*+2
WRAP *=*+1 ;WRAP FFFF FLAG
TMPC4 *=*+1
FORMAT *=*+1
BAD *=*+1
TMP12 *=*+2 ;OCCURENCE CTR FOR QUICK
NEWLC *=*+2 ;OFFSET FOR NEW LOCATER
RBUSY *=*+1 ;ROLL BUSY FLAG
OLDIER *=*+1 ;USER'S IRQ ENABLE REGISTER
MTCH *=*+64 ;64 CHAR MATCH BUFFER
.SKIP 2
KEYD = $0277 ;KEYBOAD INPUT BUF
BEGIN = $8000 ;START VICMON HERE
.SKIP 3
; ****** ROM ROUTINES ******
.SKIP 3
LD15B2 = $FFD5 ;MONITOR LOAD ENTRY
SV5B2 = $FFD8 ;MONITOR SAVE ENTRY
CLRCH = $FFCC ;CLEAR CHANNEL
BASIN = $FFCF ;INPUT A CHAR
GETIN = $FFE4 ;GET A CHAR
BSOUT = $FFD2 ;OUTPUT A CHAR
SETMSG = $FF90 ;ENABLE(.A=$80)/DISABLE(.A=0) KERNAL MESSAGES
NMI = $FE0C
IRQVEC = $FFFE
.SKIP 3
; I/O DEVICES
;
VICSCN =$0400 ;SCREEN
* =$D000
VICREG =* ;VIC REGISTERS
.SKI 2
* =$D400
SIDREG =* ;SID REGISTERS
.SKI 2
* =$D800
VICOL *=*+1024 ;VIC COLOR NYBBLES
.SKI 2
* =$DC00 ;DEVICE1 6526 (PAGE1 IRQ)
ROWS ;KEYBOARD MATRIX
D1PRA *=*+1
COLM ;KEYBOARD MATRIX
D1PRB *=*+1
D1DDRA *=*+1
D1DDRB *=*+1
D1T1L *=*+1
D1T1H *=*+1
D1T2L *=*+1
D1T2H *=*+1
D1TOD1 *=*+1
D1TODS *=*+1
D1TODM *=*+1
D1TODH *=*+1
D1SDR *=*+1
D1ICR *=*+1
D1CRA *=*+1
D1CRB *=*+1
.SKI 2
* =$DD00 ;DEVICE2 6526 (PAGE2 NMI)
D2PRA *=*+1
D2PRB *=*+1
D2DDRA *=*+1
D2DDRB *=*+1
D2T1L *=*+1
D2T1H *=*+1
D2T2L *=*+1
D2T2H *=*+1
D2TOD1 *=*+1
D2TODS *=*+1
D2TODM *=*+1
D2TODH *=*+1
D2SDR *=*+1
D2ICR *=*+1
D2CRA *=*+1
D2CRB *=*+1
.SKI 2
TIMRB =$19 ;6526 CRB ENABLE ONE-SHOT TB
.SKIP 4
*= BEGIN
; .BYT 0
; .WOR COLDS-2
; .WOR $10
; .BYT 158 ;SYS TOKEN
; .BYT '(1039)',0,0,0
COLDS JMP INIT ;COLD START MONITOR
WARMS JMP BRKE ;WARM START MONITOR
.SKIP 3
RDT JMP BASIN ;ALL INPUT THRU HERE
WRT JMP BSOUT ;ALL OUTPUT THRU HERE
.SKIP 3
; INSTALL EXTRA MONITOR COMMANDS
;
INIT SEI ;STOP IRQ'S
LDA NMINV ;SAVE HIS NMI
STA OLDNMI
LDA NMINV+1
STA OLDNMI+1
LDA BRKVEC ;INIT NEW BRK VECTOR
LDX BRKVEC+1
STA CBINV
STX CBINV+1
JSR REVECT ;KEYS=CINV:CINV=WINTR -- INTERCEPT KEYBOARD INPUT
LDA #0
STA SPAGE ;INDICATE NO SWAP PAGE
STA SPAGE+1
INIT30
LDA #$80 ;ENABLE KERNAL MESSAGES
JSR SETMSG
LDA #$FF
STA OPCODE ;NO BREAK POINT OPCODES HAVE BEEN SAVED
LDA #0
STA FULSPD ;NO BREAK POINT ACTIVE
STA WSW ;DO A BREAK
STA RBUSY ;NOT BUSY
CLI ;ALLOW IRQ'S
BRK
.SKIP 4
BRKE
JSR SWAP ;DO A SWAP IF ITS NEEDED
PLA ;RETRIEVE REGISTERS FROM IRQ HANDLER IN ROM
STA YR
PLA
STA XR
PLA
STA ACC
PLA
STA FLGS
PLA
STA PCL
PLA
STA PCH
;
TSX
STX SP ;SAVE STACK POINTER
SEC
LDA PCL ;BACK UP ONE INSTRUCTION
SBC #2 ;2 BYTES IS ONE INSTRUCTION
STA PCL
LDA PCH
SBC #0 ;ADJUST WITH CARRY
STA PCH
;
JSR REVECT ;SO I CAN INTERCEPT KEYS FOR SCROLL CONTROL
LDA OPCODE ;WAS THIS MY BREAK POINT?
CMP #$FF
BEQ B5 ;BRANCH IF NOT
;
LDX BRKADR ;ELSE PUT INSTRUCTION BACK
STX TMP0 ;MAKE MEMORY LOOK RIGHT
LDX BRKADR+1
STX TMP0+1
LDY #0
JSR PUTBYY ;PUT THE OPCODE BACK
;
LDA TMP12 ;BREAK ON N'TH OCCURENCE
BNE BRK500 ;BRANCH IF NOT AT N'TH OCCURENCE YET
LDA TMP12+1
BNE BRK400
BEQ B5 ;DO THE BREAK
;
BRK500 JMP TBR500
BRK400 JMP TBR400
;
B5 JSR CRLF
LDX #'B ;SET X EQUAL TO B
B567 LDA #'*
JSR WRTWO
JMP D1X ;DISPLAY REGISTERS
; PERMIT IMMEDIATE
; ALTER FOLLOWING
; BREAKPOINT
ERROPR LDA #$3F ;PRINT A "?" FOR AN ERROR
JSR WRT
STRT
JSR CRLF
STRT10 LDA #'. ;TYPE A PROMPTING '.'
JSR WRT
LDA #0 ;ZERO WRAP FLAG
STA NORELO ;TURN ON RELOCATION
STA WRAP
STA RBUSY ;NOT BUST NOW
ST1 JSR RDOC ;READ COMMAND. CHARACTER
; IS RETURNED IN A
CMP #'. ;IGNORE PROMPTING '.'
BEQ ST1
CMP #$20 ;IGNORE SPACES
BEQ ST1
.SKIP 3
; SEARCH FOR COMMANDS
;
NWCMD LDX #NCMDS-1
NW10 CMP CMDS,X
BNE NW20
STA SAVCMD
TXA ;MULT BY TWO
ASL A
TAX ;INDEX INTO DISPATCH TABLE
.SKIP 3
; DISPATCH TO COMMAND
;
LDA ADRS,X ;FAKE INDEXED JMP
STA TMP0
LDA ADRS+1,X ;PUSH ADR-1 AND RTS
STA TMP0+1
JMP (TMP0)
;
NW20 DEX
BPL NW10
BMI ERROPR ;CMD NOT FOUND ERROR
.SKIP 3
; DEC TMP0 OR TMP2
;
DECT2 LDX #2 ;DEC TMP2 WORD
BNE DEC30 ;ALWAYS
DECT0 LDX #0 ;DEC TMP0 WORD
DEC30 LDY TMP0,X ;A BORROW?
BNE DEC20 ;NO-SKIP
LDY TMP0+1,X ;A MEMORY WRAP
BNE DEC10 ;NO-SKIP
INC WRAP ;YES-SET FLAG
DEC10 DEC TMP0+1,X
DEC20 DEC TMP0,X
DRTS RTS
.SKIP 3
;DISASSEMBLE ONE LINE PRINT 2 SPACES
;
DISSPC LDA #0 ;PRINT ALL CHARS
STA PTCH
JSR DIS300 ;DIS. ONE
LDX #2 ;SET FOR 2 SPACES
.SKIP 3
;PRINT # OF SPACES=X
;
SPCX JSR SPACE
DEX
BNE SPCX
RTS
.SKIP 3
; EXCHANGE TMP REGISTERS
;
T0T10 LDX #2 ;EXCHANGE TMP0 WITH
T0T100 LDA TMP0-1,X ; TMP10
PHA
LDA TMP10-1,X
STA TMP0-1,X
PLA
STA TMP10-1,X
DEX
BNE T0T100
RTS
.SKIP 3
; DOUBLE SUBTRACT
; DIFF=LO DIFFERENCE
; Y=HI DIFFERENCE
; A=0 IF ZERO DIFFERENCE
;
DCT10 LDA TMP10 ;TMP10-TMP0
LDY TMP10+1
JMP DC10 ;SKIP OVER
DCMP LDA TMP2 ;TMP2-TMP0
LDY TMP2+1
DC10 SEC
SBC TMP0
STA DIFF
TYA ;HI BYTE IN Y
SBC TMP0+1
TAY ;SAVE HI RESULT IN Y
ORA DIFF ;OR LO FOR EQUAL TEST
RTS
.SKIP 5
.END