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

  1.         - (end of string reached; there are included quotes, butS QUOTE S has returned one more than the length of the string   without its opening and closing quotes and counting only single embedded quotes) make a space in the work space of this length          - set pointers on the start of the string and the start of the work space.                                                     _25CB_S_Q_COPY: read a code from the string pointer              - move on the string pointer                                    - copy the code to the work space pointer                       - move on the work space pointer                                - if the last code wasn't 22h " loop back to S Q COPY           - (it was) read the next code and move on the string    pointer only                                                            - if the next code is again 22h ", loop back to S Q     COPY; without copying the second quote of the pair to the work  space                                                                  _25D9_S_Q_PRMS (copying is finished, or if entry is from S QUOTE there was no copying; the string start pointer is on thestack, and the length including the final quote has been        counted) decrement the length to exclude the final quote                - recover the start pointer; these are the string       parameters.                                                            Exit: into 25DB S STRING, which puts the parameters of   the copy in the work space, if one was made, otherwise of the   string in the BASIC on the calculator stack and returns into thescanning loop at 2712 S CONT 2; the next code may be a binary   operator.                                                              Output parameters: none                                          - the string parameters are on the calculator stack.           Rems:                                                            250F S QUOTE S used by                                                                                                      S QUOTE S subroutine 250F                                           Finds the length of a string between quotes; see S QUOTEabove, which is the only routine to call it.                           Input parameters: BC holds the length of the string as   counted so far, perhaps up to a pair of embedded quotes.               Action: call 0074 CH ADD+1 to move on the BASIC pointer  in 5C5D CH ADD                                                          - increment the string length                                   - if the code at the pointer is a newline report        "Nonsense in BASIC"; the string lacks a closing "                       - if it isn't 22h " loop back to S QUOTE S                      - (" found) call 0074 CH ADD+1 to move on the BASIC     pointer                                                                 - if the next character is a consecutive " return with  Z; the end of the string hasn't been reached.                          Exit: RET.                                                      Output parameters: BC holds the length of the string,    inclusive of the last but not the first quotation mark, and     counting embedded pairs as single characters                            - the Z/NZ flag shows Z if return was made on the first of two ""s.                                                            Called from:                                                     25B3 S QUOTE                                                    25BE S Q AGAIN                                                 Jumps from:                                                      auto                                                                                                                        S RND subroutine 25F8                                               Called only by SCANNING through the scanning function   table 2696; the executive routine for handling the RND function.Puts a "pseudorandom" number between zero and one on the stack; like PI, it is a function without an argument. Only half true inthis case: RND X can't be written in BASIC, but the subroutine  really uses the value in 5C76 SEED as an argument. See page 73  of the old handbook, page 77 of the Plus 2 handbook.                    Strictly speaking, a random number is a number that     can't be predicted, or one whose method of calculation isn't    known. Computers therefore can't produce random numbers! The    "pseudorandom" numbers of the Spectrum are produced from a      "seed" S by the formula                                                R = remainder on dividing (S+1)*75 by 65537, less 1,     divided by 65536; all decimals.                                         These are perfectly predictable, but the computer can   produce them faster than you can predict them!                         Input parameters: none.                                         Action: get the value from 5C76 SEED and call 2D2B STACK BC to put it on the stack                                               - figure the formula above, not including the division  by 65536d, on the calculator                                            - duplicate this result                                         - call 2DA2 FP TO BC to take one copy of the stack;     leaving only one copy on the stack. FP TO BC makes no error     reports, but truncates the number on the stack to an integer,   and if it is more than 65536d merely returns its remainder on   dividing by 65536d                                                      - put it in 5C76 SEED                                           - get the exponent of the copy from the stack pointer           - if it is zero jump on to S RND END; the result is zero        - (non-zero) take away 10h from the exponent, equivalentto dividing the number by 2**10h = 65536d.                             _2625_S_RND_END: jump on to exit.                               Exit: into 26C3 S NUMERIC via 2630 PI END, going back    into the scanning loop with the flag set for "numeric result" at2712 S CONT 2; the next code may be a binary operator.                 Output parameters: none                                          - the value of RND is on the calculator stack.                 Rems:                                                            26C3 S NUMERIC numeric result identified                        36A0 n-mod-m only used to calculate random number                                                                           S RND END 2625 (25F8 S RND)                                        Jumps from:                                                      25F8 S RND (twice)                                                                                                          S RPORT C 252D (24FB SCANNING; the heading is duplicated at 2761)                                                                  Exit from:                                                       2522 S 2 COORD (twice)                                                                                                      S RPORT C 2761 (2734 S LOOP; the heading is duplicated at   252D)                                                                  Exit from:                                                       275B S SYNTEST                                                  2788 S NOT AND                                                                                                              S RUNTEST 2764 (24FB SCANNING)                                     Jumps from:                                                      274C S STK LIST                                                                                                             S SC MATCH 255A (2668 S SCREEN$)                                   Jumps from:                                                      254F S SCRN LP                                                                                                              S SCREEN$ subroutine 2668                                           Called only from the scanning function table 2596; the  executive routine of the SCREEN$ function. Finds SCREEN$ (X,Y), the character on screen at the print position X,Y. The result isa string of length one.                                                 If the character at X,Y isn't in the range 20h "space"  to 7Fh "", the function returns the null string, length zero.  This won't happen with tokens, which are put on screen as       letters, but it will happen with user-designed graphics, unless sv 5C3O CHARS is reset for a scan of the UDGs.                          There are two complications:                                 1. The pixel bytes of the characters aren't consecutive on the screen, although they are in the character set. See DISPLAY AREA.                                                                2. The character on screen may be displayed INVERSE, ie    with PAPER and INK reversed; this must still count as a match.  The subroutine cannot recognise one character printed OVER      another.                                                                Most of the action is in the pseudo-subroutine 2525 S   SCRN$ S, which is called only from here, but this is merely a   device to abbreviate S SCREEN$ so that it will fit in the 256d- byte range of the table offsets, so its description is included here.                                                                   [As the notes on S SCRN$ S point out, the programmer    lost his place here: S SCRN$ S should return directly, not      through STK STO$. You can see the effect by running the         following:                                                                    10 CLS: PRINT "hello"                                           20 PRINT SCREEN$ (0,0)+SCREEN$(0,1)                       This ought to print "hello" followed on the next line by"he", but in fact it is followed by "ee". This is because the   PRINT statement in line 20 is a single expression; in evaluatingthis expression, the stack gets wrongly loaded with_two "h"s and_two "e"s and only the last two sets of string parameters get   printed. If the "+" in line 20 is replaced with a ";", so that  the two SCREEN$ functions are evaluated as separate expressions,the program prints out correctly.                                       A nit-picker could also criticize the ROM programming inS SCRN$ S on the ground that as a large number of the character forms have 00000000 as their first pixel byte, it wastes a good deal of time; quicker to sample the forms in their fourth or    fifth bytes, which are much more distinctive. However "a good   deal of time" doesn't actually mean much when time is measured  in T states; there is no perceptible delay in response to the   function.]                                                             Input parameters: none.                                         Action: call 2522 S 2 COORD to read the X and Y          coordinates from BASIC and put them on the calculator stack             - call S SCRN$ S to evaluate the function.                     _2535_S_SCRN$_S: call 2307 STK TO BC to get the          coordinates back; X is in C register, Y in B                            - get a pointer to the address in 5C36 CHARS; this is   100h less than on the first pixel byte of the character set             - add 100h; now on the first pixel byte                         - calculate a screen pointer to the address in the      display area of the first pixel on screen belonging to the printposition: for tab Y on line X this is, all in hex numbers:               4000 + 20 * (remainder on dividing X by 8) + Y          The "one-byte binary arithmetic" used is almost identical with that of 0E9B CL ADDR; see the index entry                               - make a character counter 60h/96d.                            _254F_S_SCRN_LP: get the pixel byte from the screen      pointer                                                                 - XOR it with the one in the character set; a direct    match gives 00000000b and an "inverse match" gives 11111111b            - if the result is zero jump on to SC MATCH                     - (not a direct match) increment the result; 11111111b  becomes 00000000b                                                       - if it isn't now zero jump on to S SCR NEXT                    - (inverse match) decrement it back to 11111111b.              _255A_S_SC_MATCH (first pixels match): copy the result ofmatching as an inverse/direct flag; 00 for direct match, FF for inverse match                                                           - make another counter 07; to loop through the remainingseven pixel bytes of the screen character and the character     form. The bytes are consecutive in the character form but 100h/ 256d bytes apart in the screen display.                                _255D_S_SC_ROWS: move the screen pointer on 100h; to the next pixel byte on screen                                               - move the character form pointer on one                        - XOR the screen pixel byte with the form pixel byte            - now XOR the result with the inverse/direct flag; in   either case a match will produce zero                                   - if it isn't zero jump on to S SCR NEXT; mismatch              - (matching so far) loop back to S SC ROWS counting downthe pixel bytes to zero                                                 - (all eight bytes match) drop the pointers                     - recover the character counter; it was counting down   characters from 96d                                                     - subtract it from 80h/128d to get the character code;  eg the first code in the set is 128 - 96 = 32d, the space               - make a space byte one; this one is also used on exit  from S SCR STO as the length of the string to be stacked                - call 0030 BC SPACES to make one space in the work     space                                                                   - put the code in it                                            - jump on to S SCR STO.                                        _2573_S_SCR_NXT: (mismatch found) move on the character  set pointer by 8 bytes                                                  - put the screen pointer back on the first pixel byte           - loop back to S SCRN LP, counting down the character   counter to zero                                                         - (no match found anywhere) make the string length zero.       _257D_S_SCR_STO: exit from S SCRN$ S through 257D S SCR  STO$ which puts the string parameters on the calculator stack.          - (return to S SCREEN$) move on the BASIC pointer and   exit.                                                                   Exit: into 25DB S STRING, which stacks the string       parameters again - unnecessarily, see the note above - and jumpsback into the scanning loop at 2712 S CONT 2; the next code     could be a binary operator.                                            Output parameters: none                                          - doubled string parameters on the calculator stack.           Rems:                                                            2522 S 2 COORD used by S SCREEN$                                                                                            S SCRN LP 254F (2668 S SCREEN$)                                    Jumps from:                                                      2573 S SCR NXT                                                                                                              S SCR NXT 2573 (2668 S SCREEN$)                                    Jumps from:                                                      254F S SCRN LP                                                  255D S SC ROWS                                                                                                              S SCRN$ S subroutine 2535                                           See 2668 S SCREEN$.                                            Called from:                                                     2668 S SCREEN$                                                                                                              S SCR ROWS 255D (2668 S SCREEN$)                                   Jumps from:                                                      auto                                                                                                                        S SCR STO 257D (2668 S SCREEN$)                                    Jumps from:                                                      255D S SC ROWS                                                                                                              S SD SKIP 26B6 (268D S BIN)                                        Jumps from:                                                      auto                                                                                                                        S STK DEC 26B5 (268D S BIN)                                        Jumps from:                                                      268D S BIN                                                                                                                  S STK LIST 274C (24FB SCANNING) see also BASIC INTERPRETER         Jumps from:                                                      2734 S LOOP (twice)                                            Rems:                                                            34B3 usr-no NB that on return to BASIC from m/c,                            alternate HL' must hold 2758h, the address                      of 38 end-calc in this section                                                                                  S STRING 25DB (24FB SCANNING)                                      Exit from:                                                       25B3 S QUOTE                                                    25D9 S Q PRMS                                                   2668 S SCREEN$                                                 Rems:                                                            257D S SCR STO mistake; parameters stacked twice                                                                            S SYNTEST 275B (24FB SCANNING)                                     Jumps from:                                                      274C S STK LST                                                                                                              stack see CALCULATE, GO SUB stack                                                                                               STACK A subroutine 2D28                                             Given a single-byte integer, puts its value on the      calculator stack in small integer FP form. The value is always  read as positive, eg FFh is read as 255d, not -1.                      Input parameters: value in the A register.                      Action: transfer the value to the BC register.                  Exit: into 2D2B STACK BC, which puts the value on the    stack.                                                                 Output parameters: the value in BC, with B zero                  - everything else unchanged.                                   Called from:                                                     23C1 DR PRMS (twice)                                            2439 ARC START (twice)                                          245F ARC END (twice)                                            2497 DRAW SAVE                                                  371C VALID