IRQ handler for UP9600
This commit is contained in:
1 parent
df1285e5f3
commit
6f010b8c56
9 files changed
+138
-14
No files matched your search
@@ -114,7 +114,7 @@
|
|||||||
.label INBIT = $A7 // -- NOT IMPLEMENTED --
|
.label INBIT = $A7 // -- NOT IMPLEMENTED --
|
||||||
#if !CONFIG_LEGACY_SCNKEY
|
#if !CONFIG_LEGACY_SCNKEY
|
||||||
.label BITCI = $A8 // -- NOT IMPLEMENTED --
|
.label BITCI = $A8 // -- NOT IMPLEMENTED --
|
||||||
.label RINONE = $A9 // -- NOT IMPLEMENTED --
|
.label RINONE = $A9 // -- WIP -- (UP9600 only) RS-232 check for start bit flag
|
||||||
.label RIDDATA = $AA // -- NOT IMPLEMENTED --
|
.label RIDDATA = $AA // -- NOT IMPLEMENTED --
|
||||||
.label RIPRTY = $AB // -- NOT IMPLEMENTED --
|
.label RIPRTY = $AB // -- NOT IMPLEMENTED --
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
|
|
||||||
default_irq_handler:
|
default_irq_handler:
|
||||||
|
|
||||||
|
#if CONFIG_RS232_UP9600
|
||||||
|
|
||||||
|
jsr rs232_count_channels
|
||||||
|
cpx #$00
|
||||||
|
beq !+
|
||||||
|
jsr up9600_irq
|
||||||
|
!:
|
||||||
|
|
||||||
|
#endif // CONFIG_RS232_UP9600
|
||||||
|
|
||||||
|
|
||||||
jsr cursor_blink
|
jsr cursor_blink
|
||||||
jsr JSCNKEY
|
jsr JSCNKEY
|
||||||
jsr JUDTIM // update jiffy clock
|
jsr JUDTIM // update jiffy clock
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO
|
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO
|
||||||
|
|
||||||
// Turn tape motor on/off depending on the button state
|
// Turn tape motor on/off depending on the button state
|
||||||
@@ -25,7 +37,8 @@ default_irq_handler:
|
|||||||
|
|
||||||
default_irq_handler_end_tape:
|
default_irq_handler_end_tape:
|
||||||
|
|
||||||
#endif
|
#endif // CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO
|
||||||
|
|
||||||
|
|
||||||
// Acknowledge CIA interrupt and return
|
// Acknowledge CIA interrupt and return
|
||||||
jmp clear_cia1_interrupt_flag_and_return_from_interrupt
|
jmp clear_cia1_interrupt_flag_and_return_from_interrupt
|
||||||
@@ -17,9 +17,10 @@ default_nmi_handler:
|
|||||||
bne !+
|
bne !+
|
||||||
jmp (ICART_WARM_START)
|
jmp (ICART_WARM_START)
|
||||||
!:
|
!:
|
||||||
|
|
||||||
// According to C64 Wiki, if STOP key is pressed, the routine assumes warm start request
|
// According to C64 Wiki, if STOP key is pressed, the routine assumes warm start request
|
||||||
|
|
||||||
|
// XXX is it right? how to check that IRQ was caused by RESTORE?
|
||||||
|
|
||||||
jsr JSTOP
|
jsr JSTOP
|
||||||
bcs !+
|
bcs !+
|
||||||
jmp return_from_interrupt // no STOP pressed
|
jmp return_from_interrupt // no STOP pressed
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ close_rs232:
|
|||||||
// If more than one, skip deallocation (other channels still uses the buffer).
|
// If more than one, skip deallocation (other channels still uses the buffer).
|
||||||
|
|
||||||
jsr rs232_count_channels
|
jsr rs232_count_channels
|
||||||
|
cpx #$02 // set Carry if more than one is open
|
||||||
bcs close_rs232_end
|
bcs close_rs232_end
|
||||||
|
|
||||||
// Deallocate buffer
|
// Deallocate buffer
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ open_rs232:
|
|||||||
// If more than one, skip allocation (already allocated).
|
// If more than one, skip allocation (already allocated).
|
||||||
|
|
||||||
jsr rs232_count_channels
|
jsr rs232_count_channels
|
||||||
|
cpx #$02 // set Carry if more than one is open
|
||||||
bcs open_rs232_end
|
bcs open_rs232_end
|
||||||
|
|
||||||
// Allocate buffers - first RIBUF, afterwards ROBUF
|
// Allocate buffers - first RIBUF, afterwards ROBUF
|
||||||
@@ -43,6 +44,14 @@ open_rs232:
|
|||||||
sta RODBS
|
sta RODBS
|
||||||
sta RODBE
|
sta RODBE
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_RS232_UP9600
|
||||||
|
|
||||||
|
jmp up9600_enable
|
||||||
|
|
||||||
|
#endif // CONFIG_RS232_UP9600
|
||||||
|
|
||||||
|
|
||||||
open_rs232_end:
|
open_rs232_end:
|
||||||
|
|
||||||
jmp open_done_success
|
jmp open_done_success
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Sets .X to number of open RS-232 channels
|
// Sets .X to number of open RS-232 channels
|
||||||
// Sets Carry if more than one is open
|
//
|
||||||
|
|
||||||
|
|
||||||
#if HAS_RS232
|
#if HAS_RS232
|
||||||
@@ -20,8 +20,6 @@ rs232_count_channels:
|
|||||||
inx
|
inx
|
||||||
bpl !- // branch always
|
bpl !- // branch always
|
||||||
|
|
||||||
cpx #$02
|
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Enable UP9600 interface
|
// Enable UP9600 interface support
|
||||||
//
|
//
|
||||||
|
|
||||||
// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations
|
// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations
|
||||||
@@ -11,6 +11,63 @@
|
|||||||
|
|
||||||
up9600_enable: // XXX adapt
|
up9600_enable: // XXX adapt
|
||||||
|
|
||||||
|
sei
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
lda IRQVECT
|
||||||
|
cmp #<ORIGIRQ
|
||||||
|
bne INSTERR; IRQ-VECTOR ALREADY CHANGED
|
||||||
|
lda IRQVECT+1
|
||||||
|
cmp #>ORIGIRQ
|
||||||
|
bne INSTERR; IRQ-VECTOR ALREADY CHANGED
|
||||||
|
lda NMIVECT
|
||||||
|
cmp #<ORIGNMI
|
||||||
|
bne INSTERR; NMI-VECTOR ALREADY CHANGED
|
||||||
|
lda NMIVECT+1
|
||||||
|
cmp #>ORIGNMI
|
||||||
|
bne INSTERR; NMI-VECTOR ALREADY CHANGED
|
||||||
|
ldy #0
|
||||||
|
sty RODBE
|
||||||
|
sty RODBS
|
||||||
|
sty RIDBE
|
||||||
|
sty RIDBS
|
||||||
|
; PROBE FOR RS232 INTERFACE
|
||||||
|
cli
|
||||||
|
lda #$7F
|
||||||
|
sta CIA2_ICR // $DD0D ; DISABLE ALL NMIS
|
||||||
|
lda #$80
|
||||||
|
sta CIA2_DDRB // $DD03 ; PB7 USED AS OUTPUT
|
||||||
|
sta $DD0E; STOP TIMERA
|
||||||
|
sta CIA2_CRB // $DD0F ; STOP TIMERB
|
||||||
|
bit CIA2_ICR // $DD0D ; CLEAR PENDING INTERRUPTS
|
||||||
|
ldx #8
|
||||||
|
INSTALL2
|
||||||
|
stx CIA2_PRB // $DD01; TOGGLE TXD
|
||||||
|
sta CIA2_PRB // $DD01; AND LOOK IF IT TRIGGERS AN
|
||||||
|
dex; SHIFT-REGISTER INTERRUPT
|
||||||
|
bne INSTALL2
|
||||||
|
lda CIA2_ICR // $DD0D ; CHECK FOR BIT3 (SDR-FLAG)
|
||||||
|
and #8
|
||||||
|
beq INSTERR; NO INTERFACE DETECTED
|
||||||
|
; GENERATE LOOKUP TABLE
|
||||||
|
ldx #0
|
||||||
|
INSTALL3
|
||||||
|
stx OUTSTAT; OUTSTAT USED AS TEMPORARY VARIABLE
|
||||||
|
ldy #8
|
||||||
|
INSTALL4
|
||||||
|
asl OUTSTAT
|
||||||
|
ror
|
||||||
|
dey
|
||||||
|
bne INSTALL4
|
||||||
|
sta REVTAB,X
|
||||||
|
inx
|
||||||
|
bpl INSTALL3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sei
|
sei
|
||||||
// XXX set NEWIRQ as IRQ vector
|
// XXX set NEWIRQ as IRQ vector
|
||||||
// XXX set NMIDOBIT as NMI vector
|
// XXX set NMIDOBIT as NMI vector
|
||||||
@@ -63,4 +120,14 @@ ENABLE2
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INSTERR
|
||||||
|
cli
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // CONFIG_RS232_UP9600
|
#endif // CONFIG_RS232_UP9600
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// RS-232 IRQ handler part
|
||||||
|
//
|
||||||
|
|
||||||
|
// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations
|
||||||
|
|
||||||
|
|
||||||
|
#if CONFIG_RS232_UP9600
|
||||||
|
|
||||||
|
|
||||||
|
up9600_irq:
|
||||||
|
|
||||||
|
lda CIA1_ICR // $DC0D
|
||||||
|
|
||||||
|
lsr
|
||||||
|
lsr // move bit 1 (timer B flag) into Carry
|
||||||
|
and #$02 // test SDR (shift register) status
|
||||||
|
|
||||||
|
beq up9600_irq_continue
|
||||||
|
|
||||||
|
ldx RINONE
|
||||||
|
beq !+ // skip if not waiting for empty SDR
|
||||||
|
dex
|
||||||
|
stx RINONE
|
||||||
|
!:
|
||||||
|
bcc up9600_irq_end
|
||||||
|
|
||||||
|
up9600_irq_continue:
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
up9600_irq_end:
|
||||||
|
|
||||||
|
pla
|
||||||
|
pla
|
||||||
|
jmp return_from_interrupt
|
||||||
|
|
||||||
|
|
||||||
|
#endif // CONFIG_RS232_UP9600
|
||||||
@@ -6,19 +6,14 @@
|
|||||||
// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations
|
// Based on UP9600 code by Daniel Dallman with Bo Zimmerman adaptations
|
||||||
|
|
||||||
|
|
||||||
// XXX integrate with NMI handler
|
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_RS232_UP9600
|
#if CONFIG_RS232_UP9600
|
||||||
|
|
||||||
|
|
||||||
up9600_nmi:
|
up9600_nmi:
|
||||||
// XXX integrate this
|
// XXX integrate with NMI handler
|
||||||
|
|
||||||
|
|
||||||
NMIDOBIT
|
|
||||||
pha
|
pha
|
||||||
bit CIA2_ICR // $DD0D; CHECK BIT 7 (STARTBIT PRINT)
|
bit CIA2_ICR // $DD0D; check if CIA caused the interrupt
|
||||||
bpl NMIDOBI2; NO STARTBIT RECEIVED, THEN SKIP
|
bpl NMIDOBI2; NO STARTBIT RECEIVED, THEN SKIP
|
||||||
lda #$13
|
lda #$13
|
||||||
sta CIA2_CRB // $DD0F; START TIMER B (FORCED RELOAD, SIGNAL AT PB7)
|
sta CIA2_CRB // $DD0F; START TIMER B (FORCED RELOAD, SIGNAL AT PB7)
|
||||||
|
|||||||
Reference in new issue
Block a user