~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/mame/drivers/psikyo4.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
182
182
{
183
183
        if (ACCESSING_BITS_16_31)
184
184
        {
185
 
                return input_port_read(device->machine(), "JP4");
 
185
                return device->machine().root_device().ioport("JP4")->read();
186
186
        }
187
187
 
188
188
//  logerror("Unk EEPROM read mask %x\n", mem_mask);
195
195
        device_set_input_line(device, 4, HOLD_LINE);
196
196
}
197
197
 
198
 
static CUSTOM_INPUT( system_port_r )
 
198
CUSTOM_INPUT_MEMBER(psikyo4_state::system_port_r)
199
199
{
200
 
        return input_port_read(field.machine(), "SYSTEM");
 
200
        return ioport("SYSTEM")->read();
201
201
}
202
202
 
203
 
static CUSTOM_INPUT( mahjong_ctrl_r ) /* used by hotgmck/hgkairak */
 
203
CUSTOM_INPUT_MEMBER(psikyo4_state::mahjong_ctrl_r)/* used by hotgmck/hgkairak */
204
204
{
205
 
        psikyo4_state *state = field.machine().driver_data<psikyo4_state>();
206
205
        int player = (FPTR)param;
207
 
        int sel = (state->m_io_select[0] & 0x0000ff00) >> 8;
 
206
        int sel = (m_io_select[0] & 0x0000ff00) >> 8;
208
207
        int ret = 0xff;
209
208
 
210
 
        if (sel & 1) ret &= input_port_read(field.machine(), player ? "KEY4" : "KEY0" );
211
 
        if (sel & 2) ret &= input_port_read(field.machine(), player ? "KEY5" : "KEY1" );
212
 
        if (sel & 4) ret &= input_port_read(field.machine(), player ? "KEY6" : "KEY2" );
213
 
        if (sel & 8) ret &= input_port_read(field.machine(), player ? "KEY7" : "KEY3" );
 
209
        if (sel & 1) ret &= ioport(player ? "KEY4" : "KEY0" )->read();
 
210
        if (sel & 2) ret &= ioport(player ? "KEY5" : "KEY1" )->read();
 
211
        if (sel & 4) ret &= ioport(player ? "KEY6" : "KEY2" )->read();
 
212
        if (sel & 8) ret &= ioport(player ? "KEY7" : "KEY3" )->read();
214
213
 
215
214
        return ret;
216
215
}
217
216
 
218
 
static WRITE32_HANDLER( ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w )
219
 
{
220
 
        psikyo4_state *state = space->machine().driver_data<psikyo4_state>();
221
 
        int r, g, b;
222
 
        COMBINE_DATA(&state->m_paletteram[offset]);
223
 
 
224
 
        b = ((state->m_paletteram[offset] & 0x0000ff00) >> 8);
225
 
        g = ((state->m_paletteram[offset] & 0x00ff0000) >> 16);
226
 
        r = ((state->m_paletteram[offset] & 0xff000000) >> 24);
227
 
 
228
 
        palette_set_color(space->machine(), offset, MAKE_RGB(r, g, b));
229
 
        palette_set_color(space->machine(), offset + 0x800, MAKE_RGB(r, g, b)); // For screen 2
230
 
}
231
 
 
232
 
static WRITE32_HANDLER( ps4_bgpen_1_dword_w )
233
 
{
234
 
        psikyo4_state *state = space->machine().driver_data<psikyo4_state>();
235
 
        int r, g, b;
236
 
        COMBINE_DATA(&state->m_bgpen_1[0]);
237
 
 
238
 
        b = ((state->m_bgpen_1[0] & 0x0000ff00) >>8);
239
 
        g = ((state->m_bgpen_1[0] & 0x00ff0000) >>16);
240
 
        r = ((state->m_bgpen_1[0] & 0xff000000) >>24);
241
 
 
242
 
        palette_set_color(space->machine(), 0x1000, MAKE_RGB(r, g, b)); // Clear colour for screen 1
243
 
}
244
 
 
245
 
static WRITE32_HANDLER( ps4_bgpen_2_dword_w )
246
 
