Added driver data struct and save states to: jangou.c, jantotsu.c, jollyjgr.c and jongkyo.c

This commit is contained in:
Fabio Priuli 2009-12-09 16:04:47 +00:00
parent 08b933040b
commit 58f0e8c7c2
4 changed files with 725 additions and 311 deletions

View File

@ -33,18 +33,33 @@ $c088-$c095 player tiles
#define MASTER_CLOCK XTAL_19_968MHz #define MASTER_CLOCK XTAL_19_968MHz
static UINT8 *blit_buffer; typedef struct _jangou_state jangou_state;
static UINT8 pen_data[0x10]; struct _jangou_state
static UINT8 blit_data[6]; {
/* video-related */
UINT8 *blit_buffer;
UINT8 pen_data[0x10];
UINT8 blit_data[6];
/* Jangou CVSD Sound */ /* sound-related */
static emu_timer *cvsd_bit_timer; // Jangou CVSD Sound
static UINT8 cvsd_shiftreg; emu_timer *cvsd_bit_timer;
static int cvsd_shift_cnt; UINT8 cvsd_shiftreg;
int cvsd_shift_cnt;
// Jangou Lady ADPCM Sound
UINT8 adpcm_byte;
int msm5205_vclk_toggle;
/* Jangou Lady ADPCM Sound */ /* misc */
static UINT8 adpcm_byte; UINT8 mux_data;
static int msm5205_vclk_toggle; UINT8 nsc_latch, z80_latch;
/* devices */
const device_config *cpu_0;
const device_config *cpu_1;
const device_config *cvsd;
const device_config *nsc;
};
/************************************* /*************************************
@ -95,16 +110,20 @@ static PALETTE_INIT( jangou )
static VIDEO_START( jangou ) static VIDEO_START( jangou )
{ {
blit_buffer = auto_alloc_array(machine, UINT8, 256*256); jangou_state *state = (jangou_state *)machine->driver_data;
state->blit_buffer = auto_alloc_array(machine, UINT8, 256 * 256);
state_save_register_global_pointer(machine, state->blit_buffer, 256 * 256);
} }
static VIDEO_UPDATE( jangou ) static VIDEO_UPDATE( jangou )
{ {
jangou_state *state = (jangou_state *)screen->machine->driver_data;
int x, y; int x, y;
for (y = cliprect->min_y; y <= cliprect->max_y; ++y) for (y = cliprect->min_y; y <= cliprect->max_y; ++y)
{ {
UINT8 *src = &blit_buffer[y * 512/2 + cliprect->min_x]; UINT8 *src = &state->blit_buffer[y * 512 / 2 + cliprect->min_x];
UINT16 *dst = BITMAP_ADDR16(bitmap, y, cliprect->min_x); UINT16 *dst = BITMAP_ADDR16(bitmap, y, cliprect->min_x);
for (x = cliprect->min_x; x <= cliprect->max_x; x += 2) for (x = cliprect->min_x; x <= cliprect->max_x; x += 2)
@ -134,55 +153,52 @@ static UINT8 jangou_gfx_nibble(running_machine *machine,UINT16 niboffset)
const UINT8 *const blit_rom = memory_region(machine, "gfx"); const UINT8 *const blit_rom = memory_region(machine, "gfx");
if (niboffset & 1) if (niboffset & 1)
{
return (blit_rom[(niboffset >> 1) & 0xffff] & 0xf0) >> 4; return (blit_rom[(niboffset >> 1) & 0xffff] & 0xf0) >> 4;
}
else else
{
return (blit_rom[(niboffset >> 1) & 0xffff] & 0x0f); return (blit_rom[(niboffset >> 1) & 0xffff] & 0x0f);
} }
}
static void plot_jangou_gfx_pixel(UINT8 pix, int x, int y) static void plot_jangou_gfx_pixel( running_machine *machine, UINT8 pix, int x, int y )
{ {
if (y>=512) return; jangou_state *state = (jangou_state *)machine->driver_data;
if (x>=512) return; if (y < 0 || y >= 512)
if (y<0) return; return;
if (x<0) return; if (x < 0 || x >= 512)
return;
if (x & 1) if (x & 1)
{ state->blit_buffer[(y * 256) + (x >> 1)] = (state->blit_buffer[(y * 256) + (x >> 1)] & 0x0f) | ((pix << 4) & 0xf0);
blit_buffer[(y*256)+(x>>1)] = (blit_buffer[(y*256)+(x>>1)] & 0x0f) | ((pix<<4) & 0xf0);
}
else else
{ state->blit_buffer[(y * 256) + (x >> 1)] = (state->blit_buffer[(y * 256) + (x >> 1)] & 0xf0) | (pix & 0x0f);
blit_buffer[(y*256)+(x>>1)] = (blit_buffer[(y*256)+(x>>1)] & 0xf0) | (pix & 0x0f);
}
} }
static WRITE8_HANDLER( blitter_process_w ) static WRITE8_HANDLER( blitter_process_w )
{ {
jangou_state *state = (jangou_state *)space->machine->driver_data;
int src, x, y, h, w, flipx; int src, x, y, h, w, flipx;
blit_data[offset] = data; state->blit_data[offset] = data;
if (offset == 5) if (offset == 5)
{
//printf("%02x %02x %02x %02x %02x %02x\n",blit_data[0],blit_data[1],blit_data[2],blit_data[3],blit_data[4],blit_data[5]);
w = (blit_data[4] & 0xff)+1;
h = (blit_data[5] & 0xff)+1;
src = ((blit_data[1]<<8)|(blit_data[0]<<0));
x = (blit_data[2] & 0xff);
y = (blit_data[3] & 0xff);
// lowest bit of src controls flipping / draw direction?
flipx=(blit_data[0] & 1);
if (!flipx) src += (w*h)-1;
else src -= (w*h)-1;
{ {
int count = 0; int count = 0;
int xcount, ycount; int xcount, ycount;
/* printf("%02x %02x %02x %02x %02x %02x\n", state->blit_data[0], state->blit_data[1], state->blit_data[2],
state->blit_data[3], state->blit_data[4], state->blit_data[5]); */
w = (state->blit_data[4] & 0xff) + 1;
h = (state->blit_data[5] & 0xff) + 1;
src = ((state->blit_data[1] << 8)|(state->blit_data[0] << 0));
x = (state->blit_data[2] & 0xff);
y = (state->blit_data[3] & 0xff);
// lowest bit of src controls flipping / draw direction?
flipx = (state->blit_data[0] & 1);
if (!flipx)
src += (w * h) - 1;
else
src -= (w * h) - 1;
for (ycount = 0; ycount < h; ycount++) for (ycount = 0; ycount < h; ycount++)
{ {
for(xcount = 0; xcount < w; xcount++) for(xcount = 0; xcount < w; xcount++)
@ -190,17 +206,18 @@ static WRITE8_HANDLER( blitter_process_w )
int drawx = (x + xcount) & 0xff; int drawx = (x + xcount) & 0xff;
int drawy = (y + ycount) & 0xff; int drawy = (y + ycount) & 0xff;
UINT8 dat = jangou_gfx_nibble(space->machine, src + count); UINT8 dat = jangou_gfx_nibble(space->machine, src + count);
UINT8 cur_pen_hi = pen_data[(dat & 0xf0)>>4]; UINT8 cur_pen_hi = state->pen_data[(dat & 0xf0) >> 4];
UINT8 cur_pen_lo = pen_data[(dat & 0x0f)>>0]; UINT8 cur_pen_lo = state->pen_data[(dat & 0x0f) >> 0];
dat = cur_pen_lo | cur_pen_hi<<4; dat = cur_pen_lo | (cur_pen_hi << 4);
if ((dat & 0xff) != 0) if ((dat & 0xff) != 0)
plot_jangou_gfx_pixel(dat, drawx,drawy); plot_jangou_gfx_pixel(space->machine, dat, drawx, drawy);
if (!flipx) count--; if (!flipx)
else count++; count--;
} else
count++;
} }
} }
} }
@ -209,8 +226,10 @@ static WRITE8_HANDLER( blitter_process_w )
/* What is the bit 5 (0x20) for?*/ /* What is the bit 5 (0x20) for?*/
static WRITE8_HANDLER( blit_vregs_w ) static WRITE8_HANDLER( blit_vregs_w )
{ {
jangou_state *state = (jangou_state *)space->machine->driver_data;
// printf("%02x %02x\n", offset, data); // printf("%02x %02x\n", offset, data);
pen_data[offset] = data & 0xf; state->pen_data[offset] = data & 0xf;
} }
/************************************* /*************************************
@ -219,11 +238,10 @@ static WRITE8_HANDLER( blit_vregs_w )
* *
*************************************/ *************************************/
static UINT8 mux_data;
static WRITE8_HANDLER( mux_w ) static WRITE8_HANDLER( mux_w )
{ {
mux_data = ~data; jangou_state *state = (jangou_state *)space->machine->driver_data;
state->mux_data = ~data;
} }
static WRITE8_HANDLER( output_w ) static WRITE8_HANDLER( output_w )
@ -241,7 +259,8 @@ static WRITE8_HANDLER( output_w )
static READ8_DEVICE_HANDLER( input_mux_r ) static READ8_DEVICE_HANDLER( input_mux_r )
{ {
switch(mux_data) jangou_state *state = (jangou_state *)device->machine->driver_data;
switch(state->mux_data)
{ {
case 0x01: return input_port_read(device->machine, "PL1_1"); case 0x01: return input_port_read(device->machine, "PL1_1");
case 0x02: return input_port_read(device->machine, "PL1_2"); case 0x02: return input_port_read(device->machine, "PL1_2");
@ -268,53 +287,59 @@ static READ8_DEVICE_HANDLER( input_system_r )
static WRITE8_HANDLER( sound_latch_w ) static WRITE8_HANDLER( sound_latch_w )
{ {
jangou_state *state = (jangou_state *)space->machine->driver_data;
soundlatch_w(space, 0, data & 0xff); soundlatch_w(space, 0, data & 0xff);
cputag_set_input_line(space->machine, "cpu1", INPUT_LINE_NMI, ASSERT_LINE); cpu_set_input_line(state->cpu_1, INPUT_LINE_NMI, ASSERT_LINE);
} }
static READ8_HANDLER( sound_latch_r ) static READ8_HANDLER( sound_latch_r )
{ {
cputag_set_input_line(space->machine, "cpu1", INPUT_LINE_NMI, CLEAR_LINE); jangou_state *state = (jangou_state *)space->machine->driver_data;
cpu_set_input_line(state->cpu_1, INPUT_LINE_NMI, CLEAR_LINE);
return soundlatch_r(space, 0); return soundlatch_r(space, 0);
} }
/* Jangou HC-55516 CVSD */ /* Jangou HC-55516 CVSD */
static WRITE8_HANDLER( cvsd_w ) static WRITE8_HANDLER( cvsd_w )
{ {
cvsd_shiftreg = data; jangou_state *state = (jangou_state *)space->machine->driver_data;
state->cvsd_shiftreg = data;
} }
static TIMER_CALLBACK( cvsd_bit_timer_callback ) static TIMER_CALLBACK( cvsd_bit_timer_callback )
{ {
jangou_state *state = (jangou_state *)machine->driver_data;
/* Data is shifted out at the MSB */ /* Data is shifted out at the MSB */
hc55516_digit_w(devtag_get_device(machine, "cvsd"), (cvsd_shiftreg >> 7) & 1); hc55516_digit_w(state->cvsd, (state->cvsd_shiftreg >> 7) & 1);
cvsd_shiftreg <<= 1; state->cvsd_shiftreg <<= 1;
/* Trigger an IRQ for every 8 shifted bits */ /* Trigger an IRQ for every 8 shifted bits */
if ((++cvsd_shift_cnt & 7) == 0) if ((++state->cvsd_shift_cnt & 7) == 0)
cputag_set_input_line(machine, "cpu1", 0, HOLD_LINE); cpu_set_input_line(state->cpu_1, 0, HOLD_LINE);
} }
/* Jangou Lady MSM5218 (MSM5205-compatible) ADPCM */ /* Jangou Lady MSM5218 (MSM5205-compatible) ADPCM */
static WRITE8_HANDLER( adpcm_w ) static WRITE8_HANDLER( adpcm_w )
{ {
adpcm_byte = data; jangou_state *state = (jangou_state *)space->machine->driver_data;
state->adpcm_byte = data;
} }
static void jngolady_vclk_cb( const device_config *device ) static void jngolady_vclk_cb( const device_config *device )
{ {
if (msm5205_vclk_toggle == 0) jangou_state *state = (jangou_state *)device->machine->driver_data;
{
msm5205_data_w(device, adpcm_byte >> 4); if (state->msm5205_vclk_toggle == 0)
} msm5205_data_w(device, state->adpcm_byte >> 4);
else else
{ {
msm5205_data_w(device, adpcm_byte & 0xf); msm5205_data_w(device, state->adpcm_byte & 0xf);
cputag_set_input_line(device->machine, "cpu1", 0, HOLD_LINE); cpu_set_input_line(state->cpu_1, 0, HOLD_LINE);
} }
msm5205_vclk_toggle ^= 1; state->msm5205_vclk_toggle ^= 1;
} }
@ -324,27 +349,30 @@ static void jngolady_vclk_cb(const device_config *device)
* *
*************************************/ *************************************/
static UINT8 nsc_latch,z80_latch;
static READ8_HANDLER( master_com_r ) static READ8_HANDLER( master_com_r )
{ {
return z80_latch; jangou_state *state = (jangou_state *)space->machine->driver_data;
return state->z80_latch;
} }
static WRITE8_HANDLER( master_com_w ) static WRITE8_HANDLER( master_com_w )
{ {
cputag_set_input_line(space->machine, "nsc", 0, HOLD_LINE); jangou_state *state = (jangou_state *)space->machine->driver_data;
nsc_latch = data;
cpu_set_input_line(state->nsc, 0, HOLD_LINE);
state->nsc_latch = data;
} }
static READ8_HANDLER( slave_com_r ) static READ8_HANDLER( slave_com_r )
{ {
return nsc_latch; jangou_state *state = (jangou_state *)space->machine->driver_data;
return state->nsc_latch;
} }
static WRITE8_HANDLER( slave_com_w ) static WRITE8_HANDLER( slave_com_w )
{ {
z80_latch = data; jangou_state *state = (jangou_state *)space->machine->driver_data;
state->z80_latch = data;
} }
/************************************* /*************************************
@ -750,14 +778,98 @@ static const msm5205_interface msm5205_config =
static SOUND_START( jangou ) static SOUND_START( jangou )
{ {
jangou_state *state = (jangou_state *)machine->driver_data;
/* Create a timer to feed the CVSD DAC with sample bits */ /* Create a timer to feed the CVSD DAC with sample bits */
cvsd_bit_timer = timer_alloc(machine, cvsd_bit_timer_callback, NULL); state->cvsd_bit_timer = timer_alloc(machine, cvsd_bit_timer_callback, NULL);
timer_adjust_periodic(cvsd_bit_timer, ATTOTIME_IN_HZ(MASTER_CLOCK / 1024), 0, ATTOTIME_IN_HZ(MASTER_CLOCK / 1024)); timer_adjust_periodic(state->cvsd_bit_timer, ATTOTIME_IN_HZ(MASTER_CLOCK / 1024), 0, ATTOTIME_IN_HZ(MASTER_CLOCK / 1024));
} }
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_START( common )
{
jangou_state *state = (jangou_state *)machine->driver_data;
state->cpu_0 = devtag_get_device(machine, "cpu0");
state->cpu_1 = devtag_get_device(machine, "cpu1");
state->cvsd = devtag_get_device(machine, "cvsd");
state->nsc = devtag_get_device(machine, "nsc");
state_save_register_global_array(machine, state->pen_data);
state_save_register_global_array(machine, state->blit_data);
state_save_register_global(machine, state->mux_data);
}
static MACHINE_START( jangou )
{
jangou_state *state = (jangou_state *)machine->driver_data;
MACHINE_START_CALL(common);
state_save_register_global(machine, state->cvsd_shiftreg);
state_save_register_global(machine, state->cvsd_shift_cnt);
}
static MACHINE_START( jngolady )
{
jangou_state *state = (jangou_state *)machine->driver_data;
MACHINE_START_CALL(common);
state_save_register_global(machine, state->adpcm_byte);
state_save_register_global(machine, state->msm5205_vclk_toggle);
state_save_register_global(machine, state->nsc_latch);
state_save_register_global(machine, state->z80_latch);
}
static MACHINE_RESET( common )
{
jangou_state *state = (jangou_state *)machine->driver_data;
int i;
state->mux_data = 0;
for (i = 0; i < 6; i++)
state->blit_data[i] = 0;
for (i = 0; i < 16; i++)
state->pen_data[i] = 0;
}
static MACHINE_RESET( jangou )
{
jangou_state *state = (jangou_state *)machine->driver_data;
MACHINE_RESET_CALL(common);
state->cvsd_shiftreg = 0;
state->cvsd_shift_cnt = 0;
}
static MACHINE_RESET( jngolady )
{
jangou_state *state = (jangou_state *)machine->driver_data;
MACHINE_RESET_CALL(common);
state->adpcm_byte = 0;
state->msm5205_vclk_toggle = 0;
state->nsc_latch = 0;
state->z80_latch = 0;
}
/* Note: All frequencies and dividers are unverified */ /* Note: All frequencies and dividers are unverified */
static MACHINE_DRIVER_START( jangou ) static MACHINE_DRIVER_START( jangou )
/* driver data */
MDRV_DRIVER_DATA(jangou_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("cpu0", Z80, MASTER_CLOCK / 8) MDRV_CPU_ADD("cpu0", Z80, MASTER_CLOCK / 8)
MDRV_CPU_PROGRAM_MAP(cpu0_map) MDRV_CPU_PROGRAM_MAP(cpu0_map)
@ -768,6 +880,9 @@ static MACHINE_DRIVER_START( jangou )
MDRV_CPU_PROGRAM_MAP(cpu1_map) MDRV_CPU_PROGRAM_MAP(cpu1_map)
MDRV_CPU_IO_MAP(cpu1_io) MDRV_CPU_IO_MAP(cpu1_io)
MDRV_MACHINE_START(jangou)
MDRV_MACHINE_RESET(jangou)
/* video hardware */ /* video hardware */
MDRV_PALETTE_INIT(jangou) MDRV_PALETTE_INIT(jangou)
@ -810,6 +925,9 @@ static MACHINE_DRIVER_START( jngolady )
MDRV_CPU_ADD("nsc", NSC8105, MASTER_CLOCK / 8) MDRV_CPU_ADD("nsc", NSC8105, MASTER_CLOCK / 8)
MDRV_CPU_PROGRAM_MAP(nsc_map) MDRV_CPU_PROGRAM_MAP(nsc_map)
MDRV_MACHINE_START(jngolady)
MDRV_MACHINE_RESET(jngolady)
/* sound hardware */ /* sound hardware */
MDRV_SOUND_START(0) MDRV_SOUND_START(0)
MDRV_DEVICE_REMOVE("cvsd") MDRV_DEVICE_REMOVE("cvsd")
@ -829,11 +947,20 @@ static MACHINE_DRIVER_START( cntrygrl )
MDRV_DEVICE_REMOVE("cpu1") MDRV_DEVICE_REMOVE("cpu1")
MDRV_MACHINE_START(common)
MDRV_MACHINE_RESET(common)
/* sound hardware */ /* sound hardware */
MDRV_SOUND_START(0) MDRV_SOUND_START(0)
MDRV_DEVICE_REMOVE("cvsd") MDRV_DEVICE_REMOVE("cvsd")
MACHINE_DRIVER_END MACHINE_DRIVER_END
/*************************************
*
* ROM definition(s)
*
*************************************/
/* /*
JANGOU (C)1982 Nichibutsu JANGOU (C)1982 Nichibutsu
@ -1059,6 +1186,12 @@ ROM_START( luckygrl )
ROM_END ROM_END
/*************************************
*
* Driver initialization
*
*************************************/
/*Temporary kludge for make the RNG work*/ /*Temporary kludge for make the RNG work*/
static READ8_HANDLER( jngolady_rng_r ) static READ8_HANDLER( jngolady_rng_r )
{ {
@ -1076,7 +1209,6 @@ static DRIVER_INIT (luckygrl)
int A; int A;
UINT8 *ROM = memory_region(machine, "cpu0"); UINT8 *ROM = memory_region(machine, "cpu0");
unsigned char patn1[32] = { unsigned char patn1[32] = {
0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0,
0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28, 0x88, 0x28,
@ -1114,14 +1246,20 @@ static DRIVER_INIT (luckygrl)
} }
GAME( 1983, jangou, 0, jangou, jangou, 0, ROT0, "Nichibutsu", "Jangou [BET] (Japan)", GAME_NO_COCKTAIL ) /*************************************
GAME( 1983, macha, 0, jangou, macha, 0, ROT0, "Logitec", "Monoshiri Quiz Osyaberi Macha (Japan)", GAME_NO_COCKTAIL ) *
GAME( 1984, jngolady, 0, jngolady, jngolady, jngolady, ROT0, "Nichibutsu", "Jangou Lady (Japan)", GAME_NO_COCKTAIL ) * Game driver(s)
GAME( 1984, cntrygrl, 0, cntrygrl, cntrygrl, 0, ROT0, "Royal Denshi", "Country Girl (Japan set 1)", GAME_NO_COCKTAIL ) *
GAME( 1984, cntrygrla, cntrygrl, cntrygrl, cntrygrl, 0, ROT0, "Nichibutsu", "Country Girl (Japan set 2)", GAME_NO_COCKTAIL ) *************************************/
GAME( 1984, fruitbun, cntrygrl, cntrygrl, cntrygrl, 0, ROT0, "Nichibutsu", "Fruits & Bunny (World?)", GAME_NO_COCKTAIL )
GAME( 1983, jangou, 0, jangou, jangou, 0, ROT0, "Nichibutsu", "Jangou [BET] (Japan)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1983, macha, 0, jangou, macha, 0, ROT0, "Logitec", "Monoshiri Quiz Osyaberi Macha (Japan)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1984, jngolady, 0, jngolady, jngolady, jngolady, ROT0, "Nichibutsu", "Jangou Lady (Japan)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1984, cntrygrl, 0, cntrygrl, cntrygrl, 0, ROT0, "Royal Denshi", "Country Girl (Japan set 1)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1984, cntrygrla, cntrygrl, cntrygrl, cntrygrl, 0, ROT0, "Nichibutsu", "Country Girl (Japan set 2)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1984, fruitbun, cntrygrl, cntrygrl, cntrygrl, 0, ROT0, "Nichibutsu", "Fruits & Bunny (World?)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
/* The following might not run there... */ /* The following might not run there... */
GAME( 1984?,luckygrl, 0, cntrygrl, cntrygrl, luckygrl, ROT0, "Wing", "Lucky Girl? (Wing)", GAME_NOT_WORKING ) GAME( 1984?, luckygrl, 0, cntrygrl, cntrygrl, luckygrl, ROT0, "Wing", "Lucky Girl? (Wing)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
/* /*
Some other games that might run on this HW: Some other games that might run on this HW:

View File

@ -99,27 +99,44 @@ dumped by sayu
#include "sound/sn76496.h" #include "sound/sn76496.h"
#include "sound/msm5205.h" #include "sound/msm5205.h"
static UINT8 *jan_bitmap; typedef struct _jantotsu_state jantotsu_state;
static UINT8 vram_bank,col_bank; struct _jantotsu_state
static UINT8 mux_data; {
/* video-related */
UINT8 *bitmap;
UINT8 vram_bank, col_bank;
static UINT32 adpcm_pos; /* sound-related */
static UINT8 adpcm_idle; UINT32 adpcm_pos;
static int adpcm_data; UINT8 adpcm_idle;
int adpcm_data;
UINT8 adpcm_trigger;
/* misc */
UINT8 mux_data;
};
/*************************************
*
* Video emulation
*
*************************************/
static VIDEO_START(jantotsu) static VIDEO_START(jantotsu)
{ {
jan_bitmap = auto_alloc_array(machine, UINT8, 0x8000); jantotsu_state *state = (jantotsu_state *)machine->driver_data;
vram_bank = 0; state->bitmap = auto_alloc_array(machine, UINT8, 0x8000);
state_save_register_global_pointer(machine, state->bitmap, 0x8000);
} }
static VIDEO_UPDATE(jantotsu) static VIDEO_UPDATE(jantotsu)
{ {
jantotsu_state *state = (jantotsu_state *)screen->machine->driver_data;
int x, y, i; int x, y, i;
int count; int count = 0;
count = 0;
for (y = 0; y < 256; y++) for (y = 0; y < 256; y++)
{ {
for (x = 0; x < 256; x += 8) for (x = 0; x < 256; x += 8)
@ -128,18 +145,18 @@ static VIDEO_UPDATE(jantotsu)
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
pen[0] = (jan_bitmap[count+0x0000])>>(7-i); pen[0] = (state->bitmap[count + 0x0000]) >> (7 - i);
pen[1] = (jan_bitmap[count+0x2000])>>(7-i); pen[1] = (state->bitmap[count + 0x2000]) >> (7 - i);
pen[2] = (jan_bitmap[count+0x4000])>>(7-i); pen[2] = (state->bitmap[count + 0x4000]) >> (7 - i);
pen[3] = (jan_bitmap[count+0x6000])>>(7-i); pen[3] = (state->bitmap[count + 0x6000]) >> (7 - i);
color = ((pen[0] & 1) << 0); color = ((pen[0] & 1) << 0);
color |= ((pen[1] & 1) << 1); color |= ((pen[1] & 1) << 1);
color |= ((pen[2] & 1) << 2); color |= ((pen[2] & 1) << 2);
color |= ((pen[3] & 1) << 3); color |= ((pen[3] & 1) << 3);
color|= col_bank; color |= state->col_bank;
if((x+i)<=video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y) if ((x + i) <= video_screen_get_visible_area(screen)->max_x && (y + 0) < video_screen_get_visible_area(screen)->max_y)
*BITMAP_ADDR32(bitmap, y, x + i) = screen->machine->pens[color]; *BITMAP_ADDR32(bitmap, y, x + i) = screen->machine->pens[color];
} }
@ -153,17 +170,21 @@ static VIDEO_UPDATE(jantotsu)
/* banked vram */ /* banked vram */
static READ8_HANDLER( jantotsu_bitmap_r ) static READ8_HANDLER( jantotsu_bitmap_r )
{ {
return jan_bitmap[offset+((vram_bank & 3)*0x2000)]; jantotsu_state *state = (jantotsu_state *)space->machine->driver_data;
return state->bitmap[offset + ((state->vram_bank & 3) * 0x2000)];
} }
static WRITE8_HANDLER( jantotsu_bitmap_w ) static WRITE8_HANDLER( jantotsu_bitmap_w )
{ {
jan_bitmap[offset+((vram_bank & 3)*0x2000)] = data; jantotsu_state *state = (jantotsu_state *)space->machine->driver_data;
state->bitmap[offset + ((state->vram_bank & 3) * 0x2000)] = data;
} }
static WRITE8_HANDLER( bankaddr_w ) static WRITE8_HANDLER( bankaddr_w )
{ {
vram_bank = ((data & 0xc0)>>6); // top 2 bits? jantotsu_state *state = (jantotsu_state *)space->machine->driver_data;
state->vram_bank = ((data & 0xc0) >> 6); // top 2 bits?
// looks like the top 2 bits and bottom 2 bits are used.. // looks like the top 2 bits and bottom 2 bits are used..
// multiple buffers? different read / write ? // multiple buffers? different read / write ?
@ -196,16 +217,21 @@ static PALETTE_INIT( jantotsu )
} }
} }
/*************************************
*
* Memory handlers
*
*************************************/
/*Multiplexer is mapped as 6-bits reads,bits 6 & 7 are always connected to the coin mechs.*/ /*Multiplexer is mapped as 6-bits reads,bits 6 & 7 are always connected to the coin mechs.*/
static READ8_HANDLER( jantotsu_mux_r ) static READ8_HANDLER( jantotsu_mux_r )
{ {
static UINT8 coin_port; jantotsu_state *state = (jantotsu_state *)space->machine->driver_data;
UINT8 coin_port = input_port_read(space->machine, "COINS");
coin_port = input_port_read(space->machine, "COINS"); // printf("%02x\n", state->mux_data);
// printf("%02x\n",mux_data); switch (state->mux_data)
switch(mux_data)
{ {
case 0x01: return input_port_read(space->machine, "PL1_1") | coin_port; case 0x01: return input_port_read(space->machine, "PL1_1") | coin_port;
case 0x02: return input_port_read(space->machine, "PL1_2") | coin_port; case 0x02: return input_port_read(space->machine, "PL1_2") | coin_port;
@ -222,7 +248,8 @@ static READ8_HANDLER( jantotsu_mux_r )
static WRITE8_HANDLER( jantotsu_mux_w ) static WRITE8_HANDLER( jantotsu_mux_w )
{ {
mux_data = ~data; jantotsu_state *state = (jantotsu_state *)space->machine->driver_data;
state->mux_data = ~data;
} }
/*If bits 6 & 7 doesn't return 0x80,the game hangs until this bit is set, /*If bits 6 & 7 doesn't return 0x80,the game hangs until this bit is set,
@ -236,11 +263,13 @@ static READ8_HANDLER( jantotsu_dsw2_r )
static WRITE8_DEVICE_HANDLER( jan_adpcm_w ) static WRITE8_DEVICE_HANDLER( jan_adpcm_w )
{ {
jantotsu_state *state = (jantotsu_state *)device->machine->driver_data;
switch (offset) switch (offset)
{ {
case 0: case 0:
adpcm_pos = (data & 0xff) * 0x100; state->adpcm_pos = (data & 0xff) * 0x100;
adpcm_idle = 0; state->adpcm_idle = 0;
msm5205_reset_w(device, 0); msm5205_reset_w(device, 0);
/* I don't think that this will ever happen, it's there just to be sure /* I don't think that this will ever happen, it's there just to be sure
(i.e. I'll probably never do a "nagare" in my entire life ;-) ) */ (i.e. I'll probably never do a "nagare" in my entire life ;-) ) */
@ -250,7 +279,7 @@ static WRITE8_DEVICE_HANDLER( jan_adpcm_w )
break; break;
/*same write as port 2? MSM sample ack? */ /*same write as port 2? MSM sample ack? */
case 1: case 1:
// adpcm_idle = 1; // state->adpcm_idle = 1;
// msm5205_reset_w(device, 1); // msm5205_reset_w(device, 1);
// printf("%02x 1\n", data); // printf("%02x 1\n", data);
break; break;
@ -259,31 +288,37 @@ static WRITE8_DEVICE_HANDLER( jan_adpcm_w )
static void jan_adpcm_int( const device_config *device ) static void jan_adpcm_int( const device_config *device )
{ {
static UINT8 trigger; jantotsu_state *state = (jantotsu_state *)device->machine->driver_data;
if (adpcm_pos >= 0x10000 || adpcm_idle) if (state->adpcm_pos >= 0x10000 || state->adpcm_idle)
{ {
//adpcm_idle = 1; //state->adpcm_idle = 1;
msm5205_reset_w(device, 1); msm5205_reset_w(device, 1);
trigger = 0; state->adpcm_trigger = 0;
} }
else else
{ {
UINT8 *ROM = memory_region(device->machine, "adpcm"); UINT8 *ROM = memory_region(device->machine, "adpcm");
adpcm_data = ((trigger ? (ROM[adpcm_pos] & 0x0f) : (ROM[adpcm_pos] & 0xf0)>>4) ); state->adpcm_data = ((state->adpcm_trigger ? (ROM[state->adpcm_pos] & 0x0f) : (ROM[state->adpcm_pos] & 0xf0) >> 4));
msm5205_data_w(device,adpcm_data & 0xf); msm5205_data_w(device, state->adpcm_data & 0xf);
trigger^=1; state->adpcm_trigger ^= 1;
if(trigger == 0) if (state->adpcm_trigger == 0)
{ {
adpcm_pos++; state->adpcm_pos++;
if((ROM[adpcm_pos] & 0xff) == 0x70) if ((ROM[state->adpcm_pos] & 0xff) == 0x70)
adpcm_idle = 1; state->adpcm_idle = 1;
} }
} }
} }
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( jantotsu_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( jantotsu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xbfff) AM_ROM AM_RANGE(0x0000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_RANGE(0xc000, 0xc7ff) AM_RAM
@ -299,6 +334,13 @@ static ADDRESS_MAP_START( jantotsu_io, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x07, 0x07) AM_WRITE(bankaddr_w) AM_RANGE(0x07, 0x07) AM_WRITE(bankaddr_w)
ADDRESS_MAP_END ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( jantotsu ) static INPUT_PORTS_START( jantotsu )
PORT_START("COINS") PORT_START("COINS")
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
@ -410,14 +452,12 @@ static INPUT_PORTS_START( jantotsu )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_F ) PORT_PLAYER(2) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_F ) PORT_PLAYER(2)
INPUT_PORTS_END INPUT_PORTS_END
static MACHINE_RESET( jantotsu )
{ /*************************************
mux_data = 0; *
/*Load hard-wired background color.*/ * Sound interface
col_bank = (input_port_read(machine, "DSW2") & 0xc0)>>3; *
adpcm_pos = 0; *************************************/
adpcm_idle = 1;
}
static const msm5205_interface msm5205_config = static const msm5205_interface msm5205_config =
{ {
@ -425,14 +465,53 @@ static const msm5205_interface msm5205_config =
MSM5205_S64_4B /* 6 KHz */ MSM5205_S64_4B /* 6 KHz */
}; };
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_START( jantotsu )
{
jantotsu_state *state = (jantotsu_state *)machine->driver_data;
state_save_register_global(machine, state->vram_bank);
state_save_register_global(machine, state->mux_data);
state_save_register_global(machine, state->adpcm_pos);
state_save_register_global(machine, state->adpcm_idle);
state_save_register_global(machine, state->adpcm_data);
state_save_register_global(machine, state->adpcm_trigger);
}
static MACHINE_RESET( jantotsu )
{
jantotsu_state *state = (jantotsu_state *)machine->driver_data;
/*Load hard-wired background color.*/
state->col_bank = (input_port_read(machine, "DSW2") & 0xc0) >> 3;
state->vram_bank = 0;
state->mux_data = 0;
state->adpcm_pos = 0;
state->adpcm_idle = 1;
state->adpcm_data = 0;
state->adpcm_trigger = 0;
}
static MACHINE_DRIVER_START( jantotsu ) static MACHINE_DRIVER_START( jantotsu )
/* driver data */
MDRV_DRIVER_DATA(jantotsu_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,18432000/4) MDRV_CPU_ADD("maincpu", Z80,18432000/4)
MDRV_CPU_PROGRAM_MAP(jantotsu_map) MDRV_CPU_PROGRAM_MAP(jantotsu_map)
MDRV_CPU_IO_MAP(jantotsu_io) MDRV_CPU_IO_MAP(jantotsu_io)
MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse) MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse)
MDRV_MACHINE_START(jantotsu)
MDRV_MACHINE_RESET(jantotsu) MDRV_MACHINE_RESET(jantotsu)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)
@ -462,6 +541,11 @@ static MACHINE_DRIVER_START( jantotsu )
MACHINE_DRIVER_END MACHINE_DRIVER_END
/*************************************
*
* ROM definition(s)
*
*************************************/
ROM_START( jantotsu ) ROM_START( jantotsu )
ROM_REGION( 0x10000, "maincpu", 0 ) ROM_REGION( 0x10000, "maincpu", 0 )
@ -482,4 +566,11 @@ ROM_START( jantotsu )
ROM_LOAD( "jat-60.10p", 0x00, 0x20, CRC(65528ae0) SHA1(6e3bf27d10ec14e3c6a494667b03b68726fcff14) ) ROM_LOAD( "jat-60.10p", 0x00, 0x20, CRC(65528ae0) SHA1(6e3bf27d10ec14e3c6a494667b03b68726fcff14) )
ROM_END ROM_END
GAME( 1983, jantotsu, 0, jantotsu, jantotsu, 0, ROT270, "Sanritsu", "4nin-uchi Mahjong Jantotsu", GAME_IMPERFECT_GRAPHICS )
/*************************************
*
* Game driver(s)
*
*************************************/
GAME( 1983, jantotsu, 0, jantotsu, jantotsu, 0, ROT270, "Sanritsu", "4nin-uchi Mahjong Jantotsu", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )

View File

@ -101,44 +101,70 @@ Notes:
#include "cpu/z80/z80.h" #include "cpu/z80/z80.h"
#include "sound/ay8910.h" #include "sound/ay8910.h"
static tilemap *bg_tilemap;
static int nmi_enable = 0, jullyjgr_flip_screen_x = 0, jullyjgr_flip_screen_y = 0; typedef struct _jollyjgr_state jollyjgr_state;
static UINT8 *jollyjgr_bitmap; struct _jollyjgr_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * colorram;
UINT8 * spriteram;
UINT8 * bitmap;
/* video-related */
tilemap *bg_tilemap;
/* misc */
int nmi_enable, flip_x, flip_y;
};
/*************************************
*
* Memory handlers
*
*************************************/
static WRITE8_HANDLER( jollyjgr_videoram_w ) static WRITE8_HANDLER( jollyjgr_videoram_w )
{ {
space->machine->generic.videoram.u8[offset] = data; jollyjgr_state *state = (jollyjgr_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap,offset); state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
} }
static WRITE8_HANDLER( jollyjgr_attrram_w ) static WRITE8_HANDLER( jollyjgr_attrram_w )
{ {
jollyjgr_state *state = (jollyjgr_state *)space->machine->driver_data;
if (offset & 1) if (offset & 1)
{ {
/* color change */ /* color change */
int i; int i;
for (i = offset >> 1; i < 0x0400; i += 32) for (i = offset >> 1; i < 0x0400; i += 32)
tilemap_mark_tile_dirty(bg_tilemap, i); tilemap_mark_tile_dirty(state->bg_tilemap, i);
} }
else else
{ {
tilemap_set_scrolly(bg_tilemap, offset >> 1, data); tilemap_set_scrolly(state->bg_tilemap, offset >> 1, data);
} }
space->machine->generic.colorram.u8[offset] = data; state->colorram[offset] = data;
} }
static WRITE8_HANDLER( jollyjgr_misc_w ) static WRITE8_HANDLER( jollyjgr_misc_w )
{ {
jollyjgr_state *state = (jollyjgr_state *)space->machine->driver_data;
// they could be swapped, because it always set "data & 3" // they could be swapped, because it always set "data & 3"
jullyjgr_flip_screen_x = data & 1; state->flip_x = data & 1;
jullyjgr_flip_screen_y = data & 2; state->flip_y = data & 2;
tilemap_set_flip(bg_tilemap, (jullyjgr_flip_screen_x ? TILEMAP_FLIPX : 0) | (jullyjgr_flip_screen_y ? TILEMAP_FLIPY : 0)); tilemap_set_flip(state->bg_tilemap, (state->flip_x ? TILEMAP_FLIPX : 0) | (state->flip_y ? TILEMAP_FLIPY : 0));
nmi_enable = data & 0x80; state->nmi_enable = data & 0x80;
} }
static WRITE8_HANDLER( jollyjgr_coin_lookout_w ) static WRITE8_HANDLER( jollyjgr_coin_lookout_w )
{ {
coin_lockout_global_w(space->machine, data & 1); coin_lockout_global_w(space->machine, data & 1);
@ -146,6 +172,12 @@ static WRITE8_HANDLER( jollyjgr_coin_lookout_w )
/* bits 4, 5, 6 and 7 are used too */ /* bits 4, 5, 6 and 7 are used too */
} }
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( jollyjgr_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( jollyjgr_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_RANGE(0x8000, 0x87ff) AM_RAM
@ -156,14 +188,20 @@ static ADDRESS_MAP_START( jollyjgr_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8fff, 0x8fff) AM_READ_PORT("DSW2") AM_RANGE(0x8fff, 0x8fff) AM_READ_PORT("DSW2")
AM_RANGE(0x8ffc, 0x8ffc) AM_WRITE(jollyjgr_misc_w) AM_RANGE(0x8ffc, 0x8ffc) AM_WRITE(jollyjgr_misc_w)
AM_RANGE(0x8ffd, 0x8ffd) AM_WRITE(jollyjgr_coin_lookout_w) AM_RANGE(0x8ffd, 0x8ffd) AM_WRITE(jollyjgr_coin_lookout_w)
AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(jollyjgr_videoram_w) AM_BASE_GENERIC(videoram) AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(jollyjgr_videoram_w) AM_BASE_MEMBER(jollyjgr_state, videoram)
AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(jollyjgr_attrram_w) AM_BASE_GENERIC(colorram) AM_RANGE(0x9800, 0x983f) AM_RAM_WRITE(jollyjgr_attrram_w) AM_BASE_MEMBER(jollyjgr_state, colorram)
AM_RANGE(0x9840, 0x987f) AM_RAM AM_BASE_GENERIC(spriteram) AM_RANGE(0x9840, 0x987f) AM_RAM AM_BASE_MEMBER(jollyjgr_state, spriteram)
AM_RANGE(0x9880, 0x9bff) AM_RAM AM_RANGE(0x9880, 0x9bff) AM_RAM
AM_RANGE(0xa000, 0xffff) AM_RAM AM_BASE(&jollyjgr_bitmap) AM_RANGE(0xa000, 0xffff) AM_RAM AM_BASE_MEMBER(jollyjgr_state, bitmap)
ADDRESS_MAP_END ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( jollyjgr ) static INPUT_PORTS_START( jollyjgr )
PORT_START("DSW1") PORT_START("DSW1")
PORT_DIPNAME( 0x03, 0x02, DEF_STR( Bonus_Life ) ) PORT_DIPNAME( 0x03, 0x02, DEF_STR( Bonus_Life ) )
@ -232,6 +270,12 @@ static INPUT_PORTS_START( jollyjgr )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_TILT ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_TILT )
INPUT_PORTS_END INPUT_PORTS_END
/*************************************
*
* Video emulation
*
*************************************/
static PALETTE_INIT( jollyjgr ) static PALETTE_INIT( jollyjgr )
{ {
int i; int i;
@ -268,20 +312,23 @@ static PALETTE_INIT( jollyjgr )
/* Tilemap is the same as in Galaxian */ /* Tilemap is the same as in Galaxian */
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
int color = machine->generic.colorram.u8[((tile_index & 0x1f) << 1) | 1] & 7; jollyjgr_state *state = (jollyjgr_state *)machine->driver_data;
SET_TILE_INFO(0, machine->generic.videoram.u8[tile_index], color, 0); int color = state->colorram[((tile_index & 0x1f) << 1) | 1] & 7;
SET_TILE_INFO(0, state->videoram[tile_index], color, 0);
} }
static VIDEO_START( jollyjgr ) static VIDEO_START( jollyjgr )
{ {
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); jollyjgr_state *state = (jollyjgr_state *)machine->driver_data;
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(bg_tilemap, 0); tilemap_set_transparent_pen(state->bg_tilemap, 0);
tilemap_set_scroll_cols(bg_tilemap, 32); tilemap_set_scroll_cols(state->bg_tilemap, 32);
} }
static void draw_bitmap(bitmap_t *bitmap) static void draw_bitmap( running_machine *machine, bitmap_t *bitmap )
{ {
jollyjgr_state *state = (jollyjgr_state *)machine->driver_data;
int x, y, count; int x, y, count;
int i, bit0, bit1, bit2; int i, bit0, bit1, bit2;
int color; int color;
@ -293,18 +340,18 @@ static void draw_bitmap(bitmap_t *bitmap)
{ {
for(i = 0; i < 8; i++) for(i = 0; i < 8; i++)
{ {
bit0 = (jollyjgr_bitmap[count] >> i) & 1; bit0 = (state->bitmap[count] >> i) & 1;
bit1 = (jollyjgr_bitmap[count + 0x2000] >> i) & 1; bit1 = (state->bitmap[count + 0x2000] >> i) & 1;
bit2 = (jollyjgr_bitmap[count + 0x4000] >> i) & 1; bit2 = (state->bitmap[count + 0x4000] >> i) & 1;
color = bit0 | (bit1 << 1) | (bit2 << 2); color = bit0 | (bit1 << 1) | (bit2 << 2);
if(color) if(color)
{ {
if(jullyjgr_flip_screen_x && jullyjgr_flip_screen_y) if(state->flip_x && state->flip_y)
*BITMAP_ADDR16(bitmap, y, x * 8 + i) = color + 32; *BITMAP_ADDR16(bitmap, y, x * 8 + i) = color + 32;
else if(jullyjgr_flip_screen_x && !jullyjgr_flip_screen_y) else if(state->flip_x && !state->flip_y)
*BITMAP_ADDR16(bitmap, 255 - y, x * 8 + i) = color + 32; *BITMAP_ADDR16(bitmap, 255 - y, x * 8 + i) = color + 32;
else if(!jullyjgr_flip_screen_x && jullyjgr_flip_screen_y) else if(!state->flip_x && state->flip_y)
*BITMAP_ADDR16(bitmap, y, 255 - x * 8 - i) = color + 32; *BITMAP_ADDR16(bitmap, y, 255 - x * 8 - i) = color + 32;
else else
*BITMAP_ADDR16(bitmap, 255 - y, 255 - x * 8 - i) = color + 32; *BITMAP_ADDR16(bitmap, 255 - y, 255 - x * 8 - i) = color + 32;
@ -318,14 +365,15 @@ static void draw_bitmap(bitmap_t *bitmap)
static VIDEO_UPDATE( jollyjgr ) static VIDEO_UPDATE( jollyjgr )
{ {
UINT8 *spriteram = screen->machine->generic.spriteram.u8; jollyjgr_state *state = (jollyjgr_state *)screen->machine->driver_data;
UINT8 *spriteram = state->spriteram;
int offs; int offs;
bitmap_fill(bitmap, cliprect, 32); bitmap_fill(bitmap, cliprect, 32);
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_bitmap(bitmap); draw_bitmap(screen->machine, bitmap);
/* Sprites are the same as in Galaxian */ /* Sprites are the same as in Galaxian */
for (offs = 0; offs < 0x40; offs += 4) for (offs = 0; offs < 0x40; offs += 4)
@ -337,22 +385,19 @@ static VIDEO_UPDATE( jollyjgr )
int code = spriteram[offs + 1] & 0x3f; int code = spriteram[offs + 1] & 0x3f;
int color = spriteram[offs + 2] & 7; int color = spriteram[offs + 2] & 7;
if (jullyjgr_flip_screen_x) if (state->flip_x)
{ {
sx = 240 - sx; sx = 240 - sx;
flipx = !flipx; flipx = !flipx;
} }
if (jullyjgr_flip_screen_y) if (state->flip_y)
{
flipy = !flipy; flipy = !flipy;
}
else else
{
sy = 240 - sy; sy = 240 - sy;
}
if (offs < 3*4) sy++; if (offs < 3 * 4)
sy++;
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1], drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1],
code,color, code,color,
@ -363,6 +408,12 @@ static VIDEO_UPDATE( jollyjgr )
return 0; return 0;
} }
/*************************************
*
* Graphics definitions
*
*************************************/
static const gfx_layout jollyjgr_charlayout = static const gfx_layout jollyjgr_charlayout =
{ {
8,8, 8,8,
@ -392,17 +443,52 @@ static GFXDECODE_START( jollyjgr )
GFXDECODE_ENTRY( "gfx2", 0, jollyjgr_spritelayout, 0, 8 ) GFXDECODE_ENTRY( "gfx2", 0, jollyjgr_spritelayout, 0, 8 )
GFXDECODE_END GFXDECODE_END
/*************************************
*
* Machine driver
*
*************************************/
static INTERRUPT_GEN( jollyjgr_interrupt ) static INTERRUPT_GEN( jollyjgr_interrupt )
{ {
if(nmi_enable) jollyjgr_state *state = (jollyjgr_state *)device->machine->driver_data;
if(state->nmi_enable)
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
} }
static MACHINE_START( jollyjgr )
{
jollyjgr_state *state = (jollyjgr_state *)machine->driver_data;
state_save_register_global(machine, state->nmi_enable);
state_save_register_global(machine, state->flip_x);
state_save_register_global(machine, state->flip_y);
}
static MACHINE_RESET( jollyjgr )
{
jollyjgr_state *state = (jollyjgr_state *)machine->driver_data;
state->nmi_enable = 0;
state->flip_x = 0;
state->flip_y = 0;
}
static MACHINE_DRIVER_START( jollyjgr ) static MACHINE_DRIVER_START( jollyjgr )
/* driver data */
MDRV_DRIVER_DATA(jollyjgr_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 3579545) /* 3,579545 MHz */ MDRV_CPU_ADD("maincpu", Z80, 3579545) /* 3,579545 MHz */
MDRV_CPU_PROGRAM_MAP(jollyjgr_map) MDRV_CPU_PROGRAM_MAP(jollyjgr_map)
MDRV_CPU_VBLANK_INT("screen", jollyjgr_interrupt) MDRV_CPU_VBLANK_INT("screen", jollyjgr_interrupt)
MDRV_MACHINE_START(jollyjgr)
MDRV_MACHINE_RESET(jollyjgr)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)
@ -425,6 +511,12 @@ static MACHINE_DRIVER_START( jollyjgr )
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.45) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.45)
MACHINE_DRIVER_END MACHINE_DRIVER_END
/*************************************
*
* ROM definition(s)
*
*************************************/
ROM_START( jollyjgr ) ROM_START( jollyjgr )
ROM_REGION( 0x10000, "maincpu", 0 ) ROM_REGION( 0x10000, "maincpu", 0 )
ROM_LOAD( "kd14.8a", 0x0000, 0x1000, CRC(404cfa2b) SHA1(023abecbc614d1deb6a239906f62e25bb688ac14) ) ROM_LOAD( "kd14.8a", 0x0000, 0x1000, CRC(404cfa2b) SHA1(023abecbc614d1deb6a239906f62e25bb688ac14) )
@ -449,4 +541,10 @@ ROM_START( jollyjgr )
ROM_LOAD( "kd13.1f", 0x0000, 0x1000, CRC(4f4e4e13) SHA1(a8fe0e1fd354e6cc2cf65eab66882c3b98c82100) ) ROM_LOAD( "kd13.1f", 0x0000, 0x1000, CRC(4f4e4e13) SHA1(a8fe0e1fd354e6cc2cf65eab66882c3b98c82100) )
ROM_END ROM_END
GAME( 1982, jollyjgr, 0, jollyjgr, jollyjgr, 0, ROT90, "Taito Corporation", "Jolly Jogger", 0 ) /*************************************
*
* Game driver(s)
*
*************************************/
GAME( 1982, jollyjgr, 0, jollyjgr, jollyjgr, 0, ROT90, "Taito Corporation", "Jolly Jogger", GAME_SUPPORTS_SAVE )

View File

@ -1,12 +1,4 @@
/* Jongkyo */ /**********************************************************
#include "driver.h"
#include "cpu/z80/z80.h"
#include "sound/ay8910.h"
#include "machine/segacrpt.h"
#define JONGKYO_CLOCK 18432000
/*
Jongkyo Jongkyo
(c)1985 Kiwako (c)1985 Kiwako
@ -30,13 +22,34 @@ PR-6264.0H (82S123N)
PR-6265.0M (82S129N) PR-6265.0M (82S129N)
PR-6266.0B (82S129N) PR-6266.0B (82S129N)
*/ **********************************************************/
#include "driver.h"
#include "cpu/z80/z80.h"
#include "sound/ay8910.h"
#include "machine/segacrpt.h"
#define JONGKYO_CLOCK 18432000
//static UINT8 *videoram; typedef struct _jongkyo_state jongkyo_state;
struct _jongkyo_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * videoram2;
static int rom_bank; /* misc */
static UINT8* videoram2; UINT8 rom_bank;
UINT8 mux_data;
};
/*************************************
*
* Video emulation
*
*************************************/
static VIDEO_START( jongkyo ) static VIDEO_START( jongkyo )
{ {
@ -45,6 +58,7 @@ static VIDEO_START(jongkyo)
static VIDEO_UPDATE( jongkyo ) static VIDEO_UPDATE( jongkyo )
{ {
jongkyo_state *state = (jongkyo_state *)screen->machine->driver_data;
int y; int y;
for (y = 0; y < 256; ++y) for (y = 0; y < 256; ++y)
@ -58,7 +72,7 @@ static VIDEO_UPDATE(jongkyo)
UINT8 data2; UINT8 data2;
UINT8 data3; UINT8 data3;
// data3 = videoram2[x/4 + y*64]; // wrong // data3 = state->videoram2[x/4 + y*64]; // wrong
// good mahjong tiles // good mahjong tiles
data3 = 0x0f; // we're missing 2 bits.. there must be another piece of video ram somewhere or we can't use all the colours (6bpp).. banked somehow? data3 = 0x0f; // we're missing 2 bits.. there must be another piece of video ram somewhere or we can't use all the colours (6bpp).. banked somehow?
@ -67,17 +81,14 @@ static VIDEO_UPDATE(jongkyo)
data1 = screen->machine->generic.videoram.u8[0x4000 + x/4 + y*64]; data1 = state->videoram[0x4000 + x / 4 + y * 64];
data2 = screen->machine->generic.videoram.u8[x/4 + y*64]; data2 = state->videoram[x / 4 + y * 64];
for (b = 0; b < 4; ++b) for (b = 0; b < 4; ++b)
{ {
*BITMAP_ADDR16(bitmap, 255-y, 255-(x+b)) = ((data2 & 0x01)) + *BITMAP_ADDR16(bitmap, 255 - y, 255 - (x + b)) = ((data2 & 0x01)) + ((data2 & 0x10) >> 3) +
((data2 & 0x10) >> 3) + ((data1 & 0x01) << 2) + ((data1 & 0x10) >> 1) +
((data1 & 0x01) << 2) + ((data3 & 0x01) << 4) + ((data3 & 0x10) << 1);
((data1 & 0x10) >> 1) +
((data3 & 0x01) << 4) +
((data3 & 0x10) << 1);
data1 >>= 1; data1 >>= 1;
data2 >>= 1; data2 >>= 1;
data3 >>= 1; data3 >>= 1;
@ -89,25 +100,30 @@ static VIDEO_UPDATE(jongkyo)
} }
/*************************************
*
* Memory handlers
*
*************************************/
static WRITE8_HANDLER( bank_select_w ) static WRITE8_HANDLER( bank_select_w )
{ {
jongkyo_state *state = (jongkyo_state *)space->machine->driver_data;
int mask = 1 << (offset >> 1); int mask = 1 << (offset >> 1);
rom_bank &= ~mask; state->rom_bank &= ~mask;
if (offset & 1) if (offset & 1)
rom_bank |= mask; state->rom_bank |= mask;
memory_set_bank(space->machine, "bank1", rom_bank); memory_set_bank(space->machine, "bank1", state->rom_bank);
} }
static UINT8 mux_data;
static WRITE8_HANDLER( mux_w ) static WRITE8_HANDLER( mux_w )
{ {
mux_data = ~data; jongkyo_state *state = (jongkyo_state *)space->machine->driver_data;
// printf("%02x\n",mux_data); state->mux_data = ~data;
// printf("%02x\n", state->mux_data);
} }
static WRITE8_HANDLER( jongkyo_coin_counter_w ) static WRITE8_HANDLER( jongkyo_coin_counter_w )
@ -120,11 +136,10 @@ static WRITE8_HANDLER( jongkyo_coin_counter_w )
static READ8_DEVICE_HANDLER( input_1p_r ) static READ8_DEVICE_HANDLER( input_1p_r )
{ {
static UINT8 cr_clear; jongkyo_state *state = (jongkyo_state *)device->machine->driver_data;
UINT8 cr_clear = input_port_read(device->machine, "CR_CLEAR");
cr_clear = input_port_read(device->machine, "CR_CLEAR"); switch (state->mux_data)
switch(mux_data)
{ {
case 0x01: return input_port_read(device->machine, "PL1_1") | cr_clear; case 0x01: return input_port_read(device->machine, "PL1_1") | cr_clear;
case 0x02: return input_port_read(device->machine, "PL1_2") | cr_clear; case 0x02: return input_port_read(device->machine, "PL1_2") | cr_clear;
@ -133,19 +148,18 @@ static READ8_DEVICE_HANDLER( input_1p_r )
case 0x10: return input_port_read(device->machine, "PL1_5") | cr_clear; case 0x10: return input_port_read(device->machine, "PL1_5") | cr_clear;
case 0x20: return input_port_read(device->machine, "PL1_6") | cr_clear; case 0x20: return input_port_read(device->machine, "PL1_6") | cr_clear;
} }
// printf("%04x\n",mux_data); // printf("%04x\n", state->mux_data);
return (input_port_read(device->machine, "PL1_1") & input_port_read(device->machine, "PL1_2") & input_port_read(device->machine, "PL1_3") & return (input_port_read(device->machine, "PL1_1") & input_port_read(device->machine, "PL1_2") & input_port_read(device->machine, "PL1_3") &
input_port_read(device->machine, "PL1_4") & input_port_read(device->machine, "PL1_5") & input_port_read(device->machine, "PL1_6")) | cr_clear;//input_port_read(device->machine, "PL1_0") && ; input_port_read(device->machine, "PL1_4") & input_port_read(device->machine, "PL1_5") & input_port_read(device->machine, "PL1_6")) | cr_clear;
} }
static READ8_DEVICE_HANDLER( input_2p_r ) static READ8_DEVICE_HANDLER( input_2p_r )
{ {
static UINT8 coin_port; jongkyo_state *state = (jongkyo_state *)device->machine->driver_data;
UINT8 coin_port = input_port_read(device->machine, "COINS");
coin_port = input_port_read(device->machine, "COINS"); switch (state->mux_data)
switch(mux_data)
{ {
case 0x01: return input_port_read(device->machine, "PL2_1") | coin_port; case 0x01: return input_port_read(device->machine, "PL2_1") | coin_port;
case 0x02: return input_port_read(device->machine, "PL2_2") | coin_port; case 0x02: return input_port_read(device->machine, "PL2_2") | coin_port;
@ -154,15 +168,16 @@ static READ8_DEVICE_HANDLER( input_2p_r )
case 0x10: return input_port_read(device->machine, "PL2_5") | coin_port; case 0x10: return input_port_read(device->machine, "PL2_5") | coin_port;
case 0x20: return input_port_read(device->machine, "PL2_6") | coin_port; case 0x20: return input_port_read(device->machine, "PL2_6") | coin_port;
} }
// printf("%04x\n",mux_data); // printf("%04x\n", state->mux_data);
return (input_port_read(device->machine, "PL2_1") & input_port_read(device->machine, "PL2_2") & input_port_read(device->machine, "PL2_3") & return (input_port_read(device->machine, "PL2_1") & input_port_read(device->machine, "PL2_2") & input_port_read(device->machine, "PL2_3") &
input_port_read(device->machine, "PL2_4") & input_port_read(device->machine, "PL2_5") & input_port_read(device->machine, "PL2_6")) | coin_port;//input_port_read(device->machine, "PL1_0") && ; input_port_read(device->machine, "PL2_4") & input_port_read(device->machine, "PL2_5") & input_port_read(device->machine, "PL2_6")) | coin_port;
} }
static WRITE8_HANDLER( videoram2_w ) static WRITE8_HANDLER( videoram2_w )
{ {
videoram2[offset] = data; jongkyo_state *state = (jongkyo_state *)space->machine->driver_data;
state->videoram2[offset] = data;
} }
static WRITE8_HANDLER( unknown_w ) static WRITE8_HANDLER( unknown_w )
@ -192,12 +207,19 @@ static WRITE8_HANDLER( unknown_w )
} }
} }
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( jongkyo_memmap, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( jongkyo_memmap, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x3fff) AM_ROM AM_WRITE(videoram2_w) // wrong, this doesn't seem to be video ram on write.. AM_RANGE(0x0000, 0x3fff) AM_ROM AM_WRITE(videoram2_w) // wrong, this doesn't seem to be video ram on write..
AM_RANGE(0x4000, 0x6bff) AM_ROM // fixed rom AM_RANGE(0x4000, 0x6bff) AM_ROM // fixed rom
AM_RANGE(0x6c00, 0x6fff) AM_ROMBANK("bank1") // banked (8 banks) AM_RANGE(0x6c00, 0x6fff) AM_ROMBANK("bank1") // banked (8 banks)
AM_RANGE(0x7000, 0x77ff) AM_RAM AM_RANGE(0x7000, 0x77ff) AM_RAM
AM_RANGE(0x8000, 0xffff) AM_RAM AM_BASE_GENERIC(videoram) AM_RANGE(0x8000, 0xffff) AM_RAM AM_BASE_MEMBER(jongkyo_state, videoram)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -214,7 +236,10 @@ static ADDRESS_MAP_START( jongkyo_portmap, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x46, 0x4f) AM_WRITE(unknown_w) AM_RANGE(0x46, 0x4f) AM_WRITE(unknown_w)
ADDRESS_MAP_END ADDRESS_MAP_END
/* /*************************************
*
* Input ports
*
------------------------------------------------------------- -------------------------------------------------------------
Jongkyo ?1985 Kiwako Jongkyo ?1985 Kiwako
DIPSW | |1 2 3 4 |5 |6 |7 |8 DIPSW | |1 2 3 4 |5 |6 |7 |8
@ -248,7 +273,8 @@ Last chance |5 | | | |on |
Bonus credit |50 | | | | |on Bonus credit |50 | | | | |on
|10 | | | | |off |10 | | | | |off
------------------------------------------------------------- -------------------------------------------------------------
*/
*************************************/
static INPUT_PORTS_START( jongkyo ) static INPUT_PORTS_START( jongkyo )
@ -388,6 +414,13 @@ static INPUT_PORTS_START( jongkyo )
INPUT_PORTS_END INPUT_PORTS_END
/*************************************
*
* Palette initialization and
* graphics definitions
*
*************************************/
static PALETTE_INIT(jongkyo) static PALETTE_INIT(jongkyo)
{ {
int i; int i;
@ -405,6 +438,12 @@ static PALETTE_INIT(jongkyo)
} }
} }
/*************************************
*
* Sound interface
*
*************************************/
static const ay8910_interface ay8910_config = static const ay8910_interface ay8910_config =
{ {
AY8910_LEGACY_OUTPUT, AY8910_LEGACY_OUTPUT,
@ -415,13 +454,47 @@ static const ay8910_interface ay8910_config =
DEVCB_NULL DEVCB_NULL
}; };
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_START( jongkyo )
{
jongkyo_state *state = (jongkyo_state *)machine->driver_data;
state->videoram2 = auto_alloc_array(machine, UINT8, 0x4000);
state_save_register_global_pointer(machine, state->videoram2, 0x4000);
state_save_register_global(machine, state->rom_bank);
state_save_register_global(machine, state->mux_data);
}
static MACHINE_RESET( jongkyo )
{
jongkyo_state *state = (jongkyo_state *)machine->driver_data;
state->rom_bank = 0;
state->mux_data = 0;
}
static MACHINE_DRIVER_START( jongkyo ) static MACHINE_DRIVER_START( jongkyo )
/* driver data */
MDRV_DRIVER_DATA(jongkyo_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,JONGKYO_CLOCK/4) MDRV_CPU_ADD("maincpu", Z80,JONGKYO_CLOCK/4)
MDRV_CPU_PROGRAM_MAP(jongkyo_memmap) MDRV_CPU_PROGRAM_MAP(jongkyo_memmap)
MDRV_CPU_IO_MAP(jongkyo_portmap) MDRV_CPU_IO_MAP(jongkyo_portmap)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(jongkyo)
MDRV_MACHINE_RESET(jongkyo)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)
@ -443,6 +516,12 @@ static MACHINE_DRIVER_START( jongkyo )
MACHINE_DRIVER_END MACHINE_DRIVER_END
/*************************************
*
* ROM definition
*
*************************************/
ROM_START( jongkyo ) ROM_START( jongkyo )
ROM_REGION( 0x9000, "maincpu", 0 ) ROM_REGION( 0x9000, "maincpu", 0 )
ROM_LOAD( "epr-6258", 0x00000, 0x02000, CRC(fb8b7bcc) SHA1(8ece7c2c82c237b4b51829d412b2109b96ccd0e7) ) ROM_LOAD( "epr-6258", 0x00000, 0x02000, CRC(fb8b7bcc) SHA1(8ece7c2c82c237b4b51829d412b2109b96ccd0e7) )
@ -462,6 +541,12 @@ ROM_START( jongkyo )
ROM_END ROM_END
/*************************************
*
* Driver initialization
*
*************************************/
static DRIVER_INIT( jongkyo ) static DRIVER_INIT( jongkyo )
{ {
int i; int i;
@ -475,11 +560,13 @@ static DRIVER_INIT( jongkyo )
/* then do the standard Sega decryption */ /* then do the standard Sega decryption */
jongkyo_decode(machine, "maincpu"); jongkyo_decode(machine, "maincpu");
videoram2 = auto_alloc_array(machine, UINT8, 0x4000);
state_save_register_global_pointer(machine, videoram2, 0x4000);
} }
GAME( 1985, jongkyo, 0, jongkyo, jongkyo, jongkyo, ROT0, "Kiwako", "Jongkyo", GAME_WRONG_COLORS ) /*************************************
*
* Game driver
*
*************************************/
GAME( 1985, jongkyo, 0, jongkyo, jongkyo, jongkyo, ROT0, "Kiwako", "Jongkyo", GAME_WRONG_COLORS | GAME_SUPPORTS_SAVE )