Previous 15994 Revisions Next

r5367 Friday 7th August, 2009 at 06:45:23 UTC by Barry Rodewald
[PCW] Replaced boot code with what is output by the usual boot sequence, fixed interrupts, and a small tweak to the upd765 seek/recalibrate time. System will now boot CP/M.
[src/mess/drivers]pcw.c
[src/mess/machine]nec765.c

src/mess/machine/nec765.c
r5366r5367
467467{
468468   nec765_t *fdc = get_safe_token(device);
469469   /* setup timer to signal after seek time is complete */
470   timer_adjust_periodic(fdc->seek_timer, attotime_zero, 0, double_to_attotime(fdc->srt_in_ms*abs(signed_tracks)*0.001));
470   timer_adjust_oneshot(fdc->seek_timer, double_to_attotime(fdc->srt_in_ms*abs(signed_tracks)*0.001), 0);
471471}
472472
473473static void nec765_seek_setup(const device_config *device, int is_recalibrate)
src/mess/drivers/pcw.c
r5366r5367
102102// pcw/pcw16 beeper
103103#include "sound/beep.h"
104104
105#define VERBOSE
105#define VERBOSE 1
106106#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
107107
108108static NEC765_INTERRUPT( pcw_fdc_interrupt );
r5366r5367
118118unsigned char pcw_vdu_video_control_register;
119119static int pcw_interrupt_counter;
120120
121static unsigned long pcw_banks[4];
121static UINT8 pcw_banks[4];
122122static unsigned char pcw_bank_force = 0;
123123
124124
r5366r5367
150150      ((fdc_interrupt_code==1) && ((pcw_system_status & (1<<5))!=0))
151151      )
152152   {
153      cputag_set_input_line(machine, "maincpu", 0,HOLD_LINE);
153      if(cpu_get_reg(cputag_get_cpu(machine,"maincpu"),Z80_IFF1))
154         cputag_set_input_line(machine, "maincpu", 0,ASSERT_LINE);
154155   }
155156   else
156157   {
r5366r5367
194195            {
195196               /* I'll pulse it because if I used hold-line I'm not sure
196197                    it would clear - to be checked */
197               cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
198               cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
198199            }
199200         }
200201      }
r5366r5367
218219/* fdc interrupt callback. set/clear fdc int */
219220static NEC765_INTERRUPT( pcw_fdc_interrupt )
220221{
221   pcw_system_status &= ~(1<<5);
222222
223   if (state)
224   {
225      /* fdc interrupt occured */
223   if (state == CLEAR_LINE)
224      pcw_system_status &= ~(1<<5);
225   else
226226      pcw_system_status |= (1<<5);
227   }
228227
229228   pcw_trigger_fdc_int(device->machine);
230229}
r5366r5367
263262static void pcw_update_read_memory_block(running_machine *machine, int block, int bank)
264263{
265264   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
266   memory_set_bankptr(machine, block + 1, mess_ram + ((bank * 0x4000) % mess_ram_size));
267265
268266   /* bank 3? */
269267   if (bank == 3)
r5366r5367
273271      memory_install_read8_handler(space,
274272         block * 0x04000 + 0x3ff0, block * 0x04000 + 0x3fff, 0, 0,
275273         pcw_keyboard_r);
274      LOG(("MEM: read block %i -> bank %i\n",block,bank));
276275   }
277276   else
278277   {
r5366r5367
280279      memory_install_read8_handler(space,
281280         block * 0x04000 + 0x0000, block * 0x04000 + 0x3fff, 0, 0,
282281         (read8_space_func) (STATIC_BANK1 + (FPTR)block));
282      LOG(("MEM: read block %i -> bank %i\n",block,bank));
283283   }
284   memory_set_bankptr(machine, block + 1, mess_ram + ((bank * 0x4000) % mess_ram_size));
284285}
285286
286287
r5366r5367
288289static void pcw_update_write_memory_block(running_machine *machine, int block, int bank)
289290{
290291   memory_set_bankptr(machine, block + 5, mess_ram + ((bank * 0x4000) % mess_ram_size));
292   LOG(("MEM: write block %i -> bank %i\n",block,bank));
291293}
292294
293295
r5366r5367
322324      {
323325         case 0:
324326         {
325            mask = (1<<6);
327            mask = (1<<7);
326328         }
327329         break;
328330
r5366r5367
334336
335337         case 2:
336338         {
337            mask = (1<<5);
339            mask = (1<<6);
338340         }
339341         break;
340342
341343         case 3:
342344         {
343            mask = (1<<7);
345            mask = (1<<5);
344346         }
345347         break;
346348      }
r5366r5367
374376/* from Jacob Nevins docs */
375377static int pcw_get_sys_status(running_machine *machine)
376378{
377   return pcw_interrupt_counter | (input_port_read(machine, "EXTRA") & (0x040 | 0x010)) | pcw_system_status;
379   return pcw_interrupt_counter | (input_port_read(machine, "EXTRA") & (0x040 | 0x010)) | (pcw_system_status & 0x20);
378380}
379381
380382static READ8_HANDLER(pcw_interrupt_counter_r)
r5366r5367
390392   /* update interrupt */
391393   pcw_interrupt_handle(space->machine);
392394   /* return data */
395   LOG(("SYS: IRQ counter read, returning %02x\n",data));
393396   return data;
394397}
395398
r5366r5367
420423
421424   roller_ram_addr = (((data>>5) & 0x07)<<14) |
422425                     ((data & 0x01f)<<9);
426   LOG(("Roller-RAM: Address set to 0x%05x\n",roller_ram_addr));
423427}
424428
425429static WRITE8_HANDLER(pcw_pointer_table_top_scan_w)
426430{
427431   roller_ram_offset = data;
432   LOG(("Roller-RAM: offset set to 0x%05x\n",roller_ram_offset));
428433}
429434
430435static WRITE8_HANDLER(pcw_vdu_video_control_register_w)
431436{
432437   pcw_vdu_video_control_register = data;
438   LOG(("Roller-RAM: control reg set to 0x%02x\n",data));
433439}
434440
435441static WRITE8_HANDLER(pcw_system_control_w)
r5366r5367
451457      /* reboot */
452458      case 1:
453459      {
460         popmessage("SYS: Reboot");
454461      }
455462      break;
456463
r5366r5367
505512         fdc_interrupt_code = 2;
506513
507514         /* previously connected to NMI or INT? */
508         if ((fdc_previous_interrupt_code == 0) || (fdc_previous_interrupt_code == 1))
515         if ((fdc_previous_interrupt_code == 0))
509516         {
510517            /* yes */
511518
r5366r5367
513520            cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
514521
515522         }
523         pcw_interrupt_handle(space->machine);
516524
517         pcw_interrupt_handle(space->machine);
518525      }
519526      break;
520527
r5366r5367
587594static READ8_HANDLER(pcw_system_status_r)
588595{
589596   /* from Jacob Nevins docs */
590   return pcw_get_sys_status(space->machine);
597   UINT8 ret = pcw_get_sys_status(space->machine);
598   
599   LOG(("SYS: Status port returning %02x\n",ret));
600   return ret;
591601}
592602
593603/* read from expansion hardware - additional hardware not part of
r5366r5367
596606{
597607   logerror("pcw expansion r: %04x\n",offset+0x080);
598608
599   switch (offset-0x080)
609   switch (offset+0x080)
600610   {
601611      case 0x0e0:
602612      {
r5366r5367
619629      }
620630
621631      case 0x0e1:
632      case 0x0e3:
622633      {
623         return 0x07f;
634         return 0x7f;
624635      }
625636
626637      case 0x085:
r5366r5367
691702
692703static  READ8_HANDLER(pcw_printer_status_r)
693704{
694   return 0x0ff;
705   return 0xff;
695706}
696707
697708/* TODO: Implement parallel port! */
r5366r5367
714725
715726
716727static ADDRESS_MAP_START(pcw_io, ADDRESS_SPACE_IO, 8)
717   AM_RANGE(0x000, 0x07f) AM_READWRITE(pcw_fdc_r,               pcw_fdc_w)
728   ADDRESS_MAP_GLOBAL_MASK(0xff)
729   AM_RANGE(0x000, 0x07f) AM_READWRITE(pcw_fdc_r,               pcw_fdc_w) 
718730   AM_RANGE(0x080, 0x0ef) AM_READWRITE(pcw_expansion_r,         pcw_expansion_w)
719731   AM_RANGE(0x0f0, 0x0f3) AM_WRITE(                        pcw_bank_select_w)
720732   AM_RANGE(0x0f4, 0x0f4) AM_READWRITE(pcw_interrupt_counter_r,   pcw_bank_force_selection_w)
r5366r5367
729741
730742
731743static ADDRESS_MAP_START(pcw9512_io, ADDRESS_SPACE_IO, 8)
744   ADDRESS_MAP_GLOBAL_MASK(0xff)
732745   AM_RANGE(0x000, 0x07f) AM_READWRITE(pcw_fdc_r,               pcw_fdc_w)
733746   AM_RANGE(0x080, 0x0ef) AM_READWRITE(pcw_expansion_r,         pcw_expansion_w)
734747   AM_RANGE(0x0f0, 0x0f3) AM_WRITE(                        pcw_bank_select_w)
r5366r5367
752765
753766static MACHINE_START( pcw )
754767{
755   fdc_interrupt_code = 0;
768   fdc_interrupt_code = 2;
756769   floppy_drive_set_geometry(image_from_devtype_and_index(machine, IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80);
757770}
758771
772static MACHINE_RESET( pcw )
773{
774   /* ram paging is actually undefined at power-on */
775   pcw_bank_force = 0x00;
776   
777   pcw_banks[0] = 0x00;
778   pcw_banks[1] = 0x01;
779   pcw_banks[2] = 0x02;
780   pcw_banks[3] = 0x03;
759781
782   pcw_update_mem(machine, 0, pcw_banks[0]);
783   pcw_update_mem(machine, 1, pcw_banks[1]);
784   pcw_update_mem(machine, 2, pcw_banks[2]);
785   pcw_update_mem(machine, 3, pcw_banks[3]);
786}
787
760788static DRIVER_INIT(pcw)
761789{
762   pcw_boot = 1;
790   UINT8* code = memory_region(machine,"bootcode");
791   int x;
792   pcw_boot = 0;
763793
764794   cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), 0, 0x0ff);
765795
796   /* copy boot code into RAM - yes, it's skipping a step,
797      but there is no verified dump of the boot sequence */
766798
767   /* ram paging is actually undefined at power-on */
768   pcw_banks[0] = 0;
769   pcw_banks[1] = 1;
770   pcw_banks[2] = 2;
771   pcw_banks[3] = 3;
799   memset(mess_ram,0x00,mess_ram_size);   
800   for(x=0;x<256;x++)
801      mess_ram[x+2] = code[x];
772802
773   pcw_update_mem(machine, 0, pcw_banks[0]);
774   pcw_update_mem(machine, 1, pcw_banks[1]);
775   pcw_update_mem(machine, 2, pcw_banks[2]);
776   pcw_update_mem(machine, 3, pcw_banks[3]);
777
778803   /* lower 4 bits are interrupt counter */
779804   pcw_system_status = 0x000;
780805   pcw_system_status &= ~((1<<6) | (1<<5) | (1<<4));
r5366r5367
9891014   MDRV_CPU_ADD("maincpu", Z80, 4000000)       /* clock supplied to chip, but in reality it is 3.4 MHz */
9901015   MDRV_CPU_PROGRAM_MAP(pcw_map)
9911016   MDRV_CPU_IO_MAP(pcw_io)
992   MDRV_QUANTUM_TIME(HZ(60))
1017   MDRV_QUANTUM_TIME(HZ(50))
9931018
9941019   MDRV_MACHINE_START(pcw)
1020   MDRV_MACHINE_RESET(pcw)
9951021
9961022    /* video hardware */
9971023   MDRV_SCREEN_ADD("screen", RASTER)
r5366r5367
10311057
10321058/* I am loading the boot-program outside of the Z80 memory area, because it
10331059is banked. */
1060/* 8256boot.bin is not a real ROM, it is what is loaded into RAM by the boot sequence
1061   It was typed in by hand based on the disassembly found at
1062   http://www.chiark.greenend.org.uk/~jacobn/cpm/pcwboot.html  */
10341063
10351064// for now all models use the same rom
10361065#define ROM_PCW(model)                                    \
10371066   ROM_START(model)                                    \
1038      ROM_REGION(0x014000, "maincpu",0)                     \
1039      ROM_LOAD("pcwboot.bin", 0x010000, 608, BAD_DUMP CRC(679b0287) SHA1(5dde974304e3376ace00850d6b4c8ec3b674199e))   \
1067      ROM_REGION(0x010000, "maincpu",0)                     \
1068      ROM_FILL(0x0000,0x10000,0x00)                                 \
1069/*      ROM_LOAD("pcwboot.bin", 0x010000, 608, BAD_DUMP CRC(679b0287) SHA1(5dde974304e3376ace00850d6b4c8ec3b674199e))*/   \
1070      ROM_REGION(256,"bootcode",0)                        \
1071      ROM_LOAD("8256boot.bin", 0, 256, NO_DUMP CRC(d55925bd) SHA1(bca6a47d657557be99cb8580d4bf90968d8dde4a))   \
10401072   ROM_END                                             \
10411073
10421074ROM_PCW(pcw8256)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team