{
247
 
        psikyo4_state *state = space->machine().driver_data<psikyo4_state>();
248
 
        int r, g, b;
249
 
        COMBINE_DATA(&state->m_bgpen_2[0]);
250
 
 
251
 
        b = ((state->m_bgpen_2[0] & 0x0000ff00) >>8);
252
 
        g = ((state->m_bgpen_2[0] & 0x00ff0000) >>16);
253
 
        r = ((state->m_bgpen_2[0] & 0xff000000) >>24);
254
 
 
255
 
        palette_set_color(space->machine(), 0x1001, MAKE_RGB(r, g, b)); // Clear colour for screen 2
256
 
}
257
 
 
258
 
static WRITE32_HANDLER( ps4_screen1_brt_w )
259
 
{
260
 
        psikyo4_state *state = space->machine().driver_data<psikyo4_state>();
 
217
WRITE32_MEMBER(psikyo4_state::ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w)
 
218
{
 
219
        int r, g, b;
 
220
        COMBINE_DATA(&m_paletteram[offset]);
 
221
 
 
222
        b = ((m_paletteram[offset] & 0x0000ff00) >> 8);
 
223
        g = ((m_paletteram[offset] & 0x00ff0000) >> 16);
 
224
        r = ((m_paletteram[offset] & 0xff000000) >> 24);
 
225
 
 
226
        palette_set_color(machine(), offset, MAKE_RGB(r, g, b));
 
227
        palette_set_color(machine(), offset + 0x800, MAKE_RGB(r, g, b)); // For screen 2
 
228
}
 
229
 
 
230
WRITE32_MEMBER(psikyo4_state::ps4_bgpen_1_dword_w)
 
231
{
 
232
        int r, g, b;
 
233
        COMBINE_DATA(&m_bgpen_1[0]);
 
234
 
 
235
        b = ((m_bgpen_1[0] & 0x0000ff00) >>8);
 
236
        g = ((m_bgpen_1[0] & 0x00ff0000) >>16);
 
237
        r = ((m_bgpen_1[0] & 0xff000000) >>24);
 
238
 
 
239
        palette_set_color(machine(), 0x1000, MAKE_RGB(r, g, b)); // Clear colour for screen 1
 
240
}
 
241
 
 
242
WRITE32_MEMBER(psikyo4_state::ps4_bgpen_2_dword_w)
 
243
{
 
244
        int r, g, b;
 
245
        COMBINE_DATA(&m_bgpen_2[0]);
 
246
 
 
247
        b = ((m_bgpen_2[0] & 0x0000ff00) >>8);
 
248
        g = ((m_bgpen_2[0] & 0x00ff0000) >>16);
 
249
        r = ((m_bgpen_2[0] & 0xff000000) >>24);
 
250
 
 
251
        palette_set_color(machine(), 0x1001, MAKE_RGB(r, g, b)); // Clear colour for screen 2
 
252
}
 
253
 
 
254
WRITE32_MEMBER(psikyo4_state::ps4_screen1_brt_w)
 
255
{
261
256
 
262
257
        if (ACCESSING_BITS_0_7)
263
258
        {
268
263
                        brt1 = 0x7f; /* I reckon values must be clamped to 0x7f */
269
264
 
270
265
                brt1 = (0x7f - brt1) / 127.0;
271
 
                if (state->m_oldbrt1 != brt1)
 
266
                if (m_oldbrt1 != brt1)
272
267
                {
273
268
                        int i;
274
269
 
275
270
                        for (i = 0; i < 0x800; i++)
276
 
                                palette_set_pen_contrast(space->machine(), i, brt1);
 
271
                                palette_set_pen_contrast(machine(), i, brt1);
277
272
 
278
 
                        state->m_oldbrt1 = brt1;
 
273
                        m_oldbrt1 = brt1;
279
274
                }
280
275
        }
281
276
        else
286
281
        }
287
282
}
288
283
 
289
 
static WRITE32_HANDLER( ps4_screen2_brt_w )
 
