trunk/src/mame/video/galastrm.c
| r249081 | r249082 | |
| 1 | 1 | // license:??? |
| 2 | 2 | // copyright-holders:Hau |
| 3 | 3 | #include "emu.h" |
| 4 | | #include "video/polylgcy.h" |
| 5 | 4 | #include "includes/galastrm.h" |
| 6 | 5 | |
| 7 | 6 | #define X_OFFSET 96 |
| 8 | 7 | #define Y_OFFSET 60 |
| 9 | 8 | |
| 10 | | struct gs_poly_extra_data |
| 9 | struct polyVert |
| 11 | 10 | { |
| 12 | | bitmap_ind16 *texbase; |
| 13 | | }; |
| 14 | | |
| 15 | | struct polygon |
| 16 | | { |
| 17 | 11 | float x; |
| 18 | 12 | float y; |
| 19 | 13 | float z; |
| 20 | 14 | }; |
| 21 | 15 | |
| 22 | | /******************************************************************/ |
| 23 | 16 | |
| 24 | | void galastrm_state::galastrm_exit() |
| 17 | galastrm_renderer::galastrm_renderer(galastrm_state& state) |
| 18 | : poly_manager<float, gs_poly_data, 2, 10000>(state.machine()) |
| 19 | , m_state(state) |
| 20 | , m_screenbits(state.m_screen->width(), state.m_screen->height()) |
| 25 | 21 | { |
| 26 | | poly_free(m_poly); |
| 22 | |
| 27 | 23 | } |
| 28 | 24 | |
| 25 | |
| 26 | /******************************************************************/ |
| 27 | |
| 29 | 28 | void galastrm_state::video_start() |
| 30 | 29 | { |
| 31 | 30 | m_spritelist = auto_alloc_array(machine(), struct gs_tempsprite, 0x4000); |
| 32 | 31 | |
| 33 | | m_screen->register_screen_bitmap(m_tmpbitmaps); |
| 34 | | m_screen->register_screen_bitmap(m_polybitmap); |
| 32 | m_poly = auto_alloc(machine(), galastrm_renderer(*this)); |
| 35 | 33 | |
| 36 | | m_poly = poly_alloc(machine(), 16, sizeof(gs_poly_extra_data), POLYFLAG_ALLOW_QUADS); |
| 37 | | machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(galastrm_state::galastrm_exit), this)); |
| 34 | m_screen->register_screen_bitmap(m_tmpbitmaps); |
| 35 | m_screen->register_screen_bitmap(m_poly->screenbits()); |
| 38 | 36 | } |
| 39 | 37 | |
| 38 | |
| 40 | 39 | /************************************************************ |
| 41 | 40 | SPRITE DRAW ROUTINES |
| 42 | 41 | |
| r249081 | r249082 | |
| 185 | 184 | m_sprite_ptr_pre++; |
| 186 | 185 | } |
| 187 | 186 | if (bad_chunks) |
| 188 | | logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); |
| 187 | logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks); |
| 189 | 188 | } |
| 190 | 189 | } |
| 191 | 190 | |
| r249081 | r249082 | |
| 215 | 214 | POLYGON RENDERER |
| 216 | 215 | **************************************************************/ |
| 217 | 216 | |
| 218 | | static void tc0610_draw_scanline(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid) |
| 217 | void galastrm_renderer::tc0610_draw_scanline(INT32 scanline, const extent_t& extent, const gs_poly_data& object, int threadid) |
| 219 | 218 | { |
| 220 | | const gs_poly_extra_data *extra = (const gs_poly_extra_data *)extradata; |
| 221 | | bitmap_ind16 *destmap = (bitmap_ind16 *)dest; |
| 222 | | UINT16 *framebuffer = &destmap->pix16(scanline); |
| 223 | | bitmap_ind16 *texbase = extra->texbase; |
| 224 | | int startx = extent->startx; |
| 225 | | int stopx = extent->stopx; |
| 226 | | INT32 u = extent->param[0].start; |
| 227 | | INT32 v = extent->param[1].start; |
| 228 | | INT32 dudx = extent->param[0].dpdx; |
| 229 | | INT32 dvdx = extent->param[1].dpdx; |
| 230 | | int x; |
| 219 | UINT16 *framebuffer = &m_screenbits.pix16(scanline); |
| 220 | const INT32 dudx = extent.param[0].dpdx; |
| 221 | const INT32 dvdx = extent.param[1].dpdx; |
| 231 | 222 | |
| 232 | | for (x = startx; x < stopx; x++) |
| 223 | INT32 u = extent.param[0].start; |
| 224 | INT32 v = extent.param[1].start; |
| 225 | for (int x = extent.startx; x < extent.stopx; x++) |
| 233 | 226 | { |
| 234 | | framebuffer[x] = texbase->pix16(v >> 16, u >> 16); |
| 227 | framebuffer[x] = object.texbase->pix16(v >> 16, u >> 16); |
| 235 | 228 | u += dudx; |
| 236 | 229 | v += dvdx; |
| 237 | 230 | } |
| 238 | 231 | } |
| 239 | 232 | |
| 240 | | void galastrm_state::tc0610_rotate_draw(bitmap_ind16 &bitmap, bitmap_ind16 &srcbitmap, const rectangle &clip) |
| 233 | void galastrm_renderer::tc0610_rotate_draw(bitmap_ind16 &srcbitmap, const rectangle &clip) |
| 241 | 234 | { |
| 242 | | gs_poly_extra_data *extra = (gs_poly_extra_data *)poly_get_extra_data(m_poly); |
| 243 | | poly_draw_scanline_func callback; |
| 244 | | poly_vertex vert[4]; |
| 245 | | int rsx = m_tc0610_ctrl_reg[1][0]; |
| 246 | | int rsy = m_tc0610_ctrl_reg[1][1]; |
| 247 | | const int rzx = m_tc0610_ctrl_reg[1][2]; |
| 248 | | const int rzy = m_tc0610_ctrl_reg[1][3]; |
| 249 | | const int ryx = m_tc0610_ctrl_reg[1][5]; |
| 250 | | const int ryy = m_tc0610_ctrl_reg[1][4]; |
| 235 | vertex_t vert[4]; |
| 236 | int rsx = m_state.m_tc0610_ctrl_reg[1][0]; |
| 237 | int rsy = m_state.m_tc0610_ctrl_reg[1][1]; |
| 238 | const int rzx = m_state.m_tc0610_ctrl_reg[1][2]; |
| 239 | const int rzy = m_state.m_tc0610_ctrl_reg[1][3]; |
| 240 | const int ryx = m_state.m_tc0610_ctrl_reg[1][5]; |
| 241 | const int ryy = m_state.m_tc0610_ctrl_reg[1][4]; |
| 251 | 242 | const int lx = srcbitmap.width(); |
| 252 | 243 | const int ly = srcbitmap.height(); |
| 253 | 244 | |
| 254 | 245 | int yx, /*yy,*/ zx, zy, pxx, pxy, pyx, pyy; |
| 255 | 246 | float /*ssn, scs, ysn, ycs,*/ zsn, zcs; |
| 256 | 247 | |
| 257 | | |
| 258 | 248 | pxx = 0; |
| 259 | 249 | pxy = 0; |
| 260 | 250 | pyx = 0; |
| r249081 | r249082 | |
| 281 | 271 | zcs = ((float)pxx/4096.0f) / (float)(lx / 2); |
| 282 | 272 | |
| 283 | 273 | |
| 284 | | if ((rsx == -240 && rsy == 1072) || !m_tc0610_ctrl_reg[1][7]) |
| 274 | if ((rsx == -240 && rsy == 1072) || !m_state.m_tc0610_ctrl_reg[1][7]) |
| 285 | 275 | { |
| 286 | | m_rsxoffs = 0; |
| 287 | | m_rsyoffs = 0; |
| 276 | m_state.m_rsxoffs = 0; |
| 277 | m_state.m_rsyoffs = 0; |
| 288 | 278 | } |
| 289 | 279 | else |
| 290 | 280 | { |
| 291 | | if (rsx > m_rsxb && m_rsxb < 0 && rsx-m_rsxb > 0x8000) |
| 281 | if (rsx > m_state.m_rsxb && m_state.m_rsxb < 0 && rsx-m_state.m_rsxb > 0x8000) |
| 292 | 282 | { |
| 293 | | if (m_rsxoffs == 0) |
| 294 | | m_rsxoffs = -0x10000; |
| 283 | if (m_state.m_rsxoffs == 0) |
| 284 | m_state.m_rsxoffs = -0x10000; |
| 295 | 285 | else |
| 296 | | m_rsxoffs = 0; |
| 286 | m_state.m_rsxoffs = 0; |
| 297 | 287 | } |
| 298 | | if (rsx < m_rsxb && m_rsxb > 0 && m_rsxb-rsx > 0x8000) |
| 288 | if (rsx < m_state.m_rsxb && m_state.m_rsxb > 0 && m_state.m_rsxb-rsx > 0x8000) |
| 299 | 289 | { |
| 300 | | if (m_rsxoffs == 0) |
| 301 | | m_rsxoffs = 0x10000-1; |
| 290 | if (m_state.m_rsxoffs == 0) |
| 291 | m_state.m_rsxoffs = 0x10000-1; |
| 302 | 292 | else |
| 303 | | m_rsxoffs = 0; |
| 293 | m_state.m_rsxoffs = 0; |
| 304 | 294 | } |
| 305 | | if (rsy > m_rsyb && m_rsyb < 0 && rsy-m_rsyb > 0x8000) |
| 295 | if (rsy > m_state.m_rsyb && m_state.m_rsyb < 0 && rsy-m_state.m_rsyb > 0x8000) |
| 306 | 296 | { |
| 307 | | if (m_rsyoffs == 0) |
| 308 | | m_rsyoffs = -0x10000; |
| 297 | if (m_state.m_rsyoffs == 0) |
| 298 | m_state.m_rsyoffs = -0x10000; |
| 309 | 299 | else |
| 310 | | m_rsyoffs = 0; |
| 300 | m_state.m_rsyoffs = 0; |
| 311 | 301 | } |
| 312 | | if (rsy < m_rsyb && m_rsyb > 0 && m_rsyb-rsy > 0x8000) |
| 302 | if (rsy < m_state.m_rsyb && m_state.m_rsyb > 0 && m_state.m_rsyb-rsy > 0x8000) |
| 313 | 303 | { |
| 314 | | if (m_rsyoffs == 0) |
| 315 | | m_rsyoffs = 0x10000-1; |
| 304 | if (m_state.m_rsyoffs == 0) |
| 305 | m_state.m_rsyoffs = 0x10000-1; |
| 316 | 306 | else |
| 317 | | m_rsyoffs = 0; |
| 307 | m_state.m_rsyoffs = 0; |
| 318 | 308 | } |
| 319 | 309 | } |
| 320 | | m_rsxb = rsx; |
| 321 | | m_rsyb = rsy; |
| 322 | | if (m_rsxoffs) rsx += m_rsxoffs; |
| 323 | | if (m_rsyoffs) rsy += m_rsyoffs; |
| 324 | | if (rsx < -0x14000 || rsx >= 0x14000) m_rsxoffs = 0; |
| 325 | | if (rsy < -0x14000 || rsy >= 0x14000) m_rsyoffs = 0; |
| 310 | m_state.m_rsxb = rsx; |
| 311 | m_state.m_rsyb = rsy; |
| 312 | if (m_state.m_rsxoffs) rsx += m_state.m_rsxoffs; |
| 313 | if (m_state.m_rsyoffs) rsy += m_state.m_rsyoffs; |
| 314 | if (rsx < -0x14000 || rsx >= 0x14000) m_state.m_rsxoffs = 0; |
| 315 | if (rsy < -0x14000 || rsy >= 0x14000) m_state.m_rsyoffs = 0; |
| 326 | 316 | |
| 327 | 317 | |
| 328 | 318 | pxx = 0; |
| r249081 | r249082 | |
| 336 | 326 | //ysn = 0.0; |
| 337 | 327 | //ycs = 0.0; |
| 338 | 328 | |
| 339 | | if (m_tc0610_ctrl_reg[1][7]) |
| 329 | if (m_state.m_tc0610_ctrl_reg[1][7]) |
| 340 | 330 | { |
| 341 | 331 | if (ryx != 0 || ryy != 0) |
| 342 | 332 | { |
| r249081 | r249082 | |
| 382 | 372 | //scs = ((float)pyy/65536.0) / (float)(ly / 2); |
| 383 | 373 | } |
| 384 | 374 | |
| 385 | | |
| 386 | 375 | { |
| 387 | | polygon tmpz[4]; |
| 388 | | |
| 376 | polyVert tmpz[4]; |
| 389 | 377 | tmpz[0].x = ((float)(-zx) * zcs) - ((float)(-zy) * zsn); |
| 390 | 378 | tmpz[0].y = ((float)(-zx) * zsn) + ((float)(-zy) * zcs); |
| 391 | 379 | tmpz[0].z = 0.0; |
| r249081 | r249082 | |
| 399 | 387 | tmpz[3].y = ((float)(zx-1) * zsn) + ((float)(-zy) * zcs); |
| 400 | 388 | tmpz[3].z = 0.0; |
| 401 | 389 | |
| 402 | | |
| 403 | 390 | vert[0].x = tmpz[0].x + (float)(lx / 2); |
| 404 | 391 | vert[0].y = tmpz[0].y + (float)(ly / 2); |
| 405 | 392 | vert[1].x = tmpz[1].x + (float)(lx / 2); |
| r249081 | r249082 | |
| 419 | 406 | vert[3].p[0] = (float)(lx - 1) * 65536.0f; |
| 420 | 407 | vert[3].p[1] = 0.0; |
| 421 | 408 | |
| 422 | | extra->texbase = &srcbitmap; |
| 423 | | callback = tc0610_draw_scanline; |
| 424 | | poly_render_quad(m_poly, &bitmap, clip, callback, 2, &vert[0], &vert[1], &vert[2], &vert[3]); |
| 409 | gs_poly_data& extra = object_data_alloc(); |
| 410 | extra.texbase = &srcbitmap; |
| 411 | |
| 412 | render_polygon<4>(clip, render_delegate(FUNC(galastrm_renderer::tc0610_draw_scanline), this), 2, vert); |
| 413 | wait(); |
| 425 | 414 | } |
| 426 | 415 | |
| 427 | 416 | /************************************************************** |
| r249081 | r249082 | |
| 533 | 522 | { |
| 534 | 523 | pri = &priority_bitmap.pix8(y, x); |
| 535 | 524 | if (!(*pri & 0x02) && m_tmpbitmaps.pix16(y, x)) |
| 536 | | *pri |= 0x04; |
| 525 | *pri |= 0x04; |
| 537 | 526 | } |
| 538 | 527 | } |
| 539 | 528 | } |
| r249081 | r249082 | |
| 541 | 530 | draw_sprites_pre(42-X_OFFSET, -571+Y_OFFSET); |
| 542 | 531 | draw_sprites(screen,m_tmpbitmaps,clip,primasks,1); |
| 543 | 532 | |
| 544 | | copybitmap_trans(bitmap,m_polybitmap,0,0, 0,0,cliprect,0); |
| 545 | | m_polybitmap.fill(0, clip); |
| 546 | | tc0610_rotate_draw(m_polybitmap,m_tmpbitmaps,cliprect); |
| 547 | | |
| 533 | copybitmap_trans(bitmap, m_poly->screenbits(), 0,0, 0,0, cliprect, 0); |
| 534 | m_poly->screenbits().fill(0, clip); |
| 535 | m_poly->tc0610_rotate_draw(m_tmpbitmaps, cliprect); |
| 536 | |
| 548 | 537 | priority_bitmap.fill(0, cliprect); |
| 549 | 538 | draw_sprites(screen,bitmap,cliprect,primasks,0); |
| 550 | 539 | |