📄 ex.lst
字号:
0154 1A 42 [05] mov A, [saveCmd] ; get back sample rate
0156 92 7B [10] call ps2SetSampleRate ; and set it
0158
0158 ;
0158 ; on exit from ps2SetSampleRate:
0158 ; (A) = PS2_ACK if the rate is valid
0158 ; Else, (A) = PS2_RESEND
0158 ;
0158
0158 16 FA [05] cmp A, PS2_ACK
015A B1 AC [05] jnz ps2DoCmdError ; go if sample rate setting has error
015C
015C 19 FA [04] mov A, PS2_ACK ; send back ACK byte as required
015E 93 96 [10] call ps2SendResponseByte ; by PS/2 protocol
0160
0160 19 00 [04] mov A, 00h ; clear the error count
0162 31 37 [05] mov [ps2InvalidCmdCount], A ;
0164 31 36 [05] mov [ps2LastValidCmd], A ; reset last valid command
0166
0166 1A 42 [05] mov A, [saveCmd] ; get back command byte (in this
0168 ; case, command byte = sample rate)
0168 93 B0 [10] call checkWheel ; check whether wheel has been enabled
016A 81 C3 [05] jmp doCmdExit ; exit
016C
016C doCmd1:
016C 1A 36 [05] mov A, [ps2LastValidCmd] ; get last valid command
016E 16 E8 [05] cmp A, PS2_SET_RESOLUTION_CMD
0170 B1 86 [05] jnz decodeCmd ; go if not SetResolution command
0172 1A 42 [05] mov A, [saveCmd] ; else (A) = resolution factor
0174 91 CE [10] call ps2SetResolution ; set it
0176
0176 ;
0176 ; on exit from ps2SetResolution:
0176 ; (A) = PS2_ACK if the resolution is valid
0176 ; Else, (A) = PS2_RESEND
0176 ;
0176
0176 16 FA [05] cmp A, PS2_ACK
0178 B1 AC [05] jnz ps2DoCmdError ; go if set resolution failed
017A
017A 19 FA [04] mov A, PS2_ACK ; send back ACK byte as required
017C 93 96 [10] call ps2SendResponseByte ; by PS/2 protocol
017E
017E 19 00 [04] mov A, 00h ; reset variables for next transaction
0180 31 37 [05] mov [ps2InvalidCmdCount], A ;
0182 31 36 [05] mov [ps2LastValidCmd], A ;
0184 81 C3 [05] jmp doCmdExit ; exit
0186
0186 decodeCmd:
0186 19 00 [04] mov A, 00h ; abort transmission when receiving
0188 31 48 [05] mov [ps2XmitLen], A ; a new command
018A
018A 1A 42 [05] mov A, [saveCmd]
018C 16 F3 [05] cmp A, PS2_SET_SAMPLE_RATE_CMD
018E A1 94 [05] jz doCmd2
0190
0190 19 00 [04] mov A, 00h ; reset count of consecutive sample
0192 31 41 [05] mov [sequence], A ; rate settings - this is to keep
0194 ; track of wheel enabling
0194 doCmd2:
0194 1A 42 [05] mov A, [saveCmd]
0196 07 E6 [04] sub A, 0E6h ; adjust for base of command table
0198 C1 AC [05] jc ps2DoCmdError ; go if invalid command
019A
019A validCommand:
019A 2D [05] push A
019B 19 FA [04] mov A, PS2_ACK ; send back ACK byte on receiving
019D 93 96 [10] call ps2SendResponseByte ; host command (PS/2 protocol)
019F
019F 1A 42 [05] mov A, [saveCmd] ; update last valid command
01A1 31 36 [05] mov [ps2LastValidCmd], A ;
01A3 19 00 [04] mov A, 00h ; reset counter for invalid command
01A5 31 37 [05] mov [ps2InvalidCmdCount], A ;
01A7 2B [04] pop A
01A8
01A8 3B [04] asl A ; get offset into table
01A9 E1 00 [07] jacc ps2CmdTable ; do the function
01AB 00 [07] halt ; should never get here !!
01AC
01AC ps2DoCmdError:
01AC 23 37 [07] inc [ps2InvalidCmdCount] ; keep track of invalid commands
01AE 1A 37 [05] mov A, [ps2InvalidCmdCount] ;
01B0 16 02 [05] cmp A, 02h
01B2 B1 BF [05] jnz ps2DoCmdError1
01B4
01B4 19 FC [04] mov A, PS2_ERROR ; return an "error" response to host
01B6 93 96 [10] call ps2SendResponseByte ; in case of 2 errors
01B8
01B8 19 00 [04] mov A, 00h ; reinitialize variables
01BA 31 37 [05] mov [ps2InvalidCmdCount], A ;
01BC 31 36 [05] mov [ps2LastValidCmd], A ;
01BE 3F [08] ret
01BF
01BF ps2DoCmdError1:
01BF 19 FE [04] mov A, PS2_RESEND ; go if one error - return a "resend"
01C1 93 96 [10] call ps2SendResponseByte ; response to host
01C3
01C3 doCmdExit:
01C3 3F [08] ret
01C4
01C4 ;========================================================================
01C4 ; FUNCTION: ps2ResetScaling
01C4 ; Sets scaling to 1-1
01C4 ;
01C4 ;========================================================================
01C4 ps2ResetScaling:
01C4 19 00 [04] mov A, SCALE1_1
01C6 31 3A [05] mov [ps2Scale], A
01C8 3F [08] ret
01C9
01C9 ;========================================================================
01C9 ; FUNCTION: ps2SetScaling2_1
01C9 ; Sets scaling to 2-1
01C9 ;
01C9 ;========================================================================
01C9 ps2SetScaling2_1:
01C9 19 01 [04] mov A, SCALE2_1
01CB 31 3A [05] mov [ps2Scale], A
01CD 3F [08] ret
01CE
01CE ;========================================================================
01CE ; FUNCTION: ps2SetResolution
01CE ; Sets the resolution. Only 4 resolutions are supported
01CE ;
01CE ; On Entry: (A) = resolution factor
01CE ; On Exit: (A) = PS2_ACK if valid resolution factor.
01CE ; = PS2_RESEND if invalid resolution factor
01CE ;
01CE ;========================================================================
01CE ps2SetResolution:
01CE 16 00 [05] cmp A, RES1
01D0 A1 E1 [05] jz validRes ; go if 1 count per millimeter (mm)
01D2 16 01 [05] cmp A, RES2
01D4 A1 E1 [05] jz validRes ; go 2 counts/mm
01D6 16 02 [05] cmp A, RES4
01D8 A1 E1 [05] jz validRes ; go if 4 counts/mm
01DA 16 03 [05] cmp A, RES8
01DC A1 E1 [05] jz validRes ; go if 8 counts/mm
01DE 19 FE [04] mov A, PS2_RESEND
01E0 3F [08] ret
01E1
01E1 validRes:
01E1 31 3C [05] mov [ps2Resolution], A
01E3 19 FA [04] mov A, PS2_ACK
01E5 3F [08] ret
01E6
01E6 ;========================================================================
01E6 ; FUNCTION: ps2StatusRequest
01E6 ;
01E6 ; Form a 3-byte status according to IBM Specs
01E6 ;
01E6 ; Byte 1:
01E6 ; Bit 7: Reserved
01E6 ; 6: 0 = Stream Mode, 1 = Remote Mode
01E6 ; 5: 0 = Disabled, 1 = Enabled
01E6 ; 4: 0 = Scaling 1:1, 1 = Scaling 2:1
01E6 ; 3: Reserved
01E6 ; 2: 1 = Left Button Pressed
01E6 ; 1: Reserved
01E6 ; 0: 1 = Right Button Pressed
01E6 ; Byte 2:
01E6 ; Bits 7-0: Current Resolution Setting
01E6 ; Byte 3:
01E6 ; Bits 7-0: Current Sampling Rate
01E6 ;
01E6 ;========================================================================
01E6 ps2StatusRequest:
01E6 19 00 [04] mov A, 00h
01E8 31 2F [05] mov [temp], A
01EA 1A 21 [05] mov A, [currentButtonState]
01EC 10 01 [04] and A, RIGHT_BUTTON_MASK
01EE B1 F4 [05] jnz sr1
01F0 19 01 [04] mov A, BIT0 ; set right button pressed
01F2 33 2F [07] or [temp], A ;
01F4
01F4 sr1:
01F4 1A 21 [05] mov A, [currentButtonState]
01F6 10 80 [04] and A, LEFT_BUTTON_MASK
01F8 B1 FE [05] jnz sr2
01FA 19 04 [04] mov A, BIT2 ; set left button pressed
01FC 33 2F [07] or [temp], A ;
01FE
01FE sr2:
01FE 20 [04] NOP
01FF 1F [04] XPAGE
0200 1A 3A [05] mov A, [ps2Scale]
0202 16 01 [05] cmp A, SCALE2_1
0204 B2 0A [05] jnz sr3
0206 19 10 [04] mov A, BIT4 ; set scaling 2:1
0208 33 2F [07] or [temp], A ;
020A
020A sr3:
020A 1A 3D [05] mov A, [ps2MouseEnabled]
020C 16 01 [05] cmp A, 01h
020E B2 14 [05] jnz sr4
0210 19 20 [04] mov A, BIT5 ; set mouse enabled
0212 33 2F [07] or [temp], A ;
0214
0214 sr4:
0214 1A 3B [05] mov A, [ps2StreamMode]
0216 16 01 [05] cmp A, 01h
0218 A2 1E [05] jz sr5
021A 19 40 [04] mov A, BIT6 ; set remote mode
021C 33 2F [07] or [temp], A ;
021E
021E sr5:
021E 1A 2F [05] mov A, [temp] ; load packet onto xmit buffer
0220 31 43 [05] mov [ps2XmitBuffer0], A ;
0222 1A 3C [05] mov A, [ps2Resolution] ;
0224 31 44 [05] mov [ps2XmitBuffer1], A ;
0226 1A 38 [05] mov A, [ps2ReportRate] ;
0228 31 45 [05] mov [ps2XmitBuffer2], A ;
022A
022A 19 03 [04] mov A, 03h ; indicate 3-byte packet length
022C 31 47 [05] mov [ps2XmitBufferLen], A ;
022E 31 48 [05] mov [ps2XmitLen], A ;
0230 3F [08] ret
0231
0231 ;========================================================================
0231 ; FUNCTION: ps2SetStreamMode
0231 ;
0231 ;========================================================================
0231 ps2SetStreamMode:
0231 19 01 [04] mov A, 01h ; turn on stream mode
0233 31 3B [05] mov [ps2StreamMode], A ;
0235 92 C9 [10] call ps2ResetMouseReportInterval
0237 3F [08] ret
0238
0238 ;========================================================================
0238 ; FUNCTION: ps2ReadData
0238 ; Sends a mouse packet back even if there has been no mouse
0238 ; movement since the last report or the switch status is unchanged
0238 ;
0238 ;========================================================================
0238 ps2ReadData:
0238 19 02 [04] mov A, EVENT_PENDING ; force it to send a mouse packet
023A 31 28 [05] mov [eventMachine], A ;
023C 92 CE [10] call loadMousePacket ; load xmit buffer with mouse packet
023E 92 C9 [10] call ps2ResetMouseReportInterval
0240 3F [08] ret
0241
0241 ;========================================================================
0241 ; FUNCTION: ps2ResetWrapMode
0241 ; Resets the wrap mode. Note that, if stream mode is on, the
0241 ; mouse is disabled when the wrap mode is reset.
0241 ;
0241 ;========================================================================
0241
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -