Previous 15994 Revisions Next

r5918 Tuesday 29th September, 2009 at 22:31:50 UTC by Angelo Salese
[PC6001]: Rewritten the video emulation from scratch, ASCII's AX-1 Demo now displays correct gfxs
[src/mess/drivers]pc6001.c

src/mess/drivers/pc6001.c
r5917r5918
1/***************************************************************************
1/*********************************************************************************
22
3        NEC PC-6001 series
4        NEC PC-6600 series
3   NEC PC-6001 series
4   NEC PC-6600 series
55
6        12/05/2009 Skeleton driver.
6   preliminary driver by Angelo Salese
77
8      PC-6001 (1981-09):
8   TODO:
9   - Hook up tape loading, images that are floating around the net are already
10     ADC'ed, so they should be easy to implement (but not exactly faithful)
11   - Currently rewriting the video part without the MC6847 for two reasons:
12      A) the later models have a custom video chip in the place of the MC6847,
13         so this implementation will be used in the end.
14      B) It's easier to me to see what the attribute vram does since I don't
15         have any docs atm.
916
10       * CPU: Z80A @ 4 MHz
11       * ROM: 16KB + 4KB (chargen) - no kanji
12       * RAM: 16KB, it can be expanded to 32KB
13       * Text Mode: 32x16 and 2 colors
14       * Graphic Modes: 64x48 (9 colors), 128x192 (4 colors), 256x192 (2 colors)
15       * Sound: BEEP + PSG - Optional Voice Synth Cart
16       * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key,
17            HOME/CLR key, INS key, DEL key, GRAPH key, Japanese syllabary
18            key, page key, STOP key, and cursor key (4 directions)
19       * 1 cartslot, optional floppy drive, optional serial 232 port, 2
20            joystick ports
17==================================================================================
2118
19   PC-6001 (1981-09):
2220
23      PC-6001 mkII (1983-07):
21    * CPU: Z80A @ 4 MHz
22    * ROM: 16KB + 4KB (chargen) - no kanji
23    * RAM: 16KB, it can be expanded to 32KB
24    * Text Mode: 32x16 and 2 colors
25    * Graphic Modes: 64x48 (9 colors), 128x192 (4 colors), 256x192 (2 colors)
26    * Sound: BEEP + PSG - Optional Voice Synth Cart
27    * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key,
28         HOME/CLR key, INS key, DEL key, GRAPH key, Japanese syllabary
29         key, page key, STOP key, and cursor key (4 directions)
30    * 1 cartslot, optional floppy drive, optional serial 232 port, 2
31         joystick ports
2432
25       * CPU: Z80A @ 4 MHz
26       * ROM: 32KB + 16KB (chargen) + 32KB (kanji) + 16KB (Voice Synth)
27       * RAM: 64KB
28       * Text Mode: same as PC-6001 with N60-BASIC; 40x20 and 15 colors with
29            N60M-BASIC
30       * Graphic Modes: same as PC-6001 with N60-BASIC; 80x40 (15 colors),
31            160x200 (15 colors), 320x200 (4 colors) with N60M-BASIC
32       * Sound: BEEP + PSG
33       * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key,
34            HOME/CLR key, INS key, DEL key, CAPS key, GRAPH key, Japanese
35            syllabary key, page key, mode key, STOP key, and cursor key (4
36            directions)
37       * 1 cartslot, floppy drive, optional serial 232 port, 2 joystick ports
3833
34   PC-6001 mkII (1983-07):
3935
40      PC-6001 mkIISR (1984-12):
36    * CPU: Z80A @ 4 MHz
37    * ROM: 32KB + 16KB (chargen) + 32KB (kanji) + 16KB (Voice Synth)
38    * RAM: 64KB
39    * Text Mode: same as PC-6001 with N60-BASIC; 40x20 and 15 colors with
40         N60M-BASIC
41    * Graphic Modes: same as PC-6001 with N60-BASIC; 80x40 (15 colors),
42         160x200 (15 colors), 320x200 (4 colors) with N60M-BASIC
43    * Sound: BEEP + PSG
44    * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key,
45         HOME/CLR key, INS key, DEL key, CAPS key, GRAPH key, Japanese
46         syllabary key, page key, mode key, STOP key, and cursor key (4
47         directions)
48    * 1 cartslot, floppy drive, optional serial 232 port, 2 joystick ports
4149
42       * CPU: Z80A @ 3.58 MHz
43       * ROM: 64KB + 16KB (chargen) + 32KB (kanji) + 32KB (Voice Synth)
44       * RAM: 64KB
45       * Text Mode: same as PC-6001/PC-6001mkII with N60-BASIC; 40x20, 40x25,
46            80x20, 80x25 and 15 colors with N66SR-BASIC
47       * Graphic Modes: same as PC-6001/PC-6001mkII with N60-BASIC; 80x40 (15 colors),
48            320x200 (15 colors), 640x200 (15 colors) with N66SR-BASIC
49       * Sound: BEEP + PSG + FM
50       * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key,
51            HOME/CLR key, INS key, DEL key, CAPS key, GRAPH key, Japanese
52            syllabary key, page key, mode key, STOP key, and cursor key (4
53            directions)
54       * 1 cartslot, floppy drive, optional serial 232 port, 2 joystick ports
5550
51   PC-6001 mkIISR (1984-12):
5652
53    * CPU: Z80A @ 3.58 MHz
54    * ROM: 64KB + 16KB (chargen) + 32KB (kanji) + 32KB (Voice Synth)
55    * RAM: 64KB
56    * Text Mode: same as PC-6001/PC-6001mkII with N60-BASIC; 40x20, 40x25,
57         80x20, 80x25 and 15 colors with N66SR-BASIC
58    * Graphic Modes: same as PC-6001/PC-6001mkII with N60-BASIC; 80x40 (15 colors),
59         320x200 (15 colors), 640x200 (15 colors) with N66SR-BASIC
60    * Sound: BEEP + PSG + FM
61    * Keyboard: JIS Keyboard with 5 function keys, control key, TAB key,
62         HOME/CLR key, INS key, DEL key, CAPS key, GRAPH key, Japanese
63         syllabary key, page key, mode key, STOP key, and cursor key (4
64         directions)
65    * 1 cartslot, floppy drive, optional serial 232 port, 2 joystick ports
66
67
5768   info from http://www.geocities.jp/retro_zzz/machines/nec/6001/spc60.html
5869
59===
70==================================================================================
6071
6172irq vector 00: writes 0x00 to [$fa19]
6273irq vector 02: (A = 0, B = 0) tests ppi port c, does something with ay ports (plus more?) ;keyboard data ready, no kanji lock, no caps lock
r5917r5918
7283irq vector 16: tests ppi port c, writes the result to $feca. ;vblank
7384
7485
75****************************************************************************/
86*********************************************************************************/
7687
7788#include "driver.h"
7889#include "cpu/z80/z80.h"
r5917r5918
8697static UINT8 irq_vector = 0x00;
8798static UINT8 cas_switch,sys_latch;
8899
100static VIDEO_START( pc6001 )
101{
102   #if 0
103   m6847_config cfg;
104
105   memset(&cfg, 0, sizeof(cfg));
106   cfg.type = M6847_VERSION_M6847T1_NTSC;
107   cfg.get_attributes = pc6001_get_attributes;
108   cfg.get_video_ram = pc6001_get_video_ram;
109   cfg.get_char_rom = pc6001_get_char_rom;
110   m6847_init(machine, &cfg);
111   #endif
112   pc6001_video_ram = auto_alloc_array(machine, UINT8, 0x1000); //0x400? We'll see...
113}
114
115static VIDEO_UPDATE( pc6001 )
116{
117   UINT8 *gfx_data = memory_region(screen->machine, "gfx1");
118   int x,y,xi,yi;
119   int tile,attr,pen,color;
120   int fgcol;
121
122   for(y=0;y<16;y++)
123   {
124      for(x=0;x<32;x++)
125      {
126         tile = pc6001_video_ram[(x+(y*32))+0x200];
127         attr = pc6001_video_ram[(x+(y*32)) & 0x1ff] ;
128
129         if(attr & 0x40)
130         {
131            pen = (tile & 0xc0) >> 6 | (attr & 2)<<1;
132
133            for(yi=0;yi<12;yi++)
134            {
135               for(xi=0;xi<8;xi++)
136               {
137                  int i;
138                  i = (xi & 4)>>2; //x-axis
139                  i+= (yi & 4)>>1; //y-axis 1
140                  i+= (yi & 8)>>1; //y-axis 2
141
142                  color = ((tile >> i) & 1) ? pen+8 : 0;
143
144                  *BITMAP_ADDR16(bitmap, ((y*12+(11-yi))+24), (x*8+(7-xi))+32) = screen->machine->pens[color];
145               }
146            }
147         }
148         else
149         {
150            for(yi=0;yi<12;yi++)
151            {
152               for(xi=0;xi<8;xi++)
153               {
154                  pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1;
155
156                  fgcol = (attr & 2) ? 2 : 7;
157
158                  if(attr & 1)
159                     color = pen ? 0 : fgcol;
160                  else
161                     color = pen ? fgcol : 0;
162
163                     *BITMAP_ADDR16(bitmap, ((y*12+yi)+24), (x*8+xi)+32) = screen->machine->pens[color];
164               }
165            }
166         }
167      }
168   }
169
170   return 0;
171}
172
89173static WRITE8_HANDLER ( pc6001_system_latch_w )
90174{
91175   UINT16 startaddr[] = {0xC000, 0xE000, 0x8000, 0xA000 };
r5917r5918
98182   sys_latch = data;
99183}
100184
101
185#if 0
102186static ATTR_CONST UINT8 pc6001_get_attributes(running_machine *machine, UINT8 c,int scanline, int pos)
103187{
104188   UINT8 result = 0x00;
r5917r5918
107191   if (val & 0x01) {
108192      result |= M6847_INV;
109193   }
110   if (!(val & 0x20))
194   if (val & 0x40)
111195      result |= M6847_AG | M6847_GM1; //TODO
112196
113197   result |= M6847_INTEXT; // always use external ROM
r5917r5918
124208   UINT8 *gfx = memory_region(machine, "gfx1");
125209   return gfx[ch*16+line];
126210}
211#endif
127212
128213static UINT8 port_c_8255,cur_keycode;
129214
r5917r5918
299384   return irq_vector;
300385}
301386
302static VIDEO_START( pc6001 )
303{
304   m6847_config cfg;
305
306   memset(&cfg, 0, sizeof(cfg));
307   cfg.type = M6847_VERSION_M6847T1_NTSC;
308   cfg.get_attributes = pc6001_get_attributes;
309   cfg.get_video_ram = pc6001_get_video_ram;
310   cfg.get_char_rom = pc6001_get_char_rom;
311   m6847_init(machine, &cfg);
312}
313
314
315387static READ8_DEVICE_HANDLER (pc6001_8255_porta_r )
316388{
317389   return 0;
r5917r5918
400472   {
401473      cur_keycode = gfx_data[i++];
402474      //popmessage("%04x",i);
403      if(i >= 1)
475      if(i >= 0x34c6)
404476      {
405477         i = 0;
406478         cas_switch = 0;
r5917r5918
440512static MACHINE_RESET(pc6001)
441513{
442514   port_c_8255=0;
443   pc6001_video_ram =  pc6001_ram;
515   //pc6001_video_ram =  pc6001_ram;
444516
445517   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"),pc6001_irq_callback);
446518   timer_pulse(machine, ATTOTIME_IN_HZ(240), NULL, 0, keyboard_callback);
447   timer_pulse(machine, ATTOTIME_IN_HZ(100), NULL, 0, cassette_callback);
519   timer_pulse(machine, ATTOTIME_IN_HZ(160), NULL, 0, cassette_callback);
448520   cas_switch = 0;
449521}
450522
523static const rgb_t defcolors[] =
524{
525   MAKE_RGB(0x00, 0xff, 0x00),   /* GREEN */
526   MAKE_RGB(0xff, 0xff, 0x00),   /* YELLOW */
527   MAKE_RGB(0x00, 0x00, 0xff),   /* BLUE */
528   MAKE_RGB(0xff, 0x00, 0x00),   /* RED */
529   MAKE_RGB(0xff, 0xff, 0xff),   /* BUFF */
530   MAKE_RGB(0x00, 0xff, 0xff),   /* CYAN */
531   MAKE_RGB(0xff, 0x00, 0xff),   /* MAGENTA */
532   MAKE_RGB(0xff, 0x80, 0x00)   /* ORANGE */
533};
451534
535static PALETTE_INIT(pc6001)
536{
537   int i;
538
539   for(i=0;i<8;i++)
540      palette_set_color(machine, i+8,defcolors[i]);
541}
542
543
452544static MACHINE_DRIVER_START( pc6001 )
453545   /* basic machine hardware */
454546   MDRV_CPU_ADD("maincpu",Z80, 7987200 /2)
r5917r5918
462554
463555   /* video hardware */
464556   MDRV_SCREEN_ADD("screen", RASTER)
465   MDRV_SCREEN_REFRESH_RATE(M6847_NTSC_FRAMES_PER_SECOND)
557   MDRV_SCREEN_REFRESH_RATE(60)
466558   MDRV_VIDEO_START(pc6001)
467   MDRV_VIDEO_UPDATE(m6847)
468   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
559   MDRV_VIDEO_UPDATE(pc6001)
560   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
561//   MDRV_SCREEN_REFRESH_RATE(M6847_NTSC_FRAMES_PER_SECOND)
562//   MDRV_VIDEO_UPDATE(m6847)
563//   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
469564   MDRV_SCREEN_SIZE(320, 25+192+26)
470565   MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239)
566   MDRV_PALETTE_LENGTH(16)
567   MDRV_PALETTE_INIT(pc6001)
471568
472569   MDRV_I8255A_ADD( "ppi8255", pc6001_ppi8255_interface )
473570   /* uart */
r5917r5918
495592   ROM_LOAD( "cgrom60.60", 0x0000, 0x1000, CRC(b0142d32) SHA1(9570495b10af5b1785802681be94b0ea216a1e26) )
496593
497594   ROM_REGION( 0x10000, "cas", ROMREGION_ERASEFF )
498//   ROM_LOAD( "ax7 demo.cas", 0x0000, 0x2ef1, CRC(1) SHA1(1) )
595   /* Load here your tape for now (and change line 475 with the length value that MESS returns) */
596   //ROM_LOAD( "demo.cas", 0x0000, 0x34c6, CRC(1) SHA1(1) )
499597ROM_END
500598
501599ROM_START( pc6001a )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team