Use ~10€ to connect modern mouse to MSX

Pagina 2/18
1 | | 3 | 4 | 5 | 6 | 7

Van NYYRIKKI

Enlighted (5541)

afbeelding van NYYRIKKI

28-12-2013, 19:58

Van edoz

Prophet (2279)

afbeelding van edoz

28-12-2013, 22:01

Nice pictures! And it seem to be running in Symbos. Is the scroll wheel also working ? Symbos supports this .. Wink

Van NYYRIKKI

Enlighted (5541)

afbeelding van NYYRIKKI

28-12-2013, 22:20

edoz wrote:

Nice pictures! And it seem to be running in Symbos. Is the scroll wheel also working ? Symbos supports this .. Wink

I'm pretty sure MSX-version of SymbOS does not have scroll wheel support, but I'm interested if you have more information. Currently scroll wheel only changes the mouse sensitivity.

Van edoz

Prophet (2279)

afbeelding van edoz

28-12-2013, 23:58

Maybe prodatron knows this. On the meeting in Nijmegen (2013) he showed me the scroll function with mouse in Symbos. (in notepad) It was not on the MSX, but maybe it is possible to get it in also Big smile I try to ask.

Van NYYRIKKI

Enlighted (5541)

afbeelding van NYYRIKKI

29-12-2013, 02:17

First we would need to agree a new mouse protocol since MSX-mouse supports only X & Y axis, not Z-axis.

Van Prodatron

Paragon (1789)

afbeelding van Prodatron

01-01-2014, 17:50

Awesome project! Finally I can stopp hoarding MSX mouses Big smile
Regarding mouse wheel support. What's about sending unusual x/y deltas.

Example:
(of course this would be done in Z80)

deltaX = read_two_nibbles_from_mouse();
deltaY = read_two_nibbles_from_mouse();
deltaZ = 0;
if (deltaX == deltaY) && (deltaX > 118)
{
deltaZ = deltaX-123;
deltaX = 0;
deltaY = 0;
read_two_nibbles_from_mouse(); // ignore next four nibbles
read_two_nibbles_from_mouse();
}

So if both deltas are the same and >118 (which would never happen usually), they contain the deltaZ.
To stay compatible with existing mouse drivers, the mouse will send the negative versions of these two modded X/Y-deltas in the next step, so that the mouse pointer wouldn't change its position (it only twitches one time, if the wheel is used; ok, if it's aleady at the lower left border, it will probably jumps upwards/to the left Question).

PS: Happy new year! Cool

Van edoz

Prophet (2279)

afbeelding van edoz

02-01-2014, 09:57

NYYRIKKI, is this what you mean ?

Van zPasi

Champion (495)

afbeelding van zPasi

02-01-2014, 13:02

Cool! Though I don't think I'll need an MSX mouse any time soon, but never say never.

And I like seeing Arduino and MSX used together this way. I'd like to see more Arduino peripheral projects! I'm thinking to design some myself, like a memory/SD-cartridge with Arduino in place of 74-logic-chips / cpld, so the PCB would be very simple. Maybe should discuss this in another thread...

Van NYYRIKKI

Enlighted (5541)

afbeelding van NYYRIKKI

02-01-2014, 14:37

Prodatron wrote:

Awesome project! Finally I can stopp hoarding MSX mouses Big smile
Regarding mouse wheel support. What's about sending unusual x/y deltas.

Example:
(of course this would be done in Z80)

deltaX = read_two_nibbles_from_mouse();
deltaY = read_two_nibbles_from_mouse();
deltaZ = 0;
if (deltaX == deltaY) && (deltaX > 118)
{
deltaZ = deltaX-123;
deltaX = 0;
deltaY = 0;
read_two_nibbles_from_mouse(); // ignore next four nibbles
read_two_nibbles_from_mouse();
}

