Added driver_data class and save states to the following drivers: ohmygod.c, ojankohs.c and olibochu.c

This commit is contained in:
Fabio Priuli 2010-02-28 22:00:37 +00:00
parent 22c85b302d
commit c9425a3c26
5 changed files with 458 additions and 315 deletions

View File

@ -14,58 +14,40 @@ Notes:
#include "emu.h"
#include "cpu/m68000/m68000.h"
#include "sound/okim6295.h"
#include "includes/ohmygod.h"
extern UINT16 *ohmygod_videoram;
WRITE16_HANDLER( ohmygod_videoram_w );
WRITE16_HANDLER( ohmygod_spritebank_w );
WRITE16_HANDLER( ohmygod_scrollx_w );
WRITE16_HANDLER( ohmygod_scrolly_w );
VIDEO_START( ohmygod );
VIDEO_UPDATE( ohmygod );
static int adpcm_bank_shift;
static int sndbank;
static MACHINE_RESET( ohmygod )
{
UINT8 *rom = memory_region(machine, "oki");
sndbank = 0;
memcpy(rom + 0x20000,rom + 0x40000 + 0x20000 * sndbank,0x20000);
}
static WRITE16_HANDLER( ohmygod_ctrl_w )
{
ohmygod_state *state = (ohmygod_state *)space->machine->driver_data;
if (ACCESSING_BITS_0_7)
{
UINT8 *rom = memory_region(space->machine, "oki");
/* ADPCM bank switch */
if (sndbank != ((data >> adpcm_bank_shift) & 0x0f))
if (state->sndbank != ((data >> state->adpcm_bank_shift) & 0x0f))
{
sndbank = (data >> adpcm_bank_shift) & 0x0f;
memcpy(rom + 0x20000,rom + 0x40000 + 0x20000 * sndbank,0x20000);
state->sndbank = (data >> state->adpcm_bank_shift) & 0x0f;
memcpy(rom + 0x20000, rom + 0x40000 + 0x20000 * state->sndbank, 0x20000);
}
}
if (ACCESSING_BITS_8_15)
{
coin_counter_w(space->machine, 0,data & 0x1000);
coin_counter_w(space->machine, 1,data & 0x2000);
coin_counter_w(space->machine, 0, data & 0x1000);
coin_counter_w(space->machine, 1, data & 0x2000);
}
}
static ADDRESS_MAP_START( ohmygod_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x07ffff) AM_ROM
AM_RANGE(0x300000, 0x303fff) AM_RAM
AM_RANGE(0x304000, 0x307fff) AM_RAM_WRITE(ohmygod_videoram_w) AM_BASE(&ohmygod_videoram)
AM_RANGE(0x304000, 0x307fff) AM_RAM_WRITE(ohmygod_videoram_w) AM_BASE_MEMBER(ohmygod_state, videoram)
AM_RANGE(0x308000, 0x30ffff) AM_RAM
AM_RANGE(0x400000, 0x400001) AM_WRITE(ohmygod_scrollx_w)
AM_RANGE(0x400002, 0x400003) AM_WRITE(ohmygod_scrolly_w)
AM_RANGE(0x600000, 0x6007ff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x700000, 0x703fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0x700000, 0x703fff) AM_RAM AM_BASE_SIZE_MEMBER(ohmygod_state, spriteram, spriteram_size)
AM_RANGE(0x704000, 0x707fff) AM_RAM
AM_RANGE(0x708000, 0x70ffff) AM_RAM /* Work RAM */
AM_RANGE(0x800000, 0x800001) AM_READ_PORT("P1")
@ -312,16 +294,44 @@ GFXDECODE_END
static MACHINE_START( ohmygod )
{
ohmygod_state *state = (ohmygod_state *)machine->driver_data;
state_save_register_global(machine, state->spritebank);
state_save_register_global(machine, state->scrollx);
state_save_register_global(machine, state->scrolly);
state_save_register_global(machine, state->sndbank);
}
static MACHINE_RESET( ohmygod )
{
ohmygod_state *state = (ohmygod_state *)machine->driver_data;
UINT8 *rom = memory_region(machine, "oki");
state->sndbank = 0;
memcpy(rom + 0x20000, rom + 0x40000 + 0x20000 * state->sndbank, 0x20000);
state->spritebank = 0;
state->scrollx = 0;
state->scrolly = 0;
}
static MACHINE_DRIVER_START( ohmygod )
/* driver data */
MDRV_DRIVER_DATA(ohmygod_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, 12000000)
MDRV_CPU_PROGRAM_MAP(ohmygod_map)
MDRV_CPU_VBLANK_INT("screen", irq1_line_hold)
MDRV_MACHINE_RESET(ohmygod)
MDRV_WATCHDOG_TIME_INIT(SEC(3)) /* a guess, and certainly wrong */
MDRV_MACHINE_START(ohmygod)
MDRV_MACHINE_RESET(ohmygod)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@ -387,14 +397,16 @@ ROM_END
static DRIVER_INIT( ohmygod )
{
adpcm_bank_shift = 4;
ohmygod_state *state = (ohmygod_state *)machine->driver_data;
state->adpcm_bank_shift = 4;
}
static DRIVER_INIT( naname )
{
adpcm_bank_shift = 0;
ohmygod_state *state = (ohmygod_state *)machine->driver_data;
state->adpcm_bank_shift = 0;
}
GAME( 1993, ohmygod, 0, ohmygod, ohmygod, ohmygod, ROT0, "Atlus", "Oh My God! (Japan)", GAME_NO_COCKTAIL )
GAME( 1994, naname, 0, ohmygod, naname, naname, ROT0, "Atlus", "Naname de Magic! (Japan)", GAME_NO_COCKTAIL )
GAME( 1993, ohmygod, 0, ohmygod, ohmygod, ohmygod, ROT0, "Atlus", "Oh My God! (Japan)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1994, naname, 0, ohmygod, naname, naname, ROT0, "Atlus", "Naname de Magic! (Japan)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )

View File

