Previous 15994 Revisions Next

r4869 Thursday 28th May, 2009 at 12:18:50 UTC by Miodrag Milanović
[PC6001] Some WIP, and M6847 support for external char rom
[src/mess/drivers]pc6001.c spc1000.c
[src/mess/includes]coco.h
[src/mess/machine]mc10.c
[src/mess/video]apf.c atom.c coco.c m6847.c m6847.h vtech1.c z80ne.c

src/mess/video/z80ne.c
r4868r4869
2929 * 1  0    0     1     1   Semigraphic 6
3030 * 1  1    1     0     0   Inverted Alphanumeric
3131 */
32static ATTR_CONST UINT8 lx388_get_attributes(running_machine *machine, UINT8 video_byte, UINT8 attr)
32static ATTR_CONST UINT8 lx388_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
3333{
3434   UINT8 result = 0x00;
35   if (video_byte & 0x80)
35   if (c & 0x80)
3636   {
37      if (video_byte & 0x40)
37      if (c & 0x40)
3838         result |= M6847_INV;
3939      else
4040         result |= M6847_INTEXT | M6847_AS;
src/mess/video/coco.c
r4868r4869
2929 *
3030 *************************************/
3131
32ATTR_CONST UINT8 coco_get_attributes(running_machine *machine, UINT8 c, UINT8 attr)
32ATTR_CONST UINT8 coco_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
3333{
3434   coco_state *state = machine->driver_data;
3535   UINT8 result = 0x00;
src/mess/video/m6847.c
r4868r4869
108108   /* callbacks */
109109   void (*horizontal_sync_callback)(running_machine *machine, int line);
110110   void (*field_sync_callback)(running_machine *machine, int line);
111   UINT8 (*get_attributes)(running_machine *machine, UINT8 video_byte,UINT8 attr);
111   UINT8 (*get_attributes)(running_machine *machine, UINT8 c,int scanline, int pos);
112112   const UINT8 *(*get_video_ram)(running_machine *machine, int scanline);
113113   int (*new_frame_callback)(void);   /* returns whether the M6847 is in charge of this frame */
114114   void (*custom_prepare_scanline)(int scanline);
115   UINT8 (*get_char_rom)(running_machine *machine, UINT8 ch,int line);
115116
116117   /* timers */
117118   emu_timer *fs_rise_timer;
r4868r4869
11811182
11821183
11831184
1184static void text_mode(int scanline, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
1185static void text_mode(running_machine *machine, int scanline, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data)
11851186{
11861187   int x;
11871188   UINT8 byte, attr;
r4868r4869
11981199
11991200      bg_color = color(m6847->colordata[attr_index][(byte & 0x7F) / 16][0]);
12001201      fg_color = color(m6847->colordata[attr_index][(byte & 0x7F) / 16][1]);
1201      char_data = m6847->fontdata[attr_index][byte & 0x7F][scanline % 12];
1202     
1203      if( attr & M6847_INTEXT) {   
1204         if (m6847->get_char_rom) {
1205            char_data = m6847->get_char_rom(machine,byte,scanline % 12);
1206         } else {
1207            char_data = 0xff;
1208         }
1209      } else {
1210         char_data = m6847->fontdata[attr_index][byte & 0x7F][scanline % 12];
1211      }
12021212
12031213      line[x*8+0] = (char_data & 0x80) ? fg_color : bg_color;
12041214      line[x*8+1] = (char_data & 0x40) ? fg_color : bg_color;
r4868r4869
12471257      else
12481258      {
12491259         /* text/semigraphics */
1250         text_mode(scanline, line + 32, video_data);
1260         text_mode(machine, scanline, line + 32, video_data);
12511261      }
12521262
12531263      /* right border */
r4868r4869
15131523      else
15141524      {
15151525         /* has the border color changed? */
1516         attrs = (*m6847->get_attributes)(machine, 0x00, 0x00);
1526         attrs = (*m6847->get_attributes)(machine, 0, 0, 0);
15171527         if (attrs != m6847->attrs[scanline])
15181528         {
15191529            m6847->dirty = TRUE;
r4868r4869
15421552            for (i = xpos; i < 32; i++)
15431553            {
15441554               data = video_ram[i];
1545               attr = (*m6847->get_attributes)(machine, video_ram[i],video_ram[i + 0x0800]);
1555               attr = (*m6847->get_attributes)(machine, data, scanline, i);
15461556
15471557               if ((data != scanline_data[i].data)   || (attr != scanline_data[i].attr))
15481558               {
r4868r4869
18351845   m6847->new_frame_callback = cfg->new_frame_callback;
18361846   m6847->custom_prepare_scanline = cfg->custom_prepare_scanline;
18371847   m6847->has_lowercase = v->has_lowercase;
1848   m6847->get_char_rom = cfg->get_char_rom;
18381849
18391850   /* assert our assumptions */
18401851   assert((v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME)
src/mess/video/m6847.h
r4868r4869
5353   /* callbacks */
5454   void (*horizontal_sync_callback)(running_machine *machine, int line);
5555   void (*field_sync_callback)(running_machine *machine,int line);
56   UINT8 (*get_attributes)(running_machine *machine, UINT8 video_byte,UINT8 attr) ATTR_CONST;
56   UINT8 (*get_attributes)(running_machine *machine, UINT8 c, int scanline, int pos) ATTR_CONST;
5757   const UINT8 *(*get_video_ram)(running_machine *machine, int scanline);
58   UINT8 (*get_char_rom)(running_machine *machine, UINT8 ch, int line);
5859
5960   /* needed for the CoCo 3 */
6061   int (*new_frame_callback)(void);   /* returns whether the M6847 is in charge of this frame */
src/mess/video/atom.c
r4868r4869
1010#include "includes/atom.h"
1111
1212
13static ATTR_CONST UINT8 atom_get_attributes(running_machine *machine, UINT8 c, UINT8 attr)
13static ATTR_CONST UINT8 atom_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
1414{
1515   UINT8 result = 0x00;
1616   if (c & 0x40)            result |= M6847_AS | M6847_INTEXT;
src/mess/video/apf.c
r4868r4869
1010UINT8 apf_m6847_attr;
1111static UINT8 apf_chars[0x20], apf_video[0x20];
1212
13static ATTR_CONST UINT8 apf_get_attributes(running_machine *machine, UINT8 c, UINT8 attr)
13static ATTR_CONST UINT8 apf_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
1414{
1515
1616   /* this seems to be the same so far, as it gives the same result as vapf */
src/mess/video/vtech1.c
r4868r4869
6060};
6161
6262
63static ATTR_CONST UINT8 vtech1_get_attributes(running_machine *machine, UINT8 c, UINT8 attr)
63static ATTR_CONST UINT8 vtech1_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
6464{
6565   UINT8 result = 0x00;
6666   if (c & 0x40)            result |= M6847_INV;
src/mess/includes/coco.h
r4868r4869
5050
5151/*----------- defined in video/coco.c -----------*/
5252
53ATTR_CONST UINT8 coco_get_attributes(running_machine *machine, UINT8 c, UINT8 attr);
53ATTR_CONST UINT8 coco_get_attributes(running_machine *machine, UINT8 c,int scanline, int pos);
5454
5555VIDEO_START( dragon );
5656VIDEO_START( coco );
src/mess/machine/mc10.c
r4868r4869
167167*****************************************************************************/
168168
169169
170static ATTR_CONST UINT8 mc10_get_attributes(running_machine *machine, UINT8 c, UINT8 attr)
170static ATTR_CONST UINT8 mc10_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
171171{
172172   UINT8 result = 0x00;
173173   if (c & 0x40)         result |= M6847_INV;
src/mess/drivers/pc6001.c
r4868r4869
6060
6161#include "driver.h"
6262#include "cpu/z80/z80.h"
63#include "machine/8255ppi.h"
64#include "machine/msm8251.h"
65#include "video/m6847.h"
66#include "sound/ay8910.h"
6367
68UINT8 *pc6001_ram;
69UINT8 *pc6001_video_ram;
70
71WRITE8_HANDLER ( pc6001_system_latch_w )
72{
73   UINT16 startaddr[] = {0xC000, 0xE000, 0x8000, 0xA000 };
74   
75   pc6001_video_ram =  pc6001_ram + startaddr[(data >> 1) & 0x03] - 0x8000;
76}
77
78
79static ATTR_CONST UINT8 pc6001_get_attributes(running_machine *machine, UINT8 c,int scanline, int pos)
80{
81   UINT8 result = 0x00;
82   UINT8 val = pc6001_video_ram [(scanline / 12) * 0x20 + pos];
83   if (val & 0x01) {
84      result |= M6847_INV;
85   }
86   result |= M6847_INTEXT; // always use external ROM
87   return result;
88}
89
90static const UINT8 *pc6001_get_video_ram(running_machine *machine, int scanline)
91{
92   return pc6001_video_ram +0x0200+ (scanline / 12) * 0x20;
93}
94
95static UINT8 pc6001_get_char_rom(running_machine *machine, UINT8 ch, int line)
96{
97   UINT8 *gfx = memory_region(machine, "gfx1");
98   return gfx[ch*16+line];
99}
100
101UINT8 port_c_8255;
102
103READ8_DEVICE_HANDLER(nec_ppi8255_r) {
104   if (offset==2) {
105      return port_c_8255;
106   } else {
107      return ppi8255_r(device,offset);
108   }
109}
110
111WRITE8_DEVICE_HANDLER(nec_ppi8255_w) {
112   if (offset==3) {
113      if(data & 1) {
114         port_c_8255 |=   1<<((data>>1)&0x07);
115      } else {
116         port_c_8255 &= ~(1<<((data>>1)&0x07));
117      }
118      switch(data) {
119           case 0x08: port_c_8255 |= 0x88; break;
120            case 0x09: port_c_8255 &= 0xf7; break;
121            case 0x0c: port_c_8255 |= 0x28; break;
122            case 0x0d: port_c_8255 &= 0xf7; break;
123            default: break;
124      }
125      port_c_8255 |= 0xa8;
126   }
127   ppi8255_w(device,offset,data);
128}
129
64130static ADDRESS_MAP_START(pc6001_mem, ADDRESS_SPACE_PROGRAM, 8)
65131   ADDRESS_MAP_UNMAP_HIGH
132   AM_RANGE(0x0000, 0x7fff) AM_ROM
133   AM_RANGE(0x8000, 0xffff) AM_RAM AM_BASE(&pc6001_ram)
66134ADDRESS_MAP_END
67135
68136static ADDRESS_MAP_START( pc6001_io , ADDRESS_SPACE_IO, 8)
69137   ADDRESS_MAP_UNMAP_HIGH
138   ADDRESS_MAP_GLOBAL_MASK(0xff)
139   AM_RANGE(0x80, 0x80) AM_DEVREADWRITE("uart", msm8251_data_r,msm8251_data_w)
140   AM_RANGE(0x81, 0x81) AM_DEVREADWRITE("uart", msm8251_status_r,msm8251_control_w)
141   AM_RANGE(0x90, 0x93) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, nec_ppi8255_w)
142   AM_RANGE(0xB0, 0xB0) AM_WRITE(pc6001_system_latch_w)
143   AM_RANGE(0xA0, 0xA0) AM_DEVWRITE("ay8910", ay8910_address_w)
144   AM_RANGE(0xA1, 0xA1) AM_DEVWRITE("ay8910", ay8910_data_w)   
70145ADDRESS_MAP_END
71146
72147/* Input ports */
73148INPUT_PORTS_START( pc6001 )
149   PORT_START("LINE0")
150      PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1)
151      PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2)
152      PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3)
153      PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4)     
154      PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5)
155      PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6)
156      PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7)
157      PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8)   
74158INPUT_PORTS_END
75159
76
77160static MACHINE_RESET(pc6001)
78161{
162   port_c_8255=0;
163   pc6001_video_ram =  pc6001_ram;
79164}
80165
81166static VIDEO_START( pc6001 )
82167{
168   m6847_config cfg;
169
170   memset(&cfg, 0, sizeof(cfg));
171   cfg.type = M6847_VERSION_M6847T1_NTSC;
172   cfg.get_attributes = pc6001_get_attributes;
173   cfg.get_video_ram = pc6001_get_video_ram;
174   cfg.get_char_rom = pc6001_get_char_rom;
175   m6847_init(machine, &cfg);
83176}
84177
85static VIDEO_UPDATE( pc6001 )
178
179static READ8_DEVICE_HANDLER (pc6001_8255_porta_r )
86180{
87181   return 0;
88182}
183static WRITE8_DEVICE_HANDLER (pc6001_8255_porta_w )
184{   
185}
89186
187static READ8_DEVICE_HANDLER (pc6001_8255_portb_r )
188{
189   return 0;
190}
191static WRITE8_DEVICE_HANDLER (pc6001_8255_portb_w )
192{   
193}
90194
195static WRITE8_DEVICE_HANDLER (pc6001_8255_portc_w )
196{     
197}
198
199static READ8_DEVICE_HANDLER (pc6001_8255_portc_r )
200{   
201   return 0;
202}
203
204const ppi8255_interface pc6001_ppi8255_interface =
205{
206   DEVCB_HANDLER(pc6001_8255_porta_r),
207   DEVCB_HANDLER(pc6001_8255_portb_r),
208   DEVCB_HANDLER(pc6001_8255_portc_r),
209   DEVCB_HANDLER(pc6001_8255_porta_w),
210   DEVCB_HANDLER(pc6001_8255_portb_w),
211   DEVCB_HANDLER(pc6001_8255_portc_w)
212};
213
214const msm8251_interface pc6001_usart_interface=
215{
216   NULL,
217   NULL,
218   NULL
219};
220
221
222static const ay8910_interface pc6001_ay_interface =
223{
224   AY8910_LEGACY_OUTPUT,
225   AY8910_DEFAULT_LOADS,
226   DEVCB_NULL
227};
228
91229static MACHINE_DRIVER_START( pc6001 )
92230   /* basic machine hardware */
93   MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz)
231   MDRV_CPU_ADD("maincpu",Z80, 7987200 /2)
94232   MDRV_CPU_PROGRAM_MAP(pc6001_mem)
95233   MDRV_CPU_IO_MAP(pc6001_io)
96234
235//   MDRV_CPU_ADD("subcpu", I8049, 7987200)
236   
97237   MDRV_MACHINE_RESET(pc6001)
98238
99   /* video hardware */
239   /* video hardware */   
100240   MDRV_SCREEN_ADD("screen", RASTER)
101   MDRV_SCREEN_REFRESH_RATE(50)
102   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
103   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
104   MDRV_SCREEN_SIZE(640, 480)
105   MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
106   MDRV_PALETTE_LENGTH(2)
107   MDRV_PALETTE_INIT(black_and_white)
241   MDRV_SCREEN_REFRESH_RATE(M6847_NTSC_FRAMES_PER_SECOND)
242   MDRV_VIDEO_START(pc6001)
243   MDRV_VIDEO_UPDATE(m6847)
244   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
245   MDRV_SCREEN_SIZE(320, 25+192+26)
246   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
108247
109   MDRV_VIDEO_START(pc6001)
110   MDRV_VIDEO_UPDATE(pc6001)
248   MDRV_SPEAKER_STANDARD_MONO("mono")
249   MDRV_SOUND_ADD("ay8910", AY8910, XTAL_4MHz/2)
250   MDRV_SOUND_CONFIG(pc6001_ay_interface)
251   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
252   
253   MDRV_PPI8255_ADD( "ppi8255", pc6001_ppi8255_interface )
254   /* uart */
255   MDRV_MSM8251_ADD("uart", pc6001_usart_interface)
256   
111257MACHINE_DRIVER_END
112258
113259static MACHINE_DRIVER_START( pc6001sr )
src/mess/drivers/spc1000.c
r4868r4869
202202}
203203
204204
205static ATTR_CONST UINT8 spc1000_get_attributes(running_machine *machine, UINT8 c, UINT8 attr)
205static ATTR_CONST UINT8 spc1000_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos)
206206{
207207   UINT8 result = 0x00;
208   UINT8 attr = spc1000_video_ram [(scanline / 12) * 0x20 + pos + 0x0800];
209
208210   //if (c & 0x40)             result |= M6847_INTEXT;
209211   if (attr & 0x01)            result |= M6847_INV;
210212   if (attr & 0x02)            result |= M6847_CSS;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team