So if both deltas are the same and >118 (which would never happen usually), they contain the deltaZ.
To stay compatible with existing mouse drivers, the mouse will send the negative versions of these two modded X/Y-deltas in the next step, so that the mouse pointer wouldn't change its position (it only twitches one time, if the wheel is used; ok, if it's aleady at the lower left border, it will probably jumps upwards/to the left Question).

PS: Happy new year! Cool

Nice hack idea, but it still sounds a bit too hack. Smile (And I think it will cause problem with trackball support routine in BIOS)

How about a bit more PS/2 style... I mean with handshake... ie something like:
On first mouse read push pin 7 low and let pin 6 & 8 high. Now wait for 4 VDP-interrupts. If mouse recognizes this, it sends out X & Y-deltas = 127,128 on mouse read completion and after that it switches from 2-byte communication to 4-byte communication. The 3rd byte could be Z axis and 4th byte could be reserved for wheel button, possible 4th & 5th button and maybe something else. To switch back to standard communication, something similar could be used ie. Push pin 6 low and let pin 7 & 8 high (On SymbOS exit)

At the moment I'm not sure how real MSX-mouse reacts to this kind of delayed read and details need to be sorted out, but anyway... You get the idea... I think this 4-byte communication could be done to work with MSX-BIOS as well (with some limitations) as each time the MSX-BIOS actually reads mouse, it does it two times because of trackball support. On second read only some bits affect the read result.

Van NYYRIKKI

Enlighted (5541)

afbeelding van NYYRIKKI

02-01-2014, 15:45

MSX tR BIOS implementation of Mouse / Trackball:

; ******************************************
; Begin Section Mouse/Trackball
; ******************************************



;	Subroutine	S.NEWPAD
;	Inputs		________________________
;	Outputs		________________________

J349D:	CP	12
	JR	C,J34C3			; not for mouse/trackball (lightpen), not supported
	LD	E,0FH			; register 15
	LD	BC,00BFH
	LD	HL,10EFH		; port 1 pulse set and reset mask
	CP	0CH
	JR	Z,J34C5			; read mouse/trackball on port 1
	LD	BC,40FFH
	LD	HL,20DFH		; port 2 pulse set and reset mask
	CP	10H
	JR	Z,J34C5			; read mouse/trackball on port 2
	AND	03H
	SUB	02H
	LD	A,(XSAVE)
	RET	M			; read X-offset option, quit
	LD	A,(YSAVE)
	RET	Z			; read Y-offset option, quit
					; other codes have no function
J34C3:	XOR	A
	RET

J34C5:	DI
	CALL	C357A			; reset 250 kHz counter
	CALL	C354C			; reset puls bit
	CALL	C3561			; read 4 inputbits (used in case of a trackball ?)
	PUSH	AF
	CALL	C3552			; set puls bit
	LD	D,45
	CALL	C355E			; at 0.18 ms since counterreset and read 4 inputbits (DX7-DX4)
	PUSH	AF
	CALL	C354C			; reset puls bit
	LD	D,75
	CALL	C355E			; at 0.29 ms since counterreset and read 4 inputbits (DX3-DX0)
	PUSH	AF
	CALL	C3552			; set puls bit
	LD	D,105
	CALL	C355E			; at 0.41 ms since counterreset and read 4 inputbits (DY7-DY4)
	PUSH	AF
	CALL	C354C			; reset puls bit
	LD	D,135
	CALL	C355E			; at 0.53 ms since counterreset and read 4 inputbits (DY3-DY0)
	PUSH	AF
	CALL	C3552			; set puls bit
	LD	D,180
	CALL	C355E			; at 0.70 ms since counterreset and read 4 inputbits (second DX7-DX4)
	PUSH	AF
	CALL	C354C			; reset puls bit (second DX3-DX0 is send, but not read)
	LD	D,200
	CALL	C357D			; at 0.78 ms since counterreset
	CALL	C3552			; set puls bit (second DY7-DY4 is send, but not read)
	LD	D,220
	CALL	C357D			; at 0.86 ms since counterreset 
	CALL	C354C			; reset puls bit (second DY3-DY0 is send, but not read)
	EI
	POP	AF
	POP	HL			; H=DY3-DY0
	POP	DE			; D=DY7-DY4
	POP	BC			; B=DX3-DX0
	XOR	08H			; "second" DX7-DX4 correct sign
	SUB	02H
	CP	0DH			; MSX-mouse protocol (Second DX7-DX4 not too big) ?
	JR	C,J352A			; yep, mouse
					; otherwise it is a trackball (not sure!)
	POP	AF			; state after puls = DY
	CALL	C3544			; convert trackballdata to offset
	LD	(YSAVE),A
	POP	AF			; state before puls = DX
	CALL	C3544			; convert trackballdata to offset
	JR	J353E

