changeset 2620:3574de541ad4

Everything WORKS
author Boisy Pitre <boisy.pitre@nuance.com>
date Wed, 22 Feb 2012 22:13:35 -0600
parents d888412d8118
children f27161fc2926
files defs/atarivtio.d defs/os9defs level1/atari/bootroms/makefile level1/atari/modules/clock.asm level1/atari/modules/makefile level1/atari/modules/sysgo.asm level1/atari/modules/term.asm level1/atari/modules/vtio.asm level1/modules/kernel/krn.asm
diffstat 9 files changed, 561 insertions(+), 139 deletions(-) [+]
line wrap: on
line diff
--- a/defs/atarivtio.d	Wed Feb 22 10:24:04 2012 -0600
+++ b/defs/atarivtio.d	Wed Feb 22 22:13:35 2012 -0600
@@ -30,6 +30,10 @@
                ORG       V.SCF
 V.CurRow       RMB       1
 V.CurCol       RMB       1
+V.KySns        RMB       1                   key sense flags
+V.IBufH        RMB       1                   input buffer head
+V.IBufT        RMB       1                   input buffer tail
+V.InBuf        RMB       1                   input buffer ptr
                RMB       250-.
 V.Last         EQU       .
 
--- a/defs/os9defs	Wed Feb 22 10:24:04 2012 -0600
+++ b/defs/os9defs	Wed Feb 22 22:13:35 2012 -0600
@@ -484,10 +484,10 @@
                ORG       $100
 D.XSWI3        RMB       3
 D.XSWI2        RMB       3
+D.XFIRQ        RMB       3
+D.XIRQ         RMB       3
 D.XSWI         RMB       3
 D.XNMI         RMB       3
-D.XIRQ         RMB       3
-D.XFIRQ        RMB       3
 
 * Table Sizes
 BMAPSZ         EQU       32                  Bitmap table size
--- a/level1/atari/bootroms/makefile	Wed Feb 22 10:24:04 2012 -0600
+++ b/level1/atari/bootroms/makefile	Wed Feb 22 22:13:35 2012 -0600
@@ -7,16 +7,13 @@
 
 DEPENDS		= ./makefile
 
-BOOTFILE_ROM	= $(MD)/krnp2 $(MD)/init \
+BOOTFILE_ROM_P1	= $(MD)/krnp2 $(MD)/init \
 				$(MD)/ioman $(MD)/scf.mn $(MD)/vtio.dr $(MD)/term.dt \
-				$(MD)/sysgo $(CD)/mdir \
+				$(MD)/sysgo \
+				$(MD)/clock_60hz $(MD)/clock2_soft \
 				$(MD)/krn
 
-BOOTFILE_ROM_OLD	= $(MD)/rominfo $(MD)/ioman \
-		$(MD)/scf.mn $(MD)/vtio.dr \
-		$(MD)/covdg.io \
-		$(MD)/term32.dt \
-		$(MD)/clock_60hz $(MD)/clock2_soft
+BOOTFILE_ROM_P2	= $(CD)/shell_21 $(CD)/mdir
 
 BOOTROMS	= nos96809l1.rom
 
@@ -26,9 +23,13 @@
 
 # Bootfiles
 nos96809l1.rom: $(BOOTFILE_ROM) $(DEPENDS)
-	$(MERGE) $(BOOTFILE_ROM)>$@
-	$(PADROM) -b 10240 $@
-#	$(PADROM) -b 16384 $@
+	$(MERGE) $(BOOTFILE_ROM_P1)>$@_p1
+	$(MERGE) $(BOOTFILE_ROM_P2)>$@_p2
+	$(PADROM) -b 10240 $@_p1
+	$(PADROM) -b 12288 $@_p1
+	$(MERGE) $@_p2 $@_p1>$@
+	$(PADROM) -b 16384 $@
+#	$(RM) $@_p2 $@_p1
 	
 clean:
 	$(RM) $(ALLROMS)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/level1/atari/modules/clock.asm	Wed Feb 22 22:13:35 2012 -0600
