src/mess/video/ef9345.c
| r0 | r8224 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | ef9345.c |
| 4 | |
| 5 | Thomson EF9345 video controller emulator code |
| 6 | |
| 7 | This code is based on Daniel Coulom's implementation in DCVG5k |
| 8 | and DCAlice released by Daniel Coulom under GPL license |
| 9 | |
| 10 | The implementation below is released under the MAME license for use |
| 11 | in MAME, MESS and derivatives by permission of the author. |
| 12 | |
| 13 | *********************************************************************/ |
| 14 | |
| 15 | #include "emu.h" |
| 16 | #include "ef9345.h" |
| 17 | |
| 18 | typedef struct _ef9345_t ef9345_t; |
| 19 | struct _ef9345_t |
| 20 | { |
| 21 | const ef9345_config *conf; |
| 22 | |
| 23 | UINT8 bf; //busy flag |
| 24 | UINT8 char_mode; //40 or 80 chars for line |
| 25 | UINT8* charset; //charset |
| 26 | UINT8 ram[0x4000]; //16Ko (logique) pour 8Ko (physique) |
| 27 | UINT8 acc_char[0x2000]; //8Ko (logique) polices accentuees |
| 28 | UINT8 registers[8]; //registers R0-R7 |
| 29 | UINT8 state; //status register |
| 30 | UINT8 TGS,MAT,PAT,DOR,ROR; //registres acces indirect |
| 31 | UINT8 border[80]; //caractere du cadre |
| 32 | UINT8 *block; //pointeur block courant |
| 33 | UINT8 *matrice; //pointeur matrice caractere courant |
| 34 | UINT8 *char_ptr[16]; //pointeurs polices de caracteres |
| 35 | UINT16 blink; //etat du clignotement |
| 36 | UINT8 dial; //cadran en cours d'affichage |
| 37 | UINT16 last_dial[40]; //dernier cadran affiche |
| 38 | UINT8 latchc0; //couleur c0 latchee |
| 39 | UINT16 latchm; //attribut m(conceal) latche |
| 40 | UINT16 latchi; //attribut i(insert) latche |
| 41 | UINT16 latchu; //attribut u(underline) latche |
| 42 | |
| 43 | bitmap_t *screen_out; |
| 44 | |
| 45 | emu_timer *busy_timer; |
| 46 | emu_timer *blink_timer; |
| 47 | |
| 48 | }; |
| 49 | |
| 50 | static TIMER_CALLBACK( ef9345_done ); |
| 51 | |
| 52 | |
| 53 | INLINE _ef9345_t *get_safe_token(running_device *device) |
| 54 | { |
| 55 | assert(device != NULL); |
| 56 | assert(device->token != NULL); |
| 57 | assert(device->type == EF9345); |
| 58 | return (_ef9345_t *)device->token; |
| 59 | } |
| 60 | |
| 61 | /*------------------------------------------------- |
| 62 | set busy flag and timer to clear it |
| 63 | -------------------------------------------------*/ |
| 64 | static void set_busy_flag(ef9345_t *ef9345, int period) |
| 65 | { |
| 66 | ef9345->bf = 1; |
| 67 | |
| 68 | timer_adjust_oneshot(ef9345->busy_timer, ATTOTIME_IN_USEC(period), 0); |
| 69 | } |
| 70 | |
| 71 | /*------------------------------------------------- |
| 72 | draw a char in 40 char line mode |
| 73 | -------------------------------------------------*/ |
| 74 | void draw_char_40(ef9345_t *ef9345, UINT8 *c, int x, int y) |
| 75 | { |
| 76 | UINT16 i, j; |
| 77 | |
| 78 | /* verify size limit */ |
| 79 | if (y * 10 >= ef9345->conf->height || x * 8 >= ef9345->conf->width) |
| 80 | return; |
| 81 | |
| 82 | for(i = 0; i < 10; i++) |
| 83 | for(j = 0; j < 8; j++) |
| 84 | *BITMAP_ADDR16(ef9345->screen_out, y * 10 + i, x * 8 + j) = c[8 * i + j] & 0x07; |
| 85 | } |
| 86 | |
| 87 | /*------------------------------------------------- |
| 88 | draw a char in 80 char line mode |
| 89 | -------------------------------------------------*/ |
| 90 | void draw_char_80(ef9345_t *ef9345, UINT8 *c, int x, int y) |
| 91 | { |
| 92 | int i, j; |
| 93 | |
| 94 | /* verify size limit */ |
| 95 | if (y * 10 >= ef9345->conf->height || x * 6 >= ef9345->conf->width) |
| 96 | return; |
| 97 | |
| 98 | for(i = 0; i < 10; i++) |
| 99 | for(j = 0; j < 6; j++) |
| 100 | *BITMAP_ADDR16(ef9345->screen_out, y * 10 + i, x * 6 + j) = c[6 * i + j] & 0x07; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | /*------------------------------------------------- |
| 105 | set then ef9345 mode |
| 106 | -------------------------------------------------*/ |
| 107 | void set_ef9345_mode(ef9345_t *ef9345) |
| 108 | { |
| 109 | UINT8 i; |
| 110 | ef9345->char_mode = ((ef9345->PAT & 0x80) >> 5) | ((ef9345->TGS & 0xc0) >> 6); |
| 111 | |
| 112 | //couleur de bordure |
| 113 | for(i = 0; i < 80; i++) |
| 114 | ef9345->border[i] = ef9345->MAT & 0x07; |
| 115 | |
| 116 | //polices (avec ram 8K) |
| 117 | ef9345->char_ptr[0x08] = ef9345->ram + ((ef9345->DOR & 0x07) << 11); //G'0 |
| 118 | ef9345->char_ptr[0x09] = ef9345->char_ptr[0x08]; //G'0 underlined |
| 119 | ef9345->char_ptr[0x0a] = ef9345->ram + ((ef9345->DOR & 0x30) << 8); //G'10 |
| 120 | ef9345->char_ptr[0x0b] = ef9345->char_ptr[0x0a] + 0x800; //G'11 |
| 121 | ef9345->char_ptr[0x0c] = ef9345->ram; //Quadrichrome |
| 122 | ef9345->char_ptr[0x0d] = ef9345->char_ptr[0x0c]; |
| 123 | ef9345->char_ptr[0x0e] = ef9345->char_ptr[0x0c]; |
| 124 | ef9345->char_ptr[0x0f] = ef9345->char_ptr[0x0c]; |
| 125 | |
| 126 | //adresse block memoire courant |
| 127 | i = ((ef9345->ROR & 0xf0) >> 4) | ((ef9345->ROR & 0x40) >> 5) | ((ef9345->ROR & 0x20) >> 3); |
| 128 | ef9345->block = ef9345->ram + 0x800 * (i & 0x0c); |
| 129 | } |
| 130 | |
| 131 | /*------------------------------------------------- |
| 132 | Initialize the ef9345 char_ptr |
| 133 | -------------------------------------------------*/ |
| 134 | void init_char_prt(ef9345_t *ef9345) |
| 135 | { |
| 136 | int i, j; |
| 137 | //polices accentuees |
| 138 | for(j = 0; j < 0x10; j++) |
| 139 | for(i = 0; i < 0x200; i++) |
| 140 | ef9345->acc_char[(j << 9) + i] = ef9345->charset[0x0600 + i]; |
| 141 | |
| 142 | for(j = 0; j < 0x200; j += 0x40) |
| 143 | for(i = 0; i < 4; i++) |
| 144 | { |
| 145 | ef9345->acc_char[0x0200 + j + i + 4] |= 0x1c; //tilde |
| 146 | ef9345->acc_char[0x0400 + j + i + 4] |= 0x10; //aigu |
| 147 | ef9345->acc_char[0x0400 + j + i + 8] |= 0x08; //aigu |
| 148 | ef9345->acc_char[0x0600 + j + i + 4] |= 0x04; //grave |
| 149 | ef9345->acc_char[0x0600 + j + i + 8] |= 0x08; //grave |
| 150 | |
| 151 | ef9345->acc_char[0x0a00 + j + i + 4] |= 0x1c; //tilde |
| 152 | ef9345->acc_char[0x0c00 + j + i + 4] |= 0x10; //aigu |
| 153 | ef9345->acc_char[0x0c00 + j + i + 8] |= 0x08; //aigu |
| 154 | ef9345->acc_char[0x0e00 + j + i + 4] |= 0x04; //grave |
| 155 | ef9345->acc_char[0x0e00 + j + i + 8] |= 0x08; //grave |
| 156 | |
| 157 | ef9345->acc_char[0x1200 + j + i + 4] |= 0x08; //point |
| 158 | ef9345->acc_char[0x1400 + j + i + 4] |= 0x14; //trema |
| 159 | ef9345->acc_char[0x1600 + j + i + 32] |= 0x08; //cedille |
| 160 | ef9345->acc_char[0x1600 + j + i + 36] |= 0x04; //cedille |
| 161 | |
| 162 | ef9345->acc_char[0x1a00 + j + i + 4] |= 0x08; //point |
| 163 | ef9345->acc_char[0x1c00 + j + i + 4] |= 0x14; //trema |
| 164 | ef9345->acc_char[0x1e00 + j + i + 32] |= 0x08; //cedille |
| 165 | ef9345->acc_char[0x1e00 + j + i + 36] |= 0x04; //cedille |
| 166 | } |
| 167 | |
| 168 | //initialisation des pointeurs de polices fixes |
| 169 | ef9345->char_ptr[0x00] = ef9345->charset; //G0 |
| 170 | ef9345->char_ptr[0x01] = ef9345->charset + 0x0800; //G0 underlined |
| 171 | ef9345->char_ptr[0x02] = ef9345->charset + 0x1000; //G11 |
| 172 | ef9345->char_ptr[0x03] = ef9345->charset + 0x1800; //G10 |
| 173 | ef9345->char_ptr[0x04] = ef9345->acc_char; //G20 |
| 174 | ef9345->char_ptr[0x05] = ef9345->acc_char + 0x0800; //G20 underlined |
| 175 | ef9345->char_ptr[0x06] = ef9345->acc_char + 0x1000; //G21 |
| 176 | ef9345->char_ptr[0x07] = ef9345->acc_char + 0x1800; //G21 underlined |
| 177 | } |
| 178 | |
| 179 | |
| 180 | /* calculate the internal RAM offset */ |
| 181 | UINT16 indexram(ef9345_t *ef9345, UINT8 r) |
| 182 | { |
| 183 | UINT8 x, y; |
| 184 | x = ef9345->registers[r]; |
| 185 | y = ef9345->registers[r - 1]; |
| 186 | if(y < 8) |
| 187 | y &= 1; |
| 188 | return ((x&0x3f) | ((x & 0x40) << 6) | ((x & 0x80) << 4) | ((y & 0x1f) << 6) | ((y & 0x20) << 8)); |
| 189 | } |
| 190 | |
| 191 | /* calculate the internal ROM offset */ |
| 192 | UINT16 indexrom(ef9345_t *ef9345, int r) |
| 193 | { |
| 194 | UINT8 x, y; |
| 195 | x = ef9345->registers[r]; |
| 196 | y = ef9345->registers[r - 1]; |
| 197 | if(y < 8) |
| 198 | y &= 1; |
| 199 | return((x&0x3f)|((x&0x40)<<6)|((x&0x80)<<4)|((y&0x1f)<<6)); |
| 200 | } |
| 201 | |
| 202 | //calcul de l'adresse du caractere x, y dans le block courant |
| 203 | int indexblock(ef9345_t *ef9345, int x, int y) |
| 204 | { |
| 205 | int i, j; |
| 206 | i = x; |
| 207 | j = (y == 0) ? ((ef9345->TGS & 0x20) >> 5) : ((ef9345->ROR & 0x1f) + y - 1); |
| 208 | //partie droite d'un caractere en double largeur en mode 40 caracteres |
| 209 | if((ef9345->TGS & 0x80) == 0) if(x > 0) |
| 210 | { |
| 211 | if(ef9345->last_dial[x - 1] == 1) i--; //colonne precedente |
| 212 | if(ef9345->last_dial[x - 1] == 4) i--; //colonne precedente |
| 213 | if(ef9345->last_dial[x - 1] == 5) i--; //colonne precedente |
| 214 | } |
| 215 | |
| 216 | return 0x40 * j + i; |
| 217 | } |
| 218 | |
| 219 | // Increment X |
| 220 | void inc_x(ef9345_t *ef9345, int r) |
| 221 | { |
| 222 | int i; |
| 223 | i = (ef9345->registers[r] & 0x3f) + 1; |
| 224 | if(i > 39) |
| 225 | { |
| 226 | i -= 40; |
| 227 | ef9345->state |= 0x40; |
| 228 | } |
| 229 | ef9345->registers[r] = (ef9345->registers[r] & 0xc0) | i; |
| 230 | } |
| 231 | |
| 232 | // Increment Y |
| 233 | void inc_y(ef9345_t *ef9345, int r) |
| 234 | { |
| 235 | int i; |
| 236 | i = (ef9345->registers[r] & 0x1f) + 1; |
| 237 | if(i > 31) |
| 238 | i -= 24; |
| 239 | ef9345->registers[r] = (ef9345->registers[r] & 0xe0) | i; |
| 240 | } |
| 241 | |
| 242 | // Determination du cadran a afficher |
| 243 | void Cadran(ef9345_t *ef9345, int x, int attrib) |
| 244 | { |
| 245 | while(1) |
| 246 | { |
| 247 | if(x > 0) |
| 248 | if(ef9345->last_dial[x-1] == 1) |
| 249 | {ef9345->dial = 2; break;} //cadran haut droit |
| 250 | if(x > 0) |
| 251 | if(ef9345->last_dial[x-1] == 5) |
| 252 | {ef9345->dial = 10; break;} //moitie droite |
| 253 | if(ef9345->last_dial[x] == 1) |
| 254 | {ef9345->dial = 4; break;} //cadran bas gauche |
| 255 | if(ef9345->last_dial[x] == 2) |
| 256 | {ef9345->dial = 8; break;} //dial bas droit |
| 257 | if(ef9345->last_dial[x] == 3) |
| 258 | {ef9345->dial = 12; break;} //moitie basse |
| 259 | if(attrib == 1) |
| 260 | {ef9345->dial = 5; break;} //moitie gauche |
| 261 | if(attrib == 2) |
| 262 | {ef9345->dial = 3; break;} //moitie haute |
| 263 | if(attrib == 3) |
| 264 | {ef9345->dial = 1; break;} //dial haut gauche |
| 265 | ef9345->dial = 0; break; //caractere complet |
| 266 | } |
| 267 | ef9345->last_dial[x] = ef9345->dial; |
| 268 | } |
| 269 | |
| 270 | // zoom sur une partie d'un caractere |
| 271 | void zoom(ef9345_t *ef9345, UINT8 *pix, int n) |
| 272 | { |
| 273 | //pix est le tableau des pixels (8x10=80) |
| 274 | //n definit la zone (zoomx2y2 pour cadran, zoomx2 ou zoomy2 pour moitie) |
| 275 | //cadran haut-gauche=1, haut-droit=2, bas-gauche=4, bas-droite=8 |
| 276 | //moitie haute=3, basse=12, gauche=5, droite=10 |
| 277 | int i, j; |
| 278 | if((n & 0x0a) == 0) |
| 279 | for(i = 0; i < 80; i += 8) // 1, 4, 5 |
| 280 | for(j = 7; j > 0; j--) |
| 281 | pix[i + j] = pix[i + j / 2]; |
| 282 | |
| 283 | if((n & 0x05) == 0) |
| 284 | for(i = 0; i < 80; i += 8) // 2, 8, 10 |
| 285 | for(j =0 ; j < 7; j++) |
| 286 | pix[i + j] = pix[i + 4 + j / 2]; |
| 287 | |
| 288 | if((n & 0x0c) == 0) |
| 289 | for(i = 0; i < 8; i++) // 1, 2, 3 |
| 290 | for(j = 9; j > 0; j--) |
| 291 | pix[i + 8 * j] = pix[i + 8 * (j / 2)]; |
| 292 | if((n & 0x03) == 0) |
| 293 | for(i = 0; i < 8; i++) // 4, 8, 12 |
| 294 | for(j = 0; j < 9; j++) |
| 295 | pix[i + 8 * j] = pix[i + 40 + 8 * (j / 2)]; |
| 296 | } |
| 297 | |
| 298 | // Display bichrome character (40 columns) |
| 299 | void Bichrome40(ef9345_t *ef9345, int iblock, int x, int y, int c0, int c1, int insert, int flash, int conceal, int negative, int underline) |
| 300 | { |
| 301 | UINT8 i, j, pix[80]; |
| 302 | |
| 303 | if(flash && ef9345->PAT & 0x40 && ef9345->blink) |
| 304 | c1 = c0; //flash |
| 305 | if(conceal && ef9345->PAT & 0x08) |
| 306 | c1 = c0; //conceal |
| 307 | if(negative) //negative |
| 308 | { |
| 309 | i = c1; |
| 310 | c1 = c0; |
| 311 | c0 = i; |
| 312 | } |
| 313 | //? v?rifier cf instructions en commentaires ci-dessous : insert = 0 ou 1 ?? |
| 314 | if((ef9345->PAT & 0x30) == 0x30) |
| 315 | insert = 0; //active area mark |
| 316 | if(insert == 0) |
| 317 | c1 += 8; //couleur etendue foreground |
| 318 | if((ef9345->PAT & 0x30) == 0x00) |
| 319 | insert = 1; //inlay |
| 320 | if(insert == 0) |
| 321 | c0 += 8; //couleur etendue background |
| 322 | |
| 323 | |
| 324 | //affichage du curseur |
| 325 | i = (ef9345->registers[6] & 0x1f); |
| 326 | if(i < 8) |
| 327 | i &= 1; |
| 328 | |
| 329 | if(iblock == 0x40 * i + (ef9345->registers[7] & 0x3f)) //position du curseur |
| 330 | { |
| 331 | //affichage du curseur si ef9345->MAT 6 est positionne |
| 332 | //le clignotement depend de ef9345->MAT 5, la forme depend de ef9345->MAT 4 |
| 333 | switch(ef9345->MAT & 0x70) |
| 334 | { |
| 335 | case 0x40: //00 = fixed complemented |
| 336 | c0 = (23 - c0) & 15; |
| 337 | c1 = (23 - c1) & 15; |
| 338 | break; |
| 339 | case 0x50: //01 = fixed underlined |
| 340 | underline = 1; |
| 341 | break; |
| 342 | case 0x60: //10 = flash complemented |
| 343 | if(ef9345->blink) |
| 344 | { |
| 345 | c0 = (23 - c0) & 15; |
| 346 | c1 = (23 - c1) & 15; |
| 347 | } |
| 348 | break; |
| 349 | case 0x70: //11 = flash underlined |
| 350 | if(ef9345->blink) |
| 351 | underline = 1; |
| 352 | break; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | //initialisation du tableau des pixels du caractere |
| 357 | j = 0; |
| 358 | |
| 359 | for(i = 0; i < 10; i++) |
| 360 | { |
| 361 | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x01) ? c1 : c0; |
| 362 | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x02) ? c1 : c0; |
| 363 | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x04) ? c1 : c0; |
| 364 | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x08) ? c1 : c0; |
| 365 | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x10) ? c1 : c0; |
| 366 | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x20) ? c1 : c0; |
| 367 | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x40) ? c1 : c0; |
| 368 | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x80) ? c1 : c0; |
| 369 | |
| 370 | } |
| 371 | |
| 372 | //caractere souligne |
| 373 | if(underline) |
| 374 | for(j = 72; j < 80; j++) |
| 375 | pix[j] = c1; |
| 376 | |
| 377 | //affichage en fonction du cadran |
| 378 | //remarque : la double hauteur par le bit 7 du registre ef9345->MAT |
| 379 | //est prise en UINT8ge par la fonction d'affichage de l'ecran |
| 380 | //voir Displayscreen() dans le module de traitement de la video |
| 381 | if(ef9345->dial > 0) |
| 382 | zoom(ef9345, pix, ef9345->dial); |
| 383 | |
| 384 | draw_char_40(ef9345, pix, x + 1 , y + 1); |
| 385 | } |
| 386 | |
| 387 | // Display quadrichrome character (40 columns) |
| 388 | void Quadrichrome40(ef9345_t *ef9345, int c, int b, int a, int x, int y) |
| 389 | { |
| 390 | //C0-6= character code |
| 391 | //B0= insert not yet implemented !!! |
| 392 | //B1= low resolution |
| 393 | //B2= subset index (low resolution only) |
| 394 | //B3-5 = set number |
| 395 | //A0-6 = 4 color palette |
| 396 | |
| 397 | UINT8 i, j, n, col[8], pix[80]; |
| 398 | UINT8 lowresolution = (b & 0x02) >> 1, ramx, ramy, ramblock; |
| 399 | UINT8 *ramindex; |
| 400 | //pas de double hauteur ou largeur pour les quadrichromes |
| 401 | ef9345->last_dial[x] = 0; |
| 402 | //color table initialization (seules les couleurs 0-3 sont utilis?es) |
| 403 | j = 1; n = 0; |
| 404 | for(i = 0; i < 4; i++) |
| 405 | col[i] = 7; //blanc par defaut |
| 406 | |
| 407 | for(i = 0; i < 8; i++) |
| 408 | { |
| 409 | if(a & j) |
| 410 | col[n++] = i; |
| 411 | j <<= 1; |
| 412 | } |
| 413 | |
| 414 | //find block number i in ram |
| 415 | ramblock = 0; |
| 416 | if(b & 0x20) ramblock |= 4; //B5 |
| 417 | if(b & 0x08) ramblock |= 2; //B3 |
| 418 | if(b & 0x10) ramblock |= 1; //B4 |
| 419 | |
| 420 | //find character address in ram |
| 421 | ramx = c & 0x03; ramy =(c & 0x7f) >> 2; |
| 422 | ramindex = ef9345->char_ptr[0x0c] + 0x800 * ramblock + 0x40 * ramy + ramx; |
| 423 | if(lowresolution) ramindex += 5 * (b & 0x04); |
| 424 | |
| 425 | //fill pixel table |
| 426 | j = 0; for(i = 0; i < 10; i++) |
| 427 | { |
| 428 | pix[j] = pix[j + 1] = col[(*(ramindex + 4 * (i >> lowresolution)) & 0x03) >> 0]; j += 2; |
| 429 | pix[j] = pix[j + 1] = col[(*(ramindex + 4 * (i >> lowresolution)) & 0x0c) >> 2]; j += 2; |
| 430 | pix[j] = pix[j + 1] = col[(*(ramindex + 4 * (i >> lowresolution)) & 0x30) >> 4]; j += 2; |
| 431 | pix[j] = pix[j + 1] = col[(*(ramindex + 4 * (i >> lowresolution)) & 0xc0) >> 6]; j += 2; |
| 432 | } |
| 433 | |
| 434 | draw_char_40(ef9345, pix, x + 1, y + 1); |
| 435 | } |
| 436 | |
| 437 | // Display bichrome character (80 columns) |
| 438 | void Bichrome80(ef9345_t *ef9345, int c, int a, int x, int y) |
| 439 | { |
| 440 | UINT8 pix[60]; //tableau des pixels a afficher |
| 441 | int i, j, d, c0, c1; |
| 442 | c1 = (a & 1) ? (ef9345->DOR >> 4) & 7 : ef9345->DOR & 7; //foreground color = ef9345->DOR |
| 443 | c0 = ef9345->MAT & 7; //background color = ef9345->MAT |
| 444 | switch(c & 0x80) |
| 445 | { |
| 446 | case 0: //alphanumeric G0 set |
| 447 | //A0: D = color set |
| 448 | //A1: U = underline |
| 449 | //A2: F = flash |
| 450 | //A3: N = negative |
| 451 | //C0-6: character code |
| 452 | j = 0; |
| 453 | if(a & 4) if(ef9345->PAT & 0x40) if(ef9345->blink) c1 = c0; //flash |
| 454 | if(a & 8) {i = c1; c1 = c0; c0 = i;} //couleurs en mode inverse |
| 455 | d = ((c & 0x7f) >> 2) * 0x40 + (c & 0x03); //deplacement dans table police |
| 456 | for(i = 0; i < 10; i++) |
| 457 | { |
| 458 | pix[j++] = (*(ef9345->charset + d + 4 * i) & 0x01) ? c1 : c0; pix[j++] = (*(ef9345->charset + d + 4 * i) & 0x02) ? c1 : c0; |
| 459 | pix[j++] = (*(ef9345->charset + d + 4 * i) & 0x04) ? c1 : c0; pix[j++] = (*(ef9345->charset + d + 4 * i) & 0x08) ? c1 : c0; |
| 460 | pix[j++] = (*(ef9345->charset + d + 4 * i) & 0x10) ? c1 : c0; pix[j++] = (*(ef9345->charset + d + 4 * i) & 0x20) ? c1 : c0; |
| 461 | } |
| 462 | if(a & 2) for(j = 54; j < 60; j++) pix[j] = c1; //underline |
| 463 | break; |
| 464 | default: //dedicated mosaic set |
| 465 | //A0: D = color set |
| 466 | //A1-3: 3 blocks de 6 pixels |
| 467 | //C0-6: 7 blocks de 6 pixels |
| 468 | pix[ 0] = (c & 0x01) ? c1 : c0; |
| 469 | pix[ 3] = (c & 0x02) ? c1 : c0; |
| 470 | pix[12] = (c & 0x04) ? c1 : c0; |
| 471 | pix[15] = (c & 0x08) ? c1 : c0; |
| 472 | pix[24] = (c & 0x10) ? c1 : c0; |
| 473 | pix[27] = (c & 0x20) ? c1 : c0; |
| 474 | pix[36] = (c & 0x40) ? c1 : c0; |
| 475 | pix[39] = (a & 0x02) ? c1 : c0; |
| 476 | pix[48] = (a & 0x04) ? c1 : c0; |
| 477 | pix[51] = (a & 0x08) ? c1 : c0; |
| 478 | for(i = 0; i < 60; i += 12) |
| 479 | { |
| 480 | pix[i + 6] = pix[i]; |
| 481 | pix[i + 9] = pix[i + 3]; |
| 482 | } |
| 483 | for(i = 0; i < 60; i += 3) |
| 484 | pix[i + 2] = pix[i + 1] = pix[i]; |
| 485 | break; |
| 486 | } |
| 487 | draw_char_80(ef9345, pix, x, y); |
| 488 | } |
| 489 | |
| 490 | |
| 491 | // Affichage d'un caractere 16 bits 40 colonnes |
| 492 | void makechar_16x40(ef9345_t *ef9345, int x, int y) |
| 493 | { |
| 494 | int i, a, b, type, c0, c1, f, m, n, u, iblock; |
| 495 | |
| 496 | //recherche des octets b, a (precedent si double largeur) |
| 497 | iblock = indexblock(ef9345, x, y); |
| 498 | a = ef9345->block[iblock]; |
| 499 | b = ef9345->block[iblock + 0x800]; |
| 500 | |
| 501 | //determination attribut HL et numero du cadran a afficher |
| 502 | Cadran(ef9345, x, (a & 0x80) ? 0 : (((a & 0x20) >> 5) | ((a & 0x10) >> 3))); |
| 503 | |
| 504 | //adresse de la matrice de definition du caractere |
| 505 | type = ((b & 0x80) >> 4) | ((a & 0x80) >> 6); |
| 506 | ef9345->matrice = ef9345->char_ptr[type] + ((b & 0x7f) >> 2) * 0x40 + (b & 0x03); |
| 507 | if((b & 0xe0) == 0x80) |
| 508 | ef9345->matrice = ef9345->char_ptr[0x03]; //negative space |
| 509 | |
| 510 | //attributs latches |
| 511 | if(x == 0) ef9345->latchm = ef9345->latchi = ef9345->latchu = ef9345->latchc0 = 0; |
| 512 | if(type == 4) {ef9345->latchm = b & 1; ef9345->latchi = (b & 2) >> 1; ef9345->latchu = (b & 4) >> 2;} |
| 513 | if(a & 0x80) ef9345->latchc0 = (a & 0x70) >> 4; |
| 514 | |
| 515 | //attributs du caractere |
| 516 | c0 = ef9345->latchc0; //background |
| 517 | c1 = a & 0x07; //foreground |
| 518 | i = ef9345->latchi; //insert mode |
| 519 | f = (a & 0x08) >> 3; //flash |
| 520 | m = ef9345->latchm; //conceal |
| 521 | n = (a & 0x80) ? 0: ((a & 0x40) >> 6); //negative |
| 522 | u = ef9345->latchu; //underline |
| 523 | |
| 524 | //affichage |
| 525 | Bichrome40(ef9345, iblock, x, y, c0, c1, i, f, m, n, u); |
| 526 | } |
| 527 | |
| 528 | // Affichage d'un caractere 24 bits 40 colonnes |
| 529 | void makechar_24x40(ef9345_t *ef9345, int x, int y) |
| 530 | { |
| 531 | int i, a, b, c, c0, c1, f, m, n, u, iblock; |
| 532 | |
| 533 | //recherche des octets c, b, a |
| 534 | //iblock = (ef9345->MAT & 0x80) ? indexblock(x, y / 2) : indexblock(x, y); |
| 535 | //la double hauteur est maintenant prise en compte dans Displayscreen() |
| 536 | iblock = indexblock(ef9345, x, y); |
| 537 | c = ef9345->block[iblock]; b = ef9345->block[iblock + 0x800]; a = ef9345->block[iblock + 0x1000]; |
| 538 | if((b & 0xc0) == 0xc0) {Quadrichrome40(ef9345, c, b, a, x, y); return;} |
| 539 | |
| 540 | //determination attribut HL et numero du cadran a afficher |
| 541 | Cadran(ef9345, x, (b & 0x02) + ((b & 0x08) >> 3)); |
| 542 | |
| 543 | //adresse de la matrice de definition du caractere |
| 544 | ef9345->matrice = ef9345->char_ptr[(b & 0xf0) >> 4] + ((c & 0x7f) >> 2) * 0x40 + (c & 0x03); |
| 545 | |
| 546 | //attributs du caractere |
| 547 | c0 = a & 0x07; //background |
| 548 | c1 = (a & 0x70) >> 4; //foreground |
| 549 | i = b & 0x01; //insert |
| 550 | f = (a & 0x08) >> 3; //flash |
| 551 | m = (b & 0x04) >> 2; //conceal |
| 552 | n = (a & 0x80) >> 7; //negative |
| 553 | u = (((b & 0x60) == 0) || ((b & 0xc0) == 0x40)) ? ((b & 0x10) >> 4) : 0; |
| 554 | |
| 555 | //affichage |
| 556 | Bichrome40(ef9345, iblock, x, y, c0, c1, i, f, m, n, u); |
| 557 | } |
| 558 | |
| 559 | |
| 560 | // Affichage de deux caracteres 12 bits 80 colonnes |
| 561 | void makechar_12x80(ef9345_t *ef9345, int x, int y) |
| 562 | { |
| 563 | int iblock; |
| 564 | iblock = indexblock(ef9345, x, y); |
| 565 | Bichrome80(ef9345, ef9345->block[iblock], (ef9345->block[iblock + 0x1000] >> 4) & 0x0f, 2 * x + 2, y + 1); |
| 566 | Bichrome80(ef9345, ef9345->block[iblock + 0x800], ef9345->block[iblock + 0x1000] & 0x0f, 2 * x + 3, y + 1); |
| 567 | } |
| 568 | |
| 569 | void makechar(ef9345_t *ef9345, int x, int y) |
| 570 | { |
| 571 | switch (ef9345->char_mode) |
| 572 | { |
| 573 | case 0: |
| 574 | makechar_24x40(ef9345, x, y); |
| 575 | break; |
| 576 | case 3: |
| 577 | makechar_12x80(ef9345, x, y); |
| 578 | break; |
| 579 | case 4: |
| 580 | makechar_16x40(ef9345, x, y); |
| 581 | break; |
| 582 | default: |
| 583 | break; |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | // Lecture-ecriture en memoire EF9345 |
| 588 | void OCTwrite(ef9345_t *ef9345, int r, int i) |
| 589 | { |
| 590 | set_busy_flag(ef9345, 4); |
| 591 | ef9345->ram[indexram(ef9345, r)] = ef9345->registers[1]; |
| 592 | if(i == 0) return; |
| 593 | inc_x(ef9345, r); |
| 594 | if((ef9345->registers[r] & 0x3f) == 0 && r == 7) |
| 595 | inc_y(ef9345, 6); |
| 596 | } |
| 597 | void OCTread(ef9345_t *ef9345, int r, int i) |
| 598 | { |
| 599 | set_busy_flag(ef9345, 4.5); |
| 600 | ef9345->registers[1] = ef9345->ram[indexram(ef9345, r)]; |
| 601 | if(i == 0) return; |
| 602 | inc_x(ef9345, r); |
| 603 | |
| 604 | if((ef9345->registers[r] & 0x3f) == 0 && r == 7) |
| 605 | inc_y(ef9345, 6); //increment |
| 606 | } |
| 607 | |
| 608 | void KRGwrite(ef9345_t *ef9345, int i) //mode 40 caracteres 16 bits |
| 609 | { |
| 610 | int a = indexram(ef9345, 7); |
| 611 | set_busy_flag(ef9345, 5.5); |
| 612 | ef9345->ram[a] = ef9345->registers[1]; |
| 613 | ef9345->ram[a + 0x0800] = ef9345->registers[2]; |
| 614 | if(i) inc_x(ef9345, 7); |
| 615 | } |
| 616 | void KRGread(ef9345_t *ef9345, int i) |
| 617 | { |
| 618 | int a = indexram(ef9345, 7); |
| 619 | |
| 620 | set_busy_flag(ef9345, 7.5); |
| 621 | ef9345->registers[1] = ef9345->ram[a]; |
| 622 | ef9345->registers[2] = ef9345->ram[a + 0x0800]; |
| 623 | if(i) inc_x(ef9345, 7); |
| 624 | } |
| 625 | |
| 626 | void KRFwrite(ef9345_t *ef9345, int i) //mode 40 caracteres 24 bits |
| 627 | { |
| 628 | int a = indexram(ef9345, 7); |
| 629 | |
| 630 | set_busy_flag(ef9345, 4); |
| 631 | ef9345->ram[a] = ef9345->registers[1]; |
| 632 | ef9345->ram[a + 0x0800] = ef9345->registers[2]; |
| 633 | ef9345->ram[a + 0x1000] = ef9345->registers[3]; |
| 634 | if(i) inc_x(ef9345, 7); |
| 635 | } |
| 636 | |
| 637 | void KRFread(ef9345_t *ef9345, int i) |
| 638 | { |
| 639 | int a = indexram(ef9345, 7); |
| 640 | |
| 641 | set_busy_flag(ef9345, 7.5); |
| 642 | ef9345->registers[1] = ef9345->ram[a]; |
| 643 | ef9345->registers[2] = ef9345->ram[a + 0x0800]; |
| 644 | ef9345->registers[3] = ef9345->ram[a + 0x1000]; |
| 645 | if(i) inc_x(ef9345, 7); |
| 646 | } |
| 647 | |
| 648 | void KRLwrite(ef9345_t *ef9345, int i) //mode 80 caracteres 12 bits |
| 649 | { |
| 650 | int a = indexram(ef9345, 7); |
| 651 | |
| 652 | set_busy_flag(ef9345, 12.5); |
| 653 | ef9345->ram[a] = ef9345->registers[1]; |
| 654 | switch((a / 0x800) & 1) |
| 655 | { |
| 656 | case 0: ef9345->ram[a + 0x1000] &= 0x0f; |
| 657 | ef9345->ram[a + 0x1000] |= (ef9345->registers[3] & 0xf0); break; |
| 658 | case 1: ef9345->ram[a + 0x0800] &= 0xf0; |
| 659 | ef9345->ram[a + 0x0800] |= (ef9345->registers[3] & 0x0f); break; |
| 660 | } |
| 661 | if(i) |
| 662 | { |
| 663 | if((ef9345->registers[7] & 0x80) == 0x00) {ef9345->registers[7] |= 0x80; return;} |
| 664 | ef9345->registers[7] &= 0x80; |
| 665 | inc_x(ef9345, 7); |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | void KRLread(ef9345_t *ef9345, int i) |
| 670 | { |
| 671 | int a = indexram(ef9345, 7); |
| 672 | |
| 673 | set_busy_flag(ef9345, 11.5); |
| 674 | ef9345->registers[1] = ef9345->ram[a]; |
| 675 | switch((a / 0x800) & 1) |
| 676 | { |
| 677 | case 0: ef9345->registers[3] = ef9345->ram[a + 0x1000]; break; |
| 678 | case 1: ef9345->registers[3] = ef9345->ram[a + 0x0800]; break; |
| 679 | } |
| 680 | if(i) |
| 681 | { |
| 682 | if((ef9345->registers[7] & 0x80) == 0x00) {ef9345->registers[7] |= 0x80; return;} |
| 683 | ef9345->registers[7] &= 0x80; |
| 684 | inc_x(ef9345, 7); |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | // Move buffer |
| 689 | void MVB(ef9345_t *ef9345, int n, int r1, int r2, int s) |
| 690 | { |
| 691 | //s=1 pour mode normal, s=0 pour remplir tout le buffer |
| 692 | int i, a1, a2; |
| 693 | |
| 694 | set_busy_flag(ef9345, 2); |
| 695 | for(i = 0; i < 1280; i++) |
| 696 | { |
| 697 | a1 = indexram(ef9345, r1); a2 = indexram(ef9345, r2); |
| 698 | ef9345->ram[a2] = ef9345->ram[a1]; //ef9345_cycle += 16 * n; |
| 699 | if(n > 1) ef9345->ram[a2 + 0x0800] = ef9345->ram[a1 + 0x0800]; |
| 700 | if(n > 2) ef9345->ram[a2 + 0x1000] = ef9345->ram[a1 + 0x1000]; |
| 701 | inc_x(ef9345, r1); inc_x(ef9345, r2); |
| 702 | if((ef9345->registers[5] & 0x3f) == 0) {if(s) break;} |
| 703 | if((ef9345->registers[7] & 0x3f) == 0) {if(s) break; else inc_y(ef9345, 6);} |
| 704 | } |
| 705 | ef9345->state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 706 | } |
| 707 | |
| 708 | // Increment registre R6 |
| 709 | void INY(ef9345_t *ef9345) |
| 710 | { |
| 711 | set_busy_flag(ef9345, 2); |
| 712 | inc_y(ef9345, 6); |
| 713 | ef9345->state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 714 | } |
| 715 | |
| 716 | // Lecture/Ecriture des registres indirects |
| 717 | void INDwrite(ef9345_t *ef9345, int x) |
| 718 | { |
| 719 | set_busy_flag(ef9345, 2); |
| 720 | switch(x) |
| 721 | { |
| 722 | case 1: ef9345->TGS = ef9345->registers[1]; break; |
| 723 | case 2: ef9345->MAT = ef9345->registers[1]; break; |
| 724 | case 3: ef9345->PAT = ef9345->registers[1]; break; |
| 725 | case 4: ef9345->DOR = ef9345->registers[1]; break; |
| 726 | case 7: ef9345->ROR = ef9345->registers[1]; break; |
| 727 | } |
| 728 | set_ef9345_mode(ef9345); |
| 729 | ef9345->state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 730 | } |
| 731 | |
| 732 | void INDread(ef9345_t *ef9345, int x) |
| 733 | { |
| 734 | set_busy_flag(ef9345, 3.5); |
| 735 | switch(x) |
| 736 | { |
| 737 | case 0: ef9345->registers[1] = ef9345->charset[indexrom(ef9345, 7) & 0x1fff]; break; |
| 738 | case 1: ef9345->registers[1] = ef9345->TGS; break; |
| 739 | case 2: ef9345->registers[1] = ef9345->MAT; break; |
| 740 | case 3: ef9345->registers[1] = ef9345->PAT; break; |
| 741 | case 4: ef9345->registers[1] = ef9345->DOR; break; |
| 742 | case 7: ef9345->registers[1] = ef9345->ROR; break; |
| 743 | case 8: ef9345->registers[1] = ef9345->ROR; break; |
| 744 | } |
| 745 | ef9345->state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) |
| 746 | } |
| 747 | |
| 748 | // Execute EF9345 command |
| 749 | void ef9345_exec(ef9345_t *ef9345, UINT8 cmd) |
| 750 | { |
| 751 | ef9345->state = 0; |
| 752 | if((ef9345->registers[5] & 0x3f) == 39) ef9345->state |= 0x10; //S4(LXa) set |
| 753 | if((ef9345->registers[7] & 0x3f) == 39) ef9345->state |= 0x20; //S5(LXm) set |
| 754 | |
| 755 | switch(cmd) |
| 756 | { |
| 757 | case 0x00: KRFwrite(ef9345, 0); break; //KRF: R1,R2,R3->ram |
| 758 | case 0x01: KRFwrite(ef9345, 1); break; //KRF: R1,R2,R3->ram + increment |
| 759 | case 0x02: KRGwrite(ef9345, 0); break; //KRG: R1,R2->ram |
| 760 | case 0x03: KRGwrite(ef9345, 1); break; //KRG: R1,R2->ram + increment |
| 761 | case 0x05: break; //CLF: Clear page 24 bits |
| 762 | case 0x07: break; //CLG: Clear page 16 bits |
| 763 | case 0x08: KRFread(ef9345, 0); break; //KRF: ram->R1,R2,R3 |
| 764 | case 0x09: KRFread(ef9345, 1); break; //KRF: ram->R1,R2,R3 + increment |
| 765 | case 0x0a: KRGread(ef9345, 0); break; //KRG: ram->R1,R2 |
| 766 | case 0x0b: KRGread(ef9345, 1); break; //KRG: ram->R1,R2 + increment |
| 767 | case 0x30: OCTwrite(ef9345, 7, 0); break; //OCT: R1->RAM, main pointer |
| 768 | case 0x31: OCTwrite(ef9345, 7, 1); break; //OCT: R1->RAM, main pointer + inc |
| 769 | case 0x34: OCTwrite(ef9345, 5, 0); break; //OCT: R1->RAM, aux pointer |
| 770 | case 0x35: OCTwrite(ef9345, 5, 1); break; //OCT: R1->RAM, aux pointer + inc |
| 771 | case 0x38: OCTread(ef9345, 7, 0); break; //OCT: RAM->R1, main pointer |
| 772 | case 0x39: OCTread(ef9345, 7, 1); break; //OCT: RAM->R1, main pointer + inc |
| 773 | case 0x3c: OCTread(ef9345, 5, 0); break; //OCT: RAM->R1, aux pointer |
| 774 | case 0x3d: OCTread(ef9345, 5, 1); break; //OCT: RAM->R1, aux pointer + inc |
| 775 | case 0x40: break; //KRC: R1 -> ram |
| 776 | case 0x41: break; //KRC: R1 -> ram + inc |
| 777 | case 0x48: break; //KRC: 80 characters - 8 bits |
| 778 | case 0x49: break; //KRC: 80 characters - 8 bits |
| 779 | case 0x50: KRLwrite(ef9345, 0); break; //KRL: 80 UINT8 - 12 bits write |
| 780 | case 0x51: KRLwrite(ef9345, 1); break; //KRL: 80 UINT8 - 12 bits write + inc |
| 781 | case 0x58: KRLread(ef9345, 0); break; //KRL: 80 UINT8 - 12 bits read |
| 782 | case 0x59: KRLread(ef9345, 1); break; //KRL: 80 UINT8 - 12 bits read + inc |
| 783 | case 0x80: break; //IND: R1->ROM (impossible ?) |
| 784 | case 0x81: INDwrite(ef9345, 1); break; //IND: R1->ef9345->TGS |
| 785 | case 0x82: INDwrite(ef9345, 2); break; //IND: R1->ef9345->MAT |
| 786 | case 0x83: INDwrite(ef9345, 3); break; //IND: R1->ef9345->PAT |
| 787 | case 0x84: INDwrite(ef9345, 4); break; //IND: R1->ef9345->DOR |
| 788 | case 0x87: INDwrite(ef9345, 7); break; //IND: R1->ef9345->ROR |
| 789 | case 0x88: INDread(ef9345, 0); break; //IND: ROM->R1 |
| 790 | case 0x89: INDread(ef9345, 1); break; //IND: ef9345->TGS->R1 |
| 791 | case 0x8a: INDread(ef9345, 2); break; //IND: ef9345->MAT->R1 |
| 792 | case 0x8b: INDread(ef9345, 3); break; //IND: ef9345->PAT->R1 |
| 793 | case 0x8c: INDread(ef9345, 4); break; //IND: ef9345->DOR->R1 |
| 794 | case 0x8f: INDread(ef9345, 7); break; //IND: ef9345->ROR->R1 |
| 795 | case 0x90: break; //NOP: no operation |
| 796 | case 0x91: break; //NOP: no operation |
| 797 | case 0x95: break; //VRM: vertical sync mask reset |
| 798 | case 0x99: break; //VSM: vertical sync mask set |
| 799 | case 0xb0: INY(ef9345); break; //INY: increment Y |
| 800 | case 0xd5: MVB(ef9345, 1, 7, 5, 1); break; //MVB: move buffer MP->AP stop |
| 801 | case 0xd6: MVB(ef9345, 1, 7, 5, 0); break; //MVB: move buffer MP->AP nostop |
| 802 | case 0xd9: MVB(ef9345, 1, 5, 7, 1); break; //MVB: move buffer AP->MP stop |
| 803 | case 0xda: MVB(ef9345, 1, 5, 7, 0); break; //MVB: move buffer AP->MP nostop |
| 804 | case 0xe5: MVB(ef9345, 2, 7, 5, 1); break; //MVD: move double buffer MP->AP stop |
| 805 | case 0xe6: MVB(ef9345, 2, 7, 5, 0); break; //MVD: move double buffer MP->AP nostop |
| 806 | case 0xe9: MVB(ef9345, 2, 5, 7, 1); break; //MVD: move double buffer AP->MP stop |
| 807 | case 0xea: MVB(ef9345, 2, 5, 7, 0); break; //MVD: move double buffer AP->MP nostop |
| 808 | case 0xf5: MVB(ef9345, 3, 7, 5, 1); break; //MVT: move triple buffer MP->AP stop |
| 809 | case 0xf6: MVB(ef9345, 3, 7, 5, 0); break; //MVT: move triple buffer MP->AP nostop |
| 810 | case 0xf9: MVB(ef9345, 3, 5, 7, 1); break; //MVT: move triple buffer AP->MP stop |
| 811 | case 0xfa: MVB(ef9345, 3, 5, 7, 0); break; //MVT: move triple buffer AP->MP nostop |
| 812 | default: logerror("Unemulated EF9345 cmd: %02x\n", cmd); |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | |
| 817 | /************************************************************** |
| 818 | EF9345 interface |
| 819 | **************************************************************/ |
| 820 | |
| 821 | void video_update_ef9345(running_device *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 822 | { |
| 823 | ef9345_t *ef9345 = get_safe_token(device); |
| 824 | copybitmap(bitmap, ef9345->screen_out, 0, 0, 0, 0, cliprect); |
| 825 | } |
| 826 | |
| 827 | |
| 828 | READ8_DEVICE_HANDLER ( ef9345_r ) |
| 829 | { |
| 830 | ef9345_t *ef9345 = get_safe_token(device); |
| 831 | |
| 832 | if(offset & 8) |
| 833 | ef9345_exec(ef9345, ef9345->registers[0] & 0xff); |
| 834 | |
| 835 | if(offset & 7) |
| 836 | return ef9345->registers[offset & 7]; |
| 837 | |
| 838 | if(ef9345->bf) |
| 839 | ef9345->state |= 0x80; |
| 840 | else |
| 841 | ef9345->state &= 0x7f; |
| 842 | |
| 843 | return ef9345->state; |
| 844 | } |
| 845 | |
| 846 | |
| 847 | WRITE8_DEVICE_HANDLER ( ef9345_w ) |
| 848 | { |
| 849 | ef9345_t *ef9345 = get_safe_token(device); |
| 850 | |
| 851 | ef9345->registers[offset & 7] = data; |
| 852 | |
| 853 | if(offset & 8) |
| 854 | ef9345_exec(ef9345, ef9345->registers[0] & 0xff); |
| 855 | } |
| 856 | |
| 857 | |
| 858 | static TIMER_CALLBACK( ef9345_done ) |
| 859 | { |
| 860 | running_device *device = (running_device *)ptr; |
| 861 | ef9345_t *ef9345 = get_safe_token(device); |
| 862 | |
| 863 | ef9345->bf = 0; |
| 864 | } |
| 865 | |
| 866 | void ef9345_scanline(running_device *device, UINT16 scanline) |
| 867 | { |
| 868 | ef9345_t *ef9345 = get_safe_token(device); |
| 869 | UINT8 i; |
| 870 | |
| 871 | if (scanline == 250) |
| 872 | ef9345->state &= 0xfb; |
| 873 | |
| 874 | set_busy_flag(ef9345, 104); |
| 875 | |
| 876 | draw_char_40(ef9345, ef9345->border, 0, (scanline / 10) + 1); |
| 877 | draw_char_40(ef9345, ef9345->border, 41, (scanline / 10) + 1); |
| 878 | |
| 879 | if(scanline == 0) |
| 880 | { |
| 881 | ef9345->state |= 0x04; |
| 882 | for(i = 0; i < 42; i++) |
| 883 | draw_char_40(ef9345, ef9345->border, i, 0); |
| 884 | |
| 885 | if(ef9345->PAT & 1) |
| 886 | for(i = 0; i < 40; i++) |
| 887 | makechar(ef9345, i, (scanline / 10)); |
| 888 | else |
| 889 | for(i = 0; i < 42; i++) |
| 890 | draw_char_40(ef9345, ef9345->border, i, 1); |
| 891 | } |
| 892 | else if(scanline < 120) |
| 893 | { |
| 894 | if(ef9345->PAT & 2) |
| 895 | for(i = 0; i < 40; i++) |
| 896 | makechar(ef9345, i, (scanline / 10)); |
| 897 | else |
| 898 | for(i = 0; i < 42; i++) |
| 899 | draw_char_40(ef9345, ef9345->border, i, (scanline / 10)); |
| 900 | } |
| 901 | else if(scanline < 250) |
| 902 | { |
| 903 | if(ef9345->PAT & 4) |
| 904 | for(i = 0; i < 40; i++) |
| 905 | makechar(ef9345, i, (scanline / 10)); |
| 906 | else |
| 907 | for(i = 0; i < 42; i++) |
| 908 | draw_char_40(ef9345, ef9345->border, i, (scanline / 10)); |
| 909 | |
| 910 | if(scanline == 240) |
| 911 | for(i = 0; i < 42; i++) |
| 912 | draw_char_40(ef9345, ef9345->border, i, 26); |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | |
| 917 | static TIMER_CALLBACK( blinking ) |
| 918 | { |
| 919 | running_device *device = (running_device *)ptr; |
| 920 | ef9345_t *ef9345 = get_safe_token(device); |
| 921 | |
| 922 | ef9345->blink = (!ef9345->blink) & 0x01; |
| 923 | } |
| 924 | |
| 925 | |
| 926 | /*------------------------------------------------- |
| 927 | DEVICE_RESET( ef9345 ) |
| 928 | -------------------------------------------------*/ |
| 929 | static DEVICE_RESET( ef9345 ) |
| 930 | { |
| 931 | ef9345_t *ef9345 = get_safe_token(device); |
| 932 | |
| 933 | ef9345->TGS = 0; |
| 934 | ef9345->MAT = 0; |
| 935 | ef9345->PAT = 0; |
| 936 | ef9345->DOR = 0; |
| 937 | ef9345->ROR = 0; |
| 938 | ef9345->state = 0; |
| 939 | ef9345->bf = 0; |
| 940 | ef9345->blink = 0; |
| 941 | ef9345->dial = 0; |
| 942 | ef9345->latchc0 = 0; |
| 943 | ef9345->latchm = 0; |
| 944 | ef9345->latchi = 0; |
| 945 | ef9345->latchu = 0; |
| 946 | ef9345->char_mode = 0; |
| 947 | |
| 948 | memset(ef9345->last_dial, 0, sizeof(ef9345->last_dial)); |
| 949 | memset(ef9345->ram, 0, sizeof(ef9345->ram)); |
| 950 | memset(ef9345->registers, 0, sizeof(ef9345->registers)); |
| 951 | memset(ef9345->border, 0, sizeof(ef9345->border)); |
| 952 | |
| 953 | bitmap_fill(ef9345->screen_out, NULL, 0); |
| 954 | |
| 955 | set_ef9345_mode(ef9345); |
| 956 | } |
| 957 | |
| 958 | |
| 959 | /*------------------------------------------------- |
| 960 | DEVICE_START( ef9345 ) |
| 961 | -------------------------------------------------*/ |
| 962 | static DEVICE_START( ef9345 ) |
| 963 | { |
| 964 | ef9345_t *ef9345 = get_safe_token(device); |
| 965 | |
| 966 | /* validate arguments */ |
| 967 | assert(device != NULL); |
| 968 | |
| 969 | ef9345->conf = (ef9345_config*)device->baseconfig().static_config; |
| 970 | |
| 971 | ef9345->charset = memory_region(device->machine, ef9345->conf->charset); |
| 972 | |
| 973 | ef9345->busy_timer = timer_alloc(device->machine, ef9345_done, (void *)device); |
| 974 | ef9345->blink_timer = timer_alloc(device->machine, blinking, (void *)device); |
| 975 | |
| 976 | ef9345->screen_out = auto_bitmap_alloc(device->machine, ef9345->conf->width , ef9345->conf->height , BITMAP_FORMAT_INDEXED16); |
| 977 | |
| 978 | timer_adjust_periodic(ef9345->blink_timer, ATTOTIME_IN_MSEC(500), 0, ATTOTIME_IN_MSEC(500)); |
| 979 | |
| 980 | init_char_prt(ef9345); |
| 981 | |
| 982 | state_save_register_device_item_array(device, 0, ef9345->ram); |
| 983 | state_save_register_device_item_array(device, 0, ef9345->border); |
| 984 | state_save_register_device_item_array(device, 0, ef9345->registers); |
| 985 | state_save_register_device_item_array(device, 0, ef9345->last_dial); |
| 986 | |
| 987 | state_save_register_device_item(device, 0, ef9345->bf); |
| 988 | state_save_register_device_item(device, 0, ef9345->char_mode); |
| 989 | state_save_register_device_item(device, 0, ef9345->state); |
| 990 | state_save_register_device_item(device, 0, ef9345->TGS); |
| 991 | state_save_register_device_item(device, 0, ef9345->MAT); |
| 992 | state_save_register_device_item(device, 0, ef9345->PAT); |
| 993 | state_save_register_device_item(device, 0, ef9345->DOR); |
| 994 | state_save_register_device_item(device, 0, ef9345->ROR); |
| 995 | state_save_register_device_item(device, 0, ef9345->blink); |
| 996 | state_save_register_device_item(device, 0, ef9345->dial); |
| 997 | state_save_register_device_item(device, 0, ef9345->latchc0); |
| 998 | state_save_register_device_item(device, 0, ef9345->latchm); |
| 999 | state_save_register_device_item(device, 0, ef9345->latchi); |
| 1000 | state_save_register_device_item(device, 0, ef9345->latchu); |
| 1001 | |
| 1002 | state_save_register_device_item_bitmap(device, 0, ef9345->screen_out); |
| 1003 | } |
| 1004 | |
| 1005 | DEVICE_GET_INFO( ef9345 ) |
| 1006 | { |
| 1007 | switch (state) |
| 1008 | { |
| 1009 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 1010 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ef9345_t); break; |
| 1011 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(ef9345_config); break; |
| 1012 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; |
| 1013 | |
| 1014 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1015 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ef9345); break; |
| 1016 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 1017 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(ef9345); break; |
| 1018 | case DEVINFO_PTR_ROM_REGION: /* Nothing */ break; |
| 1019 | |
| 1020 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1021 | case DEVINFO_STR_NAME: strcpy(info->s, "SGS Thomson EF9345"); break; |
| 1022 | case DEVINFO_STR_FAMILY: strcpy(info->s, "EF9345"); break; |
| 1023 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 1024 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 1025 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Daniel Coulom"); break; |
| 1026 | } |
| 1027 | } |
src/mess/drivers/vg5k.c
| r8223 | r8224 | |
| 2 | 2 | |
| 3 | 3 | Philips VG-5000mu |
| 4 | 4 | |
| 5 | 05/2010 (Sandro Ronco) |
| 6 | - EF9345 video controller |
| 7 | - keyboard input ports |
| 5 | 8 | 05/2009 Skeleton driver. |
| 6 | 9 | |
| 7 | 10 | Informations ( see the very informative http://vg5k.free.fr/ ): |
| r8223 | r8224 | |
| 39 | 42 | #include "emu.h" |
| 40 | 43 | #include "cpu/z80/z80.h" |
| 41 | 44 | #include "devices/messram.h" |
| 45 | #include "devices/printer.h" |
| 46 | #include "video/ef9345.h" |
| 47 | #include "sound/dac.h" |
| 48 | #include "devices/cassette.h" |
| 49 | #include "sound/wave.h" |
| 42 | 50 | |
| 51 | |
| 52 | class vg5k_state |
| 53 | { |
| 54 | public: |
| 55 | static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vg5k_state(machine)); } |
| 56 | |
| 57 | vg5k_state(running_machine &machine) { } |
| 58 | |
| 59 | running_device *ef9345; |
| 60 | running_device *dac; |
| 61 | running_device *printer; |
| 62 | running_device *cassette; |
| 63 | |
| 64 | UINT8 ef9345_offset; |
| 65 | }; |
| 66 | |
| 67 | |
| 68 | READ8_HANDLER( printer_r ) |
| 69 | { |
| 70 | vg5k_state *vg5k = (vg5k_state *)space->machine->driver_data; |
| 71 | |
| 72 | return (printer_is_ready(vg5k->printer) ? 0x00 : 0xff); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | WRITE8_HANDLER( printer_w ) |
| 77 | { |
| 78 | vg5k_state *vg5k = (vg5k_state *)space->machine->driver_data; |
| 79 | |
| 80 | printer_output(vg5k->printer, data); |
| 81 | } |
| 82 | |
| 83 | |
| 84 | WRITE8_HANDLER ( ef9345_offset_w ) |
| 85 | { |
| 86 | vg5k_state *vg5k = (vg5k_state *)space->machine->driver_data; |
| 87 | |
| 88 | vg5k->ef9345_offset = data; |
| 89 | } |
| 90 | |
| 91 | |
| 92 | READ8_HANDLER ( ef9345_io_r ) |
| 93 | { |
| 94 | vg5k_state *vg5k = (vg5k_state *)space->machine->driver_data; |
| 95 | |
| 96 | return ef9345_r(vg5k->ef9345, vg5k->ef9345_offset); |
| 97 | } |
| 98 | |
| 99 | |
| 100 | WRITE8_HANDLER ( ef9345_io_w ) |
| 101 | { |
| 102 | vg5k_state *vg5k = (vg5k_state *)space->machine->driver_data; |
| 103 | |
| 104 | ef9345_w(vg5k->ef9345, vg5k->ef9345_offset, data); |
| 105 | } |
| 106 | |
| 107 | |
| 108 | READ8_HANDLER ( cassette_r ) |
| 109 | { |
| 110 | vg5k_state *vg5k = (vg5k_state *)space->machine->driver_data; |
| 111 | double level; |
| 112 | |
| 113 | level = cassette_input(vg5k->cassette); |
| 114 | |
| 115 | return (level > 0.03) ? 0xff : 0x00; |
| 116 | } |
| 117 | |
| 118 | |
| 119 | WRITE8_HANDLER ( cassette_w ) |
| 120 | { |
| 121 | vg5k_state *vg5k = (vg5k_state *)space->machine->driver_data; |
| 122 | |
| 123 | dac_signed_data_w(vg5k->dac, data <<2); |
| 124 | } |
| 125 | |
| 126 | |
| 43 | 127 | static ADDRESS_MAP_START( vg5k_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 44 | 128 | ADDRESS_MAP_UNMAP_HIGH |
| 45 | 129 | AM_RANGE( 0x0000, 0x3fff ) AM_ROM |
| 46 | | AM_RANGE( 0x4000, 0xffff ) AM_RAM |
| 130 | AM_RANGE( 0x4000, 0x7fff ) AM_RAM |
| 131 | AM_RANGE( 0x8000, 0xffff ) AM_NOP /* messram expansion memory */ |
| 47 | 132 | ADDRESS_MAP_END |
| 48 | 133 | |
| 49 | 134 | static ADDRESS_MAP_START( vg5k_io , ADDRESS_SPACE_IO, 8) |
| 50 | 135 | ADDRESS_MAP_UNMAP_HIGH |
| 136 | ADDRESS_MAP_GLOBAL_MASK (0xff) |
| 137 | |
| 138 | /* joystick */ |
| 139 | AM_RANGE( 0x07, 0x07 ) AM_READ_PORT("JOY0") |
| 140 | AM_RANGE( 0x08, 0x08 ) AM_READ_PORT("JOY1") |
| 141 | |
| 142 | /* printer */ |
| 143 | AM_RANGE( 0x10, 0x10 ) AM_READ(printer_r) |
| 144 | AM_RANGE( 0x11, 0x11 ) AM_WRITE(printer_w) |
| 145 | |
| 146 | /* keyboard */ |
| 147 | AM_RANGE( 0x80, 0x80 ) AM_READ_PORT("ROW1") |
| 148 | AM_RANGE( 0x81, 0x81 ) AM_READ_PORT("ROW2") |
| 149 | AM_RANGE( 0x82, 0x82 ) AM_READ_PORT("ROW3") |
| 150 | AM_RANGE( 0x83, 0x83 ) AM_READ_PORT("ROW4") |
| 151 | AM_RANGE( 0x84, 0x84 ) AM_READ_PORT("ROW5") |
| 152 | AM_RANGE( 0x85, 0x85 ) AM_READ_PORT("ROW6") |
| 153 | AM_RANGE( 0x86, 0x86 ) AM_READ_PORT("ROW7") |
| 154 | AM_RANGE( 0x87, 0x87 ) AM_READ_PORT("ROW8") |
| 155 | |
| 156 | /* EF9345 */ |
| 157 | AM_RANGE( 0x8f, 0x8f ) AM_WRITE(ef9345_offset_w) |
| 158 | AM_RANGE( 0xcf, 0xcf ) AM_READWRITE(ef9345_io_r, ef9345_io_w) |
| 159 | |
| 160 | /* cassette */ |
| 161 | AM_RANGE(0xaf,0xaf) AM_READWRITE( cassette_r, cassette_w) |
| 51 | 162 | ADDRESS_MAP_END |
| 52 | 163 | |
| 53 | 164 | /* Input ports */ |
| 54 | 165 | static INPUT_PORTS_START( vg5k ) |
| 166 | |
| 167 | PORT_START("ROW1") |
| 168 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_HOME) PORT_NAME("HOME") |
| 169 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_UNUSED |
| 170 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LSHIFT) PORT_NAME("SHIFT") |
| 171 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LEFT) PORT_NAME("LEFT") |
| 172 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_RIGHT) PORT_NAME("RIGHT") |
| 173 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DOWN) PORT_NAME("DOWN") |
| 174 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_LCONTROL) PORT_NAME("CTRL") |
| 175 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_INSERT) PORT_NAME("INS") |
| 176 | |
| 177 | PORT_START("ROW2") |
| 178 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_NAME("RUN") |
| 179 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q') |
| 180 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 181 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CAPSLOCK) PORT_NAME("CAPSLOCK") |
| 182 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_UNUSED |
| 183 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ENTER) PORT_NAME("ENTER") |
| 184 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_UP) PORT_NAME("UP") |
| 185 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 186 | |
| 187 | PORT_START("ROW3") |
| 188 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W') |
| 189 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X') |
| 190 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 191 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V') |
| 192 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 193 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 194 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR(':') |
| 195 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') |
| 196 | |
| 197 | PORT_START("ROW4") |
| 198 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S') |
| 199 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 200 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') |
| 201 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') |
| 202 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') |
| 203 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') |
| 204 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') |
| 205 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') |
| 206 | |
| 207 | PORT_START("ROW5") |
| 208 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') |
| 209 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR('*') |
| 210 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 211 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G') |
| 212 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U') |
| 213 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I') |
| 214 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O') |
| 215 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P') |
| 216 | |
| 217 | PORT_START("ROW6") |
| 218 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_UNUSED |
| 219 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 220 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') |
| 221 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_NAME("..") |
| 222 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') |
| 223 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') |
| 224 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') |
| 225 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') |
| 226 | |
| 227 | PORT_START("ROW7") |
| 228 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') |
| 229 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR('+') |
| 230 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R') |
| 231 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T') |
| 232 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') |
| 233 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PGUP) PORT_CHAR('<') |
| 234 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PGDN) PORT_NAME("PRINT") |
| 235 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 236 | |
| 237 | PORT_START("ROW8") |
| 238 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') |
| 239 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSPACE) PORT_NAME("<--") |
| 240 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N') |
| 241 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J') |
| 242 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H') |
| 243 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K') |
| 244 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L') |
| 245 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 246 | |
| 247 | PORT_START("JOY0") |
| 248 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(1) |
| 249 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1) |
| 250 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(1) |
| 251 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(1) |
| 252 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1) |
| 253 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_UNUSED |
| 254 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_UNUSED |
| 255 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_UNUSED |
| 256 | |
| 257 | PORT_START("JOY1") |
| 258 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(2) |
| 259 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(2) |
| 260 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(2) |
| 261 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(2) |
| 262 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(2) |
| 263 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_UNUSED |
| 264 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_UNUSED |
| 265 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_UNUSED |
| 266 | |
| 55 | 267 | INPUT_PORTS_END |
| 56 | 268 | |
| 57 | 269 | |
| 270 | static TIMER_CALLBACK( z80_irq ) |
| 271 | { |
| 272 | cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); |
| 273 | } |
| 274 | |
| 275 | static TIMER_DEVICE_CALLBACK( vg5k_scanline ) |
| 276 | { |
| 277 | vg5k_state *vg5k = (vg5k_state *)timer->machine->driver_data; |
| 278 | |
| 279 | ef9345_scanline(vg5k->ef9345, (UINT16)param); |
| 280 | } |
| 281 | |
| 282 | |
| 283 | static MACHINE_START( vg5k ) |
| 284 | { |
| 285 | vg5k_state *vg5k = (vg5k_state *)machine->driver_data; |
| 286 | |
| 287 | vg5k->ef9345 = devtag_get_device(machine, "ef9345"); |
| 288 | vg5k->dac = devtag_get_device(machine, "dac"); |
| 289 | vg5k->printer = devtag_get_device(machine, "printer"); |
| 290 | vg5k->cassette = devtag_get_device(machine, "cassette"); |
| 291 | |
| 292 | timer_pulse(machine, ATTOTIME_IN_MSEC(20), NULL, 0, z80_irq); |
| 293 | |
| 294 | state_save_register_global(machine, vg5k->ef9345_offset); |
| 295 | } |
| 296 | |
| 58 | 297 | static MACHINE_RESET( vg5k ) |
| 59 | 298 | { |
| 299 | vg5k_state *vg5k = (vg5k_state *)machine->driver_data; |
| 300 | |
| 301 | vg5k->ef9345_offset = 0; |
| 60 | 302 | } |
| 61 | 303 | |
| 62 | 304 | static VIDEO_START( vg5k ) |
| r8223 | r8224 | |
| 65 | 307 | |
| 66 | 308 | static VIDEO_UPDATE( vg5k ) |
| 67 | 309 | { |
| 310 | vg5k_state *vg5k = (vg5k_state *)screen->machine->driver_data; |
| 311 | |
| 312 | video_update_ef9345(vg5k->ef9345, bitmap, cliprect); |
| 313 | |
| 68 | 314 | return 0; |
| 69 | 315 | } |
| 70 | 316 | |
| r8223 | r8224 | |
| 97 | 343 | for (c = 0; c < 4; c++) |
| 98 | 344 | for (d = 0; d < 64; d+=4) |
| 99 | 345 | FNT[dest++]=FNT[a|b|c|d]; |
| 346 | |
| 347 | |
| 348 | /* install expansion memory*/ |
| 349 | const address_space *program = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 350 | UINT8 *ram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 351 | UINT16 ram_size = messram_get_size(devtag_get_device(machine, "messram")); |
| 352 | |
| 353 | if (ram_size > 0x4000) |
| 354 | memory_install_ram(program, 0x8000, 0x3fff + ram_size, 0, 0, ram); |
| 100 | 355 | } |
| 101 | 356 | |
| 357 | |
| 358 | static const ef9345_config vg5k_ef9345_config = |
| 359 | { |
| 360 | "gfx1", /* charset */ |
| 361 | 336, /* screen width */ |
| 362 | 300 /* screen height */ |
| 363 | }; |
| 364 | |
| 365 | static const struct CassetteOptions vg5kr_cassette_options = |
| 366 | { |
| 367 | 1, /* channels */ |
| 368 | 16, /* bits per sample */ |
| 369 | 44100 /* sample frequency */ |
| 370 | }; |
| 371 | |
| 372 | static const cassette_config vg5k_cassette_config = |
| 373 | { |
| 374 | cassette_default_formats, |
| 375 | &vg5kr_cassette_options, |
| 376 | (cassette_state)(CASSETTE_STOPPED | CASSETTE_MASK_SPEAKER) |
| 377 | }; |
| 378 | |
| 379 | |
| 102 | 380 | static MACHINE_DRIVER_START( vg5k ) |
| 381 | MDRV_DRIVER_DATA(vg5k_state) |
| 382 | |
| 103 | 383 | /* basic machine hardware */ |
| 104 | 384 | MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz) |
| 105 | 385 | MDRV_CPU_PROGRAM_MAP(vg5k_mem) |
| 106 | 386 | MDRV_CPU_IO_MAP(vg5k_io) |
| 107 | 387 | |
| 388 | MDRV_TIMER_ADD_SCANLINE("vg5k_scanline", vg5k_scanline, "screen", 0, 10) |
| 389 | |
| 390 | MDRV_EF9345_ADD("ef9345", vg5k_ef9345_config) |
| 391 | |
| 392 | MDRV_MACHINE_START(vg5k) |
| 108 | 393 | MDRV_MACHINE_RESET(vg5k) |
| 109 | 394 | |
| 110 | 395 | /* video hardware */ |
| r8223 | r8224 | |
| 112 | 397 | MDRV_SCREEN_REFRESH_RATE(50) |
| 113 | 398 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 114 | 399 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 115 | | MDRV_SCREEN_SIZE(640, 480) |
| 116 | | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 400 | MDRV_SCREEN_SIZE(336, 300) |
| 401 | MDRV_SCREEN_VISIBLE_AREA(00, 336-1, 00, 270-1) |
| 117 | 402 | |
| 118 | 403 | MDRV_GFXDECODE(vg5k) |
| 119 | 404 | MDRV_PALETTE_LENGTH(8) |
| r8223 | r8224 | |
| 121 | 406 | MDRV_VIDEO_START(vg5k) |
| 122 | 407 | MDRV_VIDEO_UPDATE(vg5k) |
| 123 | 408 | |
| 409 | |
| 410 | /* sound hardware */ |
| 411 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 412 | MDRV_SOUND_ADD("dac", DAC, 0) |
| 413 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 414 | |
| 415 | /* cassette */ |
| 416 | MDRV_SOUND_WAVE_ADD("wave", "cassette") |
| 417 | MDRV_SOUND_ROUTE(0, "mono", 0.1) |
| 418 | |
| 419 | MDRV_CASSETTE_ADD( "cassette", vg5k_cassette_config ) |
| 420 | |
| 421 | /* printer */ |
| 422 | MDRV_PRINTER_ADD("printer") |
| 423 | |
| 124 | 424 | /* internal ram */ |
| 125 | 425 | MDRV_RAM_ADD("messram") |
| 126 | | MDRV_RAM_DEFAULT_SIZE("24K") |
| 426 | MDRV_RAM_DEFAULT_SIZE("16K") |
| 427 | MDRV_RAM_EXTRA_OPTIONS("32K,48k") |
| 127 | 428 | MACHINE_DRIVER_END |
| 128 | 429 | |
| 129 | 430 | /* ROM definition */ |