284
WRITE32_MEMBER(psikyo4_state::ps4_screen2_brt_w)
290
285
{
291
 
        psikyo4_state *state = space->machine().driver_data<psikyo4_state>();
292
286
 
293
287
        if (ACCESSING_BITS_0_7)
294
288
        {
300
294
 
301
295
                brt2 = (0x7f - brt2) / 127.0;
302
296
 
303
 
                if (state->m_oldbrt2 != brt2)
 
297
                if (m_oldbrt2 != brt2)
304
298
                {
305
299
                        int i;
306
300
 
307
301
                        for (i = 0x800; i < 0x1000; i++)
308
 
                                palette_set_pen_contrast(space->machine(), i, brt2);
 
302
                                palette_set_pen_contrast(machine(), i, brt2);
309
303
 
310
 
                        state->m_oldbrt2 = brt2;
 
304
                        m_oldbrt2 = brt2;
311
305
                }
312
306
        }
313
307
        else
318
312
        }
319
313
}
320
314
 
321
 
static WRITE32_HANDLER( ps4_vidregs_w )
 
315
WRITE32_MEMBER(psikyo4_state::ps4_vidregs_w)
322
316
{
323
 
        psikyo4_state *state = space->machine().driver_data<psikyo4_state>();
324
 
        COMBINE_DATA(&state->m_vidregs[offset]);
 
317
        COMBINE_DATA(&m_vidregs[offset]);
325
318
 
326
319
        if (offset == 2) /* Configure bank for gfx test */
327
320
        {
328
321
                if (ACCESSING_BITS_0_15)        // Bank
329
 
                        memory_set_bankptr(space->machine(), "bank2", space->machine().region("gfx1")->base() + 0x2000 * (state->m_vidregs[offset] & 0x1fff)); /* Bank comes from vidregs */
 
322
                        membank("bank2")->set_base(machine().root_device().memregion("gfx1")->base() + 0x2000 * (m_vidregs[offset] & 0x1fff)); /* Bank comes from vidregs */
330
323
        }
331
324
}
332
325
 
333
 
#define PCM_BANK_NO(n)  ((state->m_io_select[0] >> (n * 4 + 24)) & 0x07)
 
326
#define PCM_BANK_NO_LEGACY(n)   ((state->m_io_select[0] >> (n * 4 + 24)) & 0x07)
334
327
 
335
328
static void set_hotgmck_pcm_bank( running_machine &machine, int n )
336
329
{
337
330
        psikyo4_state *state = machine.driver_data<psikyo4_state>();
338
 
        UINT8 *ymf_pcmbank = machine.region("ymf")->base() + 0x200000;
339
 
        UINT8 *pcm_rom = machine.region("ymfsource")->base();
 
331
        UINT8 *ymf_pcmbank = state->memregion("ymf")->base() + 0x200000;
 
332
        UINT8 *pcm_rom = state->memregion("ymfsource")->base();
340
333
 
341
 
        memcpy(ymf_pcmbank + n * 0x100000, pcm_rom + PCM_BANK_NO(n) * 0x100000, 0x100000);
 
334
        memcpy(ymf_pcmbank + n * 0x100000, pcm_rom + PCM_BANK_NO_LEGACY(n) * 0x100000, 0x100000);
342
335
}
343
 
 
344
 
static WRITE32_HANDLER( hotgmck_pcm_bank_w )
 
336
#define PCM_BANK_NO(n)  ((m_io_select[0] >> (n * 4 + 24)) & 0x07)
 
337
WRITE32_MEMBER(psikyo4_state::hotgmck_pcm_bank_w)
345
338
{
346
 
        psikyo4_state *state = space->machine().driver_data<psikyo4_state>();
347
339
        int old_bank0 = PCM_BANK_NO(0);
348
340
        int old_bank1 = PCM_BANK_NO(1);
349
341
        int new_bank0, new_bank1;
350
342
 
351
 
        COMBINE_DATA(&state->m_io_select[0]);
 
343
        COMBINE_DATA(&m_io_select[0]);
352
344
 
353
345
        new_bank0 = PCM_BANK_NO(0);
354
346
        new_bank1 = PCM_BANK_NO(1);
355
347
 
356
348
        if (old_bank0 != new_bank0)
357
 
                set_hotgmck_pcm_bank(space->machine(), 0);
 
349
                set_hotgmck_pcm_bank(machine(), 0);
358
350
 
359
351
        if (old_bank1 != new_bank1)
360
 
                set_hotgmck_pcm_bank(space->machine(), 1);
 
352
                set_hotgmck_pcm_bank(machine(), 1);
361
353
}
362
354
 