@ -20,8 +20,8 @@
Driver by Takahiro Nogi <nogi@kt.rim.or.jp> 2000/06/10 -
Driver by Uki 2001/12/10 -
******************************************************************************/
/******************************************************************************
******************************************************************************
Memo:
- Sometimes RAM check in testmode fails (reason unknown).
@ -33,115 +33,90 @@ Memo:
#include "emu.h"
#include "cpu/z80/z80.h"
#include "includes/ojankohs.h"
#include "sound/ay8910.h"
#include "sound/msm5205.h"
VIDEO_UPDATE( ojankohs );
PALETTE_INIT( ojankoy );
VIDEO_START( ojankohs );
VIDEO_START( ojankoy );
WRITE8_HANDLER( ojankohs_palette_w );
WRITE8_HANDLER( ccasino_palette_w );
WRITE8_HANDLER( ojankohs_videoram_w );
WRITE8_HANDLER( ojankohs_colorram_w );
WRITE8_HANDLER( ojankohs_gfxreg_w );
WRITE8_HANDLER( ojankohs_flipscreen_w );
VIDEO_UPDATE( ojankoc );
VIDEO_START( ojankoc );
WRITE8_HANDLER( ojankoc_palette_w );
WRITE8_HANDLER( ojankoc_videoram_w );
void ojankoc_flipscreen(const address_space *space, int data);
static int ojankohs_portselect;
static int ojankohs_adpcm_reset;
static int ojankohs_adpcm_data;
static int ojankohs_vclk_left;
static MACHINE_RESET( ojankohs )
{
ojankohs_portselect = 0;
ojankohs_adpcm_reset = 0;
ojankohs_adpcm_data = 0;
ojankohs_vclk_left = 0;
}
static WRITE8_HANDLER( ojankohs_rombank_w )
{
UINT8 *ROM = memory_region(space->machine, "maincpu");
memory_set_bankptr(space->machine, "bank1", &ROM[0x10000 + (0x4000 * (data & 0x3f))]);
memory_set_bank(space->machine, "bank1", data & 0x3f);
}
static WRITE8_HANDLER( ojankoy_rombank_w )
{
UINT8 *ROM = memory_region(space->machine, "maincpu");
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
memory_set_bankptr(space->machine, "bank1", &ROM[0x10000 + (0x4000 * (data & 0x1f))]);
memory_set_bank(space->machine, "bank1", data & 0x1f);
ojankohs_adpcm_reset = ((data & 0x20) >> 5);
if (!ojankohs_adpcm_reset) ojankohs_vclk_left = 0;
state->adpcm_reset = BIT(data, 5);
if (!state->adpcm_reset)
state->vclk_left = 0;
msm5205_reset_w(devtag_get_device(space->machine, "msm"), !ojankohs_adpcm_reset);
msm5205_reset_w(state->msm, !state->adpcm_reset);
}
static WRITE8_DEVICE_HANDLER( ojankohs_adpcm_reset_w )
{
ojankohs_adpcm_reset = (data & 0x01);
ojankohs_vclk_left = 0;
ojankohs_state *state = (ojankohs_state *)device->machine->driver_data;
state->adpcm_reset = BIT(data, 0);
state->vclk_left = 0;
msm5205_reset_w(device, !ojankohs_adpcm_reset);
msm5205_reset_w(device, !state->adpcm_reset);
}
static WRITE8_HANDLER( ojankohs_msm5205_w )
{
ojankohs_adpcm_data = data;
ojankohs_vclk_left = 2;
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
state->adpcm_data = data;
state->vclk_left = 2;
}
static void ojankohs_adpcm_int(running_device *device)
static void ojankohs_adpcm_int( running_device *device )
{
ojankohs_state *state = (ojankohs_state *)device->machine->driver_data;
/* skip if we're reset */
if (!ojankohs_adpcm_reset)
if (!state->adpcm_reset)
return;
/* clock the data through */
if (ojankohs_vclk_left) {
msm5205_data_w(device, (ojankohs_adpcm_data >> 4));
ojankohs_adpcm_data <<= 4;
ojankohs_vclk_left--;
if (state->vclk_left)
{
msm5205_data_w(device, (state->adpcm_data >> 4));
state->adpcm_data <<= 4;
state->vclk_left--;
}
/* generate an NMI if we're out of data */
if (!ojankohs_vclk_left)
cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
if (!state->vclk_left)
cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, PULSE_LINE);
}
static WRITE8_HANDLER( ojankoc_ctrl_w )
{
UINT8 *BANKROM = memory_region(space->machine, "user1");
UINT32 bank_address = (data & 0x0f) * 0x8000;
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
memory_set_bankptr(space->machine, "bank1", &BANKROM[bank_address]);
memory_set_bank(space->machine, "bank1", data & 0x0f);
ojankohs_adpcm_reset = ((data & 0x10) >> 4);
msm5205_reset_w(devtag_get_device(space->machine, "msm"), (!(data & 0x10) >> 4));
state->adpcm_reset = BIT(data, 4);
msm5205_reset_w(state->msm, !BIT(data, 4));
ojankoc_flipscreen(space, data);
}
static WRITE8_HANDLER( ojankohs_portselect_w )
{
ojankohs_portselect = data;
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
state->portselect = data;
}
static READ8_HANDLER( ojankohs_keymatrix_r )
{
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
int ret;
switch (ojankohs_portselect) {
switch (state->portselect)
{
case 0x01: ret = input_port_read(space->machine, "KEY0"); break;
case 0x02: ret = input_port_read(space->machine, "KEY1"); break;
case 0x04: ret = input_port_read(space->machine, "KEY2"); break;
@ -156,7 +131,7 @@ static READ8_HANDLER( ojankohs_keymatrix_r )
ret &= input_port_read(space->machine, "KEY4");
break;
default: ret = 0xff;
logerror("PC:%04X unknown %02X\n", cpu_get_pc(space->cpu), ojankohs_portselect);
logerror("PC:%04X unknown %02X\n", cpu_get_pc(space->cpu), state->portselect);
break;
}
@ -165,6 +140,7 @@ static READ8_HANDLER( ojankohs_keymatrix_r )
static READ8_HANDLER( ojankoc_keymatrix_r )
{
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
int i;
int ret = 0;
static const char *const keynames[2][5] =
@ -173,8 +149,9 @@ static READ8_HANDLER( ojankoc_keymatrix_r )
{ "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" }
};
for (i = 0; i < 5; i++) {
if (~ojankohs_portselect & (1 << i))
for (i = 0; i < 5; i++)
{
if (!BIT(state->portselect, i))
ret |= input_port_read(space->machine, keynames[offset][i]);
}
@ -211,12 +188,12 @@ static READ8_HANDLER( ccasino_dipsw4_r )
static WRITE8_HANDLER( ojankoy_coinctr_w )
{
coin_counter_w( space->machine, 0, (data & 0x01));
coin_counter_w(space->machine, 0, BIT(data, 0));
}
static WRITE8_HANDLER( ccasino_coinctr_w )
{
coin_counter_w(space->machine, 0, (data & 0x02));
coin_counter_w(space->machine, 0, BIT(data, 1));
}
@ -299,7 +276,7 @@ ADDRESS_MAP_END
static INPUT_PORTS_START( mahjong_p1 )
PORT_START("KEY0") /* PORT 1-0 */
PORT_START("KEY0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_I )
@ -309,7 +286,7 @@ static INPUT_PORTS_START( mahjong_p1 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("KEY1") /* PORT 1-1 */
PORT_START("KEY1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_J )
@ -319,7 +296,7 @@ static INPUT_PORTS_START( mahjong_p1 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("KEY2") /* PORT 1-2 */
PORT_START("KEY2")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K )
@ -329,7 +306,7 @@ static INPUT_PORTS_START( mahjong_p1 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("KEY3") /* PORT 1-3 */
PORT_START("KEY3")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L )
@ -339,7 +316,7 @@ static INPUT_PORTS_START( mahjong_p1 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("KEY4") /* PORT 1-4 */
PORT_START("KEY4")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP )
@ -351,7 +328,7 @@ static INPUT_PORTS_START( mahjong_p1 )
INPUT_PORTS_END
static INPUT_PORTS_START( ojankohs )
PORT_START("IN0") /* TEST SW */
PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE3 ) // MEMORY RESET
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE2 ) // ANALYZER
@ -361,7 +338,7 @@ static INPUT_PORTS_START( ojankohs )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_START("IN1") /* COIN SW */
PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
@ -412,7 +389,7 @@ static INPUT_PORTS_START( ojankohs )
INPUT_PORTS_END
static INPUT_PORTS_START( ojankoy )
PORT_START("IN0") /* TEST SW */
PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE3 ) // MEMORY RESET
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE2 ) // ANALYZER
@ -422,7 +399,7 @@ static INPUT_PORTS_START( ojankoy )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_START("IN1") /* COIN SW */
PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
@ -483,7 +460,7 @@ static INPUT_PORTS_START( ojankoy )
INPUT_PORTS_END
static INPUT_PORTS_START( ccasino )
PORT_START("IN0") /* TEST SW */
PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE3 ) // MEMORY RESET
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE2 ) // ANALYZER
@ -493,7 +470,7 @@ static INPUT_PORTS_START( ccasino )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_START("IN1") /* COIN SW */
PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
@ -661,7 +638,7 @@ static INPUT_PORTS_START( ojankoc )
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("KEY0") /* PORT 1-0 */
PORT_START("KEY0")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_A )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_E )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_I )
@ -671,7 +648,7 @@ static INPUT_PORTS_START( ojankoc )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START("KEY1") /* PORT 1-1 */
PORT_START("KEY1")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_B )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_F )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_J )
@ -681,7 +658,7 @@ static INPUT_PORTS_START( ojankoc )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START("KEY2") /* PORT 1-2 */
PORT_START("KEY2")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_C )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_G )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_K )
@ -691,7 +668,7 @@ static INPUT_PORTS_START( ojankoc )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START("KEY3") /* PORT 1-3 */
PORT_START("KEY3")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_D )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_H )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_L )
@ -701,7 +678,7 @@ static INPUT_PORTS_START( ojankoc )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START("KEY4") /* PORT 1-4 */
PORT_START("KEY4")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_LAST_CHANCE )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_SCORE )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_DOUBLE_UP )
@ -711,7 +688,7 @@ static INPUT_PORTS_START( ojankoc )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START("KEY5") /* PORT 2-0 */
PORT_START("KEY5")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_A ) PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_E ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_I ) PORT_PLAYER(2)
@ -720,7 +697,7 @@ static INPUT_PORTS_START( ojankoc )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START2 )
PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("KEY6") /* PORT 2-1 */
PORT_START("KEY6")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_B ) PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_F ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_J ) PORT_PLAYER(2)
@ -729,7 +706,7 @@ static INPUT_PORTS_START( ojankoc )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_BET ) PORT_PLAYER(2)
PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("KEY7") /* PORT 2-2 */
PORT_START("KEY7")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_C ) PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_G ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_K ) PORT_PLAYER(2)
@ -738,7 +715,7 @@ static INPUT_PORTS_START( ojankoc )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("KEY8") /* PORT 2-3 */
PORT_START("KEY8")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_D ) PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_H ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_L ) PORT_PLAYER(2)
@ -747,7 +724,7 @@ static INPUT_PORTS_START( ojankoc )
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("KEY9") /* PORT 2-4 */
PORT_START("KEY9")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_LAST_CHANCE ) PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_SCORE ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_DOUBLE_UP ) PORT_PLAYER(2)
@ -815,14 +792,82 @@ static const msm5205_interface msm5205_config =
};
static MACHINE_START( common )
{
ojankohs_state *state = (ojankohs_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->msm = devtag_get_device(machine, "msm");
state_save_register_global(machine, state->gfxreg);
state_save_register_global(machine, state->flipscreen);
state_save_register_global(machine, state->flipscreen_old);
state_save_register_global(machine, state->scrollx);
state_save_register_global(machine, state->scrolly);
state_save_register_global(machine, state->screen_refresh);
state_save_register_global(machine, state->portselect);
state_save_register_global(machine, state->adpcm_reset);
state_save_register_global(machine, state->adpcm_data);
state_save_register_global(machine, state->vclk_left);
}
static MACHINE_START( ojankohs )
{
UINT8 *ROM = memory_region(machine, "maincpu");
memory_configure_bank(machine, "bank1", 0, 0x40, &ROM[0x10000], 0x4000);
MACHINE_START_CALL(common);
}
static MACHINE_START( ojankoy )
{
UINT8 *ROM = memory_region(machine, "maincpu");
memory_configure_bank(machine, "bank1", 0, 0x20, &ROM[0x10000], 0x4000);
MACHINE_START_CALL(common);
}
static MACHINE_START( ojankoc )
{
UINT8 *ROM = memory_region(machine, "user1");
memory_configure_bank(machine, "bank1", 0, 0x10, &ROM[0x0000], 0x8000);
MACHINE_START_CALL(common);
}
static MACHINE_RESET( ojankohs )
{
ojankohs_state *state = (ojankohs_state *)machine->driver_data;
state->portselect = 0;
state->adpcm_reset = 0;
state->adpcm_data = 0;
state->vclk_left = 0;
state->gfxreg = 0;
state->flipscreen = 0;
state->flipscreen_old = 0;
state->scrollx = 0;
state->scrolly = 0;
state->screen_refresh = 0;
}
static MACHINE_DRIVER_START( ojankohs )
/* driver data */
MDRV_DRIVER_DATA(ojankohs_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,12000000/2) /* 6.00 MHz ? */
MDRV_CPU_PROGRAM_MAP(ojankohs_map)
MDRV_CPU_IO_MAP(ojankohs_io_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(ojankohs)
MDRV_MACHINE_RESET(ojankohs)
MDRV_NVRAM_HANDLER(generic_0fill)
@ -854,12 +899,16 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( ojankoy )
/* driver data */
MDRV_DRIVER_DATA(ojankohs_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,12000000/2) /* 6.00 MHz ? */
MDRV_CPU_PROGRAM_MAP(ojankoy_map)
MDRV_CPU_IO_MAP(ojankoy_io_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(ojankoy)
MDRV_MACHINE_RESET(ojankohs)
MDRV_NVRAM_HANDLER(generic_0fill)
@ -892,12 +941,16 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( ccasino )
/* driver data */
MDRV_DRIVER_DATA(ojankohs_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,12000000/2) /* 6.00 MHz ? */
MDRV_CPU_PROGRAM_MAP(ojankoy_map)
MDRV_CPU_IO_MAP(ccasino_io_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(ojankohs)
MDRV_MACHINE_RESET(ojankohs)
MDRV_NVRAM_HANDLER(generic_0fill)
@ -929,12 +982,16 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( ojankoc )
/* driver data */
MDRV_DRIVER_DATA(ojankohs_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,8000000/2) /* 4.00 MHz */
MDRV_CPU_PROGRAM_MAP(ojankoc_map)
MDRV_CPU_IO_MAP(ojankoc_io_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(ojankoc)
MDRV_MACHINE_RESET(ojankohs)
MDRV_NVRAM_HANDLER(generic_0fill)
@ -1056,8 +1113,8 @@ ROM_START( ojankoc )
ROM_END
GAME( 1986, ojankoc, 0, ojankoc, ojankoc, 0, ROT0, "V-System Co.", "Ojanko Club (Japan)", 0 )
GAME( 1986, ojankoy, 0, ojankoy, ojankoy, 0, ROT0, "V-System Co.", "Ojanko Yakata (Japan)", 0 )
GAME( 1987, ojanko2, 0, ojankoy, ojankoy, 0, ROT0, "V-System Co.", "Ojanko Yakata 2bankan (Japan)", 0 )
GAME( 1987, ccasino, 0, ccasino, ccasino, 0, ROT0, "V-System Co.", "Chinese Casino [BET] (Japan)", 0 )
GAME( 1988, ojankohs, 0, ojankohs, ojankohs, 0, ROT0, "V-System Co.", "Ojanko High School (Japan)", 0 )
GAME( 1986, ojankoc, 0, ojankoc, ojankoc, 0, ROT0, "V-System Co.", "Ojanko Club (Japan)", GAME_SUPPORTS_SAVE )
GAME( 1986, ojankoy, 0, ojankoy, ojankoy, 0, ROT0, "V-System Co.", "Ojanko Yakata (Japan)", GAME_SUPPORTS_SAVE )
GAME( 1987, ojanko2, 0, ojankoy, ojankoy, 0, ROT0, "V-System Co.", "Ojanko Yakata 2bankan (Japan)", GAME_SUPPORTS_SAVE )
GAME( 1987, ccasino, 0, ccasino, ccasino, 0, ROT0, "V-System Co.", "Chinese Casino [BET] (Japan)", GAME_SUPPORTS_SAVE )
GAME( 1988, ojankohs, 0, ojankohs, ojankohs, 0, ROT0, "V-System Co.", "Ojanko High School (Japan)", GAME_SUPPORTS_SAVE )

View File

@ -56,9 +56,30 @@ $7004 writes, related to $7000 reads
#include "deprecat.h"
#include "sound/ay8910.h"
static UINT8 *videoram;
static UINT8 *colorram;
static tilemap_t *bg_tilemap;
class olibochu_state
{
public:
static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, olibochu_state(machine)); }
olibochu_state(running_machine &machine) { }
/* memory pointers */
UINT8 * videoram;
UINT8 * colorram;
UINT8 * spriteram;
UINT8 * spriteram2;
// UINT8 * paletteram; // currently this uses generic palette handling
size_t spriteram_size;
size_t spriteram2_size;
/* video-related */
tilemap_t *bg_tilemap;
/* misc */
int cmd;
};
static PALETTE_INIT( olibochu )
{
@ -77,20 +98,20 @@ static PALETTE_INIT( olibochu )
pen = (color_prom[0x120 + (i - 0x100)] & 0x0f) | 0x00;
/* red component */
bit0 = (color_prom[pen] >> 0) & 0x01;
bit1 = (color_prom[pen] >> 1) & 0x01;
bit2 = (color_prom[pen] >> 2) & 0x01;
bit0 = BIT(color_prom[pen], 0);
bit1 = BIT(color_prom[pen], 1);
bit2 = BIT(color_prom[pen], 2);
r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* green component */
bit0 = (color_prom[pen] >> 3) & 0x01;
bit1 = (color_prom[pen] >> 4) & 0x01;
bit2 = (color_prom[pen] >> 5) & 0x01;
bit0 = BIT(color_prom[pen], 3);
bit1 = BIT(color_prom[pen], 4);
bit2 = BIT(color_prom[pen], 5);
g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
/* blue component */
bit0 = (color_prom[pen] >> 6) & 0x01;
bit1 = (color_prom[pen] >> 7) & 0x01;
bit0 = BIT(color_prom[pen], 6);
bit1 = BIT(color_prom[pen], 7);
b = 0x4f * bit0 + 0xa8 * bit1;
palette_set_color(machine, i, MAKE_RGB(r, g, b));
@ -99,14 +120,16 @@ static PALETTE_INIT( olibochu )
static WRITE8_HANDLER( olibochu_videoram_w )
{
videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
olibochu_state *state = (olibochu_state *)space->machine->driver_data;
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
static WRITE8_HANDLER( olibochu_colorram_w )
{
colorram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
olibochu_state *state = (olibochu_state *)space->machine->driver_data;
state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
static WRITE8_HANDLER( olibochu_flipscreen_w )
@ -122,8 +145,9 @@ static WRITE8_HANDLER( olibochu_flipscreen_w )
static TILE_GET_INFO( get_bg_tile_info )
{
int attr = colorram[tile_index];
int code = videoram[tile_index] + ((attr & 0x20) << 3);
olibochu_state *state = (olibochu_state *)machine->driver_data;
int attr = state->colorram[tile_index];
int code = state->videoram[tile_index] + ((attr & 0x20) << 3);
int color = (attr & 0x1f) + 0x20;
int flags = ((attr & 0x40) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0);
@ -132,27 +156,27 @@ static TILE_GET_INFO( get_bg_tile_info )
static VIDEO_START( olibochu )
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
8, 8, 32, 32);
olibochu_state *state = (olibochu_state *)machine->driver_data;
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
}
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
UINT8 *spriteram = machine->generic.spriteram.u8;
UINT8 *spriteram_2 = machine->generic.spriteram2.u8;
olibochu_state *state = (olibochu_state *)machine->driver_data;
UINT8 *spriteram = state->spriteram;
UINT8 *spriteram_2 = state->spriteram2;
int offs;
/* 16x16 sprites */
for (offs = 0;offs < machine->generic.spriteram_size;offs += 4)
for (offs = 0; offs < state->spriteram_size; offs += 4)
{
int attr = spriteram[offs+1];
int attr = spriteram[offs + 1];
int code = spriteram[offs];
int color = attr & 0x3f;
int flipx = attr & 0x40;
int flipy = attr & 0x80;
int sx = spriteram[offs+3];
int sy = ((spriteram[offs+2] + 8) & 0xff) - 8;
int sx = spriteram[offs + 3];
int sy = ((spriteram[offs + 2] + 8) & 0xff) - 8;
if (flip_screen_get(machine))
{
@ -170,16 +194,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
}
/* 8x8 sprites */
for (offs = 0;offs < machine->generic.spriteram2_size;offs += 4)
for (offs = 0; offs < state->spriteram2_size; offs += 4)
{
int attr = spriteram_2[offs+1];
int attr = spriteram_2[offs + 1];
int code = spriteram_2[offs];
int color = attr & 0x3f;
int flipx = attr & 0x40;
int flipy = attr & 0x80;
int sx = spriteram_2[offs+3];
int sy = spriteram_2[offs+2];
int sx = spriteram_2[offs + 3];
int sy = spriteram_2[offs + 2];
if (flip_screen_get(machine))
{
@ -199,7 +222,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
static VIDEO_UPDATE( olibochu )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
olibochu_state *state = (olibochu_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}
@ -207,23 +231,25 @@ static VIDEO_UPDATE( olibochu )
static WRITE8_HANDLER( sound_command_w )
{
static int cmd;
olibochu_state *state = (olibochu_state *)space->machine->driver_data;
int c;
if (offset == 0) cmd = (cmd & 0x00ff) | (data << 8);
else cmd = (cmd & 0xff00) | data;
if (offset == 0)
state->cmd = (state->cmd & 0x00ff) | (data << 8);
else
state->cmd = (state->cmd & 0xff00) | data;
for (c = 15;c >= 0;c--)
if (cmd & (1 << c)) break;
for (c = 15; c >= 0; c--)
if (state->cmd & (1 << c)) break;
if (c >= 0) soundlatch_w(space,0,15-c);
if (c >= 0) soundlatch_w(space, 0, 15 - c);
}
static ADDRESS_MAP_START( olibochu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(olibochu_videoram_w) AM_BASE(&videoram)
AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(olibochu_colorram_w) AM_BASE(&colorram)
AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(olibochu_videoram_w) AM_BASE_MEMBER(olibochu_state, videoram)
AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(olibochu_colorram_w) AM_BASE_MEMBER(olibochu_state, colorram)
AM_RANGE(0x9000, 0x903f) AM_RAM //???
AM_RANGE(0x9800, 0x983f) AM_RAM //???
AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
@ -234,8 +260,8 @@ static ADDRESS_MAP_START( olibochu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xa005, 0xa005) AM_READ_PORT("DSW2")
AM_RANGE(0xa800, 0xa801) AM_WRITE(sound_command_w)
AM_RANGE(0xa802, 0xa802) AM_WRITE(olibochu_flipscreen_w) /* bit 6 = enable sound? */
AM_RANGE(0xf400, 0xf41f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xf440, 0xf47f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2)
AM_RANGE(0xf400, 0xf41f) AM_RAM AM_BASE_SIZE_MEMBER(olibochu_state, spriteram, spriteram_size)
AM_RANGE(0xf440, 0xf47f) AM_RAM AM_BASE_SIZE_MEMBER(olibochu_state, spriteram2, spriteram2_size)
AM_RANGE(0xf000, 0xffff) AM_RAM
ADDRESS_MAP_END
@ -397,8 +423,25 @@ static INTERRUPT_GEN( olibochu_interrupt )
cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0xd7); /* RST 10h */
}
static MACHINE_START( olibochu )
{
olibochu_state *state = (olibochu_state *)machine->driver_data;
state_save_register_global(machine, state->cmd);
}
static MACHINE_RESET( olibochu )
{
olibochu_state *state = (olibochu_state *)machine->driver_data;
state->cmd = 0;
}
static MACHINE_DRIVER_START( olibochu )
/* driver data */
MDRV_DRIVER_DATA(olibochu_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz ?? */
MDRV_CPU_PROGRAM_MAP(olibochu_map)
@ -410,6 +453,9 @@ static MACHINE_DRIVER_START( olibochu )
// MDRV_QUANTUM_PERFECT_CPU("maincpu")
MDRV_MACHINE_START(olibochu)
MDRV_MACHINE_RESET(olibochu)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@ -477,4 +523,4 @@ ROM_END
GAME( 1981, olibochu, 0, olibochu, olibochu, 0, ROT270, "Irem + GDI", "Oli-Boo-Chu", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND )
GAME( 1981, olibochu, 0, olibochu, olibochu, 0, ROT270, "Irem + GDI", "Oli-Boo-Chu", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )

View File

@ -1,12 +1,5 @@
#include "emu.h"
UINT16 *ohmygod_videoram;
static int spritebank;
static tilemap_t *bg_tilemap;
#include "includes/ohmygod.h"
/***************************************************************************
@ -16,8 +9,9 @@ static tilemap_t *bg_tilemap;
static TILE_GET_INFO( get_tile_info )
{
UINT16 code = ohmygod_videoram[2*tile_index+1];
UINT16 attr = ohmygod_videoram[2*tile_index];
ohmygod_state *state = (ohmygod_state *)machine->driver_data;
UINT16 code = state->videoram[2 * tile_index + 1];
UINT16 attr = state->videoram[2 * tile_index];
SET_TILE_INFO(
0,
code,
@ -35,7 +29,8 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( ohmygod )
{
bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,64,64);
ohmygod_state *state = (ohmygod_state *)machine->driver_data;
state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 64, 64);
}
@ -48,28 +43,30 @@ VIDEO_START( ohmygod )
WRITE16_HANDLER( ohmygod_videoram_w )
{
COMBINE_DATA(&ohmygod_videoram[offset]);
tilemap_mark_tile_dirty(bg_tilemap,offset/2);
ohmygod_state *state = (ohmygod_state *)space->machine->driver_data;
COMBINE_DATA(&state->videoram[offset]);
tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
}
WRITE16_HANDLER( ohmygod_spritebank_w )
{
ohmygod_state *state = (ohmygod_state *)space->machine->driver_data;
if (ACCESSING_BITS_8_15)
spritebank = data & 0x8000;
state->spritebank = data & 0x8000;
}
WRITE16_HANDLER( ohmygod_scrollx_w )
{
static UINT16 scroll;
COMBINE_DATA(&scroll);
tilemap_set_scrollx(bg_tilemap,0,scroll - 0x81ec);
ohmygod_state *state = (ohmygod_state *)space->machine->driver_data;
COMBINE_DATA(&state->scrollx);
tilemap_set_scrollx(state->bg_tilemap, 0, state->scrollx - 0x81ec);
}
WRITE16_HANDLER( ohmygod_scrolly_w )
{
static UINT16 scroll;
COMBINE_DATA(&scroll);
tilemap_set_scrolly(bg_tilemap,0,scroll - 0x81ef);
ohmygod_state *state = (ohmygod_state *)space->machine->driver_data;
COMBINE_DATA(&state->scrolly);
tilemap_set_scrolly(state->bg_tilemap, 0, state->scrolly - 0x81ef);
}
@ -79,24 +76,26 @@ WRITE16_HANDLER( ohmygod_scrolly_w )
***************************************************************************/
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
UINT16 *spriteram16 = machine->generic.spriteram.u16;
ohmygod_state *state = (ohmygod_state *)machine->driver_data;
UINT16 *spriteram = state->spriteram;
int offs;
for (offs = 0;offs < machine->generic.spriteram_size/4;offs += 4)
for (offs = 0; offs < state->spriteram_size / 4; offs += 4)
{
int sx,sy,code,color,flipx;
int sx, sy, code, color, flipx;
UINT16 *sr;
sr = spritebank ? (spriteram16+machine->generic.spriteram_size/4) : spriteram16;
sr = state->spritebank ? (spriteram + state->spriteram_size / 4) : spriteram;
code = sr[offs+3] & 0x0fff;
color = sr[offs+2] & 0x000f;
sx = sr[offs+0] - 29;
sy = sr[offs+1];
if (sy >= 32768) sy -= 65536;
flipx = sr[offs+3] & 0x8000;
code = sr[offs + 3] & 0x0fff;
color = sr[offs + 2] & 0x000f;
sx = sr[offs + 0] - 29;
sy = sr[offs + 1];
if (sy >= 32768)
sy -= 65536;
flipx = sr[offs + 3] & 0x8000;
drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
code,
@ -108,7 +107,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
VIDEO_UPDATE( ohmygod )
{
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
draw_sprites(screen->machine,bitmap,cliprect);
ohmygod_state *state = (ohmygod_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}

View File

@ -9,20 +9,7 @@
#include "emu.h"
#include "cpu/z80/z80.h"
static UINT8 *ojankohs_videoram;
static UINT8 *ojankohs_colorram;
static UINT8 *ojankohs_paletteram;
static int ojankohs_gfxreg;
static int ojankohs_flipscreen;
static int ojankohs_scrollx, ojankohs_scrolly;
static tilemap_t *ojankohs_tilemap;
static int ojankoc_screen_refresh;
static bitmap_t *ojankoc_tmpbitmap;
WRITE8_HANDLER( ojankoc_videoram_w );
#include "includes/ojankohs.h"
/******************************************************************************
@ -35,24 +22,25 @@ PALETTE_INIT( ojankoy )
int i;
int bit0, bit1, bit2, bit3, bit4, r, g, b;
for (i = 0; i < machine->config->total_colors; i++) {
bit0 = (color_prom[0] >> 2) & 0x01;
bit1 = (color_prom[0] >> 3) & 0x01;
bit2 = (color_prom[0] >> 4) & 0x01;
bit3 = (color_prom[0] >> 5) & 0x01;
bit4 = (color_prom[0] >> 6) & 0x01;
for (i = 0; i < machine->config->total_colors; i++)
{
bit0 = BIT(color_prom[0], 2);
bit1 = BIT(color_prom[0], 3);
bit2 = BIT(color_prom[0], 4);
bit3 = BIT(color_prom[0], 5);
bit4 = BIT(color_prom[0], 6);
r = 0x08 * bit0 + 0x11 * bit1 + 0x21 * bit2 + 0x43 * bit3 + 0x82 * bit4;
bit0 = (color_prom[machine->config->total_colors] >> 5) & 0x01;
bit1 = (color_prom[machine->config->total_colors] >> 6) & 0x01;
bit2 = (color_prom[machine->config->total_colors] >> 7) & 0x01;
bit3 = (color_prom[0] >> 0) & 0x01;
bit4 = (color_prom[0] >> 1) & 0x01;
bit0 = BIT(color_prom[machine->config->total_colors], 5);
bit1 = BIT(color_prom[machine->config->total_colors], 6);
bit2 = BIT(color_prom[machine->config->total_colors], 7);
bit3 = BIT(color_prom[0], 0);
bit4 = BIT(color_prom[0], 1);
g = 0x08 * bit0 + 0x11 * bit1 + 0x21 * bit2 + 0x43 * bit3 + 0x82 * bit4;
bit0 = (color_prom[machine->config->total_colors] >> 0) & 0x01;
bit1 = (color_prom[machine->config->total_colors] >> 1) & 0x01;
bit2 = (color_prom[machine->config->total_colors] >> 2) & 0x01;
bit3 = (color_prom[machine->config->total_colors] >> 3) & 0x01;
bit4 = (color_prom[machine->config->total_colors] >> 4) & 0x01;
bit0 = BIT(color_prom[machine->config->total_colors], 0);
bit1 = BIT(color_prom[machine->config->total_colors], 1);
bit2 = BIT(color_prom[machine->config->total_colors], 2);
bit3 = BIT(color_prom[machine->config->total_colors], 3);
bit4 = BIT(color_prom[machine->config->total_colors], 4);
b = 0x08 * bit0 + 0x11 * bit1 + 0x21 * bit2 + 0x43 * bit3 + 0x82 * bit4;
palette_set_color(machine, i, MAKE_RGB(r, g, b));
@ -62,55 +50,57 @@ PALETTE_INIT( ojankoy )
WRITE8_HANDLER( ojankohs_palette_w )
{
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
int r, g, b;
ojankohs_paletteram[offset] = data;
state->paletteram[offset] = data;
offset &= 0x7fe;
r = (ojankohs_paletteram[offset + 0] & 0x7c) >> 2;
g = ((ojankohs_paletteram[offset + 0] & 0x03) << 3) |
((ojankohs_paletteram[offset + 1] & 0xe0) >> 5);
b = (ojankohs_paletteram[offset + 1] & 0x1f) >> 0;
r = (state->paletteram[offset + 0] & 0x7c) >> 2;
g = ((state->paletteram[offset + 0] & 0x03) << 3) | ((state->paletteram[offset + 1] & 0xe0) >> 5);
b = (state->paletteram[offset + 1] & 0x1f) >> 0;
palette_set_color_rgb(space->machine,offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
palette_set_color_rgb(space->machine, offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
}
WRITE8_HANDLER( ccasino_palette_w )
{
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
int r, g, b;
/* get top 8 bits of the I/O port address */
offset = (offset << 8) | (cpu_get_reg(space->cpu, Z80_BC) >> 8);
ojankohs_paletteram[offset] = data;
state->paletteram[offset] = data;
offset &= 0x7fe;
r = (ojankohs_paletteram[offset + 0] & 0x7c) >> 2;
g = ((ojankohs_paletteram[offset + 0] & 0x03) << 3) |
((ojankohs_paletteram[offset + 1] & 0xe0) >> 5);
b = (ojankohs_paletteram[offset + 1] & 0x1f) >> 0;
r = (state->paletteram[offset + 0] & 0x7c) >> 2;
g = ((state->paletteram[offset + 0] & 0x03) << 3) | ((state->paletteram[offset + 1] & 0xe0) >> 5);
b = (state->paletteram[offset + 1] & 0x1f) >> 0;
palette_set_color_rgb(space->machine,offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
palette_set_color_rgb(space->machine, offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
}
WRITE8_HANDLER( ojankoc_palette_w )
{
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
int r, g, b, color;
if (ojankohs_paletteram[offset] == data) return;
if (state->paletteram[offset] == data)
return;
ojankohs_paletteram[offset] = data;
ojankoc_screen_refresh = 1;
state->paletteram[offset] = data;
state->screen_refresh = 1;
color = (ojankohs_paletteram[offset & 0x1e] << 8) | ojankohs_paletteram[offset | 0x01];
color = (state->paletteram[offset & 0x1e] << 8) | state->paletteram[offset | 0x01];
r = (color >> 10) & 0x1f;
g = (color >> 5) & 0x1f;
b = (color >> 0) & 0x1f;
palette_set_color_rgb(space->machine,offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
palette_set_color_rgb(space->machine, offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
}
@ -122,53 +112,63 @@ WRITE8_HANDLER( ojankoc_palette_w )
WRITE8_HANDLER( ojankohs_videoram_w )
{
ojankohs_videoram[offset] = data;
tilemap_mark_tile_dirty(ojankohs_tilemap, offset);
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->tilemap, offset);
}
WRITE8_HANDLER( ojankohs_colorram_w )
{
ojankohs_colorram[offset] = data;
tilemap_mark_tile_dirty(ojankohs_tilemap, offset);
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->tilemap, offset);
}
WRITE8_HANDLER( ojankohs_gfxreg_w )
{
if (ojankohs_gfxreg != data) {
ojankohs_gfxreg = data;
tilemap_mark_all_tiles_dirty(ojankohs_tilemap);
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
if (state->gfxreg != data)
{
state->gfxreg = data;
tilemap_mark_all_tiles_dirty(state->tilemap);
}
}
WRITE8_HANDLER( ojankohs_flipscreen_w )
{
if (ojankohs_flipscreen != (data & 0x01)) {
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
ojankohs_flipscreen = data & 0x01;
if (state->flipscreen != BIT(data, 0))
{
tilemap_set_flip_all(space->machine, ojankohs_flipscreen ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
state->flipscreen = BIT(data, 0);
if (ojankohs_flipscreen) {
ojankohs_scrollx = -0xe0;
ojankohs_scrolly = -0x20;
tilemap_set_flip_all(space->machine, state->flipscreen ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
if (state->flipscreen)
{
state->scrollx = -0xe0;
state->scrolly = -0x20;
}
else {
ojankohs_scrollx = 0;
ojankohs_scrolly = 0;
else
{
state->scrollx = 0;
state->scrolly = 0;
}
}
}
static TILE_GET_INFO( ojankohs_get_tile_info )
{
int tile, color;
ojankohs_state *state = (ojankohs_state *)machine->driver_data;
int tile = state->videoram[tile_index] | ((state->colorram[tile_index] & 0x0f) << 8);
int color = (state->colorram[tile_index] & 0xe0) >> 5;
tile = ojankohs_videoram[tile_index] | ((ojankohs_colorram[tile_index] & 0x0f) << 8);
color = (ojankohs_colorram[tile_index] & 0xe0) >> 5;
if (ojankohs_colorram[tile_index] & 0x10) {
tile |= (ojankohs_gfxreg & 0x07) << 12;
color |= (ojankohs_gfxreg & 0xe0) >> 2;
if (state->colorram[tile_index] & 0x10)
{
tile |= (state->gfxreg & 0x07) << 12;
color |= (state->gfxreg & 0xe0) >> 2;
}
SET_TILE_INFO(0, tile, color, 0);
@ -176,12 +176,11 @@ static TILE_GET_INFO( ojankohs_get_tile_info )
static TILE_GET_INFO( ojankoy_get_tile_info )
{
int tile, color, flipx, flipy;
tile = ojankohs_videoram[tile_index] | (ojankohs_videoram[tile_index + 0x1000] << 8);
color = ojankohs_colorram[tile_index] & 0x3f;
flipx = ((ojankohs_colorram[tile_index] & 0x40) >> 6) ? TILEMAP_FLIPX : 0;
flipy = ((ojankohs_colorram[tile_index] & 0x80) >> 7) ? TILEMAP_FLIPY : 0;
ojankohs_state *state = (ojankohs_state *)machine->driver_data;
int tile = state->videoram[tile_index] | (state->videoram[tile_index + 0x1000] << 8);
int color = state->colorram[tile_index] & 0x3f;
int flipx = ((state->colorram[tile_index] & 0x40) >> 6) ? TILEMAP_FLIPX : 0;
int flipy = ((state->colorram[tile_index] & 0x80) >> 7) ? TILEMAP_FLIPY : 0;
SET_TILE_INFO(0, tile, color, (flipx | flipy));
}
@ -193,61 +192,67 @@ static TILE_GET_INFO( ojankoy_get_tile_info )
******************************************************************************/
void ojankoc_flipscreen(const address_space *space, int data)
void ojankoc_flipscreen( const address_space *space, int data )
{
static int ojankoc_flipscreen_old = 0;
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
int x, y;
UINT8 color1, color2;
ojankohs_flipscreen = (data & 0x80) >> 7;
state->flipscreen = BIT(data, 7);
if (ojankohs_flipscreen == ojankoc_flipscreen_old) return;
if (state->flipscreen == state->flipscreen_old)
return;
for (y = 0; y < 0x40; y++) {
for (x = 0; x < 0x100; x++) {
color1 = ojankohs_videoram[0x0000 + ((y * 256) + x)];
color2 = ojankohs_videoram[0x3fff - ((y * 256) + x)];
for (y = 0; y < 0x40; y++)
{
for (x = 0; x < 0x100; x++)
{
color1 = state->videoram[0x0000 + ((y * 256) + x)];
color2 = state->videoram[0x3fff - ((y * 256) + x)];
ojankoc_videoram_w(space, 0x0000 + ((y * 256) + x), color2);
ojankoc_videoram_w(space, 0x3fff - ((y * 256) + x), color1);
color1 = ojankohs_videoram[0x4000 + ((y * 256) + x)];
color2 = ojankohs_videoram[0x7fff - ((y * 256) + x)];
color1 = state->videoram[0x4000 + ((y * 256) + x)];
color2 = state->videoram[0x7fff - ((y * 256) + x)];
ojankoc_videoram_w(space, 0x4000 + ((y * 256) + x), color2);
ojankoc_videoram_w(space, 0x7fff - ((y * 256) + x), color1);
}
}
ojankoc_flipscreen_old = ojankohs_flipscreen;
state->flipscreen_old = state->flipscreen;
}
WRITE8_HANDLER( ojankoc_videoram_w )
{
ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
int i;
UINT8 x, y, xx, px, py ;
UINT8 color, color1, color2;
ojankohs_videoram[offset] = data;
state->videoram[offset] = data;
color1 = ojankohs_videoram[offset & 0x3fff];
color2 = ojankohs_videoram[offset | 0x4000];
color1 = state->videoram[offset & 0x3fff];
color2 = state->videoram[offset | 0x4000];
y = offset >> 6;
x = (offset & 0x3f) << 2;
xx = 0;
if (ojankohs_flipscreen) {
if (state->flipscreen)
{
x = 0xfc - x;
y = 0xff - y;
xx = 3;
}
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
color = ((color1 & 0x01) >> 0) | ((color1 & 0x10) >> 3) | ((color2 & 0x01) << 2) | ((color2 & 0x10) >> 1);
px = x + (i ^ xx);
py = y;
*BITMAP_ADDR16(ojankoc_tmpbitmap, py, px) = color;
*BITMAP_ADDR16(state->tmpbitmap, py, px) = color;
color1 >>= 1;
color2 >>= 1;
@ -263,25 +268,43 @@ WRITE8_HANDLER( ojankoc_videoram_w )
VIDEO_START( ojankohs )
{
ojankohs_tilemap = tilemap_create(machine, ojankohs_get_tile_info, tilemap_scan_rows, 8, 4, 64, 64);
ojankohs_videoram = auto_alloc_array(machine, UINT8, 0x2000);
ojankohs_colorram = auto_alloc_array(machine, UINT8, 0x1000);
ojankohs_paletteram = auto_alloc_array(machine, UINT8, 0x800);
ojankohs_state *state = (ojankohs_state *)machine->driver_data;
state->tilemap = tilemap_create(machine, ojankohs_get_tile_info, tilemap_scan_rows, 8, 4, 64, 64);
state->videoram = auto_alloc_array(machine, UINT8, 0x2000);
state->colorram = auto_alloc_array(machine, UINT8, 0x1000);
state->paletteram = auto_alloc_array(machine, UINT8, 0x800);
state_save_register_global_pointer(machine, state->videoram, 0x2000);
state_save_register_global_pointer(machine, state->colorram, 0x1000);
state_save_register_global_pointer(machine, state->paletteram, 0x800);
}
VIDEO_START( ojankoy )
{
ojankohs_tilemap = tilemap_create(machine, ojankoy_get_tile_info, tilemap_scan_rows, 8, 4, 64, 64);
ojankohs_videoram = auto_alloc_array(machine, UINT8, 0x2000);
ojankohs_colorram = auto_alloc_array(machine, UINT8, 0x1000);
ojankohs_paletteram = auto_alloc_array(machine, UINT8, 0x800);
ojankohs_state *state = (ojankohs_state *)machine->driver_data;
state->tilemap = tilemap_create(machine, ojankoy_get_tile_info, tilemap_scan_rows, 8, 4, 64, 64);
state->videoram = auto_alloc_array(machine, UINT8, 0x2000);
state->colorram = auto_alloc_array(machine, UINT8, 0x1000);
state->paletteram = auto_alloc_array(machine, UINT8, 0x800);
state_save_register_global_pointer(machine, state->videoram, 0x2000);
state_save_register_global_pointer(machine, state->colorram, 0x1000);
state_save_register_global_pointer(machine, state->paletteram, 0x800);
}
VIDEO_START( ojankoc )
{
ojankoc_tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
ojankohs_videoram = auto_alloc_array(machine, UINT8, 0x8000);
ojankohs_paletteram = auto_alloc_array(machine, UINT8, 0x20);
ojankohs_state *state = (ojankohs_state *)machine->driver_data;
state->tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
state->videoram = auto_alloc_array(machine, UINT8, 0x8000);
state->paletteram = auto_alloc_array(machine, UINT8, 0x20);
state_save_register_global_pointer(machine, state->videoram, 0x8000);
state_save_register_global_pointer(machine, state->paletteram, 0x20);
state_save_register_global_bitmap(machine, state->tmpbitmap);
}
@ -293,28 +316,32 @@ VIDEO_START( ojankoc )
VIDEO_UPDATE( ojankohs )
{
tilemap_set_scrollx(ojankohs_tilemap, 0, ojankohs_scrollx);
tilemap_set_scrolly(ojankohs_tilemap, 0, ojankohs_scrolly);
ojankohs_state *state = (ojankohs_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, ojankohs_tilemap, 0, 0);
tilemap_set_scrollx(state->tilemap, 0, state->scrollx);
tilemap_set_scrolly(state->tilemap, 0, state->scrolly);
tilemap_draw(bitmap, cliprect, state->tilemap, 0, 0);
return 0;
}
VIDEO_UPDATE( ojankoc )
{
ojankohs_state *state = (ojankohs_state *)screen->machine->driver_data;
int offs;
if (ojankoc_screen_refresh)
if (state->screen_refresh)
{
const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
/* redraw bitmap */
for (offs = 0; offs < 0x8000; offs++) {
ojankoc_videoram_w(space, offs, ojankohs_videoram[offs]);
for (offs = 0; offs < 0x8000; offs++)
{
ojankoc_videoram_w(space, offs, state->videoram[offs]);
}
ojankoc_screen_refresh = 0;
state->screen_refresh = 0;
}
copybitmap(bitmap, ojankoc_tmpbitmap, 0, 0, 0, 0, cliprect);
copybitmap(bitmap, state->tmpbitmap, 0, 0, 0, 0, cliprect);
return 0;
}