changeset 1846:7a973074acbe

Fixed makefile error for dskcopy target
author boisy
date Fri, 24 Jun 2005 17:24:07 +0000
parents d20130550ce5
children 6e51e709faf3
files level2/modules/cc3io.asm level2/modules/joydrv_6551L.asm level2/modules/joydrv_6551M.asm level2/modules/joydrv_6552M.asm
diffstat 4 files changed, 427 insertions(+), 294 deletions(-) [+]
line wrap: on
line diff
--- a/level2/modules/cc3io.asm	Tue Jun 21 00:24:19 2005 +0000
+++ b/level2/modules/cc3io.asm	Fri Jun 24 17:24:07 2005 +0000
@@ -3,6 +3,11 @@
 * 
 * $Id$
 * 
+* NOTE:  CODE ISSUES FOUND!!
+* "Animate Palette?  This obviously isn't implemented yet"
+* Look at this code.  Why is this calling an entry point in
+* SNDDRV???
+*
 * Edt/Rev  YYYY/MM/DD  Modified by
 * Comment
 * ------------------------------------------------------------------
@@ -101,11 +106,11 @@
          puls  cc		restore IRQs
 
          pshs  u,x
-         ldx   #(WGlobal+G.JoyEnt) $10EA
+         ldx   #(WGlobal+G.JoyEnt)
          bsr   TermSub
-         ldx   #(WGlobal+G.SndEnt) $10F4
+         ldx   #(WGlobal+G.SndEnt)
          bsr   TermSub
-         ldx   #(WGlobal+G.KeyEnt) $10E0
+         ldx   #(WGlobal+G.KeyEnt)
          bsr   TermSub
          puls  u,x
 noterm   ldb   #$0C		branch table offset for terminate
@@ -668,26 +673,26 @@
          beq   L0381			no, try joystick
          ldx   >WGlobal+G.KeyEnt	else get ptr to keydrv
          leau  >G.KeyMem,u		and ptr to its statics
-         jsr   $06,x			call into it
+         jsr   K$FnKey,x		call into it
          ldu   <D.CCMem			get ptr to CC mem
          sta   <G.KyButt,u		save key button
 L0381    ldx   >WGlobal+G.JoyEnt	get ptr to joydrv
          leau  >G.JoyMem,u		and ptr to its statics
-         jsr   $06,x			get X/Y info
+         jsr   J$MsBtn,x		get mouse button info
          ldu   <D.CCMem			get ptr to CC mem
-         lda   #$82
-         cmpb  #$80
-         beq   L0397
-         inca  
-         cmpb  #$C0
-         bne   L039C
+         lda   #%10000010		A = $82
+         cmpb  #%10000000		clear flag set?
+         beq   L0397			branch if so
+         inca  				A now = $83
+         cmpb  #%11000000		shift clear flag set?
+         bne   L039C			branch if not
 L0397    inc   <G.Clear,u
          bra   L03C8
-L039C    tst   $08,y
-         bpl   L03A8
-         bitb  #$03
-         beq   L03A8
-         lda   #$0D
+L039C    tst   V.PAUS,y			pause screen on?
+         bpl   L03A8			branch if not
+         bitb  #%00000011		any mouse buttons down?
+         beq   L03A8			branch if not
+         lda   #C$CR			load A with carriage return
          bra   L03C8
 L03A8    lda   <G.KyButt,u
          lbsr  L0229
@@ -696,10 +701,10 @@
          pshs  u,y,x
          ldx   >WGlobal+G.KeyEnt
          leau  >G.KeyMem,u
-         jsr   $09,x			call Read Key routine
+         jsr   K$RdKey,x		call Read Key routine
          puls  u,y,x
-         bpl   L03C8
-         clr   <G.LastCh,u
+         bpl   L03C8			branch if valid char received
+         clr   <G.LastCh,u		else clear last character var
          lbra  L044E
 L03C8    cmpa  <G.LastCh,u	is current ASCII code same as last one pressed?
          bne   L03DF		no, no keyboard repeat, skip ahead
@@ -1170,11 +1175,11 @@
          rts   			return
 
 * Get button status first
-GetJoy   ldx   >WGlobal+G.JoyEnt $10EA
+GetJoy   ldx   >WGlobal+G.JoyEnt
          pshs  u		save driver static
          ldu   <D.CCMem		get ptr to CC mem
          leau  >G.JoyMem,u	point to subroutine module's static mem
