?? ps2d_mouse_cmd.asm
字號:
;;*****************************************************************************
;;*****************************************************************************
;; FILENAME: PS2D_cmd.asm
;; Version: 1.2, Updated on 2005/07/06 at 13:49:25
;; Generated by PSoC Designer ver 4.2 b1013 : 02 September, 2004
;;
;; DESCRIPTION: PS2D User Module command implementation file
;; for the enCoRe II family of devices
;;
;; NOTE: User Module APIs conform to the fastcall convention for marshalling
;; arguments and observe the associated "Registers are volatile" policy.
;; This means it is the caller's responsibility to preserve any values
;; in the X and A registers that are still needed after the API
;; function returns. Even though these registers may be preserved now,
;; there is no guarantee they will be preserved in future releases.
;;-----------------------------------------------------------------------------
;; Copyright (c) Cypress Semiconductor 2004, 2005. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
include "m8c.inc"
include "PS2D.inc"
;-----------------------------------------------
; Global Symbols
;-----------------------------------------------
export PS2D_IsStreamMode
export _PS2D_IsStreamMode
export PS2D_GetResolution
export _PS2D_GetResolution
export PS2D_GetSampleInterval
export _PS2D_GetSampleInterval
export PS2D_GetScaling
export _PS2D_GetScaling
export PS2D_GetDeviceID
export _PS2D_GetDeviceID
export PS2D_StartDevice
;-----------------------------------------------
; Persistent RAM Allocation
;-----------------------------------------------
AREA bss (RAM,REL)
export PS2D_bDeviceID
export _PS2D_bDeviceID
export PS2D_bSampleRateIndex
export PS2D_bMouseScaling
export PS2D_bMouseResolution
export PS2D_bWheelUnlock
PS2D_bDeviceID:
_PS2D_bDeviceID: BLK 1
PS2D_bSampleRateIndex: BLK 1
PS2D_bMouseScaling: BLK 1
PS2D_bMouseResolution: BLK 1
PS2D_bWheelUnlock: BLK 1
;-----------------------------------------------
; PS2 Command Dispatch Tables
;-----------------------------------------------
AREA UserModules (ROM, REL)
PS2D_E6_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_E7_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_E8_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_E9_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_EA_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_EB_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_EC_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_ED_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_EE_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_EF_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_F0_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_F1_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_F2_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_F3_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_F4_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_F5_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_F6_CMD_RESPONSE: equ PS2_CMD_ACK
PS2D_F7_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_F8_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_F9_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_FA_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_FB_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_FC_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_FD_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_FE_CMD_RESPONSE: equ PS2_CMD_NO_ACK
PS2D_FF_CMD_RESPONSE: equ PS2_CMD_ACK
export PS2D_CMD_RESPONSE
.LITERAL
PS2D_CMD_RESPONSE:
DB PS2D_E6_CMD_RESPONSE
DB PS2D_E7_CMD_RESPONSE
DB PS2D_E8_CMD_RESPONSE
DB PS2D_E9_CMD_RESPONSE
DB PS2D_EA_CMD_RESPONSE
DB PS2D_EB_CMD_RESPONSE
DB PS2D_EC_CMD_RESPONSE
DB PS2D_ED_CMD_RESPONSE
DB PS2D_EE_CMD_RESPONSE
DB PS2D_EF_CMD_RESPONSE
DB PS2D_F0_CMD_RESPONSE
DB PS2D_F1_CMD_RESPONSE
DB PS2D_F2_CMD_RESPONSE
DB PS2D_F3_CMD_RESPONSE
DB PS2D_F4_CMD_RESPONSE
DB PS2D_F5_CMD_RESPONSE
DB PS2D_F6_CMD_RESPONSE
DB PS2D_F7_CMD_RESPONSE
DB PS2D_F8_CMD_RESPONSE
DB PS2D_F9_CMD_RESPONSE
DB PS2D_FA_CMD_RESPONSE
DB PS2D_FB_CMD_RESPONSE
DB PS2D_FC_CMD_RESPONSE
DB PS2D_FD_CMD_RESPONSE
DB PS2D_FE_CMD_RESPONSE
DB PS2D_FF_CMD_RESPONSE
.ENDLITERAL
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
; Mouse specific API routines
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------
; FUNCTION NAME: PS2D_GetScaling
; DESCRIPTION:
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
.SECTION
PS2D_GetScaling:
_PS2D_GetScaling:
mov a, [PS2D_bMouseScaling] ; Return the scaling value
ret
.ENDSECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: PS2D_IsStreamMode
; DESCRIPTION: Applicable to mouse support.
; Return 1 if the interface is in stream mode
; Otherwise returns 0
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
.SECTION
PS2D_IsStreamMode:
_PS2D_IsStreamMode:
mov a, 0x01 ; Assume stream mode
cmp [PS2D_bMode],PS2D_CMD_MODE_STREAM ; Are we in stream mode?
jz .exit
; Flow here when we are not in stream mode
mov a, 0x00 ; Return not in stream mode
.exit:
ret
.ENDSECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: PS2D_GetSampleInterval
; DESCRIPTION:
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
.SECTION
PS2D_GetSampleInterval:
_PS2D_GetSampleInterval:
mov a,[PS2D_bSampleRateIndex] ; Get the index
index PS2D_cValidSampleInterval ; Return the interval
ret
.ENDSECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: PS2D_GetResolution
; DESCRIPTION:
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
.SECTION
PS2D_GetResolution:
_PS2D_GetResolution:
mov a,[PS2D_bMouseResolution] ; Get the resolution
ret
.ENDSECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: PS2D_GetDeviceID
;
; DESCRIPTION:
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
.SECTION
PS2D_GetDeviceID:
_PS2D_GetDeviceID:
mov a, [PS2D_bDeviceID] ; Simply return the ID
ret
.ENDSECTION
;-----------------------------------------------------------------------------
; Mouse specific Dispatch routines
;-----------------------------------------------------------------------------
; FUNCTION NAME: PS2D_CmdSetSampleRate
; DESCRIPTION:
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
.LITERAL
PS2D_cValidSampleRates: DB 10, 20, 40, 60, 80, 100, 200
PS2D_cValidSampleInterval: DB 100, 50, 25, 17, 13, 10, 5
PS2D_cSizeOfValidSampleRates: equ PS2D_cValidSampleInterval - PS2D_cValidSampleRates
.ENDLITERAL
PS2D_CmdSetSampleRate:
.get_byte:
call PS2D_GetHostByte ; Get the host byte if one is available
swap a,x ; Swap bytes to make the check
cmp a, 0x00 ; Zero signals we have a byte
jnz .get_byte ; Keep trying to get the rate byte
; Validate the sample rate
; Build a little stack frame
swap a,x ; Get it back
push a ; x-2 sample rate
mov a,0 ;
push a ; x-1 index, initialized to 0
mov x,sp ; Here we use x as a frame pointer
.check_next:
mov a,[x-1]
index PS2D_cValidSampleRates
cmp a,[x-2]
jz .found
; Flow here to increment the index and check for termination case
inc [x-1]
cmp [x-1],PS2D_cSizeOfValidSampleRates
jnz .check_next
; Flow here if the sample rate was not found in the table
call PS2D_SendResponseError ;
jmp .clean_up
; Jump here when we valiate the sample rate
.found:
mov a,[x-1] ; Get the index
mov [PS2D_bSampleRateIndex], a ; And save it
call PS2D_CheckWheelUnlock
call PS2D_SendResponseACK ;
.clean_up:
add sp,-2 ; Clean up the stack
ret
;-----------------------------------------------------------------------------
; FUNCTION NAME: PS2D_CmdResetWrapMode
; DESCRIPTION:
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS:
;
; RETURNS:
;
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
PS2D_CmdResetWrapMode:
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -