ZX Review #3-4
22 июля 1997
  Бейсик  

Retro - Dzh.Hardman, E. Hyuzon. Top 40 procedures.

<b>Retro</b> - Dzh.Hardman, E. Hyuzon. Top 40 procedures.
            RETRO



Dzh.Hardman, E. Hyuzon.


      40 best PROCEDURES.

(Continued see ZX REVIEW
97/1-2)


           SECTION B


         4. INTRODUCTION


  Section B presents the program in machine code. For 
simplicity and ease of use they are in standard format.

The introduction describes this
format and provides a program for
BASIC'e, which can be used for loading programs into memory.


     Length: This is the length of the program

            in bytes.

Doing some number of
variables: the program may,
            require changes

            value of one or

            more variables

            transmitted to the prog
            Rummy buffered

            printer.

Check each program so
     sum: for in the form of a sequence
            sequence of integers
            positive numbers,

            placed in the following
            successive cell

            memory. Verification

            amount (ie, the sum

            all the numbers entered

            routines) is given by

            to you

            were confident in the right
            regularity downloads.


   Function: A short description
            description of the tasks fulfilled
            equate with

            program.

Variables: We define the name,

            length and address in the bu
            Fere printer each
            each variable. Ne
            Belt length

            one byte (a whole by
            positive number in

            ranging from 0 to

            255) passed in

            program from the BASIC

            or keyboard Th
            Res POKE.



    POKE cell value

   Two-byte variable

  passed by a 2-x

           commands:

  POKE cell, the value of-256 *

     INT (znachenie/256):

       POKE a cell,

      INT (znachenie/256)
 Cells are used

     Buffer memories

           printer.



       Calling Program vyzyvapodprogrammy: are used to
              Niemi function USR,

              which should

              be included in the

              command. If space
              grams in the machine
              dimensional code is not re
              gives some values
              chenie back

              BASIC for completion
              NII, then use
              is the command:


     RANDOMIZE USR address



     If you need to
 result was returned as a result
  gistrovoy pair BC, then the call

         done as follows:

      LET A = USR address

             or

       PRINT USR address

     depending on whether
 whether the data returned

   saved in the variable

    BASIC or output

           on the screen.



  Explains control verification
    Error: Key performed about
            grams for illogical
            GOVERNMENTAL or contradictory
            O values ​​of the variables
            variables, parameters, and

            etc.

Comments: Explains the possible
            nye options prog
            Rummy.


  Listing in the program representation
   Lena native language Assem
      code: Blair. To download

            in memory uses
            Xia third column -

            "The numbers for input."

            All numbers here are

            decimal system
            IU.


    As she explained the principle of

  works: the program.



    LOADER machine code


  Almost all programs of this
books conveyed, ie, they will work correctly regardless of 
where in the RAM, we their estates. If the program does not

traveling, in the comments
explains how it should be
changed if it is saved in a different area of ​​memory. In
Section A (Part 2) we have seen,
that the ZX-SPECTRUM uses a variety of RAM for various
fukntsii and that the region between
cells, these systemic
variables RAMTOP and UDG, is designed to store routines in 
machine code. 

  Program BP can be used to download, edit and move the program 
in native. With the help of

the user can reset the pointer RAMTOP, which will
more space
for machine code, enter the program with the keyboard to move 
forward or backward to adjust Error; insert or delete

part of the program.


    Program BP. Loader

   Machine Code (MC LOADER)

 100 GO SUB 8100
 200 REM ***** Calculation of available memory
 210 LET min = 1 + PEEK 23730 +256 * PEEK 23731
 220 LET p = PEEK 23732 +256 * PEEK 23733
 230 LET t = p - min + 1
 400 REM ***** determining the starting address
 410 PRINT "Lowest possible start ="; min ... "Maximum space

     avalible = "; t
 420 INPUT "Do you wish to change the lowest start address

     (Y or N)? "; Z $
 430 IF z $ = "Y" OR z $ = "y" THEN GO TO 7000
 440 INPUT "Enter address at which to start loading machine

     code "; a
 450 IF a <min OR a> p THEN BEEP .2,24: GO TO 440
 500 GO SUB 8100
 510 LET t = t-a + min
 520 PRINT "You can use up to"; t "bytes" ...
 530 LET u = PEEK 23675 +256 * PEEK 23676
 540 IF a <u AND u 

