IIcSystemClock/clock.system.s

1021 lines
22 KiB
ArmAsm
Raw Normal View History

2019-04-20 23:58:58 +00:00
.include "opcodes.inc"
.include "apple2.inc"
2019-04-20 23:08:35 +00:00
.include "common.inc"
2019-04-20 23:33:27 +00:00
.feature string_escapes
2019-04-20 23:58:58 +00:00
2019-04-20 22:54:40 +00:00
.org $2000
2019-12-09 02:16:21 +00:00
.setcpu "65C02"
.enum MessageCode
kInstall = 0
kNoSysFile = 1
kDiskError = 2
kIIc = 3
kIIe = 4
kCurrentYear = 5
kOkPrompt = 6
kNoClock = 7
kRunning = 8
kSeikoIIc = 9
kSeikoIIe = 10
kRemoveWriteProtect = 11
.endenum
2019-04-20 22:54:40 +00:00
SLOT3_FIRMWARE := $C300
PORT2_ACIA_STATUS := $C0A9
PORT2_ACIA_COMMAND := $C0AA
PORT2_ACIA_CONTROL := $C0AB
DISXY := $C058
ENBXY := $C059
DISVBL := $C05A
ENVBL := $C05B
X0EDGE1 := $C05C
X0EDGE2 := $C05D
MOUSE_BTN := $C063
2019-04-20 23:58:58 +00:00
2019-12-09 00:18:50 +00:00
kClockRoutineMaxLength = 125 ; Per ProDOS 8 TRM
2019-04-20 22:54:40 +00:00
L2000:
L2001 := * + 1
lda #$06
2019-12-09 02:16:21 +00:00
L2003 := * + 1 ; Patched location for ...?
2019-04-20 22:54:40 +00:00
lda #$A0
cmp #$CC
bne L2013
2019-12-09 02:16:21 +00:00
2019-04-21 03:33:26 +00:00
sta L239E + (L1272 - L1000) ; In relocated code
2019-04-20 22:54:40 +00:00
lda #$5C
sta L2285
sta L2336
2019-12-09 02:16:21 +00:00
L2013:
;; Clear stack
ldx #$FF
2019-04-20 22:54:40 +00:00
txs
2019-12-09 02:16:21 +00:00
;; Clear interpreter version
;; TODO: Remove this
lda #0
sta IBAKVER
sta IVERSION
2019-12-09 02:16:21 +00:00
;; Trash reset vector to cause reboot
2019-04-20 23:58:58 +00:00
sta ROMIN2
2019-04-20 22:54:40 +00:00
lda $03F3
eor #$FF
sta $03F4
2019-12-09 02:16:21 +00:00
;; Identify machine type
2019-04-20 22:54:40 +00:00
ldy #$00
ldx #$00
lda MACHID
and #%10001000 ; IIe or later, modifier
2019-04-20 22:54:40 +00:00
beq L2035
inx
2019-12-09 02:16:21 +00:00
L2035: cmp #%10001000 ; IIc ?
beq is_iic
2019-04-20 22:54:40 +00:00
lda L2003
cmp #$CC
2019-12-09 02:16:21 +00:00
beq is_iic
2019-04-20 22:54:40 +00:00
iny
2019-12-09 02:16:21 +00:00
is_iic: sty $07
2019-04-20 22:54:40 +00:00
lda L239C,x
sta $08
2019-12-09 02:16:21 +00:00
;; Check 40/80 columns; wrap strings if 40 columns.
lda MACHID
and #%00000010 ; 80 Column card?
2019-04-20 22:54:40 +00:00
lsr a
sta $09
2019-12-09 02:16:21 +00:00
bne init_80_col
2019-12-09 02:16:21 +00:00
lda #CR|$80
;; Convert spaces to newlines if 40 Columns
sta chain + (wrap1 - L1000)
sta chain + (wrap4 - L1000)
sta chain + (wrap5 - L1000)
sta chain + (wrap3 - L1000)
sta chain + (wrap2 - L1000)
2019-04-20 22:54:40 +00:00
inc L2095
inc L2099
2019-12-09 02:16:21 +00:00
bne :+
2019-04-21 03:33:26 +00:00
2019-12-09 02:16:21 +00:00
init_80_col:
jsr SLOT3_FIRMWARE
:
2019-04-21 03:33:26 +00:00
;; --------------------------------------------------
2019-04-21 03:33:26 +00:00
;; Copy to $1000
2019-12-09 02:16:21 +00:00
.proc RelocateChainingCode
ldy #0
2019-04-21 03:33:26 +00:00
;; End signature is two adjacent $FFs
2019-12-09 02:16:21 +00:00
loop:
2019-04-20 22:54:40 +00:00
L2072 := * + 2
lda L239E,y
cmp #$FF
bne L207E
2019-04-21 03:33:26 +00:00
2019-04-20 22:54:40 +00:00
L2079 := * + 2
2019-04-21 03:33:26 +00:00
ldx L239E+1,y
2019-04-20 22:54:40 +00:00
cpx #$FF
beq L208F
L207E:
L2080 := * + 2
sta L1000,y
iny
2019-12-09 02:16:21 +00:00
bne loop
2019-04-21 03:33:26 +00:00
2019-04-20 22:54:40 +00:00
inc L2072
inc L2079
inc L2080
2019-04-21 03:33:26 +00:00
2019-12-09 02:16:21 +00:00
bne loop ; always
.endproc
L208F: ldy #MessageCode::kInstall
jsr ShowMessage
2019-04-21 03:33:26 +00:00
2019-04-20 22:54:40 +00:00
L2095 := * + 1
ldy #$03
sty $22
L2099 := * + 1
ldy #$05
sty $23
jsr L116E
lda $1204
lsr a
sta L22C7
jsr L222B
2019-12-09 02:16:21 +00:00
sta year
ldx DEVCNT
L20AF: lda DEVLST,x
2019-04-20 22:54:40 +00:00
and #$0F
beq L20C8
dex
bpl L20AF
lda L2001
and #$07
bne L20C2
lda #$06
L20C2: asl a
asl a
asl a
asl a
bne L20CB
2019-12-09 00:18:50 +00:00
kPatchLength = $38
kPatch1Offset = $0
kPatch2Offset = $38
kPatch3Offset = $70
L20C8: lda DEVLST,x
L20CB: and #%01110000 ; slot
2019-04-20 22:54:40 +00:00
ora #$80
sta L22E3 ; Set $C0nn address
2019-04-21 19:20:19 +00:00
lda L11FE
2019-04-20 22:54:40 +00:00
and #$03
beq L20E3
cmp #$02
bcs L20FE
lda $07
bne L20EE
beq L20FE
2019-12-09 00:18:50 +00:00
L20E3: ldy #kPatch2Offset
2019-04-20 22:54:40 +00:00
lda $07
2019-12-09 00:18:50 +00:00
beq apply_patch
ldy #kPatch1Offset
jmp apply_patch
2019-04-20 22:54:40 +00:00
2019-04-21 19:20:19 +00:00
;; Patch bytes on top of driver
2019-12-09 00:18:50 +00:00
L20EE: ldy #kPatch3Offset
apply_patch:
ldx #$00
: lda Patches,y
2019-04-20 22:54:40 +00:00
sta L2269,x
iny
inx
2019-12-09 02:16:21 +00:00
cpx #kPatchLength
2019-12-09 00:18:50 +00:00
bne :-
2019-04-21 19:20:19 +00:00
2019-04-20 22:54:40 +00:00
L20FE: lda #$02
sta L210F
L2103: jsr L223F
bcs L2111
dec L210F
bpl L2103
bmi L2156
2019-12-09 02:16:21 +00:00
L210F: .byte 0
L2110: .byte 0
2019-04-20 22:54:40 +00:00
L2111: lda $07
bne L2135
lda L2110
bne L2135
inc L2110
ldy #$99
sty L228A
iny
sty L226A
sty L2274
2019-04-21 19:20:19 +00:00
lda L11FE
2019-04-20 22:54:40 +00:00
and #$03
beq L20FE
sty L229F
bne L20FE
2019-12-09 02:16:21 +00:00
L2135: ldy #MessageCode::kNoClock
2019-04-20 22:54:40 +00:00
sty $0B
2019-12-09 02:16:21 +00:00
lda MACHID ; Check for clock card
2019-04-20 22:54:40 +00:00
ror a
2019-12-09 02:16:21 +00:00
bcc no_clock ; Bit 0 = 0 means no clock card
2019-04-20 23:58:58 +00:00
jsr MON_HOME
2019-04-20 22:54:40 +00:00
jmp L1000
2019-12-09 02:16:21 +00:00
no_clock:
lda #0
sta DATELO
sta DATELO+1
sta TIMELO
sta TIMELO+1
2019-12-09 02:16:21 +00:00
jmp ShowMessageAndMaybeChain
;; --------------------------------------------------
2019-04-20 22:54:40 +00:00
2019-04-20 23:58:58 +00:00
L2156: lda #OPC_JMP_abs
sta DATETIME
lda MACHID
ora #%00000001 ; has clock
sta MACHID
bit KBD
2019-04-20 22:54:40 +00:00
bmi L218C
lda $0A
cmp #$0B
bcc L2176
2019-04-21 19:20:19 +00:00
bit L11FE
2019-04-20 22:54:40 +00:00
bpl L2176
sta $1204
L2176: lda $1204
lsr a
cmp #$56
bcc L218C
lda DATELO
2019-04-20 22:54:40 +00:00
cmp $1203
lda DATELO+1
2019-04-20 22:54:40 +00:00
sbc $1204
bcs L21DF
L218C: bit KBDSTRB
2019-04-21 19:20:19 +00:00
rol L11FE
2019-04-20 22:54:40 +00:00
lda #$03
cmp $0A
2019-04-21 19:20:19 +00:00
ror L11FE
2019-12-09 02:16:21 +00:00
;; Show current year prompt
L2199: ldy #MessageCode::kCurrentYear
jsr ShowMessage
lda year ; 2-digit year
2019-04-20 23:58:58 +00:00
jsr PRBYTE
2019-12-09 02:16:21 +00:00
ldy #MessageCode::kOkPrompt
jsr ShowMessage
;; Wait for keypress
: jsr RDKEY
and #%11011111 ; lowercase --> uppercase
cmp #'Y'|$80
2019-04-20 22:54:40 +00:00
beq L21D3
2019-12-09 02:16:21 +00:00
cmp #'N'|$80
bne :-
;; Prompt for two digit year
ldy #MessageCode::kCurrentYear
jsr ShowMessage
jsr GetDigitKey ; Decade
2019-04-20 22:54:40 +00:00
asl a
asl a
asl a
asl a
2019-12-09 02:16:21 +00:00
sta year
jsr GetDigitKey ; Year
2019-04-20 22:54:40 +00:00
and #$0F
2019-12-09 02:16:21 +00:00
ora year
sta year
2019-04-20 22:54:40 +00:00
jmp L2199
2019-12-09 02:16:21 +00:00
;; Current year is okay
2019-04-20 22:54:40 +00:00
L21D3: lda $1204
jsr L2210
jsr L238A
jsr L111A
L21DF: lda RWRAM1
lda RWRAM1
lda DATETIME+1
2019-12-09 00:18:50 +00:00
sta install_ptr
2019-04-20 22:54:40 +00:00
clc
adc #$76
sta L22B1
lda DATETIME+2
2019-12-09 00:18:50 +00:00
sta install_ptr+1
2019-04-21 19:20:19 +00:00
adc #0
2019-04-20 22:54:40 +00:00
sta L22B2
;; Relocate clock driver
2019-12-09 00:18:50 +00:00
ldy #kClockRoutineMaxLength - 1
: lda Driver,y
install_ptr := * + 1
2019-04-20 22:54:40 +00:00
sta $F000,y
dey
2019-12-09 00:18:50 +00:00
bpl :-
;; Initialize the time (via driver)
2019-04-20 23:58:58 +00:00
jsr DATETIME
lda ROMIN2
2019-12-09 00:18:50 +00:00
;; Chain
2019-04-20 22:54:40 +00:00
jmp L1000
2019-12-09 02:16:21 +00:00
L2210: lda year
2019-04-20 22:54:40 +00:00
pha
lsr a
lsr a
lsr a
lsr a
sta $06
asl a
asl a
adc $06
asl a
sta $06
pla
and #$0F
clc
adc $06
sta L22C7
rts
L222B: ldx #$FF
L222D: inx
sec
sbc #$0A
bcs L222D
adc #$0A
sta $06
txa
asl a
asl a
asl a
asl a
ora $06
rts
L223F: jsr L238A
lda DATELO+1
2019-04-20 22:54:40 +00:00
ror a
lda DATELO
2019-04-20 22:54:40 +00:00
rol a
rol a
rol a
rol a
and #$0F
sec
beq L2264
cmp #$0D
bcs L2264
sta $0A
lda TIMELO+1
2019-04-20 22:54:40 +00:00
cmp #$18
bcs L2264
lda TIMELO
2019-04-20 22:54:40 +00:00
cmp #$3C
L2264: rts
;;; ============================================================
;;; Clock Driver (Relocatable)
;;; ============================================================
2019-12-09 00:18:50 +00:00
Driver: cld
cld ; TODO: Remove duplicate CLD
2019-04-20 22:54:40 +00:00
php
sei
L2269:
L226A := * + 1
lda PORT2_ACIA_COMMAND
2019-12-09 02:16:21 +00:00
pha ; Save command register
2019-04-20 22:54:40 +00:00
ldy #$03
ldx #$16
2019-12-09 02:16:21 +00:00
lda #%00001000
2019-04-20 22:54:40 +00:00
L2273:
L2274 := * + 1
sta PORT2_ACIA_COMMAND
2019-04-20 22:54:40 +00:00
L2276: dex
bne L2276
eor #$0A
ldx #$09
dey
bne L2273
ldy #$04
bne L2289
L2284:
L2285 := * + 1
lda #$5D
2019-12-09 02:16:21 +00:00
L2286: dec ; 65C02
2019-04-20 22:54:40 +00:00
bne L2286
L2289:
L228A := * + 1
lda PORT2_ACIA_STATUS
2019-04-20 22:54:40 +00:00
rol a
rol a
rol a
ror $0200,x
lsr $0201,x
dey
bne L2284
ldy #$04
dex
bpl L2284
2019-12-09 02:16:21 +00:00
pla ; Restore command register
2019-04-20 22:54:40 +00:00
L229F := * + 1
sta PORT2_ACIA_COMMAND
2019-04-20 22:54:40 +00:00
ldx #$06
2019-12-09 00:18:50 +00:00
2019-04-20 22:54:40 +00:00
L22A3: lda $0201,x
2019-12-09 00:18:50 +00:00
: dec $0200,x
2019-04-20 22:54:40 +00:00
bmi L22B0
clc
2019-12-09 00:18:50 +00:00
adc #10
bcc :-
2019-04-20 22:54:40 +00:00
L22B0:
L22B1 := * + 1
L22B2 := * + 2
ldy L22DB,x
sta $BF30,y ; Modifying DEVLST ???
2019-04-20 22:54:40 +00:00
dex
dex
bne L22A3
2019-12-09 00:18:50 +00:00
2019-04-20 22:54:40 +00:00
L22BA: lda $0200
asl a
and #$E0
ora DATELO
sta DATELO
2019-04-20 22:54:40 +00:00
L22C7 := * + 1
lda #$56
rol a
sta DATELO+1
2019-04-20 22:54:40 +00:00
ldy #$01
L22CE: lda $0208,y
ora #$B0
sta $020F,y
dey
bpl L22CE
dex
L22DB := * + 1
bne L22BA
plp
rts
.byte $FF
.byte $63
.byte $FF
.byte $62
2019-04-21 19:20:19 +00:00
;; End of relocated clock driver
;;; ============================================================
;; Patches applied to driver (length $38, at offset 0)
2019-12-09 00:18:50 +00:00
Patches:
2019-04-21 19:20:19 +00:00
;; Patch #1
patch1:
2019-04-20 22:54:40 +00:00
L22E3 := * + 1
lda $C0E0 ; Set to $C0x0, n=slot+8
lda DISVBL
2019-04-20 22:54:40 +00:00
ldy #$01
ldx #$16
L22EC: dex
bne L22EC
lda DISVBL,y
2019-04-20 22:54:40 +00:00
ldx #$0B
dey
bpl L22EC
L22F7: dex
bne L22F7
ldx #$09
ldy #$04
bne L2307
L2300: lda #$5D
sec
L2303: sbc #$01
bne L2303
L2307: lda MOUSE_BTN
2019-04-20 22:54:40 +00:00
rol a
ror $0200,x
lsr $0201,x
nop
dey
bne L2300
ldy #$04
dex
bpl L2300
2019-12-09 00:18:50 +00:00
.assert * - patch1 = kPatchLength, error, "Patch length"
2019-04-21 19:20:19 +00:00
;; --------------------------------------------------
;; Patch #2
patch2:
2019-12-09 00:18:50 +00:00
.assert * = Patches + kPatch2Offset, error, "Offset changed"
2019-04-21 19:20:19 +00:00
lda PORT2_ACIA_COMMAND
2019-04-20 22:54:40 +00:00
nop
ldy #$03
ldx #$16
2019-12-09 02:16:21 +00:00
lda #%00000010
L2324: sta PORT2_ACIA_COMMAND
2019-04-20 22:54:40 +00:00
L2327: dex
bne L2327
eor #$0A
ldx #$09
dey
bne L2324
ldy #$04
bne L233A
L2335:
L2336 := * + 1
lda #$5D
2019-12-09 02:16:21 +00:00
L2337: dec ; 65C02
2019-04-20 22:54:40 +00:00
bne L2337
L233A: lda PORT2_ACIA_STATUS
2019-04-20 22:54:40 +00:00
eor #$20
rol a
rol a
rol a
ror $0200,x
lsr $0201,x
dey
bne L2335
ldy #$04
dex
bpl L2335
2019-04-21 19:20:19 +00:00
2019-04-20 22:54:40 +00:00
nop
nop
2019-04-21 19:20:19 +00:00
2019-12-09 00:18:50 +00:00
.assert * - patch2 = kPatchLength, error, "Patch length"
2019-04-21 19:20:19 +00:00
;; --------------------------------------------------
;; Patch #3
patch3:
2019-12-09 00:18:50 +00:00
.assert * = Patches + kPatch3Offset, error, "Offset changed"
2019-04-21 19:20:19 +00:00
lda ENVBL
sta ENBXY
sta X0EDGE1
2019-04-20 22:54:40 +00:00
nop
nop
nop
nop
lda DISXY
2019-04-20 22:54:40 +00:00
ldx #$15
L2364: dex
bne L2364
ldx #$09
L2369: ldy #$04
L236B: lda MOUSE_BTN
2019-04-20 22:54:40 +00:00
rol a
ror $0200,x
lsr $0201,x
sta X0EDGE2
2019-04-20 22:54:40 +00:00
nop
nop
nop
nop
nop
nop
sta X0EDGE1
2019-04-20 22:54:40 +00:00
dey
bne L236B
dex
bpl L2369
lda DISVBL
2019-12-09 00:18:50 +00:00
.assert * - patch3 = kPatchLength, error, "Patch length"
2019-04-21 19:20:19 +00:00
;;; ============================================================
2019-12-09 00:18:50 +00:00
L238A: jsr Driver
2019-04-20 22:54:40 +00:00
rts
2019-12-09 02:16:21 +00:00
;;; ------------------------------------------------------------
;;; Prompt, loop until digit key is pressed
.proc GetDigitKey
jsr RDKEY
2019-04-21 19:20:19 +00:00
cmp #'0' | $80
2019-12-09 02:16:21 +00:00
bcc GetDigitKey
2019-04-21 19:20:19 +00:00
cmp #('9'+1) | $80
2019-12-09 02:16:21 +00:00
bcs GetDigitKey
2019-04-20 23:58:58 +00:00
jmp COUT
2019-12-09 02:16:21 +00:00
.endproc
;;; ------------------------------------------------------------
2019-04-20 22:54:40 +00:00
L239C: .byte $DF
.byte $FF
2019-04-21 03:33:26 +00:00
chain:
2019-04-20 22:54:40 +00:00
L239E:
2019-04-21 03:33:26 +00:00
;; Relocated to $1000
;;; ============================================================
;;; Chaining code???
;;; ============================================================
.org $1000
L1000:
2019-04-20 22:54:40 +00:00
ldy #$00
2019-04-21 19:20:19 +00:00
sty L11E8
2019-04-20 22:54:40 +00:00
iny
sty $04
iny
2019-04-21 19:20:19 +00:00
sty L11E7
2019-04-20 22:54:40 +00:00
jsr L119F
lda $1C23
sta $02
lda $1C24
sta $03
lda #$2B
sta $00
lda #$1C
sta $01
2019-04-21 03:33:26 +00:00
L1021: ldy #$10
2019-04-20 22:54:40 +00:00
lda ($00),y
cmp #$FF
2019-04-21 03:33:26 +00:00
bne L10A8
2019-04-20 22:54:40 +00:00
ldy #$00
lda ($00),y
and #$30
2019-04-21 03:33:26 +00:00
beq L10A8
2019-04-20 22:54:40 +00:00
lda ($00),y
and #$0F
sta $05
tay
2019-04-21 19:20:19 +00:00
ldx #strlen_str_system - 1
2019-04-21 03:33:26 +00:00
L103A: lda ($00),y
2019-04-21 19:20:19 +00:00
cmp str_system,x
2019-04-21 03:33:26 +00:00
bne L10A8
2019-04-20 22:54:40 +00:00
dey
dex
2019-04-21 03:33:26 +00:00
bpl L103A
2019-04-21 19:20:19 +00:00
ldy #strlen_str_clock_system
2019-04-21 03:33:26 +00:00
L1047: lda ($00),y
2019-04-21 19:20:19 +00:00
cmp str_clock_system,y
2019-04-21 03:33:26 +00:00
bne L1053
2019-04-20 22:54:40 +00:00
dey
2019-04-21 03:33:26 +00:00
bne L1047
beq L10A8
L1053: lda $05
2019-04-20 22:54:40 +00:00
sta $121D
sta $0280
inc $05
lda $0B
cmp #$07
2019-04-21 03:33:26 +00:00
beq L1070
2019-04-20 22:54:40 +00:00
ldy #$03
jsr L10E5
lda $07
2019-04-21 03:33:26 +00:00
beq L106D
2019-04-20 22:54:40 +00:00
iny
2019-12-09 02:16:21 +00:00
L106D: jsr ShowMessage
L1070: ldy #MessageCode::kRunning
jsr ShowMessage
2019-04-20 22:54:40 +00:00
ldy #$01
2019-04-21 03:33:26 +00:00
L1077: lda ($00),y
2019-04-20 22:54:40 +00:00
sta $121D,y
sta $0280,y
ora #$80
2019-04-20 23:58:58 +00:00
jsr COUT
2019-04-20 22:54:40 +00:00
iny
cpy $05
2019-04-21 03:33:26 +00:00
bne L1077
2019-04-20 22:54:40 +00:00
jsr L114F
lda #$00
sta WNDTOP
2019-04-20 22:54:40 +00:00
lda #$18
sta WNDBTM
2019-04-20 23:58:58 +00:00
jsr MON_HOME
2019-04-20 22:54:40 +00:00
lda $09
2019-04-21 03:33:26 +00:00
beq L10A5
2019-04-20 22:54:40 +00:00
lda #$15
2019-04-20 23:58:58 +00:00
jsr COUT
2019-04-20 22:54:40 +00:00
lda #$8D
2019-04-20 23:58:58 +00:00
jsr COUT
2019-04-21 03:33:26 +00:00
L10A5: jmp L2000
2019-04-20 22:54:40 +00:00
2019-04-21 03:33:26 +00:00
L10A8: clc
2019-04-20 22:54:40 +00:00
lda $00
adc $02
sta $00
lda $01
adc #$00
sta $01
inc $04
lda $04
cmp $03
2019-04-21 03:33:26 +00:00
bne L10E2
2019-04-20 22:54:40 +00:00
ldy $1C02
2019-04-21 19:20:19 +00:00
sty L11E7
2019-04-20 22:54:40 +00:00
lda $1C03
2019-04-21 19:20:19 +00:00
sta L11E8
2019-12-09 02:16:21 +00:00
bne :+
2019-04-20 22:54:40 +00:00
tya
2019-12-09 02:16:21 +00:00
bne :+
ldy #MessageCode::kNoSysFile
jmp ShowMessageAndMaybeChain
2019-04-20 22:54:40 +00:00
2019-12-09 02:16:21 +00:00
: jsr L119F
2019-04-20 22:54:40 +00:00
lda #$00
sta $04
lda #$04
sta $00
lda #$1C
sta $01
2019-04-21 03:33:26 +00:00
L10E2: jmp L1021
2019-04-20 22:54:40 +00:00
2019-04-21 19:20:19 +00:00
L10E5: lda L11FE
2019-04-20 22:54:40 +00:00
and #$03
2019-04-21 03:33:26 +00:00
bne L10EE
2019-04-20 22:54:40 +00:00
ldy #$09
2019-04-21 03:33:26 +00:00
L10EE: rts
2019-04-20 22:54:40 +00:00
2019-12-09 02:16:21 +00:00
;;; ------------------------------------------------------------
;;; Call with message number in Y
.proc ShowMessage
lda message_table_lo,y
2019-04-21 19:20:19 +00:00
sta L1109
2019-12-09 02:16:21 +00:00
lda message_table_hi,y
2019-04-21 19:20:19 +00:00
sta L1109+1
2019-04-20 22:54:40 +00:00
cpy #$06
2019-04-21 03:33:26 +00:00
beq L1106
2019-04-20 22:54:40 +00:00
cpy #$08
2019-04-21 03:33:26 +00:00
beq L1106
2019-04-20 23:58:58 +00:00
jsr MON_HOME
2019-04-21 03:33:26 +00:00
L1106: ldy #$00
2019-04-21 19:20:19 +00:00
L1109 := *+1
2019-04-21 03:33:26 +00:00
L1108: lda $F000,y
beq L1119
2019-04-20 22:54:40 +00:00
cmp #$E0
2019-04-21 03:33:26 +00:00
bcc L1113
2019-04-20 22:54:40 +00:00
and $08
2019-04-21 03:33:26 +00:00
L1113: jsr COUT
2019-04-20 22:54:40 +00:00
iny
2019-04-21 03:33:26 +00:00
bne L1108
L1119: rts
2019-12-09 02:16:21 +00:00
.endproc
;;; ------------------------------------------------------------
2019-04-20 22:54:40 +00:00
2019-04-21 03:33:26 +00:00
L111A: lda #$07
2019-04-21 19:20:19 +00:00
sta L11F9
2019-04-20 22:54:40 +00:00
ldy #$03
2019-04-21 03:33:26 +00:00
L1121: lda DATELO,y
2019-04-20 22:54:40 +00:00
sta $1203,y
dey
2019-04-21 03:33:26 +00:00
bpl L1121
2019-04-20 23:58:58 +00:00
lda #OPC_RTS
sta DATETIME
2019-04-21 19:20:19 +00:00
PRODOS_CALL MLI_SET_FILE_INFO, L11F9
bne :+
2019-04-20 22:54:40 +00:00
lda #OPC_JMP_abs
sta DATETIME
2019-04-20 22:54:40 +00:00
rts
: cmp #$2B
2019-12-09 02:16:21 +00:00
bne ShowDiskErrorAndChain
ldy #MessageCode::kRemoveWriteProtect
jsr ShowMessage
2019-04-20 22:54:40 +00:00
jsr L11C3
2019-04-20 23:58:58 +00:00
jsr RDKEY
2019-04-20 22:54:40 +00:00
jmp L111A
2019-04-21 03:33:26 +00:00
L114F: PRODOS_CALL MLI_OPEN, $11E9
2019-12-09 02:16:21 +00:00
bne ShowDiskErrorAndChain
2019-04-21 19:20:19 +00:00
lda L11EE
sta L11F0
2019-04-21 00:03:10 +00:00
PRODOS_CALL MLI_READ, $11EF
2019-12-09 02:16:21 +00:00
bne ShowDiskErrorAndChain
2019-04-21 00:03:10 +00:00
PRODOS_CALL MLI_CLOSE, $11F7
2019-12-09 02:16:21 +00:00
bne ShowDiskErrorAndChain
2019-04-20 22:54:40 +00:00
rts
2019-04-21 03:33:26 +00:00
L116E: lda DEVNUM
2019-04-21 19:20:19 +00:00
sta L11DD
sta L11E4
2019-04-21 00:03:10 +00:00
PRODOS_CALL MLI_ON_LINE, $11DC
2019-12-09 02:16:21 +00:00
bne ShowDiskErrorAndChain
lda $120C
2019-04-20 22:54:40 +00:00
and #$0F
tay
iny
sty $120B
lda #'/'
2019-04-20 22:54:40 +00:00
sta $120C
2019-04-21 00:03:10 +00:00
PRODOS_CALL MLI_SET_PREFIX, $11E0
2019-12-09 02:16:21 +00:00
bne ShowDiskErrorAndChain
2019-04-21 00:03:10 +00:00
2019-04-21 19:20:19 +00:00
PRODOS_CALL MLI_GET_FILE_INFO, L11F9
2019-12-09 02:16:21 +00:00
bne ShowDiskErrorAndChain
rts
2019-04-21 03:33:26 +00:00
L119F: PRODOS_CALL MLI_READ_BLOCK, $11E3
2019-12-09 02:16:21 +00:00
bne ShowDiskErrorAndChain
2019-04-20 22:54:40 +00:00
rts
2019-12-09 02:16:21 +00:00
;;; ------------------------------------------------------------
.proc ShowDiskErrorAndChain
ldy #MessageCode::kDiskError
;; fall through
.endproc
;;; Show message and chain to next system file, unless
;;; kNoClock (in which case: hang)
.proc ShowMessageAndMaybeChain
sty $0B
jsr ShowMessage
2019-04-20 22:54:40 +00:00
jsr L11C3
lda $0B
2019-12-09 02:16:21 +00:00
cmp #MessageCode::kNoClock
bne loop
2019-04-20 23:58:58 +00:00
lda #OPC_RTS
sta DATETIME
2019-04-20 22:54:40 +00:00
jmp L1000
2019-12-09 02:16:21 +00:00
loop: jmp loop ; Infinite loop!
.endproc
;;; ------------------------------------------------------------
2019-04-20 22:54:40 +00:00
2019-04-21 03:33:26 +00:00
L11C3: lda #$20
2019-04-20 22:54:40 +00:00
sta $0C
2019-04-21 03:33:26 +00:00
L11C7: lda #$02
2019-04-20 23:58:58 +00:00
jsr WAIT
sta SPKR
2019-04-20 22:54:40 +00:00
lda #$24
2019-04-20 23:58:58 +00:00
jsr WAIT
sta SPKR
2019-04-20 22:54:40 +00:00
dec $0C
2019-04-21 03:33:26 +00:00
bne L11C7
2019-04-20 22:54:40 +00:00
rts
2019-12-09 02:16:21 +00:00
;; MLI call params
2019-04-20 22:54:40 +00:00
.byte $02
2019-04-21 19:20:19 +00:00
L11DD: .byte $60
2019-04-20 22:54:40 +00:00
.byte $0C
.byte $12
2019-04-21 19:20:19 +00:00
.byte $01,$0B
.byte $12,$03
L11E4: .byte $60
.byte $00,$1C
L11E7: .byte $00
L11E8: .byte $00
.byte $03
.byte $1D,$12,$00,$1C
L11EE: .byte $00
.byte $04
L11F0: .byte $00
.byte $00
.byte $20,$00,$9F,$00,$00,$01,$00
L11F9: .byte $0A
2019-04-20 23:33:27 +00:00
.byte $35,$12
2019-04-20 22:54:40 +00:00
2019-04-21 19:20:19 +00:00
L11FC: .byte 0
L11FD: .byte 0
L11FE: .byte 0
2019-12-09 02:16:21 +00:00
year: .byte 0 ; 2-digit
2019-04-21 19:20:19 +00:00
.res 46, 0
2019-04-20 23:08:35 +00:00
2019-04-21 19:20:19 +00:00
str_system:
2019-04-20 23:08:35 +00:00
.byte ".SYSTEM"
2019-04-21 19:20:19 +00:00
strlen_str_system = .strlen(".SYSTEM")
2019-04-20 23:08:35 +00:00
2019-04-21 19:20:19 +00:00
str_clock_system:
2019-04-20 23:33:27 +00:00
PASCAL_STRING "CLOCK.SYSTEM"
2019-04-21 19:20:19 +00:00
strlen_str_clock_system = .strlen("CLOCK.SYSTEM")
2019-04-20 23:08:35 +00:00
2019-12-09 02:16:21 +00:00
message_table_lo:
.byte <msgInstall,<msgNoSysFile,<msgDiskError,<msgIIc
.byte <msgIIe,<msgCurrentYear,<msgOkPrompt,<msgNoClock
.byte <msgRunning,<msgSeikoIIc,<msgSeikoIIe,<msgRemoveWriteProtect
2019-04-20 23:33:27 +00:00
2019-12-09 02:16:21 +00:00
message_table_hi:
.byte >msgInstall,>msgNoSysFile,>msgDiskError,>msgIIc
.byte >msgIIe,>msgCurrentYear,>msgOkPrompt,>msgNoClock
.byte >msgRunning,>msgSeikoIIc,>msgSeikoIIe,>msgRemoveWriteProtect
2019-04-21 03:33:26 +00:00
2019-12-09 02:16:21 +00:00
msgInstall:
HIASCII "Install Clock Driver 1.5"
L1272: HIASCII " " ; Modified at launch
HIASCII "\rCopyright (c) 1986 "
wrap1 := *-1
HIASCIIZ "Creative Peripherals Unlimited, Inc."
2019-12-09 02:16:21 +00:00
msgNoSysFile:
2019-04-20 23:33:27 +00:00
HIASCIIZ "Unable to find a '.SYSTEM' file!"
2019-12-09 02:16:21 +00:00
msgRemoveWriteProtect:
HIASCII "Remove Write-Protect tab, "
wrap2 := *-1
HIASCIIZ "Replace disk, and Press a key..."
2019-12-09 02:16:21 +00:00
msgDiskError:
2019-04-20 23:33:27 +00:00
HIASCIIZ "Disk error! Unable to continue!!!"
2019-12-09 02:16:21 +00:00
msgSeikoIIc:
HIASCII "Seiko "
msgIIc: HIASCIIZ "//c driver installed. "
wrap4 := *-2
2019-12-09 02:16:21 +00:00
msgSeikoIIe:
HIASCII "Seiko "
msgIIe: HIASCIIZ "//e driver installed. "
wrap5 := *-2
2019-12-09 02:16:21 +00:00
msgCurrentYear:
HIASCIIZ "Current year is 19"
msgOkPrompt:
HIASCII "."
wrap3 := *
HIASCIIZ " OK? (Y/N) "
2019-12-09 02:16:21 +00:00
msgNoClock:
2019-04-20 23:33:27 +00:00
HIASCIIZ "No clock! Driver not installed...\r"
2019-12-09 02:16:21 +00:00
msgRunning:
2019-04-20 23:33:27 +00:00
HIASCIIZ "Running "
2019-04-21 03:33:26 +00:00
;; Signature for end of range to copy to $1000
.byte $FF,$FF
;;; ============================================================
.byte $00,$04,$00
2019-04-20 23:33:27 +00:00
.byte $FF,$00,$FF,$00,$FF,$00,$00,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$00
.byte $FF,$00,$FF,$00,$FF,$00,$FF,$65
.byte $00,$FF,$00,$FF,$00,$FF,$00,$FF
.byte $00,$FF,$00,$FF,$00,$FF,$00,$FF
.byte $00,$FF,$00,$FF,$00,$FF,$00,$FF
.byte $00