363
 
static ADDRESS_MAP_START( ps4_map, AS_PROGRAM, 32 )
 
355
static ADDRESS_MAP_START( ps4_map, AS_PROGRAM, 32, psikyo4_state )
364
356
        AM_RANGE(0x00000000, 0x000fffff) AM_ROM         // program ROM (1 meg)
365
357
        AM_RANGE(0x02000000, 0x021fffff) AM_ROMBANK("bank1") // data ROM
366
 
        AM_RANGE(0x03000000, 0x030037ff) AM_RAM AM_BASE_SIZE_MEMBER(psikyo4_state, m_spriteram, m_spriteram_size)
367
 
        AM_RANGE(0x03003fe0, 0x03003fe3) AM_DEVREADWRITE("eeprom", ps4_eeprom_r,ps4_eeprom_w)
 
358
        AM_RANGE(0x03000000, 0x030037ff) AM_RAM AM_SHARE("spriteram")
 
359
        AM_RANGE(0x03003fe0, 0x03003fe3) AM_DEVREADWRITE_LEGACY("eeprom", ps4_eeprom_r,ps4_eeprom_w)
368
360
        AM_RANGE(0x03003fe4, 0x03003fe7) AM_READNOP // also writes to this address - might be vblank?
369
361
//  AM_RANGE(0x03003fe4, 0x03003fe7) AM_WRITENOP // might be vblank?
370
 
        AM_RANGE(0x03003fe4, 0x03003fef) AM_RAM_WRITE(ps4_vidregs_w) AM_BASE_MEMBER(psikyo4_state, m_vidregs) // vid regs?
 
362
        AM_RANGE(0x03003fe4, 0x03003fef) AM_RAM_WRITE(ps4_vidregs_w) AM_SHARE("vidregs") // vid regs?
371
363
        AM_RANGE(0x03003ff0, 0x03003ff3) AM_WRITE(ps4_screen1_brt_w) // screen 1 brightness
372
 
        AM_RANGE(0x03003ff4, 0x03003ff7) AM_WRITE(ps4_bgpen_1_dword_w) AM_BASE_MEMBER(psikyo4_state, m_bgpen_1) // screen 1 clear colour
 
364
        AM_RANGE(0x03003ff4, 0x03003ff7) AM_WRITE(ps4_bgpen_1_dword_w) AM_SHARE("bgpen_1") // screen 1 clear colour
373
365
        AM_RANGE(0x03003ff8, 0x03003ffb) AM_WRITE(ps4_screen2_brt_w) // screen 2 brightness
374
 
        AM_RANGE(0x03003ffc, 0x03003fff) AM_WRITE(ps4_bgpen_2_dword_w) AM_BASE_MEMBER(psikyo4_state, m_bgpen_2) // screen 2 clear colour
