/* tms9918.h 9/11/2012 dwg - information from TI Docs */ /* http://www1.cs.columbia.edu/~sedwards/papers/TMS9918.pdf */ /* To DO: fIX UPPER CASE T */ /* TMS9918 Modes: Graphics I Grtaphics Mode I provides 256x192 pixel display for generating pattern graphics in 15 colors plus transparent. Graphics II Graphics mode II is an enhancement of Graphics Mode I, allowing it to generate more complex color and pattern displays. Multicolor The Muylticolor mode provides an unrestricted 64x48 color-dot display employing 15 colors plus transparent. Text Mode The Text Mode provides twenty-four 40-character in two colors and is intended to maximize the capacity of the TV screen to display alphanumeric characters. (24 lines of forty blocks (each 8x8). */ /* #define DEBUG */ #define WIDTH 37 #define HEIGHT 24 #define GUTTER 3 #define BASE 128 #define DATAP (BASE+24) #define CMDP (BASE+25) #define WO_R0 #define WOR0B6 #define VDP_TRANSPARENT 0 #define VDP_BLACK 1 #define VDP_MED_GREEN 2 #define VDP_LGREEN 3 #define VDP_DBLUE 4 #define VDP_LBLUE 5 #define VDP_DRED 6 #define VDP_CYAN 7 #define VDP_MRED 8 #define VDP_LRED 9 #define VDP_DYELLOW 10 #define VDP_LYELLOW 11 #define VDP_DGREEN 12 #define VDP_MAGENTA 13 #define VDP_GRAY 14 #define VDP_WHITE 15 #define SINGLE 11 #define TRIPLE 0 char style; /* can be SINGLE or TRIPPLE */ unsigned char vdp_regen[24*40]; unsigned char charset[256*8] = { /* 10000 */ 0,0,0,0,0,0,0,0, /* 10001 */ 0,0,0,60,60,48,48,48, /* 10002 */ 0,0,0,240,240,48,48,48, /* 10003 */ 48,48,48,60,60,0,0,0, /* 10004 */ 48,48,48,240,240,0,0,0, /* 10005 */ 48,48,48,48,48,48,48,48, /* 10006 */ 0,0,0,255,255,0,0,0, /* 10007 */ 0,32,112,248,112,32,0,0, /* 10008 */ 248,216,136,0,136,216,248,0, /* 10009 */ 0,0,0,0,0,0,0,0, /* 10010 */ 0,0,0,0,0,0,0,0, /* 10011 */ 24,24,32,96,144,96,0,0, /* 10012 */ 32,80,32,32,112,32,0,0, /* 10013 */ 0,0,0,0,0,0,0,0, /* 10014 */ 0,0,0,0,0,0,0,0, /* 10015 */ 168,80,80,216,80,80,168,0, /* 10016 */ 48,48,48,252,252,48,48,48, /* 10017 */ 16,48,112,240,112,48,16,0, /* 10018 */ 32,112,32,32,32,112,32,0, /* 10019 */ 80,80,80,80,0,80,0,0, /* 10020 */ 120,168,168,104,40,40,0,0, /* 10021 */ 48,48,48,252,252,0,0,0, /* 10022 */ 0,0,0,252,252,48,48,48, /* 10023 */ 48,48,48,240,240,48,48,48, /* 10024 */ 32,112,32,32,32,32,32,32, /* 10025 */ 48,48,48,60,60,48,48,48, /* 10026 */ 0,16,24,252,24,16,0,0, /* 10027 */ 0,32,96,252,96,32,0,0, /* 10028 */ 0,0,0,0,0,0,0,0, /* 10029 */ 0,0,0,0,0,0,0,0, /* 10030 */ 0,0,0,0,0,0,0,0, /* 10031 */ 0,0,0,0,0,0,0,0, /* 10032 */ 0,0,0,0,0,0,0,0, /* 10033 */ 48,120,120,48,0,48,0,0, /* 10034 */ 216,216,80,0,0,0,0,0, /* 10035 */ 72,72,252,72,72,252,72,72, /* 10036 */ 32,120,160,120,36,248,32,0, /* 10037 */ 0,200,208,32,88,152,0,0, /* 10038 */ 48,72,72,80,96,144,120,0, /* 10039 */ 48,48,64,0,0,0,0,0, /* 10040 */ 16,32,32,32,32,32,16,0, /* 10041 */ 32,16,16,16,16,16,32,0, /* 10042 */ 32,168,112,248,112,168,32,0, /* 10043 */ 0,32,32,248,32,32,0,0, /* 10044 */ 0,0,0,0,0,48,48,64, /* 10045 0,0,0,252,0,0,0,0, */ /* 10045 */ 0,0,0,112,0,0,0,0, /* 10046 */ 0,0,0,0,0,48,48,0, /* 10047 */ 4,8,16,32,64,128,0,0, /* 10048 */ 112,152,168,168,168,200,112,0, /* 10049 */ 32,96,32,32,32,32,248,0, /* 10050 32,80,16,32,64,128,248,0, */ /* 10050 */ 112,136,8,16,96,128,248,0, /* 10051 */ 112,136,8,112,8,136,112,0, /* 10052 */ 48,80,144,248,16,16,16,0, /* 10053 */ 248,128,128,240,8,136,112,0, /* 10054 */ 56,64,128,240,136,136,112,0, /* 10055 */ 248,8,16,32,32,32,32,0, /* 10056 */ 112,136,136,112,136,136,112,0, /* 10057 */ 112,136,136,120,8,136,112,0, /* 10058 */ 0,48,48,0,48,48,0,0, /* 10059 */ 0,48,48,0,48,48,96,0, /* 10060 */ 16,32,64,128,64,32,16,0, /* 10061 */ 0,0,252,0,252,0,0,0, /* 10062 */ 64,32,16,8,16,32,64,0, /* 10063 */ 112,136,8,48,32,0,32,0, /* 10064 */ 112,136,184,176,128,128,112,0, /* 10065 */ 32,80,136,248,136,136,136,0, /* 10066 */ 240,72,72,112,72,72,240,0, /* 10067 */ 112,136,128,128,128,136,112,0, /* 10068 */ 240,72,72,72,72,72,240,0, /* 10069 */ 248,136,128,224,128,136,248,0, /* 10070 */ 248,136,128,240,128,128,128,0, /* 10071 */ 112,136,128,184,136,136,112,0, /* 10072 */ 136,136,136,248,136,136,136,0, /* 10073 */ 248,32,32,32,32,32,248,0, /* 10074 */ 28,8,8,8,8,136,112,0, /* 10075 */ 136,144,160,192,160,144,136,0, /* 10076 */ 128,128,128,128,128,136,248,0, /* 10077 */ 136,216,168,136,136,136,136,0, /* 10078 */ 136,200,168,168,168,152,136,0, /* 10079 */ 112,136,136,136,136,136,112,0, /* 10080 */ 240,136,136,240,128,128,128,0, /* 10081 */ 112,136,136,136,168,152,120,4, /* 10082 */ 240,136,136,240,160,144,136,0, /* 10083 */ 112,136,64,32,16,136,112,0, /* 10084 */ 248,32,32,32,32,32,112-64-16,0, /* 10085 */ 136,136,136,136,136,136,112,0, /* 10086 */ 136,136,136,80,80,80,32,0, /* 10087 */ 136,136,136,168,168,168,80,0, /* 10088 */ 136,136,80,32,80,136,136,0, /* 10089 */ 136,136,80,32,32,32,32,0, /* 10090 */ 248,136,16,32,64,136,248,0, /* 10091 */ 120,64,64,64,64,64,120,0, /* 10092 */ 0,128,64,32,16,8,0,0, /* 10093 */ 120,8,8,8,8,8,120,0, /* 10094 */ 32,80,136,0,0,0,0,0, /* 10095 */ 0,0,0,0,0,0,252,0, /* 10096 */ 96,96,16,0,0,0,0,0, /* 10097 */ 0,0,240,8,120,136,112,0, /* 10098 */ 128,128,128,240,136,136,240,0, /* 10099 */ 0,0,0,112,128,128,112,0, /* 10100 */ 8,8,8,120,136,136,120,0, /* 10101 */ 0,0,112,136,248,128,112,0, /* 10102 */ 0,48,72,224,64,64,64,0, /* 10103 */ 0,0,56,72,72,56,8,112, /* 10104 */ 0,128,128,176,200,136,136,0, /* 10105 */ 0,0,32,0,96,32,112,0, /* 10106 */ 0,8,0,24,8,8,72,48, /* 10107 */ 128,128,144,160,192,160,144,0, /* 10108 */ 32,32,32,32,32,32,32,0, /* 10109 */ 0,0,0,80,168,168,136,0, /* 10110 */ 0,0,0,176,200,136,136,0, /* 10111 */ 0,0,0,112,136,136,112,0, /* 10112 */ 0,0,112,72,72,112,64,64, /* 10113 */ 0,96,56,72,72,56,8,8, /* 10114 */ 0,0,0,176,200,128,128,0, /* 10115 */ 0,0,96,128,96,16,96,0, /* 10116 */ 0,0,64,224,64,64,32,0, /* 10117 */ 0,0,0,144,144,144,104,0, /* 10118 */ 0,0,0,136,136,80,32,0, /* 10119 */ 0,0,0,136,168,168,80,0, /* 10120 */ 0,0,0,72,48,48,72,0, /* 10121 */ 0,0,136,80,32,64,128,0, /* 10122 */ 0,0,248,16,32,64,248,0, /* 10123 */ 16,32,32,64,32,32,16,0, /* 10124 */ 32,32,32,0,32,32,32,0, /* 10125 */ 64,32,32,16,32,32,64,0, /* 10126 */ 108,144,0,0,0,0,0,0, /* 10127 */ 112,80,80,80,80,80,112,0, /****************************************************************/ /* These are Douglas Goodall's personal tri-plex semi graphics */ /* 10128 */ 252,128,188,160,172,168,168,168, /* upper left */ /* 10129 */ 252,0,252,0,252,0,0,0, /* top horz */ /* 10130 */ 252,4,244,20,212,84,84,84, /* upper right */ /* 10131 */ 84,84,84,84,84,84,84,84, /* right vert */ /* 10132 */ 84,84,84,212,20,244,4,252, /* lower right */ /* 10133 */ 0,0,0,255,0,255,0,255, /* bottom horz */ /* 10134 */ 168,168,168,172,160,188,128,252, /* lower left */ /* 10135 */ 168,168,168,168,168,168,168,168, /* left vert */ /* 10136 */ 168,168,172,160,172,168,168,168, /* left joint */ /* 10137 */ 84,84,212,20,212,84,84,84, /* right joint */ /* 10138 */ 0,0,252,0,252,0,0,0, /* inner horz */ /****************************************************************/ /****************************************************************/ /* These are Douglas Goodall's personal uni-plex semi graphics */ /* 10139 */ 252,128,128,128,128,128,128,128, /* upper left */ /* 10140 */ 252,0,0,0,0,0,0,0, /* top horz */ /* 10141 */ 252,4,4,4,4,4,4,4, /* upper right */ /* 10142 */ 4,4,4,4,4,4,4,4, /* right vert */ /* 10143 */ 4,4,4,4,4,4,4,252, /* lower right */ /* 10144 */ 0,0,0,0,0,0,0,252, /* bottom horz */ /* 10145 */ 128,128,128,128,128,128,128,252, /* lower left */ /* 10146 */ 128,128,128,128,128,128,128,128, /* left vert */ /* 10147 */ 128,128,128,252,128,128,128,128, /* left joint */ /* 10148 */ 4,4,4,252,4,4,4,4, /* right joint */ /* 10149 */ 0,0,0,252,0,0,0,0, /* inner horz */ /****************************************************************/ /* 10150 */ 0,0,0,0,0,0,0,0, /* 10151 */ 0,0,0,0,0,0,0,0, /* 10152 */ 0,0,0,0,0,0,0,0, /* 10153 */ 0,0,0,0,0,0,0,0, /* 10154 */ 0,0,0,0,0,0,0,0, /* 10155 */ 0,0,0,0,0,0,0,0, /* 10156 */ 0,0,0,0,0,0,0,0, /* 10157 */ 0,0,0,0,0,0,0,0, /* 10158 */ 0,0,0,0,0,0,0,0, /* 10159 */ 0,0,0,0,0,0,0,0, /* 10160 */ 32,64,240,8,120,136,112,0, /* 10161 */ 16,32,0,96,32,32,248,0, /* 10162 */ 16,32,0,112,136,136,112,0, /* 10163 */ 16,32,0,136,136,136,116,0, /* 10164 */ 16,32,0,176,200,136,136,0, /* 10165 */ 16,32,0,200,168,152,136,0, /* 10166 */ 112,136,136,124,0,252,0,0, /* 10167 */ 112,136,136,112,0,252,0,0, /* 10168 */ 32,0,32,32,64,136,112,0, /* 10169 */ 0,0,0,0,252,128,128,128, /* 10170 */ 0,0,0,0,252,4,4,4, /* 10171 */ 136,144,168,84,136,28,0,0, /* 10172 */ 136,144,168,88,184,8,0,0, /* 10173 */ 48,0,48,120,120,48,0,0, /* 10174 */ 20,40,80,160,80,40,20,0, /* 10175 */ 160,80,40,20,40,80,160,0, /* 10176 */ 84,170,84,170,84,170,84,170, /* 10177 */ 170,84,170,84,170,84,170,84, /* 10178 */ 182,108,218,182,108,218,182,108, /* 10179 */ 24,24,24,24,24,24,24,24, /* 10180 */ 24,24,24,24,248,24,24,24, /* 10181 */ 24,24,24,248,24,248,24,24, /* 10182 */ 108,108,108,108,236,108,108,108, /* 10183 */ 0,0,0,0,252,108,108,108, /* 10184 */ 0,0,0,252,108,236,108,108, /* 10185 */ 108,108,236,12,236,108,108,108, /* 10186 */ 108,108,108,108,108,108,108,108, /* 10187 */ 0,0,252,14,238,108,108,108, /* 10188 */ 108,108,236,12,252,0,0,0, /* 10189 */ 100,100,252,0,0,0,0,0, /* 10190 */ 48,48,240,48,48,240,0,0, /* 10191 */ 0,0,0,0,240,48,48,48, /* 10192 */ 48,48,48,48,60,0,0,0, /* 10193 */ 48,48,48,48,252,0,0,0, /* 10194 */ 0,0,0,0,252,48,48,48, /* 10195 */ 48,48,48,48,60,48,48,48, /* 10196 */ 0,0,0,0,252,0,0,0, /* 10197 */ 48,48,48,48,252,48,48,48, /* 10198 */ 48,48,60,48,60,48,48,48, /* 10199 */ 216,216,220,216,216,216,216,216, /* 10200 */ 216,216,216,220,192,252,0,0, /* 10201 */ 0,0,0,252,192,220,216,216, /* 10202 */ 216,216,216,220,192,0,252,0, /* 10203 */ 0,0,0,0,0,0,252,0, /* 10204 */ 216,216,216,220,192,220,216,216, /* 10205 */ 0,0,0,252,0,252,0,0, /* 10206 */ 216,216,216,220,0,220,216,216, /* 10207 */ 48,48,48,252,0,0,252,0, /* 10208 */ 216,216,216,252,0,0,0,0, /* 10209 */ 0,0,252,0,0,252,48,48, /* 10210 */ 0,0,0,0,0,252,216,216, /* 10211 */ 216,216,216,252,0,0,0,0, /* 10212 */ 48,48,48,60,48,48,60,0, /* 10213 */ 0,0,0,62,48,62,48,48, /* 10214 */ 0,0,0,0,0,252,216,216, /* 10215 */ 216,216,216,216,220,216,216,216, /* 10216 */ 48,48,252,0,0,252,48,48, /* 10217 */ 48,48,48,240,0,0,0,0, /* 10218 */ 0,0,0,60,48,48,48,48, /* 10219 */ 252,252,252,252,252,252,252,252, /* 10220 */ 0,0,0,252,252,252,192,192, /* 10221 */ 192,192,192,192,192,192,192,192, /* 10222 */ 12,12,12,12,12,12,12,12, /* 10223 */ 12,12,12,12,252,252,252,0, /* 10224 */ 0,0,0,104,144,144,104,0, /* 10225 */ 112,136,136,176,136,136,240,64, /* 10226 */ 240,144,128,128,128,128,128,0, /* 10227 */ 248,80,80,80,80,72,0,0, /* 10228 */ 248,136,64,32,64,136,248,0, /* 10229 */ 0,0,0,124,136,136,112,0, /* 10230 */ 0,0,0,136,136,136,112,128, /* 10231 */ 0,0,116,152,16,16,28,0, /* 10232 */ 252,16,56,68,56,16,252,0, /* 10233 */ 48,204,204,252,204,204,56,0, /* 10234 */ 120,132,132,132,72,72,132,0, /* 10235 */ 60,64,56,68,68,68,56,0, /* 10236 */ 0,0,108,146,146,108,0,0, /* 10237 */ 0,0,0,56,88,104,112,0, /* 10238 */ 56,64,128,248,128,64,56,0, /* 10239 */ 0,0,48,204,204,204,204,0, /* 10240 */ 252,0,0,252,0,0,252,0, /* 10241 */ 16,16,124,16,16,0,254,0, /* 10242 */ 32,16,8,16,32,0,254,0, /* 10243 */ 16,32,64,32,16,0,254,0, /* 10244 */ 24,52,48,48,48,48,48,48, /* 10245 */ 48,48,48,48,48,48,176,112, /* 10246 */ 48,48,0,252,0,48,48,0, /* 10247 */ 0,100,152,0,100,152,0,0, /* 10248 */ 56,68,68,56,0,0,0,0, /* 10249 */ 0,56,56,0,0,0,0,0, /* 10250 */ 0,0,56,0,0,0,0,0, /* 10251 */ 14,8,8,72,40,24,8,0, /* 10252 */ 0,0,0,176,72,72,72,0, /* 10253 */ 0,0,240,60,64,128,248,0, /* 10254 */ 252,252,252,252,252,252,252,252, /* 10255 */ 0,0,0,0,0,0,0,0 }; vdp_read() { char c,v; for(c=0;c<17;c++) { v = in(DATAP); printf("0x2x ",v); } } vdp_display(line,column,string) int line; int column; char * string; { char index; vdp_write_ram(GUTTER+(line*40)+column); for(index=0;indexstrlen(string)) { for(index=strlen(string);index<40;index++) { out(DATAP,' '); } } } vdp_hz_join(line) int line; { char i; char szTemp[2]; sprintf(szTemp,"%c",0x8a+style); for(i=1;i> 8) | 0x40; out(CMDP,byte1); out(CMDP,byte2); } /* eof - tms9918.h */