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

  1.        *2E56 PF LARGE large numbers reduced to printable size          *2EA9 PF INSERT digits put in buffer for printing               *2F0C PF ROUND maximum of 8 digits for printing, rounded        *2F18 PF RND LP final zero or tenth digit not printed           *2F2D PF COUNT B counts digits to be printed                    *2F46 PF NOT E prints initial zero if required                  *2F4A PF E SBRN prints digits before and after dec point        *2F52 PF OUT LP picks digits from print buffer                  *2F59 PF OUT DT print digit from buffer                         *2F5E PF DC OUT is dec point necessary?                         *2F64 PF DC 0S print dec point and/or zeroes                    *2F6C PF E FRMT print 'E' and prepare for exponent              *2F85 PF SIGN print '+' or '-' and exponent                     *361F str$ uses PRINT FP to output number to work space                                                                      print items see colours, control characters, printing                                                                           PRINT ITEMS SUBROUTINE see 1FFC PR ITEM 1                                                                                       PRINT OUT subroutine 09F4 see also printing                         The output routine for all channels except the R        channel; output will be to the upper or lower screen, or to the ZX printer, depending on the state of the flags set by 1615 CHANFLAG. It is therefore the routine usually called through restart0010 PRINT A 1, but there are also two direct calls for specificpurposes.                                                               The manoeuvres of PO 2 OPER, PO 1 OPER, PO CHANGE and POCONT require some explanation: they handle the output of AT, TABand the colour control codes.                                           AT and TAB codes are each followed by two parameters, eg                     16h 03 11h; AT 3,17 or                                          17h 19h 00; TAB 25.                                Similarly colour control codes are each followed by one parameter, eg                                                                         10h 07; INK 7 or                                                14h 01; INVERSE 1.                                Output of an AT or TAB control is handled by 201E PR AT TAB in the 1FCD PRINT command routine; it calls the output      routine 0010 PRINT A 1 three times, once with the control code  and the second and third times with the parameters. Similarly   output of colour controls is handled by 21FC CO TEMP 4, which   calls the output routine 0010 PRINT A 1 twice, once with the    control code and the second time with the parameter.                    The three codes of AT or TAB, or the two of a colour    control, are collected before any execution is performed and    executed all at once by PO CONT. PO CONT is entered with               - the control code in 5C0E TVDATA lo: 10h for INK, 11h   for PAPER, ... etc, 16h for AT or 17h for TAB                          - the first of two parameters, if there are two, in 5C0F TVDATA hi: the line number of AT, the lo byte of TAB                   - the second of the two AT/TAB parameters, or the sole   parameter of the colour controls, in the A register: the column number of AT, the hi byte of TAB, the colour number for INK/    PAPER or the on/off signal for the other colour controls.               The collection of these input parameters is achieved by manipulating the channel output address. 0010 PRINT A 1 doesn't itself execute output, it merely calls the output address; if   another address is substituted, the next call to PRINT A 1 will execute the routine at that address. So for example in executingoutput of AT                                                           - the first call to PRINT A 1 enters PO 2 OPER, through  the control character table in PRINT OUT, with code 16h/22d AT. PO 2 OPER, PO TV 1 and PO CHANGE put this code in 5C0E TVDATA loand put the address of PO TV 2 in the output channel                   - thus the second call to PRINT A 1 enters PO TV 2       directly, not through the table, and this time with the code of the first AT parameter. PO TV 2 and PO CHANGE put this code in  5C0F TVDATA hi and change the output address again, this time toPO CONT                                                                - so the third call to PRINT A 1 enters PO CONT directly,now with the code of the second AT parameter and with the other two codes in TVDATA. PO CONT changes the output address back to normal, 09F4 PRINT OUT, before proceeding to execute the AT witha full set of parameters.                                               Execution of TAB is just the same; execution of the one-parameter colour controls is the same except that initially     execution is directed to PO 1 OPER instead of PO 2 OPER, with   the effect that the middle call to PO TV 2 is left out.                 The section from 2211 CO TEMP 5 to 2287 CO TEMP E is    described here, following 0AD0 PO SPACE: although located in a  quite different part of the ROM, it is actually part of the     PRINT OUT routine. This is the routine which executes the colourcontrols INK to OVER, by making whatever changes are called for in 5C8F ATTR T/MASK T/P FLAG. ATTR T holds the attributes to be used for the next screen output; MASK T has zero bits in the    positions which are to be changed in the screen attributes; P   FLAG signals INVERSE, OVER, PAPER 9 and INK 9. These svs are    changed by three calls to CO CHANGE, which performs an XOR/AND/ XOR on the value in each of the svs in turn, using a setting    byte in A and a mask in B register; the bulk of the routine is  concerned with preparing the setting bytes and masks. See under colours, masks.                                                         [There are two errors in the PRINT OUT routine, though  fortunately their effects are seldom encountered:                    1. 0A23 PO BACK 1 contains what is perhaps the most seriouserror in the Spectrum ROM: it doesn't just give wrong responses,it can actually crash programs and damage the user's variable   records. The description given under PO BACK 1 below explains   what_ought to happen, but in fact for checking moves "off       screen" the ROM compares the line number with 18h instead of    19h: the ninth instruction in the section is LD A,18 when it    ought to be LD A,19.                                                    The effect can be seen by the following test program.   Don't try this if you have anything valuable in the computer!                10 CLS: PRINT AT X,0; CHR$ 8 + "Miles"              If you run this with X = 1, the backspace code CHR$ 8 is       ignored, and "Miles" is printed at the start of the second      screen line. This is what ought to happen at the top screen     line, X = zero.                                                         If you run it with X = zero, the backspace isn't ignoredas it should be: "iles" is printed at the start of line zero.           What happens to the "M" is that it is output eventually to PR ALL with a "screen address" in HL which was calculated    from the "impossible" position value 1902h by 0E9B CL ADDR      called from 0DD9 CL SET. None of these subroutines make any     check on impossible position values. The "screen address" from  CL ADDR comes out as 58E0h, which is read as the "first pixel   byte" on screen by PR ALL, and so it pokes the eight character  pixel rows of "M" into                                                             58E0 - an attribute                                             59E0 -   "    "                                                 5AE0 -   "    "                                                 5BE0 - the printer buffer                                       5CE0 - spare RAM                                                5DE0 -   "    "                                                 5EE0 -   "    "                                                 5FE0 -   "    "                                      Next it calls 0BDB PO ATTR which finds the "attribute   address" corresponding to this "screen address": it will be 5BE0again - in the fourth third of the screen! - so no further harm is done when the attribute byte is poked into it.                       The first four of these addresses are harmless enough,  but the other four can do incalculable damage, since they are   all too likely to be in your BASIC program and/or variables     record: a fairly common effect, with a short BASIC program, is  to produce the "Variable not found" error whenever you try to   use any variable, even if you give them new values.                  2. As the notes indicate, 0A3D PO RIGHT ought to exit      through PO STORE, to update the position value svs. As it is, ifthe routine is ever used - which seems unlikely! - it will be   ineffective, as the next print will overwrite the code just     stepped over.]                                                         Input parameters: a character code in A.                        Action: call 0B03 PO FETCH to get the print position             - if the character code is 20h or more jump on to PO    ABLE; a "printable" code, ie space, a symbol, a digit or letter,a graphic or a token                                                    - if it is less than 06 or more than 17h jump on to PO  QUEST; these codes are meaningless in output                            - (that leaves 06 PRINT comma, 08 cursor left, 09 cursorright, 0D newline, and the colour and AT/TAB controls 10h ->    17h; the rest, 07 and 0A -> 0C, are meaningless and are handled by PO QUEST through the table) add the code to the base address 0A0B of the control character table at 0A11                             - add the offset at that address; this computes the     address of the executive routine                                        - stack the address                                             - jump to PO FETCH, to get the position values again, asHL has been used; it will return to the computed address.              _0A23_PO_BACK_1 (entered from the control character tableto execute the backspace, code 08; cf 1007 ED LEFT, used in     editing to move the cursor back): increment the print position  column number                                                           - if it isn't now 22h/34d, jump on to PO BACK 3; the    position isn't at a line start                                          - (the last print was at a line start, column 21h/33d)  if bit 1 of FLAGS is set jump on to PO BACK 2; output is to the ZX printer, which cannot handle the backspace at line start             - (not ZX printer) increment the line number; ie go up  one line                                                                - make the column number 02; as if the last print was onthe last but one column                                                 - if the new line number isn't 18h/24d jump on to PO    BACK 3; moving up a line goes off screen [this should have been 19h/25d, see above]                                                     - (the print position has gone off screen) decrement theline number; ie refuse to accept the backspace.                        _0A38_PO_BACK_2 (the backspace isn't accepted): restore  the column number to line start.                                       _0A3A_PO_BACK_3: exit into 0DD9 CL SET and 0ADC PO STORE,which record the new position values in svs.                           _0A3D_PO_RIGHT (entered from the control character table to execute code 09 "print position right"; it is impossible to  get this code into BASIC with any kind of keystroke, but it can be included in print strings from m/c and could be input from   peripherals, for what it is worth): save the current P FLAG     value                                                                   - set P FLAG to 01; OVER 1                                      - load a space and call 0B65 PO CHAR to output it;      instead of manipulating the column position directly, as in PO  BACK 1 for left movement, the ROM takes the simpler course of   printing an "invisible" space by using OVER 1, which has exactlythe desired effect [except for the error noted above]                   - restore the original P FLAG value and return.                _0A4F_PO_ENTER (entered from the control character table to execute code 0D, newline. Quite different from 1024 ED ENTER,which handles the ENTER key during editing): if bit 1 of FLAGS  is set jump on to 0ECD COPY BUFF; output is to the ZX printer.  This empties the printer buffer                                         - (not ZX printer) load the column number 21h/33d;      signalling that the last print position was at line start               - call 0C55 PO SCR to check for screen scrolling and    execute it if necessary                                                 - decrement the print position line number; down one    line                                                                    - exit into 0DD9 CL SET, which finds the display addressof the new print position, and 0ADC PO STORE which sets the     position value svs.                                                    _0A5F_PO_COMMA (entered from the control character table to execute code 06, PRINT comma; cf 204E PR POSN 1 which changesa comma code 2C in a PRINT command to a PRINT comma 06 before   outputting it): call 0B03 PO FETCH to get the current print     column number; as the notes point out, this is unnecessary,     because this subroutine is actually entered from PO FETCH, by   the indirect jump from PRINT OUT. However, this call means that PO COMMA could be called as a subroutine from m/c                       - decrement the column number twice                             - AND it with 00010000b/10h; if it was 11h or less this comes out as 00, if 12h or more as 10h                                            0000xxxxb/0xh AND 10h = 00                                      0001xxxxb/1xh AND 10h = 10h                           - exit to PO FILL, which outputs the correct number of  spaces to TAB on to a half-line start.                                 _0A69_PO_QUEST (entered from PRINT OUT or the control    character table to execute the meaningless codes 00 -> 05, 07,  0A -> 0C, 0E, 0F or 18h -> 1Fh): load 3F ?                              - exit to PO ABLE to output the "?".                           _0A6D_PO_TV_2 (entered only by an indirect jump from PO 2OPER through PO CHANGE, see above): load the address of PO CONT         - store the character code in 5C0F TVDATA hi; the first parameter of an AT or TAB control                                       - exit to PO CHANGE, which continues output of AT/TAB   and their parameters.                                                  _0A75_PO_2_OPER (entered from the control character tableto execute codes 16h and 17h, the AT and TAB control codes):    load the address of PO TV 2; the next call to PRINT A 1 will go there, see above                                                        - jump on to PO TV 1.                                          _0A7A_PO_1_OPER: (entered from the control character     table to execute the colour control codes): load the address of PO CONT; the next call to PRINT A 1 will go there, see above.          _0A7D_PO_TV_1: save the control code in 5C0E TVDATA lo;  this is either AT/TAB or a colour control.                             _0A80_PO_CHANGE (entered here and from PO TV 2 with the  address of PO CONT, but from PO 2 OPER with the address of PO TV2, and also called as a subroutine from PO CONT with the addressof PRINT OUT): get the address of 5C51 CURCHL; the first two    bytes are the output address                                            - load the two bytes of the next output address there           - return.                                                      _0A87_PO_CONT (entered with a full set of parameters,    three codes for an AT/TAB or two for a colour control): load theaddress of PRINT OUT                                                    - call PO CHANGE to restore it to the output channel            - get the parameter(s) from 5C0E TVDATA                         - if the control code in 5C0E TVDATA lo is less than    16h/22d jump on to 2211 CO TEMP 5; colour controls. CO TEMP 5,  misprinted CO TEMPS in "ROM Disassembled", is described below,  after PO SPACE                                                          - if the code is 17h/23d TAB jump on to PO TAB                  - (AT) make a two-byte print position, hi byte line     number and lo byte column number, from the AT parameters                - subtract the column number, which is that given in theBASIC command, from 1Fh/31d; so instead of running from zero to 31d it now runs from 1Fh/31d to zero                                    - if this makes a carry jump on to PO AT ERR                    - add 02; see DISPLAY AREA, where it is explained how   the print position column number takes values from 21h on the   left margin to 02 on the right. There is a misprint in the      notes, +21 - +22 should read +21 - +2                                   - if bit 1 of FLAGS is set jump on to PO AT SET; the ZX printer takes no account of line numbers                                - (screen output) subtract the line number from 16h/22d;so instead of running from zero to 21d as in the AT command it  runs from 16h/22d to one.                                              _0AAC_PO_AT_ERR: if carry is set report "Integer out of  range"; AT called for a tab 32d or more, or a line 22d or more          - add 02 in two moves; the second gives the normal      position value line number, see DISPLAY AREA, but the first     value, one less, is used for a check in a moment                        - if bit zero of TV FLAG is set exit to 0C55 PO SCR;    output is to the lower screen. An AT control in the lower screenmay require scrolling; it could appear in an INPUT ... AT, or ina PRINT (hatch)                                                         - (upper screen) if the line number less one is less    than the number in 5C6B DF SZ report "Out of screen"; DF SZ     holds the position value line number of the top of the lower    screen, and if the new line number isn't more than this the     upper screen is going to overlap the lower.                            _0ABF_PO_AT_SET (AT execution completed) exit to 0DD9 CL SET to fix the position value svs.                                     _0AC2_PO_TAB (TAB; the hi byte or second byte of the     parameter input by BASIC is ignored, and the lo byte is reduced "modulo 32d", ie its remainder on dividing by 32d is used. Eg          TAB 73 is interpreted as TAB 9                                  TAB 567 = 55 + 2 * 256d is interpreted as TAB 23):               - get the first parameter; the lo byte. It came from    5C0F TVDATA hi in PO CONT                                              _OAC3_PO_FILL (this is also the exit routine from PO     COMMA; in either case the A register holds a tab position): call0B03 PO FETCH to get the last column number; say C                      - add the tab; say T + C                                        - decrement the result; T + C - 1                               - AND it with 00011111b/1Fh to get the result modulo    20h/32d; the present tab position is 21h minus the print        position column number C, so the number of spaces required to   execute the TAB command is T - (21h - C) = T + C - 1 (- 20h).   The -20h disappears in the modulo operation                             - if the result is zero return; no spaces need to be    printed                                                                 - (spaces needed) make a counter for the number of      spaces; the D register is used so as not to disturb the positionvalues in BC