J352A:	LD	A,D
	ADD	A,A
	ADD	A,A
	ADD	A,A
	ADD	A,A
	OR	H			; DY
	NEG				; was send negative
	LD	(YSAVE),A
	POP	AF			; A=DX7-DX4
	POP	DE
	ADD	A,A
	ADD	A,A
	ADD	A,A
	ADD	A,A
	OR	B			; DX
	NEG				; was send negative
J353E:	LD	(XSAVE),A
	LD	A,0FFH
	RET

;	Subroutine	convert trackballdata to offset
;	Inputs		________________________
;	Outputs		________________________

C3544:	XOR	08H			; complement sign
	BIT	3,A
	RET	Z
	OR	0F0H			; make negative
	RET

;	Subroutine	reset puls bit
;	Inputs		________________________
;	Outputs		________________________

C354C:	CALL	C3569			; read psg register with masks
	AND	L
	JR	J3556			; write psg register

;	Subroutine	set puls bit
;	Inputs		________________________
;	Outputs		________________________

C3552:	CALL	C3569			; read psg register with masks
	OR	H
J3556:	PUSH	AF
	LD	A,E
	OUT	(0A0H),A
	POP	AF
	OUT	(0A1H),A		; write psg register
	RET

;	Subroutine	wait until ticks has passed since counter reset and read 4 inputbits
;	Inputs		________________________
;	Outputs		________________________

C355E:	CALL	C357D			; wait until ticks has passed

;	Subroutine	__________________________
;	Inputs		________________________
;	Outputs		________________________

C3561:	LD	A,14
	CALL	C356A			; read psg register 14 with masks
	AND	0FH
	RET

;	Subroutine	read psg register with masks
;	Inputs		E = register, C=AND mask, B=OR mask
;	Outputs		________________________

C3569:	LD	A,E

;	Subroutine	read psg register with masks
;	Inputs		A = register, C=AND mask, B=OR mask
;	Outputs		________________________

C356A:	OUT	(0A0H),A
	IN	A,(0A2H)
	AND	C
	OR	B
	RET

;	Subroutine	wait 1 ms
;	Inputs		C = ticks
;	Outputs		________________________

J3571:	OUT	(0E6H),A
J3573:	IN	A,(0E7H)
	CP	C
	JP	C,J3573
	RET

;	Subroutine	reset 255681 Hz counter
;	Inputs		________________________
;	Outputs		________________________

C357A:	OUT	(0E6H),A
	RET

;	Subroutine	wait until ticks passed since counter reset
;	Inputs		D = ticks (0.004 ms)
;	Outputs		________________________

C357D:	IN	A,(0E6H)
	CP	D
	JP	C,C357D
	RET


;	Subroutine	wait util 0.027 ms passed
;	Inputs		D = ticks
;	Outputs		________________________
;	Remark		UNUSED CODE

?3584:	OUT	(0E6H),A
J3586:	IN	A,(0E6H)
	CP	7
	JP	C,J3586
	RET



; ******************************************
; End Section Mouse/Trackball
; ******************************************

... Seems like it is safe to send Z as 3rd byte... (4th is ignored)

Pagina 2/18
1 | | 3 | 4 | 5 | 6 | 7