@@ -0,0 +1,259 @@
+********************************************************************
+* Clock - NitrOS-9 System Clock for Atari XL/XE
+*
+* $Id$
+*
+* Edt/Rev  YYYY/MM/DD  Modified by
+* Comment
+* ------------------------------------------------------------------
+*          2012/02/22  Boisy G. Pitre
+* Created
+ 
+         nam   Clock     
+         ttl   NitrOS-9 System Clock for Atari XL/XE
+                         
+         ifp1            
+         use   defsfile  
+         endc            
+                         
+tylg     set   Systm+Objct
+atrv     set   ReEnt+rev 
+rev      set   0
+edition  set   1         
+                         
+                         
+*------------------------------------------------------------
+*
+* Start of module
+*
+         mod   len,name,tylg,atrv,init,0
+                         
+name     fcs   "Clock"   
+         fcb   edition   
+                         
+                         
+TkPerTS  equ   TkPerSec/10 ticks per time slice
+                         
+*
+* Table to set up Service Calls
+*
+NewSvc   fcb   F$Time    
+         fdb   FTime-*-2 
+         fcb   F$VIRQ    
+         fdb   FVIRQ-*-2 
+         fcb   F$STime   
+         fdb   FSTime-*-2
+         fcb   $80        end of service call installation table
+                         
+                         
+*------------------------------------------------------------
+*
+* Handle F$STime system call
+*
+* First, copy time packet from user address space to system time
+* variables, then fall through to code to update RTC.
+*
+FSTime   equ   *         
+         ldx   R$X,u     
+         ldd   ,x        
+         std   <D.Year   
+         ldd   2,x       
+         std   <D.Day    
+         ldd   4,x       
+         std   <D.Min    
+         lda   #TkPerSec  reset to start of second
+         sta   <D.Tick   
+         ldx   <D.Clock2  get entry point to Clock2
+         clra             clear carry
+         jmp   $06,x      and call SetTime entry point
+                         
+                         
+*--------------------------------------------------
+*
+* Clock Initialization
+*
+* This vector is called by the kernel to service the first F$STime
+* call.  F$STime is usually called by SysGo (with a dummy argument)
+* in order to initialize the clock.  F$STime is re-vectored to the
+* service code above to handle future F$STime calls.
+*
+*
+                         
+Clock2   fcs   "Clock2"  
+                         
+init              
+         pshs  dp,cc      save DP and CC
+         clra            
+         tfr   a,dp       set DP to zero
+                         
+         leax  <Clock2,pcr
+         lda   #Sbrtn+Objct
+         os9   F$Link    
+                         
+         bcc   LinkOk    
+                         
+         jmp   >$FFFE     level 1: jump to reset vector
+                         
+LinkOk                   
+         puls  cc,dp      ; Restore saved dp and cc
+                         
+         sty   <D.Clock2  save entry point
+InitCont                 
+                         
+* Don't need to explicitly read RTC during initialization
+         ldd   #59*256+$01 last second and last tick
+         std   <D.Sec     will prompt RTC read at next time slice
+         ldb   #TkPerSec
+         stb   <D.TSec    set ticks per second
+         ldb   #TkPerTS   get ticks per time slice
+         stb   <D.TSlice  set ticks per time slice
+         stb   <D.Slice   set first time slice
+         leax  SvcIRQ,pcr set IRQ handler
+         stx   <D.IRQ    
+                         
+         leay  NewSvc,pcr insert syscalls
+         os9   F$SSvc    
+                         
+* Call Clock2 init routine
+         ldy   <D.Clock2  get entry point to Clock2
+         jsr   ,y         call init entry point of Clock2
+
+* Tell ANTIC to assert NMI on Vertical Blank
+     	lda     #$40
+     	sta     $D40E		enable VBlank NMI
+InitRts  rts
+                         
+*
+* Clock IRQ Entry Point
+*
+* Called once every 16.667 milliseconds
+SvcIRQ                   
+          clra            
+         tfr   a,dp       set direct page to zero
+          sta   $D40F     clear NMI interrupt
+*         tst   PIA0Base+3 get hw byte
+*         bmi   L0032      branch if sync flag on
+*         jmp   [>D.SvcIRQ] else service other possible IRQ
+L0032
+         dec   <D.Tick    decrement tick counter
+         bne   L007F      go around if not zero
+         ldb   <D.Sec     get minutes/seconds
+* Seconds increment
+         incb             increment seconds
+         cmpb  #60        full minute?
+         bcs   L0079      nope...
+*
+* Call GetTime entry point in Clock2
+*
+         ldx   <D.Clock2  get entry point to Clock2
+         jsr   $03,x      call GetTime entry point
+         fcb   $8C        skip next 2 bytes
+L0079    stb   <D.Sec     update sec
+L007B    lda   <D.TSec    get ticks per second value
+         sta   <D.Tick    and repopulate tick decrement counter
+L007F    clra             clear A
+         pshs  a          and save it on the stack
+         ldy   <D.CLTb    get pointer to VIRQ Polling Entries
+         bra   L009E      go to the processing portion of the loop
+L0087    ldd   Vi.Cnt,x   get count down counter
+         subd  #$0001     subtract tick count
+         bne   L009C      branch if not at terminal count ($0000)
+         lda   #$01      
+         sta   ,s         set flag on stack to 1
+         lda   Vi.Stat,x  get status byte
+         beq   DelEntry   branch if zero (one shot, so delete)
+L0096    ora   #Vi.IFlag  set interrupted flag
+         sta   Vi.Stat,x  save in packet
+         ldd   Vi.Rst,x   get reset count
+L009C    std   Vi.Cnt,x   save tick count back
+L009E    ldx   ,y++       get two bytes at Y
+         bne   L0087      if not zero, branch
+         lda   ,s+        else get byte off stack
+         beq   GoAltIRQ   branch if zero
+         ldx   <D.Proc    else get pointer to current process descriptor
+         beq   L00AE      branch if none
+         tst   P$State,x  test process' state
+         bpl   UsrPoll    branch if system state not set
+L00AE    jsr   [>D.Poll]  poll ISRs
+         bcc   L00AE      keep polling until carry set
+GoAltIRQ                 
+         jmp   [>D.AltIRQ] jump into an alternate IRQ if available
+DelEntry                 
+         bsr   DelVIRQ    delete the VIRQ entry
+         bra   L0096     
+                         
+UsrPoll  leay  >up@,pcr   point to routine to execute
+         jmp   [>D.URtoSs] User to System
+up@      jsr   [>D.Poll]  call polling routine
+         bcc   up@        keep polling until carry set
+         ldx   <D.Proc    get current process descriptor
+         ldb   P$State,x  and its state
+         andb  #^SysState turn off sysstate bit
+         stb   P$State,x  save new state
+         ldd   <P$SWI2,x 
+         std   <D.SWI2   
+         ldd   <D.UsrIRQ 
+         std   <D.SvcIRQ 
+         bra   GoAltIRQ  
+                         
+DelVIRQ  pshs  y,x        save off Y,X
+dl@      ldx   ,y++       get next entry
+         stx   -$04,y     move up
+         bne   dl@        continue until all are moved
+         puls  y,x        restore
+         leay  -2,y       move back 2 from Y (points to last entry)
+         rts              return
+                         
+* Install or Remove VIRQ Entry
+FVIRQ    pshs  cc        
+         orcc  #IntMasks  mask all interrupts
+         ldy   <D.CLTb    get pointer to VIRQ polling table
+         ldx   <D.Init    get pointer to init module
+         ldb   PollCnt,x  get poll count
+         ldx   R$X,u      get pointer to caller's X
+         beq   L0118      branch if removing
+         tst   ,y         entry available?
+         beq   L010C     
+         subb  #$02      
+         lslb            
+         leay  b,y       
+         tst   ,y        
+         bne   PTblFul    polling table full
+L0106    tst   ,--y      
+         beq   L0106     
+         leay  $02,y     
+L010C    ldx   R$Y,u     
+         stx   ,y        
+         ldy   R$D,u     
+         sty   ,x        
+         bra   L0124     
+L0118    leax  R$Y,u      X = caller's Y
+L011A    tst   ,y         end of VIRQ table
+         beq   L0124      branch if so
+         cmpx  ,y++       else compare to current VIRQ entry and inc Y
+         bne   L011A      continue searching if not matched
+         bsr   DelVIRQ    else delete entry
+L0124    puls  cc        
+         clrb            
+         rts             
+PTblFul  puls  cc        
+         comb            
+         ldb   #E$Poll   
+         rts             
+                         
+                         
+                         
+* F$Time system call code
+FTime    ldx   R$X,u     
+         ldd   <D.Year   
+         std   ,x        
+         ldd   <D.Day    
+         std   2,x       
+         ldd   <D.Min    
+         std   4,x       
+         clrb            
+         rts             
+                         
+         emod            
+len      equ   *         
+         end             
--- a/level1/atari/modules/makefile	Wed Feb 22 10:24:04 2012 -0600
+++ b/level1/atari/modules/makefile	Wed Feb 22 22:13:35 2012 -0600
@@ -24,7 +24,7 @@
 BOOTERS		= 
 KERNEL		= krn krnp2
 SYSMODS		= ioman init sysgo
