╔════════════════════════ ═══════════════════ ═══════════════════╗ ║ Coding. ║ ╙─────────────────────────────── ───────────────────────────────╜ From : Jason Frost To : PROTON PR> PR> Determining the availability of Kempston Joystick. PR> PR> On the foreign Spectrum Kempston the joystick is selected PR> by resetting A5 on the address bus, thus its port PR> #DF (223), but on Russian Spectrums the standard port PR> Volume Kempston joystick became port #1F(31). When from- PR> the absence of a Kempston mouse is not important, and if any PR> if the program accesses the joystick via #DF then it PR> will work fine. There is most likely a typo here. NAVY MOVES doesn't work. But The adapted programs work on both our and branded machines. Our camston is selected at zeros on A5, A6, A7, and the address #DF of this does not provide. PR> PR> PR> are reset to 0. For example: PR> PR>XOR A PR>IN A,(#1F) !??????? Actually, the _full address_ of Kempston's port is #FF1F. According to generally accepted specifications, port selection is carried out zeros on one or moreaddress lines, and clean the address bus looks like #FFFF. Address bus size in Z80 (Z8400) 16 bits, and when working on shortened 8-bit addresses at the highest part contains a random value, which may lead to incompatibility with different versions of equipment. But this is already from the field of professional programming. B professional systems (IS'DOS for example) the requirement is always specifying the full 16-bit port address everywhere is mandatory, and failure to comply is considered a serious error. PR> PR> However, these methods do not work for many PR> Spectrum-compatible machines, for example Scorpions, are not all scorpions have Kempston initially. And divorced he is 100% correct. It would be more correct to say: these methods do not work. on machines with a #FF port and/or a crookedly connected joystick. PR> which are Pentagons and many others. There are several reasons: PR> firstly, on many boards not all the high-order bits of the port PR> Kempston joysticks are reset to 0, it happens that they are all PR> (or some of them) are set to 1; secondly on PR> branded Spectrums and Scorpions when contacting PR> some missing port is read from it PR> contents of the attribute port ("port #FF") - exactly with this PR> difficulties are associated withconnecting a CDOS modem to Scorpi- Scorpion has a special IORQGE input on the system bus, which disables port #FF and generally _all_ other ports, available on the motherboard. No problem. The #FF port and the modem get along quite well together. The completion consists from mikruha LP8 and a piece of wire. PR> PR> To eliminate the second reason, you need to figure out PR> how the attribute port works. Screen output begins PR> immediately after the arrival of the INT signal, or rather immediately after PR> INT the top part of the curb is drawn and at this time the port PR> attributes are disabled. When does the picture begin to emerge? port #FF is the attribute port of the _screen_, not the border, and it _not is disabled_, just out of it for about 12000 cycles after inta (while the top of the border is being drawn), guaranteed Only #FF bytes arrive, i.e. empty data bus. PR> ran, then attribute bytes come from the attribute port, PR> which are currently displayed on the monitor (however, in PR> those moments when the side parts of the curb are drawn, the port PR> attributes is disabled again) - this phenomenon allows ^^^^^^^^^^^^^^^^^^^ it doesn't turn off!!! It is simply empty, i.e. contains #FF! PR>synchronize border effects. So, to determine PR> information about the presence of a Kempston joystick (and this also applies to PR> Kempston mouse) its port should be polled only immediately PR> after INT while the attribute port is disabled, because then why right away? This must be done within the first 12,000 clock cycles after int, when a conflict with the port is guaranteed to be excluded #FF. Why 12000? Branded size of the top border field 65 lines (80 on Pentagon), a line is drawn in 224 clock cycles, 224*65=14560 clock cycles, but on wait two-field machines (in particularly branded ones) is usually less, 12,000 is just enough. PR> PR> Well, to eliminate the first cause, you need to determine PR> the presence of a Kempston joystick in the lower 5 bits, but right- PR> yes, there is one drawback to this, namely, if, when PR> the program checks for the presence of a Kempston joystick holding it PR> say, the program will not detect its presence. PR> PR> So, the optimal way to determine Kempston PR> joystick, works on absolutely all machines 100% PR> reliability: PR> PR> ; PR> ; (C) EVP-SOFT PR> ; PR> ; while Kempston availability is being determined PR> ; joystick, it is advisable to set the mode PR> ; IM 2 and interrupt routine why with IM2fence the garden? For cars with unstable tires (of which there are many), this approach is too cumbersome: it is necessary paint a sign, etc. When IM1 subroutine (ISR) polling keyboard space (depending on the number of keys pressed) takes up about 1-2 thousand cycles, which more than fits into the notorious 12 thousand. So with IM1 the trivial is quite enough EI HALT LD A,#FF IN A,(#1F) AND #E0 JR Z,PRESENT JR NOT PRESENT In the case of a mouse, it’s similar. For machines with a crookedly connected joystick, it is logical to do this: if port #FF1F is detected, but what comes from it is not exactly what necessary (the most significant three bits are not zero), then the joystick is still there, and it makes sense to interview him. PR> ; make it short: see. above about 12000 cycles. PR> PR> Kempston Mouse Availability Determination PR> PR> The name of the mouse "Kempston" does not at all mean that it PR> connects instead of a Kempston joystick. To connect In England there is a city of Kempston, in which there is a laboratory, and in it different people at different times developed joystick, mouse and printer interfaces. By the way, printer - almost an exact copy of ours on KPS8OBB55. PR> Kempston mouse needs a special onecontroller, because coor- PR> Kempston mouse dinats (unlike AY mouse) are calculated PR> hardware, not software. Communication with the controller hmm... depends on what kind of mouse it is. If serial (microsoft mou- se), then everything is so. And they are not calculated, but converted from serial code to parallel. And if parallel, (standard for amiga & macintosh) then co- She already supplies dinata in ready-made form, and the need for transformation no. PR> in its absence, it is read from all three "mouse" ports PR> #FF, of course, when the attribute port is turned off. If once again: the attribute port _doesn't turn off_! He's just _nothing contains_! PR> at least one port didn’t come from #FF, that means a mouse PR> yes. However, if after turning on the computer you do not touch PR> to the mouse, then it will also come from the coordinate ports PR> #FF, and the presence of a mouse will not be detected - so after incorrect. After reset, the coordinate ports contain zeros rather than #FF. So the presence of a mouse can always be determined. PR> when turning on the computer, always move the mouse, otherwise no PR> the program will not find it. In general, having a Kempston mouse is possible after hardware reset -similarly, because in the controller (not in everyone, but in many) after reset the same things happen processes as when the power is turned on. PR> ; PR> ; while Kempston availability is being determined PR> ; It is advisable to set the mouse to IM 2 mode why IM2? See above. PR> ; and the interrupt handling program PR> ; to put it short: see. above about 12000 cycles. Moral: don't bother with IM2. You can search for a mouse or joystick and with IM1, but in any case do this after EI : HALT, with provided that the interrupting procedure is no longer than 12000 clock cycles. For reference, the approximate lengths of some ISRs are: standard keyboard polling procedure - 1-2 thousand cycles Pro tracker player - 4-6 bars -"- ST pro - about 3.5 thousand cycles -"- ASC Sound Master - 6-12 cycles. ISR - Interrupt Service Routine.
Share your thoughts about the article