1 // license:BSD-3-Clause
2 // copyright-holders:Frank Palazzolo
3 /*******************************************************************************
4
5 Mouser - Video Hardware:
6
7 Character map with scrollable rows, 1024 possible characters.
8 - index = byte from videoram + 2 bits from colorram)
9 - (if row is scrolled, videoram is offset, colorram is not)
10 - 16 4-color combinations for each char, from colorram
11
12 15 Sprites controlled by 4-byte records
13 - 16 4-color combinations
14 - 2 banks of 64 sprite characters each
15
16 *******************************************************************************/
17
18 #include "emu.h"
19 #include "includes/mouser.h"
20
mouser_palette(palette_device & palette) const21 void mouser_state::mouser_palette(palette_device &palette) const
22 {
23 uint8_t const *const color_prom = memregion("proms")->base();
24
25 for (int i = 0; i < palette.entries(); i++)
26 {
27 int bit0, bit1, bit2;
28
29 // red component
30 bit0 = BIT(color_prom[i], 0);
31 bit1 = BIT(color_prom[i], 1);
32 bit2 = BIT(color_prom[i], 2);
33 int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
34
35 // green component
36 bit0 = BIT(color_prom[i], 3);
37 bit1 = BIT(color_prom[i], 4);
38 bit2 = BIT(color_prom[i], 5);
39 int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
40
41 // blue component
42 bit0 = BIT(color_prom[i], 6);
43 bit1 = BIT(color_prom[i], 7);
44 int const b = 0x4f * bit0 + 0xa8 * bit1;
45
46 palette.set_pen_color(i, rgb_t(r, g, b));
47 }
48 }
49
WRITE_LINE_MEMBER(mouser_state::flip_screen_x_w)50 WRITE_LINE_MEMBER(mouser_state::flip_screen_x_w)
51 {
52 flip_screen_x_set(!state);
53 }
54
WRITE_LINE_MEMBER(mouser_state::flip_screen_y_w)55 WRITE_LINE_MEMBER(mouser_state::flip_screen_y_w)
56 {
57 flip_screen_y_set(!state);
58 }
59
screen_update_mouser(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)60 uint32_t mouser_state::screen_update_mouser(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
61 {
62 uint8_t const *const spriteram = m_spriteram;
63
64 // for every character in the Video RAM
65 for (int offs = 0x3ff; offs >= 0; offs--)
66 {
67 int sx = offs % 32;
68 if (flip_screen_x())
69 sx = 31 - sx;
70
71 int sy = offs / 32;
72 if (flip_screen_y())
73 sy = 31 - sy;
74
75 /* This bit of spriteram appears to be for row scrolling */
76 /* Note: this is dependant on flipping in y */
77 int const scrolled_y_position = (256 + 8*sy - spriteram[offs%32])%256;
78 /* I think we still need to fetch the colorram bits to from the ram underneath, which is not scrolled */
79 /* Ideally we would merge these on a pixel-by-pixel basis, but it's ok to do this char-by-char, */
80 /* Since it's only for the MOUSER logo and it looks fine */
81 /* Note: this is _not_ dependant on flipping */
82 int const color_offs = offs % 32 + ((256 + 8 * (offs / 32) - spriteram[offs % 32] )% 256) / 8 * 32;
83
84 m_gfxdecode->gfx(0)->opaque(bitmap,cliprect,
85 m_videoram[offs] | (m_colorram[color_offs] >> 5) * 256 | ((m_colorram[color_offs] >> 4) & 1) * 512,
86 m_colorram[color_offs]%16,
87 flip_screen_x(),flip_screen_y(),
88 8*sx,scrolled_y_position);
89 }
90
91 // There seem to be two sets of sprites, each decoded identically
92
93 // This is the first set of 7 sprites
94 for (int offs = 0x0084; offs < 0x00a0; offs += 4)
95 {
96 if (BIT(spriteram[offs + 1], 4))
97 {
98 int flipx = BIT(spriteram[offs], 6);
99 int flipy = BIT(spriteram[offs], 7);
100
101 int sx = spriteram[offs + 3];
102 if (flip_screen_x())
103 {
104 flipx = !flipx;
105 sx = 240 - sx;
106 }
107
108 int sy = 0xef - spriteram[offs + 2];
109 if (flip_screen_y())
110 {
111 flipy = !flipy;
112 sy = 238 - sy;
113 }
114
115 m_gfxdecode->gfx(1+((spriteram[offs+1]&0x20)>>5))->transpen(bitmap,cliprect,
116 spriteram[offs]&0x3f,
117 spriteram[offs+1]%16,
118 flipx,flipy,
119 sx,sy,0);
120 }
121 }
122
123 // This is the second set of 8 sprites
124 for (int offs = 0x00c4; offs < 0x00e4; offs += 4)
125 {
126 if (BIT(spriteram[offs + 1], 4))
127 {
128 int flipx = BIT(spriteram[offs], 6);
129 int flipy = BIT(spriteram[offs], 7);
130
131 int sx = spriteram[offs + 3];
132 if (flip_screen_x())
133 {
134 flipx = !flipx;
135 sx = 240 - sx;
136 }
137
138 int sy = 0xef - spriteram[offs + 2];
139 if (flip_screen_y())
140 {
141 flipy = !flipy;
142 sy = 238 - sy;
143 }
144
145 m_gfxdecode->gfx(1+((spriteram[offs+1]&0x20)>>5))->transpen(bitmap,cliprect,
146 spriteram[offs]&0x3f,
147 spriteram[offs+1]%16,
148 flipx,flipy,
149 sx,sy,0);
150 }
151 }
152
153 return 0;
154 }
155