A2osX/SYS/KM.NSC.S.txt

305 lines
5.2 KiB
Plaintext
Raw Normal View History

2015-03-13 15:40:32 +00:00
PR#3
PREFIX /A2OSX.BUILD
2015-03-13 15:40:32 +00:00
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BUILD/SYS/KM.NSC
2015-03-13 15:40:32 +00:00
*--------------------------------------
.INB /A2OSX.BUILD/INC/MACROS.I
.INB /A2OSX.BUILD/INC/IO.I
.INB /A2OSX.BUILD/INC/MONITOR.I
.INB /A2OSX.BUILD/INC/PRODOS.I
2015-03-13 15:40:32 +00:00
*--------------------------------------
TmpPtr1 .EQ $0
TmpPtr2 .EQ $2
*--------------------------------------
2018-07-12 15:20:39 +00:00
NSC.Init >LDYAI NSC.MSG0
2015-03-13 15:40:32 +00:00
jsr NSC.Print
lda MACHID
and #MACHID.CLK Clock already installed ?
beq .1
2018-07-12 15:20:39 +00:00
>LDYAI NSC.MSG1
2015-03-13 15:40:32 +00:00
jsr NSC.Print
rts
.1 jsr NSC.Detect
bcc .2
2018-07-12 15:20:39 +00:00
>LDYAI NSC.MSG2
2015-03-13 15:40:32 +00:00
jsr NSC.Print
rts
.2 jsr NSC.Install
lda MACHID
ora #MACHID.CLK
sta MACHID
2018-07-12 15:20:39 +00:00
>LDYAI NSC.MSG3
2015-03-13 15:40:32 +00:00
jsr NSC.Print
rts
*--------------------------------------
NSC.Detect php
sei
2016-02-21 20:42:55 +00:00
lda $CFFF
pha
sta $C300
2015-03-13 15:40:32 +00:00
ldx #7
.1 ldy #8
.2 lda $C304
lsr
ror DS1216E.DATA1,x
dey
bne .2
dex
bpl .1
lda $C304 Reset DS1216E comparison register with READ A2=1
ldx #7 Read 8 bytes...
.3 lda DS1216E.PATTERN,x
phx
ldx #8 ....of 8 bits
.4 ldy #0
lsr
bcc .5
iny
2016-02-21 20:42:55 +00:00
.5 pha
lda $C300,y Write Pattern bit in A0, with A2=0
pla
2015-03-13 15:40:32 +00:00
dex
bne .4
plx
dex
bpl .3
ldx #7
.6 ldy #8
.7 lda $C304
lsr
ror DS1216E.DATA2,x
dey
bne .7
dex
bpl .6
2016-02-21 20:42:55 +00:00
pla
bmi .8
sta $CFFF
.8 plp
2015-03-13 15:40:32 +00:00
ldx #7
2016-02-21 20:42:55 +00:00
.81 lda DS1216E.DATA1,x
2015-03-13 15:40:32 +00:00
cmp DS1216E.DATA2,x
bne .9
dex
2016-02-21 20:42:55 +00:00
bpl .81
2015-03-13 15:40:32 +00:00
sec
rts
2016-02-21 20:42:55 +00:00
.9 clc
2015-03-13 15:40:32 +00:00
rts
*--------------------------------------
DS1216E.DATA1 .BS 8
DS1216E.DATA2 .BS 8
*--------------------------------------
NSC.Install lda DATETIME+1
sta TmpPtr1
sec
sbc #NSCDRV.B.START
sta NSCDRV.OFFSET
lda DATETIME+2
sta TmpPtr1+1
sbc /NSCDRV.B.START
sta NSCDRV.OFFSET+1
ldy #1
ldx #0
.1 lda NSCDRV.RELOC,x
beq .2
sta TmpPtr2
inx
lda NSCDRV.RELOC,x
sta TmpPtr2+1
lda (TmpPtr2)
clc
adc NSCDRV.OFFSET
sta (TmpPtr2)
lda (TmpPtr2),y
adc NSCDRV.OFFSET+1
sta (TmpPtr2),y
inx
bne .1
.2 lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
.3 ldy #0
.7 lda NSCDRV.B.START,y
sta (TmpPtr1),y
iny
cpy #NSCDRV.SIZE
bne .7
lda RROMBNK1
lda #$4C
sta DATETIME
rts
*--------------------------------------
NSCDRV.OFFSET .BS 2
NSCDRV.RELOC .DA NSCDRV.R1+1
.DA NSCDRV.R2+1
.DA NSCDRV.R3+1
.DA NSCDRV.R4+1
.DA NSCDRV.R5+1
.DA NSCDRV.R6+1
.DA NSCDRV.R7+1
.DA NSCDRV.R8+1
.DA NSCDRV.R9+1
.DA 0
*--------------------------------------
NSC.Print sta TmpPtr1
stx TmpPtr1+1
2015-03-13 15:40:32 +00:00
ldy #0
.1 lda (TmpPtr1),y
beq .9
ora #$80
jsr COUT
iny
bne .1
.9 jmp CROUT
*--------------------------------------
NSC.MSG0 .AZ "NSC ('No-Slot-Clock'/DS1216E) Driver For A2osX"
NSC.MSG1 .AZ "A Clock Driver Is Already Installed."
NSC.MSG2 .AZ "DS1216E Chip Not Detected."
NSC.MSG3 .AZ "DS1216E Driver Successfully Installed."
2015-03-13 15:40:32 +00:00
*--------------------------------------
* Driver For DS1216E
*--------------------------------------
NSCDRV.B.START .EQ *
NSCDRV php
sei
sta $CFFF Make cards release $C8xx space
2016-02-21 20:42:55 +00:00
sta $C300
2015-03-13 15:40:32 +00:00
lda $C304 Reset DS1216E comparison register with READ A2=1
2016-02-21 20:42:55 +00:00
ldy #7 Read 8 bytes...
2017-02-22 07:31:16 +00:00
2015-03-13 15:40:32 +00:00
NSCDRV.1
2016-02-21 20:42:55 +00:00
NSCDRV.R1 lda DS1216E.PATTERN,y
phy
ldy #8 ....of 8 bits
2017-02-22 07:31:16 +00:00
2016-02-21 20:42:55 +00:00
NSCDRV.2 ldx #0
2015-03-13 15:40:32 +00:00
lsr
bcc NSCDRV.21
2016-02-21 20:42:55 +00:00
inx
2017-02-22 07:31:16 +00:00
2016-02-21 20:42:55 +00:00
NSCDRV.21 bit $C300,x Write Pattern bit in A0, with A2=0
dey
2015-03-13 15:40:32 +00:00
bne NSCDRV.2
2017-02-22 07:31:16 +00:00
2016-02-21 20:42:55 +00:00
ply
dey
2015-03-13 15:40:32 +00:00
bpl NSCDRV.1
2017-02-22 07:31:16 +00:00
2015-03-13 15:40:32 +00:00
ldx #7
2017-02-22 07:31:16 +00:00
2015-03-13 15:40:32 +00:00
NSCDRV.4 ldy #8
NSCDRV.5 lda $C304 Read Byte...
2017-02-22 07:31:16 +00:00
2015-03-13 15:40:32 +00:00
lsr
NSCDRV.R2 ror DS1216E.DATA,x
2017-02-22 07:31:16 +00:00
2015-03-13 15:40:32 +00:00
dey
bne NSCDRV.5
2017-02-22 07:31:16 +00:00
2015-03-13 15:40:32 +00:00
NSCDRV.R3 lda DS1216E.DATA,x
pha
lsr
lsr
lsr
lsr
tay
pla
and #$0F
clc
.HS 2C Bit Absolute to skip adc #$0A
NSCDRV.6 adc #$0A
dey
bpl NSCDRV.6
NSCDRV.R4 sta DS1216E.DATA,x
dex
bpl NSCDRV.4
NSCDRV.R5 lda DS1216E.DATA+4 Get HH
sta TIMELO+1
NSCDRV.R6 lda DS1216E.DATA+5 Get mm
sta TIMELO
NSCDRV.R7 lda DS1216E.DATA+1 Get MM
asl
2017-02-22 07:31:16 +00:00
asl
2015-03-13 15:40:32 +00:00
asl
asl
asl
NSCDRV.R8 ora DS1216E.DATA+2 Get DD
sta DATELO
NSCDRV.R9 lda DS1216E.DATA Get YY
rol
sta DATELO+1
2017-02-22 07:31:16 +00:00
plp
2015-03-13 15:40:32 +00:00
rts
*--------------------------------------
DS1216E.PATTERN .HS 5CA33AC55CA33AC5 Reverted 7->0
DS1216E.DATA .BS 8 Reverted YY MM DD Day HH mm SS CS
2015-03-13 15:40:32 +00:00
*--------------------------------------
.LIST ON
NSCDRV.SIZE .EQ *-NSCDRV.B.START
.LIST OFF
2015-03-13 15:40:32 +00:00
*--------------------------------------
* CONTROL SECTION :
*--------------------------------------
.DO NSCDRV.SIZE>125
* ERROR:NSCDRV.SIZE too big
2015-03-13 15:40:32 +00:00
.FIN
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KM.NSC.S
2015-03-13 15:40:32 +00:00
ASM