-CLOCKS      = clock_60hz clock_50hz
+CLOCKS      = clock_60hz clock_50hz clock2_soft
 
 RBF		= rbf.mn
 
--- a/level1/atari/modules/sysgo.asm	Wed Feb 22 10:24:04 2012 -0600
+++ b/level1/atari/modules/sysgo.asm	Wed Feb 22 22:13:35 2012 -0600
@@ -208,7 +208,7 @@
          os9   F$Fork
          bcs   L0186
          os9   F$Wait
-         bra   DoAuto
+*         bra   DoAuto
 L0186    equ   *
          puls  u,y
 FrkShell leax  >ShellPrm,pcr
--- a/level1/atari/modules/term.asm	Wed Feb 22 10:24:04 2012 -0600
+++ b/level1/atari/modules/term.asm	Wed Feb 22 22:13:35 2012 -0600
@@ -37,7 +37,7 @@
          fcb   $01            echo:0=no echo
          fcb   $01            auto line feed:0=off
          fcb   $00            end of line null count
-         fcb   $01            pause:0=no end of page pause
+         fcb   $00            pause:0=no end of page pause
          fcb   24             lines per page
          fcb   C$BSP          backspace character
          fcb   C$DEL          delete line character
--- a/level1/atari/modules/vtio.asm	Wed Feb 22 10:24:04 2012 -0600
+++ b/level1/atari/modules/vtio.asm	Wed Feb 22 22:13:35 2012 -0600
@@ -52,6 +52,7 @@
 *    B  = error code
 *
 Init      