-         jsr   $0C,x		call entry point to get button
+         jsr   J$JyBtn,x	call entry point to get button
 * Joysticks button states returned in B
          puls  u		restore driver static
          lda   R$X+1,y		left or right?
@@ -1194,9 +1199,9 @@
          ldy   #$0000   force low res??
          pshs  u		save driver static mem
          ldu   <D.CCMem		get ptr to CC mem
-         ldx   >WGlobal+G.JoyEnt $10EA get address of joystick sub module
+         ldx   >WGlobal+G.JoyEnt get address of joystick sub module
          leau  >G.JoyMem,u	get ptr to sub module's static mem
-         jsr   $0F,x		call routine in sub module to get joy X/Y
+         jsr   J$JyXY,x		call routine in sub module to get joy X/Y
 * X = joystick X pos, Y = joystick Y pos
          puls  u		restore driver static mem
          pshs  y		save joystick Y
@@ -1262,10 +1267,10 @@
          tfr   d,y		move mouse res to Y
          lda   Pt.Actv,x	get mouse side
          pshs  u,y,x,b,a	preserve regs
-         ldx   >WGlobal+G.JoyEnt $10EA get ptr to mouse sub module
+         ldx   >WGlobal+G.JoyEnt get ptr to mouse sub module
          ldu   <D.CCMem		get mem pointer
          leau  >G.JoyMem,u	and point to mouse sub module statics
-         jsr   $09,x		get data
+         jsr   J$MsXY,x		get data
          pshs  y,x
          ldx   $06,s		get ptr to mouse packet in CC mem
          puls  b,a		get X value into D
@@ -1282,12 +1287,12 @@
          sta   <(G.MseMv-G.Mouse),x	update mouse moved flag
 L0770    rts   
 
-SSTone   ldx   >WGlobal+G.SndEnt $10F4 get address of sound sub module
-         jmp   $06,x		go execute routine in sub module
+SSTone   ldx   >WGlobal+G.SndEnt get address of sound sub module
+         jmp   S$SetStt,x	go execute routine in sub module
 
 * Animate Palette?  This obviously isn't implemented yet
-SSAnPal  ldx   >WGlobal+G.SndEnt $10F4
-         jmp   $09,x
+SSAnPal  ldx   >WGlobal+G.SndEnt
+         jmp   S$Term,x
 
 * SetStat    
 *
--- a/level2/modules/joydrv_6551L.asm	Tue Jun 21 00:24:19 2005 +0000
+++ b/level2/modules/joydrv_6551L.asm	Fri Jun 24 17:24:07 2005 +0000
@@ -3,111 +3,126 @@
 *
 * $Id$
 *
-* Ed.    Comments                                       Who YY/MM/DD
+* Edt/Rev  YYYY/MM/DD  Modified by
+* Comment
 * ------------------------------------------------------------------
-* 6      L2 Upgrade distribution version
-
-         nam   JoyDrv
+*   6      1988/??/??
+* L2 Upgrade distribution version.
+*
+*   6r1    2005/04/25  Boisy G. Pitre
+* Fixed error where wrong branch was taken.
+                         
+         nam   JoyDrv    
          ttl   Joystick Driver for 6551/Logitech Mouse
-
+                         
 * Disassembled 98/09/09 09:22:44 by Disasm v1.6 (C) 1988 by RML
-
-         ifp1  
-         use   defsfile
-         use   l51.defs
-         endc  
-
+                         
+         ifp1            
+         use   defsfile  
+         use   l51.defs  
+         endc            
+                         
 tylg     set   Systm+Objct
-atrv     set   ReEnt+rev
+atrv     set   ReEnt+rev 
 rev      set   $01
-edition  set   6
-
-MPISlot  set   $00
-
+edition  set   6         
+                         
+MPISlot  set   $00       
+                         
          mod   eom,name,tylg,atrv,start,$FF68
