GRAPHIC TECH NOTES AND BACK TO SOME BASICS by Jim Hehl The structure of a graphic file (TED), suitable for use with the Plus/4 is as follows: Luminance Information 6144-7143 ($1800-$1BE7) Free bytes 7144-7167 ($1BE8-$1BFF) Color Memory 7168-8167 ($1C00-$1FE7) Free bytes 8168-8191 ($1FE8-$1FFF) Bitmap 8192-16191 ($2000-$3F3F) Free bytes 16192-16383 ($3F40-$3FFF) Generally, for a standard 41 block TED file, the entire chunk of memory from 6144 to 16383 is used as the file. This allows room for additional information to be included in the graphic file, as follows. For those of you that will want to putter with programming, you'll be interested in the following. These files have all of the information for the border, background and foreground colors. The are stored in the following locations: color value for $FF19 in $1BFD and $1FFD color value for $FF16 in $1BFE and $1FFE color value for $FF15 in $1BFF and $1FFF In addition, the indicators, for the type of graphic, is in there: Hires and Hires Godot: $1BFA and $1FFB contains $00 $1BFB and $1FFB contains $00 Hires TED: $1BFA and $1FFA any value (except $4D, but usually "T") $1BFB and $1FFB contains $00 Multicolor TED: $1BFA and $1FFA contains $4D (the letter "M") $1BFB and $1FFB contains $00 Multicolor Godot $1BFA and $1FFA contains $4D (the letter "M") $1BFB and $1FFB contains $55 (the letter "U") Multicolor KO (converted Koala) $1BFA and $1FFA contains $4D (the letter "M") $1BFB and $1FFB contains $4b (the letter "K") To use the screen/foreground/border values, in your own programs: BASIC ML Background POKE65301,PEEK(7167) LDA $1BFD Extra color POKE65302,PEEK(7166) LDY $1BFE Border POKE65305,PEEK(7165) LDX $1BFF STA $FF19 STY $FF16 STX $FF15 The exception to the color location rules are with the Godot Hires/Multicolor files. They use a set of values that the ML (in this viewer/toolkit) identifies and transfers in a form, that actually "sets" certain bits in the proper color registers. For the most part, the method above of PEEK/POKE, will work well. If the colors aren't what you want, then just specify them: POKE65301,xx:POKE65302,xx:POKE65305,xxx Where the value of xx is: Black 0 Purple 68 Orange 72 Bl.Green 92 White 113 Green 53 Brown 41 Lt.Blue 109 Red 50 Blue 70 Yl.Green 90 Dk.Blue 46 Cyan 99 Yellow 119 Pink 107 Lt Green 95 The converted Koala (KO and CK) files use a different color/luminance table, because the C64 uses three shades of grey. The color values for these files: Black 0 Purple 68 Orange 56 Med.Grey 49 White 113 Green 69 Brown 9 Lt.Green 111 RED 50 Blue 22 Lt.Red 75 Lt.Blue 54 Cyan 67 Yellow 103 Dk.Grey 33 Lt.Grey 65 A simple way of displaying ANY Hires TED file on your Plus/4, is to use the simple BASIC program: 10 IFA=1THEN40 20 GRAPHIC1,1 sets Graphic mode and clears screen 30 A=1:LOAD"filename",8,1 loads the from within the program 40 GETA$:IFA$=""THEN40 waits for a key press 50 GRAPHIC0 returns to text screen mode For a Multicolor TED file: 10 IFA=1THEN40 20 GRAPHIC3,1 30 A=1:LOAD"filename",8,1 40 GETA$:IFA$=""THEN30 50 GRAPHIC0 Doodle and straight Bitmap files, like a white default background for the most part. If you are typing these short programs onto a clear screen, then it will be white. If your program has, say a black screen, then you should first change the screen to white: 10 IFA=1THEN50 20 COLOR1,2:REM SAME AS POKE65301,113 30 GRAPHIC1,1 40 A=1:LOAD"filename",8,1 50 GETA$:IFA$=""THEN50 60 GRAPHIC0 Finally, if you want to add the colors that are contained in the graphic files: 10 IFA=1THEN40 20 GRAPHIC1,1:REM GRAPHIC3,1 FOR MULTICOLOR MODE 30 A=1:LOAD"filename",8,1 40 POKE65301,PEEK(7167):REM BACKGROUND COLOR 50 POKE65302,PEEK(7166):REM EXTRA COLOR (UNNEEDED FOR HIRES) 60 POKE65305,PEEK(7165):REM BORDER COLOR 70 GETA$:IFA$=""THEN70 80 GRAPHIC0 COMPRESSED FILES (JJ, CM, CH, CK and CB) These files can't be LOADed directly into the RAM, of your Plus/4, and displayed, in their raw form. They will just fill the screen with garbage. The must be decompressed, first. It is a simple task to do this. On this disk is a file called: DECOM.TED(4608). This ML program will decompress any of the compressed TED files (CH, CM and CK), from your disk, into the proper area of RAM. The routine is fully relocatable to another address, if it conflicts with your own program designs. First, lets review what calling the GRAPHIC command does... along with various housekeeping tasks, associated with setting up the Graphics mode, it transfers the start of BASIC to 16385 ($4001), along with your program and all of the variables. This frees the old area of RAM, from 4096 to 16384, for the graphic file. That also leaves a chunk of memory from 4096 (the old beginning of BASIC) to 6144 (the beginning of the luminance information) for you to stash anything that you want, there. This is where we'll store the decompress ML. It will be LOADed into 4608($1200). We can then SYS to it, anytime that we want to display a compressed graphic. Be aware, though, that using the Reset button or the GRAPHICCLR command will lower the beginning of BASIC, back down to 4097, overwritting anything that we stash there. As long as we don't do that, our ML will be protected. However, holding down the Run/Stop key WHILE pressing the Reset button, to enter the Monitor, doesn't affect the beginning of BASIC. The proper syntax for using the decompress routine is: OPEN8,8,0,"filename":SYS4608:CLOSE8 The last part of the command: CLOSE8 isn't really necessary, but it is a good practice to get into. Since there is no disk error detection in this simple ML routine, it is worth typing the extra characters to insure that the file will be closed. To utilize this routine in our simple display program: 5 COLOR1,2 10 GRAPHIC1,1:REM GRAPHIC3,1 FOR MULTICOLOR 20 OPEN8,8,0,"filename":SYS4608:CLOSE8 30 POKE65301,PEEK(7167) 40 POKE65302,PEEK(7166) 50 POKE65305,PEEK(7165) 60 GETA$:IFA$=""THEN60 70 GRAPHIC0 This will properly decompress and display any 40/41 block compressed TED file (CM and CH). There are decompression routines for all of the compressed graphic files that you will find, for the Plus/4: DECOMP.TED(4608) - is for files residing at $1800 (CH, CM and CK) DECOMP.JJ(4608) - is for compressed Doodle files (JJ) DECOMP.CB(4608) - is for compressed Bitmap (CB at $2000) The syntax is the same and all of the routines are the same, except for an address byte, within the ML routine. You could utilize a single routine for ALL of the various compressed files, if you were to POKE the high byte of the LOAD address into the ML. Let's try this using the same COMP.TED(4608) routine: 5 COLOR1,2:COLOR4,1 10 GRAPHIC1,1 20 INPUT"FILENAME";N$ 30 IFLEFT$(N$,2)="JJ"THENPOKE4624,28:GOTO60 40 IFLEFT$(N$,2)="CB"THENPOKE4624,32:GOTO60 50 POKE4624,24 60 IFLEFT$(N$,2)="CK"THENGRAPHIC3 70 IFLEFT$(N$,2)="CM"THENGRAPHIC3 80 OPEN8,8,0,N$:SYS4608:CLOSE8 90 POKE65301,PEEK(7167) 100 POKE65302,PEEK(7166) 110 POKE65305,PEEK(7165) 120 GETA$:IFA$=""THEN90 130 GRAPHIC0 In line 5 we added COLOR4,1 which will default the border to black, for the compressed Bitmap (CB) file. The other types have the border color stored within the files and will change it to the proper value later. line 20 will allow you to input the name of the file that you want to LOAD, from the keyboard. Lines 30 and 40 check the left two characters, of the filename, to see if the file is a JJ or a CB file. The proper Load address is POKEd into the ML routine. If the filename doesn't begin with a JJ or CB, it falls through to line 50, which POKEs the proper value for the remainder of your compressed file types (CM, CH and CK). Lines 60 and 70 check for the prefix used for multicolor files and shifts the Plus/4 into Multicolor mode. If the prefix isn't for multicolor, the machine will remain in Hires mode. The rest of the program lines are the same as before. Graphic files with Loading addresses, other than 6144, can be used with your Plus/4. The TED chip can be made to look at other areas or RAM, for a bitmap. We'll not get into that at the present. The methods that we've covered are the easiest to understand and use. When working with graphics, understanding the basics... is MOST of the battle! By the way, in case you've forgotten, the standard (40/41 block) TED files will LOAD into your C128. Use the GRAPHIC command, in the same way that you would on the Plus/4. The colors may vary, but I think you'll get a kick out of it! The LOAD addresses of the Plus/4 TED files are the same as ones for the C128 Enjoy and experiment, folks!