Previous 15994 Revisions Next

r12470 Thursday 4th August, 2011 at 02:14:42 UTC by Barry Rodewald
amstrad.c: Refactored Multiface II support to be an expansion device. [Barry Rodewald]
[src/mess]mess.mak mess_dev.lst
[src/mess/drivers]amstrad.c
[src/mess/includes]amstrad.h
[src/mess/machine]amstrad.c cpcexp.c cpcexp.h mface2.c* mface2.h*

src/mess/machine/amstrad.c
r12469r12470
4242#include "machine/upd765.h"
4343#include "machine/ctronics.h"
4444#include "machine/cpc_rom.h"
45#include "machine/mface2.h"
4546#include "imagedev/cassette.h"
4647#include "imagedev/snapquik.h"
4748#include "includes/amstrad.h"
r12469r12470
11001101   NULL
11011102};
11021103
1103
1104/******************************************************************************************
1105    Multiface emulation
1106  ****************************************************************************************/
1107
1108
1109/* stop button has been pressed */
1110#define MULTIFACE_STOP_BUTTON_PRESSED   0x0001
1111/* ram/rom is paged into memory space */
1112#define MULTIFACE_RAM_ROM_ENABLED      0x0002
1113/* when visible OUT commands are performed! */
1114#define MULTIFACE_VISIBLE            0x0004
1115
1116/* multiface traps calls to 0x0065 when it is active.
1117This address has a RET and so executes no code.
1118
1119It is believed that it is used to make multiface invisible to programs */
1120
1121/*#define MULTIFACE_0065_TOGGLE                   0x0008*/
1122
1123DIRECT_UPDATE_HANDLER( amstrad_default )
1104WRITE_LINE_DEVICE_HANDLER(cpc_romdis)
11241105{
1125   return address;
1126}
1106      amstrad_state *tstate = device->machine().driver_data<amstrad_state>();
11271107
1128/* used to setup computer if a snapshot was specified */
1129DIRECT_UPDATE_HANDLER( amstrad_multiface_directoverride )
1130{
1131   amstrad_state *state = machine.driver_data<amstrad_state>();
1132      int pc;
1133
1134      pc = cpu_get_pc(machine.device("maincpu"));
1135
1136      /* there are two places where CALL &0065 can be found
1137        in the multiface rom. At this address there is a RET.
1138
1139        To disable the multiface from being detected, the multiface
1140        stop button must be pressed, then the program that was stopped
1141        must be returned to. When this is done, the multiface cannot
1142        be detected and the out operations to page the multiface
1143        ram/rom into the address space will not work! */
1144
1145      /* I assume that the hardware in the multiface detects
1146        the PC set to 0x065 and uses this to enable/disable the multiface
1147        */
1148
1149      /* I also use this to allow the stop button to be pressed again */
1150      if (pc==0x0164)
1151      {
1152         /* first call? */
1153         state->m_multiface_flags |= MULTIFACE_VISIBLE;
1154      }
1155      else if (pc==0x0c98)
1156      {
1157        /* second call */
1158
1159        /* no longer visible */
1160        state->m_multiface_flags &= ~(MULTIFACE_VISIBLE|MULTIFACE_STOP_BUTTON_PRESSED);
1161
1162       /* clear op base override */
1163        machine.device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(amstrad_default), &machine));
1164      }
1165
1166      return pc;
1108   tstate->m_gate_array.romdis = state;
1109   amstrad_rethinkMemory(device->machine());
11671110}
11681111
1169static void multiface_init(running_machine &machine)
1112WRITE_LINE_DEVICE_HANDLER(cpc_romen)
11701113{
1171   amstrad_state *state = machine.driver_data<amstrad_state>();
1172   /* after a reset the multiface is visible */
1173   state->m_multiface_flags = MULTIFACE_VISIBLE;
1114      amstrad_state *tstate = device->machine().driver_data<amstrad_state>();
11741115
1175   /* allocate ram */
1176   state->m_multiface_ram = auto_alloc_array(machine, UINT8, 8192);
1116      if(state != 0)
1117         tstate->m_gate_array.mrer &= ~0x04;
1118      else
1119         tstate->m_gate_array.mrer |= 0x04;
1120   amstrad_rethinkMemory(device->machine());
11771121}
11781122
1179/* call when a system reset is done */
1180static void multiface_reset(amstrad_state *state)
1181{
1182      /* stop button not pressed and ram/rom disabled */
1183      state->m_multiface_flags &= ~(MULTIFACE_STOP_BUTTON_PRESSED |
1184                  MULTIFACE_RAM_ROM_ENABLED);
1185      /* as on the real hardware the multiface is visible after a reset! */
1186      state->m_multiface_flags |= MULTIFACE_VISIBLE;
1187}
11881123
1189static int multiface_hardware_enabled(running_machine &machine)
1190{
1191   amstrad_state *state = machine.driver_data<amstrad_state>();
1192      if (state->m_multiface_ram!=NULL)
1193      {
1194            if ((input_port_read(machine, "multiface") & 0x01)!=0)
1195            {
1196                  return 1;
1197            }
1198      }
1199
1200      return 0;
1201}
1202
1203
1204static void multiface_rethink_memory(running_machine &machine)
1205{
1206   amstrad_state *state = machine.driver_data<amstrad_state>();
1207   unsigned char *multiface_rom;
1208
1209   /* multiface hardware enabled? */
1210   if (!multiface_hardware_enabled(machine))
1211      return;
1212
1213   multiface_rom = &machine.region("maincpu")->base()[0x01C000];
1214
1215   if (
1216      ((state->m_multiface_flags & MULTIFACE_RAM_ROM_ENABLED)!=0) &&
1217      ((state->m_gate_array.mrer & 0x04) == 0)
1218      )
1219   {
1220
1221      /* set bank addressess */
1222      memory_set_bankptr(machine,"bank1", multiface_rom);
1223      memory_set_bankptr(machine,"bank2", state->m_multiface_ram);
1224      memory_set_bankptr(machine,"bank9", multiface_rom);
1225      memory_set_bankptr(machine,"bank10", state->m_multiface_ram);
1226   }
1227}
1228
1229
1230/* simulate the stop button has been pressed */
1231static void multiface_stop(running_machine &machine)
1232{
1233   amstrad_state *state = machine.driver_data<amstrad_state>();
1234   /* multiface hardware enabled? */
1235   if (!multiface_hardware_enabled(machine))
1236      return;
1237
1238   /* if stop button not already pressed, do press action */
1239   /* pressing stop button while multiface is running has no effect */
1240   if ((state->m_multiface_flags & MULTIFACE_STOP_BUTTON_PRESSED)==0)
1241   {
1242      /* initialise 0065 toggle */
1243            /*state->m_multiface_flags &= ~MULTIFACE_0065_TOGGLE;*/
1244
1245      state->m_multiface_flags |= MULTIFACE_RAM_ROM_ENABLED;
1246
1247      /* stop button has been pressed, furthur pressess will not issue a NMI */
1248      state->m_multiface_flags |= MULTIFACE_STOP_BUTTON_PRESSED;
1249
1250      state->m_gate_array.mrer &=~0x04;
1251
1252      /* page rom into memory */
1253      multiface_rethink_memory(machine);
1254
1255      /* pulse the nmi line */
1256      cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
1257
1258      /* initialise 0065 override to monitor calls to 0065 */
1259      machine.device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(amstrad_multiface_directoverride), &machine));
1260   }
1261
1262}
1263
1264
1265/* any io writes are passed through here */
1266static WRITE8_HANDLER(multiface_io_write)
1267{
1268   amstrad_state *state = space->machine().driver_data<amstrad_state>();
1269   /* multiface hardware enabled? */
1270      if (!multiface_hardware_enabled(space->machine()))
1271      return;
1272
1273      /* visible? */
1274   if (state->m_multiface_flags & MULTIFACE_VISIBLE)
1275   {
1276      if (offset==0x0fee8)
1277      {
1278         state->m_multiface_flags |= MULTIFACE_RAM_ROM_ENABLED;
1279         amstrad_rethinkMemory(space->machine());
1280      }
1281
1282      if (offset==0x0feea)
1283      {
1284         state->m_multiface_flags &= ~MULTIFACE_RAM_ROM_ENABLED;
1285         amstrad_rethinkMemory(space->machine());
1286      }
1287   }
1288
1289   /* update multiface ram with data */
1290      /* these are decoded fully! */
1291      switch ((offset>>8) & 0x0ff)
1292      {
1293            /* gate array */
1294            case 0x07f:
1295            {
1296                  switch (data & 0x0c0)
1297                  {
1298                        /* pen index */
1299                        case 0x00:
1300                        {
1301                           state->m_multiface_ram[0x01fcf] = data;
1302
1303                        }
1304                        break;
1305
1306                        /* pen colour */
1307                        case 0x040:
1308                        {
1309                           int pen_index;
1310
1311                           pen_index = state->m_multiface_ram[0x01fcf] & 0x0f;
1312
1313                           if (state->m_multiface_ram[0x01fcf] & 0x010)
1314                           {
1315
1316                              state->m_multiface_ram[0x01fdf + pen_index] = data;
1317                           }
1318                           else
1319                           {
1320                              state->m_multiface_ram[0x01f90 + pen_index] = data & 0x01f;
1321                           }
1322
1323                        }
1324                        break;
1325
1326                        /* rom/mode selection */
1327                        case 0x080:
1328                        {
1329
1330                           state->m_multiface_ram[0x01fef] = data;
1331
1332                        }
1333                        break;
1334
1335                        /* ram configuration */
1336                        case 0x0c0:
1337                        {
1338
1339                           state->m_multiface_ram[0x01fff] = data;
1340
1341                        }
1342                        break;
1343
1344                        default:
1345                          break;
1346
1347                  }
1348
1349            }
1350            break;
1351
1352
1353            /* crtc register index */
1354            case 0x0bc:
1355            {
1356                  state->m_multiface_ram[0x01cff] = data;
1357            }
1358            break;
1359
1360            /* crtc register write */
1361            case 0x0bd:
1362            {
1363                  int reg_index;
1364
1365                  reg_index = state->m_multiface_ram[0x01cff] & 0x0f;
1366
1367                  state->m_multiface_ram[0x01db0 + reg_index] = data;
1368            }
1369            break;
1370
1371
1372            /* 8255 ppi control */
1373            case 0x0f7:
1374            {
1375              state->m_multiface_ram[0x017ff] = data;
1376
1377            }
1378            break;
1379
1380            /* rom select */
1381            case 0x0df:
1382            {
1383               state->m_multiface_ram[0x01aac] = data;
1384            }
1385            break;
1386
1387            default:
1388               break;
1389
1390      }
1391
1392}
1393
1394
13951124/*--------------------------
13961125  - Ram and Rom management -
13971126  --------------------------*/
r12469r12470
14061135   /* b2 : "1" Lower rom area disable or "0" Lower rom area enable */
14071136   if ( state->m_system_type == SYSTEM_CPC || state->m_system_type == SYSTEM_ALESTE )
14081137   {
1409      if ((state->m_gate_array.mrer & (1<<2)) == 0)
1138      if ((state->m_gate_array.mrer & (1<<2)) == 0 && state->m_gate_array.romdis == 0)
14101139      {
14111140         bank_base = &machine.region("maincpu")->base()[0x010000];
14121141      }
r12469r12470
14491178         memory_set_bankptr(machine,"bank6", state->m_AmstradCPC_RamBanks[2]+0x2000);
14501179      }
14511180
1452      if ( (state->m_gate_array.mrer & (1<<2)) == 0)
1181      if ( (state->m_gate_array.mrer & (1<<2)) == 0 && state->m_gate_array.romdis == 0)
14531182      {  // ASIC secondary lower ROM selection (bit 5: 1 = enabled)
14541183         if ( state->m_asic.enabled )
14551184         {
r12469r12470
14981227   UINT8 *bank_base = NULL;
14991228
15001229   /* b3 : "1" Upper rom area disable or "0" Upper rom area enable */
1501   if ( ! ( state->m_gate_array.mrer & 0x08 ) )
1230   if ( ! ( state->m_gate_array.mrer & 0x08 ) && state->m_gate_array.romdis == 0)
15021231   {
15031232      bank_base = state->m_Amstrad_ROM_Table[ state->m_gate_array.upper_bank ];
15041233   }
r12469r12470
22101939   amstrad_state *state = space->machine().driver_data<amstrad_state>();
22111940   device_t *fdc = space->machine().device("upd765");
22121941   mc6845_device *mc6845 = space->machine().device<mc6845_device>("mc6845");
1942   cpc_multiface2_device* mface2;
22131943
22141944   if ((offset & (1<<15)) == 0)
22151945   {
r12469r12470
23672097      mc6845->set_clock( ( state->m_aleste_mode & 0x02 ) ? ( XTAL_16MHz / 8 ) : ( XTAL_16MHz / 16 ) );
23682098   }
23692099
2370   multiface_io_write(space, offset, data);
2100   mface2 = space->machine().device<cpc_multiface2_device>("exp:multiface2");
2101   if(mface2 != NULL)
2102   {
2103      if(mface2->multiface_io_write(offset, data) != 0)
2104         amstrad_rethinkMemory(space->machine());
2105   }
23712106}
23722107
23732108
r12469r12470
25292264
25302265   if ( state->m_system_type == SYSTEM_PLUS || state->m_system_type == SYSTEM_GX4000 )
25312266      memset(state->m_asic.ram,0,16384);  // clear ASIC RAM
2532
2533   multiface_reset(state);
25342267}
25352268
25362269
r12469r12470
25402273static void amstrad_rethinkMemory(running_machine &machine)
25412274{
25422275   amstrad_state *state = machine.driver_data<amstrad_state>();
2276   cpc_multiface2_device* mface2;
25432277   /* the following is used for banked memory read/writes and for setting up
25442278     * opcode and opcode argument reads */
25452279
r12469r12470
25972331   }
25982332
25992333   /* multiface hardware enabled? */
2600   if (multiface_hardware_enabled(machine))
2334   mface2 = machine.device<cpc_multiface2_device>("exp:multiface2");
2335   if(mface2 != NULL)
26012336   {
2602      multiface_rethink_memory(machine);
2337      if (mface2->multiface_hardware_enabled())
2338      {
2339         if((state->m_gate_array.mrer & 0x04) == 0)
2340            mface2->multiface_rethink_memory();
2341      }
26032342   }
26042343}
26052344
r12469r12470
26162355
26172356SCREEN_EOF( amstrad )
26182357{
2619   if (input_port_read_safe(machine, "multiface", 0) & 0x02)
2358   cpc_multiface2_device* mface2 = machine.device<cpc_multiface2_device>("exp:multiface2");
2359   if(mface2 != NULL)
26202360   {
2621      multiface_stop(machine);
2361      mface2->check_button_state();
26222362   }
26232363}
26242364
r12469r12470
31382878MACHINE_START( amstrad )
31392879{
31402880   amstrad_state *state = machine.driver_data<amstrad_state>();
3141   multiface_init(machine);
31422881   state->m_system_type = SYSTEM_CPC;
31432882}
31442883
r12469r12470
32643003MACHINE_START( kccomp )
32653004{
32663005   amstrad_state *state = machine.driver_data<amstrad_state>();
3267   multiface_init(machine);
32683006   state->m_system_type = SYSTEM_CPC;
32693007}
32703008
r12469r12470
32963034MACHINE_START( aleste )
32973035{
32983036   amstrad_state *state = machine.driver_data<amstrad_state>();
3299   multiface_init(machine);
33003037   state->m_system_type = SYSTEM_ALESTE;
33013038}
33023039
src/mess/machine/cpcexp.c
r12469r12470
7070       memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb));
7171       memset(&m_out_nmi_cb, 0, sizeof(m_out_nmi_cb));
7272       memset(&m_out_reset_cb, 0, sizeof(m_out_reset_cb));
73       memset(&m_out_romdis_cb, 0, sizeof(m_out_romdis_cb));
74       memset(&m_out_romen_cb, 0, sizeof(m_out_romen_cb));
7375   }
7476}
7577
r12469r12470
8688   m_out_irq_func.resolve(m_out_irq_cb, *this);
8789   m_out_nmi_func.resolve(m_out_nmi_cb, *this);
8890   m_out_reset_func.resolve(m_out_reset_cb, *this);
91   m_out_romdis_func.resolve(m_out_romdis_cb, *this);
92   m_out_romen_func.resolve(m_out_romen_cb, *this);
8993}
9094
9195
r12469r12470
101105WRITE_LINE_MEMBER( cpc_expansion_slot_device::irq_w ) { m_out_irq_func(state); }
102106WRITE_LINE_MEMBER( cpc_expansion_slot_device::nmi_w ) { m_out_nmi_func(state); }
103107WRITE_LINE_MEMBER( cpc_expansion_slot_device::reset_w ) { m_out_reset_func(state); }
108WRITE_LINE_MEMBER( cpc_expansion_slot_device::romdis_w ) { m_out_romdis_func(state); }
109WRITE_LINE_MEMBER( cpc_expansion_slot_device::romen_w ) { m_out_romen_func(state); }
src/mess/machine/cpcexp.h
r12469r12470
7272    devcb_write_line   m_out_irq_cb;
7373    devcb_write_line   m_out_nmi_cb;
7474    devcb_write_line   m_out_reset_cb;
75    devcb_write_line   m_out_romdis_cb;
76    devcb_write_line   m_out_romen_cb;
7577};
7678
7779
78// ======================> device_c64_expansion_card_interface
80// ======================> device_cpc_expansion_card_interface
7981
80// class representing interface-specific live c64_expansion card
82// class representing interface-specific live cpc_expansion card
8183class device_cpc_expansion_card_interface : public device_interface
8284{
8385public:
r12469r12470
9092};
9193
9294
93// ======================> c64_expansion_slot_device
95// ======================> cpc_expansion_slot_device
9496
9597class cpc_expansion_slot_device : public device_t,
9698                          public cpc_expansion_slot_interface,
r12469r12470
104106   DECLARE_WRITE_LINE_MEMBER( irq_w );
105107   DECLARE_WRITE_LINE_MEMBER( nmi_w );
106108   DECLARE_WRITE_LINE_MEMBER( reset_w );
109   DECLARE_WRITE_LINE_MEMBER( romdis_w );
110   DECLARE_WRITE_LINE_MEMBER( romen_w );
107111
108112protected:
109113   // device-level overrides
r12469r12470
114118   devcb_resolved_write_line   m_out_irq_func;
115119   devcb_resolved_write_line   m_out_nmi_func;
116120   devcb_resolved_write_line   m_out_reset_func;
121    devcb_resolved_write_line   m_out_romdis_func;
122    devcb_resolved_write_line   m_out_romen_func;
117123
118124   device_cpc_expansion_card_interface *m_card;
119125};
src/mess/machine/mface2.c
r0r12470
1/*
2 * mface2.c  --  Romantic Robot Multiface II expansion device for the Amstrad CPC/CPC+
3 *
4 *  Created on: 31/07/2011
5 */
6
7#include "emu.h"
8#include "machine/mface2.h"
9
10//**************************************************************************
11//  DEVICE DEFINITIONS
12//**************************************************************************
13
14const device_type CPC_MFACE2 = &device_creator<cpc_multiface2_device>;
15
16
17DIRECT_UPDATE_MEMBER( cpc_multiface2_device::amstrad_default )
18{
19   return address;
20}
21
22/* used to setup computer if a snapshot was specified */
23DIRECT_UPDATE_MEMBER( cpc_multiface2_device::amstrad_multiface_directoverride )
24{
25      int pc;
26
27      pc = cpu_get_pc(machine().device("maincpu"));
28      /* there are two places where CALL &0065 can be found
29        in the multiface rom. At this address there is a RET.
30
31        To disable the multiface from being detected, the multiface
32        stop button must be pressed, then the program that was stopped
33        must be returned to. When this is done, the multiface cannot
34        be detected and the out operations to page the multiface
35        ram/rom into the address space will not work! */
36
37      /* I assume that the hardware in the multiface detects
38        the PC set to 0x065 and uses this to enable/disable the multiface
39        */
40
41      /* I also use this to allow the stop button to be pressed again */
42      if (pc==0x0164)
43      {
44         /* first call? */
45         m_multiface_flags |= MULTIFACE_VISIBLE;
46      }
47      else if (pc==0x0c98)
48      {
49        /* second call */
50
51        /* no longer visible */
52        m_multiface_flags &= ~(MULTIFACE_VISIBLE|MULTIFACE_STOP_BUTTON_PRESSED);
53
54        m_romdis=0;
55        m_slot->romen_w(0);
56
57       /* clear op base override */
58       machine().device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(cpc_multiface2_device::amstrad_default),this));
59       popmessage("DIRECT_UPDATE set to default");
60      }
61
62      return pc;
63}
64
65int cpc_multiface2_device::multiface_hardware_enabled()
66{
67   if (m_multiface_ram!=NULL)
68   {
69      if ((input_port_read(machine(), "exp:multiface2:multiface") & 0x01)!=0)
70      {
71         return 1;
72      }
73   }
74
75   return 0;
76}
77
78/* multiface traps calls to 0x0065 when it is active.
79This address has a RET and so executes no code.
80
81It is believed that it is used to make multiface invisible to programs */
82
83/*#define MULTIFACE_0065_TOGGLE                   0x0008*/
84
85
86void cpc_multiface2_device::multiface_rethink_memory()
87{
88   unsigned char *multiface_rom;
89
90   /* multiface hardware enabled? */
91   if (!multiface_hardware_enabled())
92      return;
93
94   multiface_rom = machine().region("exp:multiface2:multiface")->base();
95
96   if ((m_multiface_flags & MULTIFACE_RAM_ROM_ENABLED)!=0 && m_romdis != 0)
97   {
98      /* set bank addressess */
99      memory_set_bankptr(machine(),"bank1", multiface_rom);
100      memory_set_bankptr(machine(),"bank2", m_multiface_ram);
101      memory_set_bankptr(machine(),"bank9", multiface_rom);
102      memory_set_bankptr(machine(),"bank10", m_multiface_ram);
103   }
104}
105
106void cpc_multiface2_device::check_button_state()
107{
108   if(!multiface_hardware_enabled())
109      return;
110   // TODO: reset button
111   if (input_port_read(machine(), "exp:multiface2:multiface") & 0x02)
112   {
113      multiface_stop();
114   }
115}
116
117/* simulate the stop button has been pressed */
118void cpc_multiface2_device::multiface_stop()
119{
120   /* multiface hardware enabled? */
121   if (!multiface_hardware_enabled())
122      return;
123
124   /* if stop button not already pressed, do press action */
125   /* pressing stop button while multiface is running has no effect */
126   if ((m_multiface_flags & MULTIFACE_STOP_BUTTON_PRESSED)==0)
127   {
128      /* initialise 0065 toggle */
129            /*state->m_multiface_flags &= ~MULTIFACE_0065_TOGGLE;*/
130
131      m_multiface_flags |= MULTIFACE_RAM_ROM_ENABLED;
132
133      /* stop button has been pressed, furthur pressess will not issue a NMI */
134      m_multiface_flags |= MULTIFACE_STOP_BUTTON_PRESSED;
135
136      m_romdis = 1;
137      m_slot->romen_w(1);
138
139      /* page rom into memory */
140      multiface_rethink_memory();
141
142      /* pulse the nmi line */
143      m_slot->nmi_w(PULSE_LINE);
144
145      /* initialise 0065 override to monitor calls to 0065 */
146      machine().device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(cpc_multiface2_device::amstrad_multiface_directoverride),this));
147      popmessage("DIRECT_UPDATE set to Multiface");
148   }
149}
150
151/* any io writes are passed through here */
152int cpc_multiface2_device::multiface_io_write(UINT16 offset, UINT8 data)
153{
154   int ret = 0;
155
156   /* multiface hardware enabled? */
157   if (!multiface_hardware_enabled())
158      return 0;
159
160      /* visible? */
161   if (m_multiface_flags & MULTIFACE_VISIBLE)
162   {
163      if (offset==0x0fee8)
164      {
165         m_multiface_flags |= MULTIFACE_RAM_ROM_ENABLED;
166         ret = 1;
167      }
168
169      if (offset==0x0feea)
170      {
171         m_multiface_flags &= ~MULTIFACE_RAM_ROM_ENABLED;
172         ret = 1;
173      }
174   }
175
176   /* update multiface ram with data */
177   /* these are decoded fully! */
178   switch ((offset>>8) & 0x0ff)
179   {
180         /* gate array */
181         case 0x07f:
182         {
183               switch (data & 0x0c0)
184               {
185                     /* pen index */
186                     case 0x00:
187                     {
188                        m_multiface_ram[0x01fcf] = data;
189                     }
190                     break;
191                        /* pen colour */
192                     case 0x040:
193                     {
194                        int pen_index;
195                        pen_index = m_multiface_ram[0x01fcf] & 0x0f;
196                        if (m_multiface_ram[0x01fcf] & 0x010)
197                        {
198                              m_multiface_ram[0x01fdf + pen_index] = data;
199                        }
200                     else
201                        {
202                           m_multiface_ram[0x01f90 + pen_index] = data & 0x01f;
203                        }
204                     }
205                     break;
206                        /* rom/mode selection */
207                     case 0x080:
208                     {
209                           m_multiface_ram[0x01fef] = data;
210                        }
211                     break;
212                        /* ram configuration */
213                     case 0x0c0:
214                     {
215                           m_multiface_ram[0x01fff] = data;
216                     }
217                     break;
218                     default:
219                 break;
220            }
221         }
222         break;
223
224         /* crtc register index */
225         case 0x0bc:
226         {
227               m_multiface_ram[0x01cff] = data;
228         }
229         break;
230         /* crtc register write */
231         case 0x0bd:
232         {
233               int reg_index;
234               reg_index = m_multiface_ram[0x01cff] & 0x0f;
235               m_multiface_ram[0x01db0 + reg_index] = data;
236         }
237         break;
238
239
240         /* 8255 ppi control */
241         case 0x0f7:
242         {
243            m_multiface_ram[0x017ff] = data;
244         }
245         break;
246         /* rom select */
247         case 0x0df:
248         {
249            m_multiface_ram[0x01aac] = data;
250         }
251         break;
252         default:
253            break;
254   }
255   return ret;
256}
257
258static INPUT_PORTS_START(cpc_mface2)
259   PORT_START("multiface")
260   PORT_CONFNAME(0x01, 0x00, "Multiface Two" )
261   PORT_CONFSETTING(0x00, DEF_STR( Off) )
262   PORT_CONFSETTING(0x01, DEF_STR( On) )
263   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Stop Button") PORT_CODE(KEYCODE_F6)
264   //  PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Reset Button") PORT_CODE(KEYCODE_F3)  Not implemented
265INPUT_PORTS_END
266
267
268
269//-------------------------------------------------
270//  Device ROM definition
271//-------------------------------------------------
272
273// Second known revision (1988)
274ROM_START( cpc_mface2 )
275   ROM_REGION( 0x2000, "multiface", 0 )
276   ROM_LOAD("multface.rom", 0x0000, 0x2000, CRC(f36086de) SHA1(1431ec628d38f000715545dd2186b684c5fe5a6f))
277ROM_END
278
279//-------------------------------------------------
280//  rom_region - device-specific ROM region
281//-------------------------------------------------
282
283const rom_entry *cpc_multiface2_device::device_rom_region() const
284{
285   return ROM_NAME( cpc_mface2 );
286}
287
288ioport_constructor cpc_multiface2_device::device_input_ports() const
289{
290   return INPUT_PORTS_NAME( cpc_mface2 );
291}
292
293//**************************************************************************
294//  LIVE DEVICE
295//**************************************************************************
296
297cpc_multiface2_device::cpc_multiface2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
298   device_t(mconfig, CPC_MFACE2, "Multiface II", tag, owner, clock),
299   device_cpc_expansion_card_interface(mconfig, *this),
300   device_slot_card_interface(mconfig, *this)
301{
302}
303
304//-------------------------------------------------
305//  device_start - device-specific startup
306//-------------------------------------------------
307
308void cpc_multiface2_device::device_start()
309{
310   m_slot = dynamic_cast<cpc_expansion_slot_device *>(owner());
311
312   /* after a reset the multiface is visible */
313   m_multiface_flags = MULTIFACE_VISIBLE;
314
315   /* allocate ram */
316   m_multiface_ram = auto_alloc_array(machine(), UINT8, 8192);
317}
318
319//-------------------------------------------------
320//  device_reset - device-specific reset
321//-------------------------------------------------
322
323void cpc_multiface2_device::device_reset()
324{
325   /* stop button not pressed and ram/rom disabled */
326   m_multiface_flags &= ~(MULTIFACE_STOP_BUTTON_PRESSED |
327               MULTIFACE_RAM_ROM_ENABLED);
328   /* as on the real hardware the multiface is visible after a reset! */
329   m_multiface_flags |= MULTIFACE_VISIBLE;
330}
src/mess/machine/mface2.h
r0r12470
1/*
2 * mface2.h  --  Romantic Robot Multiface II expansion device for the Amstrad CPC/CPC+
3 *
4 *  Created on: 31/07/2011
5 *
6 *  I/O Ports:
7 *    -  FEE8: Enables Multiface ROM and RAM
8 *    -  FEEA: Disables Multiface ROM and RAM
9 *
10 *  When enabled, Multiface ROM is mapped to &0000, and RAM to &2000
11 *
12 *  When the Stop button is pressed, the Multiface II will generate an NMI
13 *  (I guess the ROM/RAM is enabled when you do this also?)
14 *
15 *  It also monitors all I/O port writes, so that it can restore them when resuming the current application.
16 */
17
18#ifndef MFACE2_H_
19#define MFACE2_H_
20
21#include "emu.h"
22#include "machine/cpcexp.h"
23
24/* stop button has been pressed */
25#define MULTIFACE_STOP_BUTTON_PRESSED   0x0001
26/* ram/rom is paged into memory space */
27#define MULTIFACE_RAM_ROM_ENABLED      0x0002
28/* when visible OUT commands are performed! */
29#define MULTIFACE_VISIBLE            0x0004
30
31
32class cpc_multiface2_device :    public device_t,
33                        public device_cpc_expansion_card_interface,
34                        public device_slot_card_interface
35{
36public:
37   // construction/destruction
38   cpc_multiface2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
39
40   // optional information overrides
41   virtual const rom_entry *device_rom_region() const;
42   virtual ioport_constructor device_input_ports() const;
43
44   int multiface_hardware_enabled();
45   void multiface_rethink_memory();
46   void multiface_stop();
47   int multiface_io_write(UINT16 offset, UINT8 data);
48   void check_button_state();
49protected:
50   // device-level overrides
51   virtual void device_start();
52   virtual void device_reset();
53    virtual void device_config_complete() { m_shortname = "cpc_mf2"; }
54
55private:
56   cpc_expansion_slot_device *m_slot;
57
58   DIRECT_UPDATE_MEMBER( amstrad_default );
59   DIRECT_UPDATE_MEMBER( amstrad_multiface_directoverride );
60
61   unsigned char *m_multiface_ram;
62   unsigned long m_multiface_flags;
63
64   UINT8 m_romdis;
65};
66
67// device type definition
68extern const device_type CPC_MFACE2;
69
70#endif /* MFACE2_H_ */
src/mess/includes/amstrad.h
r12469r12470
2020   UINT8   pen_selected;      /* Pen selection */
2121   UINT8   mrer;            /* Mode and ROM Enable Register */
2222   UINT8   upper_bank;
23   UINT8   romdis;  // ROMDIS signal from the expansion port
2324
2425   /* input signals from CRTC */
2526   int      vsync;
r12469r12470
103104   UINT8 m_mode0_lookup[256];
104105   UINT8 m_mode1_lookup[256];
105106   UINT8 m_mode2_lookup[256];
106   unsigned char *m_multiface_ram;
107   unsigned long m_multiface_flags;
108107   int m_prev_data;
109108   int m_printer_bit8_selected;
110109   unsigned char m_Psg_FunctionSelected;
r12469r12470
130129READ8_HANDLER ( amstrad_psg_porta_read );
131130
132131WRITE_LINE_DEVICE_HANDLER( aleste_interrupt );
132WRITE_LINE_DEVICE_HANDLER( cpc_romdis );
133WRITE_LINE_DEVICE_HANDLER( cpc_romen );
133134
134135MACHINE_START( amstrad );
135136MACHINE_RESET( amstrad );
src/mess/mess_dev.lst
r12469r12470
107107VIC1112
108108ABC_UNI800
109109ABC_SLUTPROV
110CPC_SSA1
111CPC_DKSPEECH
110CPC_SSA1  // uses internal SP0256 ROM
111CPC_DKSPEECH  // uses internal SP0256 ROM
112CPC_MFACE2
112113C64_XL80
114
src/mess/mess.mak
r12469r12470
601601   $(MESS_MACHINE)/cpcexp.o   \
602602   $(MESS_MACHINE)/cpc_ssa1.o   \
603603   $(MESS_MACHINE)/cpc_rom.o   \
604   $(MESS_MACHINE)/mface2.o   \
604605   $(MESS_DRIVERS)/amstr_pc.o   \
605606   $(MESS_MACHINE)/amstr_pc.o   \
606607   $(MESS_DRIVERS)/pc1512.o   \
src/mess/drivers/amstrad.c
r12469r12470
111111#include "machine/cpcexp.h"
112112#include "machine/cpc_ssa1.h"
113113#include "machine/cpc_rom.h"
114#include "machine/mface2.h"
114115
115116#include "machine/ram.h"
116117
r12469r12470
124125#define SYSTEM_GX4000 2
125126
126127
127
128128/* -----------------------------
129129   - amstrad_ppi8255_interface -
130130   -----------------------------*/
r12469r12470
390390//  PORT_CONFSETTING(M6845_PERSONALITY_AMS40489, "Type 3 - AMS40489")
391391//  PORT_CONFSETTING(M6845_PERSONALITY_PREASIC, "Type 4 - Pre-ASIC")
392392
393   PORT_START("multiface")
394   PORT_CONFNAME(0x01, 0x00, "Multiface Two" )
395   PORT_CONFSETTING(0x00, DEF_STR( Off) )
396   PORT_CONFSETTING(0x01, DEF_STR( On) )
397   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Stop Button") PORT_CODE(KEYCODE_F1)
398//  PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Reset Button") PORT_CODE(KEYCODE_F3)  Not implemented
399
400393   PORT_START("green_display")
401394   PORT_CONFNAME( 0x01, 0x00, "Monitor" ) PORT_CHANGED( cpc_monitor_changed, 0 )
402395   PORT_CONFSETTING(0x00, "CTM640 Colour Monitor" )
r12469r12470
775768   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD)  PORT_NAME("Funny looking Russian symbol")     PORT_CODE(KEYCODE_END)
776769
777770   PORT_INCLUDE(crtc_links)
778   PORT_MODIFY("multiface")  // move Multiface II stop to F6, as the Aleste has it's own F1-F5 keys.
779   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Stop Button") PORT_CODE(KEYCODE_F6)
780771INPUT_PORTS_END
781772
782773
r12469r12470
875866{
876867   DEVCB_CPU_INPUT_LINE("maincpu", 0),
877868   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_NMI),
878   DEVCB_NULL  // RESET
869   DEVCB_NULL,  // RESET
870   DEVCB_LINE(cpc_romdis),  // ROMDIS
871   DEVCB_LINE(cpc_romen)  // /ROMEN
879872};
880873
881874static SLOT_INTERFACE_START(cpc_exp_cards)
882875   SLOT_INTERFACE("ssa1", CPC_SSA1)
883876   SLOT_INTERFACE("dkspeech", CPC_DKSPEECH)
884877   SLOT_INTERFACE("rom", CPC_ROM)
878   SLOT_INTERFACE("multiface2", CPC_MFACE2)
885879SLOT_INTERFACE_END
886880
881static SLOT_INTERFACE_START(cpcplus_exp_cards)
882   SLOT_INTERFACE("ssa1", CPC_SSA1)
883   SLOT_INTERFACE("dkspeech", CPC_DKSPEECH)
884   SLOT_INTERFACE("rom", CPC_ROM)
885SLOT_INTERFACE_END
886
887887static MACHINE_CONFIG_FRAGMENT( cpcplus_cartslot )
888888   MCFG_CARTSLOT_ADD("cart")
889889   MCFG_CARTSLOT_EXTENSION_LIST("cpr,bin")
r12469r12470
10091009
10101010   MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(cpc6128_floppy_interface)
10111011
1012   MCFG_CPC_EXPANSION_SLOT_ADD("exp",cpc_exp_intf,cpc_exp_cards,NULL,NULL)
1012   MCFG_CPC_EXPANSION_SLOT_ADD("exp",cpc_exp_intf,cpcplus_exp_cards,NULL,NULL)
10131013
10141014   /* internal ram */
10151015   MCFG_RAM_ADD(RAM_TAG)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team