Previous 199869 Revisions Next

r40102 Saturday 1st August, 2015 at 09:40:41 UTC by Dirk Best
tutankhm: use palette device
[src/mame/drivers]tutankhm.c
[src/mame/includes]tutankhm.h
[src/mame/video]tutankhm.c

trunk/src/mame/drivers/tutankhm.c
r248613r248614
118118
119119static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, tutankhm_state )
120120   AM_RANGE(0x0000, 0x7fff) AM_RAM AM_SHARE("videoram")
121   AM_RANGE(0x8000, 0x800f) AM_MIRROR(0x00f0) AM_RAM AM_SHARE("paletteram")
121   AM_RANGE(0x8000, 0x800f) AM_MIRROR(0x00f0) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
122122   AM_RANGE(0x8100, 0x8100) AM_MIRROR(0x000f) AM_RAM AM_SHARE("scroll")
123123   AM_RANGE(0x8120, 0x8120) AM_MIRROR(0x000f) AM_READ(watchdog_reset_r)
124124   AM_RANGE(0x8160, 0x8160) AM_MIRROR(0x000f) AM_READ_PORT("DSW2") /* DSW2 (inverted bits) */
r248613r248614
237237   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)  /* not sure about the visible area */
238238   MCFG_SCREEN_UPDATE_DRIVER(tutankhm_state, screen_update_tutankhm)
239239
240   MCFG_PALETTE_ADD("palette", 16)
241   MCFG_PALETTE_FORMAT(BBGGGRRR)
242
240243   /* sound hardware */
241244   MCFG_FRAGMENT_ADD(timeplt_sound)
242245MACHINE_CONFIG_END
trunk/src/mame/includes/tutankhm.h
r248613r248614
66   tutankhm_state(const machine_config &mconfig, device_type type, const char *tag)
77      : driver_device(mconfig, type, tag),
88      m_videoram(*this, "videoram"),
9      m_paletteram(*this, "paletteram"),
109      m_scroll(*this, "scroll"),
11      m_maincpu(*this, "maincpu"){ }
10      m_maincpu(*this, "maincpu"),
11      m_palette(*this, "palette") { }
1212
1313   /* memory pointers */
1414   required_shared_ptr<UINT8> m_videoram;
15   required_shared_ptr<UINT8> m_paletteram;
1615   required_shared_ptr<UINT8> m_scroll;
1716
1817   /* video-related */
r248613r248614
2625
2726   /* devices */
2827   required_device<cpu_device> m_maincpu;
28   required_device<palette_device> m_palette;
2929   DECLARE_WRITE8_MEMBER(irq_enable_w);
3030   DECLARE_WRITE8_MEMBER(tutankhm_bankselect_w);
3131   DECLARE_WRITE8_MEMBER(sound_mute_w);
r248613r248614
3636   DECLARE_MACHINE_RESET(tutankhm);
3737   UINT32 screen_update_tutankhm(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
3838   INTERRUPT_GEN_MEMBER(tutankhm_interrupt);
39   void get_pens( pen_t *pens );
4039};
trunk/src/mame/video/tutankhm.c
r248613r248614
1212#include "includes/tutankhm.h"
1313
1414
15#define NUM_PENS    (0x10)
16
17
1815/*************************************
1916 *
2017 *  Write handlers
r248613r248614
3532
3633/*************************************
3734 *
38 *  Palette management
39 *
40 *************************************/
41
42void tutankhm_state::get_pens( pen_t *pens )
43{
44   offs_t i;
45
46   for (i = 0; i < NUM_PENS; i++)
47   {
48      UINT8 data = m_paletteram[i];
49
50      pens[i] = rgb_t(pal3bit(data >> 0), pal3bit(data >> 3), pal2bit(data >> 6));
51   }
52}
53
54
55/*************************************
56 *
5735 *  Video update
5836 *
5937 *************************************/
r248613r248614
6240{
6341   int xorx = m_flip_x ? 255 : 0;
6442   int xory = m_flip_y ? 255 : 0;
65   pen_t pens[NUM_PENS];
66   int x, y;
6743
68   get_pens( pens);
69
70   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
44   for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
7145   {
7246      UINT32 *dst = &bitmap.pix32(y);
7347
74      for (x = cliprect.min_x; x <= cliprect.max_x; x++)
48      for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
7549      {
7650         UINT8 effx = x ^ xorx;
7751         UINT8 yscroll = (effx < 192) ? *m_scroll : 0;
7852         UINT8 effy = (y ^ xory) + yscroll;
7953         UINT8 vrambyte = m_videoram[effy * 128 + effx / 2];
8054         UINT8 shifted = vrambyte >> (4 * (effx % 2));
81         dst[x] = pens[shifted & 0x0f];
55         dst[x] = m_palette->pen_color(shifted & 0x0f);
8256      }
8357   }
8458


Previous 199869 Revisions Next


© 1997-2024 The MAME Team