Previous 15994 Revisions Next

r4173 Wednesday 21st January, 2009 at 12:43:37 UTC by Curt Coder
[NEWBRAIN] Added video.
[src/mess/drivers]newbrain.c
[src/mess/includes]newbrain.h
[src/mess/video]newbrain.c

src/mess/video/newbrain.c
r4172r4173
33
44static VIDEO_START( newbrain )
55{
6//   newbrain_state *state = machine->driver_data;
6   newbrain_state *state = machine->driver_data;
77
8   /* find memory regions */
9
10   state->char_rom = memory_region(machine, "chargen");
11
812   /* register for state saving */
913
1014//   state_save_register_global(machine, state->);
1115}
1216
17static void newbrain_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
18{
19   newbrain_state *state = machine->driver_data;
20
21   const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM);
22
23   int y, sx;
24   int columns = (state->tvctl & NEWBRAIN_VIDEO_80L) ? 80 : 40;
25   int excess = (state->tvctl & NEWBRAIN_VIDEO_32_40) ? 24 : 4;
26   int ucr = (state->tvctl & NEWBRAIN_VIDEO_UCR) ? 1 : 0;
27   int fs = (state->tvctl & NEWBRAIN_VIDEO_FS) ? 1 : 0;
28   int rv = (state->tvctl & NEWBRAIN_VIDEO_RV) ? 1 : 0;
29   int gr = 0;
30
31   UINT16 videoram_addr = state->tvram;
32   UINT8 rc = 0;
33
34   for (y = 0; y < 250; y++)
35   {
36      int x = 0;
37
38      for (sx = 0; sx < columns; sx++)
39      {
40         int bit;
41
42         UINT8 videoram_data = memory_read_byte_8le(program, videoram_addr + sx);
43         UINT8 charrom_data;
44
45         if (gr)
46         {
47            /* render video ram data */
48            charrom_data = videoram_data;
49         }
50         else
51         {
52            /* render character rom data */
53            UINT16 charrom_addr = (rc << 8) | ((BIT(videoram_data, 7) & fs) << 7) | (videoram_data & 0x7f);
54            charrom_data = state->char_rom[charrom_addr & 0xfff];
55
56            if ((videoram_data & 0x80) && !fs)
57            {
58               /* invert character */
59               charrom_data ^= 0xff;
60            }
61
62            if ((videoram_data & 0x60) && !ucr)
63            {
64               /* strip bit D0 */
65               charrom_data &= 0xfe;
66            }
67         }
68
69         for (bit = 0; bit < 8; bit++)
70         {
71            int color = BIT(charrom_data, 7) ^ rv;
72
73            *BITMAP_ADDR16(bitmap, y, x++) = color;
74
75            if (columns == 40)
76            {
77               *BITMAP_ADDR16(bitmap, y, x++) = color;
78            }
79
80            charrom_data <<= 1;
81         }
82      }
83
84      /* increase row counter */
85      rc++;
86
87      if (rc == (ucr ? 8 : 10))
88      {
89         /* reset row counter */
90         rc = 0;
91
92         videoram_addr += columns;
93         videoram_addr += excess;
94      }
95   }
96}
97
1398static VIDEO_UPDATE( newbrain )
1499{
100   newbrain_state *state = screen->machine->driver_data;
101
102   if (state->enrg1 & NEWBRAIN_ENRG1_TVP)
103   {
104      newbrain_update(screen->machine, bitmap, cliprect);
105   }
106   else
107   {
108      bitmap_fill(bitmap, cliprect, 0);
109   }
110
15111   return 0;
16112}
17113
r4172r4173
22118   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
23119   MDRV_SCREEN_REFRESH_RATE(50)
24120   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
25   MDRV_SCREEN_SIZE(640, 400)
26   MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 399)
121   MDRV_SCREEN_SIZE(640, 250)
122   MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 249)
27123
28124   MDRV_PALETTE_LENGTH(2)
29125   MDRV_PALETTE_INIT(black_and_white)
src/mess/includes/newbrain.h
r4172r4173
1111#define FDC_Z80_TAG         "416"
1212#define NEC765_TAG         "418"
1313
14#define NEWBRAIN_VIDEO_RV         0x01
15#define NEWBRAIN_VIDEO_FS         0x02
16#define NEWBRAIN_VIDEO_32_40      0x04
17#define NEWBRAIN_VIDEO_UCR         0x08
18#define NEWBRAIN_VIDEO_80L         0x40
14#define NEWBRAIN_ENRG1_CLK            0x01
15#define NEWBRAIN_ENRG1_TVP            0x04
16#define NEWBRAIN_ENRG1_CTS            0x10
17#define NEWBRAIN_ENRG1_DO            0x20
18#define NEWBRAIN_ENRG1_PO            0x80
19#define NEWBRAIN_ENRG1_UST_BIT_1_MASK   0x30
20#define NEWBRAIN_ENRG1_UST_BIT_0_MASK   0xc0
1921
22#define NEWBRAIN_VIDEO_RV            0x01
23#define NEWBRAIN_VIDEO_FS            0x02
24#define NEWBRAIN_VIDEO_32_40         0x04
25#define NEWBRAIN_VIDEO_UCR            0x08
26#define NEWBRAIN_VIDEO_80L            0x40
27
2028typedef struct _newbrain_state newbrain_state;
2129struct _newbrain_state
2230{
r4172r4173
5866   int tvcnsl;            /* TV console required */
5967   int tvctl;            /* TV control register */
6068   UINT16 tvram;         /* TV start address */
69   UINT8 *char_rom;      /* character ROM */
6170
6271   /* user bus state */
6372   UINT8 user;           
src/mess/drivers/newbrain.c
r4172r4173
4242
4343   TODO:
4444
45   - make it boot!
46   - video excess
4547   - escape key
4648   - COP420 microbus
47   - video
4849   - tape
4950   - layout for the 16-segment displays
5051
r4172r4173
7071
7172/* Enable/Status */
7273
73#define NEWBRAIN_ENRG1_CLK   0x01
74#define NEWBRAIN_ENRG1_TVP   0x04
75#define NEWBRAIN_ENRG1_CTS   0x10
76#define NEWBRAIN_ENRG1_DO   0x20
77#define NEWBRAIN_ENRG1_PO   0x80
78#define NEWBRAIN_ENRG1_UST_BIT_1_MASK   0x30
79#define NEWBRAIN_ENRG1_UST_BIT_0_MASK   0xc0
80
8174static WRITE8_HANDLER( enrg1_w )
8275{
8376   /*
r4172r4173
487480
488481/* Video */
489482
483static void newbrain_tvram_w(running_machine *machine, UINT8 data, int a6)
484{
485   newbrain_state *state = machine->driver_data;
486
487   /* latch video address counter bits A5-A0 */
488   state->tvram = (state->tvctl & NEWBRAIN_VIDEO_80L) ? 0x04 : 0x02;
489
490   /* latch video address counter bit A6 */
491   state->tvram |= a6 << 6;
492
493   /* latch data to video address counter bits A14-A7 */
494   state->tvram = (data << 7);
495}
496
490497static READ8_HANDLER( tvl_r )
491498{
492   newbrain_state *state = space->machine->driver_data;
499   UINT8 data = 0xff;
493500
494   if (offset)
495   {
496      state->tvram = 0xff;
497   }
498   else
499   {
500      state->tvram = 0x1ff;
501   }
501   newbrain_tvram_w(space->machine, data, !offset);
502502
503   return 0xff;
503   return data;
504504}
505505
506506static WRITE8_HANDLER( tvl_w )
507507{
508   newbrain_state *state = space->machine->driver_data;
509
510   if (offset)
511   {
512      state->tvram = data;
513   }
514   else
515   {
516      state->tvram = 0x100 | data;
517   }
508   newbrain_tvram_w(space->machine, data, !offset);
518509}
519510
520511static WRITE8_HANDLER( tvctl_w )
r4172r4173
14391430   ROM_LOAD( "d417-2.rom", 0x0000, 0x2000, CRC(e8bda8b9) SHA1(c85a76a5ff7054f4ef4a472ce99ebaed1abd269c) )
14401431
14411432   ROM_REGION( 0x1000, "chargen", 0 )
1442   ROM_LOAD( "8248r7.453", 0x0000, 0x1000, NO_DUMP )
1433   ROM_LOAD( "8248r7.453", 0x0000, 0x1000, BAD_DUMP CRC(46ecbc65) SHA1(3fe064d49a4de5e3b7383752e98ad35a674e26dd) )
14431434ROM_END
14441435
14451436ROM_START( newbraim )
r4172r4173
14511442   ROM_LOAD( "cop420.419", 0x000, 0x400, NO_DUMP )
14521443
14531444   ROM_REGION( 0x1000, "chargen", 0 )
1454   ROM_LOAD( "8248r7.453", 0x0000, 0x1000, NO_DUMP )
1445   ROM_LOAD( "8248r7.453", 0x0000, 0x1000, BAD_DUMP CRC(46ecbc65) SHA1(3fe064d49a4de5e3b7383752e98ad35a674e26dd) )
14551446ROM_END
14561447
14571448ROM_START( newbraia )
r4172r4173
14791470   ROM_LOAD( "cop420.419", 0x000, 0x400, NO_DUMP )
14801471
14811472   ROM_REGION( 0x1000, "chargen", 0 )
1482   ROM_LOAD( "8248r7.453", 0x0000, 0x1000, NO_DUMP )
1473   ROM_LOAD( "8248r7.453", 0x0000, 0x1000, BAD_DUMP CRC(46ecbc65) SHA1(3fe064d49a4de5e3b7383752e98ad35a674e26dd) )
14831474ROM_END
14841475
14851476#define rom_newbraiv rom_newbraia

Previous 15994 Revisions Next


© 1998-2018 The MESS Team