= U THEN PRINT "You will overwrite the user defined graphics area. " 560 INPUT "Is that OK (Y or N)?"; Z $ 570 IF z $ = "N" OR z $ = "n" THEN GO TO 7000 580 IF z $ <> "Y" AND z $ <> "y" THEN BEEP .2,24: GO TO 560 700 REM *** GO AHEAD AND LOAD 710 LET l = a 750 GOSUB 8200 760 INPUT "Enter number, b, f, i, d or t"; z $ 770 IF z $ = "" THEN BEEP .2,24: GO TO 760 780 LET a $ = CHR $ (CODE z $ (1) - 32 * (z $ (a )>"@")) 790 GO TO 800 +200 * (a $ = "B") +300 * (a $ = "F") +400 * (a $ = "I") +500 * (a $ = "D") +600 * (a $ = "T") 800 LET x = VAL z $ 810 IF l> p THEN BEEP .2,24: GO TO 750 820 IF x <0 OR x> 256 OR x <> INT x THEN BEEP .2,24: GO TO 760 830 POKE l, x 840 LET l = l +1 850 GO TO 740 1000 REM *** Move forward 1010 LET l = l-1 1020 IF LEN z $> 1 THEN LET l = l +1- VAL z $ (2 TO) 1030 IF l 1 THEN LET l = l-1 + VAL z $ (2 TO) 1130 IF l> p THEN LET l = p 1140 GO TO 740 1200 REM *** Insert 1210 IF LEN z $ = 1 THEN LET n = 1: GO TO 1225 1220 LET n = VAL z $ (2 TO): IF n <1 OR n> p-1 OR n <> INT n THEN BEEP .2,24: GO TO 740 1225 CLS: GOSUB 8100: PRINT TAB 6; "Inserting in progress" 1230 FOR j = p TO l + n STEP -1 1240 POKE j, PEEK (j-n) 1250 NEXT j 1260 FOR j = l TO l + n-1 1270 POKE j, 0 1280 NEXT j 1290 GO TO 740 1300 REM *** Delete 1310 IF LEN z $ = 1 THEN LET n = 1: GO TO 1330 1320 LET n = VAL z $ (2 TO): IF n <1 OR n> pl OR n <> INT n THEN BEEP .2,24: GO TO 740 1330 IF n <0 OR n> p-l THEN BEEP .2,24: GO TO 1320 1340 CLS: GOSUB 8100: PRINT TAB 6; "DELETING IN PROGRESS" 1350 FOR j = l TO p-n 1360 POKE j, PEEK (j + n) 1370 NEXT j 1380 GO TO 740 1400 STOP 1401 PRINT AT 21,7; "PROGRAM TERMINATED" 1410 STOP 7000 REM *** Change RAMTOP 7010 INPUT "ENTER NEW START ADDRESS"; a 7020 IF a <27000 OR a> p THEN BEEP .2,24: GO TO 710 7030 CLEAR a-1 7040 RUN 7999 STOP 8100 CLS 8110 PRINT TAB 6; "MACHINE CODE LOADER" ... 8120 RETURN 8200 REM *** Display the contents of memory 8210 GOSUB 8100 8220 PRINT "ADDRESS DECIMAL CHECK SUM" 8230 LET c = 0 8240 LET s = l-8: IF s p THEN LET f = p 8290 FOR j = s TO f 8300 LET c = c + PEEK j 8310 PRINT AT j-s +3,1; j; TAB 12; PEEK j; TAB 22; c 8320 NEXT j 8400 LET pos = a-s +3 8410 PRINT AT pos, 1912; FLASH 1; PEEK l 8420 RETURN When the program BP starts, it prints the lowest address, with which the program in machine Codes can be entered and stored, ie, one greater than RAMTOP. In the car with 48K memory Jr. address of 65368 if a user to update the system variable RAMTOP. At the end of RAM is usually reserved for the 168 bytes of UDG, but program allows the user to use this area if he wishes. It may also be possible to choose a new junior address that the program then puts in a system environment variable RAMTOP, using the command CLEAR. Data can not be introduced to address less than 27000, as otherwise violated boundaries of the region required for the program BP. Program BP asks for the address from which should start the program in native. Thus, user can reserve area for several procedures and then download them each separately. Figure shows the format of BP1 display after a cell has been loaded 32000 Program "Screen Invert". The first column - the address, the second - the contents of memory at this address, the third - the checksum. The program "Screen Invert" has 18 bytes in length and checksum is 1613. Consequently, it takes a cell with 32000 to 32017 and the control the amount given to 32,017 cells, ie amount of cell contents (32000 ... 32017) is equal to 1613. MACHINE CODE LOADER ADDRESS DECIMAL CHECK SUM 32000 33 33 32001 0 33 32002 64 97 32003 1 98 32004 0 98 32005 24 122 ..... ... ... 32012 11 836 32013 120 956 32014 177 1133 32015 32 1165 32016 247 1412 32017 201 1613 Fig. BP1. Submitted Screen during boot machine code. Program "Screen Invert" is loaded with address 32000. The main screen of attention Users attracted to one cell - the contents of this cell flickers. This cell is the current and original is chosen start address program. The user enters integer between 0 and 255 inclusive, that the program MC LOADER fits into the current cell. Then the next address becomes the current cell. The user can not enter a number, and instead choose to adjust the options described in the Table BT1. Code Option B Back One Address ago B n (number) Go to n Address ago F Back One mail forward F n (number) Go to n Address forward I n (integer) Insert n bytes each of which contains 0 D n (number) Delete n bytes current area T End program Table BT1. Possible options editing the machine code. 5. SUB-shift. 5.1. Shift attributes to the left. Length: 23 Number of variables: 1 Checksum: 1574 Purpose: This program shifts the attributes of all symbols screen left one familiarity. Variables: Name: new attr Length: 1 Cell: 23296 Comment: This attribute is introduced in the rightmost column. Calling the program: RANDOMIZE USR address Error Checking: None. Comment: This program is useful for highlighting areas of text or graphics. To scroll through only 22 of upper row 24 * should be changed to 22. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 22 528 33 0 88 LD A, (23296) 58 0 91 LD C, 24 14 24 * NEXT_L LD B, 31 June 1931 NEXT_C INC HL 35 LD E, (HL) 94 DEC HL 1943 LD (HL), E 115 INC HL 35 DJNZ NEXT_C 16249 LD (HL), A 119 INC HL 35 DEC C 13 JR NZ, NEXT_L 32242 2 How it works: In a couple of registers loaded HL address field attributes. Battery load values attribute, enter in the right hand column. The register C is loaded number of lines to shift - he can now be used as the row count. In case B recorded the number 1 less than the number of characters per line, that it be used as a counter. HL is increased to specify the following attribute which is loaded into the E-register. HL decreases, and at HL fit value of E-register. HL increases again to indicate the following attribute. Register B is reduced and if it is not equal to 0, the transition to NEXT_C. HL now points to the right column, and at HL fit value from the battery. HL is increased to indicate the following string - NEXT_L. Row Count (Case C) is reduced. If result value is not 0, subroutine returns to NEXT_L. Upon completion of the program returns to BASIC. 5.2. Shift to the right attributes. Length: 23 Number of variables: 1 Checksum: 1847 Purpose: This program shifts the attributes of all symbols screen to the right by one familiarity. Variables: Name: new attr Length: 1 Cell: 23296 Comment: This attribute is entered in the leftmost column. Calling the program: RANDOMIZE USR address Error Checking: None. Comment: This program is useful for highlighting areas of text or graphics. To scroll through only 22 of upper row 24 * should be changed to 22. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 23295 33 255 1988 LD A, (23296) 58 0 91 LD C, 24 14 24 * NEXT_L LD B, 31 June 1931 NEXT_C DEC HL 1943 LD E, (HL) 94 INC HL 35 LD (HL), E 115 DEC HL 1943 DJNZ NEXT_C 16249 LD (HL), A 119 DEC HL 1943 DEC C 13 JR NZ, NEXT_L 32242 RET 201 2 How it works: In a couple of registers HL loaded the last byte of the address attributes. Battery is loaded attribute value for input into the left kololnku. In the case of C loaded lines for the shift - it is used as row count. The register recorded the number of B 1 less than the number of characters in line for use in as a counter. HL increases to specify the following attribute. The value of this attribute is loaded into E-register. HL increases, and at HL fit value of E-register. HL decreases again to specify the address of the next attribute. Counter in the register B is reduced, and if he does not is 0, then - return back to NEXT_C. HL now points to the leftmost column, and in a cell with the address of HL puts the value of the battery. HL decreases to indicate the right end of the next line. Row count is reduced, and if he is not 0 - return back to NEXT_L. The program returns to BASIC. 5.3. Shift attributes up. Length: 21 Number of variables: 1 Checksum: 1591 Purpose: This program shifts the attributes of all symbols the screen up to one familiarity. Variables: Name: new attr Length: 1 Cell: 23296 Comment: This attribute is introduced into the bottom line. Calling the program: RANDOMIZE USR address Error Checking: None. Comment: This program is useful for highlighting areas of text or graphics. To scroll through only 22 of upper row 224 * should be changed to 160. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 22560 33 32 88 LD DE, 22 528 17 0 88 LD BC, 736 1224 * 2 LDIR 237,176 LD A, (23296) 58 0 91 LD B, 32 June 1932 NEXT_C LD (DE), A 18 INC DE 1919 DJNZ NEXT_C 16252 RET 201 2 How it works: In a couple of registers HL loaded address of the second row attributes, DE loads the address of the first row and the BC number of bytes loaded for the move. The number of bytes specified in the register pair BC, is copied to a memory address, located in the DE of the cells starting from the address in HL, using the instructions LDIR. These results indicate a DE on the bottom line attributes. Battery is loaded code attribute to put in the bottom line. B-register is loaded number of characters on one line - it is used as a counter. DE is placed at the value of the battery, and then DE increases to indicate next byte. Counter is decremented, and if it is not 0, the routine returns to NEXT_C. The program then returns to BASIC. 5.4. The shift of attributes down. Length: 21 Number of variables: 1 Checksum: 2057 Purpose: This program shifts the attributes of all symbols screen down one familiarity. Variables: Name: new attr Length: 1 Cell: 23296 Comment: This attribute is introduced into the top line. Calling the program: RANDOMIZE USR address Error Checking: None. Comment: This program is useful for highlighting areas of text or graphics. To scroll through only 22 top rows must be changed: 223 * to 159, 255 * to 191, 224 * 160. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 23263 33 223 * 90 LD DE, 23295 17 255 * 90 LD BC, 736 1224 * 2 LDDR 237,184 LD A, (23296) 58 0 91 LD B, 32 June 1932 NEXT_C LD (DE), A 18 DEC DE 1927 DJNZ NEXT_C 16252 RET 201 2 How it works: In HL load address of the last attribute of the twenty-third row. In DE load address of the last attribute of the 24 th row. In BC the number of bytes loaded for the move. The team then moves LDDR bytes (the number indicated in the register pair BC) of the address in HL at a DE. These results in the DE store address the last attribute of the first row. As the battery is loaded attribute value to put in the top row. The B-register the number of bytes loaded at the top line - it is used as counter. In a cell with address DE puts the value of the battery, and DE reduced to indicate the next byte. Counter is decremented, and if he does not is equal to 0, the routine returns to NEXT_C. The program then returns to BASIC. 5.5 The shift to the left by one character. Length: 21 Number of variables: 0 Checksum: 1745 Purpose: This program scrolls the graphics screen for one character to the left. Subroutine call: RANDOMIZE USR address Error Checking: None. Comment: This program is helpful in organizing the screen as a "window" that shows a Currently a minority of large area of ​​the display. This "Window" is moved using sub shift. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 16 384 33 0 64 LD D, L 85 LD A, 192 62 192 NEXT_L LD B, 31 June 1931 NEXT_B INC HL 35 LD E, (HL) 94 DEC HL 1943 LD (HL), E 115 INC HL 35 DJNZ NEXT_B 16249 LD (HL), D 114 INC HL 35 DEC A 61 JR NZ, NEXT_L 32242 RET 201 2 How it works: In a couple of registers loaded HL address display file, and D-register is set to 0. In battery is loaded number lines on the screen. The B-register load value to 1 less than the number of characters in line - it is the number of bytes to copy. HL increases to indicate to the following address and the contents of this cell is loaded into E-register. HL decreases, and cell loaded with the address of HL value of E-register. HL increases to address the next byte and a counter in the B-register is reduced. If it is not 0, the routine returns to NEXT_B. If the register B is 0, that means that the last byte line copied and HL points to the extreme right bytes. By this address in the register pair HL placed 0, and HL increased, pointing to the next line. Row Count - the battery - is reduced, and if he is not zero, a transition to NEXT_L. The program returns to BASIC. 5.6.Sdvig right one character. Length: 22 Number of variables: 0 Checksum: 1976 Purpose: This program scrolls the contents of the display file, one character to the right. Subroutine call: RANDOMIZE USR address Error Checking: None. Comment: This program is helpful in organizing the screen as a "window" that shows a Currently a minority of large area of ​​the display. This "Window" is moved using sub shift. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 22527 33 255 1987 LD D, 0 22 0 LD A, 192 62 192 NEXT_L LD B, 31 June 1931 NEXT_B DEC HL 1943 LD E, (HL) 94 INC HL 35 LD (HL), E 115 DEC HL 1943 DJNZ NEXT_B 16249 LD (HL), D 114 DEC HL 1935 DEC A 61 JR NZ, NEXT_L 32242 RET 201 2 How it works: In a couple of registers HL loaded the last byte address of the display file, and the D-register is set to 0. As the battery is loaded on the number of rows screen. The B-register is loaded value of 1 less than the number of characters per line - it is used as a counter. HL decreases, indicating next byte, and its value loaded into the E-register. HL then increases in cell address value is loaded HL E-sensitive. HL decreases, pointing to the next byte, and counter (B-register) is reduced. If it is not 0, the routine returns to NEXT_B. If the register B is 0, that means that the HL indicates leftmost byte of the string. Then, at a register pair HL placed 0, and HL decreases, pointing to the next line. Row Count (battery) decreases and if it is not equal 0, a transition to NEXT_L. The program returns to BASIC. 5.7. Upward shift by one character. Length: 68 Number of variables: 0 Checksum: 6328 Purpose: The program shifts display file contents Up to eight pixels. Calling the program: RANDOMIZE USR address Error Checking: None. Comment: None. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 16 384 33 0 64 LD DE, 16 416 17 32 64 SAVE PUSH HL 229 PUSH DE 213 LD C, 23 14 23 NEXT_L LD B, 32 June 1932 COPY_B LD A, (DE) 26 LD (HL), A 119 LD A, C 121 AND 7230 7 CP 1 254 1 JR NZ, NEXT_B 32 2 SUB A 151 LD (DE), A 18 NEXT_B INC HL 35 INC DE 1919 DJNZ COPY_B 16241 DEC C 13 JR Z, REST 40 19 LD A, C 121 AND 7230 7 CP 0254 0 JR Z, N_BLOCK 40 22 CP 7254 7 JR NZ, NEXT_L 32225 PUSH DE 213 LD DE, 1792 17 0 7 ADD HL, DE 25 POP DE 209 JR NEXT_L 24217 REST POP DE 209 POP HL 225 INC D 20 36 INC H LD A, H 124 CP 72254 1972 JR NZ, SAVE 32,204 RET 201 N_BLOCK PUSH HL 229 LD HL, 1792 33 0 ADD HL, DE 25 EX DE, HL 235 POP HL 225 JR NEXT_L 24198 2 How it works: In a couple of registers HL loaded starting address of display file, and loads the address in DE byte of eight lines down. HL and DE are stored in the stack. In C-register is loaded on a number of less than the number of lines on the screen. The B-register is loaded the number of bytes on one line of the display - it is used as a counter. As the battery is loaded byte addressed by DE, and this value is loaded into the cell by at HL. As the battery is loaded content, C-register and if it is 1, 9 or 17, in cell is placed at DE 0. HL and DE are increasing, pointing to the next byte. Counter in B-register is reduced, and if it is not 0, the transition to 'COPY_B'. Row count in register C and then decreases. If it is 0, a transition to 'RESTORE'. If C contains 8 or 16, the transition to 'N_BLOCK'. If C does not contain 7 or 15, the routine goes to 'NEXT_L'. Then 1792 is added to the HL - HL now points to the the next block of the screen. Subroutine goes to 'NEXT_L'. In the process of 'REST' DE and HL are taken from the stack, and 256 is added to each of them. Thus, DE and HL points to a string, the position which is lower than what was previous cycle. If HL contains the value 18432, the subroutine returns to BASIC, otherwise the transition to a procedure 'SAVE'. The procedure 'N_BLOCK' 1972 added to the DE - such read DE points to the next block of the screen. Subroutine then returns to 'NEXT_L'. Upon completion of the work going on return to BASIC. 5.8. Shift down by one character. Length: 73 Number of variables: 0 Checksum: 7987 Purpose: This program shifts the contents of the display file down to eight pixels. Calling the program: RANDOMIZE USR address Error Checking: None. Comment: None. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 22527 33 255 1987 LD DE, 22495 17 223 1987 SAVE PUSH HL 229 PUSH DE 213 LD C, 23 14 23 NEXT_L LD B, 32 June 1932 CORY_B LD A, (DE) 26 LD (HL), A 119 LD A, C 121 AND 7230 7 CP 1 254 1 JR NZ, NEXT_B 32 2 SUB A 151 LD (DE), A 18 NEXT_B DEC HL 1943 DEC DE 1927 DJNZ COPY_B 16241 DEC C 13 JR Z, REST 40 21 LD A, C 121 AND 7230 7 CP 0254 0 JR Z, N_BLOCK 40 24 CP 7254 7 JR NZ, NEXT_L 32225 PUSH DE 213 LD DE, 1792 17 0 7 AND A 167 SBC HL, DE 237 82 POP DE 209 JR NEXT_L 24215 REST POP DE 209 POP HL 225 DEC D 21 DEC H 37 LD A, H 124 CP 79254 1979 RET Z 200 JR SAVE 24,201 N_BLOCK PUSH HL 229 LD HL, 1792 33 0 7 EX DE, HL 235 AND A 167 SBC HL, DE 237 82 EX DE, HL 235 POP HL 225 JR NEXT_L 24193 2 How it works: In a couple of registers HL loaded the last byte address of the display file, and DE is loaded a byte address that corresponds to the image, separated by eight lines up. HL and DE stored on the stack. The C-register is loaded on a number of less than the number of lines on the screen. Then, in the B-register is loaded the number of bytes on one line of the display - it is used as a counter. As the battery is loaded bytes address DE, and this value is sent to the cell at HL. As the battery is loaded (for test) the contents of register C and if it is 1, 9 or 17, then the cell is placed at DE 0. HL and DE is reduced by unit, pointing to the next byte display. Byte count in register B decreases and if it is not 0, the transition to 'COPY_B'. Further decrements rows in register C. If it is 0, the transition to the procedure of 'REST'. If C contains 8 or 16, then a transition to procedure 'N_BLOCK'. Unless C contains 7 or 15, the subroutine moves to 'NEXT_L'. Then, from HL subtracted 1792 - now HL points to the next third of the screen and the routine goes to 'NEXT_L'. In the process of 'REST' values ​​of DE and HL are taken from the stack, and from them subtracted the number 256. As a result, DE HL and points to a string, a position which is higher than that was in the previous cycle. If HL contains the value 20479, the subroutine returns to BASIC, otherwise there is a transition to a procedure 'SAVE'. The procedure 'N_BLOCK' 1972 is subtracted from the DE, ie, then DE points to the next block screen. Subroutine then proceeds to 'NEXT_L'. 5.9. Shift left by one pixel. Length: 17 Number of variables: 0 Checksum: 1828 Purpose: The shift in the content display a file on one pixel left. Calling the program: RANDOMIZE USR address Error Checking: None. Comment: This program provides a smoother movement than a shift left by one symbol, but you need to call it eight times to move display one complete character. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 22527 33 255 1987 LD C, 192 14 192 NEXT_L LD B, 32 June 1932 OR A 183 NEXT_B RL (HL) 203 1922 DEC HL 1943 DJNZ NEXT_B 16251 DEC C 13 JR NZ, NEXT_L 32245 RET 201 2 How it works: In a couple of registers HL loaded the last byte address of the display file, and register C load number of lines in file system on display (it's used as a counter lines). The register B is loaded amount bytes on one line (it is used as the byte count). Carry flag is set to 0. Bytes, addressed to HL, is shifted by one bit to the left, bit transfer is copied to the extreme rightmost bit, and the leftmost bit copied into the carry flag. HL register pair is reduced to guidance to the next byte and meter (B-register) is reduced. If it is not 0, the routine makes a transition to NEXT_B, otherwise reduce the number of processed lines, and if it is not 0, the routine returns to the procedure NEXT_L. Upon completion of the program returns to BASIC. 5.10. Shift to the right by one peak villages. Length: 17 Number of variables: 0 Checksum: 1550 Purpose: The shift in the content display a file on one pixel right. Subroutine call: RANDOMIZE USR address Error Checking: None. Comment: This program provides a smoother movement than the right shift on one character, but it takes eight times cause the program to move the display to one complete symbol. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 16 384 33 0 64 LD C, 192 14 192 NEXT_L LD B, 32 June 1932 OR A 183 NEXT_B RR (HL) 203 30 INC HL 35 DJNZ NEXT_B 16251 DEC C 13 JR NZ, NEXT_L 32245 RET 201 2 How it works: In a couple of registers loaded HL address display file, and C-register is loaded the number of lines on the screen (it's used as a counter lines). In Register B is loaded the number of bytes on one line (it used as a counter bytes). Carry flag set to 0. Bytes at HL shifted by one bit to the right, carry bit is copied into the leftmost bit and the rightmost bit is copied into the carry flag. HL register pair increases, pointing to the next byte and meter (B-register) is reduced. If it is not 0, the routine makes a transition to NEXT_B, otherwise reduce the number of processed lines, and if it is not 0, the routine returns to NEXT_L. When you are finished, the procedure returns to BASIC. 5.11.Sdvig up one pixel. Length: 91 Number of variables: 0 Checksum: 9228 Purpose: The shift in the content display a file up one pixel. Calling the program: RANDOMIZE USR address Error Checking: None. Comment: None. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 16 384 33 0 64 LD DE, 16 640 17 0 65 LD C, 192 14 192 NEXT_L LD B, 32 June 1932 CORY_B LD A, (DE) 26 LD (HL), A 119 LD A, C 121 CP 2 254 2 JR NZ, NEXT_B 32 2 SUB A 151 LD (DE), A 18 NEXT_B INC DE 1919 INC HL 35 DJNZ COPY_B 16243 PUSH DE 213 LD DE, 224 17 224 0 ADD HL, DE 25 EX (SP), HL 227 ADD HL, DE 25 EX DE, HL 235 POP HL 225 DEC C 13 LD A, C 121 AND 7230 7 CP 0254 0 JR NZ, SUBTR 32 10 PUSH DE 213 LD DE, 2016 17 224 7 AND A 167 SBC HL, DE 237 82 POP DE 209 JR N_BLOCK 24 14 SUBTR CP 1254 1 JR NZ, N_BLOCK 32 10 PUSH HL 229 EX DE, HL 235 LD DE, 2016 17 224 7 AND A 167 SBC HL, DE 237 82 EX DE, HL 235 POP HL 225 N_BLOCK LD A, C 121 AND 63 230 63 CP 0254 0 JR NZ, ADD 32 6 LD A, 7 July 1962 ADD A, H 132 LD H, A 103 JR NEXT_L 24187 ADD CP 1254 1 JR NZ, NEXT_L 32183 LD A, 7 July 1962 ADD A, 7130 LD D, A 87 LD A, C 121 CP 1 254 1 JR NZ, NEXT_L 32174 RET 201 2 How it works: In a couple of registers loaded HL address display file, and DE address of first byte of the second lines of the display. The register C is loaded the number of lines on the screen. The register B is loaded the number of bytes on one line - it used as a counter. As the battery is loaded bytes address in DE, and this value transferred into the cell at HL. As the battery is stored the contents of register C. If it is 2, the DE indicates the bottom of the screen and the address is written 0. HL and DE increase, to indicate next byte. Counter in the register B decreases and if it does not is 0, the transition to COPY_B. 224 is added to the register pairs HL and DE, to point to the next line screen. Then decreases register C, counter lines. If the contents Register C is not a multiple of 8, a transition to SUBTR, otherwise 2016 subtracted from the HL and is transition to N_BLOCK. Now HL points to the following 8 lines. The procedure SUBTR, if the value of (C-1) is not a multiple of 8, a transition to N_BLOCK, otherwise 2016 is subtracted from the DE, ie, DE now points to the following 8 lines. The procedure N_BLOCK, if the value of C-register multiply 64, 1792 added to the HL and made the transition to NEXT_LINE - HL now points to the next block of 64 lines. The procedure ADD, if the value of (C-1) multiple of 64, 1792 added to the DE, DE to a pair of points to the next block of 64 lines. If C-register does not contain 1, then the program returns to N_LINE, otherwise return to BASIC. 5.12. Shift down by one pixel. Length: 90 Number of variables: 0 Checksum: 9862 Purpose: The shift in the content display the file down to one pixel. Calling the program: RANDOMIZE USR address Error Checking: None. Comment: None. LISTING machine code Assembly label NUMBER FOR INPUT 147. LD HL, 22527 33 255 1987 LD DE, 22271 17 255 1986 LD C, 192 14 192 NEXT_L LD B, 32 June 1932 CORY_B LD A, (DE) 26 LD (HL), A 119 LD A, C 121 CP 2 254 2 JR NZ, NEXT_B 32 2 SUB A 151 LD (DE), A 18 NEXT_B DEC DE 1927 DEC HL 1943 DJNZ COPY_B 16243 PUSH DE 213 LD DE, 224 17 224 0 ADD A 167 SBC HL, DE 237 82 EX (SP), HL 227 AND A 167 SBC HL, DE 237 82 EX DE, HL 235 POP HL 225 DEC C 13 LD A, C 121 AND 7230 7 CP 0254 0 JR NZ, ADD 32 8 PUSH DE 213 LD DE, 2016 17 224 7 ADD HL, DE 25 POP DE 209 JR N_BLOCK November 24 ADD CP 1254 1 JR NZ, N_BLOCK 32 7 PUSH HL 229 LD HL, 2016 33 224 7 ADD HL, DE 25 EX DE, HL 235 POP HL 225 N_BLOCK LD A, C 121 AND 63 230 63 CP 0254 0 JR NZ, SUBTR 32 6 LD A, H 124 SUB 7214 7 LD H, A 103 JR NEXT_L 24188 SUBTR CP 1254 1 JR NZ, NEXT_L 32184 LD A, D 122 SUB 7214 7 LD D, A 87 LD A, C 121 CP 1 254 1 JR NZ, NEXT_L 32175 RET 201 2 How it works: In a couple of registers HL loaded the last byte address of the display file, and a pair of registers DE loaded byte address line, which is located directly above this byte. In register C is loaded the number of lines the screen. The register B is loaded the number of bytes on one line of the display - it is used as a counter. As the battery is loaded bytes from a cell with an address in DE, and this value is loaded into the cell by at HL. As the battery is loaded the contents of register C. If it is 2, the DE indicates that the top line of the screen, address of which was brought 0. HL and DE decreased to indicate The following bytes. Meter (B-register) decreases and if it does not is 0, the transition to COPY_B. 224 is subtracted from the register pairs HL and DE - now they point to the next line of the screen. Register C (row count) decreases. If the contents of register C is a multiple of 8, ie with 8 cycles for one line the transition to a procedure ADD, otherwise the 2016 is added to the HL and a transition to N_BLOCK - HL now points to the next 8 lines. The procedure ADD, if the value of (C-1) is not evenly divisible by 8, a transition to N_BLOCK, otherwise 2016 added to the DE, a pair of registers DE points to the following 8 lines. The procedure N_BLOCK, if the value of C-register is divisible by 64, subtracted from HL 1792. HL now points to the next block of 64 lines, and a transition to NEXT_L. The procedure SUBTR, if the value of (C-1) is not divisible 64, is subtracted from DE 1792 - in finally DE points to the next block of 64 lines. If the C-register does not contain 1, then returns to the subroutine NEXT_LINE, except in BASIC.




