mirror of
https://github.com/holub/mame
synced 2025-05-28 08:33:05 +03:00
Converted hornet.c to use the Konami 037122 device and removed the old code.
This commit is contained in:
parent
d911a6d636
commit
7144d7feee
@ -311,15 +311,16 @@
|
||||
#include "cpu/m68000/m68000.h"
|
||||
#include "cpu/powerpc/ppc.h"
|
||||
#include "cpu/sharc/sharc.h"
|
||||
#include "machine/adc1213x.h"
|
||||
#include "machine/eeprom.h"
|
||||
#include "machine/k033906.h"
|
||||
#include "machine/konppc.h"
|
||||
#include "video/voodoo.h"
|
||||
#include "machine/timekpr.h"
|
||||
#include "sound/rf5c400.h"
|
||||
#include "rendlay.h"
|
||||
#include "machine/adc1213x.h"
|
||||
#include "sound/k056800.h"
|
||||
#include "machine/k033906.h"
|
||||
#include "video/voodoo.h"
|
||||
#include "video/konicdev.h"
|
||||
#include "rendlay.h"
|
||||
|
||||
static UINT8 led_reg0, led_reg1;
|
||||
static UINT32 *workram;
|
||||
@ -328,244 +329,41 @@ static UINT8 *jvs_sdata;
|
||||
static UINT32 jvs_sdata_ptr = 0;
|
||||
|
||||
|
||||
/* K037122 Tilemap chip (move to konamiic.c ?) */
|
||||
|
||||
#define MAX_K037122_CHIPS 2
|
||||
|
||||
static UINT32 *K037122_tile_ram[MAX_K037122_CHIPS];
|
||||
static UINT32 *K037122_char_ram[MAX_K037122_CHIPS];
|
||||
static int K037122_gfx_index[MAX_K037122_CHIPS];
|
||||
static tilemap_t *K037122_layer[MAX_K037122_CHIPS][2];
|
||||
static UINT32 *K037122_reg[MAX_K037122_CHIPS];
|
||||
|
||||
#define K037122_NUM_TILES 16384
|
||||
|
||||
static const gfx_layout K037122_char_layout =
|
||||
static READ32_HANDLER( hornet_k037122_sram_r )
|
||||
{
|
||||
8, 8,
|
||||
K037122_NUM_TILES,
|
||||
8,
|
||||
{ 0,1,2,3,4,5,6,7 },
|
||||
{ 1*16, 0*16, 3*16, 2*16, 5*16, 4*16, 7*16, 6*16 },
|
||||
{ 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128 },
|
||||
8*128
|
||||
};
|
||||
|
||||
static TILE_GET_INFO( K037122_0_tile_info_layer0 )
|
||||
{
|
||||
UINT32 val = K037122_tile_ram[0][tile_index + (0x8000/4)];
|
||||
int color = (val >> 17) & 0x1f;
|
||||
int tile = val & 0x3fff;
|
||||
int flags = 0;
|
||||
|
||||
if (val & 0x400000)
|
||||
flags |= TILE_FLIPX;
|
||||
if (val & 0x800000)
|
||||
flags |= TILE_FLIPY;
|
||||
|
||||
SET_TILE_INFO(K037122_gfx_index[0], tile, color, flags);
|
||||
running_device *k037122 = devtag_get_device(space->machine, get_cgboard_id() ? "k037122_2" : "k037122_1");
|
||||
return k037122_sram_r(k037122, offset, mem_mask);
|
||||
}
|
||||
|
||||
static TILE_GET_INFO( K037122_0_tile_info_layer1 )
|
||||
static WRITE32_HANDLER( hornet_k037122_sram_w )
|
||||
{
|
||||
UINT32 val = K037122_tile_ram[0][tile_index];
|
||||
int color = (val >> 17) & 0x1f;
|
||||
int tile = val & 0x3fff;
|
||||
int flags = 0;
|
||||
|
||||
if (val & 0x400000)
|
||||
flags |= TILE_FLIPX;
|
||||
if (val & 0x800000)
|
||||
flags |= TILE_FLIPY;
|
||||
|
||||
SET_TILE_INFO(K037122_gfx_index[0], tile, color, flags);
|
||||
}
|
||||
|
||||
static TILE_GET_INFO( K037122_1_tile_info_layer0 )
|
||||
{
|
||||
UINT32 val = K037122_tile_ram[1][tile_index + (0x8000/4)];
|
||||
int color = (val >> 17) & 0x1f;
|
||||
int tile = val & 0x3fff;
|
||||
int flags = 0;
|
||||
|
||||
if (val & 0x400000)
|
||||
flags |= TILE_FLIPX;
|
||||
if (val & 0x800000)
|
||||
flags |= TILE_FLIPY;
|
||||
|
||||
SET_TILE_INFO(K037122_gfx_index[1], tile, color, flags);
|
||||
}
|
||||
|
||||
static TILE_GET_INFO( K037122_1_tile_info_layer1 )
|
||||
{
|
||||
UINT32 val = K037122_tile_ram[1][tile_index];
|
||||
int color = (val >> 17) & 0x1f;
|
||||
int tile = val & 0x3fff;
|
||||
int flags = 0;
|
||||
|
||||
if (val & 0x400000)
|
||||
flags |= TILE_FLIPX;
|
||||
if (val & 0x800000)
|
||||
flags |= TILE_FLIPY;
|
||||
|
||||
SET_TILE_INFO(K037122_gfx_index[1], tile, color, flags);
|
||||
}
|
||||
|
||||
static int K037122_vh_start(running_machine *machine, int chip)
|
||||
{
|
||||
for(K037122_gfx_index[chip] = 0; K037122_gfx_index[chip] < MAX_GFX_ELEMENTS; K037122_gfx_index[chip]++)
|
||||
if (machine->gfx[K037122_gfx_index[chip]] == 0)
|
||||
break;
|
||||
if(K037122_gfx_index[chip] == MAX_GFX_ELEMENTS)
|
||||
return 1;
|
||||
|
||||
K037122_char_ram[chip] = auto_alloc_array(machine, UINT32, 0x200000/4);
|
||||
|
||||
K037122_tile_ram[chip] = auto_alloc_array(machine, UINT32, 0x20000/4);
|
||||
|
||||
K037122_reg[chip] = auto_alloc_array(machine, UINT32, 0x400/4);
|
||||
|
||||
if (chip == 0)
|
||||
{
|
||||
K037122_layer[chip][0] = tilemap_create(machine, K037122_0_tile_info_layer0, tilemap_scan_rows, 8, 8, 256, 64);
|
||||
K037122_layer[chip][1] = tilemap_create(machine, K037122_0_tile_info_layer1, tilemap_scan_rows, 8, 8, 128, 64);
|
||||
}
|
||||
else
|
||||
{
|
||||
K037122_layer[chip][0] = tilemap_create(machine, K037122_1_tile_info_layer0, tilemap_scan_rows, 8, 8, 256, 64);
|
||||
K037122_layer[chip][1] = tilemap_create(machine, K037122_1_tile_info_layer1, tilemap_scan_rows, 8, 8, 128, 64);
|
||||
}
|
||||
|
||||
tilemap_set_transparent_pen(K037122_layer[chip][0], 0);
|
||||
tilemap_set_transparent_pen(K037122_layer[chip][1], 0);
|
||||
|
||||
memset(K037122_char_ram[chip], 0, 0x200000);
|
||||
memset(K037122_tile_ram[chip], 0, 0x20000);
|
||||
memset(K037122_reg[chip], 0, 0x400);
|
||||
|
||||
machine->gfx[K037122_gfx_index[chip]] = gfx_element_alloc(machine, &K037122_char_layout, (UINT8*)K037122_char_ram[chip], machine->config->total_colors / 16, 0);
|
||||
|
||||
state_save_register_item_pointer(machine, "K037122", NULL, chip, K037122_reg[chip], 0x400/sizeof(K037122_reg[chip][0]));
|
||||
state_save_register_item_pointer(machine, "K037122", NULL, chip, K037122_char_ram[chip], 0x200000/sizeof(K037122_char_ram[chip][0]));
|
||||
state_save_register_item_pointer(machine, "K037122", NULL, chip, K037122_tile_ram[chip], 0x20000/sizeof(K037122_tile_ram[chip][0]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void K037122_tile_draw(running_machine *machine, int chip, bitmap_t *bitmap, const rectangle *cliprect)
|
||||
{
|
||||
const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
|
||||
|
||||
if (K037122_reg[chip][0xc] & 0x10000)
|
||||
{
|
||||
tilemap_set_scrolldx(K037122_layer[chip][1], visarea->min_x, visarea->min_x);
|
||||
tilemap_set_scrolldy(K037122_layer[chip][1], visarea->min_y, visarea->min_y);
|
||||
tilemap_draw(bitmap, cliprect, K037122_layer[chip][1], 0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
tilemap_set_scrolldx(K037122_layer[chip][0], visarea->min_x, visarea->min_x);
|
||||
tilemap_set_scrolldy(K037122_layer[chip][0], visarea->min_y, visarea->min_y);
|
||||
tilemap_draw(bitmap, cliprect, K037122_layer[chip][0], 0,0);
|
||||
}
|
||||
}
|
||||
|
||||
static void update_palette_color(running_machine *machine, int chip, UINT32 palette_base, int color)
|
||||
{
|
||||
UINT32 data = K037122_tile_ram[chip][(palette_base/4) + color];
|
||||
palette_set_color_rgb(machine, color, pal5bit(data >> 6), pal6bit(data >> 0), pal5bit(data >> 11));
|
||||
}
|
||||
|
||||
static READ32_HANDLER(K037122_sram_r)
|
||||
{
|
||||
int chip = get_cgboard_id();
|
||||
|
||||
return K037122_tile_ram[chip][offset];
|
||||
}
|
||||
|
||||
static WRITE32_HANDLER(K037122_sram_w)
|
||||
{
|
||||
int chip = get_cgboard_id();
|
||||
|
||||
COMBINE_DATA(K037122_tile_ram[chip] + offset);
|
||||
|
||||
if (K037122_reg[chip][0xc] & 0x10000)
|
||||
{
|
||||
if (offset < 0x8000/4)
|
||||
{
|
||||
tilemap_mark_tile_dirty(K037122_layer[chip][1], offset);
|
||||
}
|
||||
else if (offset >= 0x8000/4 && offset < 0x18000/4)
|
||||
{
|
||||
tilemap_mark_tile_dirty(K037122_layer[chip][0], offset - (0x8000/4));
|
||||
}
|
||||
else if (offset >= 0x18000/4)
|
||||
{
|
||||
update_palette_color(space->machine, chip, 0x18000, offset - (0x18000/4));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (offset < 0x8000/4)
|
||||
{
|
||||
update_palette_color(space->machine, chip, 0, offset);
|
||||
}
|
||||
else if (offset >= 0x8000/4 && offset < 0x18000/4)
|
||||
{
|
||||
tilemap_mark_tile_dirty(K037122_layer[chip][0], offset - (0x8000/4));
|
||||
}
|
||||
else if (offset >= 0x18000/4)
|
||||
{
|
||||
tilemap_mark_tile_dirty(K037122_layer[chip][1], offset - (0x18000/4));
|
||||
}
|
||||
}
|
||||
running_device *k037122 = devtag_get_device(space->machine, get_cgboard_id() ? "k037122_2" : "k037122_1");
|
||||
k037122_sram_w(k037122, offset, data, mem_mask);
|
||||
}
|
||||
|
||||
|
||||
static READ32_HANDLER(K037122_char_r)
|
||||
static READ32_HANDLER( hornet_k037122_char_r )
|
||||
{
|
||||
int chip = get_cgboard_id();
|
||||
|
||||
UINT32 addr;
|
||||
int bank = K037122_reg[chip][0x30/4] & 0x7;
|
||||
|
||||
addr = offset + (bank * (0x40000/4));
|
||||
|
||||
return K037122_char_ram[chip][addr];
|
||||
running_device *k037122 = devtag_get_device(space->machine, get_cgboard_id() ? "k037122_2" : "k037122_1");
|
||||
return k037122_char_r(k037122, offset, mem_mask);
|
||||
}
|
||||
|
||||
static WRITE32_HANDLER(K037122_char_w)
|
||||
static WRITE32_HANDLER( hornet_k037122_char_w )
|
||||
{
|
||||
int chip = get_cgboard_id();
|
||||
|
||||
UINT32 addr;
|
||||
int bank = K037122_reg[chip][0x30/4] & 0x7;
|
||||
|
||||
addr = offset + (bank * (0x40000/4));
|
||||
|
||||
COMBINE_DATA(K037122_char_ram[chip] + addr);
|
||||
gfx_element_mark_dirty(space->machine->gfx[K037122_gfx_index[chip]], addr / 32);
|
||||
running_device *k037122 = devtag_get_device(space->machine, get_cgboard_id() ? "k037122_2" : "k037122_1");
|
||||
k037122_char_w(k037122, offset, data, mem_mask);
|
||||
}
|
||||
|
||||
static READ32_HANDLER(K037122_reg_r)
|
||||
static READ32_HANDLER( hornet_k037122_reg_r )
|
||||
{
|
||||
int chip = get_cgboard_id();
|
||||
|
||||
switch (offset)
|
||||
{
|
||||
case 0x14/4:
|
||||
{
|
||||
return 0x000003fa;
|
||||
}
|
||||
}
|
||||
return K037122_reg[chip][offset];
|
||||
running_device *k037122 = devtag_get_device(space->machine, get_cgboard_id() ? "k037122_2" : "k037122_1");
|
||||
return k037122_reg_r(k037122, offset, mem_mask);
|
||||
}
|
||||
|
||||
static WRITE32_HANDLER(K037122_reg_w)
|
||||
static WRITE32_HANDLER( hornet_k037122_reg_w )
|
||||
{
|
||||
int chip = get_cgboard_id();
|
||||
|
||||
COMBINE_DATA( K037122_reg[chip] + offset );
|
||||
running_device *k037122 = devtag_get_device(space->machine, get_cgboard_id() ? "k037122_2" : "k037122_1");
|
||||
k037122_reg_w(k037122, offset, data, mem_mask);
|
||||
}
|
||||
|
||||
static void voodoo_vblank_0(running_device *device, int param)
|
||||
@ -578,25 +376,14 @@ static void voodoo_vblank_1(running_device *device, int param)
|
||||
cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_IRQ1, ASSERT_LINE);
|
||||
}
|
||||
|
||||
static VIDEO_START( hornet )
|
||||
{
|
||||
K037122_vh_start(machine, 0);
|
||||
}
|
||||
|
||||
static VIDEO_START( hornet_2board )
|
||||
{
|
||||
K037122_vh_start(machine, 0);
|
||||
K037122_vh_start(machine, 1);
|
||||
}
|
||||
|
||||
|
||||
static VIDEO_UPDATE( hornet )
|
||||
{
|
||||
running_device *voodoo = devtag_get_device(screen->machine, "voodoo0");
|
||||
running_device *k037122 = devtag_get_device(screen->machine, "k037122_1");
|
||||
|
||||
voodoo_update(voodoo, bitmap, cliprect);
|
||||
|
||||
K037122_tile_draw(screen->machine, 0, bitmap, cliprect);
|
||||
k037122_tile_draw(k037122, bitmap, cliprect);
|
||||
|
||||
draw_7segment_led(bitmap, 3, 3, led_reg0);
|
||||
draw_7segment_led(bitmap, 9, 3, led_reg1);
|
||||
@ -607,19 +394,21 @@ static VIDEO_UPDATE( hornet_2board )
|
||||
{
|
||||
if (strcmp(screen->tag, "lscreen") == 0)
|
||||
{
|
||||
running_device *k037122 = devtag_get_device(screen->machine, "k037122_1");
|
||||
running_device *voodoo = devtag_get_device(screen->machine, "voodoo0");
|
||||
voodoo_update(voodoo, bitmap, cliprect);
|
||||
|
||||
/* TODO: tilemaps per screen */
|
||||
K037122_tile_draw(screen->machine, 0, bitmap, cliprect);
|
||||
k037122_tile_draw(k037122, bitmap, cliprect);
|
||||
}
|
||||
else if (strcmp(screen->tag, "rscreen") == 0)
|
||||
{
|
||||
running_device *k037122 = devtag_get_device(screen->machine, "k037122_2");
|
||||
running_device *voodoo = devtag_get_device(screen->machine, "voodoo1");
|
||||
voodoo_update(voodoo, bitmap, cliprect);
|
||||
|
||||
/* TODO: tilemaps per screen */
|
||||
K037122_tile_draw(screen->machine, 1, bitmap, cliprect);
|
||||
k037122_tile_draw(k037122, bitmap, cliprect);
|
||||
}
|
||||
|
||||
draw_7segment_led(bitmap, 3, 3, led_reg0);
|
||||
@ -798,9 +587,9 @@ static WRITE32_HANDLER(gun_w)
|
||||
|
||||
static ADDRESS_MAP_START( hornet_map, ADDRESS_SPACE_PROGRAM, 32 )
|
||||
AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE(&workram) /* Work RAM */
|
||||
AM_RANGE(0x74000000, 0x740000ff) AM_READWRITE(K037122_reg_r, K037122_reg_w)
|
||||
AM_RANGE(0x74020000, 0x7403ffff) AM_READWRITE(K037122_sram_r, K037122_sram_w)
|
||||
AM_RANGE(0x74040000, 0x7407ffff) AM_READWRITE(K037122_char_r, K037122_char_w)
|
||||
AM_RANGE(0x74000000, 0x740000ff) AM_READWRITE(hornet_k037122_reg_r, hornet_k037122_reg_w)
|
||||
AM_RANGE(0x74020000, 0x7403ffff) AM_READWRITE(hornet_k037122_sram_r, hornet_k037122_sram_w)
|
||||
AM_RANGE(0x74040000, 0x7407ffff) AM_READWRITE(hornet_k037122_char_r, hornet_k037122_char_w)
|
||||
AM_RANGE(0x74080000, 0x7408000f) AM_READWRITE(gun_r, gun_w)
|
||||
AM_RANGE(0x78000000, 0x7800ffff) AM_READWRITE(cgboard_dsp_shared_r_ppc, cgboard_dsp_shared_w_ppc)
|
||||
AM_RANGE(0x780c0000, 0x780c0003) AM_READWRITE(cgboard_dsp_comm_r_ppc, cgboard_dsp_comm_w_ppc)
|
||||
@ -1111,6 +900,21 @@ static const k033906_interface hornet_k033906_intf_1 =
|
||||
"voodoo1"
|
||||
};
|
||||
|
||||
static const k037122_interface hornet_k037122_intf =
|
||||
{
|
||||
"screen", 0
|
||||
};
|
||||
|
||||
static const k037122_interface hornet_k037122_intf_l =
|
||||
{
|
||||
"lscreen", 0
|
||||
};
|
||||
|
||||
static const k037122_interface hornet_k037122_intf_r =
|
||||
{
|
||||
"rscreen", 1
|
||||
};
|
||||
|
||||
static MACHINE_DRIVER_START( hornet )
|
||||
|
||||
/* basic machine hardware */
|
||||
@ -1147,9 +951,10 @@ static MACHINE_DRIVER_START( hornet )
|
||||
|
||||
MDRV_PALETTE_LENGTH(65536)
|
||||
|
||||
MDRV_VIDEO_START(hornet)
|
||||
MDRV_VIDEO_UPDATE(hornet)
|
||||
|
||||
MDRV_K037122_ADD("k037122_1", hornet_k037122_intf)
|
||||
|
||||
MDRV_K056800_ADD("k056800", hornet_k056800_interface)
|
||||
|
||||
MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
|
||||
@ -1191,9 +996,12 @@ static MACHINE_DRIVER_START( hornet_2board )
|
||||
|
||||
MDRV_MACHINE_RESET(hornet_2board)
|
||||
|
||||
MDRV_VIDEO_START(hornet_2board)
|
||||
MDRV_VIDEO_UPDATE(hornet_2board)
|
||||
|
||||
MDRV_DEVICE_REMOVE("k037122_1")
|
||||
MDRV_K037122_ADD("k037122_1", hornet_k037122_intf_l)
|
||||
MDRV_K037122_ADD("k037122_2", hornet_k037122_intf_r)
|
||||
|
||||
MDRV_DEVICE_REMOVE("voodoo0")
|
||||
MDRV_3DFX_VOODOO_1_ADD("voodoo0", STD_VOODOO_1_CLOCK, 2, "lscreen")
|
||||
MDRV_3DFX_VOODOO_CPU("dsp")
|
||||
|
@ -10668,7 +10668,6 @@ static void update_palette_color( running_device *device, UINT32 palette_base, i
|
||||
|
||||
READ32_DEVICE_HANDLER( k037122_sram_r )
|
||||
{
|
||||
// int chip = get_cgboard_id();
|
||||
k037122_state *k037122 = k037122_get_safe_token(device);
|
||||
|
||||
return k037122->tile_ram[offset];
|
||||
@ -10676,7 +10675,6 @@ READ32_DEVICE_HANDLER( k037122_sram_r )
|
||||
|
||||
WRITE32_DEVICE_HANDLER( k037122_sram_w )
|
||||
{
|
||||
// int chip = get_cgboard_id();
|
||||
k037122_state *k037122 = k037122_get_safe_token(device);
|
||||
|
||||
COMBINE_DATA(k037122->tile_ram + offset);
|
||||
@ -10716,7 +10714,6 @@ WRITE32_DEVICE_HANDLER( k037122_sram_w )
|
||||
|
||||
READ32_DEVICE_HANDLER( k037122_char_r )
|
||||
{
|
||||
// int chip = get_cgboard_id();
|
||||
k037122_state *k037122 = k037122_get_safe_token(device);
|
||||
int bank = k037122->reg[0x30 / 4] & 0x7;
|
||||
|
||||
@ -10725,7 +10722,6 @@ READ32_DEVICE_HANDLER( k037122_char_r )
|
||||
|
||||
WRITE32_DEVICE_HANDLER( k037122_char_w )
|
||||
{
|
||||
// int chip = get_cgboard_id();
|
||||
k037122_state *k037122 = k037122_get_safe_token(device);
|
||||
int bank = k037122->reg[0x30 / 4] & 0x7;
|
||||
UINT32 addr = offset + (bank * (0x40000/4));
|
||||
@ -10736,7 +10732,6 @@ WRITE32_DEVICE_HANDLER( k037122_char_w )
|
||||
|
||||
READ32_DEVICE_HANDLER( k037122_reg_r )
|
||||
{
|
||||
// int chip = get_cgboard_id();
|
||||
k037122_state *k037122 = k037122_get_safe_token(device);
|
||||
|
||||
switch (offset)
|
||||
@ -10751,7 +10746,6 @@ READ32_DEVICE_HANDLER( k037122_reg_r )
|
||||
|
||||
WRITE32_DEVICE_HANDLER( k037122_reg_w )
|
||||
{
|
||||
// int chip = get_cgboard_id();
|
||||
k037122_state *k037122 = k037122_get_safe_token(device);
|
||||
|
||||
COMBINE_DATA(k037122->reg + offset);
|
||||
|
Loading…
Reference in New Issue
Block a user