_hex |_decimals 26 0D FE 62 | 038 013 254 098 the results would be 62 * 0A + 00 = 03D4| 98 * 10 + 00 = 980 = D4 lo and 03 hi| = 212 lo and 003 hi FE * 0A + 03 = 09EF| 254 * 10 + 03 = 2543 = EF lo and 09 hi| = 239 lo and 009 hi 0D * 0A + 09 = 008B| 13 * 10 + 09 = 139 = 8B lo and 00 hi| = 139 lo and 000 hi 26 * 0A + 00 = 017C| 38 * 10 + 00 = 380 = 7C lo and 01 hi| = 124 lo and 001 hi leaving 7C 8B EF D4 | 124 139 239 212 as the fraction - which expressed as a binary string is ten times the original - and bringing out a carry of 01 which is printed as the next digit of the decimal representation. Input parameters: A and C each contain two hex digits, that in C being the "carry" from a previous operation. Action: put A in L with zero H - multiply HL by 10 in six bytes; clever! LD DE,10d/CALLHL=HL*DE is also six bytes, but much slower - add C - put H in C and L in A. Exit: RET. Output parameters: HL equals the result CA - B and DE unchanged. Called from: 2EEF PF FR EXX (twice) CD PRMS1 subroutine 247D Sets the_initial_parameters_for_CIRCLE_and_DRAW; but notused for DRAWing straight lines. The subroutine starts from the input values Z = the radius (CIRCLE) or approximate diameter (DRAW) of the curve G = the angle in radians through which the curve will turn; in the case of CIRCLE, G = 2pi. If you aren't sure about radians, see under 2783 get-argt. Other values are on the calculator stack and in the calculator memory, but they aren't used. The parameters required are the_arc_count a, the_number of short straight lines whichmust be drawn to approximate the required curve; these are oftencalled_"arcs", in quotes various functions of G and a: G/a, SIN (G/2a), COS (G/ a), SIN (G/a). G/a is of course the angle in radians through which each "arc" will turn; SIN (G/a) is a close approximation to the length in pixels of each arc. The first approximation to the arc count is got by calculating half the absolute value of G times the square root of Z: [ABS (G * SQR Z)]/2 which gives a count producing a length of about twice the square root of Z for each "arc"; say 18d pixels length for a circle which nearly fills the screen. The "arcs" used in DRAW are shorter, because Z is the radius of the curve, not its diameter, but the difference isn't very great. The modified value taken for the arc count is the nearest integer multiple of 4 above this; but if the modified value comes out at more than 252d, it is given 252d as a maximumvalue. This can just happen, given a long line and a large angle. The difference made by these corrections of the arc countaren't perceptible on screen. Input parameters: Z is last value on the stack, G is heldin mem-5. Action: use the calculator to figure in succession SQR Z, (SQR Z)/2, (G * SQR Z)/2, and a = ABS [(G * SQR Z)/2] - call 2DD5 FP TO A take the approximate arc count off the calculator stack into the A register - if this makes a carry jump on to USE 252; a > 255d - AND the arc count with 11111100b/FCh; giving a multiple of four - add four - if there is no carry jump on to DRAW SAVE; a is still less than 256d. _2495_USE_252 (a is more than 252d): make it FCh/252d; the maximum value. _2497_DRAW_SAVE (the label is omitted by a misprint): call 2D2B STACK A to put the arc count on the calculator stack - use the calculator to figure and load into the calculator memory SIN (G/a) SIN (G/2a) G/a SQR[1 - SIN**2(G/a)] = COS (G/a). Exit: RET, from 2497 DRAW SAVE. Output parameters: the B register holds the arc count a - mem-0 holds G/a - mem-1 holds SIN (G/2a) - mem-2 holds zero, unchanged from input - mem-3 holds COS (G/a) - mem-4 holds SIN (G/a) - mem-5 holds G, unchanged from input - the calculator stack is unchanged from input. Called from: 233B C R GRE 1 23C1 DR PRMS Rems: 2320 CIRCLE initial parameters set by 235A C ARC GE1 arc count recovered from stack 2382 DRAW initial parameters set by 2439 ARC START draws single arc 245F ARC END uses coordinates of last arc drawn 2477 LINE DRAW draws last arc C ENT 37B7 (37B5 sin) Exit from: 37AA cos 37B5 sin CH ADD system variable 5C5D Bytes: 2 The BASIC pointer: the address, usually in the program area, currently reached by the BASIC interpreter. It is one of the "fourteen pointers" which must be adjusted each time space is made or reclaimed in the ROM, see 1664 POINTERS. Written by: 0078 TEMP PTR2 0090 SKIPS 12CF MAIN 3 166B PTR NEXT 198B EACH STMT 199A EACH S 3 19FB E LINE NO 1BD1 NEXT LINE 2174 IN VAR 5 21B9 IN ASSIGN 26B6 S SD SKIP 2831 SF VALUES 288D SF VALUE (twice) 29E0 SV CH ADD 35DE val 360C V RPORT C (twice) Read by: 0008 ERROR 1 0018 GET CHAR 0074 CH ADD+1 155D MAIN ADD 166B PTR NEXT 1D34 F L&S 2129 IN PR 3 35DE val Rems (this list omits references to the note "Advance CH ADD" which is written against almost every call to NEXT CHAR): 0020 NEXT CHAR incremented 007D SKIP OVER amended 1B17 LINE SCAN skipped over line number 1BD1 NEXT LINE as usual, points to character considered 1DEC READ 3 used as pointer to DATA list 1DED READ saved in X PTR 1E0A READ 1 set; fetched and stored in DATADD; set again 268D S DECIMAL incremented by 0077 TEMP PTR1 2831 SF VALUES steps through FN statement 28AB FN SKIPOVER left undisturbed 28B2 LOOK VARS points to first letter of variable 294B V END points to next after name of variable CH ADD+1 subroutine 0074 Increment system variable 5C5D CH ADD and read its new value. The subroutine is also entered at 0077 TEMP PTR1, when HLalready holds the value of CH ADD, and at 0078 TEMP PTR2 when ithas already been incremented. Input parameters: none. Action: get the address from CH ADD. _0077_TEMP_PTR1: increment it. _0078_TEMP_PTR2: put the incremented address in CH ADD - read the byte at that address. Exit: RET from TEMP PTR2. Output parameters: HL holds the new BASIC pointer - A holds the byte at the pointer. Called from: 0020 NEXT CHAR 1E0A READ 1 (as 0077 TEMP PTR 1 and as 0078 TEMP PTR 2) 250F S QUOTE S (twice) 268D S BIN (as 0077 TEMP PTR 1) 2D40 NXT DGT 2 Rems: 2D3B INT TO FP repeated calls fetch digits of integer CHAN FLAG subroutine 1615 see also 1601 CHAN OPEN, channels and streams. Sets flags according to the channel selected, and sets 5C8F ATTR T as appropriate; for channel K, to print in the lowerscreen, it must use the BORDER colour and contrasting ink, for channel S, to print in the main screen, it must use the ink and paper colours from 5C8D ATTR P. Can be regarded merely as an alternative entry point to 1601 CHAN OPEN, called when the channel address is already known: so used in the ROM after a second channel has been openedtemporarily, the address of the first one being saved on the stack. If the selected channel isn't K, S or P, the only effectis to reset bit 4 of FLAGS2; "not using channel K". This appliesto channel R. Input parameters: HL holds a pointer to the channel information area, marking the base address of the selected channel. Action: put the address in 5C51 CURCHL - zero bit 4 of FLAGS2; "not using channel K" - move the pointer on four places; now it is on the channel code letter - get the letter - call 16DC INDEXER to index into the channel code look-up table at 162D; it collects an offset - if INDEXER returns with no carry, return; the channel code isn't K, S or P - add the offset to its address in the table to get a jump address CHAN K, CHAN S or CHAN P. _162C_CALL_JUMP: jump to the indexed address. _1634_CHAN_K: set TV FLAG bit 0; "using lower screen" - zero FLAGS bit 5; "ready for a key" - set FLAGS2 bit 4; "using channel K" - jump on to CHAN S 1. _1642_CHAN_S: zero TV FLAG bit 0; "using main screen" _1646_CHAN_S_1: zero FLAGS bit 1; "printer not in use" - exit to 0D4D TEMPS. _164D_CHAN_P: set FLAGS bit 1; "printer in use" - return. Exit: RET from CHAN P in the case of P or any other than K or S - into 0D4D TEMPS, setting 5C8F ATTR T, in the case of channels K and S. Output parameters: none - BC is undisturbed - so is A in the case of channel P. Called from: 0FA9 ED EDIT 361F str$ 365F R I STORE Exit from: 1610 CHAN OP 1 (1601 CHAN OPEN) CHAN K 1634 (1615 CHAN FLAG) Jumps from: 162D channel code look-up table channel address, channel area, channel code see channels andstreams channel code look-up table see tables channel data see channels and streams channel flags see 1615 CHAN FLAG channel information, channel information area see channels and streams channel K One of the four standard channels whose data are in the initial channel information table at 15AF, copied to the channelarea on start-up in 1219 RAM SET. Takes input from the keyboard (10AB KEY INPUT) and outputs to the screen (09F4 PRINT OUT); TV FLAG bit zero is set by 1634 CHAN K, so this means the lower screen. It is indexed by three of the "reserved" streams, FDh/ minus 3, zero and 01; the minus stream cannot be used from BASIC, the other two can, but stream zero is set again for channel K every time a report is printed at 1313 MAIN G. Opened with stream FD: 0970 SA CONTRL opened to print message 0C88 PO SCR 2 opened to print "scroll?" 0D94 CL CHAN opened after CLS Opened with stream zero: 0C55 PO SCR opened to test for scroll 106E ED LIST opened after listing 12AC MAIN 2 opened for EDITOR Opened with stream 01: 2089 INPUT opened for INPUT Rems: 107F ED ERROR skipped if not open 1615 CHAN FLAG flag reset for all but K 1634 CHAN K flag set 1701 CLOSE 2 can be CLOSEd 1736 OPEN channel code must be K, S or P 213A IN VAR 1 if using, change error pointer 2161 IN VAR 4 jump if not using 21D6 IN CHAN K sets Z flag if open CHANNEL K FLAG SUBROUTINE see 1634 CHAN K in 1615 CHAN FLAG channel P One of the four standard channels whose data are in the initial channel information table at 15AF, copied to the channelarea on start-up by 1219 RAM SET. The channel for the ZX printer. The input routine is 15C4 REPORT J, ie no input. Output to 09F4 PRINT OUT; FLAGS bit 1 is set by 164D CHAN P, so output goes to the ZX printer. It is indexed by the "reserved" stream 03. Opened by the ROM only at 1FC9 LPRINT, but can be openedfrom BASIC or m/c with stream 3, or indexed with streams 4 -> 15d. CHANNEL P FLAG SUBROUTINE see 164D CHAN P in 1615 CHAN FLAG channel R One of the four standard channels whose data are in the initial channel information table at 15AF, copied to the channelarea on start-up by 1219 RAM SET. The channel for output to the editing area or work space. The input routine is 15C4 REPORT J, ie no input. Output is to 0F81 ADD CHAR, which adds the output character to the address in 5C5B K CUR, the cursor position either in the line being edited in the editing area or the input line in the work space; as it doesn't output to screen or printer, the usual flagand colour settings aren't needed, and it isn't handled by 1615 CHAN FLAG. It is indexed by the "reserved" stream FFh/minus one.