changeset 8:e0485bef3f30

Make IRQ handler play nice with Basic. Make IRQ handler actually call the Disk Basic handler (or Extended Basic handler if no Disk Basic). This assumes the IRQ handler is in the right place for the detected version of Disk Basic. The main reason for this is so the the disk motor timeout thing actually works.
author William Astle <lost@l-w.ca>
date Sun, 28 Dec 2014 22:23:23 -0700
parents e7cbc1a5b61a
children 2401a0c72921
files dod.s
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Sun Dec 28 22:10:41 2014 -0700
+++ b/dod.s	Sun Dec 28 22:23:23 2014 -0700
@@ -263,6 +263,7 @@
 hook_openo	rmb 2				; the address of the "open for output" routine in the Disk ROM
 error_handler	rmb 2				; the installed error trap
 error_stack	rmb 2				; the stack address to use when transferring control to the error trap
+hook_irq	rmb 2				; the address of the original IRQ routine for Basic
 ; These variables are additional ones used by extensions to the original ROM
 		rmb 256-(*&255)			; align the next bit on a page boundary
 ; These are the original variables used by the system, including the direct page.
@@ -816,7 +817,10 @@
 		beq LC320			; brif not
 		bsr writekeybuf			; go process keyboard input
 LC320		lda PIA0+2			; clear interrupt status
-		rti
+; Because we're using Basic routines, we need to let the Basic IRQ handler run too.
+		clra				; restore DP to 0 for Basic
+		tfr a,dp
+		jmp [hook_irq]			; transfer control to the saved IRQ routine (this will do the RTI)
 ; These are the rollover points for the timers. Each timer only ticks if the previous
 ; timer has rolled over.
 LC324		fcb 6				; tick 10 times per second
@@ -5094,21 +5098,24 @@
 		sta $191			; set up handler for the error routine at AC46
 		stx $192
 		ldx $C004			; get DSKCON address pointer
+		ldy #$8955			; point to IRQ handler
 		cmpx #$D75F			; is it disk basic 1.1?
 		beq load_disk11			; brif so
 		cmpx #$d66c			; is it disk basic 1.0?
 		beq load_disk10			; brif so
 		ldx #disk_error			; point to the routine for no disk system
-		stx hook_openi			; set the disk basic vectors to go there
-		stx hook_openo
+		ldu #disk_error
 		bra load_001			; go finish initializing
 load_disk10	ldx #$C956			; address of "open system file for output" routine
 		ldu #$C959			; address of "open system file for input" routine
+		ldy #$d7c4			; point to Disk IRQ handler
 		bra load_000			; go set vectors
 load_disk11	ldx #$CA04			; address of "open system file for output" routine
 		ldu #$CA07			; address of "Open system file for input" routine
+		ldy #$d8b7			; point to Disk IRQ handler
 load_000	stx hook_openo			; save address of "open for output"
 		stu hook_openi			; save address of "open for input"
+		sty hook_irq			; save IRQ hook for Basic
 load_001	clr error_handler		; mark the error handler as disabled
 		clr error_handler+1
 		jmp START			; transfer control to the main stream code