+		stu		>D.KbdSta  store devmem ptr
 		pshs	u
 
 * setup static vars
@@ -95,11 +96,21 @@
  		sta	DMACTL
 
 * tell ANTIC to enable characters
-		lda	#$01
+		lda	#$02
  		sta	CHACTL
- 		
+
+* install keyboard ISR
+		leay	IRQSvc,pcr
+		leax	IRQPkt,pcr
+		ldu	,s
+		os9	F$IRQ
+		bcs	initex
+		
+* tell POKEY to enale keyboard scanning
+		sta	SKCTL
+
 		clrb
-		puls	u,pc
+initex	puls	u,pc
   
 * Term
 *
@@ -125,10 +136,38 @@
 *    CC = carry set on error
 *    B  = error code
 *
-Read                     
-		clrb
-		rts             
+Read          
+         leax  V.InBuf,u  point X to input buffer
+         ldb   V.IBufT,u  get tail pointer
+         orcc  #IRQMask   mask IRQ
+         cmpb  V.IBufH,u  same as head pointer
+         beq   Put2Bed    if so, buffer is empty, branch to sleep
+         abx              X now points to curr char
+         lda   ,x         get char
+         bsr   cktail     check for tail wrap
+         stb   V.IBufT,u  store updated tail
+         andcc  #^(IRQMask+Carry) unmask IRQ
+         rts             
                          
+Put2Bed  lda   V.BUSY,u   get calling process ID
+         sta   V.WAKE,u   store in V.WAKE
+         andcc  #^IRQMask  clear interrupts
+         ldx   #$0000    
+         os9   F$Sleep    sleep forever
+         clr   V.WAKE,u   clear wake
+         ldx   <D.Proc    get pointer to current proc desc
+         ldb   <P$Signal,x get signal recvd
+         beq   Read       branch if no signal
+         cmpb  #S$Window  window signal?
+         bcc   Read       branch if so
+         coma            
+         rts             
+* Check if we need to wrap around tail pointer to zero
+cktail   incb             increment pointer
+         cmpb  #$7F       at end?
+         bls   readex     branch if not
+         clrb             else clear pointer (wrap to head)
+readex   rts                                      
 
 * Write
 *
