does anyone have a small snippet to read and control a mouse cursor in assembler?
thanks in advance
Login or register to post comments
does anyone have a small snippet to read and control a mouse cursor in assembler?
thanks in advance
MSX1 or MSX2?
Check here. Comments are in Dutch, but I think it'll be clear enough.
Yes, I have stuff for controlling the mouse. I'll look into it hopefully this evening/weekend and get back on it. if ye still need it, that is.
Do msx1 and msx2 differ in mouse control?
I'd like to find a general method that uses direct i/o.
No bios please, subrom calls are terrible
Edwin I'll study your code, in case i'll ask some Dutch friends to translate.
Thanks
Here is the code with translated comments:
A routine to read the mouse: LD D,&B10010011 ; Use these values for a mouse in port 1 LD E,&B00010000 LD D,&B11101100 ; Use these values for a mouse in port 2 LD E,&B00100000 ; Read the mouse. Input: D/E=.... Output: H=X-offset, L=Y-offset ; Note that the routine will output H=L=255 if no mouse is present! GTMOUS: LD B,WAIT2 ; Long delay for first read CALL GTOFS2 ; Read bit 7-4 of the x-offset AND 0FH RLCA RLCA RLCA RLCA LD C,A CALL GTOFST ; Read bit 3-0 of the x-offset AND 0FH OR C LD H,A ; Store combined x-offset CALL GTOFST ; Read bit 7-4 of the y-offset AND 0FH RLCA RLCA RLCA RLCA LD C,A CALL GTOFST ; Read bit 3-0 of the y-offset AND 0FH OR C LD L,A ; Store combined y-offset RET WAIT1: EQU 10 ; Short delay value WAIT2: EQU 30 ; Long delay value GTOFST: LD B,WACHT1 GTOFS2: LD A,15 ; Read psg register 15 voor mouse OUT (0A0H),A LD A,D OUT (0A1H),A XOR E LD D,A WAIT: DJNZ WAIT ; Extra delay because the mouse is slow. LD A,14 OUT (0A0H),A IN A,(0A2H) RET
This code is valid for all MSX types. As long as you use an MSX mouse of course.
GTOFST: LD B,WACHT1 ; should be
GTOFST: LD B,WAIT1 ; I think
yes! thanks! it worked also with labels and comments in Duck
quack quack!
hoops, unwanted typo
funny one though!
Don't you have an account yet? Become an MSX-friend and register an account!