mirror of
https://github.com/holub/mame
synced 2025-04-19 15:11:37 +03:00
tutankhm: use palette device
This commit is contained in:
parent
83626b8c4a
commit
18face10b9
@ -118,7 +118,7 @@ WRITE8_MEMBER(tutankhm_state::tutankhm_coin_counter_w)
|
||||
|
||||
static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, tutankhm_state )
|
||||
AM_RANGE(0x0000, 0x7fff) AM_RAM AM_SHARE("videoram")
|
||||
AM_RANGE(0x8000, 0x800f) AM_MIRROR(0x00f0) AM_RAM AM_SHARE("paletteram")
|
||||
AM_RANGE(0x8000, 0x800f) AM_MIRROR(0x00f0) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
|
||||
AM_RANGE(0x8100, 0x8100) AM_MIRROR(0x000f) AM_RAM AM_SHARE("scroll")
|
||||
AM_RANGE(0x8120, 0x8120) AM_MIRROR(0x000f) AM_READ(watchdog_reset_r)
|
||||
AM_RANGE(0x8160, 0x8160) AM_MIRROR(0x000f) AM_READ_PORT("DSW2") /* DSW2 (inverted bits) */
|
||||
@ -237,6 +237,9 @@ static MACHINE_CONFIG_START( tutankhm, tutankhm_state )
|
||||
MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) /* not sure about the visible area */
|
||||
MCFG_SCREEN_UPDATE_DRIVER(tutankhm_state, screen_update_tutankhm)
|
||||
|
||||
MCFG_PALETTE_ADD("palette", 16)
|
||||
MCFG_PALETTE_FORMAT(BBGGGRRR)
|
||||
|
||||
/* sound hardware */
|
||||
MCFG_FRAGMENT_ADD(timeplt_sound)
|
||||
MACHINE_CONFIG_END
|
||||
|
@ -6,13 +6,12 @@ public:
|
||||
tutankhm_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: driver_device(mconfig, type, tag),
|
||||
m_videoram(*this, "videoram"),
|
||||
m_paletteram(*this, "paletteram"),
|
||||
m_scroll(*this, "scroll"),
|
||||
m_maincpu(*this, "maincpu"){ }
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_palette(*this, "palette") { }
|
||||
|
||||
/* memory pointers */
|
||||
required_shared_ptr<UINT8> m_videoram;
|
||||
required_shared_ptr<UINT8> m_paletteram;
|
||||
required_shared_ptr<UINT8> m_scroll;
|
||||
|
||||
/* video-related */
|
||||
@ -26,6 +25,7 @@ public:
|
||||
|
||||
/* devices */
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<palette_device> m_palette;
|
||||
DECLARE_WRITE8_MEMBER(irq_enable_w);
|
||||
DECLARE_WRITE8_MEMBER(tutankhm_bankselect_w);
|
||||
DECLARE_WRITE8_MEMBER(sound_mute_w);
|
||||
@ -36,5 +36,4 @@ public:
|
||||
DECLARE_MACHINE_RESET(tutankhm);
|
||||
UINT32 screen_update_tutankhm(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
|
||||
INTERRUPT_GEN_MEMBER(tutankhm_interrupt);
|
||||
void get_pens( pen_t *pens );
|
||||
};
|
||||
|
@ -12,9 +12,6 @@
|
||||
#include "includes/tutankhm.h"
|
||||
|
||||
|
||||
#define NUM_PENS (0x10)
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Write handlers
|
||||
@ -33,25 +30,6 @@ WRITE8_MEMBER(tutankhm_state::tutankhm_flip_screen_y_w)
|
||||
}
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Palette management
|
||||
*
|
||||
*************************************/
|
||||
|
||||
void tutankhm_state::get_pens( pen_t *pens )
|
||||
{
|
||||
offs_t i;
|
||||
|
||||
for (i = 0; i < NUM_PENS; i++)
|
||||
{
|
||||
UINT8 data = m_paletteram[i];
|
||||
|
||||
pens[i] = rgb_t(pal3bit(data >> 0), pal3bit(data >> 3), pal2bit(data >> 6));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Video update
|
||||
@ -62,23 +40,19 @@ UINT32 tutankhm_state::screen_update_tutankhm(screen_device &screen, bitmap_rgb3
|
||||
{
|
||||
int xorx = m_flip_x ? 255 : 0;
|
||||
int xory = m_flip_y ? 255 : 0;
|
||||
pen_t pens[NUM_PENS];
|
||||
int x, y;
|
||||
|
||||
get_pens( pens);
|
||||
|
||||
for (y = cliprect.min_y; y <= cliprect.max_y; y++)
|
||||
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
|
||||
{
|
||||
UINT32 *dst = &bitmap.pix32(y);
|
||||
|
||||
for (x = cliprect.min_x; x <= cliprect.max_x; x++)
|
||||
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
|
||||
{
|
||||
UINT8 effx = x ^ xorx;
|
||||
UINT8 yscroll = (effx < 192) ? *m_scroll : 0;
|
||||
UINT8 effy = (y ^ xory) + yscroll;
|
||||
UINT8 vrambyte = m_videoram[effy * 128 + effx / 2];
|
||||
UINT8 shifted = vrambyte >> (4 * (effx % 2));
|
||||
dst[x] = pens[shifted & 0x0f];
|
||||
dst[x] = m_palette->pen_color(shifted & 0x0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user