@@ -144,6 +183,15 @@
 Write
 		cmpa		#C$CR
 		bne		checklf
+		lda		V.CurRow,u
+		ldb		#Cols
+		mul
+		addb		V.CurCol,u
+		adca		#0
+		ldx		#ScrStart
+		leax		d,x
+		lda		#C$SPAC-$20
+		sta		,x
 		clr		V.CurCol,u
 		clrb
 		rts
@@ -171,9 +219,24 @@
 		clrb
 incrow
 		inca
-		cmpa		#24
+		cmpa		#Rows
 		blt		clrrow
+SCROLL	equ		1
+		IFNE		SCROLL
+		deca						set A to Rows - 1
+		pshs		d				save off Row/Col
+		ldx		#ScrStart			get start of screen memory
+		ldy		#Cols*(Rows-1)		set Y to size of screen minus last row
+scroll_loop
+		ldd		Cols,x			get two bytes on next row
+		std		,x++				store on this row
+		leay		-2,y				decrement Y
+		bne		scroll_loop		branch if not 0
+		puls		d				recover Row/Col
+		ELSE
 		clra
+		ENDC
+* clear last row
 clrrow	std		V.CurRow,u
 		ldb		#Cols
 		mul
@@ -184,7 +247,17 @@
 		deca
 		bne		clrloop@
 		bra		okex
-ok		std		V.CurRow,u		
+ok		std		V.CurRow,u
+
+		ldb		#Cols
+		mul
+		addb		V.CurCol,u
+		adca		#0
+		ldx		#ScrStart
+		leax		d,x
+		lda		#$80
+		sta		,x
+		
 okex		clrb
 		rts             
                          
@@ -230,6 +303,86 @@
 		rts             
 
 	
+IRQPkt	equ	*
+Pkt.Flip	fcb	$80		flip byte
+Pkt.Mask 	fcb	$81		mask byte
+		fcb 	$0A		priority
+	
+*
+* IRQ routine for keyboard
+*
+IRQSvc                   
+		ldb	KBCODE
+		leax	ATASCI,pcr
+		lda	b,x
+		ldb	V.IBufH,u  get head pointer in B
+		leax	V.InBuf,u  point X to input buffer
+		abx              X now holds address of head
+		lbsr	cktail      check for tail wrap
+		cmpb	V.IBufT,u  B at tail?
+		beq	L012F      branch if so
+		stb	V.IBufH,u 
+L012F	sta	,x         store our char at ,X
+		beq	WakeIt     if nul, do wake-up
+		cmpa	V.PCHR,u   pause character?
+		bne	L013F      branch if not
+		ldx	V.DEV2,u   else get dev2 statics
+		beq	WakeIt     branch if none
+		sta	V.PAUS,x   else set pause request
+		bra	WakeIt    
+L013F	ldb	#S$Intrpt  get interrupt signal
+		cmpa	V.INTR,u   our char same as intr?
+		beq	L014B      branch if same
+		ldb	#S$Abort   get abort signal
+		cmpa	V.QUIT,u   our char same as QUIT?
+		bne	WakeIt     branch if not
+L014B	lda	V.LPRC,u   get ID of last process to get this device
+		bra	L0153      go for it
+WakeIt	ldb	#S$Wake    get wake signal
+		lda	V.WAKE,u   get process to wake
+L0153	beq	L0158      branch if none
+		os9	F$Send     else send wakeup signal
+L0158	clr	V.WAKE,u   clear process to wake flag
+		rts
+		
+ATASCI	fcb	$6C,$6A,$3B,$80,$80,$6B,$2B,$2A ;LOWER CASE
+		fcb	$6F,$80,$70,$75,$9B,$69,$2D,$3D
+
+		fcb	$76,$80,$63,$80,$80,$62,$78,$7A
+		fcb	$34,$80,$33,$36,$1B,$35,$32,$31
+
+		fcb	$2C,$20,$2E,$6E,$80,$6D,$2F,$81
+		fcb	$72,$80,$65,$79,$7F,$74,$77,$71
+
+		fcb	$39,$80,$30,$37,$7E,$38,$3C,$3E
+		fcb	$66,$68,$64,$80,$82,$67,$73,$61
+
+
+		fcb	$4C,$4A,$3A,$80,$80,$4B,$5C,$5E ;UPPER CASE
+		fcb	$4F,$80,$50,$55,$9B,$49,$5F,$7C
+
+		fcb	$56,$80,$43,$80,$80,$42,$58,$5A
+		fcb	$24,$80,$23,$26,$1B,$25,$22,$21
+
+		fcb	$5B,$20,$5D,$4E,$80,$4D,$3F,$81
+		fcb	$52,$80,$45,$59,$9F,$54,$57,$51
+
+		fcb	$28,$80,$29,$27,$9C,$40,$7D,$9D
+		fcb	$46,$48,$44,$80,$83,$47,$53,$41
+
+
+		fcb	$0C,$0A,$7B,$80,$80,$0B,$1E,$1F ;CONTROL
+		fcb	$0F,$80,$10,$15,$9B,$09,$1C,$1D
+
+		fcb	$16,$80,$03,$80,$80,$02,$18,$1A
+		fcb	$80,$80,$85,$80,$1B,$80,$FD,$80
+
+		fcb	$00,$20,$60,$0E,$80,$0D,$80,$81
+		fcb	$12,$80,$05,$19,$9E,$14,$17,$11
+
+		fcb	$80,$80,$80,$80,$FE,$80,$7D,$FF
+		fcb	$06,$08,$04,$80,$84,$07,$13,$01
+        
 		emod            
 eom		equ	*
 		end             
