如何将这些鼠标坐标转换为gotoxy performure中使用的chracter坐标!! 这是我的代码,它采用鼠标的坐标并打印屏幕的.. 代码工作正常,但我想使用这些坐标作为gotoxy proceed中使用的字符坐标..
.model small
.stack
.data
left db "Left Mouse Button Pressed at Coordinates: ","$"
right db "Right Mouse Button Pressed at Coordinates: ","$"
move db "Mouse Moved at Coordinates: ","$"
next_line db 0DH,0AH, "$"
x_coord dw 0
y_coord dw 0
coord dw 0
.code
start:
main proc
mov ax,@data
mov ds, ax
call clrrg ; Clear Data/General Registers
; Changing Video Mode as Per Requirement
mov ah,00h ; Change Video Mode if Required
mov al,12h ; AL=12h, Video Mode 640*480
int 10h
; Show Mouse Cursor on Screen
mov ax,1 ; show Mouse Cursor Functionj
int 33h ; Mouse Interrupt
call clrrg ; Clear Registers
; ****************
; **DESCRIPTION***
; ****************
; STEP # 01: For every mouse event we want to detect,
; ADJUST Value of CX register
; STEP # 02: Load Address of Function in ES:DX which will be
; executed when ANY Mouse Event Occurs
; STEP # 03: AX=000Ch, This Interrupt Setup Interrupt Vector
; entry for MOUSE Interrupt
; STEP # 04: Call int 33h
; Set value of CX as below to Set Interrupt Function for Specific Mouse Event
; If CX is set to all one's 11111111b, it will detect all Events
; CX=00000001b, Call Interrupt Handler if mouse moves
; CX=00000010b, Call Interrupt Handler if left button pressed
; CX=00000100b, Call Interrupt Handler if left button released
; CX=00001000b, Call Interrupt Handler if right button pressed
; CX=00010000b, Call Interrupt Handler if right button released
; CX=00100000b, Call Interrupt Handler if middle button pressed
; CX=01000000b, Call Interrupt Handler if middle button released
; If we want to Detect two events, Take OR of CX values for Both Events.
; Example: To detect Mouse Movement and Left Button Pressed; CX = 00000110b
; Example: To detect Mouse Movement, Left Button Pressed and Right Button Pressed
; CX will be 00001011b
; ***********
; *Important*
; ***********
; Whenever Event is Generated and Function is Invoked,
; below registers are updated
; AX = (Specific bit will get high for which Event is Generated)
; Example: If we press Left Mouse button, value of AX will become 00000010b
; BX = button state
; CX = cursor column ; **Useful, to get info about column
; where Button was pressed**
; DX = cursor row ; **Useful, to get info about row
; where Button was pressed**
; DI = horizontal mickey count
; SI = vertical mickey count
; Step # 01
mov dx,seg mouse_handler ; Load Segment Address of
; Function (mouse_handler)
mov es,dx ; Store contents of dx in es
mov dx,offset mouse_handler ; Load Offset of Function (mouse_handler)
; Step # 02
mov cx, 00001011b ; CX=00001011b tells, we want to generate Interrupt
; if Left Mouse Button OR Right Mouse Button is Pressed
; Step # 03
mov ax,000Ch ; Setup Interrupt Vector Entry for Specific Mouse Event
; Step # 04
int 33h ; Call Mouse Interrupt
call clrrg ; Clear Registers
;****************************************************************************
;***Same 4 steps can be followed to Insert Handlers for Other Mouse events***
;****************************************************************************
; To detect mouse events, we want our program NOT to terminate rapidly
; For this an infinite loop is generated
; When you are writing your code, there might not be need for this
loop1: ; Infinite Loop
nop ; No Operation
jmp loop1
call termprg ; Terminate Program
main endp
; ***********************
; Mouse Interrupt Handler
; ***********************
mouse_handler proc far
.if ax==00000010b ; Means Left Mouse Button is Pressed
; You can also call any other function here
mov x_coord,dx
mov y_coord,cx
mov dx,offset left ; Print Message
mov ah,09h
int 21h
mov dx,x_coord
mov coord, dx ; Passing as Argument in Variable
call print_coord ; Print X Coordinates
mov dl,"," ; Print Comma
mov ah,02h
int 21h
mov dx,y_coord
mov coord, dx ; Passing as Argument in Variable
call print_coord ; Print Y Coordinates
mov dx,offset next_line ; Print Next Line
mov ah,09h
int 21h
.endif
.if ax==00001000b ; Means Right Mouse Button is Pressed
mov x_coord,dx
mov y_coord,cx
mov dx,offset right ; Print Message
mov ah,09h
int 21h
mov dx,x_coord
mov coord, dx ; Passing as Argument in Variable
call print_coord ; Print X Coordinates
mov dl,"," ; Print Comma
mov ah,02h
int 21h
mov dx,y_coord
mov coord, dx ; Passing as Argument in Variable
call print_coord ; Print Y Coordinates
mov dx,offset next_line ; Print Next Line
mov ah,09h
int 21h
.endif
.if ax==00000001b ; Means Mouse is Moved
mov x_coord,dx
mov y_coord,cx
mov dx,offset move ; Print Message
mov ah,09h
int 21h
mov dx,x_coord
mov coord, dx ; Passing as Argument in Variable
call print_coord ; Print X Coordinates
mov dl,"," ; Print Comma
mov ah,02h
int 21h
mov dx,y_coord
mov coord, dx ; Passing as Argument in Variable
call print_coord ; Print Y Coordinates
mov dx,offset next_line ; Print Next Line
mov ah,09h
int 21h
.endif
ret
mouse_handler endp
; Terminate Program
termprg proc
mov ah,4ch
int 21h
ret
termprg endp
;*******************************
; Procedure to Print Coordinates
;*******************************
print_coord proc
call clrrg ; Clear Data Registers
mov ax,coord ; Move "coord" in 'ax' (Numerator goes in ax)
mov bx,10 ; Move 10 in bx (Denominator goes in bx)
; If value is ZERO
.if ax==0
mov dl,al
add dl,48
mov ah,02h
int 21h
jmp return
.endif
; For Values other than ZERO
.while ax !=0
mov dx,0
div bx
push dx
inc cx
.endw
p:
pop dx
add dl,48
mov ah,02h
int 21h
loop p
return:
ret
print_coord endp
; *****************************
; Procedure to Clear Registers
; *****************************
clrrg proc
mov ax,0
mov bx,0
mov cx,0
mov dx,0
ret
clrrg endp
end start
end
答案 0 :(得分:2)
如果以像素为单位给出鼠标坐标,并且您需要字符单元格坐标,则将鼠标坐标除以字符单元格的大小。
因此,例如,假设一个字符单元格宽10像素,高12像素(这些只是示例数字,不是为了表示真实的字符大小)。给定鼠标像素(X,Y)坐标(173,25),您的角色单元格为:
173/10 = 17
25/12 = 2
因此,它对应于字符单元格(17,2)。
如何确定角色单元格的大小,我不知道。
答案 1 :(得分:0)
RBIL-> inter61a.zip-> INTERRUP.A
-------V-101130-----------------------------
INT 10 - VIDEO - GET FONT INFORMATION (EGA, MCGA, VGA)
AX = 1130h
BH = pointer specifier
00h INT 1Fh pointer
01h INT 43h pointer
02h ROM 8x14 character font pointer
03h ROM 8x8 double dot font pointer
04h ROM 8x8 double dot font (high 128 characters)
05h ROM alpha alternate (9 by 14) pointer (EGA,VGA)
06h ROM 8x16 font (MCGA, VGA)
07h ROM alternate 9x16 font (VGA only) (see #00021)
11h (UltraVision v2+) 8x20 font (VGA) or 8x19 font (autosync EGA)
12h (UltraVision v2+) 8x10 font (VGA) or 8x11 font (autosync EGA)
Return: ES:BP = specified pointer
CX = bytes/character of on-screen font (not the requested font!)
DL = highest character row on screen
Note: for UltraVision v2+, the 9xN alternate fonts follow the corresponding
8xN font at ES:BP+256N
BUG: the IBM EGA and some other EGA cards return in DL the number of rows on
screen rather than the highest row number (which is one less).
SeeAlso: AX=1100h,AX=1103h,AX=1120h,INT 1F"SYSTEM DATA",INT 43"VIDEO DATA"
Format of alternate font table [array]:
Offset Size Description (Table 00021)
00h BYTE character to be replaced (00h = end of table)
01h N BYTEs graphics data for character, one byte per scan line
德克