home *** CD-ROM | disk | FTP | other *** search
/ Outlet 53 / outlet-53.mgt / p2 < prev    next >
Text File  |  2021-04-18  |  20KB  |  1 lines

  1.         The position of the pixel in the display area is given  by three bytes, the hi and lo bytes of the display address and  the bit number at this address, each of which is calculated     separately.                                                             The subroutine uses very compressed "one-byte binary    arithmetic", which is perhaps best explained with the help of anexample: suppose the y-coordinate is 01111011b/7Bh/123d and the x-coordinate is 01001011b/4Bh/75d. The description will be much easier to follow if the analysis of the display addresses under DISPLAY AREA is continuously referred to.                               First subtract the y-coordinate from AFh/175d; now in   our example, Y = 00110100b/34h/52d. X = the x-coordinate        01001011b/4Bh/75d without adjustment.                                1. Hi byte: all the display addresses in any pixel line on the screen have the same y-coordinate and the same hi byte,     which therefore depends only on Y.                                     - in the top third of the screen, where Y runs line by   line from 00 at the top to 3Fh/63d, the hi byte of the pixel    lines runs line by line from 40h to 47h for the first eight     lines, and then repeats this sequence seven more times. So the  hi byte is the remainder on dividing Y by eight, plus 40h.             - in the middle third, where Y = 40h/64d -> 7Fh/127d, thesequence is 48h -> 4Fh, and the hi byte is the remainder on     dividing Y by eight, plus 48h                                          - and in the lower third, where Y = 80h/128d -> AFh/175d,the sequence is 50h -> 55h, and the hi byte is the remainder on dividing Y by eight, plus 50h.                                          Rotate three bits 010 into the hi end of Y. This dividesY by eight and adds 40h; in the example, 01000110b/46h/72d.     Ignoring the three low bits, the result is                                      01000000b/40h for the top third                                 01001000b/48h for the second                                    01010000b/50h for the bottom.                           XOR/AND/XOR this with Y, using 11111000b/F8h as a mask: this replaces the last three bits with the remainder on dividingY by eight; see masks.                                                  This is the correct hi byte for the pixel address.           2. Lo byte: it depends on both X and Y, but                       - it is the same for all the eight character bytes of anygiven character                                                        - all the addresses in any column have the same X        coordinate, and are various multiples of 20h plus the same      number: call it R1. R1 runs from 00 to 1Fh, and is equal to X/8 ignoring any remainder                                                 - the multiple of 20h is 0 * 20h for the top screen      character in the column, 1 * 20h for the next, then 2 * 20h, ...up to 7 * 20h = E0h for the eighth from the top; this ends the  top third, and the sequence is repeated for the middle and      bottom thirds. Call this R2 * 20h; R2 is zero -> 7                     - so to get the lo byte, divide X by eight and discard   the remainder, making R1. Now divide Y by eight and discard the remainder: this is the character line. Divide this by eight and multiply the remainder R2 by 20h; then the lo byte is R1 + 20h *R2.                                                                     In our example, X is 01001011b/4Bh/75d: the first five  bits represent R1.                                                      Rotate it left three times, making 01 011 010b; R1 is   split between the last three bits and the first two. The middle three bits are immaterial at this stage.                                XOR/AND/XOR this result with Y using 11000111b/C7h as   the mask: the example gives 01 110 010b. R1 is unaffected, but  the middle three bits are replaced by the corresponding three   bits of Y, which represent R2.                                          Now rotate this left two more times: the example result is 11001001b/C9h/201d. This puts R1 in the five lo bits, and R2 in the top three, ie R2 times 20h plus R1. This is the correct  lo byte of the address.                                              3. The bit number at this address is R3, the remainder on  dividing X by 8. In our example X = 01001011b/4Bh/75d. AND this with 00000111b/07, giving 00000011b/3, the bit number of the    pixel.                                                                 Input parameters: the pixel coordinates in BC: B is AFh/ 175d - Y, C is X.                                                      Action: subtract the y-coordinate from AF; giving Y              - if this makes carry, report "Integer out of range";   the y-coordinate was 176d or more                                       - rotate three bits 010 into the hi end of Y                    - XOR/AND/XOR the result with Y using 11111000b/F8h as  mask; this is the hi byte of the address                                - rotate X left three times                                     - XOR/AND/XOR the result with Y using 11000111b/C7h as  mask                                                                    - rotate this result left two more times; this is the lobyte of the address                                                     - AND X with 00000111b/07; this is the bit number of thepixel within the display address.                                      Exit: RET.                                                      Output parameters: HL holds the display address                  - A holds the bit number of the pixel                           - DE is unchanged.                                             Called from:                                                     22CB POINT SUB                                                  22E5 PLOT SUB                                                                                                               P LET 1A7A                                                      P LIST 1AAE                                                     P LLIST 1ADC                                                    P LOAD 1AE0                                                         see 1A7A syntax offset table                                                                                                PLOT key (F6) see also commands, functions and operators,   KEYBOARD SCANNING                                                       The Q key in K mode produces the command PLOT; it       requires two numeric parameters separated by a comma.                   The command is read by 1B29 STMT L 1 referring through  the syntax offset table 1A48 to the syntax parameter table 1A7A.1AC1 P PLOT causes a jump via 1CBE CLASS 09, which executes any colour commands and gets the parameters, 1C10 CLASS 00 and 1C16 JUMP C R to the executive routine 22DC PLOT.                                                                                        PLOT subroutine 22DC                                                Given a pair of pixel coordinates X and Y, sets the     pixel to one, making a dot in INK colour; see DISPLAY AREA. The executive routine of the PLOT command; also used as an exit     routine from 2320 CIRCLE to draw null circles consisting of a   single point.                                                          Input parameters: none                                           - X and Y (last) are last values on the calculator      stack.                                                                 Action: call 2307 STACK BC to get the coordinates in BC, and 22E5 PLOT SUB to make the PLOT.                                    Exit: into 0D4D TEMPS, which restores the permanent      colours.                                                               Output parameters: none.                                        Exit from:                                                       2320 CIRCLE                                                     233B C R GRE 1                                                 Rems:                                                            22AA PIXEL ADD finds pixel address (22E5 PLOT SUB)              24DF D L STEP relied on to check y-coordinate                                                                               PLOT END 2303 (22E5 PLOT SUB)                                      Jumps from:                                                      22FD PL TST IN                                                                                                              PLOT LOOP 22F0 (22E5 PLOT SUB)                                     Jumps from:                                                      auto                                                                                                                        PLOT SUB subroutine 22E5                                            Given the PLOT coordinates X, Y of a pixel, sets that   pixel to one, the INK colour on the screen. The main execution  routine for the PLOT command; also called by 24B7 DRAW LINE from24EC D L PLOT.                                                          The only small complications arise from the need to     consider INVERSE and OVER. It may be of interest to note that   PLOT INVERSE 1; OVER 1; achieves nothing at all, unless there   are other colour controls.                                             Input parameters: Y in B, X in C.                               Action: save the coordinates in 5C7D COORDS for the next DRAW command                                                            - call 22AA PIXEL ADD to find the display address and   bit number of the pixel                                                 - make a loop counter of the bit number incremented by  one; now one -> 8                                                       - make a mask 11111110b/FEh; with a "hole" at bit zero.        _22F0_PLOT_LOOP: rotate the mask right till the counter  reaches zero; now the "hole" is in the place matching the bit   number of the pixel                                                     - get the byte from the display address                         - if bit zero of P FLAG is set jump on to PL TST IN;    OVER 1                                                                  - (OVER 0) AND the display byte with the mask; this setsthe pixel to PAPER colour.                                             _22FD_PL_TEST_IN (the PLOT pixel is in PAPER colour,     unless the OVER 1 flag was set): if bit 2 of P FLAG is set jump on to PLOT END; INVERSE 1                                               - (INVERSE 0) XOR the display byte with the mask;       complementing every bit_except the selected one, which stays in PAPER colour                                                            - complement all the display bits; the selected bit goesto INK colour, everything else goes back to what it was at      first.                                                                 _2303_PLOT_END: put the changed display byte back in the display address.                                                       Exit: into 0BDB PO ATTR, which sets the attributes if    there were any colour controls.                                        Output parameters: none.                                        Called from:                                                     22DC PLOT                                                       24EC D L PLOT                                                                                                               P LPRINT 1AD9 see 1A7A syntax offset table                                                                                      PL TST IN 22FD (22E5 PLOT SUB)                                     Jumps from:                                                      22F0 PLOT LOOP                                                                                                              P MERGE 1AE2                                                    P MOVE 1B0A                                                     P NEW 1AA8                                                      P NEXT 1A98                                                         see 1A7A syntax offset table                                                                                                PO ABLE 0AD9 (09F4 PRINT OUT)                                      Jumps from:                                                      09F4 PRINT OUT                                                  0A69 PO QUEST                                                                                                               PO ANY subroutine 0B24                                              Outputs a single character code through the current     channel; not used for control codes. Although this is in form a free-standing subroutine, it is only called by ROM from PO ABLE in 09F4 PRINT OUT, so its description is given under PRINT OUT.        Called from:                                                     0AD9 PO ABLE                                                                                                                PO AT ERR 0AAC (0A75 PO 2 OPER)                                    Jumps from:                                                      0A87 PO CONT                                                                                                                PO AT SET 0ABF (0A75 PO 2 OPER)                                    Jumps from:                                                      0A87 PO CONT                                                                                                                PO ATTR subroutine 0BDB                                             Colours a character area on the screen by poking the    appropriate value into the appropriate byte in the attributes   area. The colour values used are always those of the temporary  attributes.                                                             The subroutine is given an address which is one of the  1800h/6072d addresses in the display area; see under DISPLAY    AREA. This is rather oddly called the "destination address" in  the notes. Its first task is to calculate from this the         corresponding address in the 300h/768d bytes of the attributes  area; see colours.                                                      The lo byte needs no change: the lo bytes of display    area addresses, which are the same for each byte of the         character, run from zero to FFh in each third of the screen, andare the same as the lo bytes of the corresponding attribute     addresses.                                                              The hi byte in the attributes area must be either 58h,  59h or 5Ah, depending on whether the display address is in the        top third of the screen: display addresses 4000 -> 47FFh     middle third of the screen: display addresses 4800 -> 4FFFh     bottom third of the screen: display addresses 5000 -> 57FFh          Convert the hi byte of the display address to 00 if it  was 40 -> 47h, 01 if it was 48 -> 4F or 02 if it was 50 -> 57h, and add this result to 58h to get the hi byte of the attributes area address.                                                           Take the attribute byte from the address just found and XOR/AND/XOR it with the attribute specification in 5C8F ATTR T, using 5C90 MASK T for the mask; see masks. This replaces the    bits of the attribute byte with bits from 5C8F ATTR T wherever  the mask bit is zero.                                                   Finally adjust the new attributes for PAPER and INK 9 byreference to P FLAG, and poke in the new attribute.                    Input parameters: HL holds the address of any pixel byte of the display area.                                                   Action: rotate the hi byte of the address three times to the right:                                                               01000000b/40h -> 01000111h/47h all become 08                    01001000b/48h -> 01001111b/4Fh all become 09                    01010000b/50h -> 01010111b/57h all become 0A                   - AND this with 00000011h/03; giving 00, 01 or 02 for   the top, middle and bottom thirds                                       - OR the result with 58h; this is now the hi byte of theattribute address                                                       - load 5C8F ATTR T and 5C90 MASK T into DE; the notes   put them in the wrong order                                             - XOR/AND/XOR the old attribute byte with 5C8F ATTR T   using 5C90 MASK T for the mask                                          - if bit 6 of P FLAG is zero jump on to PO ATTR 1; the  PAPER 9 flag                                                            - (PAPER 9) AND the attribute byte with 11000111b/C7h;  this makes the PAPER number in the result 000b BLACK                    - if bit 2 of the attribute byte isn't zero jump on to  PO ATTR 1; the INK colour is 100b/04 or more, GREEN, CYAN,      YELLOW or WHITE, and BLACK paper is correct                             - (INK colour of 3 or less, BLACK, BLUE, RED or MAGENTA)XOR with 00111000b/38h; it reverses the PAPER to 111b/07 WHITE.        _0BFA_PO_ATTR_1: if bit 4 of P FLAG is zero jump on to POATTR 2; the INK 9 flag                                                  - (INK 9) AND the attribute byte with 11111000b/F8h;    this makes the INK number 000b BLACK                                    - if bit 5 of the attribute byte isn't zero jump on to  PO ATTR 2; the PAPER colour is 100b/04 or more, GREEN, CYAN,    YELLOW or WHITE, and BLACK ink is correct                               - (PAPER colour of 3 or less, BLACK, BLUE, RED or       MAGENTA) XOR with 00000111b/07; it reverses the INK to 111b/07  WHITE.                                                                 _0C08_PO_ATTR_2: poke in the new value to the attribute  address.                                                               Exit: RET, from PO ATTR 2.                                      Output parameters: HL holds the attribute address                - A holds the attribute byte.                                  Called from:                                                     0BC1 PR ALL 5                                                  Exit from:                                                       2303 PLOT END (22DC PLOT)                                                                                                   PO ATTR 1 0BFA (0BDB PO ATTR)                                      Jumps from:                                                      0BDB PO ATTR (twice)                                                                                                        PO ATTR 2 0C08 (0BDB PO ATTR)                                      Exit from:                                                       0BDB PO ATTR through                                            0BFA PO ATTR 1 (twice)                                                                                                      PO BACK 1 0A23 (09F4 PRINT OUT)                                    Exit from:                                                       09F4 PRINT OUT via 0A11 control character table, when                          input code was 08 (cursor left).                                                                             PO BACK 2 0A38 (09FD PRINT OUT)                                    Jumps from:                                                      0A23 PO BACK 1                                                                                                              PO BACK 3 0A3A (09F4 PRINT OUT)                                    Jumps from:                                                      0A23 PO BACK 1 (twice)