╔════════════════════════ ═══════════════════ ═══════════════════╗ ║ Coding. ║ ╙─────────────────────────────── ───────────────────────────────╜ (C) EVP-SOFT Determining availability of Kempston Joystick. On the foreign Spectrum Kempston joystick selected by reset A5 on the address bus, so its port #DF (223), but on Russian Spectrums with a standard Kempston joystick port became port #1F(31). In the absence of a Kempston mouse this is not important, and if any program will access the joystick via #DF then it will work fine. The Kempston joystick bit layout is as follows: D0 - right; D1- left; D2 - down; D3 - up; D4 - fire, activated bit in differences from the keyboard is set to 1. In some toys there is an “inverted” bit layout (for example, in Subway Vigilante). The traditional way to determine the presence of a Kempston joystick based on the fact that the three most significant bits (D5, D6, D7) if present reset to 0. For example: XOR A IN A,(#1F) AND #E0 ;#E0 = %11100000 JR Z, there is a joystick No JR joystick or like this: XOR A IN A,(#1F) R.L.A. JR NC, there is a joystick No JR joystick However, these methods do not work on many Spectrum-compatible devices. our cars, for example Scorpions, some Pentagons and many others. There are several reasons: firstly, on many boards not everything the most significant bits of the Kempston port of the joystick are reset to 0, it happens that they are all (or some of them) set to 1; secondly on branded Spectrums and on Scorpions when contacting any if there is a missing port, the contents of the port are read from it attributes ("port #FF") - this is where the difficulties associated with connecting a CDOS modem to Scorpion or GRM, because on the board there is no such port. To eliminate the second reason, you need to understand how it works - no attribute port. Display starts immediately upon arrival signal INT, more precisely, immediately after INT the upper part is drawn curb and at this time the attribute port is disabled. When will it start? the screen begins to draw, then attribute bytes come from the attribute port ributs that are currently displayed on the monitor (however, in those moments when the side parts are drawnborder, attribute port turns off again) - this phenomenon allows you to synchronize the boron durious effects. So, to determine the presence of a Kempston joystick (and this also applies to Kempston mice) its port must be polled only immediately after INT, while the attribute port is disabled, because by- If there is no joystick, different signals can come from its port. attribute port trash. Well, to eliminate the first cause, it is necessary to determine the presence Kempston joystick for the least significant 5 bits, but there is truth in this one drawback, namely, if, when the program checks for the presence Kempston joystick hold it - the program will not detect his presence. So, the optimal way to determine the Kempston joystick is works on absolutely all machines with 100% reliability: ; ; (C) EVP-SOFT ; ; while Kempston availability is being determined ; joystick, it is advisable to set the mode ; IM 2 and interrupt routine ; make it short: ;I_ADDR EI ; RETI ; TEST_J HALT ; immediately after HLT the attribute port is turned off. XOR A IN A,(#1F) AND #1F ;#1F = %00011111 JR Z, there is a joystick No JR joystick Determining the presence of Kempston Mouse Mouse name"Kempston" does not mean that it is connected is installed instead of a Kempston joystick. To connect a Kempston mouse, you need to wives a special controller, because Kempston mouse coordinates (from - differences from the AY mouse) are calculated in hardware rather than in software. Communication with the controller is carried out through three ports: #FADF - buttons, only the three least significant bits are used, if the bit reset to 0, which means the button is pressed: D0-right, D1-left, D2-medium. #FBDF - horizontal coordinates #FFDF - vertical coordinates Mouse coordinates can go through 0 or #FF. Define the presence of a Kempston mouse is possible by the fact that in its absence from #FF is read from all three mouse ports, of course, when The attribute port is turned off. If it came from at least one port not #FF, it means there is a mouse. However, if after turning on the computer there is no touch the mouse, then from the coordinate ports will also come #FF, and the presence of a mouse will not be detected - therefore, after turning on On your computer, always move the mouse, otherwise no program will will find. In general, the presence of a Kempston mouse can be determined, for example, like this: ; ; (C) EVP-SOFT ; ; while Kempston availability is being determined ; mouse preferablyset IM 2 mode ; and the interrupt handling program ; to put it short: ;I_ADDR EI ; RETI ; TEST_M LD BC,#FADF HALT ; immediately after HLT the attribute port is turned off. IN A,(C) CPL LD E,A INC B HALT ; this HLT can be removed IN A,(C) CPL OR E LD E,A LD B,#FF HALT ; and it is advisable to leave this HLT IN A,(C) CPL OR E JR NZ, there is a mouse JR mouse no
Share your thoughts about the article