1 // license:BSD-3-Clause
2 // copyright-holders:Ernesto Corvi
3 #include "emu.h"
4 #include "includes/kikikai.h"
5
6
main_bankswitch_w(uint8_t data)7 void kikikai_state::main_bankswitch_w(uint8_t data)
8 {
9 if ((data & 7) > 5)
10 popmessage("Switching to invalid bank!");
11
12 membank("bank1")->set_entry(data & 0x07);
13
14 m_charbank = BIT(data, 5);
15 }
16
17
18
screen_update_kicknrun(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)19 uint32_t kikikai_state::screen_update_kicknrun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
20 {
21 int offs;
22 int sx, sy, xc, yc;
23 int gfx_num, gfx_attr, gfx_offs;
24
25
26 /* Bubble Bobble doesn't have a real video RAM. All graphics (characters */
27 /* and sprites) are stored in the same memory region, and information on */
28 /* the background character columns is stored inthe area dd00-dd3f */
29 bitmap.fill(255, cliprect);
30
31 sx = 0;
32
33 /* the score display seems to be outside of the main objectram. */
34 for (offs = 0x1500; offs < 0x2000; offs += 4)
35 {
36 int height;
37
38 if (offs >= 0x1800 && offs < 0x1980)
39 continue;
40
41 if (offs >= 0x19c0)
42 continue;
43
44 /* skip empty sprites */
45 /* this is dword aligned so the uint32_t * cast shouldn't give problems */
46 /* on any architecture */
47 if (*(uint32_t *)(&m_mainram[offs]) == 0)
48 continue;
49
50 gfx_num = m_mainram[offs + 1];
51 gfx_attr = m_mainram[offs + 3];
52
53 if (!BIT(gfx_num, 7)) /* 16x16 sprites */
54 {
55 gfx_offs = ((gfx_num & 0x1f) * 0x80) + ((gfx_num & 0x60) >> 1) + 12;
56 height = 2;
57 }
58 else /* tilemaps (each sprite is a 16x256 column) */
59 {
60 gfx_offs = ((gfx_num & 0x3f) * 0x80);
61 height = 32;
62 }
63
64 if ((gfx_num & 0xc0) == 0xc0) /* next column */
65 sx += 16;
66 else
67 {
68 sx = m_mainram[offs + 2];
69 //if (gfx_attr & 0x40) sx -= 256;
70 }
71 sy = 256 - height * 8 - (m_mainram[offs + 0]);
72
73 for (xc = 0; xc < 2; xc++)
74 {
75 for (yc = 0; yc < height; yc++)
76 {
77 int goffs, code, color, flipx, flipy, x, y;
78
79 goffs = gfx_offs + xc * 0x40 + yc * 0x02;
80 code = m_mainram[goffs] + ((m_mainram[goffs + 1] & 0x07) << 8)
81 + ((m_mainram[goffs + 1] & 0x80) << 4) + (m_charbank << 12);
82 color = ((m_mainram[goffs + 1] & 0x38) >> 3) + ((gfx_attr & 0x02) << 2);
83 flipx = m_mainram[goffs + 1] & 0x40;
84 flipy = 0;
85
86 //x = sx + xc * 8;
87 x = (sx + xc * 8) & 0xff;
88 y = (sy + yc * 8) & 0xff;
89
90 m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
91 code,
92 color,
93 flipx,flipy,
94 x,y,15);
95 }
96 }
97 }
98 return 0;
99 }
100
screen_update_kikikai(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)101 uint32_t kikikai_state::screen_update_kikikai(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
102 {
103 int offs;
104 int sx, sy, yc;
105 int gfx_num, /*gfx_attr,*/ gfx_offs;
106 int height;
107 int goffs, code, color, y;
108 int tx, ty;
109
110 bitmap.fill(m_palette->black_pen(), cliprect);
111 sx = 0;
112 for (offs = 0x1500; offs < 0x1800; offs += 4)
113 {
114 if (*(uint32_t*)(m_mainram + offs) == 0)
115 continue;
116
117 ty = m_mainram[offs];
118 gfx_num = m_mainram[offs + 1];
119 tx = m_mainram[offs + 2];
120 //gfx_attr = m_mainram[offs + 3];
121
122 if (gfx_num & 0x80)
123 {
124 gfx_offs = ((gfx_num & 0x3f) << 7);
125 height = 32;
126 if (gfx_num & 0x40) sx += 16;
127 else sx = tx;
128 }
129 else
130 {
131 if (!(ty && tx)) continue;
132 gfx_offs = ((gfx_num & 0x1f) << 7) + ((gfx_num & 0x60) >> 1) + 12;
133 height = 2;
134 sx = tx;
135 }
136
137 sy = 256 - (height << 3) - ty;
138
139 height <<= 1;
140 for (yc = 0; yc < height; yc += 2)
141 {
142 y = (sy + (yc << 2)) & 0xff;
143 goffs = gfx_offs + yc;
144 code = m_mainram[goffs] + ((m_mainram[goffs + 1] & 0x1f) << 8);
145 color = (m_mainram[goffs + 1] & 0xe0) >> 5;
146 goffs += 0x40;
147
148 m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
149 code,
150 color,
151 0,0,
152 sx&0xff,y,15);
153
154 code = m_mainram[goffs] + ((m_mainram[goffs + 1] & 0x1f) << 8);
155 color = (m_mainram[goffs + 1] & 0xe0) >> 5;
156
157 m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
158 code,
159 color,
160 0,0,
161 (sx+8)&0xff,y,15);
162 }
163 }
164 return 0;
165 }
166