EnterMice (Polski)
Interfejs joysticków i myszy PS/2 dla komputera Enterprise 64 / 128
Contents
- 1 Wstęp
- 2 Lista programów współpracujących z myszką (aktualizowana)
- 3 Opis ogólny
- 4 Ważne
- 5 Podłączenie do komputera
- 6 Funkcje
- 7 Korzystanie ze sterownika
- 8 Troubleshooting
- 9 Technical specification
- 10 Informacje dla programistów
Wstęp
Opisany poniżej zintegrowany interfejs został zaprojektowany dla komputerów Enterprise 64/128.
Jest efektem sześciu miesięcy pracy polskiego hobbysty znanego na forach dyskusyjnych pod nickiem Pear. Prace zostały rozpoczęte za namową hiszpańskiego kolegi GFlorez z forum [1].
Głównym przeznaczeniem interfejsu jest możliwość podłączenia taniej i powszechnie dostępnej myszki PS/2 do komputera Enterprise. Ponadto umożliwia podłączenie dwóch joysticków standardu Atari bezpośrednio, bez konieczności stosowania dodatkowych adapterów.
EnterMice bazuje na rozwiązaniach zastosowanych w interfejsie BoxSoft, który obsługuje protokół myszy Neos (MSX).
W jednym z dostępnych trybów pracy EnterMice jest całkowicie kompatybilny ze starszym interfejsem myszki BoxSoft. W innym trybie ruch myszki zamieniany jest na impulsy symulujące ruch joysticka.
Krótka historia o Enterprise i myszy
Rozszerzenie możliwości Enterprise 128 o sterowanie myszką nie jest nowym, ekscentrycznym pomysłem grupy komputerowych retromaniaków. Było to planowane już przez projektantów tego komputera. Problem polegał na tym, że zadanie zostało powierzone skromnej, angielskiej firmie Aztec Software Ltd, która zaprezentowała rozczarowujący efekt swojej pracy. Z dwóch głównych powodów. Po pierwsze, myszka była po prostu brzydka [2], w niczym nie przypominała zaokrąglonych kształtów Enterprise. Po drugie, urządzenie tak naprawdę nie działało jak myszka, tylko naśladowało ruchy joysticka. Również w tym czasie firma Enterprise Computing Ltd. zniknęła z rynku.
Jednakże baza użytkowników w Wielkiej Brytanii pozostała bardzo aktywna w kolejnych latach. Pasjonaci Enterprise zakładali małe firmy. Oferowane były nowe produkty: rozszerzenia pamięci, dedykowane okablowanie, gry, programy użytkowe, emulatory ZX Spectrum, kontrolery dysków IDE, karty EPROM, rozszerzenia płyty głównej, modemy i wiele innych.
Najbardziej płodna była firma Boxsoft, której założycielem był Tim Box. Boxsoft oferowała większość produktów wymienionych powyżej. W pakiecie z programem graficznym Paintbox [3], wprowadzono do sprzedaży adapter [4] wraz z myszką Neos oraz dołączonym do niej sterownikiem. Mysz Neos, wewnętrznie [5] niemal nie różni się od myszy dla komputerów MSX [6] i była już z powodzeniem dostosowywana do innych komputerów 8-bitowych takich jak na przykład Commodore 64.
W tamtym czasie tylko kilka komputerów 8-bitowych posiadało myszkę oraz graficzny interfejs użytkownika (GUI). Było niezwykle trudno sprzedać nowy, nieznany wynalazek do tego nie w pełni zintegrowany z komputerem. Patrząc z dzisiejszej perspektywy, zalety nawigacji systemem operacyjnym i aplikacjami przy użyciu myszki jest czymś oczywistym. Wygoda kończy się natychmiast, gdy mysz przestaje działać ...
Mimo wszystko udało się sprzedać około stu pakietów Paintbox.
Program Paintbox przybył na Węgry oddzielnie. Węgrzy kupowali komputery Enterprise wiedząc o nich tylko tyle, że pochodzą z Wielkiej Brytanii i nic więcej. Gdy wszyskie Enterprise 128 zostały sprzedane, użytkowników pozostawiono samym sobie podobnie jak w macierzystym kraju. Kolejny raz wypłynęły na rynek małe firmy oferujące nowe produkty. Wówczas firma "A studio" rozpoczęła produkcję i sprzedaż produktów Boxsoft, maskując je jako własne produkty. Jedna z wersji Paintbox została pozbawiona opcji sterowania myszką. Mimo to wciąż potrzebowała do pracy sterownika tejże myszki. Po wschodniej stronie Żelaznej Kurtyny nikt nigdy nie słyszał o myszy Neos.
Później, na Węgrzech, powstała karta interfejsu szeregowego [7] dla Enterprise, dzięki genialnemu zespołowi węgierskich projektantów: Gyula Mészáros sprzęt i László Haluska (HSOFT) oprogramowanie. HSOFT przystosował okrojony przez "A studio" sterownik myszki do współpracy z szeregową myszką Mouse Systems, a następnie stworzył sterownik wbudowany w system operacyjny EPDOS 2.x.
To już odległa historia, ale w obecnych czasach globalizacji i ogólnodostępnego Internetu, pojawiło się kilka starych artefaktów Boxsoft+Neos i wszystkie kawałki układanki zaczęły do siebie pasować. W końcu, spełniły się stare obietnice (zobacz reklamy Enterprise Computers Ltd.) i Enterprise doczekał się własnego interfejsu myszki z prawdziwego zdarzenia.
Nowy interfejs EnterMice prezentowany tutaj bazuje na pracy grupy Boxsoft, ale został zaadaptowany do współczesnych potrzeb i stwarza nowe możliwości. (To cud co osiągnął Tim Box wyłącznie przy pomocy kilku bramek i diod). Co do oprogramowania zaś, to sterownik był bardzo dobrze napisany przez D. Rabson, Andrew Fitter i Andrew Richards. Z niewielkimi modyfikacjami, ten sam sterownik jest używany przez interfejs EnterMice.
Podstawowym problemem interfejsów dla Enterprise są złącza oraz sygnały dalece odbiegające od standardów myszy i josticka. Małe złącza krawędziowe, które przypadkowo można podłączyć do góry nogami, sygnały przycisków podciągnięte do +5V podczas, gdy standardem jest łączenie ich do 0V, brak jakichkolwiek zabezpieczeń przed zwarciem kilku przycisków jednocześnie, brak możliwości przesłania informacji zwrotnie do sterownika i prawdopodobnie jeszcze wiele innych przypadłości.
Teraz to co Boxsoft wykonał przy użyciu dostępnych, tanich komponentów, zostało przeprojektowane i ulepszone z użyciem dwóch nowocześniejszych programowalnych układów. Jeden z tych układów (Xilinx XC9572) jest odpowiedzialny za połączenia i konwersję sygnałów do standardowego joysticka Atari. Oryginalny interfejs Boxsoft korzystał tylko z portu Control 1, który mógł być używany do podłączenia myszy Neos lub joysticka (ale nie obu jednocześnie). W niniejszym projekcie są podłączone i udostępnione oba porty joysticków nie zakłócające się ze złączem myszki.
Myszki Neos/MSX nie są dziś często spotykane w związku z czym zaimplementowano konwersję protokołu myszy PS/2 do MSX. Tą część obsługuje drugi z układów, prosty i niedrogi kontroler Atmel AT89C4051, którego oprogramowanie wewnętrzne zostało zoptymalizowane do pracy nawet z podrasowanym komputerem Enterprise. EnterMice działa równie dobrze z Enterprise ze standardowym zegarem 4 MHz jak i z jego superdoładowaną 10 MHz wersją.
Również protokół odczytu myszy został wzbogacony o nowe rozszerzenie protokołu MSX autorstwa Prodatron i NYYRIKKI, które pozwala na odczytanie stanu nawet pięciu przycisków oraz kółka, jeśli myszka je posiada.
Lista programów współpracujących z myszką (aktualizowana)
Paintbox ze sterownikiem myszy.
Enterprise Graphical Interfance (EGI) ze sterownikiem myszy.
SymbOS wewnętrznie, tylko w trybie zgodności z Boxsoft, ale wkrótce również w podstawowym trybie myszy EnterMice.
Programy w Basicu mogą korzystać ze sterownika myszy.
Stare programy używające joysticka w porcie 1, z EnterMice w trybie emulacji joysticka.
EPDOS 2.X wewnętrznie, tylko z kartą portu szeregowego.
Opis ogólny
Ważne
Nie podłączaj interfejsu do komputera przy załączonym zasilaniu !
Natychmiast wyłącz zasilanie, jeśli po podłączeniu interfejsu komputer nie uruchomi się prawidłowo lub zauważysz jego nietypowe zachowanie !
Sprawdź czy interfejs jest podłączony prawidłowo i spróbuj ponownie.
Myszkę i joysticki można podłączać i odłączać podczas pracy komputera, jednak nie jest to zalecane. Bezpieczniej jest wykonać wszystkie podłączenia przy wyłączonym zasilaniu.
Podłączenie do komputera
Płytka interfejsu jest podłączona jednocześnie do trzech złączy krawędziowych z tyłu komputera: Control 1, Control 2 oraz Serial. Złącza w interfejsie są zamontowane pod kątem nieco większym niż 90°. Jest to celowe, aby zapewnić lepsze dopasowanie interfejsu do złącz Enterprise.
Możliwe jest podłączenie tylko w jeden sposób, jednak może się zdarzyć, że styki nie trafią centralnie w kontakty złącza krawędziowego. Jeśli tak się stanie połączenie może być niestabilne i komputer i/lub interfejs mogą nie pracować prawidłowo.
Właściwie podłączony interfejs działa prawidłowo od razu po załączeniu zasilania komputera.
Po uruchomieniu wykonywany jest self-test interfejsu, podczas którego obie diody LED błyskają 3 razy (bez względu na ustawienie przełącznika DS3).
Po podłączeniu EnterMice do komputera, zalecane jest podłączenie myszki przed załączeniem zasilania. Mimo to interfejs posiada funkcję hot-plug umożliwiającą rozpoznanie podłączenia myszki w trakcie pracy, wówczas jest ona identyfikowana i przygotowywana do pracy (trwa to około 2-3 sekund).
Pomyślne zakończenie inicjalizacji myszki sygnalizowane świeceniem zielonej diody LED (jeśli przełącznik DS3 jest ustawiony w pozycji ON).
Funkcje
Interfejs posiada kilka trybów pracy. Do konfiguracji służy pięcio-sekcyjny przełącznik (DS).
Ustawienia konfiguracji mogą być zmieniane podczas pracy interfejsu. Nie jest wymagane wyłączanie ani restartowanie komputera.
Poniżej opis wszystkich możliwych ustawień.
DS1 | DS2 | Tryb pracy |
---|---|---|
ON | ON | Podstawowy tryb myszy EnterMice |
OFF | ON | Tryb myszy zgodny z BoxSoft. Przyciski myszy są odwrócone. Głównym przyciskiem jest prawy przycisk myszy. |
OFF | OFF | Tryb emulacji joysticka (ruchy myszy są przekierowane do portu Control 1, złącze Joystick 1 zostaje odłączone) |
ON | OFF | nie używane (faktycznie EnterMice emuluje joystick w kolumnie K klawiatury) |
Złącze Joystick 2 działa zawsze w ten sam sposób, niezależnie od wybranego trybu pracy interfejsu.
DS3 | Kontrolki LED |
---|---|
OFF | Wyłączone |
ON | Załączone |
Konfiguracja trybu emulacji joysticka
DS4 | Czułość |
---|---|
OFF | Normalna |
ON | Podwyższona |
DS5 | Korekcja ruchów ukośnych |
---|---|
OFF | Wyłączona |
ON | Załączona |
Korekcja ruchów ukośnych poprawia precyzję emulacji joysticka dla ruchów po skosie kosztem niewielkiego zmniejszenia prędkości.
Korzystanie ze sterownika
W tym miejscu [8] znajdziesz sterownik myszy.
Poniższy tekst pochodzi z oryginalnej instrukcji obsługi Paintbox, poprawionej i uzupełnionej o nowe możliwości EnterMice.
Jak używać myszy we własnych programach ?
Korzystanie z myszy nie jest zarezerwowane wyłącznie dla programów w kodzie maszynowym. Łatwo można dodać obsługę myszy niemal do każdego programu w BASIC'u. W tym celu konieczne jest użycie rozszerzenia EXOS nazywanego sterownikiem myszy ("MOUSE.XR").
Sterowniki ten umieści wskaźnik myszy na dowolnym ekranie graficznym i będzie odzwierciedlał ruchy myszy poprzez przemieszczanie kursora po ekranie.
Sterownik myszy może wykonywać różne polecenia i funkcje, na przykład włączyć lub wyłączyć kursor. Istnieją dwie metody komunikacji ze sterownikiem, pierwsza przez bezpośredni odczyt i zapis, druga z pośrednictwem zmiennych systemowych.
Loading
The Mouse Driver can be loaded by all methods ie; "START" from Basic (if from tape) or load "MOUSE.XR". It can also be loaded from the "WP", from EXDOS or from any other language (check appropriate language for details).
Once loaded it will remain resident until the next hard reset or switch off of the computer.
Then, to properly work it is necessary to initialize it with the EXOS command ":PB". The EGI and Paintbox do this internally
Ignore the error message it gives. The error code(obtained in Basic with EXTYPE) is 9000+memory page where the driver has been loaded. This was made deliberately by the driver writers.
A version that auto-initialises itself can be provided if requested, but then it will not work with the EGI or Paintbox, only in Basic.
Never load two instances of the driver nor execute two times the initialization command, as it can hang the Enterprise.
Executing ":MOUSE" it will show some version information of the driver and, if a Entermice is plugged it also will show Entermice information.
Communicating with the mouse driver
As stated above there are two ways in which you can communicate with the Mouse Driver. To demonstrate the two methods and their actions, we shall first look at all the commands, functions and variables then demonstrate their use within a program.
Printed commands and functions
The first and most important action is to open the Mouse channel, ie OPEN £?:"MOUSE:" (? being a channel number).
Commands issued by printing characters to Mouse channel:
O | Turn pointer on |
---|---|
o | Turn pointer off |
P | Request X & Y position |
Results or status obtained by reading a character from Mouse channel:
Only read after sending "P":
X | Low byte |
X | High byte |
Y | Low byte |
Y | High byte |
Always readable:
Fire = "1" if main button depressed, "0" if not.
System variables
Address | Content | Default |
---|---|---|
180 | Video channel, pointer required on | 101 |
181 | Position of X,Y co-ordinate on status line | 30 |
182 | Status co-ordinate display: 1 on, 0 off | 0 |
183 | Colour of pointer {check tech section} | 255 |
184 | Low byte of X co-ordinate | |
185 | High byte of X co-ordinate. Check demo prog. for co-ordinate conversion. | |
186 | Low byte of Y co-ordinate | |
187 | High byte of Y co-ordinate | |
188 | Status of fire button 0 off, 1 on | |
189 | Input device:
0 - Internal Joystick 1 - Control 1 2 - Control 2 3 - Boxsoft 4 - EnterMice (default) 5 - Serial Mouse Sytems 6 - Serial Microsoft on a future release(actually 6 acts the same as 5) >6 - Not implemented |
|
190 | Status of secondary button and spare buttons if present, counter of wheel if present.
Bits 0 to 3 signed nibble of the wheel counter(7 -> -8) Bit 4 wheel button Bit 6 and 5 spare buttons Bit 7 secondary button Status of buttons: 0 off, 1 on |
Examples
100 PROGRAM "ms_test.bas" 110 NUMERIC X,V,MAX_Y",X_COUNT,LASTX,LASTY 120 GRAPHICS 130 CALL MOUSE_SETUP 130 OPEN £1:"mouse:" ! Open a channel to the Mouse 140 DO 15D CALL MOUSE_POS 160 LOOK 1:FIRE ! Check the fire button 170 IF FIRE THEN 130 PRINT £1:"o"; ! Turn the pointer off 190 PLOT LASTX,LASTY,X,Y 200 PRINT 1:"O"; ! Turn the pointer on 210 ELSE I10 PLOT X,Y, 230 END IF 240 LET LASTX=X:LET LASTY=Y 250 LOOP 250 END 270 DEF MOUSE_SETUP 280 LET CHAR_Y=20 ! No. of characters screen high 290 LET X_COUNT=2 ! Pixel calc no 300 SET 180,101 ! Video channel to put mouse pointer on 310 SET 181,30 ! Position of co-ordinates on status line 320 SET 182,1 ! Show co-ordinates 330 SET 183,255" ! Colour of pointer 310 LET MAX_Y=CHAR_Y*36-2 ! Convert char_y to co-ordinates 350 END DEF - Note X_COUNT is = to "2" in 2 colour mode "4" in 4 colour mode "8" in 16 colour mode and "16" in 255 colour mode. All these values double when in lores.
Now you must add the MOUSE_POS routine. It asks the mouse position to the driver. Select one of the two following ways:
Reading the pointer co-ordinates by reading from Mouse channel.
DEF MOUSE_POS PRINT £1:"P" LOOK £1:XL LOOK £1:XH LOOK £1:YL LOOK £1:YH LET X=XL+256*XH LET Y=YL+256*YH END DEF
Reading the pointer co-ordinates from the system variables.
DEF MOUSE_POS ASK 184 XL ASK 185 XH ASK 186 YL ASK 187 YH LET X1=XL+256*XH LET X=X1*X_COUNT LET Y=YL+256*YH LET Y=Y*2 LET Y=MAX_Y—Y END DEF
You can also command the driver to put the pointer where you want:
Setting the Mouse co-ordinates by the system variables.
DEF POS_MOUSE LET X=INT(X/X_COUNT) LET XL=X-256*INT(X/256) LET XH=INT(X/256) LET Y=MAX_Y-Y:LET Y=INT(Y/2) LET YL=Y-256*INT(Y/256) LET LET YH=INT(Y/256) SET 184,XL SET 185,XH SET 186,YL SET 187,YH END DEF
This program is a very simple art program; simply drawing a line to
follow the movement of the mouse when the "Mouse Button" is
pressed. A call is made to MOUSE_POS on line 150, depending on
how you want to read it you should add into the program the
appropriate procedure from the two listed. There is another
procedure listed, that routine enables you to set the position of the
pointer. Simply call it with the desired position in variables X. and Y,
experiment with the different routines, and try and add them into
your own programs, it won't take long to get the feel of them and
after a very short while you will discover just how easy it is to
incorporate the mouse into existing programs and to write mouse
specific programs.
How to use the wheel and the spare buttons in your programs
To manage bits in Enterprise Basic is slow and difficult. The System Variable 190 has a lot of information in it but it's not easy to extract. You can use this machine code routine inside a Basic program to explode it in five bytes. In addition this MC routine will put to zero the Z_COUNTER every time it's executed:
100 ALLOCATE 42 110 CODE XPLOD=HEX$("18,05,00,00,00,00,00,23,06, 00,0E,BE,F7,10,FE,00,C0,7A,06,04,23,36,00,17,CB, 16,10,F8,23,7A,36,00,ED,6F,57,06,01,0E,BE,F7,10,C9") 120 GRAPHICS 130 OPEN £1:"MOUSE:" ><><><><><><> 520 CALL USR(XPLOD,XPLOD)! We pass the XPLOD address in "hl" register pair ><><><><><><> 930 PRINT PEEK(XPLOD+2)! Secondary mouse button \ 940 PRINT PEEK(XPLOD+3)! Spare button \ 950 PRINT PEEK(XPLOD+4)! Spare button / 0 idle, 1 pressed 960 PRINT PEEK(XPLOD+5)! Wheel button / 970 LET B=PEEK(XPLOD+6)! Z_COUNTER(wheel) two's complement 7 to -8 980 IF B<8 THEN PRINT B 990 IF B>7 THEN PRINT B-16
Here is the disassembly of the machine code routine:
ORG: jr CODE ;hl contains the ORG address BUTTON2: db 0 BUTTON3: db 0 BUTTON4: db 0 BUTTON5: db 0 Z_COUNT: db 0 CODE: inc hl ld b,0 ; read ld c, 0BEh ; 190 rst 030h db 10h ;EXOS 16, Read System Var 190 cp 0 ret nz ; if var 190 not found, the driver has not been loaded, return to Basic ld a, d ;put the obtained value in "a" to be exploded ld b, 4 ; we need a count of 4 for the buttons loop LOOP: inc hl ld (hl), 0 ; we don't need old values rla ; rotate left "a" and put bit 7 on carry rl (hl) ; put the carry bit on bit 0 of (hl) djnz LOOP inc hl ; we still have to extract the wheel count ld a,d ; recover original 190 variable content on "a" ld (hl), 0 ; we don't need old value rld ; we are only interested on low nibble of "a" ld d, a ; a nibble filled of zeros has come from (hl) to reset the wheel counter ; on low nibble of "a" but leaving the buttons intact on high nibble ld b, 1 ; now we need to write the variable ld c, 0BEh ; 190 rst 030h db 10h ;EXOS 16, Write System Var 190 ret ;return to Basic
This is an explanation of the procedure to program the wheel:
Low nibble of System variable 190 holds the count of impulses received from the wheel since the last time it was reset. The impulses are positive or negative, the driver adds or subtracts them to the counter, that can hold a value from 7 to -8. The program has to provide a timer routine to check the counter(with XPLOD) every given period. Once checked, the counter is reset to 0(also by the XPLOD routine), an the value found(XPLOD+6) can be used for a task, for example to scroll the screen.
Observe that the secondary mouse button is a "wired" one, and so can also be read directly from the keyboard matrix(with the routine described on the "Reading the joystick interface" section) or easier comparing the value of var 190 with 127(the secondary button is the 7 bit):
ASK 190 SECBUTT IF SECBUTT>127 THEN GOTO MENU !secondary mouse button pressed!!!
Driver technical information
Executing the HELP command in EXOS you can see the version of the driver in a list that shows all the extensions.
By now the driver only works on graphic modes but it is planned to implement some form of pointer on text mode. Once achieved it will be easy to use the mouse for example on the Basic editor, WP or EXDOS.
Values for EXOS variable 183 to change mouse pointer colour
SETTING | RESULTANT | |
---|---|---|
INK | COLOUR | |
2 COLOUR MODE | 0 | 0 |
255 | 1 | |
4 COLOUR MODE | 0 | 0 |
240 | 1 | |
15 | 2 | |
255 | 3 | |
16 COLOUR MODE | 0 | 0 |
192 | 1 | |
12 | 2 | |
204 | 3 | |
36 | 4 | |
228 | 5 | |
48 | 6 | |
240 | 7 | |
3 | 8 | |
195 | 9 | |
15 | 10 | |
207 | 11 | |
51 | 12 | |
243 | 13 | |
63 | 14 | |
255 | 15 | |
255 COLOUR MODE | 0-255 | 0-255 |
Joystick mode of the EnterMice mouse interface
A mouse plugged on the EnterMice PS/2 port is not just restricted to acting as a mouse, it can be made to simulate a joystick. To activate this mode you must put to OFF both DS1 and DS2 switches. The interface then will convert the mouse movement on the PS/2 connector to joystick movement on Joy 1 port. You don't have to unplug your real joystick from that port as it will be disabled. The mouse will then send movement like that of a joystick, useful to manage old programs or games.
If DS3 is ON, in joystick mode lights up red LED. It's blinking when any direction-contact is shorted.
NOTE: The fire button is the left hand button on the mouse. To make use of the right hand button use the routines shown in the section on the mouse interface.
The joystick ports
The EnterMice mouse interface will not only work as a mouse interface but as an intelligent joystick interface. Any ATARI-Kempston-Amiga style joystick can then be inserted into one of the two 9 pin connectors at the back of the interface board. If the joystick has an autofire option it will work. Mouse and joysticks can stay connected at the same time as they don't interfere one to the others.
Reading the joystick interface
Originally the control ports of the Enterprise only had 1 FIRE button, but now the EnterMice interface provides two more on both ports. Obviously, they will not work on old games, only on new releases or new conversions of games.
All normal methods of reading the two ports work. The only extra code required is to read the extra fire buttons. An example of the code is listed below.
100 PROGRAM "JOYFIRE2.BAS" 110 ALLOCATE 40 120 CODE FIRE=HEX$("7C,F3,D3,B5,DB,B6,FB,A5,28,04,21,00,00,C9, 21,01,00,C9") 130 DO 140 LET FIRE2=USR(FIRE,4) 150 IF FIRE2 THEN PRINT "FIRE I PRESSED" 160 LOOP
This is the disassembly of that little code:
org: 7c ld a,h ; h is the row, l is the column. (H*256+L) f3 di d3b5 out (b5h),a dbb6 in a,(b6h) fb ei a5 and l ; bit 0 is J column, bit 1 is K column, and bit 2 is L column. 2804 jr z,pressed 210000 ld hl, 00h c9 ret pressed: 210100 ld hl,01h c9 ret
You can read the three Fire buttons of the two joystick ports of EnterMice changing in the Basic line "140 LET FIRE2=USR(FIRE,4)", the "4" by a "1" or a "2".(H=0) For the second port you must use "1281","1282" or "1284".(H=5)
This method also can be utilised to read the two main mouse buttons, that are shared with the FIREs of control 1.
Troubleshooting
Keyboard issue
During the creation of the EnterMice, a fairly serious error in the design of the Enterprise was casually discovered.
It stays totally unnoticed if nothing is connected to the ports Control 1 and Control 2. However, the EnterMice uses them...
The issue is about interferences on KB0..KB9 ports from keyboard, that are also utilised by the control ports.
If only one key is pressed at the keyboard, then nothing wrong happens (see figure 1).
However, if you press two keys in the same column simultaneously, the signal from the selected line will be transferred to the line of the second key as well (figure 2).
The Enterprise lacks blocking return diodes to separate the rows of the keyboard!
Electrically nothing will happen (the LS145 decoder inside the computer has open collector outputs), but reading from the external ports Control 1 and Control 2 causes errors.
In order to eliminate the cause, diodes should be added to each row of keys on the Enterprise, to avoid that pressing more than one key it can cause "collisions" (figure 3).
Pear has prepared a draft of a PCB to fix it, but it has not been tested yet. In the meanwhile, in order to avoid errors, the keyboard should not be operated while joysticks or mouse are in use.
Microsoft Optical Mouse
The PS/2 Microsoft Optical Mouse is a special case. It should be only connected inserted on its original Microsoft USB to PS/2 converter. It will work with EnterMice if connected before power on, but in this particular case, you can not use the hot-plug feature as it will be not recognised.
EnterMice can be forced to recognise the Microsoft mouse during operation, you only need to momentarily short the RESET pin-header on the interface or press RESET button on newer board version (it resets only the interface, not the computer).
Technical specification
Joystick port pinout
pin | signal |
---|---|
1 | Up |
2 | Down |
3 | Left |
4 | Right |
5 | Fire 3 |
6 | Fire 1 |
7 | +5 V |
8 | GND |
9 | Fire 2 |
Control Map
J column (bit 0) | K column (bit 1) | L column (bit 2) | |||||
---|---|---|---|---|---|---|---|
JM=0* | JM=1* | JM=0 | JM=1 | JM=0 | JM=1 | ||
Control 1 | Row 0 Fire | Joy 1 Fire 1 | Mice Left Btn | Mice Left Btn or Joy 1 Fire 2* | Joy 1 Fire 2 | Mice Right Btn or Joy 1 Fire 3* | |
Row 1 Up | Joy 1 Up | Mice D0 | Mice D0 | spare | spare | spare | |
Row 2 Down | Joy 1 Down | Mice D1 | Mice D1 | spare | spare | spare | |
Row 3 Left | Joy 1 Left | Mice D2 | Mice D2 | spare | spare | spare | |
Row 4 Right | Joy 1 Right | Mice D3 | Mice D3 | spare | spare | spare | |
Control 2 | Row 5 Fire | Joy 2 Fire 1 | Joy 2 Fire 2 | Joy 2 Fire 3 | |||
Row 6 Up | Joy 2 Up | spare | spare | spare | spare | ||
Row 7 Down | Joy 2 Down | spare | spare | spare | spare | ||
Row 8 Left | Joy 2 Left | spare | spare | spare | spare | ||
Row 9 Right | Joy 2 Right | spare | spare | spare | spare |
* Mouse buttons have higher priority * JM=0 (DS1 ON) native EnterMice mouse mode JM=1 (DS1 OFF) joystick emulation & BoxSoft compatible mode
Sega Twister
to connect the Sega six-button pad [9]
Sega Six Button Controller Hardware Info
Interface Protocol of SEGA MegaDrive's 6-Button-Controller
pin | Select = Low | Select = High | Select = pulse-3 |
---|---|---|---|
1 | Up | Up | Button Z |
2 | Down | Down | Button Y |
3 | GND | Left | Button X |
4 | GND | Right | not used |
5 | +5V | ||
6 | Button A | Button B | not used |
7 | Select | ||
8 | GND | ||
9 | Start | Button C | not used |
Informacje dla programistów
Stałe czasowe EnterMice
Firmware interfejsu EnterMice został zoptymalizowany dla cyklicznych odczytów z częstotliwością 50 Hz (przerwanie wideo).
Domyślny cykl odczytu | 20 ms |
Czas oczekiwania na wykonanie self-testu myszy PS/2 (timeout) | ok. 2000 ms |
Czas pobierania kompletu danych z myszy PS/2 | max. 12 ms |
Czas od zmiany stanu sygnału RTS do wystawienia danych (półbajtu) gotowych do odczytu | 25 μs |
Czas bezczynności przed kolejnym odczytem (liczony od wystawienia półbajtu) | 14 μs |
Czas od ostatniego odczytu do wyzerowania licznika półbajtów (timeout)* | 1500 μs |
Domyślny czas odpytywania myszy w trybie emulacji joysticka | 30 ms |
Czas odpytywania myszy w trybie emulacji joysticka, gdy mysz nie jest poruszana (minimalizacja opóźnienia) | 12,5 ms |
* Po tym czasie rozpoczyna się kolejny odczyt danych z myszy.
Bufor danych
Bufor danych w EnterMice ma rozmiar 16 bajtów.
Aktualnie wykorzystana jest tylko połowa. Reszta może zostać wykorzystana w przyszłości.
Bity | Górna połowa | Dolna połowa | Zawartość | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Bajt | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | ||||
0 | wartość X | całkowita ze znakiem (dodatnia oznacza ruch w lewo) | protokół BoxSoft | |||||||||
1 | wartość Y | całkowita ze znakiem (dodatnia oznacza ruch w górę) | ||||||||||
2 | 0 | 0 | 0 | 1 | 0 | Btn5 | Btn4 | Btn3 | Identyfikator protokołu i stan przycisków 3,4,5 (1=wciśnięty) | rozszerzony protokół MSX | ||
3 | kółko poziome* | wartość Z | całkowita ze znakiem (dodatnia oznacza ruch kółka w górę) | |||||||||
4 | ExCnt | ID myszy | Ilość dodatkowych bajtów możliwych do odczytu (włącznie z tym) i ID myszy PS/2 | rozszerzony protokół EnterMice | ||||||||
5 | Hw wer. mj. | Hw wer. mn. | Wersja sprzętu (major.minor) | |||||||||
6 | Fw wer. mj. | Fw wer. mn. | Wersja firmware (major.minor) | |||||||||
7 | ID urządzenia | Identyfikator EnterMice to 5Dh |
* jeszcze nie zaimplementowane, aktualnie wszystkie 8 bitów reprezentuje wartość Z (kółko pionowe)
Nie trzeba za każdym razem odczytywać wszystkich danych z bufora.
Odczyt może zostać przerwany w dowolnym momencie. Nastąpi wówczas timeout i interfejs wykona kolejny odczyt danych z myszki, po czym znów będzie gotowy do przesłania danych z bufora.
Ostatni stan sygnału RTS również nie ma znaczenia. EnterMice reaguje na zmianę stanu sygnału, a nie na jego poziom.
Mouse reading
; Here begin the Neos mouse reading | ||
ld hl,X_REL | ; first byte | |
ld a,2 | ; put RTS low, the contrary to normal MSX | |
out (0B7h),a | ||
ld b,3 | ; long delay. Stock was 8 | |
call WAIT | ||
call READ_4BIT | ; read four higher bits | |
rld | ; push them in (HL) | |
xor a | ; put RTS high | |
out (0B7h),a | ||
ld b,1 | ; short delay. Stock was 5 | |
call WAIT | ||
call READ_4BIT | ; read four lower bits | |
rld | ; push them in (HL) | |
ld hl,Y_REL | ; second byte | |
ld a,2 | ; put RTS low | |
out (0B7h),a | ||
ld b,1 | ; short delay. Stock was 5 | |
call WAIT | ||
call READ_4BIT | ; read four higher bits | |
rld | ; push them in (HL) | |
xor a | ; put RTS high | |
out (0B7h),a | ||
ld b,1 | ; short delay. Stock was 5 | |
call WAIT | ||
call READ_4BIT | ; read four lower bits | |
rld | ; push them in (HL) | |
;<======Here will be added the future Wheel and three spare buttons reading. SECOND TENTATIVE | ||
ld hl,SW_Z_STATUS | ||
ld a,2 | ; put RTS low | |
out (0B7h),a | ||
ld b,1 | ; short delay. Stock was 5 | |
call WAIT | ||
call READ_4BIT | ; read four higher bits | |
and 15 | ||
cp 1 | ; IF THIS NIBBLE=0001 THEN THE MOUSE IS IN EXTENDED PROTOCOL | |
jr z,CONTINUE_READ | ||
xor a | ; we must leave RTS high for the next mouse reading cycle | |
out (0B7h),a | ;IGNORE THAT NIBBLE | |
ld (hl),0 | ; we don't need old values | |
jr STOP_READ | ||
CONTINUE_READ: | ||
xor a | ; put RTS high | |
out (0B7h),a | ||
ld b,1 | ; short delay. Stock was 5 | |
call WAIT | ||
call READ_4BIT | ; read four higher bits, the three lower bits are the buttons. They come ready to store | |
push af | ; push them in stack. they are in the lower nibble. | |
ld a,(hl) | ; | |
push af | ;save the Z counter for later. | |
ld a,2 | ; put RTS low | |
out (0B7h),a | ||
ld b,1 | ; short delay. Stock was 5 | |
call WAIT | ||
call READ_4BIT | ; read four bits | |
rld | ;we need z displacement in 8 bit | |
xor a | ; put RTS high for the next mouse reading cycle | |
out (0B7h),a | ||
ld b,1 | ; short delay. Stock was 5 | |
call WAIT | ||
call READ_4BIT | ; read four lower bits. Z displacement | |
rld | ; push them in (HL) ;NOW WE HAVE Z displacement in (hl) | |
pop af | ; restored Z counter to "a", but we have garbage on high nibble | |
and 00Fh | ||
bit 3,a | ||
jr z,SIGN_DONE | ||
or 0F0h | ||
SIGN_DONE: | ; now we have the sign extended to 8 bits on "a" | |
add a,(hl) | ||
cp 128 | ; positive or negative? | |
jr c,POSITIVE | ||
cp 248 | ; lower than -8? | |
jr nc,FINISHED | ; | |
ld a,248 | ; -8 is the bottom | |
jr FINISHED | ||
POSITIVE: | ||
cp 8 | ; higher than 7? | |
jr c,FINISHED | ||
ld a,7 | ; 7 is the top | |
FINISHED: | ; the excess of 7 or -8 has been wiped | |
ld c,a | ; save Z addition on c | |
pop af | ; retrieve the buttons status. They are now on first nibble of a | |
rld | ; buttons stored | |
ld a,c | ; we only need the first nibble of Z counter addition | |
rld | ; the spare buttons status and the Z counter are now in SW_Z_STATUS | |
STOP_READ: | ||
xor a | ; recall buttons on row 0 | |
out (0B5h),a | ||
in a,(0B6h) | ; read Mouse buttons | |
and 7 | ; mask | |
xor 7 | ; flip them all as on Enterprise a pressed key is 1 and released 0 | |
rl (hl) | ; Get ready the bit 7 of "hl" register pair. Inside is SW_Z_STATUS, variable number 190 | |
srl a | ; This is the very FIRST "srl a". The button status is now in the carry flag | |
; secondary button of Boxsoft is read on J column. Primary button of EnterMice is read on K column | ||
push af | ||
ld a,(INPUT_DEVICE) | ||
cp 3 | ; Boxsoft interface mode buttons | |
jr nz,L_BUTTON | ||
pop af | ; We need the value of "a" and "f" registers. Carry flag still stores the value of secondary button | |
rr (hl) | ; secondary button goes to bit 7 of SW_Z_STATUS, variable number 190 | |
srl a | ; Primary button of Boxsoft is on J column. This is the second "srl a" | |
JR MAIN_BUTTON | ||
L_BUTTON: | ; EnterMice interface mode buttons | |
pop af | ; retrieve the value of register "a". "f" is disposable, soon we will load the button on carry flag | |
push af | ; I still will need later the register "a" value | |
srl a | ; two "srl a" because the secondary button of EnterMice is read on L column | |
srl a | ; the proper button status is now in the carry flag | |
rr (hl) | ; secondary button goes to bit 7 of SW_Z_STATUS, variable number 190 | |
pop af | ; retrieve the value of register "a" just after the FIRST "srl a" | |
MAIN_BUTTON: | ||
and 1 | ||
ld (FIRE_STATUS),a | ; EXOS Variable 188. K column if Boxsoft or L column if EnterMice | |
call sub_C3A6 | ; this is the "corrections and drawing" routine where the "velocity" 1.1 modification was made | |
ld a,(X_REL) | ||
ld c,a | ||
ld a,(Y_REL) | ||
or c | ||
ret | ||
XXXXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXX | XXXXXXXXXXXXXX |
WAIT: | ||
nop | ||
nop | ||
nop | ||
dec b | ||
jr nz,WAIT | ||
ret | ||
XXXXXXXXXXXXXX | XXXXXXXXXXXXXXXXXXXX | XXXXXXXXXXXXXX |
READ_4BIT: | ; I split the routine in two to not put more processor time | |
ld b,4 | ||
ld d,0 | ||
ld a,(INPUT_DEVICE) | ||
cp 3 | ||
jr z,L_COLUMN | ||
K_COLUMN: | ||
ld a,b | ||
;inc c | ; this is not necessary | |
out (0B5h),a | ||
in a,(0B6h) | ||
;ld c,a | ; this is not necessary | |
rra | ; data read from K column | |
rra | ||
rl d | ||
djnz K_COLUMN | ||
jr CONTINUE | ||
L_COLUMN: | ||
ld a,b | ||
;inc c | ; this is not necessary | |
out (0B5h),a | ||
in a,(0B6h) | ||
;ld c,a | ; this is not necessary | |
rra | ; data read from L column | |
rl d | ||
djnz L_COLUMN | ||
CONTINUE: | ||
ld a,d | ||
ret |