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.
* $2D9B-2DFF moved to $FF9B-FFFF
*--------------------------------------
IRQ.START
XDOS.IRQV		ldx #$FA				save 6 bytes of page 0

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

				ldx #0

.3				stx irqXindex

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

				jsr gointX				execute

				bcc irqdone

.4				ldx irqXindex
				inx
				inx
				cpx #10
				bne .3

				inc irqcount			allow 255 unclaimed interrupts
				bne irqdone				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
				
gorom			sta RROMBNK2			hits ROM rts at $FFCB

* 'lreset' address must = $FFCB for rom switch i/o to work

lreset			lda /resetv-1
				pha
				lda #resetv-1
				pha
				jmp gorom

irqdone			ldx #$FA

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

gointX			jmp (inttbl,x)			interrupt routine x

irqcount 		.HS 00					# of unclaimed interrupts.
irqXindex		.HS 00
svzerop			.HS 000000000000

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

				.BS IRQ.FREE2

				.DA nmivect	 			nmi handler
				.DA lreset	 			reset handler
irqv			.DA *					PATCHED with ROM vector by LDR
				.LIST OFF
*--------------------------------------
IRQ.LEN			.EQ *-IRQ.START
MAN
SAVE USR/SRC/PRODOS.FX/PRODOS.S.IRQ
LOAD USR/SRC/PRODOS.FX/PRODOS.S
ASM
