# HG changeset patch # User gheskett # Date 1264023206 0 # Node ID 1317b044e8bf37750289e99308b04aee24ae8fee # Parent 403de20e5891305e6faf4f53f3af00def4123db9 *** empty log message *** diff -r 403de20e5891 -r 1317b044e8bf defs/l51.defs --- a/defs/l51.defs Wed Jan 20 21:21:42 2010 +0000 +++ b/defs/l51.defs Wed Jan 20 21:33:26 2010 +0000 @@ -1,12 +1,13 @@ - * miscellaneous definitions HResMaxX equ 639 high resolution X limit HResMaxY equ 191 high resolution Y limit MousData equ $0008 arbitrary choice for mouse data area ($0008-$000F) -PcktSize equ 5 number of bytes in mouse data packet -SyncData equ %10000000 initial mouse data byte pattern -SyncMask equ %11111000 mask for initial mouse data byte pattern - +*PcktSize equ 5 wrong for M$, Logitek mice +PcktSize equ 4 number of bytes in mouse data packet, wrong. max 4, usually 3 +*SyncData equ %10000000 initial mouse data byte pattern- wrong +SyncData equ %01000000 initial mouse data byte pattern, d7 is NOT used +*SyncMask equ %11111000 mask for initial mouse data byte pattern-wrong +SyncMask equ %01111000 mask for initial mouse data byte pattern * 6551 register definitions org 0 DataReg rmb 1 receive/transmit data @@ -60,7 +61,9 @@ DB.6 equ %01000000 six data bits per character DB.7 equ %00100000 seven data bits per character DB.8 equ %00000000 eight data bits per character - +* GH 28/06/2008 Note, data format is only 7 bits +* but most mice send 8 bits with the last bit, +* MSB set which=extra stop bit, so use DB.7 * baud rate table org 0 BR.ExClk rmb 1 16x external clock @@ -81,14 +84,25 @@ BR.19200 rmb 1 19200 baud * Btn.Cntr bit definitions -BC.Butn1 equ %00100000 button #1 (left, 1 = pressed) -BC.Butn2 equ %00010000 button #2 (middle, 1 = pressed) -BC.Butn3 equ %00001000 button #3 (right, 1 = pressed) -BC.RxCnt equ %00000111 Rx data counter +BC.ButnL equ %00100000 button #1 (left, 1 = pressed=$20) +BC.ButnR equ %00010000 button #2 (right, 1 = pressed=$10) +BC.ButnC equ %00001000 button #3 (center, 1 = pressed=$08) +BC.RxCnt equ %00000111 Rx data byte count +BC.Butns equ BC.ButnL!BC.ButnR!BC.ButnC mask for all buttons -BC.Butns equ BC.Butn1!BC.Butn2!BC.Butn3 mask for all buttons +* added 06/21/2008 GH some defines for button up +BU.ButnL equ %00011111 to clear button #1 left +BU.ButnR equ %00101111 to clear button #2 right +BU.ButnC equ %00110111 to clear button #3 center - +* Added 06/21/2008 GH more possibly handy defines +* here is a good place to define mouse buttons +* as the mouse output data delivers them to us +MD.Sync equ %01000000 never set unless sync byte +MD.ButnL equ %00100000 left, in first 'sync' byte of logitek mouse +MD.ButnR equ %00010000 right, in first 'sync' byte of logitek mouse +MD.ButnC equ %00100000 center, but in 4th byte only +MskYYXX equ %11000000 for use after shifted to msbits * mouse static data area definitions org 0 Btn.Cntr rmb 1 mouse button status and Rx data counter @@ -96,3 +110,25 @@ CrntXPos rmb 2 mouse X position (0 to HResMaxX) CrntYPos rmb 2 mouse Y position (0 to HResMaxY*2) +* added, may, may not be usefull, GH +* logitek mouse data defs, almost same as M$, bit D7 of any byte is don't care +* BECAUSE THE MOUSE IS A 7N1 MOUSE! +* Assume Btn.Cntr will be inc'd as last processing op of each byte rx'd here. +LkMsMask equ %01111111 d7 ignored +LkMsSync equ %01000000 only set for first byte of packet, set Btn.Cntr=0 +LkMsLBtn equ %00100000 if left button pushed, in sync byte +LkMsRbtn equ %00010000 if right button pushed, in sync byte +* except this one in 4th byte +LgtkCBtn equ %00100000 if center button pushed, and Btn.Cntr=3 +* sign bits +LkMsYSgn equ %00001000 direction of current move, in sync byte +LkMsXSgn equ %00000010 direction of current move, in sync byte +* direction since last packet bits +LkMsYMsb equ %00000100 MSB of current Y move, in sync byte +LkMsXMsb equ %00000001 MSB of current X move, in sync byte +LkMsXMov equ %00111111 the rest of an 7 bit value, when Btn.Cntr=1 (second byte) +LkMsYMov equ %00111111 the rest of an 7 bit value, when Btn.Cntr=2 + +* Microsoft sends the center button down as a no data packet +* sync bit only in first byte +* ANYTHING else is a center button up event. diff -r 403de20e5891 -r 1317b044e8bf level2/modules/joydrv_6551L.asm --- a/level2/modules/joydrv_6551L.asm Wed Jan 20 21:21:42 2010 +0000 +++ b/level2/modules/joydrv_6551L.asm Wed Jan 20 21:33:26 2010 +0000 @@ -11,93 +11,137 @@ * * 6r1 2005/04/25 Boisy G. Pitre * Fixed error where wrong branch was taken. - - nam JoyDrv - ttl Joystick Driver for 6551/Logitech Mouse - + +* GH 08/06/2008 gleaned from a newsgroup msg found by google +*--------------------------------------------- +*> Hmm, let me guess: the terminal used a 6551 ACIA. +* +* Possibly so, but not necessarily. Seems there are terminals out there +* that require DCD/DSR/strange signals for receiving/transmitting. Choose +* any combination you like. +* +* Now, the ACIA 6551 is an especially braindead beast. It requires both +* DCD and DSR, and pulling CTS low for flow control will make it stop +* sending immediately, without finishing the character, resulting in a +* junked character. (Not all versions of the chip have this bug. Most do.) +* The Archimedes people who were struck with the 6551 usually wired DCD +* and CTS to high, DSR to modem CTS, RI to modem DCD. +*---------------------------------------------- +* FWIW, the mouse outputs a packet of un-determined length when +* it is enabled, no motion needed to trigger, just turn it on +* Since the mouse is port powered, enabling its power could +* cause this I presume. +* GH 21/06/08 my mouse is fixed at 3 bytes +* GH see comments scattered through the code +* none of which will be precious in final +* version +* GH - 21/12/09 version 11 (B) moving some code to shrink, rechecking +* GH - 18/12/09 version A - trying to fix button locations in packet +* GH - 30/06/2008 version 8 +* GH - 08/08/2008 version 7 +* Re-wrote to rearrange order of init see +* comments scattered through the code +* GH - 01/07/2008 version 9 +* added code to function with a real M$ 3 button mouse +* now defaults to M$ empty packet for Center button down event +* but detects 4th byte from a Logitek mouse & switches modes +* till next reboot. +* Also no 6309 optimizations yet. Version A maybe? Not yet. +* one problem has been the narrow list format, Boisy advises: + opt w132 + 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 +* l51.defs - something else to check against google et all +* l51.defs has been modified, this needs the new version +* set this to get some debugging in the boot trace +DEBUG = 1 tylg set Systm+Objct -atrv set ReEnt+rev -rev set $01 -edition set 6 - -MPISlot set $FF - - mod eom,name,tylg,atrv,start,$FF68 - -name fcs /JoyDrv/ - fcb edition - -SlotSlct fcb 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 - +atrv set ReEnt+rev +rev set $02 +edition set 11 +* set this to where your rs-232 pack is plugged in +MPISlot set $00 front slot for mine + + mod eom,name,tylg,atrv,start,$FF6C + +name fcs /JoyDrv/ + fcb edition + +SlotSlct fcb MPISlot + +start lbra Init + lbra Term + lbra SSMsBtn + lbra SSMsXY + lbra SSJoyBtn + +* This code is not being +* used, but save it so I +* don't have to reinvent +* this wheel later +*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=$00 +Pkt.Mask fcb Stat.RxF is correct + fcb $01 priority=low + *** * JoyDrv Initialization. * @@ -108,45 +152,152 @@ * * ERROR OUTPUT: CC = Carry set * B = error code -Init clra - clrb +* first, suspend all interrupts +Init pshs cc save regs we alter + orcc #IntMasks mask IRQs while disabling ACIA + bsr InitPIAs + bsr InitGIME + bsr ClrACIA reset, gobble up trash data in ACIA + bcc ClrBuf which will also install IRQSvs + puls cc else error + lbsr Term + comb + ldb #E$PrcAbt + rts and return error + +************************************* +* Btn.Cntr,u offset 0 has room for 3 bits of incoming +* byte counter, 3 bits of button status. +* Buffer, offset 2-3 is the combined first 3 bytes +* of the incoming XY data +* CrntXpos, offset 4-5 is current (0-HResMaxX) xpos +* CrntYpos, offset 6-7 is current (0 to HResMaxY*2) ypos + +ClrBuf ldd #$0007 clear the buffer +ClrBuf1 sta b,u A=$00 + decb decr counter + bne ClrBuf1 was a bpl, so 1st byte wasn't cleared +* Now init the buffer to real data + clrb reset to $00, s/b $00 here anyway. 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 + ldd #HResMaxY*2 =$017E, 382 decimal? Odd value, check std CrntYPos,u set up Y position at top screen edge - ldd M$Mem,pcr get base hardware address + lda #'M preset M$ mouse + sta Buffer,u + +* Now we should be ready for live IRQ's +InstIRQ ldd M$Mem,pcr get base hardware address addd #StatReg status register address leax IRQPckt,pcr leay IRQSvc,pcr - 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 - 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 + os9 F$IRQ install the IRQSvs routine + lbcs InitErr go with cc on stack! + puls cc get rid of the push + rts + +* BUG FIX: InitExit is now here... was TermExit... +InitExit puls pc,cc recover original regs, return... + +* clear the PIA's for this +InitPIAs lda >PIA1Base+3 get PIA CART* input control register + anda #$FC clear PIA CART* control bits sta >PIA1Base+3 disable PIA CART* FIRQs lda >PIA1Base+2 clear possible pending PIA CART* FIRQ - lda #$01 GIME CART* IRQ enable + ifeq DEBUG-1 + pshs a,b,x,u,y,cc,dp + lda #'P + jsr 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 set MPI slot select register -* BUG FIX: InitExit is now here... was TermExit... -InitExit puls pc,cc recover original regs, return... - -*** + lda SlotSlct,pcr mpi slot of mouse + bmi ClrACIA + sta >MPI.Slct + ifeq DEBUG-1 + pshs a,b,x,u,y,cc,dp + lda #'G + jsr