Search
lxdream.org :: lxdream/src/pvr2/pvr2.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2.c
changeset 736:a02d1475ccfd
prev728:4dfc293b9d96
next805:b355f7b3ff2e
author nkeynes
date Mon Jul 14 07:44:42 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Re-indent everything consistently
Fix include guards for consistency as well
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2.c Sun Jul 06 05:30:32 2008 +0000
1.2 +++ b/src/pvr2/pvr2.c Mon Jul 14 07:44:42 2008 +0000
1.3 @@ -55,8 +55,8 @@
1.4 static int output_colour_formats[] = { COLFMT_BGRA1555, COLFMT_RGB565, COLFMT_BGR888, COLFMT_BGRA8888 };
1.5
1.6 struct dreamcast_module pvr2_module = { "PVR2", pvr2_init, pvr2_reset, NULL,
1.7 - pvr2_run_slice, NULL,
1.8 - pvr2_save_state, pvr2_load_state };
1.9 + pvr2_run_slice, NULL,
1.10 + pvr2_save_state, pvr2_load_state };
1.11
1.12
1.13 display_driver_t display_driver = NULL;
1.14 @@ -102,13 +102,13 @@
1.15 asic_event( eventid );
1.16 pvr2_update_raster_posn(sh4r.slice_cycle);
1.17 if( pvr2_state.irq_hpos_mode == HPOS_PER_LINECOUNT ) {
1.18 - pvr2_state.irq_hpos_line += pvr2_state.irq_hpos_line_count;
1.19 - while( pvr2_state.irq_hpos_line > (pvr2_state.total_lines>>1) ) {
1.20 - pvr2_state.irq_hpos_line -= (pvr2_state.total_lines>>1);
1.21 - }
1.22 + pvr2_state.irq_hpos_line += pvr2_state.irq_hpos_line_count;
1.23 + while( pvr2_state.irq_hpos_line > (pvr2_state.total_lines>>1) ) {
1.24 + pvr2_state.irq_hpos_line -= (pvr2_state.total_lines>>1);
1.25 + }
1.26 }
1.27 pvr2_schedule_scanline_event( eventid, pvr2_state.irq_hpos_line, 1,
1.28 - pvr2_state.irq_hpos_time_ns );
1.29 + pvr2_state.irq_hpos_time_ns );
1.30 }
1.31
1.32 /**
1.33 @@ -119,9 +119,9 @@
1.34 asic_event( eventid );
1.35 pvr2_update_raster_posn(sh4r.slice_cycle);
1.36 if( eventid == EVENT_SCANLINE1 ) {
1.37 - pvr2_schedule_scanline_event( eventid, pvr2_state.irq_vpos1, 1, 0 );
1.38 + pvr2_schedule_scanline_event( eventid, pvr2_state.irq_vpos1, 1, 0 );
1.39 } else {
1.40 - pvr2_schedule_scanline_event( eventid, pvr2_state.irq_vpos2, 1, 0 );
1.41 + pvr2_schedule_scanline_event( eventid, pvr2_state.irq_vpos2, 1, 0 );
1.42 }
1.43 }
1.44
1.45 @@ -140,7 +140,7 @@
1.46 pvr2_ta_reset();
1.47 save_next_render_filename = NULL;
1.48 for( i=0; i<MAX_RENDER_BUFFERS; i++ ) {
1.49 - render_buffers[i] = NULL;
1.50 + render_buffers[i] = NULL;
1.51 }
1.52 render_buffer_count = 0;
1.53 displayed_render_buffer = NULL;
1.54 @@ -162,16 +162,16 @@
1.55 mmio_region_PVR2_write( DISP_SYNCTIME, 0x07D6A53F );
1.56 mmio_region_PVR2_write( YUV_ADDR, 0 );
1.57 mmio_region_PVR2_write( YUV_CFG, 0 );
1.58 -
1.59 +
1.60 pvr2_ta_init();
1.61 texcache_flush();
1.62 if( display_driver ) {
1.63 - display_driver->display_blank(0);
1.64 - for( i=0; i<render_buffer_count; i++ ) {
1.65 - display_driver->destroy_render_buffer(render_buffers[i]);
1.66 - render_buffers[i] = NULL;
1.67 - }
1.68 - render_buffer_count = 0;
1.69 + display_driver->display_blank(0);
1.70 + for( i=0; i<render_buffer_count; i++ ) {
1.71 + display_driver->destroy_render_buffer(render_buffers[i]);
1.72 + render_buffers[i] = NULL;
1.73 + }
1.74 + render_buffer_count = 0;
1.75 }
1.76 }
1.77
1.78 @@ -185,7 +185,7 @@
1.79 fbuf.colour_format = COLFMT_BGR888;
1.80 fbuf.inverted = buffer->inverted;
1.81 fbuf.data = g_malloc0( buffer->width * buffer->height * 3 );
1.82 -
1.83 +
1.84 display_driver->read_render_buffer( fbuf.data, buffer, fbuf.rowstride, COLFMT_BGR888 );
1.85 write_png_to_stream( f, &fbuf );
1.86 g_free( fbuf.data );
1.87 @@ -196,29 +196,29 @@
1.88 fwrite( &buffer->scale, sizeof(buffer->scale), 1, f );
1.89 int32_t flushed = (int32_t)buffer->flushed; // Force to 32-bits for save-file consistency
1.90 fwrite( &flushed, sizeof(flushed), 1, f );
1.91 -
1.92 +
1.93 }
1.94
1.95 render_buffer_t pvr2_load_render_buffer( FILE *f )
1.96 {
1.97 frame_buffer_t frame = read_png_from_stream( f );
1.98 if( frame == NULL ) {
1.99 - return NULL;
1.100 + return NULL;
1.101 }
1.102
1.103 render_buffer_t buffer = pvr2_frame_buffer_to_render_buffer(frame);
1.104 if( buffer != NULL ) {
1.105 int32_t flushed;
1.106 - fread( &buffer->rowstride, sizeof(buffer->rowstride), 1, f );
1.107 - fread( &buffer->colour_format, sizeof(buffer->colour_format), 1, f );
1.108 - fread( &buffer->address, sizeof(buffer->address), 1, f );
1.109 - fread( &buffer->scale, sizeof(buffer->scale), 1, f );
1.110 - fread( &flushed, sizeof(flushed), 1, f );
1.111 - buffer->flushed = (gboolean)flushed;
1.112 + fread( &buffer->rowstride, sizeof(buffer->rowstride), 1, f );
1.113 + fread( &buffer->colour_format, sizeof(buffer->colour_format), 1, f );
1.114 + fread( &buffer->address, sizeof(buffer->address), 1, f );
1.115 + fread( &buffer->scale, sizeof(buffer->scale), 1, f );
1.116 + fread( &flushed, sizeof(flushed), 1, f );
1.117 + buffer->flushed = (gboolean)flushed;
1.118 } else {
1.119 - fseek( f, sizeof(buffer->rowstride)+sizeof(buffer->colour_format)+
1.120 - sizeof(buffer->address)+sizeof(buffer->scale)+
1.121 - sizeof(int32_t), SEEK_CUR );
1.122 + fseek( f, sizeof(buffer->rowstride)+sizeof(buffer->colour_format)+
1.123 + sizeof(buffer->address)+sizeof(buffer->scale)+
1.124 + sizeof(int32_t), SEEK_CUR );
1.125 }
1.126 return buffer;
1.127 }
1.128 @@ -232,18 +232,18 @@
1.129 uint32_t has_frontbuffer;
1.130 fwrite( &render_buffer_count, sizeof(render_buffer_count), 1, f );
1.131 if( displayed_render_buffer != NULL ) {
1.132 - has_frontbuffer = 1;
1.133 - fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );
1.134 - pvr2_save_render_buffer( f, displayed_render_buffer );
1.135 + has_frontbuffer = 1;
1.136 + fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );
1.137 + pvr2_save_render_buffer( f, displayed_render_buffer );
1.138 } else {
1.139 - has_frontbuffer = 0;
1.140 - fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );
1.141 + has_frontbuffer = 0;
1.142 + fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );
1.143 }
1.144
1.145 for( i=0; i<render_buffer_count; i++ ) {
1.146 - if( render_buffers[i] != displayed_render_buffer && render_buffers[i] != NULL ) {
1.147 - pvr2_save_render_buffer( f, render_buffers[i] );
1.148 - }
1.149 + if( render_buffers[i] != displayed_render_buffer && render_buffers[i] != NULL ) {
1.150 + pvr2_save_render_buffer( f, render_buffers[i] );
1.151 + }
1.152 }
1.153 }
1.154
1.155 @@ -254,27 +254,27 @@
1.156
1.157 fread( &count, sizeof(count), 1, f );
1.158 if( count > MAX_RENDER_BUFFERS ) {
1.159 - return FALSE;
1.160 + return FALSE;
1.161 }
1.162 fread( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );
1.163 for( i=0; i<render_buffer_count; i++ ) {
1.164 - display_driver->destroy_render_buffer(render_buffers[i]);
1.165 - render_buffers[i] = NULL;
1.166 + display_driver->destroy_render_buffer(render_buffers[i]);
1.167 + render_buffers[i] = NULL;
1.168 }
1.169 render_buffer_count = 0;
1.170
1.171 if( has_frontbuffer ) {
1.172 - displayed_render_buffer = pvr2_load_render_buffer(f);
1.173 - display_driver->display_render_buffer( displayed_render_buffer );
1.174 - count--;
1.175 + displayed_render_buffer = pvr2_load_render_buffer(f);
1.176 + display_driver->display_render_buffer( displayed_render_buffer );
1.177 + count--;
1.178 }
1.179
1.180 for( i=0; i<count; i++ ) {
1.181 - pvr2_load_render_buffer( f );
1.182 + pvr2_load_render_buffer( f );
1.183 }
1.184 return TRUE;
1.185 }
1.186 -
1.187 +
1.188
1.189 static void pvr2_save_state( FILE *f )
1.190 {
1.191 @@ -287,11 +287,11 @@
1.192 static int pvr2_load_state( FILE *f )
1.193 {
1.194 if( !pvr2_load_render_buffers(f) )
1.195 - return 1;
1.196 + return 1;
1.197 if( fread( &pvr2_state, sizeof(pvr2_state), 1, f ) != 1 )
1.198 - return 1;
1.199 + return 1;
1.200 if( pvr2_ta_load_state(f) ) {
1.201 - return 1;
1.202 + return 1;
1.203 }
1.204 return pvr2_yuv_load_state(f);
1.205 }
1.206 @@ -305,26 +305,26 @@
1.207 {
1.208 uint32_t old_line_count = pvr2_state.line_count;
1.209 if( pvr2_state.line_time_ns == 0 ) {
1.210 - return; /* do nothing */
1.211 + return; /* do nothing */
1.212 }
1.213 pvr2_state.line_remainder += (nanosecs - pvr2_state.cycles_run);
1.214 pvr2_state.cycles_run = nanosecs;
1.215 while( pvr2_state.line_remainder >= pvr2_state.line_time_ns ) {
1.216 - pvr2_state.line_count ++;
1.217 - pvr2_state.line_remainder -= pvr2_state.line_time_ns;
1.218 + pvr2_state.line_count ++;
1.219 + pvr2_state.line_remainder -= pvr2_state.line_time_ns;
1.220 }
1.221
1.222 if( pvr2_state.line_count >= pvr2_state.total_lines ) {
1.223 - pvr2_state.line_count -= pvr2_state.total_lines;
1.224 - if( pvr2_state.interlaced ) {
1.225 - pvr2_state.odd_even_field = !pvr2_state.odd_even_field;
1.226 - }
1.227 + pvr2_state.line_count -= pvr2_state.total_lines;
1.228 + if( pvr2_state.interlaced ) {
1.229 + pvr2_state.odd_even_field = !pvr2_state.odd_even_field;
1.230 + }
1.231 }
1.232 if( pvr2_state.line_count >= pvr2_state.retrace_end_line &&
1.233 - (old_line_count < pvr2_state.retrace_end_line ||
1.234 - old_line_count > pvr2_state.line_count) ) {
1.235 - pvr2_state.frame_count++;
1.236 - pvr2_display_frame();
1.237 + (old_line_count < pvr2_state.retrace_end_line ||
1.238 + old_line_count > pvr2_state.line_count) ) {
1.239 + pvr2_state.frame_count++;
1.240 + pvr2_display_frame();
1.241 }
1.242 }
1.243
1.244 @@ -354,7 +354,7 @@
1.245 gboolean pvr2_save_next_scene( const gchar *filename )
1.246 {
1.247 if( save_next_render_filename != NULL ) {
1.248 - g_free( save_next_render_filename );
1.249 + g_free( save_next_render_filename );
1.250 }
1.251 save_next_render_filename = g_strdup(filename);
1.252 return TRUE;
1.253 @@ -374,66 +374,66 @@
1.254 gboolean bEnabled = (dispmode & DISPMODE_ENABLE) && (vidcfg & DISPCFG_VO ) ? TRUE : FALSE;
1.255
1.256 if( display_driver == NULL ) {
1.257 - return; /* can't really do anything much */
1.258 + return; /* can't really do anything much */
1.259 } else if( !bEnabled ) {
1.260 - /* Output disabled == black */
1.261 - displayed_render_buffer = NULL;
1.262 - displayed_border_colour = 0;
1.263 - display_driver->display_blank( 0 );
1.264 + /* Output disabled == black */
1.265 + displayed_render_buffer = NULL;
1.266 + displayed_border_colour = 0;
1.267 + display_driver->display_blank( 0 );
1.268 } else if( MMIO_READ( PVR2, DISP_CFG2 ) & 0x08 ) {
1.269 - /* Enabled but blanked - border colour */
1.270 - displayed_border_colour = MMIO_READ( PVR2, DISP_BORDER );
1.271 - displayed_render_buffer = NULL;
1.272 - display_driver->display_blank( displayed_border_colour );
1.273 + /* Enabled but blanked - border colour */
1.274 + displayed_border_colour = MMIO_READ( PVR2, DISP_BORDER );
1.275 + displayed_render_buffer = NULL;
1.276 + display_driver->display_blank( displayed_border_colour );
1.277 } else {
1.278 - /* Real output - determine dimensions etc */
1.279 - struct frame_buffer fbuf;
1.280 - uint32_t dispsize = MMIO_READ( PVR2, DISP_SIZE );
1.281 - int vid_stride = (((dispsize & DISPSIZE_MODULO) >> 20) - 1);
1.282 - int vid_ppl = ((dispsize & DISPSIZE_PPL)) + 1;
1.283 + /* Real output - determine dimensions etc */
1.284 + struct frame_buffer fbuf;
1.285 + uint32_t dispsize = MMIO_READ( PVR2, DISP_SIZE );
1.286 + int vid_stride = (((dispsize & DISPSIZE_MODULO) >> 20) - 1);
1.287 + int vid_ppl = ((dispsize & DISPSIZE_PPL)) + 1;
1.288
1.289 - fbuf.colour_format = output_colour_formats[(dispmode & DISPMODE_COLFMT) >> 2];
1.290 - fbuf.width = vid_ppl << 2 / colour_formats[fbuf.colour_format].bpp;
1.291 - fbuf.height = ((dispsize & DISPSIZE_LPF) >> 10) + 1;
1.292 - fbuf.size = vid_ppl << 2 * fbuf.height;
1.293 - fbuf.rowstride = (vid_ppl + vid_stride) << 2;
1.294 + fbuf.colour_format = output_colour_formats[(dispmode & DISPMODE_COLFMT) >> 2];
1.295 + fbuf.width = vid_ppl << 2 / colour_formats[fbuf.colour_format].bpp;
1.296 + fbuf.height = ((dispsize & DISPSIZE_LPF) >> 10) + 1;
1.297 + fbuf.size = vid_ppl << 2 * fbuf.height;
1.298 + fbuf.rowstride = (vid_ppl + vid_stride) << 2;
1.299
1.300 - /* Determine the field to display, and deinterlace if possible */
1.301 - if( pvr2_state.interlaced ) {
1.302 - if( vid_ppl == vid_stride ) { /* Magic deinterlace */
1.303 - fbuf.height = fbuf.height << 1;
1.304 - fbuf.rowstride = vid_ppl << 2;
1.305 - fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );
1.306 - } else {
1.307 - /* Just display the field as is, folks. This is slightly tricky -
1.308 - * we pick the field based on which frame is about to come through,
1.309 - * which may not be the same as the odd_even_field.
1.310 - */
1.311 - gboolean oddfield = pvr2_state.odd_even_field;
1.312 - if( pvr2_state.line_count >= pvr2_state.retrace_start_line ) {
1.313 - oddfield = !oddfield;
1.314 - }
1.315 - if( oddfield ) {
1.316 - fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );
1.317 - } else {
1.318 - fbuf.address = MMIO_READ( PVR2, DISP_ADDR2 );
1.319 - }
1.320 - }
1.321 - } else {
1.322 - fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );
1.323 - }
1.324 - fbuf.address = (fbuf.address & 0x00FFFFFF) + PVR2_RAM_BASE;
1.325 - fbuf.inverted = FALSE;
1.326 - fbuf.data = video_base + (fbuf.address&0x00FFFFFF);
1.327 + /* Determine the field to display, and deinterlace if possible */
1.328 + if( pvr2_state.interlaced ) {
1.329 + if( vid_ppl == vid_stride ) { /* Magic deinterlace */
1.330 + fbuf.height = fbuf.height << 1;
1.331 + fbuf.rowstride = vid_ppl << 2;
1.332 + fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );
1.333 + } else {
1.334 + /* Just display the field as is, folks. This is slightly tricky -
1.335 + * we pick the field based on which frame is about to come through,
1.336 + * which may not be the same as the odd_even_field.
1.337 + */
1.338 + gboolean oddfield = pvr2_state.odd_even_field;
1.339 + if( pvr2_state.line_count >= pvr2_state.retrace_start_line ) {
1.340 + oddfield = !oddfield;
1.341 + }
1.342 + if( oddfield ) {
1.343 + fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );
1.344 + } else {
1.345 + fbuf.address = MMIO_READ( PVR2, DISP_ADDR2 );
1.346 + }
1.347 + }
1.348 + } else {
1.349 + fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );
1.350 + }
1.351 + fbuf.address = (fbuf.address & 0x00FFFFFF) + PVR2_RAM_BASE;
1.352 + fbuf.inverted = FALSE;
1.353 + fbuf.data = video_base + (fbuf.address&0x00FFFFFF);
1.354
1.355 - render_buffer_t rbuf = pvr2_get_render_buffer( &fbuf );
1.356 - if( rbuf == NULL ) {
1.357 - rbuf = pvr2_frame_buffer_to_render_buffer( &fbuf );
1.358 - }
1.359 - displayed_render_buffer = rbuf;
1.360 - if( rbuf != NULL ) {
1.361 - display_driver->display_render_buffer( rbuf );
1.362 - }
1.363 + render_buffer_t rbuf = pvr2_get_render_buffer( &fbuf );
1.364 + if( rbuf == NULL ) {
1.365 + rbuf = pvr2_frame_buffer_to_render_buffer( &fbuf );
1.366 + }
1.367 + displayed_render_buffer = rbuf;
1.368 + if( rbuf != NULL ) {
1.369 + display_driver->display_render_buffer( rbuf );
1.370 + }
1.371 }
1.372 }
1.373
1.374 @@ -447,256 +447,256 @@
1.375 MMIO_WRITE( PVR2, reg, val );
1.376 return;
1.377 }
1.378 -
1.379 +
1.380 switch(reg) {
1.381 case PVRID:
1.382 case PVRVER:
1.383 case GUNPOS: /* Read only registers */
1.384 - break;
1.385 + break;
1.386 case PVRRESET:
1.387 - val &= 0x00000007; /* Do stuff? */
1.388 - MMIO_WRITE( PVR2, reg, val );
1.389 - break;
1.390 + val &= 0x00000007; /* Do stuff? */
1.391 + MMIO_WRITE( PVR2, reg, val );
1.392 + break;
1.393 case RENDER_START: /* Don't really care what value */
1.394 - if( save_next_render_filename != NULL ) {
1.395 - if( pvr2_render_save_scene(save_next_render_filename) == 0 ) {
1.396 - INFO( "Saved scene to %s", save_next_render_filename);
1.397 - }
1.398 - g_free( save_next_render_filename );
1.399 - save_next_render_filename = NULL;
1.400 - }
1.401 - pvr2_scene_read();
1.402 - render_buffer_t buffer = pvr2_next_render_buffer();
1.403 - if( buffer != NULL ) {
1.404 - pvr2_scene_render( buffer );
1.405 - }
1.406 - asic_event( EVENT_PVR_RENDER_DONE );
1.407 - break;
1.408 + if( save_next_render_filename != NULL ) {
1.409 + if( pvr2_render_save_scene(save_next_render_filename) == 0 ) {
1.410 + INFO( "Saved scene to %s", save_next_render_filename);
1.411 + }
1.412 + g_free( save_next_render_filename );
1.413 + save_next_render_filename = NULL;
1.414 + }
1.415 + pvr2_scene_read();
1.416 + render_buffer_t buffer = pvr2_next_render_buffer();
1.417 + if( buffer != NULL ) {
1.418 + pvr2_scene_render( buffer );
1.419 + }
1.420 + asic_event( EVENT_PVR_RENDER_DONE );
1.421 + break;
1.422 case RENDER_POLYBASE:
1.423 - MMIO_WRITE( PVR2, reg, val&0x00F00000 );
1.424 - break;
1.425 + MMIO_WRITE( PVR2, reg, val&0x00F00000 );
1.426 + break;
1.427 case RENDER_TSPCFG:
1.428 - MMIO_WRITE( PVR2, reg, val&0x00010101 );
1.429 - break;
1.430 + MMIO_WRITE( PVR2, reg, val&0x00010101 );
1.431 + break;
1.432 case DISP_BORDER:
1.433 - MMIO_WRITE( PVR2, reg, val&0x01FFFFFF );
1.434 - break;
1.435 + MMIO_WRITE( PVR2, reg, val&0x01FFFFFF );
1.436 + break;
1.437 case DISP_MODE:
1.438 - MMIO_WRITE( PVR2, reg, val&0x00FFFF7F );
1.439 - break;
1.440 + MMIO_WRITE( PVR2, reg, val&0x00FFFF7F );
1.441 + break;
1.442 case RENDER_MODE:
1.443 - MMIO_WRITE( PVR2, reg, val&0x00FFFF0F );
1.444 - break;
1.445 + MMIO_WRITE( PVR2, reg, val&0x00FFFF0F );
1.446 + break;
1.447 case RENDER_SIZE:
1.448 - MMIO_WRITE( PVR2, reg, val&0x000001FF );
1.449 - break;
1.450 + MMIO_WRITE( PVR2, reg, val&0x000001FF );
1.451 + break;
1.452 case DISP_ADDR1:
1.453 - val &= 0x00FFFFFC;
1.454 - MMIO_WRITE( PVR2, reg, val );
1.455 - pvr2_update_raster_posn(sh4r.slice_cycle);
1.456 - break;
1.457 + val &= 0x00FFFFFC;
1.458 + MMIO_WRITE( PVR2, reg, val );
1.459 + pvr2_update_raster_posn(sh4r.slice_cycle);
1.460 + break;
1.461 case DISP_ADDR2:
1.462 - MMIO_WRITE( PVR2, reg, val&0x00FFFFFC );
1.463 - pvr2_update_raster_posn(sh4r.slice_cycle);
1.464 - break;
1.465 + MMIO_WRITE( PVR2, reg, val&0x00FFFFFC );
1.466 + pvr2_update_raster_posn(sh4r.slice_cycle);
1.467 + break;
1.468 case DISP_SIZE:
1.469 - MMIO_WRITE( PVR2, reg, val&0x3FFFFFFF );
1.470 - break;
1.471 + MMIO_WRITE( PVR2, reg, val&0x3FFFFFFF );
1.472 + break;
1.473 case RENDER_ADDR1:
1.474 case RENDER_ADDR2:
1.475 - MMIO_WRITE( PVR2, reg, val&0x01FFFFFC );
1.476 - break;
1.477 + MMIO_WRITE( PVR2, reg, val&0x01FFFFFC );
1.478 + break;
1.479 case RENDER_HCLIP:
1.480 - MMIO_WRITE( PVR2, reg, val&0x07FF07FF );
1.481 - break;
1.482 + MMIO_WRITE( PVR2, reg, val&0x07FF07FF );
1.483 + break;
1.484 case RENDER_VCLIP:
1.485 - MMIO_WRITE( PVR2, reg, val&0x03FF03FF );
1.486 - break;
1.487 + MMIO_WRITE( PVR2, reg, val&0x03FF03FF );
1.488 + break;
1.489 case DISP_HPOSIRQ:
1.490 - MMIO_WRITE( PVR2, reg, val&0x03FF33FF );
1.491 - pvr2_state.irq_hpos_line = val & 0x03FF;
1.492 - pvr2_state.irq_hpos_time_ns = 2000000*((val>>16)&0x03FF)/pvr2_state.dot_clock;
1.493 - pvr2_state.irq_hpos_mode = (val >> 12) & 0x03;
1.494 - switch( pvr2_state.irq_hpos_mode ) {
1.495 - case 3: /* Reserved - treat as 0 */
1.496 - case 0: /* Once per frame at specified line */
1.497 - pvr2_state.irq_hpos_mode = HPOS_PER_FRAME;
1.498 - break;
1.499 - case 2: /* Once per line - as per-line-count */
1.500 - pvr2_state.irq_hpos_line = 1;
1.501 - pvr2_state.irq_hpos_mode = 1;
1.502 - case 1: /* Once per N lines */
1.503 - pvr2_state.irq_hpos_line_count = pvr2_state.irq_hpos_line;
1.504 - pvr2_state.irq_hpos_line = (pvr2_state.line_count >> 1) +
1.505 - pvr2_state.irq_hpos_line_count;
1.506 - while( pvr2_state.irq_hpos_line > (pvr2_state.total_lines>>1) ) {
1.507 - pvr2_state.irq_hpos_line -= (pvr2_state.total_lines>>1);
1.508 - }
1.509 - pvr2_state.irq_hpos_mode = HPOS_PER_LINECOUNT;
1.510 - }
1.511 - pvr2_schedule_scanline_event( EVENT_HPOS, pvr2_state.irq_hpos_line, 0,
1.512 - pvr2_state.irq_hpos_time_ns );
1.513 - break;
1.514 - case DISP_VPOSIRQ:
1.515 - val = val & 0x03FF03FF;
1.516 - pvr2_state.irq_vpos1 = (val >> 16);
1.517 - pvr2_state.irq_vpos2 = val & 0x03FF;
1.518 - pvr2_update_raster_posn(sh4r.slice_cycle);
1.519 - pvr2_schedule_scanline_event( EVENT_SCANLINE1, pvr2_state.irq_vpos1, 0, 0 );
1.520 - pvr2_schedule_scanline_event( EVENT_SCANLINE2, pvr2_state.irq_vpos2, 0, 0 );
1.521 - MMIO_WRITE( PVR2, reg, val );
1.522 - break;
1.523 - case RENDER_NEARCLIP:
1.524 - MMIO_WRITE( PVR2, reg, val & 0x7FFFFFFF );
1.525 - break;
1.526 - case RENDER_SHADOW:
1.527 - MMIO_WRITE( PVR2, reg, val&0x000001FF );
1.528 - break;
1.529 - case RENDER_OBJCFG:
1.530 - MMIO_WRITE( PVR2, reg, val&0x003FFFFF );
1.531 - break;
1.532 - case RENDER_TSPCLIP:
1.533 - MMIO_WRITE( PVR2, reg, val&0x7FFFFFFF );
1.534 - break;
1.535 - case RENDER_FARCLIP:
1.536 - MMIO_WRITE( PVR2, reg, val&0xFFFFFFF0 );
1.537 - break;
1.538 - case RENDER_BGPLANE:
1.539 - MMIO_WRITE( PVR2, reg, val&0x1FFFFFFF );
1.540 - break;
1.541 - case RENDER_ISPCFG:
1.542 - MMIO_WRITE( PVR2, reg, val&0x00FFFFF9 );
1.543 - break;
1.544 - case VRAM_CFG1:
1.545 - MMIO_WRITE( PVR2, reg, val&0x000000FF );
1.546 - break;
1.547 - case VRAM_CFG2:
1.548 - MMIO_WRITE( PVR2, reg, val&0x003FFFFF );
1.549 - break;
1.550 - case VRAM_CFG3:
1.551 - MMIO_WRITE( PVR2, reg, val&0x1FFFFFFF );
1.552 - break;
1.553 - case RENDER_FOGTBLCOL:
1.554 - case RENDER_FOGVRTCOL:
1.555 - MMIO_WRITE( PVR2, reg, val&0x00FFFFFF );
1.556 - break;
1.557 - case RENDER_FOGCOEFF:
1.558 - MMIO_WRITE( PVR2, reg, val&0x0000FFFF );
1.559 - break;
1.560 - case RENDER_CLAMPHI:
1.561 - case RENDER_CLAMPLO:
1.562 - MMIO_WRITE( PVR2, reg, val );
1.563 - break;
1.564 - case RENDER_TEXSIZE:
1.565 - MMIO_WRITE( PVR2, reg, val&0x00031F1F );
1.566 - break;
1.567 - case RENDER_PALETTE:
1.568 - MMIO_WRITE( PVR2, reg, val&0x00000003 );
1.569 - break;
1.570 - case RENDER_ALPHA_REF:
1.571 - MMIO_WRITE( PVR2, reg, val&0x000000FF );
1.572 - break;
1.573 - /********** CRTC registers *************/
1.574 - case DISP_HBORDER:
1.575 - case DISP_VBORDER:
1.576 - MMIO_WRITE( PVR2, reg, val&0x03FF03FF );
1.577 - break;
1.578 - case DISP_TOTAL:
1.579 - val = val & 0x03FF03FF;
1.580 - MMIO_WRITE( PVR2, reg, val );
1.581 - pvr2_update_raster_posn(sh4r.slice_cycle);
1.582 - pvr2_state.total_lines = (val >> 16) + 1;
1.583 - pvr2_state.line_size = (val & 0x03FF) + 1;
1.584 - pvr2_state.line_time_ns = 1000000 * pvr2_state.line_size / pvr2_state.dot_clock;
1.585 - pvr2_state.retrace_end_line = 0x2A;
1.586 - pvr2_state.retrace_start_line = pvr2_state.total_lines - 6;
1.587 - pvr2_schedule_scanline_event( EVENT_SCANLINE1, pvr2_state.irq_vpos1, 0, 0 );
1.588 - pvr2_schedule_scanline_event( EVENT_SCANLINE2, pvr2_state.irq_vpos2, 0, 0 );
1.589 - pvr2_schedule_scanline_event( EVENT_HPOS, pvr2_state.irq_hpos_line, 0,
1.590 - pvr2_state.irq_hpos_time_ns );
1.591 - break;
1.592 - case DISP_SYNCCFG:
1.593 - MMIO_WRITE( PVR2, reg, val&0x000003FF );
1.594 - pvr2_state.interlaced = (val & 0x0010) ? TRUE : FALSE;
1.595 - break;
1.596 - case DISP_SYNCTIME:
1.597 - pvr2_state.vsync_lines = (val >> 8) & 0x0F;
1.598 - pvr2_state.hsync_width_ns = ((val & 0x7F) + 1) * 2000000 / pvr2_state.dot_clock;
1.599 - MMIO_WRITE( PVR2, reg, val&0xFFFFFF7F );
1.600 - break;
1.601 - case DISP_CFG2:
1.602 - MMIO_WRITE( PVR2, reg, val&0x003F01FF );
1.603 - break;
1.604 - case DISP_HPOS:
1.605 - val = val & 0x03FF;
1.606 - pvr2_state.front_porch_ns = (val + 1) * 1000000 / pvr2_state.dot_clock;
1.607 - MMIO_WRITE( PVR2, reg, val );
1.608 - break;
1.609 - case DISP_VPOS:
1.610 - MMIO_WRITE( PVR2, reg, val&0x03FF03FF );
1.611 - break;
1.612 + MMIO_WRITE( PVR2, reg, val&0x03FF33FF );
1.613 + pvr2_state.irq_hpos_line = val & 0x03FF;
1.614 + pvr2_state.irq_hpos_time_ns = 2000000*((val>>16)&0x03FF)/pvr2_state.dot_clock;
1.615 + pvr2_state.irq_hpos_mode = (val >> 12) & 0x03;
1.616 + switch( pvr2_state.irq_hpos_mode ) {
1.617 + case 3: /* Reserved - treat as 0 */
1.618 + case 0: /* Once per frame at specified line */
1.619 + pvr2_state.irq_hpos_mode = HPOS_PER_FRAME;
1.620 + break;
1.621 + case 2: /* Once per line - as per-line-count */
1.622 + pvr2_state.irq_hpos_line = 1;
1.623 + pvr2_state.irq_hpos_mode = 1;
1.624 + case 1: /* Once per N lines */
1.625 + pvr2_state.irq_hpos_line_count = pvr2_state.irq_hpos_line;
1.626 + pvr2_state.irq_hpos_line = (pvr2_state.line_count >> 1) +
1.627 + pvr2_state.irq_hpos_line_count;
1.628 + while( pvr2_state.irq_hpos_line > (pvr2_state.total_lines>>1) ) {
1.629 + pvr2_state.irq_hpos_line -= (pvr2_state.total_lines>>1);
1.630 + }
1.631 + pvr2_state.irq_hpos_mode = HPOS_PER_LINECOUNT;
1.632 + }
1.633 + pvr2_schedule_scanline_event( EVENT_HPOS, pvr2_state.irq_hpos_line, 0,
1.634 + pvr2_state.irq_hpos_time_ns );
1.635 + break;
1.636 + case DISP_VPOSIRQ:
1.637 + val = val & 0x03FF03FF;
1.638 + pvr2_state.irq_vpos1 = (val >> 16);
1.639 + pvr2_state.irq_vpos2 = val & 0x03FF;
1.640 + pvr2_update_raster_posn(sh4r.slice_cycle);
1.641 + pvr2_schedule_scanline_event( EVENT_SCANLINE1, pvr2_state.irq_vpos1, 0, 0 );
1.642 + pvr2_schedule_scanline_event( EVENT_SCANLINE2, pvr2_state.irq_vpos2, 0, 0 );
1.643 + MMIO_WRITE( PVR2, reg, val );
1.644 + break;
1.645 + case RENDER_NEARCLIP:
1.646 + MMIO_WRITE( PVR2, reg, val & 0x7FFFFFFF );
1.647 + break;
1.648 + case RENDER_SHADOW:
1.649 + MMIO_WRITE( PVR2, reg, val&0x000001FF );
1.650 + break;
1.651 + case RENDER_OBJCFG:
1.652 + MMIO_WRITE( PVR2, reg, val&0x003FFFFF );
1.653 + break;
1.654 + case RENDER_TSPCLIP:
1.655 + MMIO_WRITE( PVR2, reg, val&0x7FFFFFFF );
1.656 + break;
1.657 + case RENDER_FARCLIP:
1.658 + MMIO_WRITE( PVR2, reg, val&0xFFFFFFF0 );
1.659 + break;
1.660 + case RENDER_BGPLANE:
1.661 + MMIO_WRITE( PVR2, reg, val&0x1FFFFFFF );
1.662 + break;
1.663 + case RENDER_ISPCFG:
1.664 + MMIO_WRITE( PVR2, reg, val&0x00FFFFF9 );
1.665 + break;
1.666 + case VRAM_CFG1:
1.667 + MMIO_WRITE( PVR2, reg, val&0x000000FF );
1.668 + break;
1.669 + case VRAM_CFG2:
1.670 + MMIO_WRITE( PVR2, reg, val&0x003FFFFF );
1.671 + break;
1.672 + case VRAM_CFG3:
1.673 + MMIO_WRITE( PVR2, reg, val&0x1FFFFFFF );
1.674 + break;
1.675 + case RENDER_FOGTBLCOL:
1.676 + case RENDER_FOGVRTCOL:
1.677 + MMIO_WRITE( PVR2, reg, val&0x00FFFFFF );
1.678 + break;
1.679 + case RENDER_FOGCOEFF:
1.680 + MMIO_WRITE( PVR2, reg, val&0x0000FFFF );
1.681 + break;
1.682 + case RENDER_CLAMPHI:
1.683 + case RENDER_CLAMPLO:
1.684 + MMIO_WRITE( PVR2, reg, val );
1.685 + break;
1.686 + case RENDER_TEXSIZE:
1.687 + MMIO_WRITE( PVR2, reg, val&0x00031F1F );
1.688 + break;
1.689 + case RENDER_PALETTE:
1.690 + MMIO_WRITE( PVR2, reg, val&0x00000003 );
1.691 + break;
1.692 + case RENDER_ALPHA_REF:
1.693 + MMIO_WRITE( PVR2, reg, val&0x000000FF );
1.694 + break;
1.695 + /********** CRTC registers *************/
1.696 + case DISP_HBORDER:
1.697 + case DISP_VBORDER:
1.698 + MMIO_WRITE( PVR2, reg, val&0x03FF03FF );
1.699 + break;
1.700 + case DISP_TOTAL:
1.701 + val = val & 0x03FF03FF;
1.702 + MMIO_WRITE( PVR2, reg, val );
1.703 + pvr2_update_raster_posn(sh4r.slice_cycle);
1.704 + pvr2_state.total_lines = (val >> 16) + 1;
1.705 + pvr2_state.line_size = (val & 0x03FF) + 1;
1.706 + pvr2_state.line_time_ns = 1000000 * pvr2_state.line_size / pvr2_state.dot_clock;
1.707 + pvr2_state.retrace_end_line = 0x2A;
1.708 + pvr2_state.retrace_start_line = pvr2_state.total_lines - 6;
1.709 + pvr2_schedule_scanline_event( EVENT_SCANLINE1, pvr2_state.irq_vpos1, 0, 0 );
1.710 + pvr2_schedule_scanline_event( EVENT_SCANLINE2, pvr2_state.irq_vpos2, 0, 0 );
1.711 + pvr2_schedule_scanline_event( EVENT_HPOS, pvr2_state.irq_hpos_line, 0,
1.712 + pvr2_state.irq_hpos_time_ns );
1.713 + break;
1.714 + case DISP_SYNCCFG:
1.715 + MMIO_WRITE( PVR2, reg, val&0x000003FF );
1.716 + pvr2_state.interlaced = (val & 0x0010) ? TRUE : FALSE;
1.717 + break;
1.718 + case DISP_SYNCTIME:
1.719 + pvr2_state.vsync_lines = (val >> 8) & 0x0F;
1.720 + pvr2_state.hsync_width_ns = ((val & 0x7F) + 1) * 2000000 / pvr2_state.dot_clock;
1.721 + MMIO_WRITE( PVR2, reg, val&0xFFFFFF7F );
1.722 + break;
1.723 + case DISP_CFG2:
1.724 + MMIO_WRITE( PVR2, reg, val&0x003F01FF );
1.725 + break;
1.726 + case DISP_HPOS:
1.727 + val = val & 0x03FF;
1.728 + pvr2_state.front_porch_ns = (val + 1) * 1000000 / pvr2_state.dot_clock;
1.729 + MMIO_WRITE( PVR2, reg, val );
1.730 + break;
1.731 + case DISP_VPOS:
1.732 + MMIO_WRITE( PVR2, reg, val&0x03FF03FF );
1.733 + break;
1.734
1.735 - /*********** Tile accelerator registers ***********/
1.736 - case TA_POLYPOS:
1.737 - case TA_LISTPOS:
1.738 - /* Readonly registers */
1.739 - break;
1.740 - case TA_TILEBASE:
1.741 - case TA_LISTEND:
1.742 - case TA_LISTBASE:
1.743 - MMIO_WRITE( PVR2, reg, val&0x00FFFFE0 );
1.744 - break;
1.745 - case RENDER_TILEBASE:
1.746 - case TA_POLYBASE:
1.747 - case TA_POLYEND:
1.748 - MMIO_WRITE( PVR2, reg, val&0x00FFFFFC );
1.749 - break;
1.750 - case TA_TILESIZE:
1.751 - MMIO_WRITE( PVR2, reg, val&0x000F003F );
1.752 - break;
1.753 - case TA_TILECFG:
1.754 - MMIO_WRITE( PVR2, reg, val&0x00133333 );
1.755 - break;
1.756 - case TA_INIT:
1.757 - if( val & 0x80000000 )
1.758 - pvr2_ta_init();
1.759 - break;
1.760 - case TA_REINIT:
1.761 - break;
1.762 - /**************** Scaler registers? ****************/
1.763 - case RENDER_SCALER:
1.764 - MMIO_WRITE( PVR2, reg, val&0x0007FFFF );
1.765 - break;
1.766 + /*********** Tile accelerator registers ***********/
1.767 + case TA_POLYPOS:
1.768 + case TA_LISTPOS:
1.769 + /* Readonly registers */
1.770 + break;
1.771 + case TA_TILEBASE:
1.772 + case TA_LISTEND:
1.773 + case TA_LISTBASE:
1.774 + MMIO_WRITE( PVR2, reg, val&0x00FFFFE0 );
1.775 + break;
1.776 + case RENDER_TILEBASE:
1.777 + case TA_POLYBASE:
1.778 + case TA_POLYEND:
1.779 + MMIO_WRITE( PVR2, reg, val&0x00FFFFFC );
1.780 + break;
1.781 + case TA_TILESIZE:
1.782 + MMIO_WRITE( PVR2, reg, val&0x000F003F );
1.783 + break;
1.784 + case TA_TILECFG:
1.785 + MMIO_WRITE( PVR2, reg, val&0x00133333 );
1.786 + break;
1.787 + case TA_INIT:
1.788 + if( val & 0x80000000 )
1.789 + pvr2_ta_init();
1.790 + break;
1.791 + case TA_REINIT:
1.792 + break;
1.793 + /**************** Scaler registers? ****************/
1.794 + case RENDER_SCALER:
1.795 + MMIO_WRITE( PVR2, reg, val&0x0007FFFF );
1.796 + break;
1.797
1.798 - case YUV_ADDR:
1.799 - val = val & 0x00FFFFF8;
1.800 - MMIO_WRITE( PVR2, reg, val );
1.801 - pvr2_yuv_init( val );
1.802 - break;
1.803 - case YUV_CFG:
1.804 - MMIO_WRITE( PVR2, reg, val&0x01013F3F );
1.805 - pvr2_yuv_set_config(val);
1.806 - break;
1.807 + case YUV_ADDR:
1.808 + val = val & 0x00FFFFF8;
1.809 + MMIO_WRITE( PVR2, reg, val );
1.810 + pvr2_yuv_init( val );
1.811 + break;
1.812 + case YUV_CFG:
1.813 + MMIO_WRITE( PVR2, reg, val&0x01013F3F );
1.814 + pvr2_yuv_set_config(val);
1.815 + break;
1.816
1.817 - /**************** Unknowns ***************/
1.818 - case PVRUNK1:
1.819 - MMIO_WRITE( PVR2, reg, val&0x000007FF );
1.820 - break;
1.821 - case PVRUNK2:
1.822 - MMIO_WRITE( PVR2, reg, val&0x00000007 );
1.823 - break;
1.824 - case PVRUNK3:
1.825 - MMIO_WRITE( PVR2, reg, val&0x000FFF3F );
1.826 - break;
1.827 - case PVRUNK5:
1.828 - MMIO_WRITE( PVR2, reg, val&0x0000FFFF );
1.829 - break;
1.830 - case PVRUNK7:
1.831 - MMIO_WRITE( PVR2, reg, val&0x00000001 );
1.832 - break;
1.833 - case PVRUNK8:
1.834 - MMIO_WRITE( PVR2, reg, val&0x0300FFFF );
1.835 - break;
1.836 + /**************** Unknowns ***************/
1.837 + case PVRUNK1:
1.838 + MMIO_WRITE( PVR2, reg, val&0x000007FF );
1.839 + break;
1.840 + case PVRUNK2:
1.841 + MMIO_WRITE( PVR2, reg, val&0x00000007 );
1.842 + break;
1.843 + case PVRUNK3:
1.844 + MMIO_WRITE( PVR2, reg, val&0x000FFF3F );
1.845 + break;
1.846 + case PVRUNK5:
1.847 + MMIO_WRITE( PVR2, reg, val&0x0000FFFF );
1.848 + break;
1.849 + case PVRUNK7:
1.850 + MMIO_WRITE( PVR2, reg, val&0x00000001 );
1.851 + break;
1.852 + case PVRUNK8:
1.853 + MMIO_WRITE( PVR2, reg, val&0x0300FFFF );
1.854 + break;
1.855 }
1.856 }
1.857
1.858 @@ -718,29 +718,29 @@
1.859 uint32_t result = pvr2_state.line_count;
1.860
1.861 if( pvr2_state.odd_even_field ) {
1.862 - result |= 0x0400;
1.863 + result |= 0x0400;
1.864 }
1.865 if( (pvr2_state.line_count & 0x01) == pvr2_state.odd_even_field ) {
1.866 - if( pvr2_state.line_remainder > pvr2_state.hsync_width_ns ) {
1.867 - result |= 0x1000; /* !HSYNC */
1.868 - }
1.869 - if( pvr2_state.line_count >= pvr2_state.vsync_lines ) {
1.870 - if( pvr2_state.line_remainder > pvr2_state.front_porch_ns ) {
1.871 - result |= 0x2800; /* Display active */
1.872 - } else {
1.873 - result |= 0x2000; /* Front porch */
1.874 - }
1.875 - }
1.876 + if( pvr2_state.line_remainder > pvr2_state.hsync_width_ns ) {
1.877 + result |= 0x1000; /* !HSYNC */
1.878 + }
1.879 + if( pvr2_state.line_count >= pvr2_state.vsync_lines ) {
1.880 + if( pvr2_state.line_remainder > pvr2_state.front_porch_ns ) {
1.881 + result |= 0x2800; /* Display active */
1.882 + } else {
1.883 + result |= 0x2000; /* Front porch */
1.884 + }
1.885 + }
1.886 } else {
1.887 - if( pvr2_state.line_count >= pvr2_state.vsync_lines ) {
1.888 - if( pvr2_state.line_remainder < (pvr2_state.line_time_ns - pvr2_state.back_porch_ns)) {
1.889 - result |= 0x3800; /* Display active */
1.890 - } else {
1.891 - result |= 0x3000;
1.892 - }
1.893 - } else {
1.894 - result |= 0x1000; /* Back porch */
1.895 - }
1.896 + if( pvr2_state.line_count >= pvr2_state.vsync_lines ) {
1.897 + if( pvr2_state.line_remainder < (pvr2_state.line_time_ns - pvr2_state.back_porch_ns)) {
1.898 + result |= 0x3800; /* Display active */
1.899 + } else {
1.900 + result |= 0x3000;
1.901 + }
1.902 + } else {
1.903 + result |= 0x1000; /* Back porch */
1.904 + }
1.905 }
1.906 return result;
1.907 }
1.908 @@ -760,42 +760,42 @@
1.909 {
1.910 uint32_t field = pvr2_state.odd_even_field;
1.911 if( line <= pvr2_state.line_count && pvr2_state.interlaced ) {
1.912 - field = !field;
1.913 + field = !field;
1.914 }
1.915 if( hpos_ns > pvr2_state.line_time_ns ) {
1.916 - hpos_ns = pvr2_state.line_time_ns;
1.917 + hpos_ns = pvr2_state.line_time_ns;
1.918 }
1.919
1.920 line <<= 1;
1.921 if( field ) {
1.922 - line += 1;
1.923 + line += 1;
1.924 }
1.925 -
1.926 +
1.927 if( line < pvr2_state.total_lines ) {
1.928 - uint32_t lines;
1.929 - uint32_t time;
1.930 - if( line <= pvr2_state.line_count ) {
1.931 - lines = (pvr2_state.total_lines - pvr2_state.line_count + line);
1.932 - } else {
1.933 - lines = (line - pvr2_state.line_count);
1.934 - }
1.935 - if( lines <= minimum_lines ) {
1.936 - lines += pvr2_state.total_lines;
1.937 - }
1.938 - time = (lines * pvr2_state.line_time_ns) - pvr2_state.line_remainder + hpos_ns;
1.939 - event_schedule( eventid, time );
1.940 + uint32_t lines;
1.941 + uint32_t time;
1.942 + if( line <= pvr2_state.line_count ) {
1.943 + lines = (pvr2_state.total_lines - pvr2_state.line_count + line);
1.944 + } else {
1.945 + lines = (line - pvr2_state.line_count);
1.946 + }
1.947 + if( lines <= minimum_lines ) {
1.948 + lines += pvr2_state.total_lines;
1.949 + }
1.950 + time = (lines * pvr2_state.line_time_ns) - pvr2_state.line_remainder + hpos_ns;
1.951 + event_schedule( eventid, time );
1.952 } else {
1.953 - event_cancel( eventid );
1.954 + event_cancel( eventid );
1.955 }
1.956 }
1.957
1.958 MMIO_REGION_READ_FN( PVR2, reg )
1.959 {
1.960 switch( reg ) {
1.961 - case DISP_SYNCSTAT:
1.962 - return pvr2_get_sync_status();
1.963 - default:
1.964 - return MMIO_READ( PVR2, reg );
1.965 + case DISP_SYNCSTAT:
1.966 + return pvr2_get_sync_status();
1.967 + default:
1.968 + return MMIO_READ( PVR2, reg );
1.969 }
1.970 }
1.971
1.972 @@ -808,8 +808,8 @@
1.973 void pvr2_check_palette_changed()
1.974 {
1.975 if( pvr2_state.palette_changed ) {
1.976 - texcache_invalidate_palette();
1.977 - pvr2_state.palette_changed = FALSE;
1.978 + texcache_invalidate_palette();
1.979 + pvr2_state.palette_changed = FALSE;
1.980 }
1.981 }
1.982
1.983 @@ -845,9 +845,9 @@
1.984 {
1.985 int i;
1.986 for( i=0; i<render_buffer_count; i++ ) {
1.987 - if( render_buffers[i] != NULL && render_buffers[i]->address == frame->address ) {
1.988 - return render_buffers[i];
1.989 - }
1.990 + if( render_buffers[i] != NULL && render_buffers[i]->address == frame->address ) {
1.991 + return render_buffers[i];
1.992 + }
1.993 }
1.994 return NULL;
1.995 }
1.996 @@ -871,68 +871,68 @@
1.997
1.998 /* Check existing buffers for an available buffer */
1.999 for( i=0; i<render_buffer_count; i++ ) {
1.1000 - if( render_buffers[i]->width == width && render_buffers[i]->height == height ) {
1.1001 - /* needs to be the right dimensions */
1.1002 - if( render_buffers[i]->address == render_addr ) {
1.1003 - if( displayed_render_buffer == render_buffers[i] ) {
1.1004 - /* Same address, but we can't use it because the
1.1005 - * display has it. Mark it as unaddressed for later.
1.1006 - */
1.1007 - render_buffers[i]->address = -1;
1.1008 - } else {
1.1009 - /* perfect */
1.1010 - result = render_buffers[i];
1.1011 - break;
1.1012 - }
1.1013 - } else if( render_buffers[i]->address == -1 && result == NULL &&
1.1014 - displayed_render_buffer != render_buffers[i] ) {
1.1015 - result = render_buffers[i];
1.1016 - }
1.1017 -
1.1018 - } else if( render_buffers[i]->address == render_addr ) {
1.1019 - /* right address, wrong size - if it's larger, flush it, otherwise
1.1020 - * nuke it quietly */
1.1021 - if( render_buffers[i]->width * render_buffers[i]->height >
1.1022 - width*height ) {
1.1023 - pvr2_render_buffer_copy_to_sh4( render_buffers[i] );
1.1024 - }
1.1025 - render_buffers[i]->address = -1;
1.1026 - }
1.1027 + if( render_buffers[i]->width == width && render_buffers[i]->height == height ) {
1.1028 + /* needs to be the right dimensions */
1.1029 + if( render_buffers[i]->address == render_addr ) {
1.1030 + if( displayed_render_buffer == render_buffers[i] ) {
1.1031 + /* Same address, but we can't use it because the
1.1032 + * display has it. Mark it as unaddressed for later.
1.1033 + */
1.1034 + render_buffers[i]->address = -1;
1.1035 + } else {
1.1036 + /* perfect */
1.1037 + result = render_buffers[i];
1.1038 + break;
1.1039 + }
1.1040 + } else if( render_buffers[i]->address == -1 && result == NULL &&
1.1041 + displayed_render_buffer != render_buffers[i] ) {
1.1042 + result = render_buffers[i];
1.1043 + }
1.1044 +
1.1045 + } else if( render_buffers[i]->address == render_addr ) {
1.1046 + /* right address, wrong size - if it's larger, flush it, otherwise
1.1047 + * nuke it quietly */
1.1048 + if( render_buffers[i]->width * render_buffers[i]->height >
1.1049 + width*height ) {
1.1050 + pvr2_render_buffer_copy_to_sh4( render_buffers[i] );
1.1051 + }
1.1052 + render_buffers[i]->address = -1;
1.1053 + }
1.1054 }
1.1055
1.1056 /* Nothing available - make one */
1.1057 if( result == NULL ) {
1.1058 - if( render_buffer_count == MAX_RENDER_BUFFERS ) {
1.1059 - /* maximum buffers reached - need to throw one away */
1.1060 - uint32_t field1_addr = MMIO_READ( PVR2, DISP_ADDR1 );
1.1061 - uint32_t field2_addr = MMIO_READ( PVR2, DISP_ADDR2 );
1.1062 - for( i=0; i<render_buffer_count; i++ ) {
1.1063 - if( render_buffers[i]->address != field1_addr &&
1.1064 - render_buffers[i]->address != field2_addr &&
1.1065 - render_buffers[i] != displayed_render_buffer ) {
1.1066 - /* Never throw away the current "front buffer(s)" */
1.1067 - result = render_buffers[i];
1.1068 - if( !result->flushed ) {
1.1069 - pvr2_render_buffer_copy_to_sh4( result );
1.1070 - }
1.1071 - if( result->width != width || result->height != height ) {
1.1072 - display_driver->destroy_render_buffer(render_buffers[i]);
1.1073 - result = display_driver->create_render_buffer(width,height);
1.1074 - render_buffers[i] = result;
1.1075 - }
1.1076 - break;
1.1077 - }
1.1078 - }
1.1079 - } else {
1.1080 - result = display_driver->create_render_buffer(width,height);
1.1081 - if( result != NULL ) {
1.1082 - render_buffers[render_buffer_count++] = result;
1.1083 - }
1.1084 - }
1.1085 + if( render_buffer_count == MAX_RENDER_BUFFERS ) {
1.1086 + /* maximum buffers reached - need to throw one away */
1.1087 + uint32_t field1_addr = MMIO_READ( PVR2, DISP_ADDR1 );
1.1088 + uint32_t field2_addr = MMIO_READ( PVR2, DISP_ADDR2 );
1.1089 + for( i=0; i<render_buffer_count; i++ ) {
1.1090 + if( render_buffers[i]->address != field1_addr &&
1.1091 + render_buffers[i]->address != field2_addr &&
1.1092 + render_buffers[i] != displayed_render_buffer ) {
1.1093 + /* Never throw away the current "front buffer(s)" */
1.1094 + result = render_buffers[i];
1.1095 + if( !result->flushed ) {
1.1096 + pvr2_render_buffer_copy_to_sh4( result );
1.1097 + }
1.1098 + if( result->width != width || result->height != height ) {
1.1099 + display_driver->destroy_render_buffer(render_buffers[i]);
1.1100 + result = display_driver->create_render_buffer(width,height);
1.1101 + render_buffers[i] = result;
1.1102 + }
1.1103 + break;
1.1104 + }
1.1105 + }
1.1106 + } else {
1.1107 + result = display_driver->create_render_buffer(width,height);
1.1108 + if( result != NULL ) {
1.1109 + render_buffers[render_buffer_count++] = result;
1.1110 + }
1.1111 + }
1.1112 }
1.1113
1.1114 if( result != NULL ) {
1.1115 - result->address = render_addr;
1.1116 + result->address = render_addr;
1.1117 }
1.1118 return result;
1.1119 }
1.1120 @@ -949,9 +949,9 @@
1.1121 uint32_t render_stride = MMIO_READ( PVR2, RENDER_SIZE ) << 3;
1.1122
1.1123 if( render_addr & 0x01000000 ) { /* vram64 */
1.1124 - render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE_INT;
1.1125 + render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE_INT;
1.1126 } else { /* vram32 */
1.1127 - render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE;
1.1128 + render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE;
1.1129 }
1.1130
1.1131 int width = pvr2_scene_buffer_width();
1.1132 @@ -961,12 +961,12 @@
1.1133 result = pvr2_alloc_render_buffer( render_addr, width, height );
1.1134 /* Setup the buffer */
1.1135 if( result != NULL ) {
1.1136 - result->rowstride = render_stride;
1.1137 - result->colour_format = colour_format;
1.1138 - result->scale = render_scale;
1.1139 - result->size = width * height * colour_formats[colour_format].bpp;
1.1140 - result->flushed = FALSE;
1.1141 - result->inverted = TRUE; // render buffers are inverted normally
1.1142 + result->rowstride = render_stride;
1.1143 + result->colour_format = colour_format;
1.1144 + result->scale = render_scale;
1.1145 + result->size = width * height * colour_formats[colour_format].bpp;
1.1146 + result->flushed = FALSE;
1.1147 + result->inverted = TRUE; // render buffers are inverted normally
1.1148 }
1.1149 return result;
1.1150 }
1.1151 @@ -975,18 +975,18 @@
1.1152 {
1.1153 render_buffer_t result = pvr2_alloc_render_buffer( frame->address, frame->width, frame->height );
1.1154 if( result != NULL ) {
1.1155 - int bpp = colour_formats[frame->colour_format].bpp;
1.1156 - result->rowstride = frame->rowstride;
1.1157 - result->colour_format = frame->colour_format;
1.1158 - result->scale = 0x400;
1.1159 - result->size = frame->width * frame->height * bpp;
1.1160 - result->flushed = TRUE;
1.1161 - result->inverted = frame->inverted;
1.1162 - display_driver->load_frame_buffer( frame, result );
1.1163 + int bpp = colour_formats[frame->colour_format].bpp;
1.1164 + result->rowstride = frame->rowstride;
1.1165 + result->colour_format = frame->colour_format;
1.1166 + result->scale = 0x400;
1.1167 + result->size = frame->width * frame->height * bpp;
1.1168 + result->flushed = TRUE;
1.1169 + result->inverted = frame->inverted;
1.1170 + display_driver->load_frame_buffer( frame, result );
1.1171 }
1.1172 return result;
1.1173 }
1.1174 -
1.1175 +
1.1176
1.1177 /**
1.1178 * Invalidate any caching on the supplied address. Specifically, if it falls
1.1179 @@ -997,18 +997,18 @@
1.1180 int i;
1.1181 address = address & 0x1FFFFFFF;
1.1182 for( i=0; i<render_buffer_count; i++ ) {
1.1183 - uint32_t bufaddr = render_buffers[i]->address;
1.1184 - if( bufaddr != -1 && bufaddr <= address &&
1.1185 - (bufaddr + render_buffers[i]->size) > address ) {
1.1186 - if( !render_buffers[i]->flushed ) {
1.1187 - pvr2_render_buffer_copy_to_sh4( render_buffers[i] );
1.1188 - render_buffers[i]->flushed = TRUE;
1.1189 - }
1.1190 - if( isWrite ) {
1.1191 - render_buffers[i]->address = -1; /* Invalid */
1.1192 - }
1.1193 - return TRUE; /* should never have overlapping buffers */
1.1194 - }
1.1195 + uint32_t bufaddr = render_buffers[i]->address;
1.1196 + if( bufaddr != -1 && bufaddr <= address &&
1.1197 + (bufaddr + render_buffers[i]->size) > address ) {
1.1198 + if( !render_buffers[i]->flushed ) {
1.1199 + pvr2_render_buffer_copy_to_sh4( render_buffers[i] );
1.1200 + render_buffers[i]->flushed = TRUE;
1.1201 + }
1.1202 + if( isWrite ) {
1.1203 + render_buffers[i]->address = -1; /* Invalid */
1.1204 + }
1.1205 + return TRUE; /* should never have overlapping buffers */
1.1206 + }
1.1207 }
1.1208 return FALSE;
1.1209 }
.