-
-name     fcs   /JoyDrv/
-         fcb   edition
-
-SlotSlct equ   MPISlot
-
-start    lbra  Init
-         lbra  Term
-         lbra  SSMsBtn
-         lbra  SSMsXY
-         lbra  SSJoyBtn
-
-SSJoyXY  pshs  x,b,a
-         ldx   #PIA0Base
-         lda   <$23,x
-         ldb   <$20,x
-         pshs  b,a
-         anda  #$F7
-         sta   <$23,x
-         lda   $01,x
-         ldb   $03,x
-         pshs  b,a
-         andb  #$F7
-         lsr   $04,s
-         bcs   L0043
-         orb   #$08
-L0043    stb   $03,x
-         lda   ,s
-         ora   #$08
-         bsr   L0065
-         std   $06,s
-         lda   ,s
-         anda  #$F7
-         bsr   L0065
-         std   $04,s
-         puls  b,a
-         sta   $01,x
-         stb   $03,x
-         puls  b,a
-         stb   <$20,x
-         sta   <$23,x
-         puls  pc,y,x
-L0065    sta   $01,x
-         lda   #$7F
-         ldb   #$40
-         bra   L0078
-L006D    lsrb  
-         cmpb  #$01
-         bhi   L0078
-         lsra  
-         lsra  
-         tfr   a,b
-         clra  
-         rts   
-L0078    pshs  b
-         sta   <$20,x
-         tst   ,x
-         bpl   L0085
-         adda  ,s+
-         bra   L006D
-L0085    suba  ,s+
-         bra   L006D
-
-IRQPckt  equ   *
+                         
+name     fcs   /JoyDrv/  
+         fcb   edition   
+                         
+SlotSlct equ   MPISlot   
+                         
+start    lbra  Init      
+         lbra  Term      
+         lbra  SSMsBtn   
+         lbra  SSMsXY    
+         lbra  SSJoyBtn  
+                         
+SSJoyXY  pshs  x,b,a     
+         ldx   #PIA0Base 
+         lda   <$23,x    
+         ldb   <$20,x    
+         pshs  b,a       
+         anda  #$F7      
+         sta   <$23,x    
+         lda   $01,x     
+         ldb   $03,x     
+         pshs  b,a       
+         andb  #$F7      
+         lsr   $04,s     
+         bcs   L0043     
+         orb   #$08      
+L0043    stb   $03,x     
+         lda   ,s        
+         ora   #$08      
+         bsr   L0065     
+         std   $06,s     
+         lda   ,s        
+         anda  #$F7      
+         bsr   L0065     
+         std   $04,s     
+         puls  b,a       
+         sta   $01,x     
+         stb   $03,x     
+         puls  b,a       
+         stb   <$20,x    
+         sta   <$23,x    
+         puls  pc,y,x    
+L0065    sta   $01,x     
+         lda   #$7F      
+         ldb   #$40      
+         bra   L0078     
+L006D    lsrb            
+         cmpb  #$01      
+         bhi   L0078     
+         lsra            
+         lsra            
+         tfr   a,b       
+         clra            
+         rts             
+L0078    pshs  b         
+         sta   <$20,x    
+         tst   ,x        
+         bpl   L0085     
+         adda  ,s+       
+         bra   L006D     
+L0085    suba  ,s+       
+         bra   L006D     
+                         
+IRQPckt  equ   *         
 Pkt.Flip fcb   Stat.Flp   D.Poll flip byte
 Pkt.Mask fcb   Stat.Msk   D.Poll mask byte
          fcb   $01        priority
-
-Init     clra
-         clrb 
+                         
+***
+* JoyDrv Initialization.
+*
+* INPUT:  U = JoyDrv data area address (8 bytes)
+*
+* OUTPUT:  IRQ service entry installed
+*          D, X, and U registers may be altered
+*
+* ERROR OUTPUT:  CC = Carry set
+*                B = error code
+Init     clra            
+         clrb            
          sta   Btn.Cntr,u set up Rx data sync, no button(s) pressed
          std   CrntXPos,u set up X position at left screen edge
          ldd   #HResMaxY*2
          std   CrntYPos,u set up Y position at top screen edge
-         ldd   M$Mem,pcr get base hardware address
+         ldd   M$Mem,pcr  get base hardware address
          addd  #StatReg   status register address
          leax  IRQPckt,pcr
          leay  IRQSvc,pcr
