Exchange of experience - Rapid procedure for finding the root of the number and Testing Kempston-port of SerzhSoft'a.

Adventurer #09
     (C) SerzhSoft


         A couple of words about sore


               And you and your ear does not blink ...



     I write these lines in the park the wild,
so read accordingly! -) Time really is very little ... : - 
(Sessiya! - ( 


     You may have already met with me
log Kemerovo pages Deja
Vu, in the section "CODING", of course ...
For a long time I sent my article only
in this magazine and in vain! : -) For printed
they are not at the highest level: that part of the article
somewhere lost, the source, and sometimes -
contrary to the log placed sources, and
Article disappeared in an unknown direction; listings for the 
64-character format turned into a miserable 42-character, etc.

etc: - (Yes, and in the magazine itself has long
time used my library of survey keyboard and joysticks + motion
arrows without attribution ... All
is gradually flooded the bowl of my
patience, which led to what we
met on the pages of other publications ...

     Thus, in the fifth issue of Deja Vu Again
There was garbage in my articles - were
published only source programs, and
the articles themselves have gone to # @% in ... They were 
written were still in June, during the summer session,

and still did not come to light!

     So, this: a note about the sinuses, the article
attribute of the rotational and iskazhalku
article about the Olympiad problems ...


     Now let's talk about the article
Cardinal 'and in the sixth issue of ... I did not
thought that someone have "root
problems! "The most simple and fast procedure for finding the 
root of the number specified in HL:


SQR_HL

        LD BC, # 0040; <10>

        LD A, H; <4>

        OR A; <4>

        JR Z, GO_SQR; <12 / 7>

        LD A, L; <4>

        LD L, H; <4>

        LD H, B; <4>
;

        DUP 4; BEGIN 4

        SBC HL, BC; <15>

        JR NC, $ +3; <12 / 7>}

        ADD HL, BC; <11>} 12/18

        CCF; <4>

        RL B; <8>

        ADD A, A; <4>

        ADC HL, HL; <11>

        ADD A, A; <4>

        ADC HL, HL; <15>

        EDUP; END} 292 .. 316
;
GO_SQR DUP 4; BEGIN 4

        SBC HL, BC; <15>

        JR NC, $ +3; <12 / 7>}

        ADD HL, BC; <11>} 12/18

        CCF; <4>

        RL B; <8>

        ADD HL, HL; <11>

        ADD HL, HL; <11>

        EDUP; END} 244 .. 268
;

        LD L, B; <4>

        LD H, A; <4>} 294 .. 629

        RET


     If the number from which you remove the root, less than 
256 (ie, high byte is equal to 0), execution time is

from 294 to 318 strokes, otherwise - from 581 till
629 cycles. RET command is ignored
since you can put this whole piece of code directly into any
procedure ... -) Use registers
HL, BC, AF. The result of catch in the HL, and
H = 0, of course! Or see Register B -
There is also a root. : -) Battery reset.

     By the way, Cardinal - boy, that
drew attention to a typographical error in protsedurke switch 
pages ... Well, where else OUT (C), A and LD (BANK_M), A were 
mixed up ... Of course, the first port value must be maintained 
in the cell and only then displayed in the port itself! In the 
source code, then it was all right, but when I typed the text 
of the article in the ZX-WORD 's (As of now, in a wild rush!), 
Then slipped past this unfortunate inaccuracy ...


     A spinner sprites if you want you can do before the fast, 
which is turning a sprite the size of the screen is wasted no 
more than a few seconds! If you want to - I write - as ... -)


     Recently, many electronic media (newspapers, magazines ...)
used Kempston Mouse ... But some comrades forget to test 
hardware for the presence thereof, bells and whistles! As a 
result, hang, buggy, or simply "dropped"! : - (And therefore I 
present the process of verifying your computer for your mouse 
(And the joystick at the same time!). When buggy bus mouse data 
safely "cuts off", and not "is" as some ... -)


;------------------------------------------------- -----------;
; KEMPSTON PORT TESTER (K. MOUSE 'K. JOYSTICK);
; Written by Kolotov Sergey (c) SerzhSoft, 1998;
;------------------------------------------------- -----------;
 TST_KMS

         LD BC, # FADF; k.mouse port

         LD HL, # 0000; begin: mouse, joystick present

         LD D, # 09; time of testing
 LP_TKMS IN A, (C)

         INC A

         OR L

         LD L, A

         IN A, (# 1F); k.joystick port

         AND # 1F

         OR H

         LD H, A

         DEC DE

         LD A, D

         DEC A

         JR NZ, LP_TKMS

         OR L

         JR NZ, NO_MOUS

         INC B; # FB

         IN A, (C)

         CP E; A = # FF?

         LD A, D; # 01 - yes_ms

         JR NZ, ON_MOUS

         LD B, E; # FF

         IN A, (C)

         CP E; A = # FF?

         LD A, D; # 01 - yes_ms

         JR NZ, ON_MOUS
 NO_MOUS XOR A; # 00 - no_ms
 ON_MOUS LD (MOUSEFL), A; 0 - no mouse / 1 - yes mouse

         LD A, H

         OR A

         LD A, D; # 01 - yes_km

         JR Z, ON_KMPS
 NO_KMPS XOR A; # 00 - no_km
 ON_KMPS LD (KEMPSFL), A; 0-no joystick / 1-yes joystick

         RET
;------------------------------------------------- -----------;



     Example of using the mouse you can
found in the appendix - a file CURSORLB.C.
It can be compiled in any
Assembler (best in the ZX-ASM 's!)
pre-translated into a format that
assembly from the text states, in
Do this file now resides ... In
you end up with an updated and extensive library of survey 
administration and Kempston Mouse, the first time in 
upublikovannuyu ZX-REVIEW ...



     Okay, I'll call it a day ... Yes,
I almost forgot! Editor in chief of Deja Vu
cruelly "slaughtered" a new hatch section devoted to fantasy and
fantastic! : - (I was against it ... But if
readers write that it is necessary, then I
sure that the topic be reborn! Main
send their "top ten" of domestic and foreign fiction ...

     Bye!

                        With best wishes,

                                   Serzh.


     P.S. FunTop98 - rulez! I dragged!

     P.P.S. Big hello to all your friends!


        My address is:

641800, Kurgan region.,

        Mr. Shadrinsk,

        st. Karl Liebknecht, 27, Apt. 1

        Kolotova Sergei Sergeyevich


     E-mail: lonewolf@zaural.ru

             subj: to SerzhSoft.