Previous 15994 Revisions Next

r4485 Monday 13th April, 2009 at 05:01:08 UTC by Robbbert
[KAYPRO2] WIP - it boots
[src/mess]mess.mak messdriv.c
[src/mess/drivers]kaypro2.c

src/mess/messdriv.c
r4484r4485
597597
598598   /* NON LINEAR SYSTEMS */
599599   DRIVER( kaypro )   /* Kaypro 2X                              */
600   DRIVER( kaypro2 )   /* Kaypro 2/83                              */
600601
601602   /* VEB MIKROELEKTRONIK */
602603   /* KC compact is partial CPC compatible */
src/mess/mess.mak
r4484r4485
599599
600600$(MESSOBJ)/kaypro.a:   \
601601   $(MESS_DRIVERS)/kaypro.o   \
602   $(MESS_DRIVERS)/kaypro2.o   \
602603   $(MESS_MACHINE)/cpm_bios.o   \
603604   $(MESS_VIDEO)/kaypro.o    \
604605   $(MESS_AUDIO)/kaypro.o    \
src/mess/drivers/kaypro2.c
r4484r4485
2323   - Which order are devices to be specified in the daisy chain?
2424   - Keyboard is a separate device and not emulated (includes a beeper)
2525   - Floppy disks (I have no knowledge of how to set these up)
26   - Bank switching
27   - Rom SHA1s
2826   - Split this code to video, machine
2927 
30   This code has never been compiled. There will most likely be heaps of errors!
31 
28 
3229**************************************************************************************************/
3330 
3431 
r4484r4485
5047static const device_config *kaypro2_printer;
5148static const device_config *kaypro2_fdc;
5249 
53static printer_data;
50static UINT8 printer_data;
5451 
5552 
5653/***********************************************************
5754 
55   Video
56 
57************************************************************/
58 
59static PALETTE_INIT( kaypro2 )
60{
61   palette_set_color(machine,0,RGB_BLACK); /* black */
62   palette_set_color(machine,1,MAKE_RGB(0, 200, 0)); /* green */   
63}
64 
65static VIDEO_UPDATE( kaypro2 )
66{
67/* The display consists of 80 columns and 24 rows. Each row is allocated 128 bytes of ram,
68   but only the first 80 are used. The total video ram therefore is 0x0c00 bytes.
69   There is one video attribute: bit 7 causes blinking. The first half of the
70   character generator is blank, with the visible characters in the 2nd half.
71   During the "off" period of blanking, the first half is used. Only 5 pixels are
72   connected from the rom to the shift register, the remaining pixels are held high.
73   A high pixel is black and a low pixel is green. */
74 
75   static UINT8 framecnt=0;
76   UINT8 y,ra,chr,gfx;
77   UINT16 sy=0,ma=0,x;
78   UINT8 *FNT = memory_region(screen->machine, "gfx1");
79 
80   framecnt++;
81 
82   for (y = 0; y < 24; y++)
83   {
84      for (ra = 0; ra < 10; ra++)
85      {
86         UINT16  *p = BITMAP_ADDR16(bitmap, sy++, 0);
87 
88         for (x = ma; x < ma + 80; x++)
89         {
90            chr = videoram[x]^0x80;
91 
92            if ((chr < 0x80) && (framecnt & 0x08))
93               chr |= 0x80;
94 
95            /* get pattern of pixels for that character scanline */
96            if (ra < 8) 
97               gfx = FNT[(chr<<3) | ra ];
98            else
99               gfx = 0xff;
100 
101            /* Display a scanline of a character (7 pixels) */
102            *p = 0; p++;
103            *p = ( gfx & 0x10 ) ? 0 : 1; p++;
104            *p = ( gfx & 0x08 ) ? 0 : 1; p++;
105            *p = ( gfx & 0x04 ) ? 0 : 1; p++;
106            *p = ( gfx & 0x02 ) ? 0 : 1; p++;
107            *p = ( gfx & 0x01 ) ? 0 : 1; p++;
108            *p = 0; p++;
109         }
110      }
111      ma+=128;
112   }
113   return 0;
114}
115 
116static READ8_HANDLER( kaypro2_videoram_r )
117{
118   return videoram[offset];
119}
120 
121static WRITE8_HANDLER( kaypro2_videoram_w )
122{
123   videoram[offset] = data;
124}
125 
126 
127/***********************************************************
128 
58129   PIO
59130 
60131   It seems there must have been a bulk-purchase
r4484r4485
92163   {
93164      memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, SMH_UNMAP, SMH_UNMAP);
94165      memory_install_read8_handler (mem, 0x0000, 0x0fff, 0, 0, SMH_BANK1);
95      memory_set_bankptr(mem->machine, 1, memory_region(mem->machine, "maincpu"+0x10000));
166      memory_set_bankptr(mem->machine, 1, memory_region(mem->machine, "maincpu"));
96167      memory_install_readwrite8_handler (mem, 0x3000, 0x3fff, 0, 0, kaypro2_videoram_r, kaypro2_videoram_w);
97168   }
98169   else
99170   {
100171      memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, SMH_UNMAP, SMH_UNMAP);
101172       memory_install_readwrite8_handler (mem, 0x0000, 0x3fff, 0, 0, SMH_BANK2, SMH_BANK3);
102      memory_set_bankptr(mem->machine, 2, memory_region(mem->machine, "maincpu"));
103      memory_set_bankptr(mem->machine, 3, memory_region(mem->machine, "maincpu"));
173      memory_set_bankptr(mem->machine, 2, memory_region(mem->machine, "rambank"));
174      memory_set_bankptr(mem->machine, 3, memory_region(mem->machine, "rambank"));
104175   }
105176 
106   wd17xx_set_density((data & 0x20) ? 1 : 0);
177   wd17xx_set_density(kaypro2_fdc, (data & 0x20) ? 1 : 0);
107178 
108179   if (data & 0x10)
109180   {
r4484r4485
134205   DEVCB_NULL         /* portB ready active callback */
135206};
136207 
137static const z80pio_interface kaypro_pio_s_intf =
208static const z80pio_interface kaypro2_pio_s_intf =
138209{
139210   DEVCB_NULL,      /* callback when change interrupt status - assume this is handled by the daisy-chain? */
140211   DEVCB_HANDLER(pio_system_r),   /* read printer status */
r4484r4485
145216   DEVCB_NULL         /* portB ready active callback */
146217};
147218 
148READ8_DEVICE_HANDLER( kaypro2_pio_r )
219static READ8_DEVICE_HANDLER( kaypro2_pio_r )
149220{
150221   if (!offset)
151222      return z80pio_d_r(device, 0);
r4484r4485
159230      return z80pio_c_r(device, 1);
160231}
161232       
162WRITE8_DEVICE_HANDLER( kaypro2_pio_w )
233static WRITE8_DEVICE_HANDLER( kaypro2_pio_w )
163234{
164235   if (!offset)
165236      z80pio_d_w(device, 0, data);
r4484r4485
199270   EEh    9600   
200271   FFh    19200 */
201272 
202   int baud_clock[]={ 800, 1200, 1760, 2152, 2400, 4800, 9600, 19200, 28800, 32000, 38400, 57600, 76800, 115200, 153600, 307200 };
273//   int baud_clock[]={ 800, 1200, 1760, 2152, 2400, 4800, 9600, 19200, 28800, 32000, 38400, 57600, 76800, 115200, 153600, 307200 };
203274 
204275   data &= 0x0f;
205276 
r4484r4485
237308   { NULL }
238309};
239310 
240READ8_DEVICE_HANDLER( kaypro2_sio_r )
311static READ8_DEVICE_HANDLER( kaypro2_sio_r )
241312{
242313   if (!offset)
243314      return z80sio_d_r(device, 0);
r4484r4485
251322      return z80sio_c_r(device, 1);
252323}
253324       
254WRITE8_DEVICE_HANDLER( kaypro2_sio_w )
325static WRITE8_DEVICE_HANDLER( kaypro2_sio_w )
255326{
256327   if (!offset)
257328      z80sio_d_w(device, 0, data);
r4484r4485
265336      z80sio_c_w(device, 1, data);
266337}
267338 
339 
268340/***********************************************************
269341 
342   Floppy DIsk
343 
344   If there is no diskette in the drive, the cpu will
345   HALT, until the fdc does a NMI. NMI is deactivated
346   otherwise.
347 
348************************************************************/
349 
350static WD17XX_CALLBACK( kaypro2_fdc_callback )
351{
352   switch (state)
353   {
354      case WD17XX_DRQ_CLR:
355      case WD17XX_IRQ_CLR:
356         cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, 0);
357         break;
358      case WD17XX_DRQ_SET:
359      case WD17XX_IRQ_SET:
360         if (cpu_get_reg(device->machine->cpu[0], Z80_HALT))
361            cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE);
362         break;
363   }
364}
365 
366static const wd17xx_interface kaypro2_wd1793_interface = { kaypro2_fdc_callback, NULL };
367 
368/* I have no idea how to set up floppies - these ones have 40 tracks, 10 sectors, 512 bytes per track, single sided */
369 
370static void kaypro2_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
371{
372   /* floppy */
373   switch(state)
374   {
375      /* --- the following bits of info are returned as 64-bit signed integers --- */
376      case MESS_DEVINFO_INT_COUNT:         info->i = 2; break;
377 
378      /* --- the following bits of info are returned as pointers to data or functions --- */
379//      case MESS_DEVINFO_PTR_LOAD:         info->load = DEVICE_IMAGE_LOAD_NAME(kaypro2_floppy); break;
380 
381      /* --- the following bits of info are returned as NULL-terminated strings --- */
382      case MESS_DEVINFO_STR_FILE_EXTENSIONS:      strcpy(info->s = device_temp_str(), "dsk"); break;
383 
384      default:               legacybasicdsk_device_getinfo(devclass, state, info); break;
385   }
386}
387 
388/***********************************************************
389 
270390   Address Maps
271391 
272392************************************************************/
273393 
274394static ADDRESS_MAP_START( kaypro2_map, ADDRESS_SPACE_PROGRAM, 8 )
275   AM_RANGE(0x1000, 0xffff) AM_RAM AM_REGION("maincpu", 0x1000)
395   AM_RANGE(0x0000, 0x0fff) AM_ROM AM_REGION("maincpu", 0x0000)
396   AM_RANGE(0x3000, 0x3fff) AM_RAM AM_REGION("maincpu", 0x3000) AM_BASE(&videoram) AM_SIZE(&videoram_size)
397   AM_RANGE(0x4000, 0xffff) AM_RAM AM_REGION("rambank", 0x4000)
276398ADDRESS_MAP_END
277399 
278400static ADDRESS_MAP_START( kaypro2_io, ADDRESS_SPACE_IO, 8 )
r4484r4485
298420static INPUT_PORTS_START( kaypro2 )
299421INPUT_PORTS_END
300422 
301/***********************************************************
302423 
303   Video
304 
305************************************************************/
306 
307static PALETTE_INIT( kaypro2 )
308{
309   palette_set_color(machine,0,RGB_BLACK); /* black */
310   palette_set_color(machine,1,MAKE_RGB(0, 200, 0)); /* green */   
311}
312 
313static VIDEO_UPDATE( kaypro2 )
314{
315/* Bit 7 is the blink attribute */
316   static UINT8 framecnt=0;   /* exact flash rate not documented anywhere */
317   UINT8 y,ra,chr,gfx,gfxbit;
318   UINT16 sy=0,ma=0,x;
319   UINT8 *FNT = memory_region(screen->machine, "gfx1");
320 
321   framecnt++;
322 
323   for (y = 0; y < 24; y++)         /* could be 25 lines, depending on which document you read */
324   {
325      for (ra = 0; ra < 10; ra++)
326      {
327         UINT16  *p = BITMAP_ADDR16(bitmap, sy++, 0);
328 
329         for (x = ma; x < ma + 80; x+=skip)
330         {
331            chr = videoram[x];
332 
333            if ((chr < 0x80) || (framecnt & 0x10))
334               chr |= 0x80;
335 
336            /* get pattern of pixels for that character scanline */
337            if (ra < 8) 
338               gfx = FNT[(chr<<3) | ra ];
339            else
340               gfx = 0xff;
341 
342            /* Display a scanline of a character (7 pixels) */
343            *p = 0; p++;
344            *p = ( gfx & 0x10 ) ? 0 : 1; p++;
345            *p = ( gfx & 0x08 ) ? 0 : 1; p++;
346            *p = ( gfx & 0x04 ) ? 0 : 1; p++;
347            *p = ( gfx & 0x02 ) ? 0 : 1; p++;
348            *p = ( gfx & 0x01 ) ? 0 : 1; p++;
349            *p = 0; p++;
350            }
351         }
352      }
353      ma+=80;
354   }
355   return 0;
356}
357 
358424/***********************************************************
359425 
360426   Machine
r4484r4485
363429 
364430static MACHINE_RESET( kaypro2 )
365431{
366   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
367432   kaypro2_z80pio_g = devtag_get_device(machine, "z80pio_g");
368433   kaypro2_z80pio_s = devtag_get_device(machine, "z80pio_s");
434   kaypro2_z80sio = devtag_get_device(machine, "z80sio");
369435//   kaypro2_beeper = devtag_get_device(machine, "beeper");
370436   kaypro2_printer = devtag_get_device(machine, "centronics");
371437   kaypro2_fdc = devtag_get_device(machine, "wd1793");
372   pio_system_w(kaypro_z80pio_s, 0, 0x80);
438   pio_system_w(kaypro2_z80pio_s, 0, 0x80);
373439}
374440 
375441/***********************************************************
r4484r4485
391457   MDRV_SCREEN_REFRESH_RATE(60)
392458   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
393459   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
394   MDRV_SCREEN_SIZE(80*8, 25*10)
395   MDRV_SCREEN_VISIBLE_AREA(0,80*8-1,0,25*10-1)
460   MDRV_SCREEN_SIZE(80*7, 24*10)
461   MDRV_SCREEN_VISIBLE_AREA(0,80*7-1,0,24*10-1)
396462   MDRV_PALETTE_LENGTH(2)
397463   MDRV_PALETTE_INIT(kaypro2)
398464 
r4484r4485
417483 
418484************************************************************/
419485 
420ROM_START(kaypro2) /* wrong sha1's here */
486ROM_START(kaypro2)
421487   /* The board could take a 2716 or 2732 */
422   ROM_REGION(0x12000, "maincpu",0)
423   ROM_LOAD("kaypro2.u47", 0x10000, 0x0800, CRC(28264bc1) SHA1(e84cf3121f9e0bb9e1b01b095f7a9581dcfaaae4))
424//   ROM_LOAD("kaypro2.u47", 0x10000, 0x1000, CRC(4918fb91) SHA1(e84cf3121f9e0bb9e1b01b095f7a9581dcfaaae4))
488   ROM_REGION(0x4000, "maincpu",0)
489   ROM_LOAD("kaypro2.u47", 0x0000, 0x0800, CRC(28264bc1) SHA1(a12afb11a538fc0217e569bc29633d5270dfa51b))
490//   ROM_LOAD("kaypro2.u47", 0x0000, 0x1000, CRC(4918fb91) SHA1(cd9f45cc3546bcaad7254b92c5d501c40e2ef0b2))
425491 
426   ROM_REGION(0x01000, "gfx1",0)
427   ROM_LOAD("kaypro2.u43", 0x00000, 0x0800, CRC(4cc7d206) SHA1(6361ee9667bf59d50059d09b0baf8672fdb2e8af))
492   ROM_REGION(0x10000, "rambank",0)
493   ROM_FILL( 0, 0x10000, 0xff)
494 
495   ROM_REGION(0x0800, "gfx1",0)
496   ROM_LOAD("kaypro2.u43", 0x00000, 0x0800, CRC(4cc7d206) SHA1(5cb880083b94bd8220aac1f87d537db7cfeb9013))
428497ROM_END
429498 
430static DRIVER_INIT( lnw80 )
431{
432   videoram = memory_region(machine, "maincpu")+0x11000;
433}
434499 
435/* I have no idea how to set up floppies - these ones have 40 tracks, 10 sectors, 512 bytes per track, single sided */
436 
437static void kaypro2_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
438{
439   /* floppy */
440   switch(state)
441   {
442      /* --- the following bits of info are returned as 64-bit signed integers --- */
443      case MESS_DEVINFO_INT_COUNT:         info->i = 2; break;
444 
445      /* --- the following bits of info are returned as pointers to data or functions --- */
446      case MESS_DEVINFO_PTR_LOAD:         info->load = DEVICE_IMAGE_LOAD_NAME(kaypro2_floppy); break;
447 
448      /* --- the following bits of info are returned as NULL-terminated strings --- */
449      case MESS_DEVINFO_STR_FILE_EXTENSIONS:      strcpy(info->s = device_temp_str(), "dsk"); break;
450 
451      default:               legacybasicdsk_device_getinfo(devclass, state, info); break;
452   }
453}
454 
455500static SYSTEM_CONFIG_START(kaypro2)
456501   CONFIG_DEVICE(kaypro2_floppy_getinfo)
457502SYSTEM_CONFIG_END

Previous 15994 Revisions Next


© 1998-2018 The MESS Team