-         os9   F$IRQ
-         bcs   InitExit   go report error...
-         ldx   M$Mem,pcr get base hardware address again
+         os9   F$IRQ     
+         bcs   TermExit   go report error...
+         ldx   M$Mem,pcr  get base hardware address again
          ldd   #(TIC.RTS!Cmd.DTR)*256+(DB.8!Ctl.RClk!BR.01200) [D]=command:control
-         pshs  cc
+         pshs  cc        
          orcc  #IntMasks  disable IRQs while setting up hardware
          sta   PRstReg,x  reset 6551
          std   CmdReg,x   set command and control registers
@@ -128,55 +143,104 @@
          lda   SlotSlct,pcr get MPI slot select value
          bmi   InitExit   no MPI slot select, go exit...
          sta   >MPI.Slct  set MPI slot select register
-         puls  pc,cc recover original regs, return...
-
+* BUG FIX: InitExit is now here... was TermExit... 
+InitExit puls  pc,cc      recover original regs, return...
+                         
+***
+* JoyDrv Termination.
+*
+* INPUT:  U = JoyDrv data area address (8 bytes)
+*
+* OUTPUT:  IRQ service entry removed
+*          D, X, and U registers may be altered
+*
+* ERROR OUTPUT:  CC = Carry set
+*                B = error code
 Term     pshs  cc         save regs we alter
          orcc  #IntMasks  mask IRQs while disabling ACIA
 InitErr  ldx   M$Mem,pcr  get base address
          lda   #TIC.RTS!Cmd.RxIE!Cmd.DTR *disable all
          sta   CmdReg,x   *ACIA IRQs
-         puls  cc
+         puls  cc        
          leax  StatReg,x  point to status register
          tfr   x,d        copy status register address
          ldx   #$0000     remove IRQ table entry
          leay  IRQSvc,pcr
-         os9   F$IRQ
-InitExit rts
-
-SSJoyBtn ldb   #$FF
-         ldx   #PIA0Base
+         os9   F$IRQ     
+TermExit rts             
+                         
+***
+* Joystick button(s) status check.
+*
+* INPUT:  U = JoyDrv data area address (8 bytes)
+*
+* OUTPUT:  B = button or "clear" status
+*              button(s)     = xxxxLRLR
+*          A, X, and U registers may be altered
+*
+* ERROR OUTPUT:  none
+SSJoyBtn ldb   #$FF      
+         ldx   #PIA0Base 	check for standard joystick/mouse fire buttons
          stb   $02,x
-         ldb   ,x
-         comb  
-         andb  #$0F
-         rts   
-
-SSMsBtn  pshs  cc
-         orcc  #IntMasks
+         ldb   ,x        		
+         comb            	set == button pressed
+         andb  #$0F      
+         rts             
+                         
+***
+* Mouse button(s) status check.
+*
+* INPUT:  U = JoyDrv data area address (8 bytes)
+*
+* OUTPUT:  B = button or "clear" status
+*              button(s)     = xxxxLRLR
+*              clear         = 10000000
+*              shift-clear   = 11000000
+*          A, X, and U registers may be altered
+*
+* ERROR OUTPUT:  none
+SSMsBtn  pshs  cc        
+         orcc  #IntMasks 		mask interrupts
          lda   ,u
-         tfr   a,b
-         andb  #$C0
-         bne   L0120
-         bita  #$20
-         beq   L011A
-         orb   #$03
-L011A    bita  #$10
-         beq   L0120
-         orb   #$0C
-L0120    anda  #$3F
-         sta   ,u
-         puls  pc,cc
-
-SSMsXY   ldd   #$017E
-         pshs  cc
-         orcc  #IntMasks
+         tfr   a,b       
+         andb  #%11000000		mask SHIFT-CLEAR
+         bne   L0120     
+         bita  #%00100000		????
+         beq   L011A     
+         orb   #%00000011
+L011A    bita  #%00010000
+         beq   L0120     
+         orb   #%00001100
+L0120    anda  #%00111111		turn off SHIFT-CLEAR flag
+         sta   ,u        
+         puls  pc,cc     
+                         
+***
+* Joystick/Mouse XY coordinate read.
+* 
+* INPUT:  A = side flag (1 = right, 2 = left)
+*         Y = resolution (0 = low, 1 = high)
+*         U = JoyDrv data area address (8 bytes)
+* 
+* OUTPUT:  X = horizontal coordinate (left edge = 0)
+*              low resolution = 0 to 63
+*              high resolution = 0 to HResMaxX 
+*          Y = vertical coordinate (top edge = 0)
+*              low resolution = 0 to 63
+*              high resolution = 0 to HResMaxY
+*          D and U registers may be altered
+* 
+* ERROR OUTPUT:  none
+SSMsXY   ldd   #$017E    
+         pshs  cc        
+         orcc  #IntMasks 
          ldx   CrntXPos,u
          subd  CrntYPos,u
