fixed foreground colors, fixed background wrap, added notes

This commit is contained in:
Michaël Banaan Ananas 2014-03-31 19:58:13 +00:00
parent 288c1b7018
commit 5a9fe25e7d
3 changed files with 117 additions and 80 deletions

View File

@ -1,6 +1,30 @@
/********************************************************
KO Punch (c) 1981 Sega
KO Punch (c) 1981 Sega
XTAL: ?
CPU: 8085 (proof: it uses SIM opcode)
TODO:
- discrete sound?
- figure out sensors
- coins sometimes don't register
*********************************************************
This is a simple boxing bag game, but for visual feedback
it has a small CRT instead of LEDs or a dial.
Insert coin, select your weightclass (7 buttons on cab), and punch.
Heavyweight - 300K
Middleweight - 260K
Welterweight - 230K
Lightweight - 200K
Featherweight - 170K
Bantamweight - 140K
Flyweight - 100K
********************************************************/
@ -8,6 +32,7 @@
#include "cpu/i8085/i8085.h"
#include "includes/kopunch.h"
INTERRUPT_GEN_MEMBER(kopunch_state::kopunch_interrupt)
{
device.execute().set_input_line(I8085_RST75_LINE, ASSERT_LINE);
@ -26,9 +51,6 @@ READ8_MEMBER(kopunch_state::kopunch_in_r)
WRITE8_MEMBER(kopunch_state::kopunch_lamp_w)
{
set_led_status(machine(), 0, ~data & 0x80);
// if ((data & 0x7f) != 0x7f)
// popmessage("port 38 = %02x",data);
}
WRITE8_MEMBER(kopunch_state::kopunch_coin_w)
@ -36,8 +58,8 @@ WRITE8_MEMBER(kopunch_state::kopunch_coin_w)
coin_counter_w(machine(), 0, ~data & 0x80);
coin_counter_w(machine(), 1, ~data & 0x40);
// if ((data & 0x3f) != 0x3f)
// popmessage("port 34 = %02x",data);
// if ((data & 0x3f) != 0x3e)
// printf("port 34 = %02x ",data);
}
@ -45,9 +67,9 @@ WRITE8_MEMBER(kopunch_state::kopunch_coin_w)
static ADDRESS_MAP_START( kopunch_map, AS_PROGRAM, 8, kopunch_state )
AM_RANGE(0x0000, 0x1fff) AM_ROM
AM_RANGE(0x2000, 0x23ff) AM_RAM
AM_RANGE(0x6000, 0x63ff) AM_RAM_WRITE(kopunch_videoram_w) AM_SHARE("videoram")
AM_RANGE(0x7000, 0x70ff) AM_RAM_WRITE(kopunch_videoram2_w) AM_SHARE("videoram2")
AM_RANGE(0x7100, 0x7aff) AM_RAM // ???
AM_RANGE(0x6000, 0x63ff) AM_RAM_WRITE(kopunch_fg_w) AM_SHARE("vram_fg")
AM_RANGE(0x7000, 0x70ff) AM_RAM_WRITE(kopunch_bg_w) AM_SHARE("vram_bg")
AM_RANGE(0x7100, 0x73ff) AM_RAM // unused vram
ADDRESS_MAP_END
static ADDRESS_MAP_START( kopunch_io_map, AS_IO, 8, kopunch_state )
@ -70,36 +92,36 @@ ADDRESS_MAP_END
INPUT_CHANGED_MEMBER(kopunch_state::left_coin_inserted)
{
/* left coin insertion causes a rst6.5 (vector 0x34) */
// left coin insertion causes a rst6.5 (vector 0x34)
if (newval)
m_maincpu->set_input_line(I8085_RST65_LINE, HOLD_LINE);
}
INPUT_CHANGED_MEMBER(kopunch_state::right_coin_inserted)
{
/* right coin insertion causes a rst5.5 (vector 0x2c) */
// right coin insertion causes a rst5.5 (vector 0x2c)
if (newval)
m_maincpu->set_input_line(I8085_RST55_LINE, HOLD_LINE);
}
static INPUT_PORTS_START( kopunch )
PORT_START("P1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 )
PORT_START("SYSTEM")
PORT_BIT( 0x07, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* punch strength (high 3 bits) */
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, kopunch_state,right_coin_inserted, 0)
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON6 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON7 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, kopunch_state,left_coin_inserted, 0)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // related to above startbuttons
PORT_START("SYSTEM")
PORT_BIT( 0x07, IP_ACTIVE_HIGH, IPT_SPECIAL ) // punch strength (high 3 bits)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, kopunch_state, right_coin_inserted, 0)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SPECIAL ) // sensor
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SPECIAL ) // sensor
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SPECIAL ) // sensor
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, kopunch_state, left_coin_inserted, 0)
PORT_START("DSW")
PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
@ -128,13 +150,10 @@ static INPUT_PORTS_START( kopunch )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("P2")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_COCKTAIL
PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) // ? these 3 are read at the same time: p2>>4, and 7, <<1, read from a table
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) // "
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) // "
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 )
INPUT_PORTS_END
@ -162,30 +181,30 @@ static const gfx_layout charlayoutbig =
};
static GFXDECODE_START( kopunch )
GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 1 )
GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 1 )
GFXDECODE_ENTRY( "gfx2", 0, charlayoutbig, 0, 1 )
GFXDECODE_END
void kopunch_state::machine_start()
{
save_item(NAME(m_gfxbank));
}
void kopunch_state::machine_reset()
{
// zerofill
m_gfxbank = 0;
m_scrollx = 0;
// savestates
save_item(NAME(m_gfxbank));
save_item(NAME(m_scrollx));
}
static MACHINE_CONFIG_START( kopunch, kopunch_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", I8085A, 4000000) /* 4 MHz ???? Uses SIM, must be 8085 */
MCFG_CPU_ADD("maincpu", I8085A, 4000000) // 4 MHz?
MCFG_CPU_PROGRAM_MAP(kopunch_map)
MCFG_CPU_IO_MAP(kopunch_io_map)
MCFG_CPU_VBLANK_INT_DRIVER("screen", kopunch_state, kopunch_interrupt)
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_REFRESH_RATE(60)
@ -215,9 +234,9 @@ ROM_START( kopunch )
ROM_LOAD( "epr1106.x", 0x1000, 0x1000, CRC(25a5c68b) SHA1(9761418c6f3903f8aaceece658739fe5bf5c0803) )
ROM_REGION( 0x1800, "gfx1", 0 )
ROM_LOAD( "epr1102", 0x0000, 0x0800, CRC(8a52de96) SHA1(5abdaa83c6bfea81395cb190f5364b72811927ba) )
ROM_LOAD( "epr1103", 0x0800, 0x0800, CRC(bae5e054) SHA1(95373123ab64543cdffb7ee9e02d0613c5c494bf) )
ROM_LOAD( "epr1104", 0x1000, 0x0800, CRC(7b119a0e) SHA1(454f01355fa9512a7442990cc92da7bc7a8d6b68) )
ROM_LOAD( "epr1103", 0x0000, 0x0800, CRC(bae5e054) SHA1(95373123ab64543cdffb7ee9e02d0613c5c494bf) )
ROM_LOAD( "epr1104", 0x0800, 0x0800, CRC(7b119a0e) SHA1(454f01355fa9512a7442990cc92da7bc7a8d6b68) )
ROM_LOAD( "epr1102", 0x1000, 0x0800, CRC(8a52de96) SHA1(5abdaa83c6bfea81395cb190f5364b72811927ba) )
ROM_REGION( 0x6000, "gfx2", 0 )
ROM_LOAD( "epr1107", 0x0000, 0x1000, CRC(ca00244d) SHA1(690931ea1bef9d80dcd7bd2ea2462b083c884a89) )
@ -228,9 +247,9 @@ ROM_START( kopunch )
ROM_LOAD( "epr1111", 0x5000, 0x1000, CRC(28530ec9) SHA1(1a8782d37128cdb43133fc891cde93d2bdd5476b) )
ROM_REGION( 0x0060, "proms", 0 )
ROM_LOAD( "epr1101", 0x0000, 0x0020, CRC(15600f5d) SHA1(130179f79761cb16316c544e3c689bc10431db30) ) /* palette */
ROM_LOAD( "epr1099", 0x0020, 0x0020, CRC(fc58c456) SHA1(f27c3ad669dfdc33bcd7e0481fa01bf34973e816) ) /* unknown */
ROM_LOAD( "epr1100", 0x0040, 0x0020, CRC(bedb66b1) SHA1(8e78bb205d900075b761e1baa5f5813174ff28ba) ) /* unknown */
ROM_LOAD( "epr1101", 0x0000, 0x0020, CRC(15600f5d) SHA1(130179f79761cb16316c544e3c689bc10431db30) ) /* palette */
ROM_LOAD( "epr1099", 0x0020, 0x0020, CRC(fc58c456) SHA1(f27c3ad669dfdc33bcd7e0481fa01bf34973e816) ) /* unknown */
ROM_LOAD( "epr1100", 0x0040, 0x0020, CRC(bedb66b1) SHA1(8e78bb205d900075b761e1baa5f5813174ff28ba) ) /* unknown */
ROM_END
GAME( 1981, kopunch, 0, kopunch, kopunch, driver_device, 0, ROT270, "Sega", "KO Punch", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
GAME( 1981, kopunch, 0, kopunch, kopunch, driver_device, 0, ROT270, "Sega", "KO Punch", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_MECHANICAL | GAME_SUPPORTS_SAVE )

View File

@ -1,6 +1,6 @@
/*************************************************************************
KO Punch
Sega KO Punch
*************************************************************************/
@ -9,43 +9,45 @@ class kopunch_state : public driver_device
public:
kopunch_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_videoram(*this, "videoram"),
m_videoram2(*this, "videoram2"),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode") { }
/* memory pointers */
required_shared_ptr<UINT8> m_videoram;
required_shared_ptr<UINT8> m_videoram2;
UINT8 * m_colorram;
UINT8 * m_spriteram;
size_t m_spriteram_size;
/* video-related */
tilemap_t *m_bg_tilemap;
tilemap_t *m_fg_tilemap;
int m_gfxbank;
m_gfxdecode(*this, "gfxdecode"),
m_vram_fg(*this, "vram_fg"),
m_vram_bg(*this, "vram_bg")
{ }
/* devices */
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
/* memory pointers */
required_shared_ptr<UINT8> m_vram_fg;
required_shared_ptr<UINT8> m_vram_bg;
/* video-related */
tilemap_t *m_bg_tilemap;
tilemap_t *m_fg_tilemap;
UINT8 m_gfxbank;
UINT8 m_scrollx;
DECLARE_READ8_MEMBER(kopunch_in_r);
DECLARE_WRITE8_MEMBER(kopunch_lamp_w);
DECLARE_WRITE8_MEMBER(kopunch_coin_w);
DECLARE_WRITE8_MEMBER(kopunch_videoram_w);
DECLARE_WRITE8_MEMBER(kopunch_videoram2_w);
DECLARE_WRITE8_MEMBER(kopunch_fg_w);
DECLARE_WRITE8_MEMBER(kopunch_bg_w);
DECLARE_WRITE8_MEMBER(kopunch_scroll_x_w);
DECLARE_WRITE8_MEMBER(kopunch_scroll_y_w);
DECLARE_WRITE8_MEMBER(kopunch_gfxbank_w);
DECLARE_INPUT_CHANGED_MEMBER(left_coin_inserted);
DECLARE_INPUT_CHANGED_MEMBER(right_coin_inserted);
TILE_GET_INFO_MEMBER(get_fg_tile_info);
TILE_GET_INFO_MEMBER(get_bg_tile_info);
virtual void machine_start();
virtual void machine_reset();
virtual void video_start();
DECLARE_PALETTE_INIT(kopunch);
UINT32 screen_update_kopunch(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
virtual void machine_start();
virtual void video_start();
INTERRUPT_GEN_MEMBER(kopunch_interrupt);
};

View File

@ -1,3 +1,11 @@
/*************************************************************************
Sega KO Punch
Functions to emulate the video hardware of the machine.
*************************************************************************/
#include "emu.h"
#include "includes/kopunch.h"
@ -5,10 +13,10 @@
PALETTE_INIT_MEMBER(kopunch_state, kopunch)
{
const UINT8 *color_prom = memregion("proms")->base();
int i;
color_prom += 24; /* first 24 colors are black */
for (i = 0; i < palette.entries(); i++)
color_prom += 24; // first 24 colors are black
for (int i = 0; i < palette.entries(); i++)
{
int bit0, bit1, bit2, r, g, b;
@ -33,20 +41,21 @@ PALETTE_INIT_MEMBER(kopunch_state, kopunch)
}
}
WRITE8_MEMBER(kopunch_state::kopunch_videoram_w)
WRITE8_MEMBER(kopunch_state::kopunch_fg_w)
{
m_videoram[offset] = data;
m_vram_fg[offset] = data;
m_fg_tilemap->mark_tile_dirty(offset);
}
WRITE8_MEMBER(kopunch_state::kopunch_videoram2_w)
WRITE8_MEMBER(kopunch_state::kopunch_bg_w)
{
m_videoram2[offset] = data;
m_vram_bg[offset] = data;
m_bg_tilemap->mark_tile_dirty(offset);
}
WRITE8_MEMBER(kopunch_state::kopunch_scroll_x_w)
{
m_scrollx = data;
m_bg_tilemap->set_scrollx(0, data);
}
@ -57,25 +66,28 @@ WRITE8_MEMBER(kopunch_state::kopunch_scroll_y_w)
WRITE8_MEMBER(kopunch_state::kopunch_gfxbank_w)
{
// d0-d2: bg gfx bank
if (m_gfxbank != (data & 0x07))
{
m_gfxbank = data & 0x07;
m_bg_tilemap->mark_all_dirty();
}
// d3: flip y, other bits: unused
m_bg_tilemap->set_flip((data & 0x08) ? TILEMAP_FLIPY : 0);
}
TILE_GET_INFO_MEMBER(kopunch_state::get_fg_tile_info)
{
int code = m_videoram[tile_index];
int code = m_vram_fg[tile_index];
SET_TILE_INFO_MEMBER(0, code, 0, 0);
}
TILE_GET_INFO_MEMBER(kopunch_state::get_bg_tile_info)
{
int code = (m_videoram2[tile_index] & 0x7f) + 128 * m_gfxbank;
// note: highest bit is unused
int code = (m_vram_bg[tile_index] & 0x7f) | m_gfxbank << 7;
SET_TILE_INFO_MEMBER(1, code, 0, 0);
}
@ -86,13 +98,17 @@ void kopunch_state::video_start()
m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(kopunch_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 16, 16);
m_fg_tilemap->set_transparent_pen(0);
m_bg_tilemap->set_scrolldx(16, 16);
}
UINT32 kopunch_state::screen_update_kopunch(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
bitmap.fill(0, cliprect);
// background does not wrap around horizontally
rectangle bg_clip = cliprect;
bg_clip.max_x = m_scrollx ^ 0xff;
m_bg_tilemap->draw(screen, bitmap, bg_clip, 0, 0);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
return 0;