Previous 199869 Revisions Next

r18017 Wednesday 19th September, 2012 at 13:19:23 UTC by Miodrag Milanović
More cleanup on mess side (nw)
[src/mess/drivers]astrocde.c n64.c

trunk/src/mess/drivers/astrocde.c
r18016r18017
1313#include "imagedev/cartslot.h"
1414#include "machine/ram.h"
1515
16MACHINE_RESET( astrocde );
17void get_ram_expansion_settings(address_space &space, int &ram_expansion_installed, int &write_protect_on, int &expansion_ram_start, int &expansion_ram_end, int &shadow_ram_end);
16class astrocde_mess_state : public astrocde_state
17{
18public:
19   astrocde_mess_state(const machine_config &mconfig, device_type type, const char *tag)
20      : astrocde_state(mconfig, type, tag)
21      { }
1822
23   void get_ram_expansion_settings(int &ram_expansion_installed, int &write_protect_on, int &expansion_ram_start, int &expansion_ram_end, int &shadow_ram_end);
24   DECLARE_MACHINE_RESET(astrocde);
25   DECLARE_INPUT_CHANGED_MEMBER(set_write_protect);
26};
27
28
1929/*************************************
2030 *
2131 *  Memory maps
r18016r18017
7686 *
7787 *************************************/
7888
79static ADDRESS_MAP_START( astrocade_mem, AS_PROGRAM, 8, astrocde_state )
89static ADDRESS_MAP_START( astrocade_mem, AS_PROGRAM, 8, astrocde_mess_state )
8090   AM_RANGE(0x0000, 0x0fff) AM_ROM AM_WRITE(astrocade_funcgen_w)
8191   AM_RANGE(0x1000, 0x3fff) AM_ROM /* Star Fortress writes in here?? */
8292   AM_RANGE(0x4000, 0x4fff) AM_RAM AM_SHARE("videoram") /* ASG */
8393ADDRESS_MAP_END
8494
8595
86static ADDRESS_MAP_START( astrocade_io, AS_IO, 8, astrocde_state )
96static ADDRESS_MAP_START( astrocade_io, AS_IO, 8, astrocde_mess_state )
8797   AM_RANGE(0x00, 0x1f) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(astrocade_data_chip_register_r, astrocade_data_chip_register_w)
8898ADDRESS_MAP_END
8999
90static INPUT_CHANGED( set_write_protect )  // run when RAM expansion write protect switch is changed
100INPUT_CHANGED_MEMBER(astrocde_mess_state::set_write_protect)  // run when RAM expansion write protect switch is changed
91101{
92102   int ram_expansion_installed = 0, write_protect_on = 0, expansion_ram_start = 0, expansion_ram_end = 0, shadow_ram_end = 0;
93   address_space &space = *field.machine().device("maincpu")->memory().space(AS_PROGRAM);
94   UINT8 *expram = field.machine().device<ram_device>("ram_tag")->pointer();
103   address_space &space = *machine().device("maincpu")->memory().space(AS_PROGRAM);
104   UINT8 *expram = machine().device<ram_device>("ram_tag")->pointer();
95105
96   get_ram_expansion_settings(space, ram_expansion_installed, write_protect_on, expansion_ram_start, expansion_ram_end, shadow_ram_end);  // passing by reference
106   get_ram_expansion_settings(ram_expansion_installed, write_protect_on, expansion_ram_start, expansion_ram_end, shadow_ram_end);  // passing by reference
97107
98108    if (ram_expansion_installed == 1)
99109    {
r18016r18017
225235   PORT_DIPSETTING(   0x20, "32KB Blue RAM Expansion")
226236
227237   PORT_START("PROTECT")  /* Write protect RAM */
228   PORT_DIPNAME( 0x01, 0x00, "Write Protect RAM") PORT_CHANGED(set_write_protect, 0)
238   PORT_DIPNAME( 0x01, 0x00, "Write Protect RAM") PORT_CHANGED_MEMBER(DEVICE_SELF, astrocde_mess_state, set_write_protect, 0)
229239   PORT_DIPSETTING( 0x00, "Write Protect Off")
230240   PORT_DIPSETTING( 0x01, "Write Protect On")
231241INPUT_PORTS_END
r18016r18017
237247 *
238248 *************************************/
239249
240static MACHINE_CONFIG_START( astrocde, astrocde_state )
250static MACHINE_CONFIG_START( astrocde, astrocde_mess_state )
241251   /* basic machine hardware */
242252   MCFG_CPU_ADD("maincpu", Z80, ASTROCADE_CLOCK/4)        /* 1.789 MHz */
243253   MCFG_CPU_PROGRAM_MAP(astrocade_mem)
244254   MCFG_CPU_IO_MAP(astrocade_io)
245255
246   MCFG_MACHINE_RESET( astrocde )
256   MCFG_MACHINE_RESET_OVERRIDE(astrocde_mess_state, astrocde)
247257
248258   /* video hardware */
249259   MCFG_SCREEN_ADD("screen", RASTER)
r18016r18017
307317   m_video_config = AC_SOUND_PRESENT | AC_LIGHTPEN_INTS;
308318}
309319
310MACHINE_RESET( astrocde )
320MACHINE_RESET_MEMBER(astrocde_mess_state, astrocde)
311321{
312322    int ram_expansion_installed = 0, write_protect_on = 0, expansion_ram_start = 0, expansion_ram_end = 0, shadow_ram_end = 0;
313    address_space &space = *machine.device("maincpu")->memory().space(AS_PROGRAM);
314    UINT8 *expram = machine.device<ram_device>("ram_tag")->pointer();
323    address_space &space = *machine().device("maincpu")->memory().space(AS_PROGRAM);
324    UINT8 *expram = machine().device<ram_device>("ram_tag")->pointer();
315325    space.unmap_readwrite(0x5000, 0xffff);  // unmap any previously installed expansion RAM
316326
317    get_ram_expansion_settings(space, ram_expansion_installed, write_protect_on, expansion_ram_start, expansion_ram_end, shadow_ram_end);  // passing by reference
327    get_ram_expansion_settings(ram_expansion_installed, write_protect_on, expansion_ram_start, expansion_ram_end, shadow_ram_end);  // passing by reference
318328
319329    if (ram_expansion_installed == 1)
320330    {
r18016r18017
331341     }
332342}
333343
334void get_ram_expansion_settings(address_space &space, int &ram_expansion_installed, int &write_protect_on, int &expansion_ram_start, int &expansion_ram_end, int &shadow_ram_end)
344void astrocde_mess_state::get_ram_expansion_settings(int &ram_expansion_installed, int &write_protect_on, int &expansion_ram_start, int &expansion_ram_end, int &shadow_ram_end)
335345{
336    if (space.machine().root_device().ioport("PROTECT")->read() == 0x01)
346    if (machine().root_device().ioport("PROTECT")->read() == 0x01)
337347        write_protect_on = 1;
338348    else
339349        write_protect_on = 0;
340350
341351    ram_expansion_installed = 1;
342352
343    switch(space.machine().root_device().ioport("CFG")->read())  // check RAM expansion configuration and set address ranges
353    switch(machine().root_device().ioport("CFG")->read())  // check RAM expansion configuration and set address ranges
344354    {
345355        case 0x00:  // No RAM Expansion
346356             ram_expansion_installed = 0;
trunk/src/mess/drivers/n64.c
r18016r18017
1414#include "imagedev/cartslot.h"
1515#include "includes/n64.h"
1616
17static READ32_HANDLER( dd_null_r )
17class n64_mess_state : public n64_state
1818{
19public:
20   n64_mess_state(const machine_config &mconfig, device_type type, const char *tag)
21      : n64_state(mconfig, type, tag)
22      { }
23
24   DECLARE_READ32_MEMBER(dd_null_r);
25   DECLARE_MACHINE_START(n64dd);
26   INTERRUPT_GEN_MEMBER(n64_reset_poll);
27};
28
29READ32_MEMBER(n64_mess_state::dd_null_r)
30{
1931   return 0xffffffff;
2032}
2133
22static ADDRESS_MAP_START( n64_map, AS_PROGRAM, 32, n64_state )
34static ADDRESS_MAP_START( n64_map, AS_PROGRAM, 32, n64_mess_state )
2335   AM_RANGE(0x00000000, 0x007fffff) AM_RAM   AM_SHARE("rdram")               // RDRAM
2436   AM_RANGE(0x03f00000, 0x03f00027) AM_DEVREADWRITE("rcp", n64_periphs, rdram_reg_r, rdram_reg_w)
2537   AM_RANGE(0x04000000, 0x04000fff) AM_RAM AM_SHARE("rsp_dmem")               // RSP DMEM
r18016r18017
3244   AM_RANGE(0x04600000, 0x046fffff) AM_DEVREADWRITE("rcp", n64_periphs, pi_reg_r, pi_reg_w)   // Peripheral Interface
3345   AM_RANGE(0x04700000, 0x047fffff) AM_DEVREADWRITE("rcp", n64_periphs, ri_reg_r, ri_reg_w)   // RDRAM Interface
3446   AM_RANGE(0x04800000, 0x048fffff) AM_DEVREADWRITE("rcp", n64_periphs, si_reg_r, si_reg_w)   // Serial Interface
35   AM_RANGE(0x05000508, 0x0500050b) AM_READ_LEGACY(dd_null_r);
47   AM_RANGE(0x05000508, 0x0500050b) AM_READ(dd_null_r);
3648   AM_RANGE(0x08000000, 0x0801ffff) AM_RAM AM_SHARE("sram")                              // Cartridge SRAM
3749   AM_RANGE(0x10000000, 0x13ffffff) AM_ROM AM_REGION("user2", 0)                           // Cartridge
3850   AM_RANGE(0x1fc00000, 0x1fc007bf) AM_ROM AM_REGION("user1", 0)                           // PIF ROM
3951   AM_RANGE(0x1fc007c0, 0x1fc007ff) AM_DEVREADWRITE("rcp", n64_periphs, pif_ram_r, pif_ram_w)
4052ADDRESS_MAP_END
4153
42static ADDRESS_MAP_START( n64dd_map, AS_PROGRAM, 32, n64_state )
54static ADDRESS_MAP_START( n64dd_map, AS_PROGRAM, 32, n64_mess_state )
4355   AM_RANGE(0x00000000, 0x007fffff) AM_RAM   AM_SHARE("rdram")            // RDRAM
4456   AM_RANGE(0x03f00000, 0x03f00027) AM_DEVREADWRITE("rcp", n64_periphs, rdram_reg_r, rdram_reg_w)
4557   AM_RANGE(0x04000000, 0x04000fff) AM_RAM AM_SHARE("rsp_dmem")               // RSP DMEM
r18016r18017
6072   AM_RANGE(0x1fc007c0, 0x1fc007ff) AM_DEVREADWRITE("rcp", n64_periphs, pif_ram_r, pif_ram_w)
6173ADDRESS_MAP_END
6274
63static ADDRESS_MAP_START( rsp_map, AS_PROGRAM, 32, n64_state )
75static ADDRESS_MAP_START( rsp_map, AS_PROGRAM, 32, n64_mess_state )
6476   AM_RANGE(0x00000000, 0x00000fff) AM_RAM AM_SHARE("rsp_dmem")
6577   AM_RANGE(0x00001000, 0x00001fff) AM_RAM AM_SHARE("rsp_imem")
6678   AM_RANGE(0x04000000, 0x04000fff) AM_RAM AM_SHARE("rsp_dmem")
r18016r18017
232244   return IMAGE_INIT_PASS;
233245}
234246
235MACHINE_START( n64dd )
247MACHINE_START_MEMBER(n64_mess_state,n64dd)
236248{
237   n64_state *state = machine.driver_data<n64_state>();
238   state->machine_start();
249   machine_start();
239250
240   UINT8 *ipl = machine.root_device().memregion("ddipl")->base();
251   UINT8 *ipl = machine().root_device().memregion("ddipl")->base();
241252
242253   for (int i = 0; i < 0x400000; i += 4)
243254   {
r18016r18017
252263   }
253264}
254265
255static INTERRUPT_GEN( n64_reset_poll )
266INTERRUPT_GEN_MEMBER(n64_mess_state::n64_reset_poll)
256267{
257   n64_periphs *periphs = device->machine().device<n64_periphs>("rcp");
258   periphs->poll_reset_button((device->machine().root_device().ioport("RESET")->read() & 1) ? true : false);
268   n64_periphs *periphs = machine().device<n64_periphs>("rcp");
269   periphs->poll_reset_button((machine().root_device().ioport("RESET")->read() & 1) ? true : false);
259270}
260271
261static MACHINE_CONFIG_START( n64, n64_state )
272static MACHINE_CONFIG_START( n64, n64_mess_state )
262273
263274   /* basic machine hardware */
264275   MCFG_CPU_ADD("maincpu", VR4300BE, 93750000)
265276   MCFG_CPU_CONFIG(config)
266277   MCFG_CPU_PROGRAM_MAP(n64_map)
267   MCFG_CPU_VBLANK_INT("screen", n64_reset_poll)
278   MCFG_CPU_VBLANK_INT_DRIVER("screen", n64_mess_state, n64_reset_poll)
268279
269280   MCFG_CPU_ADD("rsp", RSP, 62500000)
270281   MCFG_CPU_CONFIG(n64_rsp_config)
r18016r18017
308319   MCFG_CPU_MODIFY("maincpu")
309320   MCFG_CPU_PROGRAM_MAP(n64dd_map)
310321
311   MCFG_MACHINE_START( n64dd )
322   MCFG_MACHINE_START_OVERRIDE(n64_mess_state, n64dd)
312323
313324   MCFG_CARTSLOT_MODIFY("cart")
314325   MCFG_CARTSLOT_NOT_MANDATORY

Previous 199869 Revisions Next


© 1997-2024 The MAME Team