-         lsra  
-         rorb  
-         tfr   d,y
-         puls  pc,cc
-
+         lsra            
+         rorb            
+         tfr   d,y       
+         puls  pc,cc     
+                         
 ***
 * Mouse IRQ service routine.
 *
@@ -188,7 +252,7 @@
 *          D, X, Y, and U registers may be altered
 *
 * ERROR OUTPUT:  none
-IRQSvc   ldx   M$Mem,pcr
+IRQSvc   ldx   M$Mem,pcr 
          bita  #Stat.Err  any error(s)?
          beq   ChkRDRF    no, go check Rx data
          ldb   DataReg,x  read Rx data register to clear error flags
@@ -196,8 +260,8 @@
          anda  #^BC.RxCnt clear Rx data counter
 ButnExit sta   Btn.Cntr,u reset Rx mouse data counter to wait for sync...
 IRQExit  clrb             clear Carry to mark IRQ serviced
-         rts   
-
+         rts             
+                         
 ChkRDRF  bita  #Stat.RxF  Rx data?
          beq   IRQExit    no, but this branch should never be taken...
          ldb   DataReg,x  get Rx data
@@ -214,19 +278,19 @@
          lslb             *bits 5-3
          andb  #BC.Butns  clear everything but the button bits
          incb             set Rx counter to first XY position byte
-         pshs  b
-         lda   ,u
-         bita  #$08
-         beq   L017A
-         bitb  #$08
-         bne   L017A
-         lda   #$C0
+         pshs  b         
+         lda   ,u        
+         bita  #$08      
+         beq   L017A     
+         bitb  #$08      
+         bne   L017A     
+         lda   #$C0      
          ldx   CrntXPos,u
-         cmpx  #$0140
-         bcs   L017A
-         lsla
-L017A    anda  #$C0
-         ora   ,s+
+         cmpx  #$0140    
+         bcs   L017A     
+         lsla            
+L017A    anda  #$C0      
+         ora   ,s+       
          bra   ButnExit   go save new button status and Rx counter, exit...
 ChkOfst  cmpa  #PcktSize-1 last byte in mouse packet?
          bcs   SaveData   no, go save mouse data to Rx buffer...
@@ -246,8 +310,8 @@
 SaveData stb   a,u        save XY position byte to mouse data Rx buffer
          inc   Btn.Cntr,u point to next byte in Rx buffer
          clrb             clear Carry to mark IRQ serviced
-         rts   
-
+         rts             
+                         
 CalcPos  sex              sign extend mouse packet's 2nd XY offset ([D] = -128 to +127)
          pshs  d          save it temporarily...
          ldb   ,y         get mouse packet's 1st XY offset
@@ -270,8 +334,8 @@
          bls   SavePos    no, go save it...
          ldd   2,s        get maximum XY position
 SavePos  std   ,x         save new XY position
-         rts   
-
-         emod  
-eom      equ   *
-         end   
+         rts             
+                         
+         emod            
+eom      equ   *         
+         end             
--- a/level2/modules/joydrv_6551M.asm	Tue Jun 21 00:24:19 2005 +0000
+++ b/level2/modules/joydrv_6551M.asm	Fri Jun 24 17:24:07 2005 +0000
@@ -14,10 +14,9 @@
 
 * Disassembled 98/09/09 09:50:25 by Disasm v1.6 (C) 1988 by RML
 
-MPI      set   1
-
          ifp1
          use   defsfile
+         use   m51.defs
          endc
 
 tylg     set   Systm+Objct   
@@ -25,23 +24,15 @@
 rev      set   $00
 edition  set   6
 
-         mod   eom,name,tylg,atrv,start,size
+MPISlot  set   $00
 
