Previous 15994 Revisions Next

r3671 Thursday 27th November, 2008 at 18:40:31 UTC by Nathan Woods
Reenabled Kaypro and KIM-1
[src/mess]mess.mak messdriv.c
[src/mess/drivers]kim1.c
[src/mess/machine]cpm_bios.c cpm_bios.h kaypro.c sms.c
[src/mess/video]kaypro.c

src/mess/video/kaypro.c
r3670r3671
125125
126126static void kaypro_putstr(running_machine *machine, const char * src)
127127{
128   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
128129   while (*src)
129      kaypro_conout_w(machine, 0, *src++);
130      kaypro_conout_w(space, 0, *src++);
130131}
131132
132133static int kaypro_getcursorcode(int code)
src/mess/messdriv.c
r3670r3671
306306//128u4   DRIVER( a800xl )   /* 1983 Atari 800 XL                        */
307307
308308   /* COMMODORE */
309//128u4   DRIVER( kim1 )      /* Commodore (MOS) KIM-1 1975                  */
309   DRIVER( kim1 )      /* Commodore (MOS) KIM-1 1975                  */
310310//128u4   DRIVER( sym1 )      /* Synertek SYM-1                           */
311311//128u4   DRIVER( aim65 )      /* Rockwell AIM65                           */
312312
r3670r3671
578578   DRIVER( ep128 )      /* Enterprise 128 k                           */
579579
580580   /* NON LINEAR SYSTEMS */
581//128u4   DRIVER( kaypro )   /* Kaypro 2X                              */
581   DRIVER( kaypro )   /* Kaypro 2X                              */
582582
583583   /* VEB MIKROELEKTRONIK */
584584   /* KC compact is partial CPC compatible */
src/mess/machine/sms.c
r3670r3671
998998   } else {
999999      /* Pull reset line of CPU #0 low */
10001000      cpunum_suspend( 0, SUSPEND_REASON_HALT, 1 );
1001      cpunum_reset( 0 );
1001      cpu_reset(machine->cpu[0]);
10021002   }
10031003   sms_store_control = data;
10041004}
src/mess/machine/kaypro.c
r3670r3671
152152 ******************************************************/
153153INTERRUPT_GEN( kaypro_interrupt )
154154{
155   const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
155156   int mod, row, col, chg, new;
156157   static int lastrow = 0, mask = 0x00, key = 0x00, repeat = 0, repeater = 0;
157158
r3670r3671
167168   }
168169
169170   row = 9;
170   new = input_port_read(machine, "ROW9");
171   new = input_port_read(device->machine, "ROW9");
171172   chg = keyrows[row] ^ new;
172173
173   if (!chg) { new = input_port_read(machine, "ROW8"); chg = keyrows[--row] ^ new; }
174   if (!chg) { new = input_port_read(machine, "ROW7"); chg = keyrows[--row] ^ new; }
175   if (!chg) { new = input_port_read(machine, "ROW6"); chg = keyrows[--row] ^ new; }
176   if (!chg) { new = input_port_read(machine, "ROW5"); chg = keyrows[--row] ^ new; }
177   if (!chg) { new = input_port_read(machine, "ROW4"); chg = keyrows[--row] ^ new; }
178   if (!chg) { new = input_port_read(machine, "ROW3"); chg = keyrows[--row] ^ new; }
179   if (!chg) { new = input_port_read(machine, "ROW2"); chg = keyrows[--row] ^ new; }
180   if (!chg) { new = input_port_read(machine, "ROW1"); chg = keyrows[--row] ^ new; }
181   if (!chg) { new = input_port_read(machine, "ROW0"); chg = keyrows[--row] ^ new; }
174   if (!chg) { new = input_port_read(device->machine, "ROW8"); chg = keyrows[--row] ^ new; }
175   if (!chg) { new = input_port_read(device->machine, "ROW7"); chg = keyrows[--row] ^ new; }
176   if (!chg) { new = input_port_read(device->machine, "ROW6"); chg = keyrows[--row] ^ new; }
177   if (!chg) { new = input_port_read(device->machine, "ROW5"); chg = keyrows[--row] ^ new; }
178   if (!chg) { new = input_port_read(device->machine, "ROW4"); chg = keyrows[--row] ^ new; }
179   if (!chg) { new = input_port_read(device->machine, "ROW3"); chg = keyrows[--row] ^ new; }
180   if (!chg) { new = input_port_read(device->machine, "ROW2"); chg = keyrows[--row] ^ new; }
181   if (!chg) { new = input_port_read(device->machine, "ROW1"); chg = keyrows[--row] ^ new; }
182   if (!chg) { new = input_port_read(device->machine, "ROW0"); chg = keyrows[--row] ^ new; }
182183   if (!chg) --row;
183184
184185   if (row >= 0)
r3670r3671
222223         if( key )   /* normal key */
223224         {
224225            repeater = 30;
225            kaypro_conin_w(machine, 0, key);
226            kaypro_conin_w(space, 0, key);
226227         }
227228         else
228229         if( (row == 0) && (chg == 0x04) ) /* Ctrl-@ (NUL) */
229            kaypro_conin_w(machine, 0, 0);
230            kaypro_conin_w(space, 0, 0);
230231         keyrows[row] |= new;
231232      }
232233      else
r3670r3671
237238   }
238239   else if ( key && (keyrows[lastrow] & mask) && repeat == 0 )
239240   {
240      kaypro_conin_w(machine, 0, key);
241      kaypro_conin_w(space, 0, key);
241242   }
242243}
243244
src/mess/machine/cpm_bios.c
r3670r3671
7777 *   initialize bios functions at addresses BIOS_00 .. BIOS_11
7878 *   and the central bios execute function at BIOS_EXEC
7979 *****************************************************************************/
80static void cpm_jumptable(void)
80static void cpm_jumptable(running_machine *machine)
8181{
82   UINT8 * RAM = memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000);
82   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
83   UINT8 * RAM = memory_get_write_ptr(space, 0x0000);
8384   int i;
8485   int jmp_addr, fun_addr;
8586
r3670r3671
132133 *****************************************************************************/
133134int cpm_init( running_machine *machine, int n, const char *const ids[])
134135{
135   UINT8 * RAM = memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000);
136   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
137   UINT8 * RAM = memory_get_write_ptr(space, 0x0000);
136138   const dsk_fmt *f;
137139   int i, d;
138140
r3670r3671
258260   /* create a file to receive list output (ie. PIP LST:=FILE.EXT) */
259261   mame_fopen(SEARCHPATH_IMAGE, "cpm.lst", OPEN_FLAG_WRITE, &lp);
260262
261   cpm_jumptable();
263   cpm_jumptable(machine);
262264
263265   add_exit_callback(machine, cpm_exit);
264266   return 0;
r3670r3671
293295 * cpm_conout_chr
294296 * send a character to the console
295297 *****************************************************************************/
296static void cpm_conout_chr(int data)
298static void cpm_conout_chr(running_machine *machine, int data)
297299{
298   io_write_byte(BIOS_CONOUT, data);
300   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_IO);
301   memory_write_byte(space, BIOS_CONOUT, data);
299302}
300303
301304/*****************************************************************************
302305 * cpm_conout_str
303306 * send a zero terminated string to the console
304307 *****************************************************************************/
305static void cpm_conout_str(const char *src)
308static void cpm_conout_str(running_machine *machine, const char *src)
306309{
307310   while (*src)
308      cpm_conout_chr(*src++);
311      cpm_conout_chr(machine, *src++);
309312}
310313
311314/*****************************************************************************
r3670r3671
500503   dma = d;
501504}
502505
503static void dump_sector(void)
506static void dump_sector(running_machine *machine)
504507{
505   UINT8 *DMA = ((UINT8 *) memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000)) + dma;
508   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
509   UINT8 *DMA = ((UINT8 *) memory_get_write_ptr(space, 0x0000)) + dma;
506510
507511   {
508512      int i;
r3670r3671
522526   }
523527}
524528
525int cpm_disk_read_sector(void)
529int cpm_disk_read_sector(running_machine *machine)
526530{
531   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
527532   int result = -1;
528533
529534   /* TODO: remove this */
530   unsigned char *RAM = memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000);
535   unsigned char *RAM = memory_get_write_ptr(space, 0x0000);
531536
532537   if (curdisk >= 0 &&
533538      curdisk < num_disks &&
r3670r3671
548553   {
549554      logerror("BDOS Err on %c: Select\n", curdisk + 'A');
550555   }
551      dump_sector();
556   dump_sector(machine);
552557   return result;
553558}
554559
555int cpm_disk_write_sector(void)
560int cpm_disk_write_sector(running_machine *machine)
556561{
562   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
557563   int result = -1;
558564
559565   /* TODO: remove this */
560   unsigned char *RAM = memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000);
566   unsigned char *RAM = memory_get_write_ptr(space, 0x0000);
561567
562568   if (curdisk >= 0 &&
563569      curdisk < num_disks &&
r3670r3671
588594{
589595   const dsk_fmt *f;
590596   char buff[256];
591   UINT8 * RAM = memory_get_write_ptr(0, ADDRESS_SPACE_PROGRAM, 0x0000);
597   const address_space *program_space = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
598   UINT8 * RAM = memory_get_write_ptr(program_space, 0x0000);
592599   UINT16 tmp, af, bc, de, hl;
593600   int i;
594601
595602   /* Get the values of the basic Z80 registers */
596   af = activecpu_get_reg( Z80_AF );
597   bc = activecpu_get_reg( Z80_BC );
598   de = activecpu_get_reg( Z80_DE );
599   hl = activecpu_get_reg( Z80_HL );
603   af = cpu_get_reg( space->machine->cpu[0], Z80_AF );
604   bc = cpu_get_reg( space->machine->cpu[0], Z80_BC );
605   de = cpu_get_reg( space->machine->cpu[0], Z80_DE );
606   hl = cpu_get_reg( space->machine->cpu[0], Z80_HL );
600607
601608   switch( data )
602609   {
r3670r3671
604611      if (VERBOSE)
605612         logerror("BIOS 00 cold boot\n");
606613
607      cpm_conout_str("MESS CP/M 2.2 Emulator\r\n\n");
614      cpm_conout_str(space->machine, "MESS CP/M 2.2 Emulator\r\n\n");
608615      for (i = 0; i < NDSK; i++)
609616      {
610617         if (fmt[i] != -1)
r3670r3671
619626               (f->density == DEN_FM_LO || f->density == DEN_FM_HI) ? "SD" : "DD",
620627               f->spt, f->seclen,
621628               f->dpb.dsm + 1, (RECL << f->dpb.bsh) / 1024);
622            cpm_conout_str(buff);
629            cpm_conout_str(space->machine, buff);
623630         }
624631      }
625632      /* change vector at 0000 to warm start */
r3670r3671
639646
640647      /* copy the CP/M 2.2 image to Z80 memory space */
641648      for (i = 0; i < 0x1600; i++)
642         RAM[CCP + i] = memory_region(machine, "cpu1")[i];
649         RAM[CCP + i] = memory_region(space->machine, "cpu1")[i];
643650
644651      /* build the bios jump table */
645      cpm_jumptable();
652      cpm_jumptable(space->machine);
646653      bc = curdisk;
647      cpu_set_reg(machine->activecpu,  Z80_BC, bc );
648      cpu_set_reg(machine->activecpu,  Z80_SP, 0x0080  );
649      cpu_set_reg(machine->activecpu,  Z80_PC, CCP + 3 );
654      cpu_set_reg(space->machine->cpu[0],  Z80_BC, bc );
655      cpu_set_reg(space->machine->cpu[0],  Z80_SP, 0x0080  );
656      cpu_set_reg(space->machine->cpu[0],  Z80_PC, CCP + 3 );
650657      break;
651658
652659   case 0x02: /* CSTAT */
653      tmp = io_read_byte(BIOS_CONST) & 0xff;
660      tmp = memory_read_byte(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), BIOS_CONST) & 0xff;
654661      af = (af & 0xff) | (tmp << 8);
655662
656663      if (VERBOSE_CONIO)
r3670r3671
658665      break;
659666
660667   case 0x03: /* CONIN */
661      if ( io_read_byte(BIOS_CONST) == 0 )
668      if ( memory_read_byte(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), BIOS_CONST) == 0 )
662669      {
663         cpu_set_reg(machine->activecpu, Z80_PC, activecpu_get_reg(Z80_PC) - 2 );
670         cpu_set_reg(space->machine->cpu[0], Z80_PC, cpu_get_reg(space->machine->cpu[0], Z80_PC) - 2 );
664671         break;
665672      }
666      tmp = io_read_byte(BIOS_CONIN) & 0xff;
673      tmp = memory_read_byte(cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_IO), BIOS_CONIN) & 0xff;
667674      af = (af & 0xff) | (tmp << 8);
668675      if (VERBOSE_CONIO)
669676         logerror("BIOS 03 console input       A:%02X\n", tmp);
r3670r3671
673680      tmp = bc & 0xff;
674681      if (VERBOSE_CONIO)
675682         logerror("BIOS 04 console output      C:%02X\n", tmp);
676      cpm_conout_chr( tmp );
683      cpm_conout_chr( space->machine, tmp );
677684      break;
678685
679686   case 0x05: /* LSTOUT */
r3670r3671
751758
752759
753760   case 0x0d: /* RDSEC */
754      tmp = cpm_disk_read_sector();
761      tmp = cpm_disk_read_sector(space->machine);
755762      af = (af & 0xff) | (tmp << 8);
756763
757764      if (VERBOSE_BIOS)
r3670r3671
760767
761768
762769   case 0x0e: /* WRSEC */
763      tmp = cpm_disk_write_sector();
770      tmp = cpm_disk_write_sector(space->machine);
764771      af = (af & 0xff) | (tmp << 8);
765772
766773      if (VERBOSE_BIOS)
r3670r3671
805812
806813
807814   case 0x11: /* TRAP */
808      cpm_conout_str(buff);
815      cpm_conout_str(space->machine, buff);
809816      break;
810817   }
811818
812819   /* Write back the possibly modified Z80 basic registers */
813   cpu_set_reg(machine->activecpu,  Z80_AF, af );
814   cpu_set_reg(machine->activecpu,  Z80_BC, bc );
815   cpu_set_reg(machine->activecpu,  Z80_DE, de );
816   cpu_set_reg(machine->activecpu,  Z80_HL, hl );
820   cpu_set_reg(space->machine->cpu[0], Z80_AF, af );
821   cpu_set_reg(space->machine->cpu[0], Z80_BC, bc );
822   cpu_set_reg(space->machine->cpu[0], Z80_DE, de );
823   cpu_set_reg(space->machine->cpu[0], Z80_HL, hl );
817824}
818825
src/mess/machine/cpm_bios.h
r3670r3671
159159extern void cpm_disk_set_track(int t);
160160extern void cpm_disk_set_sector(int s);
161161extern void cpm_disk_set_dma(int d);
162extern int cpm_disk_read_sector(void);
163extern int cpm_disk_write_sector(void);
162extern int cpm_disk_read_sector(running_machine *machine);
163extern int cpm_disk_write_sector(running_machine *machine);
164164
165165#endif  /* _CPM_BIOS_H */
src/mess/mess.mak
r3670r3671
403403   $(MESSOBJ)/intv.a \
404404   $(MESSOBJ)/irisha.a \
405405   $(MESSOBJ)/jupiter.a \
406   $(MESSOBJ)/kaypro.a \
407   $(MESSOBJ)/kim1.a \
406408   $(MESSOBJ)/kramermc.a \
407409   $(MESSOBJ)/luxor.a \
408410   $(MESSOBJ)/lviv.a \
r3670r3671
465467#   $(MESSOBJ)/glasgow.a \
466468#   $(MESSOBJ)/gmaster.a \
467469#   $(MESSOBJ)/hp48.a \
468#   $(MESSOBJ)/kaypro.a \
469#   $(MESSOBJ)/kim1.a \
470470#   $(MESSOBJ)/lynx.a \
471471#   $(MESSOBJ)/mephisto.a \
472472#   $(MESSOBJ)/mk1.a \
src/mess/drivers/kim1.c
r3670r3671
105105
106106static INPUT_CHANGED( kim1_reset )
107107{
108   if ( newval == 0 )
109      cpunum_reset( 0 );
108   if (newval == 0)
109      cpu_reset(field->port->machine->cpu[0]);
110110}
111111
112112
r3670r3671
289289
290290static MACHINE_START( kim1 )
291291{
292   state_save_register_item( "kim1", 0, kim1_u2_port_b );
293   state_save_register_item( "kim1", 0, kim1_311_output );
294   state_save_register_item( "kim1", 0, kim1_cassette_high_count );
292   state_save_register_item( "kim1", NULL, 0, kim1_u2_port_b );
293   state_save_register_item( "kim1", NULL, 0, kim1_311_output );
294   state_save_register_item( "kim1", NULL, 0, kim1_cassette_high_count );
295295}
296296
297297

Previous 15994 Revisions Next


© 1998-2018 The MESS Team