trunk/src/mame/includes/fuukifg2.h
| r32554 | r32555 | |
| 1 | 1 | #include "sound/okim6295.h" |
| 2 | #include "video/fuukifg.h" |
| 2 | 3 | |
| 3 | 4 | class fuuki16_state : public driver_device |
| 4 | 5 | { |
| r32554 | r32555 | |
| 13 | 14 | fuuki16_state(const machine_config &mconfig, device_type type, const char *tag) |
| 14 | 15 | : driver_device(mconfig, type, tag), |
| 15 | 16 | m_vram(*this, "vram"), |
| 16 | | m_spriteram(*this, "spriteram"), |
| 17 | 17 | m_vregs(*this, "vregs"), |
| 18 | 18 | m_unknown(*this, "unknown"), |
| 19 | 19 | m_priority(*this, "priority"), |
| r32554 | r32555 | |
| 22 | 22 | m_oki(*this, "oki"), |
| 23 | 23 | m_gfxdecode(*this, "gfxdecode"), |
| 24 | 24 | m_screen(*this, "screen"), |
| 25 | | m_palette(*this, "palette") { } |
| 25 | m_palette(*this, "palette"), |
| 26 | m_fuukivid(*this, "fuukivid") |
| 27 | { } |
| 26 | 28 | |
| 27 | 29 | /* memory pointers */ |
| 28 | 30 | required_shared_ptr_array<UINT16,4> m_vram; |
| 29 | | required_shared_ptr<UINT16> m_spriteram; |
| 30 | 31 | required_shared_ptr<UINT16> m_vregs; |
| 31 | 32 | required_shared_ptr<UINT16> m_unknown; |
| 32 | 33 | required_shared_ptr<UINT16> m_priority; |
| r32554 | r32555 | |
| 59 | 60 | UINT32 screen_update_fuuki16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 60 | 61 | inline void get_tile_info(tile_data &tileinfo, tilemap_memory_index tile_index, int _N_); |
| 61 | 62 | inline void fuuki16_vram_w(offs_t offset, UINT16 data, UINT16 mem_mask, int _N_); |
| 62 | | void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ); |
| 63 | 63 | void fuuki16_draw_layer( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int i, int flag, int pri ); |
| 64 | 64 | DECLARE_WRITE_LINE_MEMBER(soundirq); |
| 65 | 65 | required_device<okim6295_device> m_oki; |
| 66 | 66 | required_device<gfxdecode_device> m_gfxdecode; |
| 67 | 67 | required_device<screen_device> m_screen; |
| 68 | 68 | required_device<palette_device> m_palette; |
| 69 | required_device<fuukivid_device> m_fuukivid; |
| 69 | 70 | protected: |
| 70 | 71 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 71 | 72 | }; |
trunk/src/mame/includes/fuukifg3.h
| r32554 | r32555 | |
| 1 | #include "video/fuukifg.h" |
| 1 | 2 | |
| 2 | | |
| 3 | 3 | /* Define clocks based on actual OSC on the PCB */ |
| 4 | 4 | |
| 5 | 5 | #define CPU_CLOCK (XTAL_40MHz / 2) /* clock for 68020 */ |
| r32554 | r32555 | |
| 22 | 22 | fuuki32_state(const machine_config &mconfig, device_type type, const char *tag) |
| 23 | 23 | : driver_device(mconfig, type, tag), |
| 24 | 24 | m_vram(*this, "vram"), |
| 25 | | m_spriteram(*this, "spriteram"), |
| 26 | 25 | m_vregs(*this, "vregs"), |
| 27 | 26 | m_priority(*this, "priority"), |
| 28 | 27 | m_tilebank(*this, "tilebank"), |
| r32554 | r32555 | |
| 30 | 29 | m_soundcpu(*this, "soundcpu"), |
| 31 | 30 | m_gfxdecode(*this, "gfxdecode"), |
| 32 | 31 | m_screen(*this, "screen"), |
| 33 | | m_palette(*this, "palette") { } |
| 32 | m_palette(*this, "palette"), |
| 33 | m_fuukivid(*this, "fuukivid") |
| 34 | { } |
| 34 | 35 | |
| 35 | 36 | /* memory pointers */ |
| 36 | 37 | required_shared_ptr_array<UINT32,4> m_vram; |
| 37 | | required_shared_ptr<UINT32> m_spriteram; |
| 38 | 38 | required_shared_ptr<UINT32> m_vregs; |
| 39 | 39 | required_shared_ptr<UINT32> m_priority; |
| 40 | 40 | required_shared_ptr<UINT32> m_tilebank; |
| r32554 | r32555 | |
| 55 | 55 | required_device<gfxdecode_device> m_gfxdecode; |
| 56 | 56 | required_device<screen_device> m_screen; |
| 57 | 57 | required_device<palette_device> m_palette; |
| 58 | required_device<fuukivid_device> m_fuukivid; |
| 58 | 59 | |
| 59 | | |
| 60 | 60 | DECLARE_READ32_MEMBER(snd_020_r); |
| 61 | 61 | DECLARE_WRITE32_MEMBER(snd_020_w); |
| 62 | 62 | DECLARE_WRITE32_MEMBER(fuuki32_vregs_w); |
trunk/src/mame/video/fuukifg2.c
| r32554 | r32555 | |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
| 109 | | /*************************************************************************** |
| 110 | 109 | |
| 111 | | |
| 112 | | Sprites Drawing |
| 113 | | |
| 114 | | Offset: Bits: Value: |
| 115 | | |
| 116 | | 0.w fedc ---- ---- ---- Number Of Tiles Along X - 1 |
| 117 | | ---- b--- ---- ---- Flip X |
| 118 | | ---- -a-- ---- ---- 1 = Don't Draw This Sprite |
| 119 | | ---- --98 7654 3210 X (Signed) |
| 120 | | |
| 121 | | 2.w fedc ---- ---- ---- Number Of Tiles Along Y - 1 |
| 122 | | ---- b--- ---- ---- Flip Y |
| 123 | | ---- -a-- ---- ---- |
| 124 | | ---- --98 7654 3210 Y (Signed) |
| 125 | | |
| 126 | | 4.w fedc ---- ---- ---- Zoom X ($0 = Full Size, $F = Half Size) |
| 127 | | ---- ba98 ---- ---- Zoom Y "" |
| 128 | | ---- ---- 76-- ---- Priority |
| 129 | | ---- ---- --54 3210 Color |
| 130 | | |
| 131 | | 6.w Code |
| 132 | | |
| 133 | | |
| 134 | | ***************************************************************************/ |
| 135 | | |
| 136 | | void fuuki16_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 137 | | { |
| 138 | | int offs; |
| 139 | | gfx_element *gfx = m_gfxdecode->gfx(0); |
| 140 | | bitmap_ind8 &priority_bitmap = screen.priority(); |
| 141 | | const rectangle &visarea = screen.visible_area(); |
| 142 | | UINT16 *spriteram16 = m_spriteram; |
| 143 | | int max_x = visarea.max_x + 1; |
| 144 | | int max_y = visarea.max_y + 1; |
| 145 | | |
| 146 | | /* Draw them backwards, for pdrawgfx */ |
| 147 | | for ( offs = (m_spriteram.bytes() - 8) / 2; offs >=0; offs -= 8 / 2 ) |
| 148 | | { |
| 149 | | int x, y, xstart, ystart, xend, yend, xinc, yinc; |
| 150 | | int xnum, ynum, xzoom, yzoom, flipx, flipy; |
| 151 | | int pri_mask; |
| 152 | | |
| 153 | | int sx = spriteram16[offs + 0]; |
| 154 | | int sy = spriteram16[offs + 1]; |
| 155 | | int attr = spriteram16[offs + 2]; |
| 156 | | int code = spriteram16[offs + 3]; |
| 157 | | |
| 158 | | if (sx & 0x400) |
| 159 | | continue; |
| 160 | | |
| 161 | | flipx = sx & 0x0800; |
| 162 | | flipy = sy & 0x0800; |
| 163 | | |
| 164 | | xnum = ((sx >> 12) & 0xf) + 1; |
| 165 | | ynum = ((sy >> 12) & 0xf) + 1; |
| 166 | | |
| 167 | | xzoom = 16 * 8 - (8 * ((attr >> 12) & 0xf)) / 2; |
| 168 | | yzoom = 16 * 8 - (8 * ((attr >> 8) & 0xf)) / 2; |
| 169 | | |
| 170 | | switch ((attr >> 6) & 3) |
| 171 | | { |
| 172 | | case 3: pri_mask = 0xf0 | 0xcc | 0xaa; break; // behind all layers |
| 173 | | case 2: pri_mask = 0xf0 | 0xcc; break; // behind fg + middle layer |
| 174 | | case 1: pri_mask = 0xf0; break; // behind fg layer |
| 175 | | case 0: |
| 176 | | default: pri_mask = 0; // above all |
| 177 | | } |
| 178 | | |
| 179 | | sx = (sx & 0x1ff) - (sx & 0x200); |
| 180 | | sy = (sy & 0x1ff) - (sy & 0x200); |
| 181 | | |
| 182 | | if (flip_screen()) |
| 183 | | { |
| 184 | | flipx = !flipx; sx = max_x - sx - xnum * 16; |
| 185 | | flipy = !flipy; sy = max_y - sy - ynum * 16; |
| 186 | | } |
| 187 | | |
| 188 | | if (flipx) { xstart = xnum-1; xend = -1; xinc = -1; } |
| 189 | | else { xstart = 0; xend = xnum; xinc = +1; } |
| 190 | | |
| 191 | | if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } |
| 192 | | else { ystart = 0; yend = ynum; yinc = +1; } |
| 193 | | |
| 194 | | for (y = ystart; y != yend; y += yinc) |
| 195 | | { |
| 196 | | for (x = xstart; x != xend; x += xinc) |
| 197 | | { |
| 198 | | if (xzoom == (16*8) && yzoom == (16*8)) |
| 199 | | gfx->prio_transpen(bitmap,cliprect, |
| 200 | | code++, |
| 201 | | attr & 0x3f, |
| 202 | | flipx, flipy, |
| 203 | | sx + x * 16, sy + y * 16, |
| 204 | | priority_bitmap, |
| 205 | | pri_mask,15 ); |
| 206 | | else |
| 207 | | gfx->prio_zoom_transpen(bitmap,cliprect, |
| 208 | | code++, |
| 209 | | attr & 0x3f, |
| 210 | | flipx, flipy, |
| 211 | | sx + (x * xzoom) / 8, sy + (y * yzoom) / 8, |
| 212 | | (0x10000/0x10/8) * (xzoom + 8),(0x10000/0x10/8) * (yzoom + 8), priority_bitmap,// nearest greater integer value to avoid holes |
| 213 | | pri_mask,15 ); |
| 214 | | } |
| 215 | | } |
| 216 | | |
| 217 | | #ifdef MAME_DEBUG |
| 218 | | #if 0 |
| 219 | | if (machine().input().code_pressed(KEYCODE_X)) |
| 220 | | { /* Display some info on each sprite */ |
| 221 | | char buf[40]; |
| 222 | | sprintf(buf, "%Xx%X %X",xnum,ynum,(attr>>6)&3); |
| 223 | | ui_draw_text(buf, sx, sy); |
| 224 | | } |
| 225 | | #endif |
| 226 | | #endif |
| 227 | | } |
| 228 | | } |
| 229 | | |
| 230 | | |
| 231 | 110 | /*************************************************************************** |
| 232 | 111 | |
| 233 | 112 | |
| r32554 | r32555 | |
| 339 | 218 | fuuki16_draw_layer(screen, bitmap, cliprect, tm_middle, 0, 2); |
| 340 | 219 | fuuki16_draw_layer(screen, bitmap, cliprect, tm_front, 0, 4); |
| 341 | 220 | |
| 342 | | draw_sprites(screen, bitmap, cliprect); |
| 221 | m_fuukivid->draw_sprites(screen, bitmap, cliprect, flip_screen(), 0); |
| 343 | 222 | |
| 344 | 223 | return 0; |
| 345 | 224 | } |
trunk/src/mame/video/fuukifg3.c
| r32554 | r32555 | |
| 90 | 90 | |
| 91 | 91 | void fuuki32_state::video_start() |
| 92 | 92 | { |
| 93 | | m_buf_spriteram = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); |
| 94 | | m_buf_spriteram2 = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); |
| 93 | // m_buf_spriteram = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); |
| 94 | // m_buf_spriteram2 = auto_alloc_array(machine(), UINT32, m_spriteram.bytes() / 4); |
| 95 | 95 | |
| 96 | | save_pointer(NAME(m_buf_spriteram), m_spriteram.bytes() / 4); |
| 97 | | save_pointer(NAME(m_buf_spriteram2), m_spriteram.bytes() / 4); |
| 98 | 96 | |
| 97 | |
| 99 | 98 | m_tilemap[0] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(fuuki32_state::get_tile_info_0),this), TILEMAP_SCAN_ROWS, 16, 16, 64, 32); |
| 100 | 99 | m_tilemap[1] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(fuuki32_state::get_tile_info_1),this), TILEMAP_SCAN_ROWS, 16, 16, 64, 32); |
| 101 | 100 | m_tilemap[2] = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(fuuki32_state::get_tile_info_2),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); |
| r32554 | r32555 | |
| 111 | 110 | } |
| 112 | 111 | |
| 113 | 112 | |
| 114 | | /*************************************************************************** |
| 115 | 113 | |
| 116 | | |
| 117 | | Sprites Drawing |
| 118 | | |
| 119 | | Offset: Bits: Value: |
| 120 | | |
| 121 | | 0.w fedc ---- ---- ---- Number Of Tiles Along X - 1 |
| 122 | | ---- b--- ---- ---- Flip X |
| 123 | | ---- -a-- ---- ---- 1 = Don't Draw This Sprite |
| 124 | | ---- --98 7654 3210 X (Signed) |
| 125 | | |
| 126 | | 2.w fedc ---- ---- ---- Number Of Tiles Along Y - 1 |
| 127 | | ---- b--- ---- ---- Flip Y |
| 128 | | ---- -a-- ---- ---- |
| 129 | | ---- --98 7654 3210 Y (Signed) |
| 130 | | |
| 131 | | 4.w fedc ---- ---- ---- Zoom X ($0 = Full Size, $F = Half Size) |
| 132 | | ---- ba98 ---- ---- Zoom Y "" |
| 133 | | ---- ---- 76-- ---- Priority |
| 134 | | ---- ---- --54 3210 Color |
| 135 | | |
| 136 | | 6.w fe-- ---- ---- ---- Tile Bank |
| 137 | | --dc ba98 7654 3210 Tile Code |
| 138 | | |
| 139 | | |
| 140 | | ***************************************************************************/ |
| 141 | | |
| 142 | | void fuuki32_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) |
| 143 | | { |
| 144 | | int offs; |
| 145 | | gfx_element *gfx = m_gfxdecode->gfx(0); |
| 146 | | bitmap_ind8 &priority_bitmap = screen.priority(); |
| 147 | | const rectangle &visarea = screen.visible_area(); |
| 148 | | int max_x = visarea.max_x + 1; |
| 149 | | int max_y = visarea.max_y + 1; |
| 150 | | |
| 151 | | UINT32 *src = m_buf_spriteram2; /* Use spriteram buffered by 2 frames, need palette buffered by one frame? */ |
| 152 | | |
| 153 | | /* Draw them backwards, for pdrawgfx */ |
| 154 | | for (offs = (m_spriteram.bytes() - 8) / 4; offs >= 0; offs -= 8/4) |
| 155 | | { |
| 156 | | int x, y, xstart, ystart, xend, yend, xinc, yinc; |
| 157 | | int xnum, ynum, xzoom, yzoom, flipx, flipy; |
| 158 | | int pri_mask; |
| 159 | | |
| 160 | | int sx = (src[offs + 0]& 0xffff0000) >> 16; |
| 161 | | int sy = (src[offs + 0]& 0x0000ffff); |
| 162 | | int attr = (src[offs + 1]& 0xffff0000) >> 16; |
| 163 | | int code = (src[offs + 1]& 0x0000ffff); |
| 164 | | |
| 165 | | int bank = (code & 0xc000) >> 14; |
| 166 | | int bank_lookedup; |
| 167 | | |
| 168 | | bank_lookedup = ((m_spr_buffered_tilebank[1] & 0xffff0000) >> (16 + bank * 4)) & 0xf; |
| 169 | | code &= 0x3fff; |
| 170 | | code += bank_lookedup * 0x4000; |
| 171 | | |
| 172 | | if (sx & 0x400) |
| 173 | | continue; |
| 174 | | |
| 175 | | flipx = sx & 0x0800; |
| 176 | | flipy = sy & 0x0800; |
| 177 | | |
| 178 | | xnum = ((sx >> 12) & 0xf) + 1; |
| 179 | | ynum = ((sy >> 12) & 0xf) + 1; |
| 180 | | |
| 181 | | xzoom = 16 * 8 - (8 * ((attr >> 12) & 0xf)) / 2; |
| 182 | | yzoom = 16 * 8 - (8 * ((attr >> 8) & 0xf)) / 2; |
| 183 | | |
| 184 | | switch( (attr >> 6) & 3 ) |
| 185 | | { |
| 186 | | case 3: pri_mask = 0xf0 | 0xcc | 0xaa; break; // behind all layers |
| 187 | | case 2: pri_mask = 0xf0 | 0xcc; break; // behind fg + middle layer |
| 188 | | case 1: pri_mask = 0xf0; break; // behind fg layer |
| 189 | | case 0: |
| 190 | | default: pri_mask = 0; // above all |
| 191 | | } |
| 192 | | |
| 193 | | sx = (sx & 0x1ff) - (sx & 0x200); |
| 194 | | sy = (sy & 0x1ff) - (sy & 0x200); |
| 195 | | |
| 196 | | if (flip_screen()) |
| 197 | | { |
| 198 | | flipx = !flipx; sx = max_x - sx - xnum * 16; |
| 199 | | flipy = !flipy; sy = max_y - sy - ynum * 16; |
| 200 | | } |
| 201 | | |
| 202 | | if (flipx) { xstart = xnum-1; xend = -1; xinc = -1; } |
| 203 | | else { xstart = 0; xend = xnum; xinc = +1; } |
| 204 | | |
| 205 | | if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } |
| 206 | | else { ystart = 0; yend = ynum; yinc = +1; } |
| 207 | | |
| 208 | | #if 0 |
| 209 | | if(!( (screen.machine().input().code_pressed(KEYCODE_V) && (((attr >> 6)&3) == 0)) |
| 210 | | || (screen.machine().input().code_pressed(KEYCODE_B) && (((attr >> 6)&3) == 1)) |
| 211 | | || (screen.machine().input().code_pressed(KEYCODE_N) && (((attr >> 6)&3) == 2)) |
| 212 | | || (screen.machine().input().code_pressed(KEYCODE_M) && (((attr >> 6)&3) == 3)) |
| 213 | | )) |
| 214 | | #endif |
| 215 | | |
| 216 | | for (y = ystart; y != yend; y += yinc) |
| 217 | | { |
| 218 | | for (x = xstart; x != xend; x += xinc) |
| 219 | | { |
| 220 | | if (xzoom == (16*8) && yzoom == (16*8)) |
| 221 | | gfx->prio_transpen(bitmap,cliprect, |
| 222 | | code++, |
| 223 | | attr & 0x3f, |
| 224 | | flipx, flipy, |
| 225 | | sx + x * 16, sy + y * 16, |
| 226 | | priority_bitmap, |
| 227 | | pri_mask,15 ); |
| 228 | | else |
| 229 | | gfx->prio_zoom_transpen(bitmap,cliprect, |
| 230 | | code++, |
| 231 | | attr & 0x3f, |
| 232 | | flipx, flipy, |
| 233 | | sx + (x * xzoom) / 8, sy + (y * yzoom) / 8, |
| 234 | | (0x10000/0x10/8) * (xzoom + 8),(0x10000/0x10/8) * (yzoom + 8), priority_bitmap,// nearest greater integer value to avoid holes |
| 235 | | pri_mask,15 ); |
| 236 | | } |
| 237 | | } |
| 238 | | |
| 239 | | #ifdef MAME_DEBUG |
| 240 | | #if 0 |
| 241 | | if (screen.machine().input().code_pressed(KEYCODE_X)) |
| 242 | | { /* Display some info on each sprite */ |
| 243 | | char buf[40]; |
| 244 | | sprintf(buf, "%Xx%X %X",xnum,ynum,(attr>>6)&3); |
| 245 | | ui_draw_text(buf, sx, sy); |
| 246 | | } |
| 247 | | #endif |
| 248 | | #endif |
| 249 | | } |
| 250 | | } |
| 251 | | |
| 252 | | |
| 253 | 114 | /*************************************************************************** |
| 254 | 115 | |
| 255 | 116 | |
| r32554 | r32555 | |
| 356 | 217 | fuuki32_draw_layer(screen, bitmap, cliprect, tm_middle, 0, 2); |
| 357 | 218 | fuuki32_draw_layer(screen, bitmap, cliprect, tm_front, 0, 4); |
| 358 | 219 | |
| 359 | | draw_sprites(screen, bitmap, cliprect); |
| 220 | m_fuukivid->draw_sprites(screen, bitmap, cliprect, flip_screen(), m_spr_buffered_tilebank); |
| 360 | 221 | return 0; |
| 361 | 222 | } |
| 362 | 223 | |
| r32554 | r32555 | |
| 368 | 229 | /* Buffer sprites and tilebank by 2 frames */ |
| 369 | 230 | m_spr_buffered_tilebank[1] = m_spr_buffered_tilebank[0]; |
| 370 | 231 | m_spr_buffered_tilebank[0] = m_tilebank[0]; |
| 371 | | memcpy(m_buf_spriteram2, m_buf_spriteram, m_spriteram.bytes()); |
| 372 | | memcpy(m_buf_spriteram, m_spriteram, m_spriteram.bytes()); |
| 232 | m_fuukivid->buffer_sprites(); |
| 373 | 233 | } |
| 374 | 234 | } |
trunk/src/mame/video/fuukifg.c
| r0 | r32555 | |
| 1 | /* |
| 2 | */ |
| 3 | |
| 4 | #include "emu.h" |
| 5 | #include "fuukifg.h" |
| 6 | |
| 7 | const device_type FUUKI_VIDEO = &device_creator<fuukivid_device>; |
| 8 | |
| 9 | fuukivid_device::fuukivid_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 10 | : device_t(mconfig, FUUKI_VIDEO, "Fuuki Video", tag, owner, clock, "fuukivid", __FILE__), |
| 11 | device_video_interface(mconfig, *this), |
| 12 | m_gfxdecode(*this) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | void fuukivid_device::static_set_gfxdecode_tag(device_t &device, const char *tag) |
| 17 | { |
| 18 | downcast<fuukivid_device &>(device).m_gfxdecode.set_tag(tag); |
| 19 | } |
| 20 | |
| 21 | |
| 22 | void fuukivid_device::device_start() |
| 23 | { |
| 24 | m_sprram = auto_alloc_array_clear(machine(), UINT16, 0x2000 / 2); |
| 25 | |
| 26 | // fuukifg3 clearly has buffered ram, it is unclear if fuukifg2 has |
| 27 | // it is likely these render to a framebuffer as the tile bank (which is probably external hw) also needs to be banked |
| 28 | // suggesting that the sprites are rendered earlier, then displayed from a buffer |
| 29 | |
| 30 | m_sprram_old = auto_alloc_array_clear(machine(), UINT16, 0x2000 / 2); |
| 31 | m_sprram_old2 = auto_alloc_array_clear(machine(), UINT16, 0x2000 / 2); |
| 32 | |
| 33 | save_pointer(NAME(m_sprram), 0x2000 / 2); |
| 34 | save_pointer(NAME(m_sprram_old), 0x2000 / 2); |
| 35 | save_pointer(NAME(m_sprram_old2), 0x2000 / 2); |
| 36 | |
| 37 | } |
| 38 | |
| 39 | void fuukivid_device::device_reset() |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | |
| 44 | /*************************************************************************** |
| 45 | |
| 46 | |
| 47 | Sprites Drawing |
| 48 | |
| 49 | Offset: Bits: Value: |
| 50 | |
| 51 | 0.w fedc ---- ---- ---- Number Of Tiles Along X - 1 |
| 52 | ---- b--- ---- ---- Flip X |
| 53 | ---- -a-- ---- ---- 1 = Don't Draw This Sprite |
| 54 | ---- --98 7654 3210 X (Signed) |
| 55 | |
| 56 | 2.w fedc ---- ---- ---- Number Of Tiles Along Y - 1 |
| 57 | ---- b--- ---- ---- Flip Y |
| 58 | ---- -a-- ---- ---- |
| 59 | ---- --98 7654 3210 Y (Signed) |
| 60 | |
| 61 | 4.w fedc ---- ---- ---- Zoom X ($0 = Full Size, $F = Half Size) |
| 62 | ---- ba98 ---- ---- Zoom Y "" |
| 63 | ---- ---- 76-- ---- Priority |
| 64 | ---- ---- --54 3210 Color |
| 65 | |
| 66 | 6.w Tile Code |
| 67 | |
| 68 | for FG3 hardware |
| 69 | |
| 70 | 6.w fe-- ---- ---- ---- Tile Bank |
| 71 | --dc ba98 7654 3210 Tile Code |
| 72 | |
| 73 | ***************************************************************************/ |
| 74 | |
| 75 | void fuukivid_device::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flip_screen , UINT32* tilebank) |
| 76 | { |
| 77 | // as we're likely framebuffered (sprites are delayed by 2-3 frames, at least on FG3, and doing rasters on sprites causes glitches) we |
| 78 | // only draw the sprites when MAME wants to draw the final screen line. Ideally we should framebuffer them instead. |
| 79 | if (cliprect.max_y != m_screen->visible_area().max_y) |
| 80 | return; |
| 81 | |
| 82 | rectangle spriteclip = m_screen->visible_area(); |
| 83 | |
| 84 | int offs; |
| 85 | gfx_element *gfx = m_gfxdecode->gfx(0); |
| 86 | bitmap_ind8 &priority_bitmap = screen.priority(); |
| 87 | const rectangle &visarea = screen.visible_area(); |
| 88 | |
| 89 | UINT16 *spriteram16 = m_sprram; |
| 90 | |
| 91 | if (tilebank) spriteram16 = m_sprram_old2; // so that FG3 uses the buffered RAM |
| 92 | |
| 93 | int max_x = visarea.max_x + 1; |
| 94 | int max_y = visarea.max_y + 1; |
| 95 | |
| 96 | /* Draw them backwards, for pdrawgfx */ |
| 97 | for ( offs = (0x2000 - 8) / 2; offs >=0; offs -= 8 / 2 ) |
| 98 | { |
| 99 | int x, y, xstart, ystart, xend, yend, xinc, yinc; |
| 100 | int xnum, ynum, xzoom, yzoom, flipx, flipy; |
| 101 | int pri_mask; |
| 102 | |
| 103 | int sx = spriteram16[offs + 0]; |
| 104 | int sy = spriteram16[offs + 1]; |
| 105 | int attr = spriteram16[offs + 2]; |
| 106 | int code = spriteram16[offs + 3]; |
| 107 | |
| 108 | if (tilebank) |
| 109 | { |
| 110 | int bank = (code & 0xc000) >> 14; |
| 111 | int bank_lookedup; |
| 112 | |
| 113 | bank_lookedup = ((tilebank[1] & 0xffff0000) >> (16 + bank * 4)) & 0xf; |
| 114 | code &= 0x3fff; |
| 115 | code += bank_lookedup * 0x4000; |
| 116 | } |
| 117 | |
| 118 | if (sx & 0x400) |
| 119 | continue; |
| 120 | |
| 121 | flipx = sx & 0x0800; |
| 122 | flipy = sy & 0x0800; |
| 123 | |
| 124 | xnum = ((sx >> 12) & 0xf) + 1; |
| 125 | ynum = ((sy >> 12) & 0xf) + 1; |
| 126 | |
| 127 | xzoom = 16 * 8 - (8 * ((attr >> 12) & 0xf)) / 2; |
| 128 | yzoom = 16 * 8 - (8 * ((attr >> 8) & 0xf)) / 2; |
| 129 | |
| 130 | switch ((attr >> 6) & 3) |
| 131 | { |
| 132 | case 3: pri_mask = 0xf0 | 0xcc | 0xaa; break; // behind all layers |
| 133 | case 2: pri_mask = 0xf0 | 0xcc; break; // behind fg + middle layer |
| 134 | case 1: pri_mask = 0xf0; break; // behind fg layer |
| 135 | case 0: |
| 136 | default: pri_mask = 0; // above all |
| 137 | } |
| 138 | |
| 139 | sx = (sx & 0x1ff) - (sx & 0x200); |
| 140 | sy = (sy & 0x1ff) - (sy & 0x200); |
| 141 | |
| 142 | if (flip_screen) |
| 143 | { |
| 144 | flipx = !flipx; sx = max_x - sx - xnum * 16; |
| 145 | flipy = !flipy; sy = max_y - sy - ynum * 16; |
| 146 | } |
| 147 | |
| 148 | if (flipx) { xstart = xnum-1; xend = -1; xinc = -1; } |
| 149 | else { xstart = 0; xend = xnum; xinc = +1; } |
| 150 | |
| 151 | if (flipy) { ystart = ynum-1; yend = -1; yinc = -1; } |
| 152 | else { ystart = 0; yend = ynum; yinc = +1; } |
| 153 | |
| 154 | for (y = ystart; y != yend; y += yinc) |
| 155 | { |
| 156 | for (x = xstart; x != xend; x += xinc) |
| 157 | { |
| 158 | if (xzoom == (16*8) && yzoom == (16*8)) |
| 159 | gfx->prio_transpen(bitmap,spriteclip, |
| 160 | code++, |
| 161 | attr & 0x3f, |
| 162 | flipx, flipy, |
| 163 | sx + x * 16, sy + y * 16, |
| 164 | priority_bitmap, |
| 165 | pri_mask,15 ); |
| 166 | else |
| 167 | gfx->prio_zoom_transpen(bitmap,spriteclip, |
| 168 | code++, |
| 169 | attr & 0x3f, |
| 170 | flipx, flipy, |
| 171 | sx + (x * xzoom) / 8, sy + (y * yzoom) / 8, |
| 172 | (0x10000/0x10/8) * (xzoom + 8),(0x10000/0x10/8) * (yzoom + 8), priority_bitmap,// nearest greater integer value to avoid holes |
| 173 | pri_mask,15 ); |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | void fuukivid_device::buffer_sprites(void) |
| 180 | { |
| 181 | memcpy(m_sprram_old2, m_sprram_old, 0x2000); |
| 182 | memcpy(m_sprram_old, m_sprram, 0x2000); |
| 183 | } |
| | No newline at end of file |
trunk/src/mame/drivers/fuukifg3.c
| r32554 | r32555 | |
| 215 | 215 | AM_RANGE(0x504000, 0x505fff) AM_RAM_WRITE(fuuki32_vram_2_w) AM_SHARE("vram.2") // Tilemap bg |
| 216 | 216 | AM_RANGE(0x506000, 0x507fff) AM_RAM_WRITE(fuuki32_vram_3_w) AM_SHARE("vram.3") // Tilemap bg2 |
| 217 | 217 | AM_RANGE(0x508000, 0x517fff) AM_RAM // More tilemap, or linescroll? Seems to be empty all of the time |
| 218 | | AM_RANGE(0x600000, 0x601fff) AM_RAM AM_SHARE("spriteram") // Sprites |
| 218 | AM_RANGE(0x600000, 0x601fff) AM_RAM AM_DEVREADWRITE16("fuukivid", fuukivid_device, fuuki_sprram_r, fuuki_sprram_w, 0xffffffff) // Sprites |
| 219 | 219 | AM_RANGE(0x700000, 0x703fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // Palette |
| 220 | 220 | |
| 221 | 221 | AM_RANGE(0x800000, 0x800003) AM_READ_PORT("800000") AM_WRITENOP // Coin |
| r32554 | r32555 | |
| 545 | 545 | m_soundcpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE); |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | | static MACHINE_CONFIG_START( fuuki32, fuuki32_state ) |
| 548 | static MACHINE_CONFIG_START(fuuki32, fuuki32_state) |
| 549 | 549 | |
| 550 | 550 | /* basic machine hardware */ |
| 551 | 551 | MCFG_CPU_ADD("maincpu", M68EC020, CPU_CLOCK) /* 20MHz verified */ |
| r32554 | r32555 | |
| 555 | 555 | MCFG_CPU_PROGRAM_MAP(fuuki32_sound_map) |
| 556 | 556 | MCFG_CPU_IO_MAP(fuuki32_sound_io_map) |
| 557 | 557 | |
| 558 | | |
| 559 | 558 | /* video hardware */ |
| 560 | 559 | MCFG_SCREEN_ADD("screen", RASTER) |
| 561 | 560 | MCFG_SCREEN_REFRESH_RATE(60) |
| 562 | | MCFG_SCREEN_SIZE(64*8, 32*8) |
| 563 | | MCFG_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 30*8-1) |
| 561 | MCFG_SCREEN_SIZE(64 * 8, 32 * 8) |
| 562 | MCFG_SCREEN_VISIBLE_AREA(0, 40 * 8 - 1, 0, 30 * 8 - 1) |
| 564 | 563 | MCFG_SCREEN_UPDATE_DRIVER(fuuki32_state, screen_update_fuuki32) |
| 565 | 564 | MCFG_SCREEN_VBLANK_DRIVER(fuuki32_state, screen_eof_fuuki32) |
| 566 | 565 | MCFG_SCREEN_PALETTE("palette") |
| 567 | 566 | |
| 568 | 567 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", fuuki32) |
| 569 | | MCFG_PALETTE_ADD("palette", 0x4000/2) |
| 568 | MCFG_PALETTE_ADD("palette", 0x4000 / 2) |
| 570 | 569 | MCFG_PALETTE_FORMAT(xRRRRRGGGGGBBBBB) |
| 571 | 570 | |
| 571 | MCFG_DEVICE_ADD("fuukivid", FUUKI_VIDEO, 0) |
| 572 | MCFG_FUUKI_VIDEO_GFXDECODE("gfxdecode") |
| 573 | |
| 572 | 574 | /* sound hardware */ |
| 573 | 575 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 574 | 576 | |