-u0000    rmb   2
-u0002    rmb   1
-u0003    rmb   2
-u0005    rmb   1
-u0006    rmb   1
-u0007    rmb   8
-u000F    rmb   113
-u0080    rmb   18
-u0092    rmb   21
-u00A7    rmb   65217
-size     equ   .
+         mod   eom,name,tylg,atrv,start,$FF68
 
 name     fcs   /JoyDrv/
          fcb   edition
 
+SlotSlct equ   MPISlot
+
 start    lbra  Init
          lbra  Term
          lbra  SSMsBtn
@@ -98,61 +89,92 @@
          bra   L006D
 L0085    suba  ,s+
          bra   L006D
-L0089    fcb   $00
-L008A    fcb   $0f,$01
+
+IRQPckt  equ   *
+Pkt.Flip fcb   Stat.Flp	D.Poll filp byte
+Pkt.Mask fcb   Stat.Msk	D.Poll mask byte
+         fcb   $01      priority
+*L0089    fcb   $00
+*L008A    fcb   $0f,$01
 
-Init     fcb   $cc,$00,$07
-          
-L008F    fcb   $a7
-         bitb  #$5A
+***      
+* JoyDrv Initialization.
+*        
+* INPUT:  U = JoyDrv data area address (8 bytes)
+*        
+* OUTPUT:  IRQ service entry installed
+*          D, X, and U registers may be altered
+*        
+* ERROR OUTPUT:  CC = Carry set
+*                B = error code
+Init     ldd   #$0007
+L008F    sta   b,u
+         decb
          bpl   L008F
-         ldd   >M$Mem,pcr
-         addd  #$0001
-         leax  >L0089,pcr
-         leay  >L0152,pcr
+         ldd   >M$Mem,pcr	get base hardware address
+         addd  #StatReg		status register address
+         leax  IRQPckt,pcr
+         leay  IRQSvc,pcr
          os9   F$IRQ    
-         bcs   L00F7
-         ldx   >M$Mem,pcr
-         ldd   #$0938
+         bcs   TermExit		go report error...
+         ldx   >M$Mem,pcr	get base hardware address again
+         ldd   #(TIC.RTS!Cmd.DTR)*256+(DB.8!Ctl.RClk!BR.01200) [D]=command:control
          pshs  cc
-         orcc  #IntMasks
-         sta   $01,x
-         std   $02,x
-         lda   >PIA1Base+3
-         anda  #$FC
-         sta   >PIA1Base+3
-         lda   >PIA1Base+2
-         lda   #$01
-         ora   <u0092
-         sta   <u0092
-         sta   >IrqEnR
-         ldb   ,x
-         ldb   $01,x
-         ldb   ,x
-         ldb   $01,x
-         andb  >L008A,pcr
-         bne   L00DF
+         orcc  #IntMasks	disable IRQs while setting up hardware
+         sta   PRstReg,x	reset 6551
+         std   CmdReg,x		set command and control registers
+         lda   >PIA1Base+3	get PIA CART* input control register
+         anda  #$FC		clear PIA CART* control bits
+         sta   >PIA1Base+3	disable PIA CART* control bits
+         lda   >PIA1Base+2	clear possible pending PIA CART* FIRQ
+         lda   #$01		GIME CART* IRQ enable
+         ora   <D.IRQER		mask in current GIME IRQ enables
+         sta   <D.IRQER		save GIME CART* IRQ enable shadow register
+         sta   >IrqEnR		enable GIME CART* IRQs
+         ldb   DataReg,x	ensure old error,
+         ldb   StatReg,x	Rx data, and
+         ldb   DataReg,x	IRQ flags
+         ldb   StatReg,x	are clear
+         andb  Pkt.Mask,pcr	IRQ bits still set?
+         bne   InitErr		yes, go disable ACIA and return...
+         lda   SlotSlct,pcr	get MPI slot select value
+         bmi   InitExit		no MPI slot select, go exit...
+         sta   >MPI.Slct	recover original regs, return...
+InitExit puls  pc,cc
 
