Previous 15994 Revisions Next

r6000 Wednesday 7th October, 2009 at 18:28:53 UTC by Angelo Salese
[PC98]: improved up to the state of executing code in work ram
[src/mess/drivers]pc98.c

src/mess/drivers/pc98.c
r5999r6000
208208
209209#include "driver.h"
210210#include "cpu/i386/i386.h"
211#include "machine/8255ppi.h"
211212
212213static UINT32 *pc9801_vram;
213214
r5999r6000
241242   return 0;
242243}
243244
244static ADDRESS_MAP_START( pc9801_mem, ADDRESS_SPACE_PROGRAM, 32)
245   AM_RANGE(0x00000000, 0x0000ffff) AM_RAM
246   AM_RANGE(0x000a0000, 0x000bffff) AM_RAM AM_BASE(&pc9801_vram)
247   AM_RANGE(0x000e0000, 0x000fffff) AM_ROM AM_REGION("maincpu",0)//AM_REGION("memory",0xf8000)
248   AM_RANGE(0xfffe0000, 0xffffffff) AM_ROM AM_REGION("maincpu",0)
249ADDRESS_MAP_END
245static READ8_HANDLER( sys_port_r )
246{
247   if(offset & 1)
248      return ppi8255_r(devtag_get_device(space->machine, "ppi8255_0"), (offset & 6) >> 1);
250249
251static READ32_HANDLER( test1_r )
250   logerror("RS-232c R access %02x\n",offset >> 1);
251   return 0xff;
252}
253
254
255static WRITE8_HANDLER( sys_port_w )
252256{
253   return 0x00008000; //avoid a pitfall, otherwise the code will execute a retf without anything in the stack!
257   if(offset & 1)
258      ppi8255_w(devtag_get_device(space->machine, "ppi8255_0"), (offset & 6) >> 1, data);
259   else
260      logerror("RS-232c W access %02x %02x\n",offset >> 1,data);
254261}
255262
256static READ32_HANDLER( test2_r )
263static READ8_HANDLER( sio_port_r )
257264{
258   return mame_rand(space->machine);
265   if(!(offset & 1))
266      return ppi8255_r(devtag_get_device(space->machine, "ppi8255_1"), (offset & 6) >> 1);
267
268   logerror("keyboard R access %02x\n",offset >> 1);
269   return 0xff;
259270}
260271
272
273static WRITE8_HANDLER( sio_port_w )
274{
275   if(!(offset & 1))
276      ppi8255_w(devtag_get_device(space->machine, "ppi8255_1"), (offset & 6) >> 1, data);
277   else
278      logerror("keyboard W access %02x %02x\n",offset >> 1,data);
279}
280
281/*
282#define UPD7220_SR_DATA_READY         0x01
283#define UPD7220_SR_FIFO_FULL         0x02
284#define UPD7220_SR_FIFO_EMPTY         0x04
285#define UPD7220_SR_DRAWING_IN_PROGRESS   0x08
286#define UPD7220_SR_DMA_EXECUTE         0x10
287#define UPD7220_SR_VSYNC_ACTIVE         0x20
288#define UPD7220_SR_HBLANK_ACTIVE      0x40
289#define UPD7220_SR_LIGHT_PEN_DETECT      0x80
290*/
291static READ8_HANDLER( crtc_status_r )
292{
293   UINT8 vsync = input_port_read(space->machine, "VBLANK") & 0x20;
294
295   return 0x04 | vsync;//mame_rand(space->machine);
296}
297
298static READ8_HANDLER( crtc_fifo_r )
299{
300   return 0x00;//mame_rand(space->machine);
301}
302
303static WRITE8_HANDLER( crtc_param_w )
304{
305}
306
307static WRITE8_HANDLER( crtc_cmd_w )
308{
309}
310
311
312static READ8_HANDLER( port_60_r )
313{
314   if(offset == 0)
315      return crtc_status_r(space, 0);
316   if(offset == 2)
317      return crtc_fifo_r(space,0);
318
319   return 0xff;
320}
321
322static WRITE8_HANDLER( port_60_w )
323{
324   if(offset == 0)
325      crtc_param_w(space, 0,data);
326   if(offset == 2)
327      crtc_cmd_w(space,0,data);
328}
329
330static READ8_HANDLER( port_a0_r )
331{
332   if(offset == 0)
333      return crtc_status_r(space, 0);
334   if(offset == 2)
335      return crtc_fifo_r(space,0);
336
337   return 0xff;
338}
339
340static WRITE8_HANDLER( port_a0_w )
341{
342   if(offset == 0)
343      crtc_param_w(space, 0,data);
344   if(offset == 2)
345      crtc_cmd_w(space,0,data);
346}
347
348static ADDRESS_MAP_START( pc9801_mem, ADDRESS_SPACE_PROGRAM, 32)
349   AM_RANGE(0x00000000, 0x0009ffff) AM_RAM
350   AM_RANGE(0x000a0000, 0x000bffff) AM_RAM AM_BASE(&pc9801_vram)
351   AM_RANGE(0x000e0000, 0x000fffff) AM_ROM AM_REGION("maincpu",0)
352   AM_RANGE(0xfffe0000, 0xffffffff) AM_ROM AM_REGION("maincpu",0)
353ADDRESS_MAP_END
354
355
356
261357static ADDRESS_MAP_START( pc9801_io, ADDRESS_SPACE_IO, 32)
262   AM_RANGE(0x0034, 0x0037) AM_READ(test1_r)
263   AM_RANGE(0x0060, 0x0063) AM_READ(test2_r)
264   AM_RANGE(0x00a0, 0x00a3) AM_READ(test2_r)
358//   AM_RANGE(0x0000, 0x0000) pic8259
359//   AM_RANGE(0x0002, 0x0002)
360//   AM_RANGE(0x0020, 0x0020) rtc
361//   AM_RANGE(0x0022, 0x0022)
362//   AM_RANGE(0x0030, 0x0030) rs232c (i8251 1)
363//   AM_RANGE(0x0032, 0x0032)
364//   AM_RANGE(0x0031, 0x0031) system port (ppi8255 1)
365//   AM_RANGE(0x0033, 0x0033)
366//   AM_RANGE(0x0035, 0x0035)
367//   AM_RANGE(0x0037, 0x0037)
368   AM_RANGE(0x0030, 0x0037) AM_READWRITE8(sys_port_r,sys_port_w,0xffffffff)
369//   AM_RANGE(0x0040, 0x0040) printer port (ppi8255 2)
370//   AM_RANGE(0x0042, 0x0042)
371//   AM_RANGE(0x0044, 0x0044)
372//   AM_RANGE(0x0046, 0x0046)
373//   AM_RANGE(0x0041, 0x0041) keyboard (i8251 2)
374//   AM_RANGE(0x0043, 0x0043)
375   AM_RANGE(0x0040, 0x0047) AM_READWRITE8(sio_port_r,sio_port_w,0xffffffff)
376//   AM_RANGE(0x0060, 0x0060) uPD7220 status reg / param write (for chars)
377//   AM_RANGE(0x0062, 0x0062) uPD7220 fifo read / cmd write
378   AM_RANGE(0x0060, 0x0063) AM_READWRITE8(port_60_r,port_60_w,0xffffffff)
379//   AM_RANGE(0x0064, 0x0064) V-SYNC related write
380//   AM_RANGE(0x0068, 0x0068) Flip-Flop 1 r/w
381//   AM_RANGE(0x006a, 0x006a) Flip-Flop 2 r/w
382//   AM_RANGE(0x006e, 0x006e) Flip-Flop 3 r/w
383//   AM_RANGE(0x0070, 0x0070) crtc registers
384//   AM_RANGE(0x0072, 0x0072)
385//   AM_RANGE(0x0074, 0x0074)
386//   AM_RANGE(0x0076, 0x0076)
387//   AM_RANGE(0x0078, 0x0078)
388//   AM_RANGE(0x007a, 0x007a)
389//   AM_RANGE(0x0071, 0x0071) pit8253
390//   AM_RANGE(0x0073, 0x0073)
391//   AM_RANGE(0x0075, 0x0075)
392//   AM_RANGE(0x0077, 0x0077)
393//   AM_RANGE(0x007c, 0x007c) GRCG mode write
394//   AM_RANGE(0x007e, 0x007e) GRCG tile write
395//   AM_RANGE(0x00a0, 0x00a0) uPD7220 status reg / param write (for gfx)
396//   AM_RANGE(0x00a2, 0x00a2) uPD7220 fifo read / cmd write
397   AM_RANGE(0x00a0, 0x00a3) AM_READWRITE8(port_a0_r,port_a0_w,0xffffffff)
398//    AM_RANGE(0x00e0, 0x00ef) DMA
399//   AM_RANGE(0x043f, 0x043f) EMS select (bankswitch)
400
401//   (and many more...)
265402ADDRESS_MAP_END
266403
267404static ADDRESS_MAP_START( pc9821_mem, ADDRESS_SPACE_PROGRAM, 32)
r5999r6000
270407
271408/* Input ports */
272409static INPUT_PORTS_START( pc9801 )
410   PORT_START("VBLANK")
411   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_VBLANK )
273412INPUT_PORTS_END
274413
275414
r5999r6000
305444   GFXDECODE_ENTRY( "gfx1",   0x00000, charset,    0x000, 0x01 )
306445GFXDECODE_END
307446
447/*
448 * PPI8255
449 */
450
451static READ8_DEVICE_HANDLER( pc98_porta_r )
452{
453   printf("PPI Port A read\n");
454   return 0x00;
455}
456
457static READ8_DEVICE_HANDLER( pc98_portb_r )
458{
459   static UINT8 tmp;
460
461   tmp ^= 1; //<- actually related to the RTC somehow
462   //printf("PPI Port B read\n");
463   return 0xf8 | tmp;
464}
465
466static READ8_DEVICE_HANDLER( pc98_portc_r )
467{
468   printf("PPI Port C read\n");
469   return 0x00;
470}
471
472static WRITE8_DEVICE_HANDLER( pc98_porta_w )
473{
474   printf("PPI Port A write %02x\n",data);
475}
476
477static WRITE8_DEVICE_HANDLER( pc98_portb_w )
478{
479   printf("PPI Port B write %02x\n",data);
480}
481
482static WRITE8_DEVICE_HANDLER( pc98_portc_w )
483{
484   printf("PPI Port C write %02x\n",data);
485}
486
487static const ppi8255_interface ppi8255_intf =
488{
489   DEVCB_HANDLER(pc98_porta_r),               /* Port A read */
490   DEVCB_HANDLER(pc98_portb_r),               /* Port B read */
491   DEVCB_HANDLER(pc98_portc_r),               /* Port C read */
492   DEVCB_HANDLER(pc98_porta_w),               /* Port A write */
493   DEVCB_HANDLER(pc98_portb_w),               /* Port B write */
494   DEVCB_HANDLER(pc98_portc_w)                  /* Port C write */
495};
496
497static const ppi8255_interface printer_intf =
498{
499   DEVCB_NULL,               /* Port A read */
500   DEVCB_NULL,               /* Port B read */
501   DEVCB_NULL,               /* Port C read */
502   DEVCB_NULL,               /* Port A write */
503   DEVCB_NULL,               /* Port B write */
504   DEVCB_NULL               /* Port C write */
505};
506
308507/* I suspect the dump for pc9801 comes from a i386 later model... the original machine would use a i8086 @ 5Mhz CPU (see notes at top) */
309508/* More investigations are required, but in the meanwhile I set a I386 as main CPU */
310509static MACHINE_DRIVER_START( pc9801 )
r5999r6000
315514
316515   MDRV_MACHINE_RESET(pc9801)
317516
517   MDRV_PPI8255_ADD( "ppi8255_0", ppi8255_intf )
518   MDRV_PPI8255_ADD( "ppi8255_1", printer_intf )
519
318520   /* video hardware */
319521   MDRV_SCREEN_ADD("screen", RASTER)
320522   MDRV_SCREEN_REFRESH_RATE(50)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team