-
Notifications
You must be signed in to change notification settings - Fork 82
/
init
432 lines (432 loc) · 8.25 KB
/
init
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
.PAG 'INIT 11/19/82'
;------------------------------------------------
; START - SYSTEM RESET ROUTINE
; KERNAL CHECKS ON 4K BOUNDRIES FROM $1000-$8000
; FIRST OCCURANCE HAS PRIORITY.
; IF NO OCCURANCE THEN $E000 IS USED FOR VECTOR
; $E000 => MONITOR START
; KERNAL EXPECTS:
; $X000 - JMP INIT (COLD START)
; $X003 - JMP WINIT (WARM START)
; $X006 - 'C'(+$80)=> KERNAL COLD START FIRST
; $X007 - 'B'+$80
; $X008 - 'M'+$80
; $X009 - 'X' X=4K BANK (1-8)
;
;------------------------------------------------
.SKI 1
PATALL .BYT $C2,$CD ;$X004 ROM PATTERN
.SKI 1
START LDX #$FE ;DO ALL NORMAL JUNK...
SEI
TXS
CLD
;
; CHECK FOR WARM START
;
LDA #WARM+WINIT ;LOAD UP BITS THAT SHOW WARM
EOR EVECT+2 ;CHECK WARM FLAG
EOR EVECT+3 ;CHECK COMPLETE FLAG
BEQ SWARMG ;GOOD...DO WARM START
;
; CHECK FOR ROMS
;
SCOLD LDA #6 ;SET UP INDIRECT
STA EAL
LDA #0 ;CLEAR UPPER
STA EAH
STA EVECT+0 ;SET LOW BYTE OF VECTOR
LDX #$30 ;EXISTANCE FLAG
SLOOP0 LDY #3 ;GO AROUND TEST LOOP
LDA EAH
BMI SLOOP2 ;NO ROMS BUT THIS ONE...
CLC ;CALC NEW TEST POINT
ADC #$10 ;4K STEPS
STA EAH
INX
TXA
CMP (EAL)Y
BNE SLOOP0 ;DIDN'T MATCH 'X'...
DEY
SLOOP1 LDA (EAL)Y
DEY
BMI SLOOP3 ;ALL DONE...CORRECTLY
CMP PATALL,Y
BEQ SLOOP1
BNE SLOOP0 ;NO GOOD...
;
; MONITOR (COULD BE TEST FOR KEYDOWN ***)
;
SLOOP2 LDY #$E0
.BYTE $2C ;SKIP TWO BYTES
SLOOP3 LDY EAH
STARHI STY EVECT+1 ;SET HIGH BYTE OF VECTOR
;
TAX ;SET FLAGS
BPL SWARMG ;DON'T USE KERNAL INITILIZATION
;;BPL SWARM ;DON'T USE KERNAL INITILIZATION
;
; KERNAL COLD START
;
SKERNL JSR IOINIT ;INITILIZE I/O
JSR XCINT ;REM SPECIAL CINIT CALL FOR NON-CLEARED SYSTEM
JSR RAMTAS ;RAM TEST AND SET
JSR RESTOR ;OPERATIONG SYSTEM VECTORS
JSR CINT ;SCREEN EDITOR INITILIZATION
LDA #WARM ;SET FOR WARM RESET
STA EVECT+2
LDA #WINIT
STA EVECT+3
SWARMI CLI ;ALLOW INTERRUPTS NOW
SWARM JMP (EVECT) ;START EXIT
SWARMG LDA #$03 ;POINT AT WARM START $XX03
STA EVECT
BNE SWARM ;ALWAYS
.PAGE 'INIT - I/O'
;----------------------------------
; IOINIT - INITILIZE I/O SYSTEM
; 6509/6525/6525/6526
;
;----------------------------------
IOINIT
;
; 6509 INITILIZATION CODE
; SEE PAGE 2 FOR ASSIGNMENTS
; DONE BY RESET
;
;
; 6525 TPI1 INITILIZATION CODE
; SEE PAGE 12 FOR ASSIGNMENTS
;
LDA #%11110011 ;CB,CA=HI IE3,4=NEG IP=1 MC=1
STA TPI1+CREG
LDA #$FF ;MASK ON ALL IRQ'S
STA TPI1+DDPC
; PB4=OUTPUT 1, TO CLAIM DBUS
LDA #%01011100 ;WRT=LO UNUSED NETR=OFF
STA TPI1+PB ;NETW=OFF IFC=LO (MUST TURN OFF !!!)
LDA #%01111101 ;SET DIRECTIONS
STA TPI1+DDPB
;
LDA #%00111101 ;IEEE CONTROLS OFF
STA TPI1+PA
LDA #%00111111 ;IEEE CONTROL TO TRANSMITT
STA TPI1+DDPA ;DATA TO RECEIVE
;
; 6525 TPI2 INITILIZATION CODE
; SEE PAGE 13 FOR ASSIGNMENTS
;
LDA #$FF
STA TPI2+PA ;SET UP KEYOARD OUTPUTS
STA TPI1+PB
STA TPI2+DDPA
STA TPI2+DDPB
LSR TPI2+PA ;TURN STOP KEY LINE ON ***
.IFN SYSTEM <
LDA #$C0 ;SET UP VIC SELECTS=OUT FOR P-SERIES
>
.IFE SYSTEM <
LDA #$00 ;SET UP VIC SELECTS=IN FOR SYSTEM JUMPERS
>
STA TPI2+PC
STA TPI2+DDPC ; KEYBOARD=IN (0-5)
;
; 6526 CIA INITILIZATION CODE
; SEE PAGE 10 FOR ASSIGNMENTS
;
LDA #$84 ;ALARM IS ALWAYS ON...
STA CIA+ICR
LDY #$00
STY CIA+DDRA ;ALL IEEE IN / TRIGGERS 14,24 ALSO
STY CIA+DDRB ;SAME FOR GAME INPUTS 10-13,20-23
STY CIA+CRB ;WRITE TOD TIMER B=OFF
; ACTIVATE TOD
;
STA CIA+TOD10
;
; 60/50 HZ TEST CODE FOR TOD
;
STY TPI1+PC
IO100 LDA TPI1+PC ;WAIT UNTILL IT HAPPENS AGAIN
ROR A
BCC IO100 ;PC0 = 1 -> 50/60HZ IRQ
STY TPI1+PC ;CLEAR IT AGAIN
;
; START A TIMMER
;
LDX #0
LDY #0
IO110 INX
BNE IO110
INY
LDA TPI1+PC
ROR A
BCC IO110 ;PC0 = 1 -> 50/60HZ IRQ
;
CPY #ID55HZ
BCC IO120 ;IT WAS 60 HZ
LDA #%10001000 ;SET FOR 50HZ
.BYT $2C ;SKIP TWO BYTES
IO120 LDA #%00001000
STA CIA+CRA
;
; 6526 INTER-PROCESS COMMUNICATION INITIALIZATION
; PRA = DATA PORT
; PRB = IPC LINES
; IRQ'S FROM 2ND PROCESSOR VIA FLAG INPUT
;
LDA IPCIA+ICR ;CLEAR ICR
LDA #$90
STA IPCIA+ICR ;FLAG IRQS ON
LDA #$40
STA IPCIA+PRB ;NO NMI TO Z80, SEM6509 LOW
LDA #0
STA IPCIA+DDRA ;PORT A=INPUT
STA IPCIA+CRB ;TIMER B OFF
STA IPCIA+CRA ;TIMER A OFF
LDA #%01001000 ;PORT B LINES SEM65,ENNMI ARE OUTS
STA IPCIA+DDRB
;
;
; 6551 INITILIZATION CODE
; SEE PAGE 11 FOR ASSIGNMENTS
; HANDLED BY RESET 10/19/81 RSR
;
; TURN OFF IFC (COULD BE TOO SOON)***
;
LDA #IFC
ORA TPI1+PB
STA TPI1+PB
;
RTS
.PAGE 'INIT - RAMTAS'
;-----------------------------------------
; RAMTAS - INITILIZE LOWER RAM WITH $00
; AND TEST ALL SYSTEM DYNAMIC RAM
; SET RAM LIMITS (64K BANK MIN SIZE)
; ALLOCATE INITIAL BUFFER SPACE
; TURN OFF RS232 AND CASSETTE BUFFERS
;
;-----------------------------------------
RAMTAS
; CLEAR $0002-$0101 AND $0200-$03F7
;
LDA #0
TAX
PX1 .BYT $9D ;STA $0002,X
.WOR $0002
STA $200,X
STA $300-8,X
INX
BNE PX1
.SKIP 3
;
;MEMORY SIZE CHECK
;
LDA #0 ;SET INDIRECT TO SEGMENT 0
STA I6509
STA MEMSTR+2 ;SET BOTTOM OF MEMORY
STA LOWADR+2
LDA #2
STA MEMSTR
STA LOWADR
;
; MEMSIZ,SAL,LOWADR ARE ZEROED ABOVE
;
SIZLOP INC I6509 ;CLACULATE NEXT IND SEG
LDA I6509
CMP #15 ;ALL SLOTS FULL...EXIT
BEQ SIZE
LDY #2 ;ALWAYS START AT $0002
SIZ100
LDA (SAL)Y
TAX
LDA #$55
STA (SAL)Y
LDA (SAL)Y
CMP #$55
BNE SIZE
ASL A
STA (SAL)Y
LDA (SAL)Y
CMP #$AA
BNE SIZE
TXA
STA (SAL)Y
INY
BNE SIZ100
INC SAL+1
BNE SIZ100
BEQ SIZLOP
;
; SET TOP OF MEMORY
;
SIZE LDX I6509 ;SEG NUMBER OF FAILURE
DEX ;BACK UP ONE SEGMENT
TXA ;.A= SEG#
LDX #$FF
LDY #$FF
STA HIADR+2 ;SET SYSTEM TOP OF MEMORY
STY HIADR+1
STX HIADR
;
; ALLOCATE 1.25 K BYTES (FUNCS, RS232, CASSETTE)
;
LDY #$FF-5
CLC
JSR MEMTOP ;SET USER TOP OF MEMORY
;
; FLAG BUFFERS AS NOT ASSIGNED =>$FF
;
DEC RIBUF+2
DEC TAPE1+2
RTS
.PAGE 'INIT - KERNAL'
; PANIC - HANDLES NMI'S ???
;
PANIC RTI ;DO NOTHING FOR NOW
.SKI 5
JMPTAB .WOR YIRQ ;CINV
.WOR TIMB ;CBINV....BRK GOES TO MONITOR
.WOR PANIC ;NO.....NMINV !!!!!
.WOR NOPEN ;OPEN FILE
.WOR NCLOSE ;CLOSE FILE
.WOR NCHKIN ;OPEN CHANNEL IN
.WOR NCKOUT ;OPEN CHANNEL OUT
.WOR NCLRCH ;CLOSE CHANNEL
.WOR NBASIN ;INPUT FROM CHANNEL
.WOR NBSOUT ;OUTPUT TO CHANNEL
.WOR NSTOP ;SCAN STOP KEY
.WOR NGETIN ;SCAN KEYBOARD
.WOR NCLALL ;CLOSE ALL FILES
.WOR NLOAD ;LOAD FROM FILE
.WOR NSAVE ;SAVE TO FILE
.WOR S0 ;MONITOR COMMAND PARSER
.WOR ESCRTS ;ESC KEY VECTOR
.WOR ESCRTS ;USER CTRL KEY VECTOR
TABEND
NMI JMP (NMINV)
.SKI 5
; .A = FILENAME LENGTH
; .X = ZERO PAGE LOCATION OF 3 BYTE ADDRESS
;
SETNAM STA FNLEN
LDA $00,X
STA FNADR
LDA $01,X
STA FNADR+1
LDA $02,X
STA FNADR+2
RTS
.SKI 5
SETLFS STA LA
STX FA
STY SA
RTS
.SKI 5
;READ/WRITE STATUS
;
;CARRY SET -- READ DEVICE STATUS INTO .A
;
READST BCC STORST
LDA FA ;SEE WHICH DEVICES' TO READ
CMP #2
BNE READSS ;NOT RS-232
LDA RSSTAT ;YES GET IT
PHA
LDA #00 ;CLEAR STATUS WHEN READ
STA RSSTAT
PLA
RTS
;
SETMSG STA MSGFLG
READSS LDA STATUS
UDST ORA STATUS
STA STATUS
RTS
;
;CARRY CLEAR -- SET DEVICE STATUS WITH .A
;
STORST PHA
LDA FA
CMP #2
BNE STORSS ;NOT RS-232
PLA
STA RSSTAT
RTS
;
STORSS PLA
STA STATUS
RTS
.SKI 5
SETTMO STA TIMOUT
RTS
.SKI 5
MEMTOP BCC SETTOP
;
;CARRY SET--READ TOP OF MEMORY
;
LDA MEMSIZ+2
LDX MEMSIZ
LDY MEMSIZ+1
;
;CARRY CLEAR--SET TOP OF MEMORY
;
SETTOP STX MEMSIZ
STY MEMSIZ+1
STA MEMSIZ+2
RTS
.SKI 5
;MANAGE BOTTOM OF MEMORY
;
MEMBOT BCC SETBOT
;
;CARRY SET--READ BOTTOM OF MEMORY
;
LDA MEMSTR+2
LDX MEMSTR
LDY MEMSTR+1
;
;CARRY CLEAR--SET BOTTOM OF MEMORY
;
SETBOT STX MEMSTR
STY MEMSTR+1
STA MEMSTR+2
RTS
.SKI 5
;RESTORE RAM I/O VECTORS
;
RESTOR LDX #<JMPTAB
LDY #>JMPTAB
LDA #IROM
CLC
;
;MANAGE RAM I/O VECTORS
;
VECTOR STX SAL
STY SAH
LDX I6509 ;SAVE INDIRECT
STA I6509
;
BCC VECT50
;
;CARRY SET--READ VECTORS
;
LDY #TABEND-JMPTAB-1
VECT20 LDA CINV,Y ;FROM RAM TABLE
STA (SAL)Y ;INTO USER AREA
DEY
BPL VECT20
;
;CARRY CLEAR--SET VECTORS
;
VECT50 LDY #TABEND-JMPTAB-1
VECT60 LDA (SAL)Y ;FROM USER AREA
STA CINV,Y ;INTO RAM TABLE
DEY
BPL VECT60
;
STX I6509 ;RESTORE INDIRECT
RTS
AAAAAA
.END