trunk/src/mame/drivers/tutankhm.c
| r248613 | r248614 | |
| 118 | 118 | |
| 119 | 119 | static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, tutankhm_state ) |
| 120 | 120 | 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") |
| 122 | 122 | AM_RANGE(0x8100, 0x8100) AM_MIRROR(0x000f) AM_RAM AM_SHARE("scroll") |
| 123 | 123 | AM_RANGE(0x8120, 0x8120) AM_MIRROR(0x000f) AM_READ(watchdog_reset_r) |
| 124 | 124 | AM_RANGE(0x8160, 0x8160) AM_MIRROR(0x000f) AM_READ_PORT("DSW2") /* DSW2 (inverted bits) */ |
| r248613 | r248614 | |
| 237 | 237 | MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) /* not sure about the visible area */ |
| 238 | 238 | MCFG_SCREEN_UPDATE_DRIVER(tutankhm_state, screen_update_tutankhm) |
| 239 | 239 | |
| 240 | MCFG_PALETTE_ADD("palette", 16) |
| 241 | MCFG_PALETTE_FORMAT(BBGGGRRR) |
| 242 | |
| 240 | 243 | /* sound hardware */ |
| 241 | 244 | MCFG_FRAGMENT_ADD(timeplt_sound) |
| 242 | 245 | MACHINE_CONFIG_END |
trunk/src/mame/includes/tutankhm.h
| r248613 | r248614 | |
| 6 | 6 | tutankhm_state(const machine_config &mconfig, device_type type, const char *tag) |
| 7 | 7 | : driver_device(mconfig, type, tag), |
| 8 | 8 | m_videoram(*this, "videoram"), |
| 9 | | m_paletteram(*this, "paletteram"), |
| 10 | 9 | m_scroll(*this, "scroll"), |
| 11 | | m_maincpu(*this, "maincpu"){ } |
| 10 | m_maincpu(*this, "maincpu"), |
| 11 | m_palette(*this, "palette") { } |
| 12 | 12 | |
| 13 | 13 | /* memory pointers */ |
| 14 | 14 | required_shared_ptr<UINT8> m_videoram; |
| 15 | | required_shared_ptr<UINT8> m_paletteram; |
| 16 | 15 | required_shared_ptr<UINT8> m_scroll; |
| 17 | 16 | |
| 18 | 17 | /* video-related */ |
| r248613 | r248614 | |
| 26 | 25 | |
| 27 | 26 | /* devices */ |
| 28 | 27 | required_device<cpu_device> m_maincpu; |
| 28 | required_device<palette_device> m_palette; |
| 29 | 29 | DECLARE_WRITE8_MEMBER(irq_enable_w); |
| 30 | 30 | DECLARE_WRITE8_MEMBER(tutankhm_bankselect_w); |
| 31 | 31 | DECLARE_WRITE8_MEMBER(sound_mute_w); |
| r248613 | r248614 | |
| 36 | 36 | DECLARE_MACHINE_RESET(tutankhm); |
| 37 | 37 | UINT32 screen_update_tutankhm(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 38 | 38 | INTERRUPT_GEN_MEMBER(tutankhm_interrupt); |
| 39 | | void get_pens( pen_t *pens ); |
| 40 | 39 | }; |
trunk/src/mame/video/tutankhm.c
| r248613 | r248614 | |
| 12 | 12 | #include "includes/tutankhm.h" |
| 13 | 13 | |
| 14 | 14 | |
| 15 | | #define NUM_PENS (0x10) |
| 16 | | |
| 17 | | |
| 18 | 15 | /************************************* |
| 19 | 16 | * |
| 20 | 17 | * Write handlers |
| r248613 | r248614 | |
| 35 | 32 | |
| 36 | 33 | /************************************* |
| 37 | 34 | * |
| 38 | | * Palette management |
| 39 | | * |
| 40 | | *************************************/ |
| 41 | | |
| 42 | | void 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 | | * |
| 57 | 35 | * Video update |
| 58 | 36 | * |
| 59 | 37 | *************************************/ |
| r248613 | r248614 | |
| 62 | 40 | { |
| 63 | 41 | int xorx = m_flip_x ? 255 : 0; |
| 64 | 42 | int xory = m_flip_y ? 255 : 0; |
| 65 | | pen_t pens[NUM_PENS]; |
| 66 | | int x, y; |
| 67 | 43 | |
| 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++) |
| 71 | 45 | { |
| 72 | 46 | UINT32 *dst = &bitmap.pix32(y); |
| 73 | 47 | |
| 74 | | for (x = cliprect.min_x; x <= cliprect.max_x; x++) |
| 48 | for (int x = cliprect.min_x; x <= cliprect.max_x; x++) |
| 75 | 49 | { |
| 76 | 50 | UINT8 effx = x ^ xorx; |
| 77 | 51 | UINT8 yscroll = (effx < 192) ? *m_scroll : 0; |
| 78 | 52 | UINT8 effy = (y ^ xory) + yscroll; |
| 79 | 53 | UINT8 vrambyte = m_videoram[effy * 128 + effx / 2]; |
| 80 | 54 | UINT8 shifted = vrambyte >> (4 * (effx % 2)); |
| 81 | | dst[x] = pens[shifted & 0x0f]; |
| 55 | dst[x] = m_palette->pen_color(shifted & 0x0f); |
| 82 | 56 | } |
| 83 | 57 | } |
| 84 | 58 | |