Previous 15994 Revisions Next

r8527 Saturday 17th July, 2010 at 17:04:49 UTC by Angelo Salese
[PASOPIA7]: Rewrote memory map and added MIO bit, a.k.a. the possibility of the HW to access memory mapped stuff from the isolated i/o (!)
[src/mess/drivers]pasopia.c

src/mess/drivers/pasopia.c
r8526r8527
1717#include "sound/sn76496.h"
1818#include "video/mc6845.h"
1919
20static UINT8 vram_sel;
20static UINT8 vram_sel,mio_sel;
2121static UINT8 *p7_vram;
2222static UINT8 bank_reg;
2323static UINT16 cursor_addr;
r8526r8527
6666      p7_vram[offset] = data;
6767}
6868
69static WRITE8_HANDLER( paso7_bankswitch )
69static WRITE8_HANDLER( pasopia7_memory_ctrl_w )
7070{
7171   UINT8 *cpu = memory_region(space->machine, "maincpu");
7272   UINT8 *basic = memory_region(space->machine, "basic");
r8526r8527
9090
9191   bank_reg = data & 3;
9292   vram_sel = data & 4;
93   mio_sel = data & 8;
9394
94   if(data & 8) // as far as I can see, this enables a RAM bankswitch mapped on i/o ports ...
95      printf("Warning: i/o bank write enabled\n");
96
9795   // bank4 is always RAM
9896
9997//   printf("%02x\n",data);
r8526r8527
126124      case 0: pac2_index[pac2_bank_select] = (pac2_index[pac2_bank_select] & 0x7f00) | (data & 0xff); break;
127125      case 1: pac2_index[pac2_bank_select] = (pac2_index[pac2_bank_select] & 0xff) | ((data & 0x7f) << 8); break;
128126      case 2: // RAM write
127         printf("Warning: write to RAM packs\n");
129128         break;
130129      case 3:
131130      {
r8526r8527
180179   }
181180}
182181
182static READ8_HANDLER( pasopia7_io_r )
183{
184   static UINT16 io_port;
183185
186   if(mio_sel)
187   {
188      const address_space *ram_space = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
189      mio_sel = 0;
190      //return 0x0d; // hack: this is used for reading the keyboard data, we can fake it a little ... (modify fda4)
191      return memory_read_byte(ram_space, offset);
192   }
193
194   io_port = offset & 0xff; //trim down to 8-bit bus
195
196   if(io_port >= 0x08 && io_port <= 0x0b)       { return i8255a_r(devtag_get_device(space->machine, "ppi8255_0"), (io_port-0x08) & 3); }
197   else if(io_port >= 0x0c && io_port <= 0x0f) { return i8255a_r(devtag_get_device(space->machine, "ppi8255_1"), (io_port-0x0c) & 3); }
198//   else if(io_port == 0x10 || io_port == 0x11) { M6845 read }
199   else if(io_port >= 0x18 && io_port <= 0x1b) { return pac2_r(space, io_port-0x1b);  }
200   else if(io_port >= 0x20 && io_port <= 0x23) { return i8255a_r(devtag_get_device(space->machine, "ppi8255_2"), (io_port-0x20) & 3); }
201   else if(io_port >= 0x28 && io_port <= 0x2b) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), io_port-0x28);  }
202   else if(io_port >= 0x30 && io_port <= 0x33) { return z80pio_cd_ba_r(devtag_get_device(space->machine, "z80pio_0"), (io_port-0x30) & 3); }
203//   else if(io_port == 0x3a)                  { SN1 }
204//   else if(io_port == 0x3b)                  { SN2 }
205//   else if(io_port == 0x3c)                  { bankswitch }
206//   else if(io_port >= 0xe0 && io_port <= 0xe6) { fdc }
207   else
208   {
209      logerror("(PC=%06x) Read i/o address %02x\n",cpu_get_pc(space->cpu),io_port);
210   }
211   return 0xff;
212}
213
214static WRITE8_HANDLER( pasopia7_io_w )
215{
216   static UINT16 io_port;
217
218   if(mio_sel)
219   {
220      const address_space *ram_space = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
221      mio_sel = 0;
222      memory_write_byte(ram_space, offset, data);
223      return;
224   }
225
226   io_port = offset & 0xff; //trim down to 8-bit bus
227
228   if(io_port >= 0x08 && io_port <= 0x0b)       { i8255a_w(devtag_get_device(space->machine, "ppi8255_0"), (io_port-0x08) & 3, data); }
229   else if(io_port >= 0x0c && io_port <= 0x0f) { i8255a_w(devtag_get_device(space->machine, "ppi8255_1"), (io_port-0x0c) & 3, data); }
230   else if(io_port >= 0x10 && io_port <= 0x11) { pasopia7_6845_w(space, io_port-0x10, data); }
231   else if(io_port >= 0x18 && io_port <= 0x1b) { pac2_w(space, io_port-0x1b, data);  }
232   else if(io_port >= 0x20 && io_port <= 0x23) { i8255a_w(devtag_get_device(space->machine, "ppi8255_2"), (io_port-0x20) & 3, data); }
233   else if(io_port >= 0x28 && io_port <= 0x2b) { z80ctc_w(devtag_get_device(space->machine, "ctc"), io_port-0x28,data);  }
234   else if(io_port >= 0x30 && io_port <= 0x33) { z80pio_cd_ba_w(devtag_get_device(space->machine, "z80pio_0"), (io_port-0x30) & 3, data); }
235   else if(io_port == 0x3a)                  { sn76496_w(devtag_get_device(space->machine, "sn1"), 0, data); }
236   else if(io_port == 0x3b)                  { sn76496_w(devtag_get_device(space->machine, "sn2"), 0, data); }
237   else if(io_port == 0x3c)                  { pasopia7_memory_ctrl_w(space,0, data); }
238//   else if(io_port >= 0xe0 && io_port <= 0xe6) { fdc }
239   else
240   {
241      logerror("(PC=%06x) Write i/o address %02x = %02x\n",cpu_get_pc(space->cpu),offset,data);
242   }
243}
244
184245static ADDRESS_MAP_START(paso7_mem, ADDRESS_SPACE_PROGRAM, 8)
185246   ADDRESS_MAP_UNMAP_HIGH
186247   AM_RANGE( 0x0000, 0x7fff ) AM_WRITE( ram_bank_w )
r8526r8527
192253
193254static ADDRESS_MAP_START( paso7_io , ADDRESS_SPACE_IO, 8)
194255   ADDRESS_MAP_UNMAP_HIGH
195   ADDRESS_MAP_GLOBAL_MASK(0xff)
196   AM_RANGE( 0x08, 0x0b ) AM_DEVREADWRITE("ppi8255_0", i8255a_r, i8255a_w)
197   AM_RANGE( 0x0c, 0x0f ) AM_DEVREADWRITE("ppi8255_1", i8255a_r, i8255a_w)
198   AM_RANGE( 0x10, 0x11 ) AM_WRITE(pasopia7_6845_w)
199   AM_RANGE( 0x18, 0x1b ) AM_READWRITE( pac2_r, pac2_w )
200   AM_RANGE( 0x20, 0x23 ) AM_DEVREADWRITE("ppi8255_2", i8255a_r, i8255a_w)
201   AM_RANGE( 0x28, 0x2b ) AM_DEVREADWRITE("ctc", z80ctc_r, z80ctc_w)
202   AM_RANGE( 0x30, 0x33 ) AM_DEVREADWRITE("z80pio_0", z80pio_cd_ba_r, z80pio_cd_ba_w)
203   AM_RANGE( 0x3a, 0x3a ) AM_DEVWRITE("sn1", sn76496_w)
204   AM_RANGE( 0x3b, 0x3b ) AM_DEVWRITE("sn2", sn76496_w)
205   AM_RANGE( 0x3c, 0x3c ) AM_WRITE(paso7_bankswitch)
206//   AM_RANGE( 0xe0, 0xe6 ) AM_READWRITE( fdc_r, fregdc_w )
256   AM_RANGE( 0x0000, 0xffff) AM_READWRITE( pasopia7_io_r, pasopia7_io_w )
207257ADDRESS_MAP_END
208258
209259/* Input ports */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team