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				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.Reset1		sta 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 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 /resetv-1
				pha
				lda #resetv-1
				pha
				bra IRQ.Reset1

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 nmivect	 			nmi handler
				.DA IRQ.Reset 			reset handler
irqv			.DA *					PATCHED with ROM vector by LDR
				.LIST OFF
*--------------------------------------
IRQ.LEN			.EQ *-IRQ
*--------------------------------------
MAN
SAVE USR/SRC/PRODOS.FX/PRODOS.S.IRQ
LOAD USR/SRC/PRODOS.FX/PRODOS.S
ASM
