Search
lxdream.org :: lxdream/src/pvr2/pvr2.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2.c
changeset 850:28782ebbd01d
prev805:b355f7b3ff2e
next851:41e8ae2c114b
author nkeynes
date Mon Sep 08 07:56:33 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Add lightgun support
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2.c Thu Aug 07 23:53:17 2008 +0000
1.2 +++ b/src/pvr2/pvr2.c Mon Sep 08 07:56:33 2008 +0000
1.3 @@ -115,7 +115,8 @@
1.4 * Event handler for the scanline callbacks. Fires the corresponding
1.5 * ASIC event, and resets the timer for the next field.
1.6 */
1.7 -static void pvr2_scanline_callback( int eventid ) {
1.8 +static void pvr2_scanline_callback( int eventid )
1.9 +{
1.10 asic_event( eventid );
1.11 pvr2_update_raster_posn(sh4r.slice_cycle);
1.12 if( eventid == EVENT_SCANLINE1 ) {
1.13 @@ -125,6 +126,14 @@
1.14 }
1.15 }
1.16
1.17 +static void pvr2_gunpos_callback( int eventid )
1.18 +{
1.19 + pvr2_update_raster_posn(sh4r.slice_cycle);
1.20 + int hpos = pvr2_state.line_remainder * pvr2_state.dot_clock / 1000000;
1.21 + MMIO_WRITE( PVR2, GUNPOS, ((pvr2_state.line_count<<16)|(hpos&0x3FF)) );
1.22 + asic_event( EVENT_MAPLE_DMA );
1.23 +}
1.24 +
1.25 static void pvr2_init( void )
1.26 {
1.27 int i;
1.28 @@ -134,6 +143,7 @@
1.29 register_event_callback( EVENT_HPOS, pvr2_hpos_callback );
1.30 register_event_callback( EVENT_SCANLINE1, pvr2_scanline_callback );
1.31 register_event_callback( EVENT_SCANLINE2, pvr2_scanline_callback );
1.32 + register_event_callback( EVENT_GUNPOS, pvr2_gunpos_callback );
1.33 video_base = mem_get_region_by_name( MEM_REGION_VIDEO );
1.34 texcache_init();
1.35 pvr2_reset();
1.36 @@ -789,6 +799,13 @@
1.37 }
1.38 }
1.39
1.40 +void pvr2_queue_gun_event( int xpos, int ypos )
1.41 +{
1.42 + pvr2_update_raster_posn(sh4r.slice_cycle);
1.43 + pvr2_schedule_scanline_event( EVENT_GUNPOS, (ypos >> 1) + pvr2_state.vsync_lines, 0,
1.44 + (1000000 * xpos / pvr2_state.dot_clock) + pvr2_state.hsync_width_ns );
1.45 +}
1.46 +
1.47 MMIO_REGION_READ_FN( PVR2, reg )
1.48 {
1.49 switch( reg ) {
.