1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-28 15:31:18 +00:00

Changed chip register names, fixed a bug

git-svn-id: svn://svn.cc65.org/cc65/trunk@2789 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-12-19 23:04:30 +00:00
parent 5c632ab0ef
commit 290de026d1
4 changed files with 149 additions and 132 deletions

View File

@ -231,26 +231,37 @@ Env3 = $1C
; I/O $db00: CIA 6526 Inter Process Communication
;
; IPCcia = $db00
PortA = $00
PortB = $01
DDRA = $02
DDRB = $03
TimALo = $04
TimAHi = $05
TimBLo = $06
TimBHi = $07
TOD10 = $08
TODsec = $09
TODmin = $0A
TODhour = $0B
SerDataReg = $0C
IntCtrReg = $0D
CtrlA = $0E
CtrlB = $0F
.struct CIA
PRA .byte
PRB .byte
DDRA .byte
DDRB .byte
.union
.struct
TALO .byte
TAHI .byte
.endstruct
TA .word
.endunion
.union
.struct
TBLO .byte
TBHI .byte
.endstruct
TB .word
.endunion
TOD10 .byte
TODSEC .byte
TODMIN .byte
TODHR .byte
SDR .byte
ICR .byte
CRA .byte
CRB .byte
.endstruct
; I/O $dc00: CIA 6526
@ -261,7 +272,7 @@ CtrlB = $0F
; I/O $dd00: ACIA 6551
; acia = $dd00
; acia = $dd00
ADataReg = $00
AStatusReg = $01
@ -272,23 +283,28 @@ ACtrlReg = $03
; I/O $de00: Triport #1 6525
; tpi1 = $de00
tpiPortA = $00
tpiPortB = $01
tpiPortC = $02
tpiIntLatch = $02
tpiDDRA = $03
tpiDDRB = $04
tpiDDRC = $05
tpiIntMask = $05
tpiCtrlReg = $06
tpiActIntReg = $07
; tpi1 = $de00
.struct TPI
PRA .byte
PRB .byte
.union
PRC .byte
INT .byte
.endunion
DDRA .byte
DDRB .byte
.union
DDRC .byte
IMR .byte
.endunion
CR .byte
AIR .byte
.endstruct
; I/O $df00: Triport #2 6525
; tpi2 = $df00
; tpi2 = $df00

View File

@ -13,29 +13,28 @@
; -------------------------------------------------------------------------
; Talk senden
; TALK subroutine
TALK: ora #$40
bne talk_listen
; -------------------------------------------------------------------------
; Listen senden
; LISTEN subroutine
LISTEN:
ora #$20
LISTEN: ora #$20
talk_listen:
pha
lda #$3F
ldy #tpiDDRA
ldy #TPI::DDRA
sta (tpi1),y
lda #$FF
ldy #PortA
ldy #CIA::PRA
sta (cia),y
ldy #DDRA
ldy #CIA::DDRA
sta (cia),y
lda #$FA
ldy #tpiPortA
ldy #TPI::PRA
sta (tpi1),y
lda CTemp
bpl LF268
@ -47,82 +46,25 @@ talk_listen:
lda CTemp
and #$7F
sta CTemp
ldy #tpiPortA
ldy #TPI::PRA
lda (tpi1),y
ora #$20
sta (tpi1),y
LF268: lda (tpi1),y ; tpiPortA
LF268: lda (tpi1),y ; TPI::PRA
and #$F7
sta (tpi1),y
pla
jmp transfer_byte
; -------------------------------------------------------------------------
; Output secondary address after listen
SECOND: jsr transfer_byte
scatn: ldy #tpiPortA
lda (tpi1),y
ora #$08
sta (tpi1),y
rts
; -------------------------------------------------------------------------
; Output secondary address
TKSA: jsr transfer_byte
LF283: ldy #tpiPortA
lda (tpi1),y
and #$39
; A -> IEC control, data ready for input
set_listen:
ldy #tpiPortA
sta (tpi1),y
lda #$C7
ldy #tpiDDRA
sta (tpi1),y
lda #$00
ldy #DDRA
sta (cia),y
jmp scatn
; -------------------------------------------------------------------------
CIOUT: pha
lda CTemp
bpl @L1
lda snsw1
jsr transfer_byte
lda CTemp
@L1: ora #$80
sta CTemp
pla
sta snsw1
rts
; -------------------------------------------------------------------------
; UNTLK
UNTLK: lda #$5F
bne LF2B1
UNLSN: lda #$3F
LF2B1: jsr talk_listen
lda #$F9
jmp set_listen
; jmp transfer_byte
; -------------------------------------------------------------------------
; Output A (without EOF flag)
transfer_byte:
eor #$FF
ldy #PortA
ldy #CIA::PRA
sta (cia),y
ldy #tpiPortA
ldy #TPI::PRA
lda (tpi1),y
ora #$12
sta (tpi1),y
@ -144,11 +86,11 @@ LF2DE: jsr SetTimB32ms
bcc LF2E4 ; Branch always
LF2E3: sec
LF2E4: ldy #tpiPortA
LF2E4: ldy #TPI::PRA
lda (tpi1),y
and #$40
bne LF2FC
ldy #IntCtrReg
ldy #CIA::ICR
lda (cia),y
and #$02
beq LF2E4
@ -158,19 +100,78 @@ LF2E4: ldy #tpiPortA
lda #$01
jsr UPDST
LF2FC: ldy #tpiPortA
LF2FC: ldy #TPI::PRA
lda (tpi1),y
ora #$10
sta (tpi1),y
LF304: lda #$FF
ldy #PortA
ldy #CIA::PRA
sta (cia),y
rts
; -------------------------------------------------------------------------
; Output secondary address after listen
ACPTR: ldy #tpiPortA
SECOND: jsr transfer_byte
scatn: ldy #TPI::PRA
lda (tpi1),y
ora #$08
sta (tpi1),y
rts
; -------------------------------------------------------------------------
; Output secondary address
TKSA: jsr transfer_byte
LF283: ldy #TPI::PRA
lda (tpi1),y
and #$39
; A -> IEC control, data ready for input
set_listen:
ldy #TPI::PRA
sta (tpi1),y
lda #$C7
ldy #TPI::DDRA
sta (tpi1),y
lda #$00
ldy #CIA::DDRA
sta (cia),y
jmp scatn
; -------------------------------------------------------------------------
; CIOUT routine
CIOUT: pha
lda CTemp
bpl @L1
lda snsw1
jsr transfer_byte
lda CTemp
@L1: ora #$80
sta CTemp
pla
sta snsw1
rts
; -------------------------------------------------------------------------
; UNTALK/UNLISTEN
UNTLK: lda #$5F
bne LF2B1
UNLSN: lda #$3F
LF2B1: jsr talk_listen
lda #$F9
jmp set_listen
; -------------------------------------------------------------------------
; ACPTR routine
ACPTR: ldy #TPI::PRA
lda (tpi1),y
and #$B9
ora #$81
@ -181,11 +182,11 @@ LF314: jsr SetTimB32ms
LF319: sec
LF31A: ldy #tpiPortA
LF31A: ldy #TPI::PRA
lda (tpi1),y
and #$10
beq LF33F
ldy #IntCtrReg
ldy #CIA::ICR
lda (cia),y
and #$02
beq LF31A ; Loop if not timeout
@ -195,15 +196,14 @@ LF31A: ldy #tpiPortA
bcc LF319
lda #$02
jsr UPDST
ldy #tpiPortA
ldy #TPI::PRA
lda (tpi1),y
and #$3D
sta (tpi1),y
lda #$0D
rts
; -------------------------------------------------------------------------
LF33F: lda (tpi1),y ; tpiPortA
LF33F: lda (tpi1),y ; TPI::PRA
and #$7F
sta (tpi1),y
and #$20
@ -211,16 +211,16 @@ LF33F: lda (tpi1),y ; tpiPortA
lda #$40
jsr UPDST
LF350: ldy #PortA
LF350: ldy #CIA::PRA
lda (cia),y
eor #$FF
pha
ldy #tpiPortA
ldy #TPI::PRA
lda (tpi1),y
ora #$40
sta (tpi1),y
LF35E: lda (tpi1),y ; tpiPortA
LF35E: lda (tpi1),y ; TPI::PRA
and #$10
beq LF35E
lda (tpi1),y
@ -234,12 +234,13 @@ LF35E: lda (tpi1),y ; tpiPortA
SetTimB32ms:
lda #$FF ; 255*256*0,5 µs
ldy #TimBHi
ldy #CIA::TBHI
sta (cia),y ; as high byte, low byte = 0
lda #$11
ldy #CtrlB
ldy #CIA::CRB
sta (cia),y ; Start the timer
ldy #IntCtrReg
ldy #CIA::ICR
lda (cia),y ; Clear the interrupt flag
clc
rts

