trunk/src/mame/video/powervr2.c
| r23710 | r23711 | |
| 1 | 1 | /* |
| 2 | | dc.c - Dreamcast video emulation |
| 3 | | |
| 2 | Dreamcast video emulation |
| 4 | 3 | */ |
| 5 | 4 | |
| 6 | 5 | #include "emu.h" |
| r23710 | r23711 | |
| 13 | 12 | |
| 14 | 13 | const device_type POWERVR2 = &device_creator<powervr2_device>; |
| 15 | 14 | |
| 15 | DEVICE_ADDRESS_MAP_START(ta_map, 32, powervr2_device) |
| 16 | AM_RANGE(0x0000, 0x0003) AM_READ( id_r) |
| 17 | AM_RANGE(0x0004, 0x0007) AM_READ( revision_r) |
| 18 | AM_RANGE(0x0008, 0x000b) AM_READWRITE(softreset_r, softreset_w) |
| 19 | AM_RANGE(0x0014, 0x0017) AM_WRITE( startrender_w) |
| 20 | // 18 = test select |
| 21 | AM_RANGE(0x0020, 0x0023) AM_READWRITE(param_base_r, param_base_w) |
| 22 | AM_RANGE(0x002c, 0x002f) AM_READWRITE(region_base_r, region_base_w) |
| 23 | // 30 = span sort cfg |
| 24 | AM_RANGE(0x0040, 0x0043) AM_READWRITE(vo_border_col_r, vo_border_col_w) |
| 25 | AM_RANGE(0x0044, 0x0047) AM_READWRITE(fb_r_ctrl_r, fb_r_ctrl_w) |
| 26 | AM_RANGE(0x0048, 0x004b) AM_READWRITE(fb_w_ctrl_r, fb_w_ctrl_w) |
| 27 | AM_RANGE(0x004c, 0x004f) AM_READWRITE(fb_w_linestride_r, fb_w_linestride_w) |
| 28 | AM_RANGE(0x0050, 0x0053) AM_READWRITE(fb_r_sof1_r, fb_r_sof1_w) |
| 29 | AM_RANGE(0x0054, 0x0057) AM_READWRITE(fb_r_sof2_r, fb_r_sof2_w) |
| 30 | AM_RANGE(0x005c, 0x005f) AM_READWRITE(fb_r_size_r, fb_r_size_w) |
| 31 | AM_RANGE(0x0060, 0x0063) AM_READWRITE(fb_w_sof1_r, fb_w_sof1_w) |
| 32 | AM_RANGE(0x0064, 0x0067) AM_READWRITE(fb_w_sof2_r, fb_w_sof2_w) |
| 33 | AM_RANGE(0x0068, 0x006b) AM_READWRITE(fb_x_clip_r, fb_x_clip_w) |
| 34 | AM_RANGE(0x006c, 0x006f) AM_READWRITE(fb_y_clip_r, fb_y_clip_w) |
| 35 | // 74 = fpu_shad_scale |
| 36 | // 78 = fpu_cull_val |
| 37 | AM_RANGE(0x007c, 0x007f) AM_READWRITE(fpu_param_cfg_r, fpu_param_cfg_w) |
| 38 | // 80 = half_offset |
| 39 | // 84 = fpu_perp_val |
| 40 | // 88 = isp_backgnd_d |
| 41 | AM_RANGE(0x008c, 0x008f) AM_READWRITE(isp_backgnd_t_r, isp_backgnd_t_w) |
| 42 | // 98 = isp_feed_cfg |
| 43 | // a0 = sdram_refresh |
| 44 | // a4 = sdram_arb_cfg |
| 45 | // a8 = sdram_cfg |
| 46 | // b0 = fog_col_ram |
| 47 | // b4 = fog_col_vert |
| 48 | // b8 = fog_density |
| 49 | // bc = fog_clamp_max |
| 50 | // c0 = fog_clamp_min |
| 51 | // c4 = spg_trigger_pos |
| 52 | AM_RANGE(0x00c8, 0x00cb) AM_READWRITE(spg_hblank_int_r, spg_hblank_int_w) |
| 53 | AM_RANGE(0x00cc, 0x00cf) AM_READWRITE(spg_vblank_int_r, spg_vblank_int_w) |
| 54 | // d0 = spg_control |
| 55 | AM_RANGE(0x00d4, 0x00d7) AM_READWRITE(spg_hblank_r, spg_hblank_w) |
| 56 | AM_RANGE(0x00d8, 0x00db) AM_READWRITE(spg_load_r, spg_load_w) |
| 57 | AM_RANGE(0x00dc, 0x00df) AM_READWRITE(spg_vblank_r, spg_vblank_w) |
| 58 | AM_RANGE(0x00e0, 0x00e3) AM_READWRITE(spg_width_r, spg_width_w) |
| 59 | AM_RANGE(0x00e4, 0x00e7) AM_READWRITE(text_control_r, text_control_w) |
| 60 | AM_RANGE(0x00e8, 0x00eb) AM_READWRITE(vo_control_r, vo_control_w) |
| 61 | AM_RANGE(0x00ec, 0x00ef) AM_READWRITE(vo_startx_r, vo_startx_w) |
| 62 | AM_RANGE(0x00f0, 0x00f3) AM_READWRITE(vo_starty_r, vo_starty_w) |
| 63 | // f4 = scaler_ctl |
| 64 | AM_RANGE(0x0108, 0x010b) AM_READWRITE(pal_ram_ctrl_r, pal_ram_ctrl_w) |
| 65 | AM_RANGE(0x010c, 0x010f) AM_READ( spg_status_r) |
| 66 | // 110 = fb_burstctrl |
| 67 | // 118 = y_coeff |
| 68 | // 11c = pt_alpha_ref |
| 69 | |
| 70 | AM_RANGE(0x0124, 0x0127) AM_READWRITE(ta_ol_base_r, ta_ol_base_w) |
| 71 | AM_RANGE(0x0128, 0x012b) AM_READWRITE(ta_isp_base_r, ta_isp_base_w) |
| 72 | AM_RANGE(0x012c, 0x012f) AM_READWRITE(ta_ol_limit_r, ta_ol_limit_w) |
| 73 | AM_RANGE(0x0130, 0x0133) AM_READWRITE(ta_isp_limit_r, ta_isp_limit_w) |
| 74 | AM_RANGE(0x0134, 0x0137) AM_READ( ta_next_opb_r) |
| 75 | AM_RANGE(0x0138, 0x013b) AM_READ( ta_itp_current_r) |
| 76 | // 13c = ta_glob_tile_clip |
| 77 | AM_RANGE(0x0140, 0x0143) AM_READWRITE(ta_alloc_ctrl_r, ta_alloc_ctrl_w) |
| 78 | AM_RANGE(0x0144, 0x0147) AM_READWRITE(ta_list_init_r, ta_list_init_w) |
| 79 | AM_RANGE(0x0148, 0x014b) AM_READWRITE(ta_yuv_tex_base_r, ta_yuv_tex_base_w) |
| 80 | AM_RANGE(0x014c, 0x014f) AM_READWRITE(ta_yuv_tex_ctrl_r, ta_yuv_tex_ctrl_w) |
| 81 | AM_RANGE(0x0150, 0x0153) AM_READWRITE(ta_yuv_tex_cnt_r, ta_yuv_tex_cnt_w) |
| 82 | AM_RANGE(0x0160, 0x0163) AM_WRITE( ta_list_cont_w) |
| 83 | AM_RANGE(0x0164, 0x0167) AM_READWRITE(ta_next_opb_init_r, ta_next_opb_init_w) |
| 84 | |
| 85 | AM_RANGE(0x0200, 0x03ff) AM_READWRITE(fog_table_r, fog_table_w) |
| 86 | AM_RANGE(0x1000, 0x1fff) AM_READWRITE(palette_r, palette_w) |
| 87 | ADDRESS_MAP_END |
| 88 | |
| 16 | 89 | const int powervr2_device::pvr_parconfseq[] = {1,2,3,2,3,4,5,6,5,6,7,8,9,10,11,12,13,14,13,14,15,16,17,16,17,0,0,0,0,0,18,19,20,19,20,21,22,23,22,23}; |
| 17 | 90 | const int powervr2_device::pvr_wordsvertex[24] = {8,8,8,8,8,16,16,8,8,8, 8, 8,8,8,8,8,16,16, 8,16,16,8,16,16}; |
| 18 | 91 | const int powervr2_device::pvr_wordspolygon[24] = {8,8,8,8,8, 8, 8,8,8,8,16,16,8,8,8,8, 8, 8,16,16,16,8, 8, 8}; |
| 19 | 92 | |
| 20 | 93 | #define DEBUG_FIFO_POLY (0) |
| 21 | | #define DEBUG_PVRTA (0) |
| 22 | | #define DEBUG_PVRTA_REGS (0) |
| 94 | #define DEBUG_PVRTA 0 |
| 23 | 95 | #define DEBUG_PVRDLIST (0) |
| 24 | 96 | #define DEBUG_PALRAM (1) |
| 25 | 97 | #define DEBUG_PVRCTRL (0) |
| 26 | 98 | |
| 27 | | /* PVR TA macro defines */ |
| 28 | | /* |
| 29 | | SPG_HBLANK_INT |
| 30 | | ---- --xx xxxx xxxx ---- ---- ---- ---- hblank_in_interrupt |
| 31 | | ---- ---- ---- ---- --xx ---- ---- ---- hblank_int_mode |
| 32 | | ---- ---- ---- ---- ---- --xx xxxx xxxx line_comp_val |
| 33 | | */ |
| 34 | | #define spg_hblank_in_irq ((pvrta_regs[SPG_HBLANK_INT] & 0x03ff0000) >> 16) |
| 35 | | #define spg_hblank_in_irq_new ((pvrta_regs[SPG_HBLANK_INT] & 0x03ff0000) >> 16) |
| 36 | | #define spg_hblank_int_mode ((pvrta_regs[SPG_HBLANK_INT] & 0x00003000) >> 12) |
| 37 | | #define spg_line_comp_val ((pvrta_regs[SPG_HBLANK_INT] & 0x000003ff) >> 0) |
| 38 | | |
| 39 | | /* |
| 40 | | SPG_VBLANK_INT |
| 41 | | ---- --xx xxxx xxxx ---- ---- ---- ---- vblank_out_interrupt_line_number |
| 42 | | ---- ---- ---- ---- ---- --xx xxxx xxxx vblank_in_interrupt_line_number |
| 43 | | */ |
| 44 | | #define spg_vblank_out_irq_line_num ((pvrta_regs[SPG_VBLANK_INT] & 0x03ff0000) >> 16) |
| 45 | | #define spg_vblank_in_irq_line_num ((pvrta_regs[SPG_VBLANK_INT] & 0x000003ff) >> 0) |
| 46 | | #define spg_vblank_out_irq_line_num_new ((pvrta_regs[SPG_VBLANK_INT] & 0x03ff0000) >> 16) |
| 47 | | #define spg_vblank_in_irq_line_num_new ((pvrta_regs[SPG_VBLANK_INT] & 0x000003ff) >> 0) |
| 48 | | |
| 49 | | |
| 50 | | /* |
| 51 | | VO_BORDER_COL |
| 52 | | ---- ---x ---- ---- ---- ---- ---- ---- Chroma ;suchie3 sets 0xff there, maybe it's 8 bits too? |
| 53 | | ---- ---- xxxx xxxx ---- ---- ---- ---- Red |
| 54 | | ---- ---- ---- ---- xxxx xxxx ---- ---- Green |
| 55 | | ---- ---- ---- ---- ---- ---- xxxx xxxx Blue |
| 56 | | */ |
| 57 | | #define vo_border_K ((pvrta_regs[VO_BORDER_COL] & 0x01000000) >> 24) |
| 58 | | #define vo_border_R ((pvrta_regs[VO_BORDER_COL] & 0x00ff0000) >> 16) |
| 59 | | #define vo_border_G ((pvrta_regs[VO_BORDER_COL] & 0x0000ff00) >> 8) |
| 60 | | #define vo_border_B ((pvrta_regs[VO_BORDER_COL] & 0x000000ff) >> 0) |
| 61 | | |
| 62 | | /* |
| 63 | | SPG_HBLANK |
| 64 | | ---- ---- --xx xxxx xxxx ---- ---- ---- hbend |
| 65 | | ---- ---- ---- ---- ---- --xx xxxx xxxx hbstart |
| 66 | | */ |
| 67 | | #define spg_hbend ((pvrta_regs[SPG_HBLANK] & 0x03ff0000) >> 16) |
| 68 | | #define spg_hbstart ((pvrta_regs[SPG_HBLANK] & 0x000003ff) >> 0) |
| 69 | | |
| 70 | | |
| 71 | | /* |
| 72 | | SPG_LOAD |
| 73 | | ---- ---- --xx xxxx xxxx ---- ---- ---- vcount |
| 74 | | ---- ---- ---- ---- ---- --xx xxxx xxxx hcount |
| 75 | | */ |
| 76 | | #define spg_vcount ((pvrta_regs[SPG_LOAD] & 0x03ff0000) >> 16) |
| 77 | | #define spg_hcount ((pvrta_regs[SPG_LOAD] & 0x000003ff) >> 0) |
| 78 | | |
| 79 | | /* |
| 80 | | SPG_VBLANK |
| 81 | | ---- ---- --xx xxxx xxxx ---- ---- ---- vbend |
| 82 | | ---- ---- ---- ---- ---- --xx xxxx xxxx vbstart |
| 83 | | */ |
| 84 | | #define spg_vbend ((pvrta_regs[SPG_VBLANK] & 0x03ff0000) >> 16) |
| 85 | | #define spg_vbstart ((pvrta_regs[SPG_VBLANK] & 0x000003ff) >> 0) |
| 86 | | |
| 87 | | |
| 88 | | /* |
| 89 | | VO_CONTROL |
| 90 | | ---- ---- --xx xxxx ---- ---- ---- ---- pclk_delay |
| 91 | | ---- ---- ---- ---- ---- ---x ---- ---- pixel_double ;used in test mode |
| 92 | | ---- ---- ---- ---- ---- ---- xxxx ---- field_mode |
| 93 | | ---- ---- ---- ---- ---- ---- ---- x--- blank_video |
| 94 | | ---- ---- ---- ---- ---- ---- ---- -x-- blank_pol |
| 95 | | ---- ---- ---- ---- ---- ---- ---- --x- vsync_pol |
| 96 | | ---- ---- ---- ---- ---- ---- ---- ---x hsync_pol |
| 97 | | */ |
| 98 | | #define spg_pclk_delay ((pvrta_regs[VO_CONTROL] & 0x003f0000) >> 16) |
| 99 | | #define spg_pixel_double ((pvrta_regs[VO_CONTROL] & 0x00000100) >> 8) |
| 100 | | #define spg_field_mode ((pvrta_regs[VO_CONTROL] & 0x000000f0) >> 4) |
| 101 | | #define spg_blank_video ((pvrta_regs[VO_CONTROL] & 0x00000008) >> 3) |
| 102 | | #define spg_blank_pol ((pvrta_regs[VO_CONTROL] & 0x00000004) >> 2) |
| 103 | | #define spg_vsync_pol ((pvrta_regs[VO_CONTROL] & 0x00000002) >> 1) |
| 104 | | #define spg_hsync_pol ((pvrta_regs[VO_CONTROL] & 0x00000001) >> 0) |
| 105 | | |
| 106 | | /* |
| 107 | | VO_STARTX |
| 108 | | ---- ---- ---- ---- ---- ---x xxxx xxxx horzontal start position |
| 109 | | */ |
| 110 | | #define vo_horz_start_pos ((pvrta_regs[VO_STARTX] & 0x000003ff) >> 0) |
| 111 | | |
| 112 | | /* |
| 113 | | VO_STARTY |
| 114 | | ---- ---x xxxx xxxx ---- ---- ---- ---- vertical start position on field 2 |
| 115 | | ---- ---- ---- ---- ---- ---x xxxx xxxx vertical start position on field 1 |
| 116 | | */ |
| 117 | | |
| 118 | | #define vo_vert_start_pos_f2 ((pvrta_regs[VO_STARTY] & 0x03ff0000) >> 16) |
| 119 | | #define vo_vert_start_pos_f1 ((pvrta_regs[VO_STARTY] & 0x000003ff) >> 0) |
| 120 | | |
| 121 | | /* |
| 122 | | SPG_STATUS |
| 123 | | ---- ---- ---- ---- --x- ---- ---- ---- vsync |
| 124 | | ---- ---- ---- ---- ---x ---- ---- ---- hsync |
| 125 | | ---- ---- ---- ---- ---- x--- ---- ---- blank |
| 126 | | ---- ---- ---- ---- ---- -x-- ---- ---- field number |
| 127 | | ---- ---- ---- ---- ---- --xx xxxx xxxx scanline |
| 128 | | */ |
| 129 | | |
| 130 | | |
| 131 | 99 | // Perform a standard bilinear filter across four pixels |
| 132 | 100 | inline INT32 powervr2_device::clamp(INT32 in, INT32 min, INT32 max) |
| 133 | 101 | { |
| r23710 | r23711 | |
| 441 | 409 | int off = dilated1[t->cd][xt] + dilated0[t->cd][yt]; |
| 442 | 410 | int addrp = t->address + (off >> 1); |
| 443 | 411 | int c = ((reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)] >> ((off & 1) << 2)) & 0xf; |
| 444 | | return cv_1555(pvrta_regs[t->palbase + c]); |
| 412 | return cv_1555(palette[t->palbase + c]); |
| 445 | 413 | } |
| 446 | 414 | |
| 447 | 415 | UINT32 powervr2_device::tex_r_p4_1555_vq(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 451 | 419 | int idx = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(t->address + dilated1[t->cd][xt >> 1] + dilated0[t->cd][yt >> 1])]; |
| 452 | 420 | int addrp = t->vqbase + 8*idx + dilated1[t->cd][xt & 1] + dilated0[t->cd][yt & 3]; |
| 453 | 421 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)] & 0xf; |
| 454 | | return cv_1555(pvrta_regs[t->palbase + c]); |
| 422 | return cv_1555(palette[t->palbase + c]); |
| 455 | 423 | } |
| 456 | 424 | |
| 457 | 425 | UINT32 powervr2_device::tex_r_p4_565_tw(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 461 | 429 | int off = dilated1[t->cd][xt] + dilated0[t->cd][yt]; |
| 462 | 430 | int addrp = t->address + (off >> 1); |
| 463 | 431 | int c = ((reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)] >> ((off & 1) << 2)) & 0xf; |
| 464 | | return cv_565(pvrta_regs[t->palbase + c]); |
| 432 | return cv_565(palette[t->palbase + c]); |
| 465 | 433 | } |
| 466 | 434 | |
| 467 | 435 | UINT32 powervr2_device::tex_r_p4_565_vq(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 471 | 439 | int idx = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(t->address + dilated1[t->cd][xt >> 1] + dilated0[t->cd][yt >> 1])]; |
| 472 | 440 | int addrp = t->vqbase + 8*idx + dilated1[t->cd][xt & 1] + dilated0[t->cd][yt & 3]; |
| 473 | 441 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)] & 0xf; |
| 474 | | return cv_565(pvrta_regs[t->palbase + c]); |
| 442 | return cv_565(palette[t->palbase + c]); |
| 475 | 443 | } |
| 476 | 444 | |
| 477 | 445 | UINT32 powervr2_device::tex_r_p4_4444_tw(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 481 | 449 | int off = dilated1[t->cd][xt] + dilated0[t->cd][yt]; |
| 482 | 450 | int addrp = t->address + (off >> 1); |
| 483 | 451 | int c = ((reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)] >> ((off & 1) << 2)) & 0xf; |
| 484 | | return cv_4444(pvrta_regs[t->palbase + c]); |
| 452 | return cv_4444(palette[t->palbase + c]); |
| 485 | 453 | } |
| 486 | 454 | |
| 487 | 455 | UINT32 powervr2_device::tex_r_p4_4444_vq(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 491 | 459 | int idx = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(t->address + dilated1[t->cd][xt >> 1] + dilated0[t->cd][yt >> 1])]; |
| 492 | 460 | int addrp = t->vqbase + 8*idx + dilated1[t->cd][xt & 1] + dilated0[t->cd][yt & 3]; |
| 493 | 461 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)] & 0xf; |
| 494 | | return cv_4444(pvrta_regs[t->palbase + c]); |
| 462 | return cv_4444(palette[t->palbase + c]); |
| 495 | 463 | } |
| 496 | 464 | |
| 497 | 465 | UINT32 powervr2_device::tex_r_p4_8888_tw(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 501 | 469 | int off = dilated1[t->cd][xt] + dilated0[t->cd][yt]; |
| 502 | 470 | int addrp = t->address + (off >> 1); |
| 503 | 471 | int c = ((reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)] >> ((off & 1) << 2)) & 0xf; |
| 504 | | return pvrta_regs[t->palbase + c]; |
| 472 | return palette[t->palbase + c]; |
| 505 | 473 | } |
| 506 | 474 | |
| 507 | 475 | UINT32 powervr2_device::tex_r_p4_8888_vq(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 511 | 479 | int idx = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(t->address + dilated1[t->cd][xt >> 1] + dilated0[t->cd][yt >> 1])]; |
| 512 | 480 | int addrp = t->vqbase + 8*idx + dilated1[t->cd][xt & 1] + dilated0[t->cd][yt & 3]; |
| 513 | 481 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)] & 0xf; |
| 514 | | return pvrta_regs[t->palbase + c]; |
| 482 | return palette[t->palbase + c]; |
| 515 | 483 | } |
| 516 | 484 | |
| 517 | 485 | UINT32 powervr2_device::tex_r_p8_1555_tw(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 520 | 488 | int yt = ((int)y) & (t->sizey-1); |
| 521 | 489 | int addrp = t->address + dilated1[t->cd][xt] + dilated0[t->cd][yt]; |
| 522 | 490 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)]; |
| 523 | | return cv_1555(pvrta_regs[t->palbase + c]); |
| 491 | return cv_1555(palette[t->palbase + c]); |
| 524 | 492 | } |
| 525 | 493 | |
| 526 | 494 | UINT32 powervr2_device::tex_r_p8_1555_vq(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 530 | 498 | int idx = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(t->address + dilated1[t->cd][xt >> 1] + dilated0[t->cd][yt >> 1])]; |
| 531 | 499 | int addrp = t->vqbase + 8*idx + dilated1[t->cd][xt & 1] + dilated0[t->cd][yt & 3]; |
| 532 | 500 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)]; |
| 533 | | return cv_1555(pvrta_regs[t->palbase + c]); |
| 501 | return cv_1555(palette[t->palbase + c]); |
| 534 | 502 | } |
| 535 | 503 | |
| 536 | 504 | UINT32 powervr2_device::tex_r_p8_565_tw(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 539 | 507 | int yt = ((int)y) & (t->sizey-1); |
| 540 | 508 | int addrp = t->address + dilated1[t->cd][xt] + dilated0[t->cd][yt]; |
| 541 | 509 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)]; |
| 542 | | return cv_565(pvrta_regs[t->palbase + c]); |
| 510 | return cv_565(palette[t->palbase + c]); |
| 543 | 511 | } |
| 544 | 512 | |
| 545 | 513 | UINT32 powervr2_device::tex_r_p8_565_vq(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 549 | 517 | int idx = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(t->address + dilated1[t->cd][xt >> 1] + dilated0[t->cd][yt >> 1])]; |
| 550 | 518 | int addrp = t->vqbase + 8*idx + dilated1[t->cd][xt & 1] + dilated0[t->cd][yt & 3]; |
| 551 | 519 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)]; |
| 552 | | return cv_565(pvrta_regs[t->palbase + c]); |
| 520 | return cv_565(palette[t->palbase + c]); |
| 553 | 521 | } |
| 554 | 522 | |
| 555 | 523 | UINT32 powervr2_device::tex_r_p8_4444_tw(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 558 | 526 | int yt = ((int)y) & (t->sizey-1); |
| 559 | 527 | int addrp = t->address + dilated1[t->cd][xt] + dilated0[t->cd][yt]; |
| 560 | 528 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)]; |
| 561 | | return cv_4444(pvrta_regs[t->palbase + c]); |
| 529 | return cv_4444(palette[t->palbase + c]); |
| 562 | 530 | } |
| 563 | 531 | |
| 564 | 532 | UINT32 powervr2_device::tex_r_p8_4444_vq(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 568 | 536 | int idx = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(t->address + dilated1[t->cd][xt >> 1] + dilated0[t->cd][yt >> 1])]; |
| 569 | 537 | int addrp = t->vqbase + 8*idx + dilated1[t->cd][xt & 1] + dilated0[t->cd][yt & 3]; |
| 570 | 538 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)]; |
| 571 | | return cv_4444(pvrta_regs[t->palbase + c]); |
| 539 | return cv_4444(palette[t->palbase + c]); |
| 572 | 540 | } |
| 573 | 541 | |
| 574 | 542 | UINT32 powervr2_device::tex_r_p8_8888_tw(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 577 | 545 | int yt = ((int)y) & (t->sizey-1); |
| 578 | 546 | int addrp = t->address + dilated1[t->cd][xt] + dilated0[t->cd][yt]; |
| 579 | 547 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)]; |
| 580 | | return pvrta_regs[t->palbase + c]; |
| 548 | return palette[t->palbase + c]; |
| 581 | 549 | } |
| 582 | 550 | |
| 583 | 551 | UINT32 powervr2_device::tex_r_p8_8888_vq(texinfo *t, float x, float y) |
| r23710 | r23711 | |
| 587 | 555 | int idx = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(t->address + dilated1[t->cd][xt >> 1] + dilated0[t->cd][yt >> 1])]; |
| 588 | 556 | int addrp = t->vqbase + 8*idx + dilated1[t->cd][xt & 1] + dilated0[t->cd][yt & 3]; |
| 589 | 557 | int c = (reinterpret_cast<UINT8 *>(dc_texture_ram))[BYTE_XOR_LE(addrp)]; |
| 590 | | return pvrta_regs[t->palbase + c]; |
| 558 | return palette[t->palbase + c]; |
| 591 | 559 | } |
| 592 | 560 | |
| 593 | 561 | |
| r23710 | r23711 | |
| 640 | 608 | |
| 641 | 609 | |
| 642 | 610 | /* Stride select is used only in the non-twiddled case */ |
| 643 | | t->stride = (t->mode & 1) && strideselect ? (pvrta_regs[TEXT_CONTROL] & 0x1f) << 5 : t->sizex; |
| 611 | t->stride = (t->mode & 1) && strideselect ? (text_control & 0x1f) << 5 : t->sizex; |
| 644 | 612 | |
| 645 | 613 | t->blend_mode = blend_mode; |
| 646 | 614 | t->filter_mode = filtermode; |
| r23710 | r23711 | |
| 653 | 621 | t->vqbase = t->address; |
| 654 | 622 | t->blend = use_alpha ? blend_functions[t->blend_mode] : bl10; |
| 655 | 623 | |
| 656 | | // fprintf(stderr, "tex %d %d %d %d\n", t->pf, t->mode, pvrta_regs[PAL_RAM_CTRL], t->mipmapped); |
| 624 | // fprintf(stderr, "tex %d %d %d %d\n", t->pf, t->mode, pal_ram_ctrl, t->mipmapped); |
| 657 | 625 | |
| 658 | 626 | switch(t->pf) { |
| 659 | 627 | case 0: // 1555 |
| r23710 | r23711 | |
| 707 | 675 | break; |
| 708 | 676 | |
| 709 | 677 | case 5: // 4bpp palette |
| 710 | | t->palbase = 0x400 | ((t->palette & 0x3f) << 4); |
| 678 | t->palbase = (t->palette & 0x3f) << 4; |
| 711 | 679 | switch(t->mode) { |
| 712 | 680 | case 0: case 1: |
| 713 | 681 | miptype = 0; |
| 714 | 682 | |
| 715 | | switch(pvrta_regs[PAL_RAM_CTRL]) { |
| 683 | switch(pal_ram_ctrl) { |
| 716 | 684 | case 0: t->r = &powervr2_device::tex_r_p4_1555_tw; break; |
| 717 | 685 | case 1: t->r = &powervr2_device::tex_r_p4_565_tw; break; |
| 718 | 686 | case 2: t->r = &powervr2_device::tex_r_p4_4444_tw; break; |
| r23710 | r23711 | |
| 721 | 689 | break; |
| 722 | 690 | case 2: case 3: |
| 723 | 691 | miptype = 3; // ? |
| 724 | | switch(pvrta_regs[PAL_RAM_CTRL]) { |
| 692 | switch(pal_ram_ctrl) { |
| 725 | 693 | case 0: t->r = &powervr2_device::tex_r_p4_1555_vq; t->address += 0x800; break; |
| 726 | 694 | case 1: t->r = &powervr2_device::tex_r_p4_565_vq; t->address += 0x800; break; |
| 727 | 695 | case 2: t->r = &powervr2_device::tex_r_p4_4444_vq; t->address += 0x800; break; |
| r23710 | r23711 | |
| 736 | 704 | break; |
| 737 | 705 | |
| 738 | 706 | case 6: // 8bpp palette |
| 739 | | t->palbase = 0x400 | ((t->palette & 0x30) << 4); |
| 707 | t->palbase = (t->palette & 0x30) << 4; |
| 740 | 708 | switch(t->mode) { |
| 741 | 709 | case 0: case 1: |
| 742 | 710 | miptype = 1; |
| 743 | 711 | |
| 744 | | switch(pvrta_regs[PAL_RAM_CTRL]) { |
| 712 | switch(pal_ram_ctrl) { |
| 745 | 713 | case 0: t->r = &powervr2_device::tex_r_p8_1555_tw; break; |
| 746 | 714 | case 1: t->r = &powervr2_device::tex_r_p8_565_tw; break; |
| 747 | 715 | case 2: t->r = &powervr2_device::tex_r_p8_4444_tw; break; |
| r23710 | r23711 | |
| 750 | 718 | break; |
| 751 | 719 | case 2: case 3: |
| 752 | 720 | miptype = 3; // ? |
| 753 | | switch(pvrta_regs[PAL_RAM_CTRL]) { |
| 721 | switch(pal_ram_ctrl) { |
| 754 | 722 | case 0: t->r = &powervr2_device::tex_r_p8_1555_vq; t->address += 0x800; break; |
| 755 | 723 | case 1: t->r = &powervr2_device::tex_r_p8_565_vq; t->address += 0x800; break; |
| 756 | 724 | case 2: t->r = &powervr2_device::tex_r_p8_4444_vq; t->address += 0x800; break; |
| r23710 | r23711 | |
| 860 | 828 | |
| 861 | 829 | } |
| 862 | 830 | |
| 863 | | READ32_MEMBER( powervr2_device::pvr_ta_r ) |
| 831 | READ32_MEMBER( powervr2_device::id_r ) |
| 864 | 832 | { |
| 865 | | switch (offset) |
| 866 | | { |
| 867 | | case SPG_STATUS: |
| 868 | | { |
| 869 | | UINT8 fieldnum,vsync,hsync,blank; |
| 833 | return 0x17fd11db; |
| 834 | } |
| 870 | 835 | |
| 871 | | fieldnum = (space.machine().primary_screen->frame_number() & 1) ? 1 : 0; |
| 836 | READ32_MEMBER( powervr2_device::revision_r ) |
| 837 | { |
| 838 | return 0x00000011; |
| 839 | } |
| 872 | 840 | |
| 873 | | vsync = space.machine().primary_screen->vblank() ? 1 : 0; |
| 874 | | if(spg_vsync_pol) { vsync^=1; } |
| 841 | READ32_MEMBER( powervr2_device::softreset_r ) |
| 842 | { |
| 843 | return softreset; |
| 844 | } |
| 875 | 845 | |
| 876 | | hsync = space.machine().primary_screen->hblank() ? 1 : 0; |
| 877 | | if(spg_hsync_pol) { hsync^=1; } |
| 846 | WRITE32_MEMBER( powervr2_device::softreset_w ) |
| 847 | { |
| 848 | COMBINE_DATA(&softreset); |
| 849 | if (softreset & 1) { |
| 850 | #if DEBUG_PVRTA |
| 851 | logerror("%s: TA soft reset\n", tag()); |
| 852 | #endif |
| 853 | listtype_used=0; |
| 854 | } |
| 855 | if (softreset & 2) { |
| 856 | #if DEBUG_PVRTA |
| 857 | logerror("%s: Core Pipeline soft reset\n", tag()); |
| 858 | #endif |
| 859 | if (start_render_received == 1) { |
| 860 | for (int a=0;a < NUM_BUFFERS;a++) |
| 861 | if (grab[a].busy == 1) |
| 862 | grab[a].busy = 0; |
| 863 | start_render_received = 0; |
| 864 | } |
| 865 | } |
| 866 | if (softreset & 4) { |
| 867 | #if DEBUG_PVRTA |
| 868 | logerror("%s: sdram I/F soft reset\n", tag()); |
| 869 | #endif |
| 870 | } |
| 871 | } |
| 878 | 872 | |
| 879 | | /* FIXME: following is just a wild guess */ |
| 880 | | blank = (space.machine().primary_screen->vblank() | space.machine().primary_screen->hblank()) ? 0 : 1; |
| 881 | | if(spg_blank_pol) { blank^=1; } |
| 873 | WRITE32_MEMBER( powervr2_device::startrender_w ) |
| 874 | { |
| 875 | g_profiler.start(PROFILER_USER1); |
| 876 | #if DEBUG_PVRTA |
| 877 | logerror("%s: Start render, region=%08x, params=%08x\n", tag(), region_base, param_base); |
| 878 | #endif |
| 882 | 879 | |
| 883 | | pvrta_regs[offset] = (vsync << 13) | (hsync << 12) | (blank << 11) | (fieldnum << 10) | (space.machine().primary_screen->vpos() & 0x3ff); |
| 880 | // select buffer to draw using param_base |
| 881 | for (int a=0;a < NUM_BUFFERS;a++) { |
| 882 | if ((grab[a].ispbase == param_base) && (grab[a].valid == 1) && (grab[a].busy == 0)) { |
| 883 | grab[a].busy = 1; |
| 884 | renderselect = a; |
| 885 | start_render_received=1; |
| 886 | |
| 887 | |
| 888 | grab[a].fbwsof1 = fb_w_sof1; |
| 889 | grab[a].fbwsof2 = fb_w_sof2; |
| 890 | |
| 891 | rectangle clip(0, 1023, 0, 1023); |
| 892 | |
| 893 | // we've got a request to draw, so, draw to the accumulation buffer! |
| 894 | // this should really be done for each tile! |
| 895 | render_to_accumulation_buffer(*fake_accumulationbuffer_bitmap,clip); |
| 896 | |
| 897 | endofrender_timer_isp->adjust(attotime::from_usec(4000) ); // hack, make sure render takes some amount of time |
| 898 | |
| 899 | /* copy the tiles to the framebuffer (really the rendering should be in this loop too) */ |
| 900 | int sizera = fpu_param_cfg & 0x200000 ? 6 : 5; |
| 901 | int offsetra=region_base; |
| 902 | |
| 903 | //printf("base is %08x\n", offsetra); |
| 904 | |
| 905 | // sanity |
| 906 | int sanitycount = 0; |
| 907 | for (;;) { |
| 908 | UINT32 st[6]; |
| 909 | |
| 910 | st[0]=space.read_dword((0x05000000+offsetra)); |
| 911 | st[1]=space.read_dword((0x05000004+offsetra)); // Opaque List Pointer |
| 912 | st[2]=space.read_dword((0x05000008+offsetra)); // Opaque Modifier Volume List Pointer |
| 913 | st[3]=space.read_dword((0x0500000c+offsetra)); // Translucent List Pointer |
| 914 | st[4]=space.read_dword((0x05000010+offsetra)); // Translucent Modifier Volume List Pointer |
| 915 | |
| 916 | if (sizera == 6) { |
| 917 | st[5] = space.read_dword((0x05000014+offsetra)); // Punch Through List Pointer |
| 918 | offsetra+=0x18; |
| 919 | } else { |
| 920 | st[5] = 0; |
| 921 | offsetra+=0x14; |
| 922 | } |
| 923 | |
| 924 | { |
| 925 | int x = ((st[0]&0x000000fc)>>2)*32; |
| 926 | int y = ((st[0]&0x00003f00)>>8)*32; |
| 927 | //printf("tiledata %08x %d %d - %08x %08x %08x %08x %08x\n",st[0],x,y,st[1],st[2],st[3],st[4],st[5]); |
| 928 | |
| 929 | // should render to the accumulation buffer here using pointers we filled in when processing the data |
| 930 | // sent to the TA. HOWEVER, we don't process the TA data and create the real format object lists, so |
| 931 | // instead just use these co-ordinates to copy data from our fake full-screnen accumnulation buffer into |
| 932 | // the framebuffer |
| 933 | |
| 934 | pvr_accumulationbuffer_to_framebuffer(space, x,y); |
| 935 | } |
| 936 | |
| 937 | if (st[0] & 0x80000000) |
| 938 | break; |
| 939 | |
| 940 | // prevent infinite loop if asked to process invalid data |
| 941 | if(sanitycount>2000) |
| 942 | break; |
| 943 | } |
| 884 | 944 | break; |
| 885 | 945 | } |
| 886 | | case SPG_TRIGGER_POS: |
| 887 | | printf("Warning: read at h/v counter ext latches\n"); |
| 888 | | break; |
| 889 | | case TA_LIST_INIT: |
| 890 | | return 0; //bit 31 always return 0, a probable left-over in Crazy Taxi reads this and discards the read (?) |
| 891 | 946 | } |
| 947 | } |
| 892 | 948 | |
| 893 | | #if DEBUG_PVRTA_REGS |
| 894 | | if (reg != 0x43) |
| 895 | | mame_printf_verbose("PVRTA: [%08x] read %x @ %x (reg %x), mask %" I64FMT "x (PC=%x)\n", 0x5f8000+reg*4, pvrta_regs[reg], offset, reg, mem_mask, space.device().safe_pc()); |
| 896 | | #endif |
| 897 | | return (UINT64)pvrta_regs[offset]; |
| 949 | |
| 950 | READ32_MEMBER( powervr2_device::param_base_r ) |
| 951 | { |
| 952 | return param_base; |
| 898 | 953 | } |
| 899 | 954 | |
| 900 | | WRITE32_MEMBER( powervr2_device::pvr_ta_w ) |
| 955 | WRITE32_MEMBER( powervr2_device::param_base_w ) |
| 901 | 956 | { |
| 902 | | UINT32 sizera,offsetra; |
| 903 | | int a; |
| 904 | | int sanitycount; |
| 957 | COMBINE_DATA(¶m_base); |
| 958 | } |
| 905 | 959 | |
| 906 | | // Dreamcast BIOS attempts to set PVRID to zero and then dies |
| 907 | | // if it succeeds. Don't allow. |
| 908 | | if ((offset != PVRID) && (offset != REVISION)) |
| 909 | | { |
| 910 | | pvrta_regs[offset] = data; // 5f8000+reg*4=dat |
| 911 | | } |
| 960 | READ32_MEMBER( powervr2_device::region_base_r ) |
| 961 | { |
| 962 | return region_base; |
| 963 | } |
| 912 | 964 | |
| 913 | | switch (offset) |
| 914 | | { |
| 915 | | case SOFTRESET: |
| 916 | | if (data & 1) |
| 917 | | { |
| 918 | | #if DEBUG_PVRTA |
| 919 | | mame_printf_verbose("pvr_ta_w: TA soft reset\n"); |
| 920 | | #endif |
| 921 | | listtype_used=0; |
| 922 | | } |
| 923 | | if (data & 2) |
| 924 | | { |
| 925 | | #if DEBUG_PVRTA |
| 926 | | mame_printf_verbose("pvr_ta_w: Core Pipeline soft reset\n"); |
| 927 | | #endif |
| 928 | | if (start_render_received == 1) |
| 929 | | { |
| 930 | | for (a=0;a < NUM_BUFFERS;a++) |
| 931 | | if (grab[a].busy == 1) |
| 932 | | grab[a].busy = 0; |
| 933 | | start_render_received = 0; |
| 934 | | } |
| 935 | | } |
| 936 | | if (data & 4) |
| 937 | | { |
| 938 | | #if DEBUG_PVRTA |
| 939 | | mame_printf_verbose("pvr_ta_w: sdram I/F soft reset\n"); |
| 940 | | #endif |
| 941 | | } |
| 942 | | break; |
| 943 | | case STARTRENDER: |
| 944 | | g_profiler.start(PROFILER_USER1); |
| 945 | | #if DEBUG_PVRTA |
| 946 | | mame_printf_verbose("Start Render Received:\n"); |
| 947 | | mame_printf_verbose(" Region Array at %08x\n",pvrta_regs[REGION_BASE]); |
| 948 | | mame_printf_verbose(" ISP/TSP Parameters at %08x\n",pvrta_regs[PARAM_BASE]); |
| 965 | WRITE32_MEMBER( powervr2_device::region_base_w ) |
| 966 | { |
| 967 | COMBINE_DATA(®ion_base); |
| 968 | } |
| 949 | 969 | |
| 950 | | #endif |
| 951 | | // select buffer to draw using PARAM_BASE |
| 952 | | for (a=0;a < NUM_BUFFERS;a++) |
| 953 | | { |
| 954 | | if ((grab[a].ispbase == pvrta_regs[PARAM_BASE]) && (grab[a].valid == 1) && (grab[a].busy == 0)) |
| 955 | | { |
| 956 | | grab[a].busy = 1; |
| 957 | | renderselect = a; |
| 958 | | start_render_received=1; |
| 970 | READ32_MEMBER( powervr2_device::vo_border_col_r ) |
| 971 | { |
| 972 | return vo_border_col; |
| 973 | } |
| 959 | 974 | |
| 975 | WRITE32_MEMBER( powervr2_device::vo_border_col_w ) |
| 976 | { |
| 977 | COMBINE_DATA(&vo_border_col); |
| 978 | } |
| 960 | 979 | |
| 961 | | grab[a].fbwsof1=pvrta_regs[FB_W_SOF1]; |
| 962 | | grab[a].fbwsof2=pvrta_regs[FB_W_SOF2]; |
| 980 | READ32_MEMBER( powervr2_device::fb_r_ctrl_r ) |
| 981 | { |
| 982 | return fb_r_ctrl; |
| 983 | } |
| 963 | 984 | |
| 964 | | rectangle clip(0, 1023, 0, 1023); |
| 985 | WRITE32_MEMBER( powervr2_device::fb_r_ctrl_w ) |
| 986 | { |
| 987 | COMBINE_DATA(&fb_r_ctrl); |
| 988 | } |
| 965 | 989 | |
| 966 | | // we've got a request to draw, so, draw to the accumulation buffer! |
| 967 | | // this should really be done for each tile! |
| 968 | | render_to_accumulation_buffer(*fake_accumulationbuffer_bitmap,clip); |
| 990 | READ32_MEMBER( powervr2_device::fb_w_ctrl_r ) |
| 991 | { |
| 992 | return fb_w_ctrl; |
| 993 | } |
| 969 | 994 | |
| 970 | | endofrender_timer_isp->adjust(attotime::from_usec(4000) ); // hack, make sure render takes some amount of time |
| 995 | WRITE32_MEMBER( powervr2_device::fb_w_ctrl_w ) |
| 996 | { |
| 997 | COMBINE_DATA(&fb_w_ctrl); |
| 998 | } |
| 971 | 999 | |
| 972 | | /* copy the tiles to the framebuffer (really the rendering should be in this loop too) */ |
| 973 | | if (pvrta_regs[FPU_PARAM_CFG] & 0x200000) |
| 974 | | sizera=6; |
| 975 | | else |
| 976 | | sizera=5; |
| 977 | | offsetra=pvrta_regs[REGION_BASE]; |
| 1000 | READ32_MEMBER( powervr2_device::fb_w_linestride_r ) |
| 1001 | { |
| 1002 | return fb_w_linestride; |
| 1003 | } |
| 978 | 1004 | |
| 979 | | //printf("base is %08x\n", offsetra); |
| 1005 | WRITE32_MEMBER( powervr2_device::fb_w_linestride_w ) |
| 1006 | { |
| 1007 | COMBINE_DATA(&fb_w_linestride); |
| 1008 | } |
| 980 | 1009 | |
| 981 | | // sanity |
| 982 | | sanitycount = 0; |
| 983 | | for (;;) |
| 984 | | { |
| 985 | | UINT32 st[6]; |
| 1010 | READ32_MEMBER( powervr2_device::fb_r_sof1_r ) |
| 1011 | { |
| 1012 | return fb_r_sof1; |
| 1013 | } |
| 986 | 1014 | |
| 987 | | st[0]=space.read_dword((0x05000000+offsetra)); |
| 988 | | st[1]=space.read_dword((0x05000004+offsetra)); // Opaque List Pointer |
| 989 | | st[2]=space.read_dword((0x05000008+offsetra)); // Opaque Modifier Volume List Pointer |
| 990 | | st[3]=space.read_dword((0x0500000c+offsetra)); // Translucent List Pointer |
| 991 | | st[4]=space.read_dword((0x05000010+offsetra)); // Translucent Modifier Volume List Pointer |
| 1015 | WRITE32_MEMBER( powervr2_device::fb_r_sof1_w ) |
| 1016 | { |
| 1017 | COMBINE_DATA(&fb_r_sof1); |
| 1018 | } |
| 992 | 1019 | |
| 993 | | if (sizera == 6) |
| 994 | | { |
| 995 | | st[5] = space.read_dword((0x05000014+offsetra)); // Punch Through List Pointer |
| 996 | | offsetra+=0x18; |
| 997 | | } |
| 998 | | else |
| 999 | | { |
| 1000 | | st[5] = 0; |
| 1001 | | offsetra+=0x14; |
| 1002 | | } |
| 1020 | READ32_MEMBER( powervr2_device::fb_r_sof2_r ) |
| 1021 | { |
| 1022 | return fb_r_sof2; |
| 1023 | } |
| 1003 | 1024 | |
| 1004 | | { |
| 1005 | | int x = ((st[0]&0x000000fc)>>2)*32; |
| 1006 | | int y = ((st[0]&0x00003f00)>>8)*32; |
| 1007 | | //printf("tiledata %08x %d %d - %08x %08x %08x %08x %08x\n",st[0],x,y,st[1],st[2],st[3],st[4],st[5]); |
| 1025 | WRITE32_MEMBER( powervr2_device::fb_r_sof2_w ) |
| 1026 | { |
| 1027 | COMBINE_DATA(&fb_r_sof2); |
| 1028 | } |
| 1008 | 1029 | |
| 1009 | | // should render to the accumulation buffer here using pointers we filled in when processing the data |
| 1010 | | // sent to the TA. HOWEVER, we don't process the TA data and create the real format object lists, so |
| 1011 | | // instead just use these co-ordinates to copy data from our fake full-screnen accumnulation buffer into |
| 1012 | | // the framebuffer |
| 1030 | READ32_MEMBER( powervr2_device::fb_r_size_r ) |
| 1031 | { |
| 1032 | return fb_r_size; |
| 1033 | } |
| 1013 | 1034 | |
| 1014 | | pvr_accumulationbuffer_to_framebuffer(space, x,y); |
| 1015 | | } |
| 1035 | WRITE32_MEMBER( powervr2_device::fb_r_size_w ) |
| 1036 | { |
| 1037 | COMBINE_DATA(&fb_r_size); |
| 1038 | } |
| 1016 | 1039 | |
| 1017 | | if (st[0] & 0x80000000) |
| 1018 | | break; |
| 1040 | READ32_MEMBER( powervr2_device::fb_w_sof1_r ) |
| 1041 | { |
| 1042 | return fb_w_sof1; |
| 1043 | } |
| 1019 | 1044 | |
| 1020 | | // prevent infinite loop if asked to process invalid data |
| 1021 | | if(sanitycount>2000) |
| 1022 | | break; |
| 1023 | | } |
| 1045 | WRITE32_MEMBER( powervr2_device::fb_w_sof1_w ) |
| 1046 | { |
| 1047 | COMBINE_DATA(&fb_w_sof1); |
| 1048 | } |
| 1024 | 1049 | |
| 1050 | READ32_MEMBER( powervr2_device::fb_w_sof2_r ) |
| 1051 | { |
| 1052 | return fb_w_sof2; |
| 1053 | } |
| 1025 | 1054 | |
| 1055 | WRITE32_MEMBER( powervr2_device::fb_w_sof2_w ) |
| 1056 | { |
| 1057 | COMBINE_DATA(&fb_w_sof2); |
| 1058 | } |
| 1026 | 1059 | |
| 1060 | READ32_MEMBER( powervr2_device::fb_x_clip_r ) |
| 1061 | { |
| 1062 | return fb_x_clip; |
| 1063 | } |
| 1027 | 1064 | |
| 1065 | WRITE32_MEMBER( powervr2_device::fb_x_clip_w ) |
| 1066 | { |
| 1067 | COMBINE_DATA(&fb_x_clip); |
| 1068 | } |
| 1069 | |
| 1070 | READ32_MEMBER( powervr2_device::fb_y_clip_r ) |
| 1071 | { |
| 1072 | return fb_y_clip; |
| 1073 | } |
| 1074 | |
| 1075 | WRITE32_MEMBER( powervr2_device::fb_y_clip_w ) |
| 1076 | { |
| 1077 | COMBINE_DATA(&fb_y_clip); |
| 1078 | } |
| 1079 | |
| 1080 | READ32_MEMBER( powervr2_device::fpu_param_cfg_r ) |
| 1081 | { |
| 1082 | return fpu_param_cfg; |
| 1083 | } |
| 1084 | |
| 1085 | WRITE32_MEMBER( powervr2_device::fpu_param_cfg_w ) |
| 1086 | { |
| 1087 | COMBINE_DATA(&fpu_param_cfg); |
| 1088 | } |
| 1089 | |
| 1090 | READ32_MEMBER( powervr2_device::isp_backgnd_t_r ) |
| 1091 | { |
| 1092 | return isp_backgnd_t; |
| 1093 | } |
| 1094 | |
| 1095 | WRITE32_MEMBER( powervr2_device::isp_backgnd_t_w ) |
| 1096 | { |
| 1097 | COMBINE_DATA(&isp_backgnd_t); |
| 1098 | } |
| 1099 | |
| 1100 | READ32_MEMBER( powervr2_device::spg_hblank_int_r ) |
| 1101 | { |
| 1102 | return spg_hblank_int; |
| 1103 | } |
| 1104 | |
| 1105 | WRITE32_MEMBER( powervr2_device::spg_hblank_int_w ) |
| 1106 | { |
| 1107 | COMBINE_DATA(&spg_hblank_int); |
| 1108 | /* TODO: timer adjust */ |
| 1109 | } |
| 1110 | |
| 1111 | READ32_MEMBER( powervr2_device::spg_vblank_int_r ) |
| 1112 | { |
| 1113 | return spg_vblank_int; |
| 1114 | } |
| 1115 | |
| 1116 | WRITE32_MEMBER( powervr2_device::spg_vblank_int_w ) |
| 1117 | { |
| 1118 | COMBINE_DATA(&spg_vblank_int); |
| 1119 | |
| 1120 | /* clear pending irqs and modify them with the updated ones */ |
| 1121 | vbin_timer->adjust(attotime::never); |
| 1122 | vbout_timer->adjust(attotime::never); |
| 1123 | |
| 1124 | vbin_timer->adjust(space.machine().primary_screen->time_until_pos(spg_vblank_int & 0x3ff)); |
| 1125 | vbout_timer->adjust(space.machine().primary_screen->time_until_pos((spg_vblank_int >> 16) & 0x3ff)); |
| 1126 | } |
| 1127 | |
| 1128 | READ32_MEMBER( powervr2_device::spg_hblank_r ) |
| 1129 | { |
| 1130 | return spg_hblank; |
| 1131 | } |
| 1132 | |
| 1133 | WRITE32_MEMBER( powervr2_device::spg_hblank_w ) |
| 1134 | { |
| 1135 | COMBINE_DATA(&spg_hblank); |
| 1136 | update_screen_format(); |
| 1137 | } |
| 1138 | |
| 1139 | READ32_MEMBER( powervr2_device::spg_load_r ) |
| 1140 | { |
| 1141 | return spg_load; |
| 1142 | } |
| 1143 | |
| 1144 | WRITE32_MEMBER( powervr2_device::spg_load_w ) |
| 1145 | { |
| 1146 | COMBINE_DATA(&spg_load); |
| 1147 | update_screen_format(); |
| 1148 | } |
| 1149 | |
| 1150 | READ32_MEMBER( powervr2_device::spg_vblank_r ) |
| 1151 | { |
| 1152 | return spg_vblank; |
| 1153 | } |
| 1154 | |
| 1155 | WRITE32_MEMBER( powervr2_device::spg_vblank_w ) |
| 1156 | { |
| 1157 | COMBINE_DATA(&spg_vblank); |
| 1158 | update_screen_format(); |
| 1159 | } |
| 1160 | |
| 1161 | READ32_MEMBER( powervr2_device::spg_width_r ) |
| 1162 | { |
| 1163 | return spg_width; |
| 1164 | } |
| 1165 | |
| 1166 | WRITE32_MEMBER( powervr2_device::spg_width_w ) |
| 1167 | { |
| 1168 | COMBINE_DATA(&spg_width); |
| 1169 | update_screen_format(); |
| 1170 | } |
| 1171 | |
| 1172 | READ32_MEMBER( powervr2_device::text_control_r ) |
| 1173 | { |
| 1174 | return text_control; |
| 1175 | } |
| 1176 | |
| 1177 | WRITE32_MEMBER( powervr2_device::text_control_w ) |
| 1178 | { |
| 1179 | COMBINE_DATA(&text_control); |
| 1180 | } |
| 1181 | |
| 1182 | READ32_MEMBER( powervr2_device::vo_control_r ) |
| 1183 | { |
| 1184 | return vo_control; |
| 1185 | } |
| 1186 | |
| 1187 | WRITE32_MEMBER( powervr2_device::vo_control_w ) |
| 1188 | { |
| 1189 | COMBINE_DATA(&vo_control); |
| 1190 | } |
| 1191 | |
| 1192 | READ32_MEMBER( powervr2_device::vo_startx_r ) |
| 1193 | { |
| 1194 | return vo_startx; |
| 1195 | } |
| 1196 | |
| 1197 | WRITE32_MEMBER( powervr2_device::vo_startx_w ) |
| 1198 | { |
| 1199 | COMBINE_DATA(&vo_startx); |
| 1200 | update_screen_format(); |
| 1201 | } |
| 1202 | |
| 1203 | READ32_MEMBER( powervr2_device::vo_starty_r ) |
| 1204 | { |
| 1205 | return vo_starty; |
| 1206 | } |
| 1207 | |
| 1208 | WRITE32_MEMBER( powervr2_device::vo_starty_w ) |
| 1209 | { |
| 1210 | COMBINE_DATA(&vo_starty); |
| 1211 | update_screen_format(); |
| 1212 | } |
| 1213 | |
| 1214 | READ32_MEMBER( powervr2_device::pal_ram_ctrl_r ) |
| 1215 | { |
| 1216 | return pal_ram_ctrl; |
| 1217 | } |
| 1218 | |
| 1219 | WRITE32_MEMBER( powervr2_device::pal_ram_ctrl_w ) |
| 1220 | { |
| 1221 | COMBINE_DATA(&pal_ram_ctrl); |
| 1222 | } |
| 1223 | |
| 1224 | READ32_MEMBER( powervr2_device::spg_status_r ) |
| 1225 | { |
| 1226 | UINT32 fieldnum = (machine().primary_screen->frame_number() & 1) ? 1 : 0; |
| 1227 | |
| 1228 | UINT32 vsync = machine().primary_screen->vblank() ? 1 : 0; |
| 1229 | if(vo_control & 2) { vsync^=1; } |
| 1230 | |
| 1231 | UINT32 hsync = machine().primary_screen->hblank() ? 1 : 0; |
| 1232 | if(vo_control & 1) { hsync^=1; } |
| 1233 | |
| 1234 | /* FIXME: following is just a wild guess */ |
| 1235 | UINT32 blank = (machine().primary_screen->vblank() | space.machine().primary_screen->hblank()) ? 0 : 1; |
| 1236 | if(vo_control & 4) { blank^=1; } |
| 1237 | |
| 1238 | return (vsync << 13) | (hsync << 12) | (blank << 11) | (fieldnum << 10) | (machine().primary_screen->vpos() & 0x3ff); |
| 1239 | } |
| 1240 | |
| 1241 | |
| 1242 | READ32_MEMBER( powervr2_device::ta_ol_base_r ) |
| 1243 | { |
| 1244 | return ta_ol_base; |
| 1245 | } |
| 1246 | |
| 1247 | WRITE32_MEMBER( powervr2_device::ta_ol_base_w ) |
| 1248 | { |
| 1249 | COMBINE_DATA(&ta_ol_base); |
| 1250 | } |
| 1251 | |
| 1252 | READ32_MEMBER( powervr2_device::ta_isp_base_r ) |
| 1253 | { |
| 1254 | return ta_isp_base; |
| 1255 | } |
| 1256 | |
| 1257 | WRITE32_MEMBER( powervr2_device::ta_isp_base_w ) |
| 1258 | { |
| 1259 | COMBINE_DATA(&ta_isp_base); |
| 1260 | } |
| 1261 | |
| 1262 | READ32_MEMBER( powervr2_device::ta_ol_limit_r ) |
| 1263 | { |
| 1264 | return ta_ol_limit; |
| 1265 | } |
| 1266 | |
| 1267 | WRITE32_MEMBER( powervr2_device::ta_ol_limit_w ) |
| 1268 | { |
| 1269 | COMBINE_DATA(&ta_ol_limit); |
| 1270 | } |
| 1271 | |
| 1272 | READ32_MEMBER( powervr2_device::ta_isp_limit_r ) |
| 1273 | { |
| 1274 | return ta_isp_limit; |
| 1275 | } |
| 1276 | |
| 1277 | WRITE32_MEMBER( powervr2_device::ta_isp_limit_w ) |
| 1278 | { |
| 1279 | COMBINE_DATA(&ta_isp_limit); |
| 1280 | } |
| 1281 | |
| 1282 | READ32_MEMBER( powervr2_device::ta_next_opb_r ) |
| 1283 | { |
| 1284 | return ta_next_opb; |
| 1285 | } |
| 1286 | |
| 1287 | READ32_MEMBER( powervr2_device::ta_itp_current_r ) |
| 1288 | { |
| 1289 | return ta_itp_current; |
| 1290 | } |
| 1291 | |
| 1292 | READ32_MEMBER( powervr2_device::ta_alloc_ctrl_r ) |
| 1293 | { |
| 1294 | return ta_alloc_ctrl; |
| 1295 | } |
| 1296 | |
| 1297 | WRITE32_MEMBER( powervr2_device::ta_alloc_ctrl_w ) |
| 1298 | { |
| 1299 | COMBINE_DATA(&ta_alloc_ctrl); |
| 1300 | } |
| 1301 | |
| 1302 | READ32_MEMBER( powervr2_device::ta_list_init_r ) |
| 1303 | { |
| 1304 | return 0; //bit 31 always return 0, a probable left-over in Crazy Taxi reads this and discards the read (?) |
| 1305 | } |
| 1306 | |
| 1307 | WRITE32_MEMBER( powervr2_device::ta_list_init_w ) |
| 1308 | { |
| 1309 | if(data & 0x80000000) { |
| 1310 | tafifo_pos=0; |
| 1311 | tafifo_mask=7; |
| 1312 | tafifo_vertexwords=8; |
| 1313 | tafifo_listtype= -1; |
| 1314 | #if DEBUG_PVRTA |
| 1315 | logerror("%s: list init ol=(%08x, %08x) isp=(%08x, %08x), alloc=%08x obp=%08x\n", |
| 1316 | tag(), ta_ol_base, ta_ol_limit, ta_isp_base, ta_isp_limit, ta_alloc_ctrl, ta_next_opb_init); |
| 1317 | #endif |
| 1318 | ta_next_opb = ta_next_opb_init; |
| 1319 | ta_itp_current = ta_isp_base; |
| 1320 | alloc_ctrl_OPB_Mode = ta_alloc_ctrl & 0x100000; // 0 up 1 down |
| 1321 | alloc_ctrl_PT_OPB = (4 << ((ta_alloc_ctrl >> 16) & 3)) & 0x38; // number of 32 bit words (0,8,16,32) |
| 1322 | alloc_ctrl_TM_OPB = (4 << ((ta_alloc_ctrl >> 12) & 3)) & 0x38; |
| 1323 | alloc_ctrl_T_OPB = (4 << ((ta_alloc_ctrl >> 8) & 3)) & 0x38; |
| 1324 | alloc_ctrl_OM_OPB = (4 << ((ta_alloc_ctrl >> 4) & 3)) & 0x38; |
| 1325 | alloc_ctrl_O_OPB = (4 << ((ta_alloc_ctrl >> 0) & 3)) & 0x38; |
| 1326 | listtype_used |= (1+4); |
| 1327 | // use ta_isp_base and select buffer for grab data |
| 1328 | grabsel = -1; |
| 1329 | // try to find already used buffer but not busy |
| 1330 | for (int a=0;a < NUM_BUFFERS;a++) |
| 1331 | if ((grab[a].ispbase == ta_isp_base) && (grab[a].busy == 0) && (grab[a].valid == 1)) { |
| 1332 | grabsel=a; |
| 1028 | 1333 | break; |
| 1029 | 1334 | } |
| 1030 | | } |
| 1031 | | if (a != NUM_BUFFERS) |
| 1032 | | break; |
| 1033 | | assert_always(0, "TA grabber error A!\n"); |
| 1034 | | break; |
| 1035 | | case TA_LIST_INIT: |
| 1036 | | if(data & 0x80000000) |
| 1037 | | { |
| 1038 | | tafifo_pos=0; |
| 1039 | | tafifo_mask=7; |
| 1040 | | tafifo_vertexwords=8; |
| 1041 | | tafifo_listtype= -1; |
| 1042 | | #if DEBUG_PVRTA |
| 1043 | | mame_printf_verbose("TA_OL_BASE %08x TA_OL_LIMIT %08x\n", pvrta_regs[TA_OL_BASE], pvrta_regs[TA_OL_LIMIT]); |
| 1044 | | mame_printf_verbose("TA_ISP_BASE %08x TA_ISP_LIMIT %08x\n", pvrta_regs[TA_ISP_BASE], pvrta_regs[TA_ISP_LIMIT]); |
| 1045 | | mame_printf_verbose("TA_ALLOC_CTRL %08x\n", pvrta_regs[TA_ALLOC_CTRL]); |
| 1046 | | mame_printf_verbose("TA_NEXT_OPB_INIT %08x\n", pvrta_regs[TA_NEXT_OPB_INIT]); |
| 1047 | | #endif |
| 1048 | | pvrta_regs[TA_NEXT_OPB] = pvrta_regs[TA_NEXT_OPB_INIT]; |
| 1049 | | pvrta_regs[TA_ITP_CURRENT] = pvrta_regs[TA_ISP_BASE]; |
| 1050 | | alloc_ctrl_OPB_Mode = pvrta_regs[TA_ALLOC_CTRL] & 0x100000; // 0 up 1 down |
| 1051 | | alloc_ctrl_PT_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 16) & 3)) & 0x38; // number of 32 bit words (0,8,16,32) |
| 1052 | | alloc_ctrl_TM_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 12) & 3)) & 0x38; |
| 1053 | | alloc_ctrl_T_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 8) & 3)) & 0x38; |
| 1054 | | alloc_ctrl_OM_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 4) & 3)) & 0x38; |
| 1055 | | alloc_ctrl_O_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 0) & 3)) & 0x38; |
| 1056 | | listtype_used |= (1+4); |
| 1057 | | // use TA_ISP_BASE and select buffer for grab data |
| 1058 | | grabsel = -1; |
| 1059 | | // try to find already used buffer but not busy |
| 1060 | | for (a=0;a < NUM_BUFFERS;a++) |
| 1061 | | { |
| 1062 | | if ((grab[a].ispbase == pvrta_regs[TA_ISP_BASE]) && (grab[a].busy == 0) && (grab[a].valid == 1)) |
| 1063 | | { |
| 1335 | |
| 1336 | // try a buffer not used yet |
| 1337 | if (grabsel < 0) |
| 1338 | for (int a=0;a < NUM_BUFFERS;a++) |
| 1339 | if (grab[a].valid == 0) { |
| 1064 | 1340 | grabsel=a; |
| 1065 | 1341 | break; |
| 1066 | 1342 | } |
| 1067 | | } |
| 1068 | | // try a buffer not used yet |
| 1069 | | if (grabsel < 0) |
| 1070 | | { |
| 1071 | | for (a=0;a < NUM_BUFFERS;a++) |
| 1072 | | { |
| 1073 | | if (grab[a].valid == 0) |
| 1074 | | { |
| 1075 | | grabsel=a; |
| 1076 | | break; |
| 1077 | | } |
| 1343 | |
| 1344 | // find a non busy buffer starting from the last one used |
| 1345 | if (grabsel < 0) |
| 1346 | for (int a=0;a < 3;a++) |
| 1347 | if (grab[(grabsellast+1+a) & 3].busy == 0) { |
| 1348 | grabsel=a; |
| 1349 | break; |
| 1078 | 1350 | } |
| 1079 | | } |
| 1080 | | // find a non busy buffer starting from the last one used |
| 1081 | | if (grabsel < 0) |
| 1082 | | { |
| 1083 | | for (a=0;a < 3;a++) |
| 1084 | | { |
| 1085 | | if (grab[(grabsellast+1+a) & 3].busy == 0) |
| 1086 | | { |
| 1087 | | grabsel=a; |
| 1088 | | break; |
| 1089 | | } |
| 1090 | | } |
| 1091 | | } |
| 1092 | | if (grabsel < 0) |
| 1093 | | assert_always(0, "TA grabber error B!\n"); |
| 1094 | | grabsellast=grabsel; |
| 1095 | | grab[grabsel].ispbase=pvrta_regs[TA_ISP_BASE]; |
| 1096 | | grab[grabsel].busy=0; |
| 1097 | | grab[grabsel].valid=1; |
| 1098 | | grab[grabsel].verts_size=0; |
| 1099 | | grab[grabsel].strips_size=0; |
| 1100 | 1351 | |
| 1101 | | g_profiler.stop(); |
| 1102 | | } |
| 1103 | | break; |
| 1104 | | //#define TA_YUV_TEX_BASE ((0x005f8148-0x005f8000)/4) |
| 1105 | | case TA_YUV_TEX_BASE: |
| 1106 | | printf("TA_YUV_TEX_BASE initialized to %08x\n", data); |
| 1352 | if (grabsel < 0) |
| 1353 | assert_always(0, "TA grabber error B!\n"); |
| 1354 | grabsellast=grabsel; |
| 1355 | grab[grabsel].ispbase=ta_isp_base; |
| 1356 | grab[grabsel].busy=0; |
| 1357 | grab[grabsel].valid=1; |
| 1358 | grab[grabsel].verts_size=0; |
| 1359 | grab[grabsel].strips_size=0; |
| 1360 | |
| 1361 | g_profiler.stop(); |
| 1362 | } |
| 1363 | } |
| 1107 | 1364 | |
| 1108 | | // hack, this interrupt is generated after transfering a set amount of data |
| 1109 | | //irq_cb(EOXFER_YUV_IRQ); |
| 1110 | 1365 | |
| 1111 | | break; |
| 1112 | | case TA_YUV_TEX_CTRL: |
| 1113 | | printf("TA_YUV_TEX_CTRL initialized to %08x\n", data); |
| 1114 | | break; |
| 1366 | READ32_MEMBER( powervr2_device::ta_yuv_tex_base_r ) |
| 1367 | { |
| 1368 | return ta_yuv_tex_base; |
| 1369 | } |
| 1115 | 1370 | |
| 1116 | | case SPG_VBLANK_INT: |
| 1117 | | /* clear pending irqs and modify them with the updated ones */ |
| 1118 | | vbin_timer->adjust(attotime::never); |
| 1119 | | vbout_timer->adjust(attotime::never); |
| 1371 | WRITE32_MEMBER( powervr2_device::ta_yuv_tex_base_w ) |
| 1372 | { |
| 1373 | COMBINE_DATA(&ta_yuv_tex_base); |
| 1374 | logerror("%s: ta_yuv_tex_base = %08x\n", tag(), ta_yuv_tex_base); |
| 1120 | 1375 | |
| 1121 | | vbin_timer->adjust(space.machine().primary_screen->time_until_pos(spg_vblank_in_irq_line_num)); |
| 1122 | | vbout_timer->adjust(space.machine().primary_screen->time_until_pos(spg_vblank_out_irq_line_num)); |
| 1123 | | break; |
| 1124 | | /* TODO: timer adjust for SPG_HBLANK_INT too */ |
| 1125 | | case TA_LIST_CONT: |
| 1126 | | #if DEBUG_PVRTA |
| 1127 | | mame_printf_verbose("List continuation processing\n"); |
| 1128 | | #endif |
| 1129 | | if(data & 0x80000000) |
| 1130 | | { |
| 1131 | | tafifo_listtype= -1; // no list being received |
| 1132 | | listtype_used |= (1+4); |
| 1133 | | } |
| 1134 | | break; |
| 1135 | | case SPG_VBLANK: |
| 1136 | | case SPG_HBLANK: |
| 1137 | | case SPG_LOAD: |
| 1138 | | case VO_STARTX: |
| 1139 | | case VO_STARTY: |
| 1140 | | { |
| 1141 | | rectangle visarea = space.machine().primary_screen->visible_area(); |
| 1142 | | /* FIXME: right visible area calculations aren't known yet*/ |
| 1143 | | visarea.min_x = 0; |
| 1144 | | visarea.max_x = ((spg_hbstart - spg_hbend - vo_horz_start_pos) <= 0x180 ? 320 : 640) - 1; |
| 1145 | | visarea.min_y = 0; |
| 1146 | | visarea.max_y = ((spg_vbstart - spg_vbend - vo_vert_start_pos_f1) <= 0x100 ? 240 : 480) - 1; |
| 1376 | // hack, this interrupt is generated after transfering a set amount of data |
| 1377 | //irq_cb(EOXFER_YUV_IRQ); |
| 1378 | } |
| 1147 | 1379 | |
| 1380 | READ32_MEMBER( powervr2_device::ta_yuv_tex_ctrl_r ) |
| 1381 | { |
| 1382 | return ta_yuv_tex_ctrl; |
| 1383 | } |
| 1148 | 1384 | |
| 1149 | | space.machine().primary_screen->configure(spg_hbstart, spg_vbstart, visarea, space.machine().primary_screen->frame_period().attoseconds ); |
| 1150 | | } |
| 1151 | | break; |
| 1385 | WRITE32_MEMBER( powervr2_device::ta_yuv_tex_ctrl_w ) |
| 1386 | { |
| 1387 | COMBINE_DATA(&ta_yuv_tex_ctrl); |
| 1388 | logerror("%s: ta_yuv_tex_ctrl = %08x\n", tag(), ta_yuv_tex_ctrl); |
| 1389 | } |
| 1390 | |
| 1391 | READ32_MEMBER( powervr2_device::ta_yuv_tex_cnt_r ) |
| 1392 | { |
| 1393 | return ta_yuv_tex_cnt; |
| 1394 | } |
| 1395 | |
| 1396 | WRITE32_MEMBER( powervr2_device::ta_yuv_tex_cnt_w ) |
| 1397 | { |
| 1398 | COMBINE_DATA(&ta_yuv_tex_cnt); |
| 1399 | } |
| 1400 | |
| 1401 | WRITE32_MEMBER( powervr2_device::ta_list_cont_w ) |
| 1402 | { |
| 1403 | if(data & 0x80000000) { |
| 1404 | tafifo_listtype= -1; // no list being received |
| 1405 | listtype_used |= (1+4); |
| 1152 | 1406 | } |
| 1407 | } |
| 1153 | 1408 | |
| 1154 | | #if DEBUG_PVRTA_REGS |
| 1155 | | if ((offset != 0x14) && (offset != 0x15)) |
| 1156 | | mame_printf_verbose("PVRTA: [%08x=%x] write %x to %x %x, mask %x\n", 0x5f8000+reg*4, data, offset, (reg*4)+0x8000, mem_mask); |
| 1157 | | #endif |
| 1409 | READ32_MEMBER( powervr2_device::ta_next_opb_init_r ) |
| 1410 | { |
| 1411 | return ta_next_opb_init; |
| 1158 | 1412 | } |
| 1159 | 1413 | |
| 1414 | WRITE32_MEMBER( powervr2_device::ta_next_opb_init_w ) |
| 1415 | { |
| 1416 | COMBINE_DATA(&ta_next_opb_init); |
| 1417 | } |
| 1418 | |
| 1419 | |
| 1420 | READ32_MEMBER( powervr2_device::fog_table_r ) |
| 1421 | { |
| 1422 | return fog_table[offset]; |
| 1423 | } |
| 1424 | |
| 1425 | WRITE32_MEMBER( powervr2_device::fog_table_w ) |
| 1426 | { |
| 1427 | COMBINE_DATA(fog_table+offset); |
| 1428 | } |
| 1429 | |
| 1430 | READ32_MEMBER( powervr2_device::palette_r ) |
| 1431 | { |
| 1432 | return palette[offset]; |
| 1433 | } |
| 1434 | |
| 1435 | WRITE32_MEMBER( powervr2_device::palette_w ) |
| 1436 | { |
| 1437 | COMBINE_DATA(palette+offset); |
| 1438 | } |
| 1439 | |
| 1440 | void powervr2_device::update_screen_format() |
| 1441 | { |
| 1442 | INT32 spg_hbstart = spg_hblank & 0x3ff; |
| 1443 | INT32 spg_hbend = (spg_hblank >> 16) & 0x3ff; |
| 1444 | INT32 spg_vbstart = spg_vblank & 0x3ff; |
| 1445 | INT32 spg_vbend = (spg_vblank >> 16) & 0x3ff; |
| 1446 | INT32 vo_horz_start_pos = vo_startx & 0x3ff; |
| 1447 | INT32 vo_vert_start_pos_f1 = vo_starty & 0x3ff; |
| 1448 | |
| 1449 | rectangle visarea = machine().primary_screen->visible_area(); |
| 1450 | /* FIXME: right visible area calculations aren't known yet*/ |
| 1451 | visarea.min_x = 0; |
| 1452 | visarea.max_x = ((spg_hbstart - spg_hbend - vo_horz_start_pos) <= 0x180 ? 320 : 640) - 1; |
| 1453 | visarea.min_y = 0; |
| 1454 | visarea.max_y = ((spg_vbstart - spg_vbend - vo_vert_start_pos_f1) <= 0x100 ? 240 : 480) - 1; |
| 1455 | |
| 1456 | machine().primary_screen->configure(spg_hbstart, spg_vbstart, visarea, machine().primary_screen->frame_period().attoseconds ); |
| 1457 | } |
| 1458 | |
| 1160 | 1459 | TIMER_CALLBACK_MEMBER(powervr2_device::transfer_opaque_list_irq) |
| 1161 | 1460 | { |
| 1162 | 1461 | irq_cb(EOXFER_OPLST_IRQ); |
| r23710 | r23711 | |
| 1838 | 2137 | { |
| 1839 | 2138 | dc_state *state = machine().driver_data<dc_state>(); |
| 1840 | 2139 | address_space &space = state->m_maincpu->space(AS_PROGRAM); |
| 1841 | | int cs,rs,ns; |
| 1842 | | UINT32 c; |
| 1843 | 2140 | #if 0 |
| 1844 | 2141 | int stride; |
| 1845 | 2142 | UINT16 *bmpaddr16; |
| r23710 | r23711 | |
| 1852 | 2149 | |
| 1853 | 2150 | //printf("drawtest!\n"); |
| 1854 | 2151 | |
| 1855 | | rs=renderselect; |
| 1856 | | c=pvrta_regs[ISP_BACKGND_T]; |
| 1857 | | c=space.read_dword(0x05000000+((c&0xfffff8)>>1)+(3+3)*4); |
| 2152 | int rs=renderselect; |
| 2153 | UINT32 c=space.read_dword(0x05000000+((isp_backgnd_t & 0xfffff8)>>1)+(3+3)*4); |
| 1858 | 2154 | bitmap.fill(c, cliprect); |
| 1859 | 2155 | |
| 1860 | 2156 | |
| 1861 | | ns=grab[rs].strips_size; |
| 2157 | int ns=grab[rs].strips_size; |
| 1862 | 2158 | if(ns) |
| 1863 | 2159 | memset(wbuffer, 0x00, sizeof(wbuffer)); |
| 1864 | 2160 | |
| 1865 | | for (cs=0;cs < ns;cs++) |
| 2161 | for (int cs=0;cs < ns;cs++) |
| 1866 | 2162 | { |
| 1867 | 2163 | strip *ts = &grab[rs].strips[cs]; |
| 1868 | 2164 | int sv = ts->svert; |
| r23710 | r23711 | |
| 1914 | 2210 | // the standard format for the framebuffer appears to be 565 |
| 1915 | 2211 | // yes, this means colour data is lost in the conversion |
| 1916 | 2212 | |
| 1917 | | UINT32 wc = pvrta_regs[FB_W_CTRL]; |
| 1918 | | UINT32 stride = pvrta_regs[FB_W_LINESTRIDE]; |
| 1919 | | UINT32 writeoffs = pvrta_regs[FB_W_SOF1]; |
| 2213 | UINT8 packmode = fb_w_ctrl & 0x7; |
| 1920 | 2214 | |
| 1921 | | UINT32* src; |
| 1922 | | |
| 1923 | | |
| 1924 | | UINT8 packmode = wc & 0x7; |
| 1925 | | |
| 1926 | 2215 | switch (packmode) |
| 1927 | 2216 | { |
| 1928 | 2217 | // used by ringout |
| r23710 | r23711 | |
| 1931 | 2220 | int xcnt,ycnt; |
| 1932 | 2221 | for (ycnt=0;ycnt<32;ycnt++) |
| 1933 | 2222 | { |
| 1934 | | UINT32 realwriteoffs = 0x05000000 + writeoffs + (y+ycnt) * (stride<<3) + (x*2); |
| 1935 | | src = &fake_accumulationbuffer_bitmap->pix32(y+ycnt, x); |
| 2223 | UINT32 realwriteoffs = 0x05000000 + fb_w_sof1 + (y+ycnt) * (fb_w_linestride<<3) + (x*2); |
| 2224 | UINT32 *src = &fake_accumulationbuffer_bitmap->pix32(y+ycnt, x); |
| 1936 | 2225 | |
| 1937 | 2226 | |
| 1938 | 2227 | for (xcnt=0;xcnt<32;xcnt++) |
| r23710 | r23711 | |
| 1955 | 2244 | int xcnt,ycnt; |
| 1956 | 2245 | for (ycnt=0;ycnt<32;ycnt++) |
| 1957 | 2246 | { |
| 1958 | | UINT32 realwriteoffs = 0x05000000 + writeoffs + (y+ycnt) * (stride<<3) + (x*2); |
| 1959 | | src = &fake_accumulationbuffer_bitmap->pix32(y+ycnt, x); |
| 2247 | UINT32 realwriteoffs = 0x05000000 + fb_w_sof1 + (y+ycnt) * (fb_w_linestride<<3) + (x*2); |
| 2248 | UINT32 *src = &fake_accumulationbuffer_bitmap->pix32(y+ycnt, x); |
| 1960 | 2249 | |
| 1961 | 2250 | |
| 1962 | 2251 | for (xcnt=0;xcnt<32;xcnt++) |
| r23710 | r23711 | |
| 1982 | 2271 | int xcnt,ycnt; |
| 1983 | 2272 | for (ycnt=0;ycnt<32;ycnt++) |
| 1984 | 2273 | { |
| 1985 | | UINT32 realwriteoffs = 0x05000000 + writeoffs + (y+ycnt) * (stride<<3) + (x*2); |
| 1986 | | src = &fake_accumulationbuffer_bitmap->pix32(y+ycnt, x); |
| 2274 | UINT32 realwriteoffs = 0x05000000 + fb_w_sof1 + (y+ycnt) * (fb_w_linestride<<3) + (x*2); |
| 2275 | UINT32 *src = &fake_accumulationbuffer_bitmap->pix32(y+ycnt, x); |
| 1987 | 2276 | |
| 1988 | 2277 | |
| 1989 | 2278 | for (xcnt=0;xcnt<32;xcnt++) |
| r23710 | r23711 | |
| 2007 | 2296 | int xcnt,ycnt; |
| 2008 | 2297 | for (ycnt=0;ycnt<32;ycnt++) |
| 2009 | 2298 | { |
| 2010 | | UINT32 realwriteoffs = 0x05000000 + writeoffs + (y+ycnt) * (stride<<3) + (x*2); |
| 2011 | | src = &fake_accumulationbuffer_bitmap->pix32(y+ycnt, x); |
| 2299 | UINT32 realwriteoffs = 0x05000000 + fb_w_sof1 + (y+ycnt) * (fb_w_linestride<<3) + (x*2); |
| 2300 | UINT32 *src = &fake_accumulationbuffer_bitmap->pix32(y+ycnt, x); |
| 2012 | 2301 | |
| 2013 | 2302 | |
| 2014 | 2303 | for (xcnt=0;xcnt<32;xcnt++) |
| r23710 | r23711 | |
| 2034 | 2323 | int xcnt,ycnt; |
| 2035 | 2324 | for (ycnt=0;ycnt<32;ycnt++) |
| 2036 | 2325 | { |
| 2037 | | UINT32 realwriteoffs = 0x05000000 + writeoffs + (y+ycnt) * (stride<<3) + (x*2); |
| 2038 | | src = &fake_accumulationbuffer_bitmap->pix32(y+ycnt, x); |
| 2326 | UINT32 realwriteoffs = 0x05000000 + fb_w_sof1 + (y+ycnt) * (fb_w_linestride<<3) + (x*2); |
| 2327 | UINT32 *src = &fake_accumulationbuffer_bitmap->pix32(y+ycnt, x); |
| 2039 | 2328 | |
| 2040 | 2329 | |
| 2041 | 2330 | for (xcnt=0;xcnt<32;xcnt++) |
| r23710 | r23711 | |
| 2068 | 2357 | UINT32 c; |
| 2069 | 2358 | UINT32 r,g,b; |
| 2070 | 2359 | |
| 2071 | | UINT32 wc = pvrta_regs[FB_R_CTRL]; |
| 2072 | | UINT8 unpackmode = (wc & 0x0000000c) >>2; // aka fb_depth |
| 2073 | | UINT8 enable = (wc & 0x00000001); |
| 2360 | UINT8 unpackmode = (fb_r_ctrl & 0x0000000c) >>2; // aka fb_depth |
| 2361 | UINT8 enable = (fb_r_ctrl & 0x00000001); |
| 2074 | 2362 | |
| 2075 | 2363 | // ?? |
| 2076 | 2364 | if (!enable) return; |
| 2077 | 2365 | |
| 2078 | 2366 | // only for rgb565 framebuffer |
| 2079 | | xi=((pvrta_regs[FB_R_SIZE] & 0x3ff)+1) << 1; |
| 2080 | | dy=((pvrta_regs[FB_R_SIZE] >> 10) & 0x3ff)+1; |
| 2367 | xi=((fb_r_size & 0x3ff)+1) << 1; |
| 2368 | dy=((fb_r_size >> 10) & 0x3ff)+1; |
| 2081 | 2369 | |
| 2082 | 2370 | dy++; |
| 2083 | 2371 | dy*=2; // probably depends on interlace mode, fields etc... |
| r23710 | r23711 | |
| 2088 | 2376 | // should upsample back to 8-bit output using fb_concat |
| 2089 | 2377 | for (y=0;y <= dy;y++) |
| 2090 | 2378 | { |
| 2091 | | addrp=pvrta_regs[FB_R_SOF1]+y*xi*2; |
| 2092 | | if(spg_pixel_double) |
| 2379 | addrp = fb_r_sof1+y*xi*2; |
| 2380 | if(vo_control & 0x100) |
| 2093 | 2381 | { |
| 2094 | 2382 | for (x=0;x < xi;x++) |
| 2095 | 2383 | { |
| r23710 | r23711 | |
| 2132 | 2420 | // should upsample back to 8-bit output using fb_concat |
| 2133 | 2421 | for (y=0;y <= dy;y++) |
| 2134 | 2422 | { |
| 2135 | | addrp=pvrta_regs[FB_R_SOF1]+y*xi*2; |
| 2136 | | if(spg_pixel_double) |
| 2423 | addrp = fb_r_sof1+y*xi*2; |
| 2424 | if(vo_control & 0x100) |
| 2137 | 2425 | { |
| 2138 | 2426 | for (x=0;x < xi;x++) |
| 2139 | 2427 | { |
| r23710 | r23711 | |
| 2177 | 2465 | case 0x02: ; // 888 RGB 24-bit - suchie3 - HACKED, see pvr_accumulationbuffer_to_framebuffer! |
| 2178 | 2466 | for (y=0;y <= dy;y++) |
| 2179 | 2467 | { |
| 2180 | | addrp=pvrta_regs[FB_R_SOF1]+y*xi*2; |
| 2181 | | if(spg_pixel_double) |
| 2468 | addrp = fb_r_sof1+y*xi*2; |
| 2469 | if(vo_control & 0x100) |
| 2182 | 2470 | { |
| 2183 | 2471 | for (x=0;x < xi;x++) |
| 2184 | 2472 | { |
| r23710 | r23711 | |
| 2221 | 2509 | case 0x03: // 0888 ARGB 32-bit - HACKED, see pvr_accumulationbuffer_to_framebuffer! |
| 2222 | 2510 | for (y=0;y <= dy;y++) |
| 2223 | 2511 | { |
| 2224 | | addrp=pvrta_regs[FB_R_SOF1]+y*xi*2; |
| 2225 | | if(spg_pixel_double) |
| 2512 | addrp = fb_r_sof1+y*xi*2; |
| 2513 | if(vo_control & 0x100) |
| 2226 | 2514 | { |
| 2227 | 2515 | for (x=0;x < xi;x++) |
| 2228 | 2516 | { |
| r23710 | r23711 | |
| 2272 | 2560 | UINT32 r,g,b; |
| 2273 | 2561 | int i; |
| 2274 | 2562 | |
| 2275 | | //popmessage("%02x",pvrta_regs[PAL_RAM_CTRL]); |
| 2563 | //popmessage("%02x",pal_ram_ctrl); |
| 2276 | 2564 | |
| 2277 | 2565 | for(i=0;i<0x400;i++) |
| 2278 | 2566 | { |
| 2279 | | pal = pvrta_regs[((0x005F9000-0x005F8000)/4)+i]; |
| 2280 | | switch(pvrta_regs[PAL_RAM_CTRL]) |
| 2567 | pal = palette[i]; |
| 2568 | switch(pal_ram_ctrl) |
| 2281 | 2569 | { |
| 2282 | 2570 | case 0: //argb1555 <- guilty gear uses this mode |
| 2283 | 2571 | { |
| r23710 | r23711 | |
| 2357 | 2645 | { |
| 2358 | 2646 | irq_cb(VBL_IN_IRQ); |
| 2359 | 2647 | |
| 2360 | | vbin_timer->adjust(machine().primary_screen->time_until_pos(spg_vblank_in_irq_line_num)); |
| 2648 | vbin_timer->adjust(machine().primary_screen->time_until_pos(spg_vblank_int & 0x3ff)); |
| 2361 | 2649 | } |
| 2362 | 2650 | |
| 2363 | 2651 | TIMER_CALLBACK_MEMBER(powervr2_device::vbout) |
| 2364 | 2652 | { |
| 2365 | 2653 | irq_cb(VBL_OUT_IRQ); |
| 2366 | 2654 | |
| 2367 | | vbout_timer->adjust(machine().primary_screen->time_until_pos(spg_vblank_out_irq_line_num)); |
| 2655 | vbout_timer->adjust(machine().primary_screen->time_until_pos((spg_vblank_int >> 16) & 0x3ff)); |
| 2368 | 2656 | } |
| 2369 | 2657 | |
| 2370 | 2658 | TIMER_CALLBACK_MEMBER(powervr2_device::hbin) |
| 2371 | 2659 | { |
| 2372 | | if(spg_hblank_int_mode & 1) |
| 2660 | if(spg_hblank_int & 0x1000) |
| 2373 | 2661 | { |
| 2374 | 2662 | if(scanline == next_y) |
| 2375 | 2663 | { |
| 2376 | 2664 | irq_cb(HBL_IN_IRQ); |
| 2377 | | next_y+=spg_line_comp_val; |
| 2665 | next_y += spg_hblank_int & 0x3ff; |
| 2378 | 2666 | } |
| 2379 | 2667 | } |
| 2380 | | else if((scanline == spg_line_comp_val) || (spg_hblank_int_mode & 2)) |
| 2668 | else if((scanline == (spg_hblank_int & 0x3ff)) || (spg_hblank_int & 0x2000)) |
| 2381 | 2669 | { |
| 2382 | 2670 | irq_cb(HBL_IN_IRQ); |
| 2383 | 2671 | } |
| r23710 | r23711 | |
| 2386 | 2674 | |
| 2387 | 2675 | scanline++; |
| 2388 | 2676 | |
| 2389 | | if(scanline >= spg_vblank_in_irq_line_num) |
| 2677 | if(scanline >= (spg_vblank_int & 0x3ff)) |
| 2390 | 2678 | { |
| 2391 | 2679 | scanline = 0; |
| 2392 | | next_y = spg_line_comp_val; |
| 2680 | next_y = spg_hblank_int & 0x3ff; |
| 2393 | 2681 | } |
| 2394 | 2682 | |
| 2395 | | hbin_timer->adjust(machine().primary_screen->time_until_pos(scanline, spg_hblank_in_irq-1)); |
| 2683 | hbin_timer->adjust(machine().primary_screen->time_until_pos(scanline, ((spg_hblank_int >> 16) & 0x3ff)-1)); |
| 2396 | 2684 | } |
| 2397 | 2685 | |
| 2398 | 2686 | |
| r23710 | r23711 | |
| 2455 | 2743 | } |
| 2456 | 2744 | #endif |
| 2457 | 2745 | |
| 2458 | | bitmap.fill(MAKE_ARGB(0xff,vo_border_R,vo_border_G,vo_border_B), cliprect); //FIXME: Chroma bit? |
| 2746 | bitmap.fill(MAKE_ARGB(0xff, |
| 2747 | (vo_border_col >> 16) & 0xff, |
| 2748 | (vo_border_col >> 8 ) & 0xff, |
| 2749 | (vo_border_col ) & 0xff), cliprect); //FIXME: Chroma bit? |
| 2459 | 2750 | |
| 2460 | | if(!spg_blank_video) |
| 2751 | if(!(vo_control & 8)) |
| 2461 | 2752 | pvr_drawframebuffer(bitmap, cliprect); |
| 2462 | 2753 | |
| 2463 | 2754 | // update this here so we only do string lookup once per frame |
| r23710 | r23711 | |
| 2532 | 2823 | |
| 2533 | 2824 | WRITE32_MEMBER( powervr2_device::pvrs_ta_w ) |
| 2534 | 2825 | { |
| 2535 | | pvr_ta_w(space,offset,data,mem_mask); |
| 2536 | | pvr2_ta_w(space,offset,data,mem_mask); |
| 2826 | // pvr_ta_w(space,offset,data,mem_mask); |
| 2827 | // pvr2_ta_w(space,offset,data,mem_mask); |
| 2537 | 2828 | //printf("PVR2 %08x %08x\n",reg,dat); |
| 2538 | 2829 | } |
| 2539 | 2830 | |
| r23710 | r23711 | |
| 2633 | 2924 | irq_cb.resolve_safe(); |
| 2634 | 2925 | |
| 2635 | 2926 | memset(pvrctrl_regs, 0, sizeof(pvrctrl_regs)); |
| 2636 | | memset(pvrta_regs, 0, sizeof(pvrta_regs)); |
| 2637 | 2927 | memset(grab, 0, sizeof(grab)); |
| 2638 | 2928 | pvr_build_parameterconfig(); |
| 2639 | 2929 | |
| r23710 | r23711 | |
| 2649 | 2939 | |
| 2650 | 2940 | fake_accumulationbuffer_bitmap = auto_bitmap_rgb32_alloc(machine(),1024,1024); |
| 2651 | 2941 | |
| 2942 | softreset = 0; |
| 2943 | param_base = 0; |
| 2944 | region_base = 0; |
| 2945 | vo_border_col = 0; |
| 2946 | fb_r_ctrl = 0; |
| 2947 | fb_w_ctrl = 0; |
| 2948 | fb_w_linestride = 0; |
| 2949 | fb_r_sof1 = 0; |
| 2950 | fb_r_sof2 = 0; |
| 2951 | fb_r_size = 0; |
| 2952 | fb_w_sof1 = 0; |
| 2953 | fb_w_sof2 = 0; |
| 2954 | fb_x_clip = 0; |
| 2955 | fb_y_clip = 0; |
| 2956 | fpu_param_cfg = 0; |
| 2957 | isp_backgnd_t = 0; |
| 2958 | spg_hblank_int = 0; |
| 2959 | spg_vblank_int = 0; |
| 2960 | spg_hblank = 0; |
| 2961 | spg_load = 0; |
| 2962 | spg_vblank = 0; |
| 2963 | spg_width = 0; |
| 2964 | vo_control = 0; |
| 2965 | vo_startx = 0; |
| 2966 | vo_starty = 0; |
| 2967 | text_control = 0; |
| 2968 | pal_ram_ctrl = 0; |
| 2969 | ta_ol_base = 0; |
| 2970 | ta_ol_limit = 0; |
| 2971 | ta_isp_base = 0; |
| 2972 | ta_isp_limit = 0; |
| 2973 | ta_next_opb = 0; |
| 2974 | ta_itp_current = 0; |
| 2975 | ta_alloc_ctrl = 0; |
| 2976 | ta_next_opb_init = 0; |
| 2977 | ta_yuv_tex_base = 0; |
| 2978 | ta_yuv_tex_ctrl = 0; |
| 2979 | ta_yuv_tex_cnt = 0; |
| 2980 | memset(fog_table, 0, sizeof(fog_table)); |
| 2981 | memset(palette, 0, sizeof(palette)); |
| 2982 | |
| 2983 | save_item(NAME(softreset)); |
| 2984 | save_item(NAME(param_base)); |
| 2985 | save_item(NAME(region_base)); |
| 2986 | save_item(NAME(vo_border_col)); |
| 2987 | save_item(NAME(fb_r_ctrl)); |
| 2988 | save_item(NAME(fb_w_ctrl)); |
| 2989 | save_item(NAME(fb_w_linestride)); |
| 2990 | save_item(NAME(fb_r_sof1)); |
| 2991 | save_item(NAME(fb_r_sof2)); |
| 2992 | save_item(NAME(fb_r_size)); |
| 2993 | save_item(NAME(fb_w_sof1)); |
| 2994 | save_item(NAME(fb_w_sof2)); |
| 2995 | save_item(NAME(fb_x_clip)); |
| 2996 | save_item(NAME(fb_y_clip)); |
| 2997 | save_item(NAME(fpu_param_cfg)); |
| 2998 | save_item(NAME(isp_backgnd_t)); |
| 2999 | save_item(NAME(spg_hblank_int)); |
| 3000 | save_item(NAME(spg_vblank_int)); |
| 3001 | save_item(NAME(spg_hblank)); |
| 3002 | save_item(NAME(spg_load)); |
| 3003 | save_item(NAME(spg_vblank)); |
| 3004 | save_item(NAME(spg_width)); |
| 3005 | save_item(NAME(vo_control)); |
| 3006 | save_item(NAME(vo_startx)); |
| 3007 | save_item(NAME(vo_starty)); |
| 3008 | save_item(NAME(text_control)); |
| 3009 | save_item(NAME(pal_ram_ctrl)); |
| 3010 | save_item(NAME(ta_ol_base)); |
| 3011 | save_item(NAME(ta_ol_limit)); |
| 3012 | save_item(NAME(ta_isp_base)); |
| 3013 | save_item(NAME(ta_isp_limit)); |
| 3014 | save_item(NAME(ta_next_opb)); |
| 3015 | save_item(NAME(ta_itp_current)); |
| 3016 | save_item(NAME(ta_alloc_ctrl)); |
| 3017 | save_item(NAME(ta_next_opb_init)); |
| 3018 | save_item(NAME(ta_yuv_tex_base)); |
| 3019 | save_item(NAME(ta_yuv_tex_ctrl)); |
| 3020 | save_item(NAME(ta_yuv_tex_cnt)); |
| 3021 | save_pointer(NAME(fog_table), 0x80); |
| 3022 | save_pointer(NAME(palette), 0x400); |
| 3023 | |
| 2652 | 3024 | save_item(NAME(m_pvr_dma.pvr_addr)); |
| 2653 | 3025 | save_item(NAME(m_pvr_dma.sys_addr)); |
| 2654 | 3026 | save_item(NAME(m_pvr_dma.size)); |
| r23710 | r23711 | |
| 2656 | 3028 | save_item(NAME(m_pvr_dma.dir)); |
| 2657 | 3029 | save_item(NAME(m_pvr_dma.flag)); |
| 2658 | 3030 | save_item(NAME(m_pvr_dma.start)); |
| 2659 | | save_pointer(NAME(pvrta_regs),0x2000/4); |
| 2660 | 3031 | save_pointer(NAME(pvrctrl_regs),0x100/4); |
| 2661 | 3032 | save_item(NAME(debug_dip_status)); |
| 2662 | 3033 | save_pointer(NAME(tafifo_buff),32); |
| r23710 | r23711 | |
| 2666 | 3037 | |
| 2667 | 3038 | void powervr2_device::device_reset() |
| 2668 | 3039 | { |
| 2669 | | pvrta_regs[VO_CONTROL]= 0x00000108; |
| 2670 | | pvrta_regs[SOFTRESET]= 0x00000007; |
| 2671 | | pvrta_regs[VO_STARTX]= 0x0000009d; |
| 2672 | | pvrta_regs[VO_STARTY]= 0x00150015; |
| 2673 | | pvrta_regs[SPG_HBLANK]= 0x007e0345; |
| 2674 | | pvrta_regs[SPG_LOAD]= 0x01060359; |
| 2675 | | pvrta_regs[SPG_VBLANK]= 0x01500104; |
| 2676 | | pvrta_regs[SPG_HBLANK_INT]= 0x031d0000; |
| 2677 | | pvrta_regs[SPG_VBLANK_INT]= 0x01500104; |
| 3040 | softreset = 0x00000007; |
| 3041 | vo_control = 0x00000108; |
| 3042 | vo_startx = 0x0000009d; |
| 3043 | vo_starty = 0x00150015; |
| 3044 | spg_hblank = 0x007e0345; |
| 3045 | spg_load = 0x01060359; |
| 3046 | spg_vblank = 0x01500104; |
| 3047 | spg_hblank_int = 0x031d0000; |
| 3048 | spg_vblank_int = 0x01500104; |
| 2678 | 3049 | |
| 2679 | | // if the next 2 registers do not have the correct values, the naomi bios will hang |
| 2680 | | pvrta_regs[PVRID]=0x17fd11db; |
| 2681 | | pvrta_regs[REVISION]=0x11; |
| 2682 | | |
| 2683 | 3050 | tafifo_pos=0; |
| 2684 | 3051 | tafifo_mask=7; |
| 2685 | 3052 | tafifo_vertexwords=8; |
| r23710 | r23711 | |
| 2688 | 3055 | renderselect= -1; |
| 2689 | 3056 | grabsel=0; |
| 2690 | 3057 | |
| 2691 | | vbout_timer->adjust(machine().primary_screen->time_until_pos(spg_vblank_out_irq_line_num_new)); |
| 2692 | | vbin_timer->adjust(machine().primary_screen->time_until_pos(spg_vblank_in_irq_line_num_new)); |
| 2693 | | hbin_timer->adjust(machine().primary_screen->time_until_pos(0, spg_hblank_in_irq_new-1)); |
| 3058 | vbout_timer->adjust(machine().primary_screen->time_until_pos((spg_vblank_int >> 16) & 0x3ff)); |
| 3059 | vbin_timer->adjust(machine().primary_screen->time_until_pos(spg_vblank_int & 0x3ff)); |
| 3060 | hbin_timer->adjust(machine().primary_screen->time_until_pos(0, ((spg_hblank_int >> 16) & 0x3ff)-1)); |
| 2694 | 3061 | |
| 2695 | 3062 | scanline = 0; |
| 2696 | 3063 | next_y = 0; |