1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-05 20:31:53 +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 ; I/O $db00: CIA 6526 Inter Process Communication
;
; IPCcia = $db00 ; IPCcia = $db00
PortA = $00 .struct CIA
PortB = $01 PRA .byte
DDRA = $02 PRB .byte
DDRB = $03 DDRA .byte
TimALo = $04 DDRB .byte
TimAHi = $05 .union
TimBLo = $06 .struct
TimBHi = $07 TALO .byte
TOD10 = $08 TAHI .byte
TODsec = $09 .endstruct
TODmin = $0A TA .word
TODhour = $0B .endunion
SerDataReg = $0C .union
IntCtrReg = $0D .struct
CtrlA = $0E TBLO .byte
CtrlB = $0F 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 ; I/O $dc00: CIA 6526
@ -261,7 +272,7 @@ CtrlB = $0F
; I/O $dd00: ACIA 6551 ; I/O $dd00: ACIA 6551
; acia = $dd00 ; acia = $dd00
ADataReg = $00 ADataReg = $00
AStatusReg = $01 AStatusReg = $01
@ -272,23 +283,28 @@ ACtrlReg = $03
; I/O $de00: Triport #1 6525 ; I/O $de00: Triport #1 6525
; tpi1 = $de00 ; tpi1 = $de00
tpiPortA = $00
tpiPortB = $01
tpiPortC = $02
tpiIntLatch = $02
tpiDDRA = $03
tpiDDRB = $04
tpiDDRC = $05
tpiIntMask = $05
tpiCtrlReg = $06
tpiActIntReg = $07
.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 ; I/O $df00: Triport #2 6525
; tpi2 = $df00 ; tpi2 = $df00

View File

@ -13,29 +13,28 @@
; ------------------------------------------------------------------------- ; -------------------------------------------------------------------------
; Talk senden ; TALK subroutine
TALK: ora #$40 TALK: ora #$40
bne talk_listen bne talk_listen
; ------------------------------------------------------------------------- ; -------------------------------------------------------------------------
; Listen senden ; LISTEN subroutine
LISTEN: LISTEN: ora #$20
ora #$20
talk_listen: talk_listen:
pha pha
lda #$3F lda #$3F
ldy #tpiDDRA ldy #TPI::DDRA
sta (tpi1),y sta (tpi1),y
lda #$FF lda #$FF
ldy #PortA ldy #CIA::PRA
sta (cia),y sta (cia),y
ldy #DDRA ldy #CIA::DDRA
sta (cia),y sta (cia),y
lda #$FA lda #$FA
ldy #tpiPortA ldy #TPI::PRA
sta (tpi1),y sta (tpi1),y
lda CTemp lda CTemp
bpl LF268 bpl LF268
@ -47,82 +46,25 @@ talk_listen:
lda CTemp lda CTemp
and #$7F and #$7F
sta CTemp sta CTemp
ldy #tpiPortA ldy #TPI::PRA
lda (tpi1),y lda (tpi1),y
ora #$20 ora #$20
sta (tpi1),y sta (tpi1),y
LF268: lda (tpi1),y ; tpiPortA LF268: lda (tpi1),y ; TPI::PRA
and #$F7 and #$F7
sta (tpi1),y sta (tpi1),y
pla pla
jmp transfer_byte ; 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
; ------------------------------------------------------------------------- ; -------------------------------------------------------------------------
; Output A (without EOF flag) ; Output A (without EOF flag)
transfer_byte: transfer_byte:
eor #$FF eor #$FF
ldy #PortA ldy #CIA::PRA
sta (cia),y sta (cia),y
ldy #tpiPortA ldy #TPI::PRA
lda (tpi1),y lda (tpi1),y
ora #$12 ora #$12
sta (tpi1),y sta (tpi1),y
@ -144,11 +86,11 @@ LF2DE: jsr SetTimB32ms
bcc LF2E4 ; Branch always bcc LF2E4 ; Branch always
LF2E3: sec LF2E3: sec
LF2E4: ldy #tpiPortA LF2E4: ldy #TPI::PRA
lda (tpi1),y lda (tpi1),y
and #$40 and #$40
bne LF2FC bne LF2FC
ldy #IntCtrReg ldy #CIA::ICR
lda (cia),y lda (cia),y
and #$02 and #$02
beq LF2E4 beq LF2E4
@ -158,19 +100,78 @@ LF2E4: ldy #tpiPortA
lda #$01 lda #$01
jsr UPDST jsr UPDST
LF2FC: ldy #tpiPortA LF2FC: ldy #TPI::PRA
lda (tpi1),y lda (tpi1),y
ora #$10 ora #$10
sta (tpi1),y sta (tpi1),y
LF304: lda #$FF LF304: lda #$FF
ldy #PortA ldy #CIA::PRA
sta (cia),y sta (cia),y
rts 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 lda (tpi1),y
and #$B9 and #$B9
ora #$81 ora #$81
@ -181,11 +182,11 @@ LF314: jsr SetTimB32ms
LF319: sec LF319: sec
LF31A: ldy #tpiPortA LF31A: ldy #TPI::PRA
lda (tpi1),y lda (tpi1),y
and #$10 and #$10
beq LF33F beq LF33F
ldy #IntCtrReg ldy #CIA::ICR
lda (cia),y lda (cia),y
and #$02 and #$02
beq LF31A ; Loop if not timeout beq LF31A ; Loop if not timeout
@ -195,15 +196,14 @@ LF31A: ldy #tpiPortA
bcc LF319 bcc LF319
lda #$02 lda #$02
jsr UPDST jsr UPDST
ldy #tpiPortA ldy #TPI::PRA
lda (tpi1),y lda (tpi1),y
and #$3D and #$3D
sta (tpi1),y sta (tpi1),y
lda #$0D lda #$0D
rts rts
; -------------------------------------------------------------------------
LF33F: lda (tpi1),y ; tpiPortA LF33F: lda (tpi1),y ; TPI::PRA
and #$7F and #$7F
sta (tpi1),y sta (tpi1),y
and #$20 and #$20
@ -211,16 +211,16 @@ LF33F: lda (tpi1),y ; tpiPortA
lda #$40 lda #$40
jsr UPDST jsr UPDST
LF350: ldy #PortA LF350: ldy #CIA::PRA
lda (cia),y lda (cia),y
eor #$FF eor #$FF
pha pha
ldy #tpiPortA ldy #TPI::PRA
lda (tpi1),y lda (tpi1),y
ora #$40 ora #$40
sta (tpi1),y sta (tpi1),y
LF35E: lda (tpi1),y ; tpiPortA LF35E: lda (tpi1),y ; TPI::PRA
and #$10 and #$10
beq LF35E beq LF35E
lda (tpi1),y lda (tpi1),y
@ -234,12 +234,13 @@ LF35E: lda (tpi1),y ; tpiPortA
SetTimB32ms: SetTimB32ms:
lda #$FF ; 255*256*0,5 µs lda #$FF ; 255*256*0,5 µs
ldy #TimBHi ldy #CIA::TBHI
sta (cia),y ; as high byte, low byte = 0 sta (cia),y ; as high byte, low byte = 0
lda #$11 lda #$11
ldy #CtrlB ldy #CIA::CRB
sta (cia),y ; Start the timer sta (cia),y ; Start the timer
ldy #IntCtrReg ldy #CIA::ICR
lda (cia),y ; Clear the interrupt flag lda (cia),y ; Clear the interrupt flag
clc clc
rts rts

View File

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

View File

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