Previous 15994 Revisions Next

r8423 Wednesday 7th July, 2010 at 13:57:35 UTC by Fabio Priuli
[VG5K] Implemented double height chars (fixing US Rally intro) and 80 columns mode [Sandro Ronco]
[src/mess/drivers]vg5k.c
[src/mess/formats]vg5k_cas.c
[src/mess/video]ef9345.c ef9345.h

src/mess/video/ef9345.c
r8422r8423
1515#include "emu.h"
1616#include "ef9345.h"
1717
18#define MODE24x40   0
19#define MODEVAR40   1
20#define MODE8x80   2
21#define MODE12x80   3
22#define MODE16x40   4
23
1824typedef struct _ef9345_t ef9345_t;
1925struct _ef9345_t
2026{
21   const ef9345_config *conf;
27   screen_device *screen;         //screen we are acting on
2228
2329   UINT8 bf;                  //busy flag
2430   UINT8 char_mode;            //40 or 80 chars for line
r8422r8423
3036   UINT8 TGS,MAT,PAT,DOR,ROR;      //registres acces indirect
3137   UINT8 border[80];            //caractere du cadre
3238   UINT8 *block;               //pointeur block courant
33   UINT8 *matrice;               //pointeur matrice caractere courant
3439   UINT8 *char_ptr[16];         //pointeurs polices de caracteres
3540   UINT16 blink;               //etat du clignotement
3641   UINT8 dial;                  //cadran en cours d'affichage
r8422r8423
4449
4550   emu_timer *busy_timer;
4651   emu_timer *blink_timer;
47
4852};
4953
5054static TIMER_CALLBACK( ef9345_done );
r8422r8423
7579   UINT16 i, j;
7680
7781   /* verify size limit */
78   if (y * 10 >= ef9345->conf->height || x * 8 >= ef9345->conf->width)
82   if (y * 10 >= ef9345->screen->height() || x * 8 >= ef9345->screen->width())
7983      return;
8084
8185   for(i = 0; i < 10; i++)
r8422r8423
9195   int i, j;
9296
9397   /* verify size limit */
94   if (y * 10 >= ef9345->conf->height || x * 6 >= ef9345->conf->width)
98   if (y * 10 >= ef9345->screen->height() || x * 6 >= ef9345->screen->width())
9599      return;
96100
97101   for(i = 0; i < 10; i++)
r8422r8423
107111{
108112   UINT8 i;
109113   ef9345->char_mode = ((ef9345->PAT & 0x80) >> 5) | ((ef9345->TGS & 0xc0) >> 6);
114   UINT16 new_width = (ef9345->char_mode == MODE12x80 || ef9345->char_mode == MODE8x80) ? 492 : 336;
110115
116   if (ef9345->screen->width() != new_width)
117   {
118      rectangle visarea = ef9345->screen->visible_area();
119      visarea.max_x = new_width - 1;
120
121      ef9345->screen->configure(new_width, ef9345->screen->height(), visarea, ef9345->screen->frame_period().attoseconds);
122   }
123
111124   //couleur de bordure
112125   for(i = 0; i < 80; i++)
113126      ef9345->border[i] = ef9345->MAT & 0x07;
r8422r8423
295308}
296309
297310// Display bichrome character (40 columns)
298void Bichrome40(ef9345_t *ef9345, int iblock, int x, int y, int c0, int c1, int insert, int flash, int conceal, int negative, int underline)
311void Bichrome40(ef9345_t *ef9345, UINT8 *matrice, int iblock, int x, int y, int c0, int c1, int insert, int flash, int conceal, int negative, int underline)
299312{
300313   UINT8 i, j, pix[80];
301314
r8422r8423
357370
358371   for(i = 0; i < 10; i++)
359372   {
360      pix[j++] = (*(ef9345->matrice + 4 * i) & 0x01) ? c1 : c0;
361      pix[j++] = (*(ef9345->matrice + 4 * i) & 0x02) ? c1 : c0;
362      pix[j++] = (*(ef9345->matrice + 4 * i) & 0x04) ? c1 : c0;
363      pix[j++] = (*(ef9345->matrice + 4 * i) & 0x08) ? c1 : c0;
364      pix[j++] = (*(ef9345->matrice + 4 * i) & 0x10) ? c1 : c0;
365      pix[j++] = (*(ef9345->matrice + 4 * i) & 0x20) ? c1 : c0;
366      pix[j++] = (*(ef9345->matrice + 4 * i) & 0x40) ? c1 : c0;
367      pix[j++] = (*(ef9345->matrice + 4 * i) & 0x80) ? c1 : c0;
373      pix[j++] = (*(matrice + 4 * i) & 0x01) ? c1 : c0;
374      pix[j++] = (*(matrice + 4 * i) & 0x02) ? c1 : c0;
375      pix[j++] = (*(matrice + 4 * i) & 0x04) ? c1 : c0;
376      pix[j++] = (*(matrice + 4 * i) & 0x08) ? c1 : c0;
377      pix[j++] = (*(matrice + 4 * i) & 0x10) ? c1 : c0;
378      pix[j++] = (*(matrice + 4 * i) & 0x20) ? c1 : c0;
379      pix[j++] = (*(matrice + 4 * i) & 0x40) ? c1 : c0;
380      pix[j++] = (*(matrice + 4 * i) & 0x80) ? c1 : c0;
368381
369382   }
370383
r8422r8423
380393   if(ef9345->dial > 0)
381394      zoom(ef9345, pix, ef9345->dial);
382395
396   //doubles the height of the char
397   if (ef9345->MAT & 0x80)
398      zoom(ef9345, pix, (y & 0x01) ? 0x0c : 0x03);
399
383400   draw_char_40(ef9345, pix, x + 1 , y + 1);
384401}
385402
r8422r8423
491508void makechar_16x40(ef9345_t *ef9345, int x, int y)
492509{
493510   int i, a, b, type, c0, c1, f, m, n, u, iblock;
511   UINT8* matrice;
494512
495513   //recherche des octets b, a (precedent si double largeur)
496   iblock = indexblock(ef9345, x, y);
514   iblock = (ef9345->MAT & 0x80 && y > 1) ? indexblock(ef9345, x, y / 2) : indexblock(ef9345, x, y);
497515   a = ef9345->block[iblock];
498516   b = ef9345->block[iblock + 0x800];
499517
r8422r8423
502520
503521   //adresse de la matrice de definition du caractere
504522   type = ((b & 0x80) >> 4) | ((a & 0x80) >> 6);
505   ef9345->matrice = ef9345->char_ptr[type] + ((b & 0x7f) >> 2) * 0x40 + (b & 0x03);
523   matrice = ef9345->char_ptr[type] + ((b & 0x7f) >> 2) * 0x40 + (b & 0x03);
506524   if((b & 0xe0) == 0x80)
507      ef9345->matrice = ef9345->char_ptr[0x03]; //negative space
525      matrice = ef9345->char_ptr[0x03]; //negative space
508526
509527   //attributs latches
510528   if(x == 0) ef9345->latchm = ef9345->latchi = ef9345->latchu = ef9345->latchc0 = 0;
r8422r8423
521539   u = ef9345->latchu;                  //underline
522540
523541   //affichage
524   Bichrome40(ef9345, iblock, x, y, c0, c1, i, f, m, n, u);
542   Bichrome40(ef9345, matrice, iblock, x, y, c0, c1, i, f, m, n, u);
525543}
526544
527545// Affichage d'un caractere 24 bits 40 colonnes
528546void makechar_24x40(ef9345_t *ef9345, int x, int y)
529547{
530548   int i, a, b, c, c0, c1, f, m, n, u, iblock;
549   UINT8* matrice;
531550
532551   //recherche des octets c, b, a
533   //iblock = (ef9345->MAT & 0x80) ? indexblock(x, y / 2) : indexblock(x, y);
534   //la double hauteur est maintenant prise en compte dans Displayscreen()
535   iblock = indexblock(ef9345, x, y);
552   iblock = (ef9345->MAT & 0x80 && y > 1) ? indexblock(ef9345,x, y / 2) : indexblock(ef9345, x, y);
536553   c = ef9345->block[iblock]; b = ef9345->block[iblock + 0x800]; a = ef9345->block[iblock + 0x1000];
537554   if((b & 0xc0) == 0xc0) {Quadrichrome40(ef9345, c, b, a, x, y); return;}
538555
r8422r8423
540557   Cadran(ef9345, x, (b & 0x02) + ((b & 0x08) >> 3));
541558
542559   //adresse de la matrice de definition du caractere
543   ef9345->matrice = ef9345->char_ptr[(b & 0xf0) >> 4] + ((c & 0x7f) >> 2) * 0x40 + (c & 0x03);
560   matrice = ef9345->char_ptr[(b & 0xf0) >> 4] + ((c & 0x7f) >> 2) * 0x40 + (c & 0x03);
544561
545562   //attributs du caractere
546563   c0 = a & 0x07;        //background
r8422r8423
552569   u = (((b & 0x60) == 0) || ((b & 0xc0) == 0x40)) ? ((b & 0x10) >> 4) : 0;
553570
554571   //affichage
555   Bichrome40(ef9345, iblock, x, y, c0, c1, i, f, m, n, u);
572   Bichrome40(ef9345, matrice, iblock, x, y, c0, c1, i, f, m, n, u);
556573}
557574
558575
r8422r8423
561578{
562579   int iblock;
563580   iblock = indexblock(ef9345, x, y);
564   Bichrome80(ef9345, ef9345->block[iblock], (ef9345->block[iblock + 0x1000] >> 4) & 0x0f, 2 * x + 2, y + 1);
565   Bichrome80(ef9345, ef9345->block[iblock + 0x800], ef9345->block[iblock + 0x1000] & 0x0f, 2 * x + 3, y + 1);
581   Bichrome80(ef9345, ef9345->block[iblock], (ef9345->block[iblock + 0x1000] >> 4) & 0x0f, 2 * x + 1, y + 1);
582   Bichrome80(ef9345, ef9345->block[iblock + 0x800], ef9345->block[iblock + 0x1000] & 0x0f, 2 * x + 2, y + 1);
566583}
567584
568585void makechar(ef9345_t *ef9345, int x, int y)
569586{
570587   switch (ef9345->char_mode)
571588   {
572      case 0:
589      case MODE24x40:
573590         makechar_24x40(ef9345, x, y);
574591         break;
575      case 3:
592      case MODEVAR40:
593         //TODO
594         break;
595      case MODE8x80:
596         //TODO
597         break;
598      case MODE12x80:
576599         makechar_12x80(ef9345, x, y);
577600         break;
578      case 4:
601      case MODE16x40:
579602         makechar_16x40(ef9345, x, y);
580603         break;
581604      default:
r8422r8423
859882   ef9345->bf = 0;
860883}
861884
885void draw_border(ef9345_t *ef9345, UINT8 line)
886{
887   UINT8 i;
888
889   if (ef9345->char_mode == MODE12x80 || ef9345->char_mode == MODE8x80)
890      for(i = 0; i < 82; i++)
891         draw_char_80(ef9345, ef9345->border, i, line);
892   else
893      for(i = 0; i < 42; i++)
894         draw_char_40(ef9345, ef9345->border, i, line);
895}
896
862897void ef9345_scanline(running_device *device, UINT16 scanline)
863898{
864899   ef9345_t *ef9345 = get_safe_token(device);
r8422r8423
869904
870905   set_busy_flag(ef9345, 104);
871906
872   draw_char_40(ef9345, ef9345->border, 0, (scanline / 10) + 1);
873   draw_char_40(ef9345, ef9345->border, 41, (scanline / 10) + 1);
907   if (ef9345->char_mode == MODE12x80 || ef9345->char_mode == MODE8x80)
908   {
909      draw_char_80(ef9345, ef9345->border, 0, (scanline / 10) + 1);
910      draw_char_80(ef9345, ef9345->border, 81, (scanline / 10) + 1);
911   }
912   else
913   {
914      draw_char_40(ef9345, ef9345->border, 0, (scanline / 10) + 1);
915      draw_char_40(ef9345, ef9345->border, 41, (scanline / 10) + 1);
916   }
874917
875918   if(scanline == 0)
876919   {
877920      ef9345->state |= 0x04;
878      for(i = 0; i < 42; i++)
879         draw_char_40(ef9345, ef9345->border, i, 0);
880
921      draw_border(ef9345, 0);
881922      if(ef9345->PAT & 1)
882923         for(i = 0; i < 40; i++)
883924            makechar(ef9345, i, (scanline / 10));
r8422r8423
891932         for(i = 0; i < 40; i++)
892933            makechar(ef9345, i, (scanline / 10));
893934      else
894         for(i = 0; i < 42; i++)
895            draw_char_40(ef9345, ef9345->border, i, (scanline / 10));
935         draw_border(ef9345, scanline / 10);
896936   }
897937   else if(scanline < 250)
898938   {
r8422r8423
900940         for(i = 0; i < 40; i++)
901941            makechar(ef9345, i, (scanline / 10));
902942      else
903         for(i = 0; i < 42; i++)
904            draw_char_40(ef9345, ef9345->border, i, (scanline / 10));
943         draw_border(ef9345, scanline / 10);
905944
906945      if(scanline == 240)
907         for(i = 0; i < 42; i++)
908            draw_char_40(ef9345, ef9345->border, i, 26);
946         draw_border(ef9345, 26);
909947   }
910948}
911949
r8422r8423
958996static DEVICE_START( ef9345 )
959997{
960998   ef9345_t *ef9345 = get_safe_token(device);
999   const ef9345_config *config = (ef9345_config*)device->baseconfig().static_config();
9611000
9621001   /* validate arguments */
9631002   assert(device != NULL);
9641003
965   ef9345->conf = (ef9345_config*)device->baseconfig().static_config();
1004   ef9345->charset = memory_region(device->machine, config->charset);
9661005
967   ef9345->charset = memory_region(device->machine, ef9345->conf->charset);
1006   ef9345->screen = device->machine->device<screen_device>(config->screen_tag);
1007   assert(ef9345->screen != NULL);
9681008
9691009   ef9345->busy_timer = timer_alloc(device->machine, ef9345_done, (void *)device);
9701010   ef9345->blink_timer = timer_alloc(device->machine, blinking, (void *)device);
9711011
972   ef9345->screen_out = auto_bitmap_alloc(device->machine, ef9345->conf->width , ef9345->conf->height , BITMAP_FORMAT_INDEXED16);
1012   ef9345->screen_out = auto_bitmap_alloc(device->machine, 496, ef9345->screen->height() , BITMAP_FORMAT_INDEXED16);
9731013
9741014   timer_adjust_periodic(ef9345->blink_timer, ATTOTIME_IN_MSEC(500), 0, ATTOTIME_IN_MSEC(500));
9751015
src/mess/video/ef9345.h
r8422r8423
2323typedef struct _ef9345_config ef9345_config;
2424struct _ef9345_config
2525{
26   const char* charset;
27   UINT16 width;
28   UINT16 height;
26   const char *screen_tag;
27   const char *charset;
2928};
3029
3130/***************************************************************************
src/mess/formats/vg5k_cas.c
r8422r8423
117117   data_pos = 0;
118118   sample_count = 0;
119119
120   /* file has to start with an head block */
121   if (casdata[0] != 0xd3  || casdata[1] != 0xd3 || casdata[2] != 0xd3)
122      return -1;
123
120124   /* on the entire file*/
121125    while( data_pos < k7_size )
122126   {
123      UINT16   block_size;
127      UINT16   block_size = 0;
124128
125129      /* Identify type of block */
126130      if (casdata[data_pos] == 0xd3)
r8422r8423
146150         sample_count += vg5k_k7_synchro( buffer, sample_count, 7200);
147151      }
148152      else
149         return -1;
153      {
154         /* tries to handle files that do not respect the size declared in the head block */
155         while (data_pos < k7_size && casdata[data_pos] != 0xd3 && casdata[data_pos] != 0xd6)
156            data_pos++;
157      }
150158
151159      /* Data samples */
152160      for ( ; block_size ; data_pos++, block_size-- )
153161        {
154162          /* Make sure there are enough bytes left */
155          if ( data_pos > k7_size )
163          if (data_pos > k7_size)
156164            return -1;
157165
158166          sample_count += vg5k_cas_byte( buffer, sample_count, casdata[data_pos] );
r8422r8423
174182********************************************************************/
175183static int vg5k_k7_fill_wave(INT16 *buffer, int sample_count, UINT8 *bytes)
176184{
177   return vg5k_handle_tap( buffer, bytes );
185   return vg5k_handle_tap(buffer, bytes);
178186}
179187
180188
src/mess/drivers/vg5k.c
r8422r8423
373373
374374static const ef9345_config vg5k_ef9345_config =
375375{
376   "gfx1",            /* charset */
377   336,            /* screen width */
378   300               /* screen height */
376   "screen",         /* screen we are acting on */
377   "gfx1"            /* charset */
379378};
380379
381380static const struct CassetteOptions vg5k_cassette_options =
r8422r8423
423422   MDRV_VIDEO_START(vg5k)
424423   MDRV_VIDEO_UPDATE(vg5k)
425424
426
427425   /* sound hardware */
428426   MDRV_SPEAKER_STANDARD_MONO("mono")
429427   MDRV_SOUND_ADD("dac", DAC, 0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team