Search
lxdream.org :: lxdream/src/pvr2/pvr2mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2mem.c
changeset 429:e581b90c3fb3
prev352:f0df7a6d4703
next477:9a373f2ff009
author nkeynes
date Mon Oct 08 11:52:13 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Fix compilation warnings
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2mem.c Sun Feb 11 10:09:32 2007 +0000
1.2 +++ b/src/pvr2/pvr2mem.c Mon Oct 08 11:52:13 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: pvr2mem.c,v 1.9 2007-02-11 10:09:32 nkeynes Exp $
1.6 + * $Id: pvr2mem.c,v 1.10 2007-10-08 11:52:13 nkeynes Exp $
1.7 *
1.8 * PVR2 (Video) VRAM handling routines (mainly for the 64-bit region)
1.9 *
1.10 @@ -20,9 +20,9 @@
1.11 #include <stdio.h>
1.12 #include <errno.h>
1.13
1.14 -extern char *video_base;
1.15 +extern unsigned char *video_base;
1.16
1.17 -void pvr2_dma_write( sh4addr_t destaddr, char *src, uint32_t count )
1.18 +void pvr2_dma_write( sh4addr_t destaddr, unsigned char *src, uint32_t count )
1.19 {
1.20 int region;
1.21
1.22 @@ -57,7 +57,7 @@
1.23 }
1.24 }
1.25
1.26 -void pvr2_vram64_write( sh4addr_t destaddr, char *src, uint32_t length )
1.27 +void pvr2_vram64_write( sh4addr_t destaddr, unsigned char *src, uint32_t length )
1.28 {
1.29 int bank_flag = (destaddr & 0x04) >> 2;
1.30 uint32_t *banks[2];
1.31 @@ -80,7 +80,7 @@
1.32
1.33 /* Handle non-aligned start of source */
1.34 if( destaddr & 0x03 ) {
1.35 - char *dest = ((char *)banks[bank_flag]) + (destaddr & 0x03);
1.36 + unsigned char *dest = ((unsigned char *)banks[bank_flag]) + (destaddr & 0x03);
1.37 for( i= destaddr & 0x03; i < 4 && length > 0; i++, length-- ) {
1.38 *dest++ = *src++;
1.39 }
1.40 @@ -96,8 +96,8 @@
1.41
1.42 /* Handle non-aligned end of source */
1.43 if( length ) {
1.44 - src = (char *)dwsrc;
1.45 - char *dest = (char *)banks[bank_flag];
1.46 + src = (unsigned char *)dwsrc;
1.47 + unsigned char *dest = (unsigned char *)banks[bank_flag];
1.48 while( length-- > 0 ) {
1.49 *dest++ = *src++;
1.50 }
1.51 @@ -109,7 +109,7 @@
1.52 * The destaddr must be 32-bit aligned, and both line_bytes and line_stride_bytes
1.53 * must be multiples of 4.
1.54 */
1.55 -void pvr2_vram64_write_stride( sh4addr_t destaddr, char *src, uint32_t line_bytes,
1.56 +void pvr2_vram64_write_stride( sh4addr_t destaddr, unsigned char *src, uint32_t line_bytes,
1.57 uint32_t line_stride_bytes, uint32_t line_count )
1.58 {
1.59 int bank_flag = (destaddr & 0x04) >> 2;
1.60 @@ -155,14 +155,14 @@
1.61 * must be multiples of 4. line_stride_bytes must be >= line_bytes.
1.62 * This method is used to extract a "stride" texture from vram.
1.63 */
1.64 -void pvr2_vram64_read_stride( char *dest, uint32_t dest_line_bytes, sh4addr_t srcaddr,
1.65 +void pvr2_vram64_read_stride( unsigned char *dest, uint32_t dest_line_bytes, sh4addr_t srcaddr,
1.66 uint32_t src_line_bytes, uint32_t line_count )
1.67 {
1.68 int bank_flag = (srcaddr & 0x04) >> 2;
1.69 uint32_t *banks[2];
1.70 uint32_t *dwdest;
1.71 - uint32_t dest_line_gap;
1.72 - uint32_t src_line_gap;
1.73 + uint32_t dest_line_gap = 0;
1.74 + uint32_t src_line_gap = 0;
1.75 uint32_t line_bytes;
1.76 int src_line_gap_flag;
1.77 int i,j;
1.78 @@ -301,13 +301,13 @@
1.79 * @param width image width (must be a power of 2)
1.80 * @param height image height (must be a power of 2)
1.81 */
1.82 -void pvr2_vram64_read_twiddled_4( char *dest, sh4addr_t srcaddr, uint32_t width, uint32_t height )
1.83 +void pvr2_vram64_read_twiddled_4( unsigned char *dest, sh4addr_t srcaddr, uint32_t width, uint32_t height )
1.84 {
1.85 int offset_flag = (srcaddr & 0x07);
1.86 uint8_t *banks[2];
1.87 uint8_t *wdest = (uint8_t*)dest;
1.88 uint32_t stride = width >> 1;
1.89 - int i,j;
1.90 + int i;
1.91
1.92 srcaddr = srcaddr & 0x7FFFF8;
1.93
1.94 @@ -344,12 +344,12 @@
1.95 * @param width image width (must be a power of 2)
1.96 * @param height image height (must be a power of 2)
1.97 */
1.98 -void pvr2_vram64_read_twiddled_8( char *dest, sh4addr_t srcaddr, uint32_t width, uint32_t height )
1.99 +void pvr2_vram64_read_twiddled_8( unsigned char *dest, sh4addr_t srcaddr, uint32_t width, uint32_t height )
1.100 {
1.101 int offset_flag = (srcaddr & 0x07);
1.102 uint8_t *banks[2];
1.103 uint8_t *wdest = (uint8_t*)dest;
1.104 - int i,j;
1.105 + int i;
1.106
1.107 srcaddr = srcaddr & 0x7FFFF8;
1.108
1.109 @@ -386,11 +386,11 @@
1.110 * @param width image width (must be a power of 2)
1.111 * @param height image height (must be a power of 2)
1.112 */
1.113 -void pvr2_vram64_read_twiddled_16( char *dest, sh4addr_t srcaddr, uint32_t width, uint32_t height ) {
1.114 +void pvr2_vram64_read_twiddled_16( unsigned char *dest, sh4addr_t srcaddr, uint32_t width, uint32_t height ) {
1.115 int offset_flag = (srcaddr & 0x06) >> 1;
1.116 uint16_t *banks[2];
1.117 uint16_t *wdest = (uint16_t*)dest;
1.118 - int i,j;
1.119 + int i;
1.120
1.121 srcaddr = srcaddr & 0x7FFFF8;
1.122
1.123 @@ -420,11 +420,11 @@
1.124 }
1.125 }
1.126
1.127 -void pvr2_vram_write_invert( sh4addr_t destaddr, char *src, uint32_t length, uint32_t line_length,
1.128 +void pvr2_vram_write_invert( sh4addr_t destaddr, unsigned char *src, uint32_t length, uint32_t line_length,
1.129 uint32_t src_stride )
1.130 {
1.131 - char *dest = video_base + (destaddr & 0x007FFFFF);
1.132 - char *p = src + length - src_stride;
1.133 + unsigned char *dest = video_base + (destaddr & 0x007FFFFF);
1.134 + unsigned char *p = src + length - src_stride;
1.135 while( p >= src ) {
1.136 memcpy( dest, p, line_length );
1.137 p -= src_stride;
1.138 @@ -432,7 +432,7 @@
1.139 }
1.140 }
1.141
1.142 -void pvr2_vram64_read( char *dest, sh4addr_t srcaddr, uint32_t length )
1.143 +void pvr2_vram64_read( unsigned char *dest, sh4addr_t srcaddr, uint32_t length )
1.144 {
1.145 int bank_flag = (srcaddr & 0x04) >> 2;
1.146 uint32_t *banks[2];
1.147 @@ -466,8 +466,8 @@
1.148
1.149 /* Handle non-aligned end of source */
1.150 if( length ) {
1.151 - dest = (char *)dwdest;
1.152 - char *src = (char *)banks[bank_flag];
1.153 + dest = (unsigned char *)dwdest;
1.154 + unsigned char *src = (unsigned char *)banks[bank_flag];
1.155 while( length-- > 0 ) {
1.156 *dest++ = *src++;
1.157 }
1.158 @@ -484,7 +484,7 @@
1.159 ERROR( "Unable to write to dump file '%s' (%s)", filename, strerror(errno) );
1.160 return;
1.161 }
1.162 - pvr2_vram64_read( (char *)tmp, addr, length );
1.163 + pvr2_vram64_read( (unsigned char *)tmp, addr, length );
1.164 fprintf( f, "%08X\n", addr );
1.165 for( i =0; i<length>>2; i+=8 ) {
1.166 for( j=i; j<i+8; j++ ) {
1.167 @@ -500,7 +500,7 @@
1.168
1.169 void pvr2_vram64_dump( sh4addr_t addr, uint32_t length, FILE *f )
1.170 {
1.171 - char tmp[length];
1.172 + unsigned char tmp[length];
1.173 pvr2_vram64_read( tmp, addr, length );
1.174 fwrite_dump( tmp, length, f );
1.175 }
1.176 @@ -518,14 +518,14 @@
1.177 */
1.178 void pvr2_render_buffer_copy_to_sh4( render_buffer_t buffer )
1.179 {
1.180 - if( buffer->address & 0xFF000000 == 0x04000000 ) {
1.181 + if( (buffer->address & 0xFF000000) == 0x04000000 ) {
1.182 /* Interlaced buffer. Go the double copy... :( */
1.183 - char target[buffer->size];
1.184 + unsigned char target[buffer->size];
1.185 display_driver->read_render_buffer( buffer, target );
1.186 pvr2_vram64_write( buffer->address, target, buffer->size );
1.187 } else {
1.188 /* Regular buffer */
1.189 - char target[buffer->size];
1.190 + unsigned char target[buffer->size];
1.191 int line_size = buffer->width * colour_formats[buffer->colour_format].bpp;
1.192 display_driver->read_render_buffer( buffer, target );
1.193 if( (buffer->scale & 0xFFFF) == 0x0800 ) {
.