NEW
  AUTO 3,1
*--------------------------------------
* this routine handles interrupts and is coded to reach 'lreset' precisely at
* address $FFCB (ROM rts opcode) for rom switching to function.
* $FF9B
*--------------------------------------
IRQ.START		.PH IRQ

IRQ.START1		ldx #$FA				save 6 bytes of page 0

.2  			lda	$00,x
				sta	IRQ.ZPSave-$FA,x
				inx
				bne	.2

*				lda mslot
*				sta IRQ.DoneCn+2

*				ldx #0

.3				lda GP.IRQVs+1,x		test for a valid routine.
				beq .4					branch if no routine.

				phx
				jsr IRQ.GoX
				plx

				bcc IRQ.Done

.4				inx
				inx
				cpx #8
				bne .3

				inc IRQ.Cnt				allow 255 unclaimed interrupts
				bne IRQ.Done			before system death.

				lda #$01				bad irq so
				jsr GP.SYSDEATH			kill the system.
*--------------------------------------
				.LIST ON
IRQ.FREE1		.EQ $ffc8-*
				.LIST OFF

				.BS IRQ.FREE1

IRQ.ToRomRTS	sta IO.RROMBNK2
				.DO *=$FFCB
*				hits ROM rts at $FFCB
				.ELSE
		ERROR
				.FIN
*--------------------------------------
IRQ.Done		ldx #$FA

.1  			lda	IRQ.ZPSave-$FA,x	restore the zero page
				sta	$00,x
				inx
				bne .1

*				lda IO.CLRC8ROM
				
*IRQ.DoneCn		lda $C100				SELF MODIFIED		
*				lda IRQ.DoneCn+2
*				sta mslot
				
				rti
*--------------------------------------
IRQ.GoX			jmp (GP.IRQVs,x)		interrupt routine x

IRQ.Reset		lda /ROM.RESETV-1
				pha
				lda #ROM.RESETV-1
				pha
				bra IRQ.ToRomRTS

IRQ.Cnt	 		.HS 00					# of unclaimed interrupts.
IRQ.ZPSave		.HS 000000000000		6 bytes

				.LIST ON
IRQ.FREE2		.EQ $fffa-*
				.LIST OFF

				.BS IRQ.FREE2

				.DA ROM.NMIJMP 			nmi handler
				.DA IRQ.Reset 			reset handler
irqv			.DA *					PATCHED with ROM vector by LDR
				.LIST OFF
*--------------------------------------
				.EP
*--------------------------------------
IRQ.LEN			.EQ *-IRQ.START
*--------------------------------------
MAN
SAVE usr/src/prodos.fx/prodos.s.irq
LOAD usr/src/prodos.fx/prodos.s
ASM