-         ifeq  MPI-1
-         lda   #$03
-         sta   MPI.Slct
-         endc
-
-         puls  pc,cc
+***
+* JoyDrv Termination.
+*
+* INPUT:  U = JoyDrv data area address (8 bytes)
+*
+* OUTPUT:  IRQ service entry removed
+*          D, X, and U registers may be altered
+*
+* ERROR OUTPUT:  CC = Carry set
+*                B = error code
+Term     pshs  cc		save regs we alter
+         orcc  #IntMasks	mask IRQs while disabling ACIA
+InitErr  ldx   M$Mem,pcr	get base address
+         lda   #TIC.RTS!Cmd.RxIE!Cmd.DTR	disable all
+         sta   CmdReg,x		ACIA IRQs
+         puls  cc
+         leax  StatReg,x	point to status register
+         tfr   x,d		copy status register address
+         ldx   #$0000		remove IRQ table entry
+         leay  IRQSvc,pcr
+         os9   F$IRQ    
+TermExit rts   
 
-Term     pshs  cc
-         orcc  #IntMasks
-L00DF    ldx   >M$Mem,pcr
-         lda   #$0B
-         sta   $02,x
-         puls  cc
-         leax  $01,x
-         tfr   x,d
-         ldx   #$0000
-         leay  >L0152,pcr
-         os9   F$IRQ    
-L00F7    rts   
-
+***
+* Joystick button(s) status check.
+*
+* INPUT:  U = JoyDrv data area address (8 bytes)
+*
+* OUTPUT:  B = button or "clear" status
+*              button(s)     = xxxxLRLR
+*          A, X, and U registers may be altered
+*
+* ERROR OUTPUT:  none
 SSJoyBtn ldb   #$FF
          ldx   #PIA0Base
          stb   $02,x
@@ -161,59 +183,100 @@
          andb  #$0F
          rts   
 
-SSMsBtn  lda   ,u
-         clrb  
-         bita  #$20
-         beq   L010E
-         orb   #$03
-L010E    bita  #$10
-         beq   L0114
-         orb   #$0C
-L0114    tfr   b,a
-         anda  #$FA
-         pshs  a
-         andb  #$05
-         orb   u0007,u
+***
+* Mouse button(s) status check.
+*
+* INPUT:  U = JoyDrv data area address (8 bytes)
+*        
+* OUTPUT:  B = button or "clear" status
+*              button(s)     = xxxxLRLR
+*              clear         = 10000000
+*              shift-clear   = 11000000
+*          A, X, and U registers may be altered
+*
+* ERROR OUTPUT:  none
+SSMsBtn  lda   ,u			get byte at ,U
+         clrb  				clear B
+         bita  #$20			A %00100000 bit clear?
+         beq   L010E			branch if so
+         orb   #$03			else set OR B with %00000011
+L010E    bita  #$10			A %00010000 bit clear?
+         beq   L0114			branch if so
+         orb   #$0C			else set OR B with %11000000
+L0114    tfr   b,a			move B to A
+         anda  #$FA			AND A with %11111010
+         pshs  a			save A
+         andb  #$05			AND B with %00000101
+         orb   7,u			OR B with ????
          leax  <L0134,pcr
          lda   b,x
          anda  #$0A
-         sta   u0007,u
+         sta   7,u
          ldb   b,x
          andb  #$85
          bpl   L0131
-         ldb   u0002,u
+         ldb   2,u
          andb  #$C0
 L0131    orb   ,s+
          rts   
 L0134    fdb   $0003,$0003,$0806,$0206,$8002,$0002,$0806,$0a06
 
+***
+* Joystick/Mouse XY coordinate read.
+* 
+* INPUT:  A = side flag (1 = right, 2 = left)
+*         Y = resolution (0 = low, 1 = high)
+*         U = JoyDrv data area address (8 bytes)
+* 
+* OUTPUT:  X = horizontal coordinate (left edge = 0)
+*              low resolution = 0 to 63 
+*              high resolution = 0 to HResMaxX
+*          Y = vertical coordinate (top edge = 0)
+*              low resolution = 0 to 63
+*              high resolution = 0 to HResMaxY
+*          D and U registers may be altered
+*        
+* ERROR OUTPUT:  none           
 SSMsXY   pshs  cc
          orcc  #IntMasks
-         ldx   u0003,u
-         ldd   u0005,u
+         ldx   3,u
+         ldd   5,u
          lsra  
          rorb  
          tfr   d,y
          puls  pc,cc