Other articles:

TR-DOS for beginners - Part 1.

Authoring - General Sound - Multimedia for the ZX Spectrum!

Business Card - Introducing the new electronic journal "Major Wares" (c) Codebusters & VMG

Computer novella - Knight Lore "legends of chivalry times."

New Programs - I. Roshchin. HELP_Z80. Davydov. Catalog's Base v1.8.

description of the shell of the journal "ZX-REVIEW"

Crossing Dragon - Aavlon, Castle of Dreams, Erik the Viking.

Crossing Dragon - Eureka!, Eye of Bain, Kentilla.

Crossing - Sherlock, Apollo, Shadows of Mordor, Rigels Revenge, Temple of Terror, ID, That's the Spirit, Return to Ithaka.

Retro - Dzh.Hardman, E. Hyuzon. Top 40 procedures.

Expert Tips - Castle Master.

Expert Tips - Firelord.

Expert Tips - Stonkers.

Forum Games - Insult Megademo, Catch 23, Livingstone, Rock Star ate my Hampster, UFO-2: Devils of the Abyss, Terminator 2, Venturama, The Spririts, Nipper, Sweewo'S World, King's Bounti -2, Hacker 2, Black Magic, Satcom, Star Heritage.

Forum - A. Gura. Code programmer.

Forum - A. Strelnikov. Prospects of development of ZX Spectrum.

