TEXT MISER by Ray Elder from ZX Computing January 1987 Ray Elder presents a program for efficient text storage. Although the program as printed is nothing special, the end product will save a minimum of 15 bytes per message on a 100 location adventure - this becomes 1500+ bytes! In simple terms the program takes a text and/or graphics input and stores it sequentially as bytes. The short 36 byte machine code routine then prints out the text as required. The routine and code is completely relocatable and options to view the text before storage, re-entering it, and viewing all the stored text are included. The main disadvantage is that editing of stored text is not possible (at the moment) so it is wise to plan the entries before using the program. Once you have entered the program, the machine code is built in - make sure the DATA line is accurate, just run it and follow the prompts. If you just press ENTER for the x,y co-ordinates and the INK and PAPER colours, the program defaults to PRINT AT 0,0; INK 0; PAPER 7. At any time you can leave the text entering routine and view what you have stored so far, going back from the option page if you require to add more. Details of the number of entries made and the length of the file are also given so you can keep an eye on how much space you have left. The program starts at 40000 but this can be lowered if you wish. From the option menu you can save the code to tape; it saves as "text" CODE 40000, length. Using the text The stored text can be used from either machine code programs or from BASIC. First it should be loaded to the required address, for example to load it to 50000 first CLEAR address-2 (49998) then LOAD "" CODE 50000. Obviously the address+length (as given on the option page) must not exceed 65535. The reason for clearing two below the address is that the program uses the address-1 location to get the text item number. For BASIC the most economical way is to set up a variable for the call address, eg. LET z=50000, and to print the required message POKE the item number into z-1. So to print the fifth message you would use POKE z-1,5: RANDOMIZE USR z. As you may have gathered it is very useful to keep a list of your messages; menu option 1 is useful for this. From machine code, stack the values of AF, BC, DE and HL if you want to preserve them, load BC with the routine's address - LD BC 50000 - POKE the message number to the address-1 and CALL the address. Advantages Apart from being an economical way of storing text, it has the advantage that the text cannot be read by listing the basic program. The technique of setting up such a text "table" is one which has been used extensively before the advent of good old inefficient BASIC where DIMming a string often means most of the string is wasted spaces. Each message takes up only the length of that message plus eight bytes, the format of the stored message is: 1 byte, total length of entry 1 byte, paper token character 1 byte, paper colour 1 byte, ink token character 1 byte, ink colour 1 byte, AT token character 1 byte, Y co-ordinate 1 byte, X co-ordinate n bytes, the characters of the message Machine code routine 9C40 0000 ORG 40000 9C40 213200 0005 LD HL,50 9C43 09 0010 ADD HL,BC 9C44 0B 0015 DEC BC 9C45 0A 0020 LD A,(BC) 9C46 3D 0025 DEC A 9C47 FE00 0030 CP 0 9C49 2808 0035 JR Z,PRINT 9C4B 47 0040 LD B,A 9C4C 1600 0045 LD D,0 9C4E 7E 0050 LOOP LD A,(HL) 9C4F 5F 0055 LD E,A 9C50 19 0060 ADD HL,DE 9C51 10FB 0065 DJNZ LOOP 9C53 E5 0070 PRINT PUSH HL 9C54 3E02 0075 LD A,2 9C56 CD0116 0080 CALL 1601H 9C59 E1 0085 POP HL 9C5A 0600 0090 LD B,0 9C5C 4E 0095 LD C,(HL) 9C5D 0D 0100 DEC C 9C5E 23 0105 INC HL 9C5F EB 0110 EX DE,HL 9C60 CD3C20 0115 CALL 203CH 9C63 C9 0120 RET 0125 END PRINT 9C53 LOOP 9C4E # 5E3E -- Another Fine Product transcribed by: Jim Grimwood, Weardale, England (http://www.users.globalnet.co.uk/~jimg/) --