Search
lxdream.org :: lxdream :: r674:377d987db8f2
lxdream 0.9.1
released Jun 29
Download Now
changeset674:377d987db8f2
parent673:44c579439d73
child675:b97020f9af1c
authornkeynes
dateMon May 26 10:42:18 2008 +0000 (11 years ago)
Fix save states for x86-64, and ensure compatibility between 32-bit and 64-bit versions
src/display.h
src/eventq.c
src/mem.c
src/mmio.h
src/pvr2/pvr2.c
src/pvr2/tacore.c
src/pvr2/yuv.c
src/sh4/sh4.h
src/util.c
1.1 --- a/src/display.h Sun May 25 21:01:55 2008 +0000
1.2 +++ b/src/display.h Mon May 26 10:42:18 2008 +0000
1.3 @@ -67,11 +67,11 @@
1.4 uint32_t width;
1.5 uint32_t height;
1.6 uint32_t rowstride;
1.7 - int colour_format;
1.8 + uint32_t colour_format;
1.9 sh4addr_t address; /* Address buffer was rendered to, or -1 for unrendered */
1.10 uint32_t size; /* Size of buffer in bytes, must be width*height*bpp */
1.11 gboolean inverted;/* True if the buffer is upside down */
1.12 - int scale;
1.13 + uint32_t scale;
1.14 unsigned int buf_id; /* driver-specific buffer id, if applicable */
1.15 gboolean flushed; /* True if the buffer has been flushed to vram */
1.16 };
1.17 @@ -84,7 +84,7 @@
1.18 uint32_t width;
1.19 uint32_t height;
1.20 uint32_t rowstride;
1.21 - int colour_format;
1.22 + uint32_t colour_format;
1.23 sh4addr_t address;
1.24 uint32_t size; /* Size of buffer in bytes, must be width*height*bpp */
1.25 gboolean inverted;/* True if the buffer is upside down */
2.1 --- a/src/eventq.c Sun May 25 21:01:55 2008 +0000
2.2 +++ b/src/eventq.c Mon May 26 10:42:18 2008 +0000
2.3 @@ -255,7 +255,7 @@
2.4
2.5 void event_save_state( FILE *f )
2.6 {
2.7 - int id, i;
2.8 + int32_t id, i;
2.9 id = event_head == NULL ? -1 : event_head->id;
2.10 fwrite( &id, sizeof(id), 1, f );
2.11 id = long_event_head == NULL ? -1 : long_event_head->id;
2.12 @@ -270,7 +270,7 @@
2.13
2.14 int event_load_state( FILE *f )
2.15 {
2.16 - int id, i;
2.17 + int32_t id, i;
2.18 fread( &id, sizeof(id), 1, f );
2.19 event_head = id == -1 ? NULL : &events[id];
2.20 fread( &id, sizeof(id), 1, f );
3.1 --- a/src/mem.c Sun May 25 21:01:55 2008 +0000
3.2 +++ b/src/mem.c Mon May 26 10:42:18 2008 +0000
3.3 @@ -46,7 +46,7 @@
3.4 struct mmio_region *io_rgn[MAX_IO_REGIONS];
3.5 struct mmio_region *P4_io[4096];
3.6
3.7 -uintptr_t num_io_rgns = 0, num_mem_rgns = 0;
3.8 +uint32_t num_io_rgns = 0, num_mem_rgns = 0;
3.9
3.10 void *mem_alloc_pages( int n )
3.11 {
3.12 @@ -332,7 +332,7 @@
3.13 /* P4 area (on-chip I/O channels */
3.14 P4_io[(io->base&0x1FFFFFFF)>>19] = io;
3.15 } else {
3.16 - page_map[io->base>>12] = (sh4ptr_t )num_io_rgns;
3.17 + page_map[io->base>>12] = (sh4ptr_t)(uintptr_t)num_io_rgns;
3.18 }
3.19 io_rgn[num_io_rgns] = io;
3.20 num_io_rgns++;
4.1 --- a/src/mmio.h Sun May 25 21:01:55 2008 +0000
4.2 +++ b/src/mmio.h Mon May 26 10:42:18 2008 +0000
4.3 @@ -65,7 +65,7 @@
4.4 void register_io_regions( struct mmio_region **mmiolist );
4.5
4.6 extern struct mmio_region *io_rgn[];
4.7 -extern uintptr_t num_io_rgns;
4.8 +extern uint32_t num_io_rgns;
4.9
4.10 #define MMIO_READ( id, r ) *((int32_t *)(mmio_region_##id.mem + (r)))
4.11 #define MMIO_READF( id, r ) *((float *)(mmio_region_##id.mem + (r)))
5.1 --- a/src/pvr2/pvr2.c Sun May 25 21:01:55 2008 +0000
5.2 +++ b/src/pvr2/pvr2.c Mon May 26 10:42:18 2008 +0000
5.3 @@ -72,8 +72,8 @@
5.4 uint32_t irq_vpos1;
5.5 uint32_t irq_vpos2;
5.6 uint32_t odd_even_field; /* 1 = odd, 0 = even */
5.7 - gboolean palette_changed; /* TRUE if palette has changed since last render */
5.8 - gchar *save_next_render_filename;
5.9 + int32_t palette_changed; /* TRUE if palette has changed since last render */
5.10 + uint32_t padding; /* FIXME: Remove in next DST version */
5.11 /* timing */
5.12 uint32_t dot_clock;
5.13 uint32_t total_lines;
5.14 @@ -85,11 +85,12 @@
5.15 uint32_t back_porch_ns;
5.16 uint32_t retrace_start_line;
5.17 uint32_t retrace_end_line;
5.18 - gboolean interlaced;
5.19 + int32_t interlaced;
5.20 } pvr2_state;
5.21
5.22 +static gchar *save_next_render_filename;
5.23 static render_buffer_t render_buffers[MAX_RENDER_BUFFERS];
5.24 -static int render_buffer_count = 0;
5.25 +static uint32_t render_buffer_count = 0;
5.26 static render_buffer_t displayed_render_buffer = NULL;
5.27 static uint32_t displayed_border_colour = 0;
5.28
5.29 @@ -136,7 +137,7 @@
5.30 texcache_init();
5.31 pvr2_reset();
5.32 pvr2_ta_reset();
5.33 - pvr2_state.save_next_render_filename = NULL;
5.34 + save_next_render_filename = NULL;
5.35 for( i=0; i<MAX_RENDER_BUFFERS; i++ ) {
5.36 render_buffers[i] = NULL;
5.37 }
5.38 @@ -192,7 +193,8 @@
5.39 fwrite( &buffer->colour_format, sizeof(buffer->colour_format), 1, f );
5.40 fwrite( &buffer->address, sizeof(buffer->address), 1, f );
5.41 fwrite( &buffer->scale, sizeof(buffer->scale), 1, f );
5.42 - fwrite( &buffer->flushed, sizeof(buffer->flushed), 1, f );
5.43 + int32_t flushed = (int32_t)buffer->flushed; // Force to 32-bits for save-file consistency
5.44 + fwrite( &flushed, sizeof(flushed), 1, f );
5.45
5.46 }
5.47
5.48 @@ -205,15 +207,17 @@
5.49
5.50 render_buffer_t buffer = pvr2_frame_buffer_to_render_buffer(frame);
5.51 if( buffer != NULL ) {
5.52 + int32_t flushed;
5.53 fread( &buffer->rowstride, sizeof(buffer->rowstride), 1, f );
5.54 fread( &buffer->colour_format, sizeof(buffer->colour_format), 1, f );
5.55 fread( &buffer->address, sizeof(buffer->address), 1, f );
5.56 fread( &buffer->scale, sizeof(buffer->scale), 1, f );
5.57 - fread( &buffer->flushed, sizeof(buffer->flushed), 1, f );
5.58 + fread( &flushed, sizeof(flushed), 1, f );
5.59 + buffer->flushed = (gboolean)flushed;
5.60 } else {
5.61 fseek( f, sizeof(buffer->rowstride)+sizeof(buffer->colour_format)+
5.62 sizeof(buffer->address)+sizeof(buffer->scale)+
5.63 - sizeof(buffer->flushed), SEEK_CUR );
5.64 + sizeof(int32_t), SEEK_CUR );
5.65 }
5.66 return buffer;
5.67 }
5.68 @@ -224,14 +228,15 @@
5.69 void pvr2_save_render_buffers( FILE *f )
5.70 {
5.71 int i;
5.72 + uint32_t has_frontbuffer;
5.73 fwrite( &render_buffer_count, sizeof(render_buffer_count), 1, f );
5.74 if( displayed_render_buffer != NULL ) {
5.75 - i = 1;
5.76 - fwrite( &i, sizeof(i), 1, f );
5.77 + has_frontbuffer = 1;
5.78 + fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );
5.79 pvr2_save_render_buffer( f, displayed_render_buffer );
5.80 } else {
5.81 - i = 0;
5.82 - fwrite( &i, sizeof(i), 1, f );
5.83 + has_frontbuffer = 0;
5.84 + fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );
5.85 }
5.86
5.87 for( i=0; i<render_buffer_count; i++ ) {
5.88 @@ -243,8 +248,8 @@
5.89
5.90 gboolean pvr2_load_render_buffers( FILE *f )
5.91 {
5.92 - uint32_t count;
5.93 - int i, has_frontbuffer;
5.94 + uint32_t count, has_frontbuffer;
5.95 + int i;
5.96
5.97 fread( &count, sizeof(count), 1, f );
5.98 if( count > MAX_RENDER_BUFFERS ) {
5.99 @@ -346,10 +351,10 @@
5.100
5.101 gboolean pvr2_save_next_scene( const gchar *filename )
5.102 {
5.103 - if( pvr2_state.save_next_render_filename != NULL ) {
5.104 - g_free( pvr2_state.save_next_render_filename );
5.105 + if( save_next_render_filename != NULL ) {
5.106 + g_free( save_next_render_filename );
5.107 }
5.108 - pvr2_state.save_next_render_filename = g_strdup(filename);
5.109 + save_next_render_filename = g_strdup(filename);
5.110 return TRUE;
5.111 }
5.112
5.113 @@ -451,12 +456,12 @@
5.114 MMIO_WRITE( PVR2, reg, val );
5.115 break;
5.116 case RENDER_START: /* Don't really care what value */
5.117 - if( pvr2_state.save_next_render_filename != NULL ) {
5.118 - if( pvr2_render_save_scene(pvr2_state.save_next_render_filename) == 0 ) {
5.119 - INFO( "Saved scene to %s", pvr2_state.save_next_render_filename);
5.120 + if( save_next_render_filename != NULL ) {
5.121 + if( pvr2_render_save_scene(save_next_render_filename) == 0 ) {
5.122 + INFO( "Saved scene to %s", save_next_render_filename);
5.123 }
5.124 - g_free( pvr2_state.save_next_render_filename );
5.125 - pvr2_state.save_next_render_filename = NULL;
5.126 + g_free( save_next_render_filename );
5.127 + save_next_render_filename = NULL;
5.128 }
5.129 pvr2_scene_read();
5.130 render_buffer_t buffer = pvr2_next_render_buffer();
6.1 --- a/src/pvr2/tacore.c Sun May 25 21:01:55 2008 +0000
6.2 +++ b/src/pvr2/tacore.c Mon May 26 10:42:18 2008 +0000
6.3 @@ -127,39 +127,39 @@
6.4 };
6.5
6.6 struct tile_bounds {
6.7 - int x1, y1, x2, y2;
6.8 + int32_t x1, y1, x2, y2;
6.9 };
6.10
6.11 struct pvr2_ta_status {
6.12 - int state;
6.13 - int width, height; /* Tile resolution, ie 20x15 */
6.14 - int tilelist_dir; /* Growth direction of the tilelist, 0 = up, 1 = down */
6.15 + int32_t state;
6.16 + int32_t width, height; /* Tile resolution, ie 20x15 */
6.17 + int32_t tilelist_dir; /* Growth direction of the tilelist, 0 = up, 1 = down */
6.18 uint32_t tilelist_size; /* Size of the tilelist segments */
6.19 uint32_t tilelist_start; /* Initial address of the tilelist */
6.20 - int polybuf_start; /* Initial bank address of the polygon buffer (ie &0x00F00000) */
6.21 - int current_vertex_type;
6.22 - gboolean accept_vertexes;
6.23 - int vertex_count; /* index of last start-vertex seen, or -1 if no vertexes
6.24 + uint32_t polybuf_start; /* Initial bank address of the polygon buffer (ie &0x00F00000) */
6.25 + int32_t current_vertex_type;
6.26 + uint32_t accept_vertexes; /* 0 = NO, 1 = YES */
6.27 + int32_t vertex_count; /* index of last start-vertex seen, or -1 if no vertexes
6.28 * are present
6.29 */
6.30 - int max_vertex; /* Maximum number of vertexes in the current polygon (3/4/6/8) */
6.31 - int current_list_type;
6.32 + uint32_t max_vertex; /* Maximum number of vertexes in the current polygon (3/4/6/8) */
6.33 + uint32_t current_list_type;
6.34 uint32_t current_tile_matrix; /* Memory location of the first tile for the current list. */
6.35 uint32_t current_tile_size; /* Size of the tile matrix space in 32-bit words (0/8/16/32)*/
6.36 uint32_t intensity1, intensity2;
6.37 struct tile_bounds clip;
6.38 - int clip_mode;
6.39 + int32_t clip_mode;
6.40 /**
6.41 * Current working object
6.42 */
6.43 - int poly_context_size;
6.44 - int poly_vertex_size;
6.45 - int poly_parity;
6.46 + int32_t poly_context_size;
6.47 + int32_t poly_vertex_size;
6.48 + int32_t poly_parity;
6.49 uint32_t poly_context[5];
6.50 uint32_t poly_pointer;
6.51 struct tile_bounds last_triangle_bounds;
6.52 struct pvr2_ta_vertex poly_vertex[8];
6.53 - int debug_output;
6.54 + uint32_t debug_output;
6.55 };
6.56
6.57 static struct pvr2_ta_status ta_status;
7.1 --- a/src/pvr2/yuv.c Sun May 25 21:01:55 2008 +0000
7.2 +++ b/src/pvr2/yuv.c Mon May 26 10:42:18 2008 +0000
7.3 @@ -30,12 +30,12 @@
7.4
7.5 struct yuv_state {
7.6 uint32_t target;
7.7 - int width;
7.8 - int height;
7.9 - int input_format;
7.10 + uint32_t width;
7.11 + uint32_t height;
7.12 + uint32_t input_format;
7.13 unsigned char data[512];
7.14 - int data_length;
7.15 - int x, y;
7.16 + uint32_t data_length;
7.17 + uint32_t x, y;
7.18 } pvr2_yuv_state;
7.19
7.20 /**
8.1 --- a/src/sh4/sh4.h Sun May 25 21:01:55 2008 +0000
8.2 +++ b/src/sh4/sh4.h Mon May 26 10:42:18 2008 +0000
8.3 @@ -70,7 +70,7 @@
8.4 int32_t i;
8.5 float f;
8.6 } fpul;
8.7 - float *pad;
8.8 + uint32_t pad; // FIXME: remove in next DST version
8.9 float fr[2][16];
8.10 uint64_t mac;
8.11 uint32_t gbr, ssr, spc, sgr, dbr, vbr;
9.1 --- a/src/util.c Sun May 25 21:01:55 2008 +0000
9.2 +++ b/src/util.c Mon May 26 10:42:18 2008 +0000
9.3 @@ -88,7 +88,8 @@
9.4 unsigned char *tmp = g_malloc0( csize );
9.5 int status = compress( tmp, &csize, p, size );
9.6 assert( status == Z_OK );
9.7 - fwrite( &csize, sizeof(csize), 1, f );
9.8 + uint32_t wsize = (uint32_t)csize;
9.9 + fwrite( &wsize, sizeof(wsize), 1, f );
9.10 fwrite( tmp, csize, 1, f );
9.11 g_free(tmp);
9.12 }
9.13 @@ -96,7 +97,7 @@
9.14 int fread_gzip( void *p, size_t sz, size_t count, FILE *f )
9.15 {
9.16 uLongf size = sz*count;
9.17 - uLongf csize;
9.18 + uint32_t csize;
9.19 unsigned char *tmp;
9.20
9.21 fread( &csize, sizeof(csize), 1, f );
.