Previous 15994 Revisions Next

r5314 Thursday 30th July, 2009 at 11:37:59 UTC by Jonathan Gevaryahu
[SOCRATES] Implemented rom banking
[src/mess/drivers]socrates.c

src/mess/drivers/socrates.c
r5313r5314
9898
9999/* Devices */
100100
101/* stuff below belongs in machine/socrates.c */
102static struct
103{
104UINT8 data[8];
105UINT8 rom_bank;
106} socrates={ {0}};
101107
108static void socrates_set_rom_bank( running_machine *machine )
109{
110 memory_set_bankptr( machine, 1, memory_region(machine, "maincpu") + ( socrates.rom_bank * 0x4000 ));
111}
112
113MACHINE_RESET( socrates )
114{
115 socrates.rom_bank = 0; // actually set semi-randomly on real console but we need to initialize it somewhere...
116 socrates_set_rom_bank( machine );
117 // ram bank should also be zeroed here; the actual console sets it semi randomly on power up, and the bios cleans it up.
118}
119
120READ8_HANDLER( socrates_rom_bank_r )
121{
122 UINT8 data = 0xFF;
123 data = socrates.rom_bank;
124 return data;
125}
126
127WRITE8_HANDLER( socrates_rom_bank_w )
128{
129 socrates.rom_bank = data;
130 socrates_set_rom_bank( space->machine );
131}
132
102133/******************************************************************************
103134 Address Maps
104135******************************************************************************/
r5313r5314
106137static ADDRESS_MAP_START(z80_mem, ADDRESS_SPACE_PROGRAM, 8)
107138    ADDRESS_MAP_UNMAP_HIGH
108139    AM_RANGE(0x0000, 0x3fff) AM_ROM /* system rom, bank 0 (fixed) */
109    AM_RANGE(0x4000, 0x7fff) AM_NOP /* banked rom space; system rom is banks 0 thru F, cartridge rom is banks 10 onward, usually banks 10 thru 17. area past the end of the cartridge, and the whole 10-ff area when no cartridge is inserted, reads as 0xF3 */
140    AM_RANGE(0x4000, 0x7fff) AM_ROMBANK(1) /* banked rom space; system rom is banks 0 thru F, cartridge rom is banks 10 onward, usually banks 10 thru 17. area past the end of the cartridge, and the whole 10-ff area when no cartridge is inserted, reads as 0xF3 */
110141    AM_RANGE(0x8000, 0xbfff) AM_RAM /* banked ram 'window' 0 */
111142    AM_RANGE(0xc000, 0xffff) AM_RAM /* banked ram 'window' 1 */
112143ADDRESS_MAP_END
113144
114145static ADDRESS_MAP_START(z80_io, ADDRESS_SPACE_IO, 8)
115146   ADDRESS_MAP_GLOBAL_MASK(0xff)
116   AM_RANGE(0x00, 0x00) AM_RAM AM_MIRROR(0x7) /* rom bank select - RW - 8 bits */
147   AM_RANGE(0x00, 0x00) AM_READWRITE(socrates_rom_bank_r, socrates_rom_bank_w) AM_MIRROR(0x7) /* rom bank select - RW - 8 bits */
117148   AM_RANGE(0x08, 0x08) AM_RAM AM_MIRROR(0x7) /* ram banks select - RW - 4 low bits; Format: 0b****HHLL where LL controls whether window 0 points at ram area: 0b00: 0x0000-0x3fff; 0b01: 0x4000-0x7fff; 0b10: 0x8000-0xbfff; 0b11: 0xc000-0xffff. HH controls the same thing for window 1 */
118149   AM_RANGE(0x10, 0x17) AM_NOP AM_MIRROR (0x8) /* sound section:
119150        0x10 - W - frequency control for channel 1 (louder channel) - 01=high pitch, ff=low, write 0 to silence
r5313r5314
151182    MDRV_CPU_PROGRAM_MAP(z80_mem)
152183    MDRV_CPU_IO_MAP(z80_io)
153184    MDRV_QUANTUM_TIME(HZ(60))
185    MDRV_MACHINE_RESET(socrates)
154186
155187    /* video hardware */
156188   MDRV_DEFAULT_LAYOUT(layout_socrates)
157189
158190    /* sound hardware */
159191   //MDRV_SPEAKER_STANDARD_MONO("mono")
160   //MDRV_SOUND_ADD("soc_snd", SOCRATES, XTAL_21_47727MHz/12) /* divider guessed */
192   //MDRV_SOUND_ADD("soc_snd", SOCRATES, XTAL_21_47727MHz/(1024+512)) /* this is correct, as strange as it sounds. */
161193   //MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
162194
163195
r5313r5314
172204ROM_START(socrates)
173205    ROM_REGION(0x80000, "maincpu", 0)
174206    /* Socrates US NTSC */
175    ROM_LOAD("27-00817-000-000.u1", 0x00000, 0x40000, CRC(80f5aa20) SHA1(4fd1ff7f78b5dd2582d5de6f30633e4e4f34ca8f))
207    ROM_LOAD("27-00817-000-000.u1", 0x00000, 0x40000, CRC(80f5aa20) SHA1(4fd1ff7f78b5dd2582d5de6f30633e4e4f34ca8f))
208   ROM_FILL(0x40000, 0x40000, 0xf3) /* fill empty space with 0xf3 */
176209ROM_END
177210   
178211ROM_START(socratfc)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team