Search
lxdream.org :: lxdream/src/pvr2/pvr2.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2.c
changeset 337:cdd757aa8e8c
prev335:fb890e1814c0
next352:f0df7a6d4703
author nkeynes
date Sun Jan 28 11:36:00 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Invalidate palette textures when the palette changes (fixes a few texture
bugs)
Fix odd/even selection in pvr2_display_frame
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2.c Sat Jan 27 12:03:53 2007 +0000
1.2 +++ b/src/pvr2/pvr2.c Sun Jan 28 11:36:00 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: pvr2.c,v 1.42 2007-01-27 12:03:53 nkeynes Exp $
1.6 + * $Id: pvr2.c,v 1.43 2007-01-28 11:36:00 nkeynes Exp $
1.7 *
1.8 * PVR2 (Video) Core module implementation and MMIO registers.
1.9 *
1.10 @@ -75,6 +75,7 @@
1.11 uint32_t irq_vpos1;
1.12 uint32_t irq_vpos2;
1.13 uint32_t odd_even_field; /* 1 = odd, 0 = even */
1.14 + gboolean palette_changed; /* TRUE if palette has changed since last render */
1.15 gchar *save_next_render_filename;
1.16 /* timing */
1.17 uint32_t dot_clock;
1.18 @@ -149,6 +150,7 @@
1.19 pvr2_state.timing = ntsc_timing;
1.20 pvr2_state.dot_clock = PVR2_DOT_CLOCK;
1.21 pvr2_state.back_porch_ns = 4000;
1.22 + pvr2_state.palette_changed = FALSE;
1.23 mmio_region_PVR2_write( DISP_TOTAL, 0x0270035F );
1.24 mmio_region_PVR2_write( DISP_SYNCTIME, 0x07D6A53F );
1.25 mmio_region_PVR2_write( YUV_ADDR, 0 );
1.26 @@ -204,6 +206,7 @@
1.27 if( pvr2_state.line_count >= pvr2_state.retrace_end_line &&
1.28 (old_line_count < pvr2_state.retrace_end_line ||
1.29 old_line_count > pvr2_state.line_count) ) {
1.30 + pvr2_state.frame_count++;
1.31 pvr2_display_frame();
1.32 }
1.33 }
1.34 @@ -259,8 +262,16 @@
1.35 buffer->vres <<= 1;
1.36 buffer->rowstride = vid_ppl << 2;
1.37 display_addr = MMIO_READ( PVR2, DISP_ADDR1 );
1.38 - } else { /* Just display the field as is, folks */
1.39 - if( pvr2_state.odd_even_field ) {
1.40 + } else {
1.41 + /* Just display the field as is, folks. This is slightly tricky -
1.42 + * we pick the field based on which frame is about to come through,
1.43 + * which may not be the same as the odd_even_field.
1.44 + */
1.45 + gboolean oddfield = pvr2_state.odd_even_field;
1.46 + if( pvr2_state.line_count >= pvr2_state.retrace_start_line ) {
1.47 + oddfield = !oddfield;
1.48 + }
1.49 + if( oddfield ) {
1.50 display_addr = MMIO_READ( PVR2, DISP_ADDR1 );
1.51 } else {
1.52 display_addr = MMIO_READ( PVR2, DISP_ADDR2 );
1.53 @@ -308,7 +319,6 @@
1.54 display_driver->display_frame( buffer );
1.55 }
1.56 }
1.57 - pvr2_state.frame_count++;
1.58 }
1.59
1.60 /**
1.61 @@ -362,14 +372,23 @@
1.62 case DISP_ADDR1:
1.63 val &= 0x00FFFFFC;
1.64 MMIO_WRITE( PVR2, reg, val );
1.65 + /*
1.66 pvr2_update_raster_posn(sh4r.slice_cycle);
1.67 - if( pvr2_state.line_count >= pvr2_state.retrace_start_line ||
1.68 - pvr2_state.line_count < pvr2_state.retrace_end_line ) {
1.69 + fprintf( stderr, "Set Field 1 addr: %08X\n", val );
1.70 + if( (pvr2_state.line_count >= pvr2_state.retrace_start_line && !pvr2_state.odd_even_field) ||
1.71 + (pvr2_state.line_count < pvr2_state.retrace_end_line && pvr2_state.odd_even_field) ) {
1.72 pvr2_display_frame();
1.73 }
1.74 + */
1.75 break;
1.76 case DISP_ADDR2:
1.77 MMIO_WRITE( PVR2, reg, val&0x00FFFFFC );
1.78 + pvr2_update_raster_posn(sh4r.slice_cycle);
1.79 + /*
1.80 + if( (pvr2_state.line_count >= pvr2_state.retrace_start_line && pvr2_state.odd_even_field) ||
1.81 + (pvr2_state.line_count < pvr2_state.retrace_end_line && !pvr2_state.odd_even_field) ) {
1.82 + pvr2_display_frame();
1.83 + }*/
1.84 break;
1.85 case DISP_SIZE:
1.86 MMIO_WRITE( PVR2, reg, val&0x3FFFFFFF );
1.87 @@ -669,7 +688,21 @@
1.88 }
1.89 }
1.90
1.91 -MMIO_REGION_DEFFNS( PVR2PAL )
1.92 +MMIO_REGION_WRITE_FN( PVR2PAL, reg, val )
1.93 +{
1.94 + MMIO_WRITE( PVR2PAL, reg, val );
1.95 + pvr2_state.palette_changed = TRUE;
1.96 +}
1.97 +
1.98 +void pvr2_check_palette_changed()
1.99 +{
1.100 + if( pvr2_state.palette_changed ) {
1.101 + texcache_invalidate_palette();
1.102 + pvr2_state.palette_changed = FALSE;
1.103 + }
1.104 +}
1.105 +
1.106 +MMIO_REGION_READ_DEFFN( PVR2PAL );
1.107
1.108 void pvr2_set_base_address( uint32_t base )
1.109 {
.