--- a/level1/modules/kernel/krn.asm	Wed Feb 22 10:24:04 2012 -0600
+++ b/level1/modules/kernel/krn.asm	Wed Feb 22 22:13:35 2012 -0600
@@ -88,69 +88,6 @@
 name     fcs   /Krn/
          fcb   edition
 
-InitNam  fcs   /Init/
-
-P2Nam    fcs   /krnp2/
-
-VectCode bra   SWI3Jmp		$0100
-         nop
-         bra   SWI2Jmp		$0103
-         nop
-         bra   SWIJmp		$0106
-         nop
-         bra   NMIJmp		$0109
-         nop
-         bra   IRQJmp		$010C
-         nop
-         bra   FIRQJmp		$010F
-
-SWI3Jmp  jmp   [>D.SWI3]
-SWI2Jmp  jmp   [>D.SWI2]
-SWIJmp   jmp   [>D.SWI]
-NMIJmp   jmp   [>D.NMI]
-IRQJmp   jmp   [>D.IRQ]
-FIRQJmp  jmp   [>D.FIRQ]
-VectCSz  equ   *-VectCode
-
-
-SysTbl   fcb   F$Link
-         fdb   FLink-*-2
-         fcb   F$Fork
-         fdb   FFork-*-2
-         fcb   F$Chain
-         fdb   FChain-*-2
-         fcb   F$Chain+SysState
-         fdb   SFChain-*-2
-         fcb   F$PrsNam
-         fdb   FPrsNam-*-2
-         fcb   F$CmpNam
-         fdb   FCmpNam-*-2
-         fcb   F$SchBit
-         fdb   FSchBit-*-2
-         fcb   F$AllBit
-         fdb   FAllBit-*-2
-         fcb   F$DelBit
-         fdb   FDelBit-*-2
-         fcb   F$CRC
-         fdb   FCRC-*-2
-         fcb   F$SRqMem+SysState
-         fdb   FSRqMem-*-2
-         fcb   F$SRtMem+SysState
-         fdb   FSRtMem-*-2
-         fcb   F$AProc+SysState
-         fdb   FAProc-*-2
-         fcb   F$NProc+SysState
-         fdb   FNProc-*-2
-         fcb   F$VModul+SysState
-         fdb   FVModul-*-2
-         fcb   F$SSvc
-         fdb   FSSvc-*-2
-         fcb   $80
-
-         IFNE  H6309
-Zoro     fcb   $00
-         ENDC
-
 *
 * OS-9 Genesis!
 
