Search
lxdream.org :: lxdream/src/pvr2/pvr2.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2.c
changeset 674:377d987db8f2
prev669:ab344e42bca9
next677:3ee62740ff8f
author nkeynes
date Mon May 26 10:42:18 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Fix save states for x86-64, and ensure compatibility between 32-bit and 64-bit versions
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2.c Mon May 12 10:00:13 2008 +0000
1.2 +++ b/src/pvr2/pvr2.c Mon May 26 10:42:18 2008 +0000
1.3 @@ -72,8 +72,8 @@
1.4 uint32_t irq_vpos1;
1.5 uint32_t irq_vpos2;
1.6 uint32_t odd_even_field; /* 1 = odd, 0 = even */
1.7 - gboolean palette_changed; /* TRUE if palette has changed since last render */
1.8 - gchar *save_next_render_filename;
1.9 + int32_t palette_changed; /* TRUE if palette has changed since last render */
1.10 + uint32_t padding; /* FIXME: Remove in next DST version */
1.11 /* timing */
1.12 uint32_t dot_clock;
1.13 uint32_t total_lines;
1.14 @@ -85,11 +85,12 @@
1.15 uint32_t back_porch_ns;
1.16 uint32_t retrace_start_line;
1.17 uint32_t retrace_end_line;
1.18 - gboolean interlaced;
1.19 + int32_t interlaced;
1.20 } pvr2_state;
1.21
1.22 +static gchar *save_next_render_filename;
1.23 static render_buffer_t render_buffers[MAX_RENDER_BUFFERS];
1.24 -static int render_buffer_count = 0;
1.25 +static uint32_t render_buffer_count = 0;
1.26 static render_buffer_t displayed_render_buffer = NULL;
1.27 static uint32_t displayed_border_colour = 0;
1.28
1.29 @@ -136,7 +137,7 @@
1.30 texcache_init();
1.31 pvr2_reset();
1.32 pvr2_ta_reset();
1.33 - pvr2_state.save_next_render_filename = NULL;
1.34 + save_next_render_filename = NULL;
1.35 for( i=0; i<MAX_RENDER_BUFFERS; i++ ) {
1.36 render_buffers[i] = NULL;
1.37 }
1.38 @@ -192,7 +193,8 @@
1.39 fwrite( &buffer->colour_format, sizeof(buffer->colour_format), 1, f );
1.40 fwrite( &buffer->address, sizeof(buffer->address), 1, f );
1.41 fwrite( &buffer->scale, sizeof(buffer->scale), 1, f );
1.42 - fwrite( &buffer->flushed, sizeof(buffer->flushed), 1, f );
1.43 + int32_t flushed = (int32_t)buffer->flushed; // Force to 32-bits for save-file consistency
1.44 + fwrite( &flushed, sizeof(flushed), 1, f );
1.45
1.46 }
1.47
1.48 @@ -205,15 +207,17 @@
1.49
1.50 render_buffer_t buffer = pvr2_frame_buffer_to_render_buffer(frame);
1.51 if( buffer != NULL ) {
1.52 + int32_t flushed;
1.53 fread( &buffer->rowstride, sizeof(buffer->rowstride), 1, f );
1.54 fread( &buffer->colour_format, sizeof(buffer->colour_format), 1, f );
1.55 fread( &buffer->address, sizeof(buffer->address), 1, f );
1.56 fread( &buffer->scale, sizeof(buffer->scale), 1, f );
1.57 - fread( &buffer->flushed, sizeof(buffer->flushed), 1, f );
1.58 + fread( &flushed, sizeof(flushed), 1, f );
1.59 + buffer->flushed = (gboolean)flushed;
1.60 } else {
1.61 fseek( f, sizeof(buffer->rowstride)+sizeof(buffer->colour_format)+
1.62 sizeof(buffer->address)+sizeof(buffer->scale)+
1.63 - sizeof(buffer->flushed), SEEK_CUR );
1.64 + sizeof(int32_t), SEEK_CUR );
1.65 }
1.66 return buffer;
1.67 }
1.68 @@ -224,14 +228,15 @@
1.69 void pvr2_save_render_buffers( FILE *f )
1.70 {
1.71 int i;
1.72 + uint32_t has_frontbuffer;
1.73 fwrite( &render_buffer_count, sizeof(render_buffer_count), 1, f );
1.74 if( displayed_render_buffer != NULL ) {
1.75 - i = 1;
1.76 - fwrite( &i, sizeof(i), 1, f );
1.77 + has_frontbuffer = 1;
1.78 + fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );
1.79 pvr2_save_render_buffer( f, displayed_render_buffer );
1.80 } else {
1.81 - i = 0;
1.82 - fwrite( &i, sizeof(i), 1, f );
1.83 + has_frontbuffer = 0;
1.84 + fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );
1.85 }
1.86
1.87 for( i=0; i<render_buffer_count; i++ ) {
1.88 @@ -243,8 +248,8 @@
1.89
1.90 gboolean pvr2_load_render_buffers( FILE *f )
1.91 {
1.92 - uint32_t count;
1.93 - int i, has_frontbuffer;
1.94 + uint32_t count, has_frontbuffer;
1.95 + int i;
1.96
1.97 fread( &count, sizeof(count), 1, f );
1.98 if( count > MAX_RENDER_BUFFERS ) {
1.99 @@ -346,10 +351,10 @@
1.100
1.101 gboolean pvr2_save_next_scene( const gchar *filename )
1.102 {
1.103 - if( pvr2_state.save_next_render_filename != NULL ) {
1.104 - g_free( pvr2_state.save_next_render_filename );
1.105 + if( save_next_render_filename != NULL ) {
1.106 + g_free( save_next_render_filename );
1.107 }
1.108 - pvr2_state.save_next_render_filename = g_strdup(filename);
1.109 + save_next_render_filename = g_strdup(filename);
1.110 return TRUE;
1.111 }
1.112
1.113 @@ -451,12 +456,12 @@
1.114 MMIO_WRITE( PVR2, reg, val );
1.115 break;
1.116 case RENDER_START: /* Don't really care what value */
1.117 - if( pvr2_state.save_next_render_filename != NULL ) {
1.118 - if( pvr2_render_save_scene(pvr2_state.save_next_render_filename) == 0 ) {
1.119 - INFO( "Saved scene to %s", pvr2_state.save_next_render_filename);
1.120 + if( save_next_render_filename != NULL ) {
1.121 + if( pvr2_render_save_scene(save_next_render_filename) == 0 ) {
1.122 + INFO( "Saved scene to %s", save_next_render_filename);
1.123 }
1.124 - g_free( pvr2_state.save_next_render_filename );
1.125 - pvr2_state.save_next_render_filename = NULL;
1.126 + g_free( save_next_render_filename );
1.127 + save_next_render_filename = NULL;
1.128 }
1.129 pvr2_scene_read();
1.130 render_buffer_t buffer = pvr2_next_render_buffer();
.