Search
lxdream.org :: lxdream/src/pvr2/pvr2mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2mem.c
changeset 857:3d8944884eaa
prev856:02ac5f37bfc9
next869:b6f38c7ee7a3
author nkeynes
date Fri Sep 12 05:36:00 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Implement write-back with the hscaler enabled
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2mem.c Thu Sep 11 22:51:24 2008 +0000
1.2 +++ b/src/pvr2/pvr2mem.c Fri Sep 12 05:36:00 2008 +0000
1.3 @@ -430,15 +430,40 @@
1.4 }
1.5 }
1.6
1.7 -void pvr2_vram_write_invert( sh4addr_t destaddr, unsigned char *src, uint32_t length, uint32_t line_length,
1.8 +static void pvr2_vram_write_invert( sh4addr_t destaddr, unsigned char *src, uint32_t src_size,
1.9 + uint32_t line_size, uint32_t dest_stride,
1.10 uint32_t src_stride )
1.11 {
1.12 unsigned char *dest = video_base + (destaddr & 0x007FFFFF);
1.13 - unsigned char *p = src + length - src_stride;
1.14 + unsigned char *p = src + src_size - src_stride;
1.15 while( p >= src ) {
1.16 - memcpy( dest, p, line_length );
1.17 + memcpy( dest, p, line_size );
1.18 p -= src_stride;
1.19 - dest += line_length;
1.20 + dest += dest_stride;
1.21 + }
1.22 +}
1.23 +
1.24 +/**
1.25 + * Copy a pixel buffer to vram, flipping and scaling at the same time. This
1.26 + * is not massively efficient, but it's used pretty rarely.
1.27 + */
1.28 +static void pvr2_vram_write_invert_hscale( sh4addr_t destaddr, unsigned char *src, uint32_t src_size,
1.29 + uint32_t line_size, uint32_t dest_stride,
1.30 + uint32_t src_stride, int bpp )
1.31 +{
1.32 + unsigned char *dest = video_base + (destaddr & 0x007FFFFF);
1.33 + unsigned char *p = src + src_size - src_stride;
1.34 + while( p >= src ) {
1.35 + unsigned char *s = p, *d = dest;
1.36 + int i;
1.37 + while( s < p+line_size ) {
1.38 + for( i=0; i<bpp; i++ ) {
1.39 + *d++ = *s++;
1.40 + }
1.41 + s+= bpp;
1.42 + }
1.43 + p -= src_stride;
1.44 + dest += dest_stride;
1.45 }
1.46 }
1.47
1.48 @@ -535,13 +560,21 @@
1.49 pvr2_vram64_write( buffer->address, target, buffer->size );
1.50 } else {
1.51 /* Regular buffer */
1.52 - unsigned char target[buffer->size];
1.53 int line_size = buffer->width * colour_formats[buffer->colour_format].bpp;
1.54 - display_driver->read_render_buffer( target, buffer, buffer->rowstride, buffer->colour_format );
1.55 - if( (buffer->scale & 0xFFFF) == 0x0800 ) {
1.56 - pvr2_vram_write_invert( buffer->address, target, buffer->size, line_size, line_size << 1 );
1.57 + int src_stride = line_size;
1.58 + if( (buffer->scale & 0xFFFF) == 0x0800 )
1.59 + src_stride <<= 1;
1.60 +
1.61 + if( buffer->scale & SCALER_HSCALE ) {
1.62 + unsigned char target[buffer->size];
1.63 + display_driver->read_render_buffer( target, buffer, line_size, buffer->colour_format );
1.64 + pvr2_vram_write_invert_hscale( buffer->address, target, buffer->size, line_size, buffer->rowstride,
1.65 + src_stride, colour_formats[buffer->colour_format].bpp );
1.66 } else {
1.67 - pvr2_vram_write_invert( buffer->address, target, buffer->size, line_size, line_size );
1.68 + unsigned char target[buffer->size];
1.69 + display_driver->read_render_buffer( target, buffer, line_size, buffer->colour_format );
1.70 + pvr2_vram_write_invert( buffer->address, target, buffer->size, line_size, buffer->rowstride,
1.71 + src_stride );
1.72 }
1.73 }
1.74 buffer->flushed = TRUE;
.