-L0152    ldx   >M$Mem,pcr
-         bita  #$07
-         beq   L0164
-         ldb   ,x
-L015C    lda   u0002,u
-         anda  #$FC
-L0160    sta   u0002,u
-L0162    clrb  
+
+***      
+* Mouse IRQ service routine.
+*        
+* INPUT:  A = flipped and masked device status byte 
+*         U = mouse data area address
+*
+* OUTPUT:  updated serial mouse data
+*          CC Carry clear
+*          D, X, Y, and U registers may be altered
+*
+* ERROR OUTPUT:  none
+IRQSvc   ldx   M$Mem,pcr
+         bita  #Stat.Err	any error(s)?
+         beq   ChkRDRF		no, go check Rx data
+         ldb   DataReg,x	read Rx data register to clear error flags
+L015C    lda   2,u		get current button and Rx data counter
+         anda  #^%00000111	clear Rx data counter
+L0160    sta   2,u		reset Rx mouse data counter to wait for sync...
+IRQExit  clrb  			clear carry to mark IRQ serviced
          rts   
-L0164    bita  #$08
-         beq   L0162
-         ldb   ,x
-         lda   u0002,u
-         anda  #$03
+
+ChkRDRF  bita  #Stat.RxF	Rx data?
+         beq   IRQExit		no, but this branch should never be taken...
+         ldb   DataReg,x	get Rx data
+         lda   2,u		get button status and Rx counter
+         anda  #%00000111	waiting for sync with mouse data?
          bne   L017A
          bitb  #$40
-         beq   L0162
+         beq   IRQExit
 L0174    stb   a,u
-         inc   u0002,u
+         inc   2,u
          clrb  
          rts   
 L017A    bitb  #$40
@@ -225,16 +288,16 @@
          lda   ,u
          lsra  
          lsra  
-         leax  u0005,u
+         leax  5,u
          bsr   L01A9
          ldd   ,u
          ldx   #$027F
          stx   ,s
-         leax  u0003,u
+         leax  3,u
          bsr   L01A9
          leas  $02,s
          lda   #$80
-         ldx   u0003,u
+         ldx   3,u
          cmpx  #$0140
          bcc   L0160
          ora   #$C0
@@ -245,24 +308,24 @@
          rorb  
          lsra  
          rorb  
-         sex   
-         pshs  b,a
-         bpl   L01BB
-         orb   #$07
-         addd  #$0001
-         bra   L01BD
-L01BB    andb  #$F8
-L01BD    asra  
-         rorb  
-         addd  ,s++
-         addd  ,x
-         bpl   L01C7
-         clra  
-         clrb  
-L01C7    cmpd  $02,s
-         bls   L01CE
-         ldd   $02,s
-L01CE    std   ,x
+         sex   			sign extend mouse packet's 2nd XY offset ([D] = -128 to +127)
+         pshs  d		save it temporarily...
+         bpl   PosAdjst		go de-sensitize positive "ballistic" XY offset
+         orb   #%00000111	if -8<XYoffset<0, no "ballistic" response
+         addd  #$0001		"fix" negative offset "ballistic" response
+         bra   RShiftD		go calculate "ballistic" offset
+PosAdjst andb  #%11111000	if 0<XYoffset<8, no "ballistic" response
+RShiftD  asra  			calculate 50% of XY offset
+         rorb  			for "ballistic" response.
+         addd  ,s++		add original XY offset total, clean up stack
+         addd  ,x		add mouse's current XY position
+         bpl   CheckPos		zero or positive XY position, go check it...
+         clra  			set minimum XY position
+         clrb
+CheckPos cmpd  2,s		past maximum XY position?
+         bls   SavePos		no, go save it...
+         ldd   $02,s		get maximum XY position
+SavePos  std   ,x		save new XY position
          rts   
 
          emod
--- a/level2/modules/joydrv_6552M.asm	Tue Jun 21 00:24:19 2005 +0000
+++ b/level2/modules/joydrv_6552M.asm	Fri Jun 24 17:24:07 2005 +0000
@@ -99,9 +99,10 @@
          bra   L006D
 L0089    fcb   $00
 L008A    fcb   $07,$01
-Init    fcb   $cc,$00,$07
-L008F    fcb   $a7
-         bitb  #$5A
+
+Init     ldd   #$00007
+L008F    sta   b,u
+         decb
          bpl   L008F
          ldd   >M$Mem,pcr
          leax  >L0089,pcr