===================================== 64#4 - 4x8 FONT DRIVER FOR 64 COLUMNS ===================================== Routine to print text in 64 columns with 4x8 characters for the ZX-Spectrum, that can be accessed from Sinclair BASIC using PRINT #4. ===== USAGE ===== To create the channel and attach it to stream #4, load the code from tape and execute it only once, as follows: CLEAR 64867: LOAD ""CODE : RANDOMIZE USR 64868 Afterwards, you can use PRINT #4 to print text in 64 columns: PRINT #4;AT 4,7;"4x8 FONT DRIVER"'"by Andrew, Crisis, and Einar" FOR f=32 TO 127: PRINT #4;CHR$ f;: NEXT f This channel supports regular ASCII characters (from 32 to 127), AT control codes, and you can also use apostrophe as carriage return. ============ TECH DETAILS ============ * To choose another address, just change the ORG statement and re-assemble the code. * To choose another channel number, just change the value of symbol STR_NUM and recompile the code. * To use this stream directly in assembly, execute the code (only once) to create the stream, then simply open channel #4 and use RST 10 as usual, for instance: call 64874 ; create channel ... ld a, 0x04 call 0x1601 ; open channel #4 ... ld hl, STRING LOOP: ld a, (hl) or a ret z rst 0x10 ; print register A inc hl jr LOOP ret STRING: defb '4x8 Font Driver', 0x00 * To also include your own custom 4x8 characters, just add their definitions at the end of the 4x8 font table (7 bytes for each pair). In this case, it's better to re-assemble the code at another address so the additional characters won't overlap the UDG area. Afterwards, use them as usual: FOR f=32 TO 255: PRINT #4;CHR$ f;: NEXT f ======================= OPTIONAL COMMA OPERATOR ======================= The "comma operator" is disabled by default. When enabled, it can be used to move the cursor to next column multiple of 16, as follows: PRINT #4;AT 5,9;"ENTIRE";AT 5,3;"HELLO","WORLD!" It has 2 possible implementations: * Option 1 works as "fast comma", jumping directly to target column. Thus the example above will produce this result: HELLO ENTIRE WORLD! * Option 2 works as "standard comma", erasing characters along the way. Thus the example above will produce this result: HELLO WORLD! To enable the "comma operator", uncomment the chosen option in the source code, change the compile address accordingly (so the enlarged code won't overlap the UDG area) and recompile it. ========================= OPTIONAL INVERSE OPERATOR ========================= The "inverse operator" is also disabled by default. When enabled, each character can be printed as inversed. It has 2 possible implementations: * Option 1 works as "standard inverse", using "INVERSE 1" to activate inverse mode, and "INVERSE 0" to deactivate. This is the easiest method for BASIC programming. The only drawback is that channel #4 does not automatically deactivate it, since it cannot detect that the PRINT statement has finished. Thus you have to explicitly disable it yourself afterwards, as follows: PRINT #4; INVERSE 1;AT 7,1;"Hello World!"; INVERSE 0 * Option 2 works as "ZX81 inverse" since it's similar to the ZX81 character set where the highest bit in each character indicates if it's inversed. This is the easiest method for Assembly programming but it also works in BASIC, just add 128 to the character value to obtain its inverse. For instance: FOR f=32 to 127: PRINT #4; CHR$ (f+128);: NEXT f ===== FONTS ===== The same routine is available on tape using different fonts: "64#4 Owen" - Uses default font designed by Andrew Owen. "64#4 Minix" - Uses font "Minix" designed by Einar Saukas. "64#4 n-Bot" - Uses font "NanoBot" designed by Einar Saukas. "64#4 Omni1" - Uses font "Omni 1" designed by Einar Saukas. "64#4 Omni2" - Uses font "Omni 2" designed by Einar Saukas. ======= LICENSE ======= You can freely use this tool and/or these fonts in your programs, or adapt this code and/or fonts according to your needs, the only requirement is that you must clearly indicate that you are using this material, or alternatively provide the following link in your documentation: http://www.worldofspectrum.org/infoseekid.cgi?id=0027130 The condition above also applies to any derivative work based on this material, thus you are still required to credit "64#4" even if you are only using it indirectly, such as including in your program the library from Boriel ZX BASIC Compiler (that is based on this). ======= CREDITS ======= Original implementation (657 bytes) by Andrew Owen. Reduced 4x7 font storage (602 bytes) by Chris 'Crisis' Born. Optimized reimplementation (494 bytes) and documentation by Einar Saukas. Interface 1 compatibility fix (500 bytes) by J.G.Harston. Stream initialization based on code by Ian Beardsmore from Your Spectrum issue 7, September 1984. Channel wrapper based on code by Tony Samuels from Your Spectrum issue 20, November 1985. Further information available at the following thread: http://www.worldofspectrum.org/forums/showthread.php?t=14526