View File

@ -61,7 +61,7 @@ k_irq:
cld
lda #$0F
sta IndReg
ldy #tpiActIntReg
ldy #TPI::AIR
lda (tpi1),y ; Interrupt Register 6525
beq noirq
@ -83,8 +83,8 @@ irq1: cmp #%00010000 ; interrupt from uart?
; -------------------------------------------------------------------------
; Done
irqend: ldy #tpiActIntReg
sta (tpi1),y ; Clear interrupt
irqend: ldy #TPI::AIR
sta (tpi1),y ; Clear interrupt
noirq: pla
sta IndReg

View File

@ -17,9 +17,9 @@
sta NorKey
lda #$00
sta KbdScanBuf
ldy #tpiPortB
ldy #TPI::PRB
sta (tpi2),y
ldy #tpiPortA
ldy #TPI::PRA
sta (tpi2),y
jsr Poll
and #$3F
@ -28,16 +28,16 @@
jmp NoKey
L1: lda #$FF
ldy #tpiPortA
ldy #TPI::PRA
sta (tpi2),y
asl a
ldy #tpiPortB
ldy #TPI::PRB
sta (tpi2),y
jsr Poll
pha
sta ModKey
ora #$30
bne L3 ; Branch always
bne L3 ; Branch always
L2: jsr Poll
L3: ldx #$05
@ -48,17 +48,17 @@ L4: lsr a
dex
bpl L4
sec
ldy #tpiPortB
ldy #TPI::PRB
lda (tpi2),y
rol a
sta (tpi2),y
ldy #tpiPortA
ldy #TPI::PRA
lda (tpi2),y
rol a
sta (tpi2),y
bcs L2
pla
bcc NoKey ; Branch always
bcc NoKey ; Branch always
L5: ldy KbdScanBuf
sty NorKey
@ -98,9 +98,9 @@ L8: tax
NoKey: ldy #$FF
Done: sty LastIndex
End: lda #$7F
ldy #tpiPortA
ldy #TPI::PRA
sta (tpi2),y
ldy #tpiPortB
ldy #TPI::PRB
lda #$FF
sta (tpi2),y
rts
@ -127,7 +127,7 @@ PutKey: sta KeyBuf,x
; Poll the keyboard port until it's stable
.proc Poll
ldy #tpiPortC
ldy #TPI::PRC
L1: lda (tpi2),y
sta KeySave
lda (tpi2),y