@@ -160,6 +97,7 @@
 * Currently NitrOS-9 is in ROM on the Atari.
 * Since the Liber809 is coming here directly from reset,
 * we will be good and get the hardware initialized properly.
+		lds #$1000
 		lbsr	InitAtari
          ENDC
          
@@ -244,28 +182,21 @@
          puls  y,x
 
          IFNE  atari
-         ldx   #$D800                  skip $C000-$D7FF for now...
+* for some reason, we need to increment X from $C000 to $C001.  If we do not
+* do this, then the screen background color goes to black at random resets??
+*         leax	1,x			
+         ldy   #$D000
+         ELSE
+         ldy	#Bt.Start+Bt.Size
          ENDC
          
-* Validate modules at top of RAM (kernel, etc.)
-L00DB    lbsr  ValMod
-         bcs   L00E6
-         ldd   M$Size,x
-         leax  d,x                     go past module
-         bra   L00EC
-L00E6    cmpb  #E$KwnMod
-         beq   L00EE
-         leax  1,x
-
-L00EC
+         lbsr	ValMods
          IFNE  atari
-         cmpx  #$FF00
-         ELSE
-* Modification to stop scan into I/O space -- Added by BGP
-         cmpx  #Bt.Start+Bt.Size
+         ldx   #$D800				
+         ldy   #$FF00
+         lbsr	ValMods
          ENDC
-         bcs   L00DB
-
+         
 * Copy vectors to system globals
 L00EE    leay  >Vectors,pcr
          leax  >ModTop,pcr
@@ -349,7 +280,8 @@
 SWI2     pshs  pc,x,b
          ldb   #P$SWI2
          bra   L018C
-DUMMY    rti
+SVCNMI	jmp	[>D.IRQ]
+DUMMY	rti
 SVCIRQ   jmp   [>D.SvcIRQ]
 SWI      pshs  pc,x,b
          ldb   #P$SWI
@@ -612,9 +544,10 @@
          puls  y
          stu   R$U,y
          rts
+
 * X = address of module to validate
 ValMod   bsr   ChkMHCRC
-         bcs   L039A
+         bcs   ValModEx
          lda   M$Type,x
          pshs  x,a
          ldd   M$Name,x
@@ -622,10 +555,10 @@
          puls  a
          lbsr  L0443
          puls  x
-         bcs   L039B
+         bcs   ValLea
          ldb   #E$KwnMod
          cmpx  ,u
-         beq   L03A1
+         beq   errex@
          lda   M$Revs,x
          anda  #RevsMask
          pshs  a
@@ -633,13 +566,13 @@
          lda   M$Revs,y
          anda  #RevsMask
          cmpa  ,s+                     same revision as other mod?
-         bcc   L03A1
+         bcc   errex@
          pshs  y,x
          ldb   M$Size,u
-         bne   L0395
+         bne   ValPul
          ldx   ,u
          cmpx  <D.BTLO
-         bcc   L0395
+         bcc   ValPul
          ldd   $02,x
          addd  #$00FF
          tfr   a,b
@@ -649,29 +582,29 @@
          ldx   <D.FMBM
          os9   F$DelBit
          clr   $02,u
-L0395    puls  y,x
-L0397    stx   ,u
+ValPul   puls  y,x
+ValSto   stx   ,u
          clrb
-L039A    rts
-L039B    leay  ,u
-         bne   L0397
+ValModEx rts
+ValLea   leay  ,u
+         bne   ValSto
          ldb   #E$DirFul
-L03A1    coma
+errex@   coma
          rts
 
 * check module header and CRC
 * X = address of potential module
 ChkMHCRC ldd   ,x
          cmpd  #M$ID12                 sync bytes?
-         bne   L03B1                   nope, not a module here
+         bne   ChkMHEx                nope, not a module here
          leay  M$Parity,x
          bsr   ChkMHPar                check header parity
-         bcc   L03B5                   branch if ok
-L03B1    comb
+         bcc   Chk4CRC                 branch if ok
+ChkMHEx  comb
          ldb   #E$BMID
          rts
 
-L03B5
+Chk4CRC
 * Following 4 lines added to support no CRC checks - 2002/07/21
          lda   <D.CRC			is CRC checking on?
          bne   DoCRCCk			branch if so
