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

  1.     upper display, upper print line, upper screen see DISPLAY   AREA                                                                                                                                useful routines for m/c programs                                    These are subroutines which can be used in a variety of different kinds of program. I have tried not to include anythingtoo fancy: experienced programmers will think of all sorts of   clever tricks.                                                         General purpose:                                                _162C_CALL_JUMP: call it with any address in HL, it will call that address as a subroutine. A "computed GO SUB" command.        _16DC_INDEXER: very useful for indexed tables of all     kinds.                                                                 _19DD_DIFFER: returns with BC = HL - DE, and with HL and DE exchanged but not otherwise affected.                               _1BB0_REPORT_0 [zero]: a jump to here clears all the     "work areas", resets BASIC, and prints the "OK" message. Not a  bad way to exit from some types of m/c program. But it won't    reset the alternate HL' register.                                      _1E94_FIND_INT1 see 2DD5 FP TO A.                               _1E99_FIND_INT2 see 2DA2 FP TO BC.                              _1E9C_FIND_I_1: reports "Integer out of range" if called with either carry or NZ.                                               _1F1A_FREE_MEM: from BASIC, PRINT 65536-USR 7962 shows   the amount of memory still unused.                                     _1F54_BREAK_KEY: returns with NC if BREAK is pressed.    Invaluable for m/c programs, including debugging.                      _1FC3_UNSTACK_Z: by using the flag in bit 7 of FLAGS, youcan have a choice of return addresses from any subroutine.             _226C_CO_CHANGE: can be used to change individual bits inthe byte at the address HL, using A as the setting byte and B asa "mask". See the index entry, and under masks.                        _2AEE_DE,(DE+1): call it with an address in DE, it       returns with DE holding the values in the two following         addresses. Could be used in reading a table of addresses.              _2AFD_GET_HL*DE: see 30A9 HL=HL*DE.                             _2BA6_L_ENTER: call it at 2BA7 to carry out a normal LDIRinstruction. The advantage is that it checks BC for zero,       returning with zero if BC was zero, thus avoiding many a m/c    crash! On return, HL will have the old DE value unless BC was   zero.                                                                  _2C88_ALPHANUM call it with a code in A, it will return  with carry if the code is a digit, A-Z or a-z.                         _2C8D_ALPHA: call it with a code in A, it will return    with carry if the code is A-Z or a-z.                                  _2D1B_NUMERIC call it with a code in A, it will return   _without carry if the code is a digit; the opposite of the last two.                                                                   _2D7F_INT_FETCH: call it with HL holding the address of  the first byte of a small integer format, it returns with the   value of the number in DE.                                             _2D8E_INT_STORE: the reverse of INT FETCH: call it with anumber in DE and an address in HL, it puts DE in small integer  format in the five addresses starting at HL.                           _2DA2_FP_TO_BC: takes a 2-byte number off the calculator stack into BC. 1E99 FIND INT2 does the same, but crashes with   error reports if the number isn't an integer or is out of range.       _2DD5_FP_TO_A: takes a small number off the calculator   stack into A. 1E94 FIND INT1 does the same, but crashes with    error reports if the number isn't an integer or is out of range.       _30A9_HL=HL*DE: returns HL = HL * DE, or with carry set  if the result is too big. 2AF4 GET HL*DE does the same, but     crashes with the "Out of memory" report if the result is too    big.                                                                   _33C0_MOVE_FP (duplicate): despite the description in thenotes, this subroutine can be used to copy any five bytes from  any address HL to any other DE.                                        _343E_SWAP_BYTE: call it with a number in B, it will     exchange B bytes from the address starting in HL with B bytes   from the address starting in DE.                                    Printing on screen:                                                _0010_PRINT_A_1: the simplest way to print on screen.    Prints a single character on screen at the current print        position. You must open a channel first, but then it can be usedrepeatedly. It saves all the registers.                                _0C0A_PO_MSG: the most useful subroutine for printing    messages on screen.                                                    _0D6B_CLS: a call to it is just like the BASIC CLS       command. But the subroutine opens channel K; if you want to     print out after using it, you must call 1601 CHAN OPEN after it.Cf 0DAF CL ALL.                                                        _0DAF_CL_ALL: clears the screen, like 0D6B CLS, but      doesn't reform the lower screen area, which can be a nuisance.  However it leaves channel S open.                                      _0DD9_CL_SET: call it with a print position in BC, line  from 24d -> one in B, column from 32d -> one in C, it will      return with HL holding the address of the first pixel of that   character in the display area. See also 0E9B CL ADDR.                  _0E00_CL_SCROLL: call it with a number in B, it will     scroll the whole screen up by B lines.                                 _0E44_CL_LINE: call it with a number one -> 18h/24d in B;it clears the bottom B lines on the screen. A simple way to     clear the input area, among other things.                              _0E88_CL_ATTR: call it with HL holding 800h plus the     display address of the first pixel of any character on the      screen, see 0E9B CL ADDR below; it returns with DE holding the  attribute address of that character. Useful for setting         attributes when non-standard methods of printing on screen are  used.                                                                  _0E9B_CL_ADDR: call it with a line number in B, from one at the bottom of the screen to 18h/24d at the top; it will      return with HL holding the address in the display area of the   first pixel of the first character in that line. Useful for     putting marks on the screen. But see also 0DD9 CL SET.                 _1601_CHAN_OPEN: essential for any printing on screen    from m/c. Call it with zero or one in A to print in the lower   screen, two in the upper, or three to print out on the ZX       printer. An output routine such as RST 10h is also necessary.   Beware! CHAN OPEN corrupts all the registers.                          _1A1B_OUT_NUM_1: call it with a number in BC, it will    print BC on the screen, provided you have opened the correct    channel. But BC must be less than 10000d. 1A28 OUT NUM 2 is     similar, but prints leading spaces so that the number always    takes four spaces.                                                     _203C_PR_STRING: prints out a string starting at DE, of  length BC.                                                             _2294_BORDER: rather than calling 2294, call 229B with   the required colour in A - but make sure it is 7 or less! If    there is any doubt about it, call 2297, which will give an errorif the colour is impossible.                                           _22E5_PLOT_SUB: call it with pixel coordinates in BC, it plots a pixel at that position.                                        _238D_DR_3_PRMS: can be called at 2394 to draw arcs on   the screen. All three parameters must be on the calculator      stack: the X and Y DRAW parameters, ie the_increments required, and Z the turning angle of the arc, Z last. The old PLOT        coordinates must be in 5C7D COORDS.                                    _24B7 DRAW_LINE: can similarly be used to draw straight  lines, with two increments on the stack and two coordinates in  5C7D COORDS.                                                           _2DC1_LOG(2**A): given the exponent byte of a FP number, will tell you how many decimal digits are needed to print it.   Useful eg in printing tables with the decimal points aligned.          _2DE3_PRINT_FP: prints on screen a number from the       calculator stack, at the current print position. A channel must be opened. Will print any real number, in 14-character standard format: for integers, can well be preceded by 2D28 STACK A or   2D2B STACK BC.                                                      Miscellaneous:                                                     _0038_MASK_INT see 02BF KEYBOARD.                               _02BF_KEYBOARD: usually unnecessary to call this, as it  is called repeatedly by the interrupt, and the final code of thelast key pressed can always be found in 5C0B LAST K, IY-50.     However, if your program runs with the interrupt disabled it canbe called direct or by RST 38h.                                        _03B5_BEEPER: call it with DE holding the number of      pulses required, duration times frequency, HL holding the lengthof each pulse in units of four T states:                                         3,500,000d/(4 times frequency)                         These values are usually best found by trial and error!        _196E_LINE_ADDR: call it with a BASIC line number in HL, it returns with HL holding the start address of that line in theprogram area, or the nearest above it.                                 _1974_LINE_AD_1: call 1975, not 1974, with a line start  address in HL and BASIC line number in BC for a similar result  to LINE ADDR.                                                          _1980_CP_LINES: call it with the address of a BASIC line number in HL and a number for comparison in BC; it returns with zero and carry flags signalling the result of the comparison.   Actually any hi-lo number will work.                                                                                                user defined graphic codes see 5C7B UDG                                                                                         USE ZERO subroutine 1CE6                                            Puts a zero on the calculator stack, usually because no specific parameter has been found in the BASIC.                        Input parameters: none.                                         Action: use the calculator to stack a zero.                     Exit: RET.                                                      Output parameters: HL, DE point to the first byte of the last value and to the stack end.                                       Called from:                                                     06C3 SA CODE                                                    06F0 SA CODE 2                                                  181A LIST 3                                                    Exit from:                                                       1CDE FETCH NUM (twice)                                                                                                      USE 252 2495 (247D CD PRMS1)                                        A label is missing on the following line due to a       misprint: it should be marked 2497 DRAW SAVE.                          Jumps from:                                                      247D CD PRMS1                                                                                                               USR key (C0) see also commands, functions and operators,    KEYBOARD SCANNING, 022C extended mode table (b)                         The L key in E mode without shift produces the function USR. There are two quite different functions using the same     code.                                                                   USR X$: if the function has a string argument, it must  be a single letter from A to U inclusive, either upper or lower case, or an already defined user character. The function returnsthe address of the first byte of the corresponding character    form in the user-defined graphics area.                                 USR X: if it has a numeric argument, it must be a       positive number less than 10000h/66536d. To evaluate the        function, the program jumps to the address X, executes whatever m/c it finds there as a m/c subroutine, and when it finds a RET resumes execution of the BASIC program with the exit value of   the BC register as the value of the function. X may be a        subroutine address in ROM, or the start of a m/c routine        prepared by the user and stored in RAM.                                 On execution, 24FB SCANNING quickly leads to 26DF S     NEGATE. This converts the key code C0 first to 11h, then to ED, and adds the priority 10h/16d. Code and priority 10ED are now   pushed on to the machine stack (270D S PUSH PO) while the       expression following USR is evaluated.                                  When the code is taken off the stack (2734 S LOOP), bit 6 of FLAGS indicates whether the argument is string or numeric. For a numeric argument (2773 S TIGHTER), the operation code is  converted from ED to 2D, the calculator offset for 34B3 usr-no. For a string argument, ED is replaced by 99h, which is          immediately (in 274C S STK LIST) converted to 19h, the offset   for 34BC usr-$.                                                                                                                     usr-no subroutine 34B3                                              Called from 0028 FP CALC with the literal 2D; executes  the function USR X with numeric argument. Not called otherwise  from ROM. Fairly pointless to call it from m/c, although it     would work given the right inputs.                                      The actual value returned by USR X may or may not be    important: to give simple examples,                                    RANDOMIZE USR 0. The point of this is to reset the       computer, and in the course of doing so the computer will       "forget" all about returning a value.                                  PRINT 65536-USR 7962. Now the point is to get the number of RAM bytes used up so far; see 1F1A FREE MEM.                        Input parameters: HL points to the first byte of X, whichmust be the last value on the calculator stack; it must also be positive and less than 10000h/65536d, but needn't be an integer         - DE points to the stack end.                                  Action: call 1E99 FIND INT2, which rounds X to an integerand gets it off the stack into BC                                       - PUSH the return address 2D2B STACK BC                         - make an indirect jump to the address X.                      Exit: into the subroutine selected by the user. This willreturn to STACK BC, which stacks the BC value and resets IY in  case the user-defined routine relocated it - but doesn't reset  HL' - and then returns into the calculator loop.                       Output parameters: none.                                                                                                     USR RANGE 34D3 (34BC usr-$)                                        Jumps from:                                                      34BC usr-$                                                                                                                  USR STACK 34E4 (34BC usr-$)                                         This label is omitted by a misprint; it should be on theJP 2D2B STACK BC line just before 34E7 REPORT A.                       Jumps from:                                                      34D3 USR RANGE                                                                                                              usr-$ subroutine 34BC                                               Called from 0028 FP CALC with the literal 19h; executes the function USR X$ with string argument, by returning the      address of the first byte of the udg character form             corresponding to X$. Not called otherwise from ROM. Can be      called from m/c, direct or through the calculator.                      There are only 15h/21d udgs, and each has eight bytes.  The required address is eight times the serial number of the    named udg, starting from zero, plus the address in 5C7B UDG.            A user-defined graphic (udg) will have a code in the    range 90h -> A4h, so subtracting 90h gives the required serial  00 -> 14h, which is now multiplied by eight.                            A letter code will be either 41h -> 55h (A-U) or 61h -> 75h (a-u). These are decremented by one and multiplied by 8 in  16-bit arithmetic, ie the result is decremented by any multiple of 100h/256d:                                                                        less one     times eight    mod 100h               41h->55h --> 40h->54h --> 200h->2A0h --> 00h->A0h               61h->75h --> 60h->74h --> 300h->3A0h --> 00h->A0h                                                                               90h->A4h --> 00h->14h -->  00h->A0h                            Input parameters: none                                           - the string parameters of X$ must be the last value on the calculator stack; X$ must be a single letter A to U or a to u, or a udg character.                                                 Action: call 2BF1 STK FETCH, which puts the start addressof the string in DE and its length in BC                                - if the length isn't one report "Invalid argument"             - get the character code from the start address                 - call 2C8D ALPHA, which checks for an alphabetic letter        - jump on to USR RANGE if the character is a letter             - (it isn't a letter) take away 90h                             - if this makes a carry report "Invalid argument"; the  code is before the start of the udgs                                    - if the result is more than 14h/20d report "Invalid    argument"; the code is after the end of the udgs                        - increment the result; to cancel the decrement which   follows.                                                               _34D3_USR_RANGE: decrement the letter code                       - double it three times; multiply by eight                      - if the result is more than A0h report "Invalid        argument"; letters VWXYZ aren't accepted                                - add the resulting offset to the lo byte of the addressin 5C7B UDG                                                             - if there is no carry jump on to USR STACK                     - (carry from the lo byte) increment the hi byte; the   result is the start address of the udg character form.                 _34E4_USR_STACK (the label is omitted by a misprint; it  should be on the last line before 34E7 REPORT A): exit.                Exit: into 2D2B STACK BC, which puts the address on the  calculator stack.                                                      Output parameters: BC holds the address required.                                                                                                     -----                                                                                                  VAL key (B0) see also VAL$ key, commands, functions and     operators, KEYBOARD SCANNING, 022C extended code table (b)              The J key in E mode without shift produces the function VAL; it requires one string operand X$, which must be, or be    equivalent to, a numeric expression enclosed in quotes. The     value of the function is the value of the numeric expression.