375
 
        AM_RANGE(0x03004000, 0x03005fff) AM_RAM_WRITE(ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_MEMBER(psikyo4_state, m_paletteram) // palette
 
366
        AM_RANGE(0x03003ffc, 0x03003fff) AM_WRITE(ps4_bgpen_2_dword_w) AM_SHARE("bgpen_2") // screen 2 clear colour
 
367
        AM_RANGE(0x03004000, 0x03005fff) AM_RAM_WRITE(ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_SHARE("paletteram") // palette
376
368
        AM_RANGE(0x03006000, 0x03007fff) AM_ROMBANK("bank2") // data for rom tests (gfx), data is controlled by vidreg
377
 
        AM_RANGE(0x05000000, 0x05000007) AM_DEVREADWRITE8("ymf", ymf278b_r, ymf278b_w, 0xffffffff)
 
369
        AM_RANGE(0x05000000, 0x05000007) AM_DEVREADWRITE8_LEGACY("ymf", ymf278b_r, ymf278b_w, 0xffffffff)
378
370
        AM_RANGE(0x05800000, 0x05800003) AM_READ_PORT("P1_P2")
379
371
        AM_RANGE(0x05800004, 0x05800007) AM_READ_PORT("P3_P4")
380
 
        AM_RANGE(0x05800008, 0x0580000b) AM_WRITEONLY AM_BASE_MEMBER(psikyo4_state, m_io_select) // Used by Mahjong games to choose input (also maps normal loderndf inputs to offsets)
 
372
        AM_RANGE(0x05800008, 0x0580000b) AM_WRITEONLY AM_SHARE("io_select") // Used by Mahjong games to choose input (also maps normal loderndf inputs to offsets)
381
373
 
382
 
        AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE_MEMBER(psikyo4_state, m_ram) // main RAM (1 meg)
 
374
        AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_SHARE("ram") // main RAM (1 meg)
383
375
 
384
376
ADDRESS_MAP_END
385
377
 
386
378
 
387
379
static INPUT_PORTS_START( hotgmck )
388
380
        PORT_START("P1_P2")
389
 
        PORT_BIT( 0x000000ff, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM(system_port_r, NULL)
 
381
        PORT_BIT( 0x000000ff, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM_MEMBER(DEVICE_SELF, psikyo4_state,system_port_r, NULL)
390
382
        PORT_BIT( 0x00ffff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
391
 
        PORT_BIT( 0xff000000, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM(mahjong_ctrl_r, (void *)0)
 
383
        PORT_BIT( 0xff000000, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM_MEMBER(DEVICE_SELF, psikyo4_state,mahjong_ctrl_r, (void *)0)
392
384
 
393
385
        PORT_START("P3_P4")
394
 
        PORT_BIT( 0x000000ff, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM(system_port_r, NULL)
 
386
        PORT_BIT( 0x000000ff, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM_MEMBER(DEVICE_SELF, psikyo4_state,system_port_r, NULL)
395
387
        PORT_BIT( 0x00ffff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
396
 
        PORT_BIT( 0xff000000, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM(mahjong_ctrl_r, (void *)1)
 
388
        PORT_BIT( 0xff000000, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM_MEMBER(DEVICE_SELF, psikyo4_state,mahjong_ctrl_r, (void *)1)
397
389
 
398
390
        PORT_START("JP4")/* jumper pads 'JP4' on the PCB */
399
391
        /* EEPROM is read here */
963
955
static void install_hotgmck_pcm_bank(running_machine &machine)
964
956
{
965
957
        psikyo4_state *state = machine.driver_data<psikyo4_state>();
966
 
        UINT8 *ymf_pcm = machine.region("ymf")->base();
967
 
        UINT8 *pcm_rom = machine.region("ymfsource")->base();
 
958
        UINT8 *ymf_pcm = state->memregion("ymf")->base();
 
959
        UINT8 *pcm_rom = state->memregion("ymfsource")->base();
968
960
 
969
961
        memcpy(ymf_pcm, pcm_rom, 0x200000);
970
962
 
972
964
        set_hotgmck_pcm_bank(machine, 0);
973
965
        set_hotgmck_pcm_bank(machine, 1);
974
966
 
975
 
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x5800008, 0x580000b, FUNC(hotgmck_pcm_bank_w) );
 
967
        machine.device("maincpu")->memory().space(AS_PROGRAM)->install_write_handler(0x5800008, 0x580000b, write32_delegate(FUNC(psikyo4_state::hotgmck_pcm_bank_w),state));
976
968
        machine.save().register_postload(save_prepost_delegate(FUNC(hotgmck_pcm_bank_postload), &machine));
977
969
}
978
970
 
979
971
static DRIVER_INIT( hotgmck )
980
972
{
981
 
        UINT8 *RAM = machine.region("maincpu")->base();
982
 
        memory_set_bankptr(machine, "bank1", &RAM[0x100000]);
 
973
        UINT8 *RAM = machine.root_device().memregion("maincpu")->base();
 
974
        machine.root_device().membank("bank1")->set_base(&RAM[0x100000]);
983
975
        install_hotgmck_pcm_bank(machine);      // Banked PCM ROM
984
976
}
985
977