@@ -682,6 +615,7 @@
          ldy   M$Size,x
          bsr   ChkMCRC                 checkm module CRC
          puls  pc,x
+         
 * check module header parity
 * Y = pointer to parity byte
 ChkMHPar pshs  y,x
@@ -1120,9 +1054,23 @@
 
 		use   fssvc.asm
 
-          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
-          fcb  $39,$39
-          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
+* Validate modules subroutine
+* Entry: X = address to start searching
+*	    Y = address to stop (actually stops at Y-1)
+ValMods	pshs	y
+valloop@	lbsr	ValMod
+		bcs	valerr
+		ldd	M$Size,x
+		leax	d,x                     go past module
+		bra	valcheck
+valerr	cmpb	#E$KwnMod
+		beq	valret
+		leax	1,x
+valcheck	cmpx	,s
+		bcs	valloop@
+valret	puls  y,pc
+
+          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
           fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
           fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
           fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
@@ -1173,13 +1121,70 @@
          sta   $D20F
 		rts
 		
-          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
-          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
-          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
-          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
-          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
-          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
-          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
+VectCode bra   SWI3Jmp		$0100
+         nop
+         bra   SWI2Jmp		$0103
+         nop
+         bra   FIRQJmp		$0106
+         nop
+         bra   IRQJmp		$0109
+         nop
+         bra   SWIJmp		$010C
+         nop
+         bra   NMIJmp		$010F
+
+SWI3Jmp  jmp   [>D.SWI3]
+SWI2Jmp  jmp   [>D.SWI2]
+FIRQJmp  jmp   [>D.FIRQ]
+IRQJmp   jmp   [>D.IRQ]
+SWIJmp   jmp   [>D.SWI]
+NMIJmp   jmp   [>D.NMI]
+VectCSz  equ   *-VectCode
+
+
+SysTbl   fcb   F$Link
+         fdb   FLink-*-2
+         fcb   F$Fork
+         fdb   FFork-*-2
+         fcb   F$Chain
+         fdb   FChain-*-2
+         fcb   F$Chain+SysState
+         fdb   SFChain-*-2
+         fcb   F$PrsNam
+         fdb   FPrsNam-*-2
+         fcb   F$CmpNam
+         fdb   FCmpNam-*-2
+         fcb   F$SchBit
+         fdb   FSchBit-*-2
+         fcb   F$AllBit
+         fdb   FAllBit-*-2
+         fcb   F$DelBit
+         fdb   FDelBit-*-2
+         fcb   F$CRC
+         fdb   FCRC-*-2
+         fcb   F$SRqMem+SysState
+         fdb   FSRqMem-*-2
+         fcb   F$SRtMem+SysState
+         fdb   FSRtMem-*-2
+         fcb   F$AProc+SysState
+         fdb   FAProc-*-2
+         fcb   F$NProc+SysState
+         fdb   FNProc-*-2
+         fcb   F$VModul+SysState
+         fdb   FVModul-*-2
+         fcb   F$SSvc
+         fdb   FSSvc-*-2
+         fcb   $80
+
+         IFNE  H6309
+Zoro     fcb   $00
+         ENDC
+
+InitNam  fcs   /Init/
+
+P2Nam    fcs   /krnp2/
+
+          fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
           fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
           fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
           fcb  $39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39,$39
@@ -1196,15 +1201,15 @@
          fdb   DUMMY                   FIRQ
          fdb   SVCIRQ                  IRQ
          fdb   SWI                     SWI
-         fdb   DUMMY                   NMI
+         fdb   SVCNMI                  NMI
          IFNE  atari
-         fdb   $0000
-		 fdb   $0100
-		 fdb   $0103
-		 fdb   $0106
-		 fdb   $0109
-		 fdb   $010C
-		 fdb   $010F
+         fdb   $0000				RESERVED
+		 fdb   $0100				SWI3
+		 fdb   $0103				SWI2
+		 fdb   $0106				FIRQ
+		 fdb   $0109				IRQ
+		 fdb   $010C				SWI
+		 fdb   $010F				NMI
          IFP2
          fdb   $10000-eomem+OS9Cold                 RESET         
          ELSE