Forum - Davydov. According to materials published in the ZX-REVIEW: Some issues related to autostart BASIC programs. Redefine Keys. How to print 42 characters per line. The procedure of multiplication HL = B * C. Refinement cloning downloaders. Mini-driver disk.

Forum - With 'Light'. Music processor ZX-Speccy.

Forum - Dmitry Fyodorov: Print images with a mask with pixel precision. Algorithm for calculating the address coordinates to within a pixel.

Forum - I. Roshchin. Sharing ZX ASM 3.0 and STS 5.1.

Forum - M. Bekarev. The calculation of the address display area of familiarity, and vice versa.

Forum - VP Fedin. Refinement Profi for conflict-free peripheral connectivity.

Forum - S. Astrov. Pseudorandom number generator.

reader-reader - V. Sirotkin. Protection program (look at the problem).

reader-reader - I. Roshchin. Display driver for the computer, "Pentagon-128.

Studies - A. Savinov: The procedure for displaying a double-height characters. Procedure "dissolution" of characters.

Studies - A. Urzha. The procedure for drawing a circle.

Studies - V. Sirotkin. Program checksum.

Studies - E. Volchkov. Improvement routines address calculation system on display file.

Studies - E. Frost. Running line.

Studies - I. Komandin. The program display screen.

Studies - I. Roshchin. Two graphic effect.

Studies - M. Lazutov: The modernization program font. Program encode / decode block codes. The effect of the attributes.

Studies - O. Smolyankin: Procedures for cleaning the screen. Output of text messages on the screen.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Story - A humorous story.
Jokes - Humor.
Present - a supplement to: releases of Korund'a and Gus'a.

В этот день...   8 May