revision 736:a02d1475ccfd
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 736:a02d1475ccfd |
parent | 735:c3aac20f118e |
child | 737:7477adafe909 |
author | nkeynes |
date | Mon Jul 14 07:44:42 2008 +0000 (15 years ago) |
Re-indent everything consistently
Fix include guards for consistency as well
Fix include guards for consistency as well
1.1 --- a/src/aica/aica.c Mon Jul 14 07:42:45 2008 +00001.2 +++ b/src/aica/aica.c Mon Jul 14 07:44:42 2008 +00001.3 @@ -41,8 +41,8 @@1.4 uint32_t aica_run_slice( uint32_t );1.6 struct dreamcast_module aica_module = { "AICA", aica_init, aica_reset,1.7 - aica_start, aica_run_slice, aica_stop,1.8 - aica_save_state, aica_load_state };1.9 + aica_start, aica_run_slice, aica_stop,1.10 + aica_save_state, aica_load_state };1.12 struct aica_state_struct {1.13 uint32_t time_of_day;1.14 @@ -82,7 +82,7 @@1.15 aica_state.nanosecs_done = 0;1.16 aica_state.event_pending = 0;1.17 aica_state.clear_count = 0;1.18 -// aica_event(2); /* Pre-deliver a timer interrupt */1.19 + // aica_event(2); /* Pre-deliver a timer interrupt */1.20 }1.22 void aica_start( void )1.23 @@ -95,17 +95,17 @@1.24 /* Run arm instructions */1.25 int reset = MMIO_READ( AICA2, AICA_RESET );1.26 if( (reset & 1) == 0 ) { /* Running */1.27 - int num_samples = (int)((uint64_t)AICA_SAMPLE_RATE * (aica_state.nanosecs_done + nanosecs) / 1000000000) - aica_state.samples_done;1.28 - num_samples = arm_run_slice( num_samples );1.29 - audio_mix_samples( num_samples );1.30 + int num_samples = (int)((uint64_t)AICA_SAMPLE_RATE * (aica_state.nanosecs_done + nanosecs) / 1000000000) - aica_state.samples_done;1.31 + num_samples = arm_run_slice( num_samples );1.32 + audio_mix_samples( num_samples );1.34 - aica_state.samples_done += num_samples;1.35 - aica_state.nanosecs_done += nanosecs;1.36 + aica_state.samples_done += num_samples;1.37 + aica_state.nanosecs_done += nanosecs;1.38 }1.39 if( aica_state.nanosecs_done > 1000000000 ) {1.40 - aica_state.samples_done -= AICA_SAMPLE_RATE;1.41 - aica_state.nanosecs_done -= 1000000000;1.42 - aica_state.time_of_day++;1.43 + aica_state.samples_done -= AICA_SAMPLE_RATE;1.44 + aica_state.nanosecs_done -= 1000000000;1.45 + aica_state.time_of_day++;1.46 }1.47 return nanosecs;1.48 }1.49 @@ -136,35 +136,35 @@1.50 void aica_event( int event )1.51 {1.52 if( aica_state.event_pending == 0 )1.53 - armr.int_pending |= CPSR_F;1.54 + armr.int_pending |= CPSR_F;1.55 aica_state.event_pending |= (1<<event);1.56 -1.57 +1.58 int pending = MMIO_READ( AICA2, AICA_IRQ );1.59 if( pending == 0 || event < pending )1.60 - MMIO_WRITE( AICA2, AICA_IRQ, event );1.61 + MMIO_WRITE( AICA2, AICA_IRQ, event );1.62 }1.64 void aica_clear_event( )1.65 {1.66 aica_state.clear_count++;1.67 if( aica_state.clear_count == 4 ) {1.68 - int i;1.69 - aica_state.clear_count = 0;1.70 + int i;1.71 + aica_state.clear_count = 0;1.73 - for( i=0; i<8; i++ ) {1.74 - if( aica_state.event_pending & (1<<i) ) {1.75 - aica_state.event_pending &= ~(1<<i);1.76 - break;1.77 - }1.78 - }1.79 - for( ;i<8; i++ ) {1.80 - if( aica_state.event_pending & (1<<i) ) {1.81 - MMIO_WRITE( AICA2, AICA_IRQ, i );1.82 - break;1.83 - }1.84 - }1.85 - if( aica_state.event_pending == 0 )1.86 - armr.int_pending &= ~CPSR_F;1.87 + for( i=0; i<8; i++ ) {1.88 + if( aica_state.event_pending & (1<<i) ) {1.89 + aica_state.event_pending &= ~(1<<i);1.90 + break;1.91 + }1.92 + }1.93 + for( ;i<8; i++ ) {1.94 + if( aica_state.event_pending & (1<<i) ) {1.95 + MMIO_WRITE( AICA2, AICA_IRQ, i );1.96 + break;1.97 + }1.98 + }1.99 + if( aica_state.event_pending == 0 )1.100 + armr.int_pending &= ~CPSR_F;1.101 }1.102 }1.104 @@ -218,24 +218,24 @@1.106 switch( reg ) {1.107 case AICA_RESET:1.108 - tmp = MMIO_READ( AICA2, AICA_RESET );1.109 - if( (tmp & 1) == 1 && (val & 1) == 0 ) {1.110 - /* ARM enabled - execute a core reset */1.111 - DEBUG( "ARM enabled" );1.112 - arm_reset();1.113 - aica_state.samples_done = 0;1.114 - aica_state.nanosecs_done = 0;1.115 - } else if( (tmp&1) == 0 && (val&1) == 1 ) {1.116 - DEBUG( "ARM disabled" );1.117 - }1.118 - MMIO_WRITE( AICA2, AICA_RESET, val );1.119 - break;1.120 + tmp = MMIO_READ( AICA2, AICA_RESET );1.121 + if( (tmp & 1) == 1 && (val & 1) == 0 ) {1.122 + /* ARM enabled - execute a core reset */1.123 + DEBUG( "ARM enabled" );1.124 + arm_reset();1.125 + aica_state.samples_done = 0;1.126 + aica_state.nanosecs_done = 0;1.127 + } else if( (tmp&1) == 0 && (val&1) == 1 ) {1.128 + DEBUG( "ARM disabled" );1.129 + }1.130 + MMIO_WRITE( AICA2, AICA_RESET, val );1.131 + break;1.132 case AICA_IRQCLEAR:1.133 - aica_clear_event();1.134 - break;1.135 + aica_clear_event();1.136 + break;1.137 default:1.138 - MMIO_WRITE( AICA2, reg, val );1.139 - break;1.140 + MMIO_WRITE( AICA2, reg, val );1.141 + break;1.142 }1.143 }1.145 @@ -246,21 +246,21 @@1.146 int32_t val;1.147 switch( reg ) {1.148 case AICA_CHANSTATE:1.149 - channo = (MMIO_READ( AICA2, AICA_CHANSEL ) >> 8) & 0x3F;1.150 - channel = audio_get_channel(channo);1.151 - if( channel->loop == LOOP_LOOPED ) {1.152 - val = 0x8000;1.153 - channel->loop = LOOP_ON;1.154 - } else {1.155 - val = 0;1.156 - }1.157 - return val;1.158 + channo = (MMIO_READ( AICA2, AICA_CHANSEL ) >> 8) & 0x3F;1.159 + channel = audio_get_channel(channo);1.160 + if( channel->loop == LOOP_LOOPED ) {1.161 + val = 0x8000;1.162 + channel->loop = LOOP_ON;1.163 + } else {1.164 + val = 0;1.165 + }1.166 + return val;1.167 case AICA_CHANPOSN:1.168 - channo = (MMIO_READ( AICA2, AICA_CHANSEL ) >> 8) & 0x3F;1.169 - channel = audio_get_channel(channo);1.170 - return channel->posn;1.171 + channo = (MMIO_READ( AICA2, AICA_CHANSEL ) >> 8) & 0x3F;1.172 + channel = audio_get_channel(channo);1.173 + return channel->posn;1.174 default:1.175 - return MMIO_READ( AICA2, reg );1.176 + return MMIO_READ( AICA2, reg );1.177 }1.178 }1.180 @@ -270,10 +270,10 @@1.181 switch( reg ) {1.182 case AICA_RTCHI:1.183 rv = (aica_state.time_of_day >> 16) & 0xFFFF;1.184 - break;1.185 + break;1.186 case AICA_RTCLO:1.187 - rv = aica_state.time_of_day & 0xFFFF;1.188 - break;1.189 + rv = aica_state.time_of_day & 0xFFFF;1.190 + break;1.191 }1.192 // DEBUG( "Read AICA RTC %d => %08X", reg, rv );1.193 return rv;1.194 @@ -284,22 +284,22 @@1.195 {1.196 switch( reg ) {1.197 case AICA_RTCEN:1.198 - MMIO_WRITE( AICARTC, reg, val&0x01 );1.199 - break;1.200 + MMIO_WRITE( AICARTC, reg, val&0x01 );1.201 + break;1.202 case AICA_RTCLO:1.203 - if( MMIO_READ( AICARTC, AICA_RTCEN ) & 0x01 ) {1.204 - aica_state.time_of_day = (aica_state.time_of_day & 0xFFFF0000) | (val & 0xFFFF);1.205 - }1.206 - break;1.207 + if( MMIO_READ( AICARTC, AICA_RTCEN ) & 0x01 ) {1.208 + aica_state.time_of_day = (aica_state.time_of_day & 0xFFFF0000) | (val & 0xFFFF);1.209 + }1.210 + break;1.211 case AICA_RTCHI:1.212 - if( MMIO_READ( AICARTC, AICA_RTCEN ) & 0x01 ) {1.213 - aica_state.time_of_day = (aica_state.time_of_day & 0xFFFF) | (val<<16);1.214 - MMIO_WRITE( AICARTC, AICA_RTCEN, 0 );1.215 - }1.216 - break;1.217 + if( MMIO_READ( AICARTC, AICA_RTCEN ) & 0x01 ) {1.218 + aica_state.time_of_day = (aica_state.time_of_day & 0xFFFF) | (val<<16);1.219 + MMIO_WRITE( AICARTC, AICA_RTCEN, 0 );1.220 + }1.221 + break;1.222 }1.223 }1.224 -1.225 +1.226 /**1.227 * Translate the channel frequency to a sample rate. The frequency is a1.228 * 14-bit floating point number, where bits 0..9 is the mantissa,1.229 @@ -314,14 +314,14 @@1.230 uint32_t mantissa = freq & 0x03FF;1.231 uint32_t rate;1.232 if( freq & 0x4000 ) {1.233 - /* neg exponent - rate < 44100 */1.234 - exponent = 8 - exponent;1.235 - rate = (44100 >> exponent) +1.236 - ((44100 * mantissa) >> (10+exponent));1.237 + /* neg exponent - rate < 44100 */1.238 + exponent = 8 - exponent;1.239 + rate = (44100 >> exponent) +1.240 + ((44100 * mantissa) >> (10+exponent));1.241 } else {1.242 - /* pos exponent - rate > 44100 */1.243 - rate = (44100 << exponent) +1.244 - ((44100 * mantissa) >> (10-exponent));1.245 + /* pos exponent - rate > 44100 */1.246 + rate = (44100 << exponent) +1.247 + ((44100 * mantissa) >> (10-exponent));1.248 }1.249 return rate;1.250 }1.251 @@ -330,12 +330,12 @@1.252 {1.253 int i;1.254 for( i=0; i<32; i++ ) {1.255 - uint32_t val = MMIO_READ( AICA0, i<<7 );1.256 - audio_start_stop_channel(i, val&0x4000);1.257 + uint32_t val = MMIO_READ( AICA0, i<<7 );1.258 + audio_start_stop_channel(i, val&0x4000);1.259 }1.260 for( ; i<64; i++ ) {1.261 - uint32_t val = MMIO_READ( AICA1, (i-32)<<7 );1.262 - audio_start_stop_channel(i, val&0x4000);1.263 + uint32_t val = MMIO_READ( AICA1, (i-32)<<7 );1.264 + audio_start_stop_channel(i, val&0x4000);1.265 }1.266 }1.268 @@ -343,22 +343,22 @@1.269 * Derived directly from Dan Potter's log table1.270 */1.271 uint8_t aica_volume_table[256] = {1.272 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,1.273 - 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4,1.274 - 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9,1.275 - 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16,1.276 - 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 22, 22, 23, 23, 24, 25,1.277 - 25, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 34, 35, 36,1.278 - 37, 37, 38, 39, 40, 40, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49,1.279 - 50, 51, 52, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,1.280 - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, 81,1.281 - 82, 83, 85, 86, 87, 88, 89, 90, 92, 93, 94, 95, 97, 98, 99, 100,1.282 - 102, 103, 104, 105, 107, 108, 109, 111, 112, 113, 115, 116, 117, 119, 120, 121,1.283 - 123, 124, 126, 127, 128, 130, 131, 133, 134, 136, 137, 139, 140, 142, 143, 145,1.284 - 146, 148, 149, 151, 152, 154, 155, 157, 159, 160, 162, 163, 165, 167, 168, 170,1.285 - 171, 173, 175, 176, 178, 180, 181, 183, 185, 187, 188, 190, 192, 194, 195, 197,1.286 - 199, 201, 202, 204, 206, 208, 210, 211, 213, 215, 217, 219, 221, 223, 224, 226,1.287 - 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 253, 254, 255 };1.288 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,1.289 + 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4,1.290 + 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9,1.291 + 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16,1.292 + 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 22, 22, 23, 23, 24, 25,1.293 + 25, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 34, 35, 36,1.294 + 37, 37, 38, 39, 40, 40, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49,1.295 + 50, 51, 52, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,1.296 + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, 81,1.297 + 82, 83, 85, 86, 87, 88, 89, 90, 92, 93, 94, 95, 97, 98, 99, 100,1.298 + 102, 103, 104, 105, 107, 108, 109, 111, 112, 113, 115, 116, 117, 119, 120, 121,1.299 + 123, 124, 126, 127, 128, 130, 131, 133, 134, 136, 137, 139, 140, 142, 143, 145,1.300 + 146, 148, 149, 151, 152, 154, 155, 157, 159, 160, 162, 163, 165, 167, 168, 170,1.301 + 171, 173, 175, 176, 178, 180, 181, 183, 185, 187, 188, 190, 192, 194, 195, 197,1.302 + 199, 201, 202, 204, 206, 208, 210, 211, 213, 215, 217, 219, 221, 223, 224, 226,1.303 + 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 253, 254, 255 };1.306 void aica_write_channel( int channelNo, uint32_t reg, uint32_t val )1.307 @@ -367,58 +367,58 @@1.308 audio_channel_t channel = audio_get_channel(channelNo);1.309 switch( reg ) {1.310 case 0x00: /* Config + high address bits*/1.311 - channel->start = (channel->start & 0xFFFF) | ((val&0x1F) << 16);1.312 - if( val & 0x200 )1.313 - channel->loop = LOOP_ON;1.314 - else1.315 - channel->loop = LOOP_OFF;1.316 - switch( (val >> 7) & 0x03 ) {1.317 - case 0:1.318 - channel->sample_format = AUDIO_FMT_16BIT;1.319 - break;1.320 - case 1:1.321 - channel->sample_format = AUDIO_FMT_8BIT;1.322 - break;1.323 - case 2:1.324 - case 3:1.325 - channel->sample_format = AUDIO_FMT_ADPCM;1.326 - break;1.327 - }1.328 - if( val & 0x8000 ) {1.329 - aica_start_stop_channels();1.330 - }1.331 - break;1.332 - case 0x04: /* Low 16 address bits */1.333 - channel->start = (channel->start & 0x001F0000) | val;1.334 - break;1.335 - case 0x08: /* Loop start */1.336 - channel->loop_start = val;1.337 - break;1.338 - case 0x0C: /* End */1.339 - channel->end = val;1.340 - break;1.341 - case 0x10: /* Envelope register 1 */1.342 - break;1.343 - case 0x14: /* Envelope register 2 */1.344 - break;1.345 - case 0x18: /* Frequency */1.346 - channel->sample_rate = aica_frequency_to_sample_rate ( val );1.347 - break;1.348 - case 0x1C: /* ??? */1.349 - case 0x20: /* ??? */1.350 - case 0x24: /* Volume? /pan */1.351 - val = val & 0x1F;1.352 - if( val <= 0x0F )1.353 - val = 0x0F - val; /* Convert to smooth pan over 0..31 */1.354 - channel->pan = val;1.355 - break;1.356 - case 0x28: /* Volume */1.357 - // This isn't remotely correct, but it will have to suffice until I have1.358 - // time to figure out what's actually going on here...1.359 - channel->vol = aica_volume_table[max((val & 0xFF),((val>>8)&0xFF))];1.360 - break;1.361 - default: /* ??? */1.362 - break;1.363 + channel->start = (channel->start & 0xFFFF) | ((val&0x1F) << 16);1.364 + if( val & 0x200 )1.365 + channel->loop = LOOP_ON;1.366 + else1.367 + channel->loop = LOOP_OFF;1.368 + switch( (val >> 7) & 0x03 ) {1.369 + case 0:1.370 + channel->sample_format = AUDIO_FMT_16BIT;1.371 + break;1.372 + case 1:1.373 + channel->sample_format = AUDIO_FMT_8BIT;1.374 + break;1.375 + case 2:1.376 + case 3:1.377 + channel->sample_format = AUDIO_FMT_ADPCM;1.378 + break;1.379 + }1.380 + if( val & 0x8000 ) {1.381 + aica_start_stop_channels();1.382 + }1.383 + break;1.384 + case 0x04: /* Low 16 address bits */1.385 + channel->start = (channel->start & 0x001F0000) | val;1.386 + break;1.387 + case 0x08: /* Loop start */1.388 + channel->loop_start = val;1.389 + break;1.390 + case 0x0C: /* End */1.391 + channel->end = val;1.392 + break;1.393 + case 0x10: /* Envelope register 1 */1.394 + break;1.395 + case 0x14: /* Envelope register 2 */1.396 + break;1.397 + case 0x18: /* Frequency */1.398 + channel->sample_rate = aica_frequency_to_sample_rate ( val );1.399 + break;1.400 + case 0x1C: /* ??? */1.401 + case 0x20: /* ??? */1.402 + case 0x24: /* Volume? /pan */1.403 + val = val & 0x1F;1.404 + if( val <= 0x0F )1.405 + val = 0x0F - val; /* Convert to smooth pan over 0..31 */1.406 + channel->pan = val;1.407 + break;1.408 + case 0x28: /* Volume */1.409 + // This isn't remotely correct, but it will have to suffice until I have1.410 + // time to figure out what's actually going on here...1.411 + channel->vol = aica_volume_table[max((val & 0xFF),((val>>8)&0xFF))];1.412 + break;1.413 + default: /* ??? */1.414 + break;1.415 }1.417 }
2.1 --- a/src/aica/armcore.c Mon Jul 14 07:42:45 2008 +00002.2 +++ b/src/aica/armcore.c Mon Jul 14 07:44:42 2008 +00002.3 @@ -30,12 +30,12 @@2.4 void arm_set_mode( int mode );2.6 uint32_t arm_exceptions[][2] = {{ MODE_SVC, 0x00000000 },2.7 - { MODE_UND, 0x00000004 },2.8 - { MODE_SVC, 0x00000008 },2.9 - { MODE_ABT, 0x0000000C },2.10 - { MODE_ABT, 0x00000010 },2.11 - { MODE_IRQ, 0x00000018 },2.12 - { MODE_FIQ, 0x0000001C } };2.13 + { MODE_UND, 0x00000004 },2.14 + { MODE_SVC, 0x00000008 },2.15 + { MODE_ABT, 0x0000000C },2.16 + { MODE_ABT, 0x00000010 },2.17 + { MODE_IRQ, 0x00000018 },2.18 + { MODE_FIQ, 0x0000001C } };2.20 #define EXC_RESET 02.21 #define EXC_UNDEFINED 12.22 @@ -65,15 +65,15 @@2.23 int i;2.25 for( i=0; i<arm_breakpoint_count; i++ ) {2.26 - if( arm_breakpoints[i].address == pc &&2.27 - arm_breakpoints[i].type == type ) {2.28 - while( ++i < arm_breakpoint_count ) {2.29 - arm_breakpoints[i-1].address = arm_breakpoints[i].address;2.30 - arm_breakpoints[i-1].type = arm_breakpoints[i].type;2.31 - }2.32 - arm_breakpoint_count--;2.33 - return TRUE;2.34 - }2.35 + if( arm_breakpoints[i].address == pc &&2.36 + arm_breakpoints[i].type == type ) {2.37 + while( ++i < arm_breakpoint_count ) {2.38 + arm_breakpoints[i-1].address = arm_breakpoints[i].address;2.39 + arm_breakpoints[i-1].type = arm_breakpoints[i].type;2.40 + }2.41 + arm_breakpoint_count--;2.42 + return TRUE;2.43 + }2.44 }2.45 return FALSE;2.46 }2.47 @@ -82,8 +82,8 @@2.48 {2.49 int i;2.50 for( i=0; i<arm_breakpoint_count; i++ ) {2.51 - if( arm_breakpoints[i].address == pc )2.52 - return arm_breakpoints[i].type;2.53 + if( arm_breakpoints[i].address == pc )2.54 + return arm_breakpoints[i].type;2.55 }2.56 return 0;2.57 }2.58 @@ -93,35 +93,35 @@2.59 int i,j,k;2.61 if( !armr.running )2.62 - return num_samples;2.63 + return num_samples;2.65 for( i=0; i<num_samples; i++ ) {2.66 - for( j=0; j < CYCLES_PER_SAMPLE; j++ ) {2.67 - armr.icount++;2.68 - if( !arm_execute_instruction() )2.69 - return i;2.70 + for( j=0; j < CYCLES_PER_SAMPLE; j++ ) {2.71 + armr.icount++;2.72 + if( !arm_execute_instruction() )2.73 + return i;2.74 #ifdef ENABLE_DEBUG_MODE2.75 - for( k=0; k<arm_breakpoint_count; k++ ) {2.76 - if( arm_breakpoints[k].address == armr.r[15] ) {2.77 - dreamcast_stop();2.78 - if( arm_breakpoints[k].type == BREAK_ONESHOT )2.79 - arm_clear_breakpoint( armr.r[15], BREAK_ONESHOT );2.80 - return i;2.81 - }2.82 - }2.83 + for( k=0; k<arm_breakpoint_count; k++ ) {2.84 + if( arm_breakpoints[k].address == armr.r[15] ) {2.85 + dreamcast_stop();2.86 + if( arm_breakpoints[k].type == BREAK_ONESHOT )2.87 + arm_clear_breakpoint( armr.r[15], BREAK_ONESHOT );2.88 + return i;2.89 + }2.90 + }2.91 #endif2.92 - }2.93 -2.94 - k = MMIO_READ( AICA2, AICA_TCR );2.95 - uint8_t val = MMIO_READ( AICA2, AICA_TIMER );2.96 - val++;2.97 - if( val == 0 ) {2.98 - aica_event( AICA_EVENT_TIMER );2.99 - // MMIO_WRITE( AICA2, AICA_TCR, k & ~0x40 );2.100 - }2.101 - MMIO_WRITE( AICA2, AICA_TIMER, val );2.102 - if( !dreamcast_is_running() )2.103 - break;2.104 + }2.105 +2.106 + k = MMIO_READ( AICA2, AICA_TCR );2.107 + uint8_t val = MMIO_READ( AICA2, AICA_TIMER );2.108 + val++;2.109 + if( val == 0 ) {2.110 + aica_event( AICA_EVENT_TIMER );2.111 + // MMIO_WRITE( AICA2, AICA_TCR, k & ~0x40 );2.112 + }2.113 + MMIO_WRITE( AICA2, AICA_TIMER, val );2.114 + if( !dreamcast_is_running() )2.115 + break;2.116 }2.118 return i;2.119 @@ -173,12 +173,12 @@2.120 static uint32_t *arm_user_reg( int reg )2.121 {2.122 if( IS_EXCEPTION_MODE() ) {2.123 - if( reg == 13 || reg == 14 )2.124 - return &armr.user_r[reg-8];2.125 - if( IS_FIQ_MODE() ) {2.126 - if( reg >= 8 || reg <= 12 )2.127 - return &armr.user_r[reg-8];2.128 - }2.129 + if( reg == 13 || reg == 14 )2.130 + return &armr.user_r[reg-8];2.131 + if( IS_FIQ_MODE() ) {2.132 + if( reg >= 8 || reg <= 12 )2.133 + return &armr.user_r[reg-8];2.134 + }2.135 }2.136 return &armr.r[reg];2.137 }2.138 @@ -195,23 +195,23 @@2.139 void arm_set_cpsr( uint32_t value, uint32_t fields )2.140 {2.141 if( IS_PRIVILEGED_MODE() ) {2.142 - if( fields & SET_CPSR_CONTROL ) {2.143 - int mode = value & CPSR_MODE;2.144 - arm_set_mode( mode );2.145 - armr.t = ( value & CPSR_T ); /* Technically illegal to change */2.146 - armr.cpsr = (armr.cpsr & 0xFFFFFF00) | (value & 0x000000FF);2.147 - }2.148 + if( fields & SET_CPSR_CONTROL ) {2.149 + int mode = value & CPSR_MODE;2.150 + arm_set_mode( mode );2.151 + armr.t = ( value & CPSR_T ); /* Technically illegal to change */2.152 + armr.cpsr = (armr.cpsr & 0xFFFFFF00) | (value & 0x000000FF);2.153 + }2.155 - /* Middle 16 bits not currently defined */2.156 + /* Middle 16 bits not currently defined */2.157 }2.158 if( fields & SET_CPSR_FLAGS ) {2.159 - /* Break flags directly out of given value - don't bother writing2.160 - * back to CPSR2.161 - */2.162 - armr.n = ( value & CPSR_N );2.163 - armr.z = ( value & CPSR_Z );2.164 - armr.c = ( value & CPSR_C );2.165 - armr.v = ( value & CPSR_V );2.166 + /* Break flags directly out of given value - don't bother writing2.167 + * back to CPSR2.168 + */2.169 + armr.n = ( value & CPSR_N );2.170 + armr.z = ( value & CPSR_Z );2.171 + armr.c = ( value & CPSR_C );2.172 + armr.v = ( value & CPSR_V );2.173 }2.174 }2.176 @@ -219,15 +219,15 @@2.177 {2.178 /* Only defined if we actually have an SPSR register */2.179 if( IS_EXCEPTION_MODE() ) {2.180 - if( fields & SET_CPSR_CONTROL ) {2.181 - armr.spsr = (armr.spsr & 0xFFFFFF00) | (value & 0x000000FF);2.182 - }2.183 + if( fields & SET_CPSR_CONTROL ) {2.184 + armr.spsr = (armr.spsr & 0xFFFFFF00) | (value & 0x000000FF);2.185 + }2.187 - /* Middle 16 bits not currently defined */2.188 + /* Middle 16 bits not currently defined */2.190 - if( fields & SET_CPSR_FLAGS ) {2.191 - armr.spsr = (armr.spsr & 0x00FFFFFF) | (value & 0xFF000000);2.192 - }2.193 + if( fields & SET_CPSR_FLAGS ) {2.194 + armr.spsr = (armr.spsr & 0x00FFFFFF) | (value & 0xFF000000);2.195 + }2.196 }2.197 }2.199 @@ -244,7 +244,7 @@2.200 armr.r[14] = armr.r[15] + 4;2.201 armr.cpsr = (spsr & 0xFFFFFF00) | mode | CPSR_I;2.202 if( mode == MODE_FIQ )2.203 - armr.cpsr |= CPSR_F;2.204 + armr.cpsr |= CPSR_F;2.205 armr.r[15] = arm_exceptions[exception][1];2.206 }2.208 @@ -272,92 +272,92 @@2.209 {2.210 int currentMode = armr.cpsr & CPSR_MODE;2.211 if( currentMode == targetMode )2.212 - return;2.213 + return;2.215 switch( currentMode ) {2.216 case MODE_USER:2.217 case MODE_SYS:2.218 - armr.user_r[5] = armr.r[13];2.219 - armr.user_r[6] = armr.r[14];2.220 - break;2.221 + armr.user_r[5] = armr.r[13];2.222 + armr.user_r[6] = armr.r[14];2.223 + break;2.224 case MODE_SVC:2.225 - armr.svc_r[0] = armr.r[13];2.226 - armr.svc_r[1] = armr.r[14];2.227 - armr.svc_r[2] = armr.spsr;2.228 - break;2.229 + armr.svc_r[0] = armr.r[13];2.230 + armr.svc_r[1] = armr.r[14];2.231 + armr.svc_r[2] = armr.spsr;2.232 + break;2.233 case MODE_ABT:2.234 - armr.abt_r[0] = armr.r[13];2.235 - armr.abt_r[1] = armr.r[14];2.236 - armr.abt_r[2] = armr.spsr;2.237 - break;2.238 + armr.abt_r[0] = armr.r[13];2.239 + armr.abt_r[1] = armr.r[14];2.240 + armr.abt_r[2] = armr.spsr;2.241 + break;2.242 case MODE_UND:2.243 - armr.und_r[0] = armr.r[13];2.244 - armr.und_r[1] = armr.r[14];2.245 - armr.und_r[2] = armr.spsr;2.246 - break;2.247 + armr.und_r[0] = armr.r[13];2.248 + armr.und_r[1] = armr.r[14];2.249 + armr.und_r[2] = armr.spsr;2.250 + break;2.251 case MODE_IRQ:2.252 - armr.irq_r[0] = armr.r[13];2.253 - armr.irq_r[1] = armr.r[14];2.254 - armr.irq_r[2] = armr.spsr;2.255 - break;2.256 + armr.irq_r[0] = armr.r[13];2.257 + armr.irq_r[1] = armr.r[14];2.258 + armr.irq_r[2] = armr.spsr;2.259 + break;2.260 case MODE_FIQ:2.261 - armr.fiq_r[0] = armr.r[8];2.262 - armr.fiq_r[1] = armr.r[9];2.263 - armr.fiq_r[2] = armr.r[10];2.264 - armr.fiq_r[3] = armr.r[11];2.265 - armr.fiq_r[4] = armr.r[12];2.266 - armr.fiq_r[5] = armr.r[13];2.267 - armr.fiq_r[6] = armr.r[14];2.268 - armr.fiq_r[7] = armr.spsr;2.269 - armr.r[8] = armr.user_r[0];2.270 - armr.r[9] = armr.user_r[1];2.271 - armr.r[10] = armr.user_r[2];2.272 - armr.r[11] = armr.user_r[3];2.273 - armr.r[12] = armr.user_r[4];2.274 - break;2.275 + armr.fiq_r[0] = armr.r[8];2.276 + armr.fiq_r[1] = armr.r[9];2.277 + armr.fiq_r[2] = armr.r[10];2.278 + armr.fiq_r[3] = armr.r[11];2.279 + armr.fiq_r[4] = armr.r[12];2.280 + armr.fiq_r[5] = armr.r[13];2.281 + armr.fiq_r[6] = armr.r[14];2.282 + armr.fiq_r[7] = armr.spsr;2.283 + armr.r[8] = armr.user_r[0];2.284 + armr.r[9] = armr.user_r[1];2.285 + armr.r[10] = armr.user_r[2];2.286 + armr.r[11] = armr.user_r[3];2.287 + armr.r[12] = armr.user_r[4];2.288 + break;2.289 }2.290 -2.291 +2.292 switch( targetMode ) {2.293 case MODE_USER:2.294 case MODE_SYS:2.295 - armr.r[13] = armr.user_r[5];2.296 - armr.r[14] = armr.user_r[6];2.297 - break;2.298 + armr.r[13] = armr.user_r[5];2.299 + armr.r[14] = armr.user_r[6];2.300 + break;2.301 case MODE_SVC:2.302 - armr.r[13] = armr.svc_r[0];2.303 - armr.r[14] = armr.svc_r[1];2.304 - armr.spsr = armr.svc_r[2];2.305 - break;2.306 + armr.r[13] = armr.svc_r[0];2.307 + armr.r[14] = armr.svc_r[1];2.308 + armr.spsr = armr.svc_r[2];2.309 + break;2.310 case MODE_ABT:2.311 - armr.r[13] = armr.abt_r[0];2.312 - armr.r[14] = armr.abt_r[1];2.313 - armr.spsr = armr.abt_r[2];2.314 - break;2.315 + armr.r[13] = armr.abt_r[0];2.316 + armr.r[14] = armr.abt_r[1];2.317 + armr.spsr = armr.abt_r[2];2.318 + break;2.319 case MODE_UND:2.320 - armr.r[13] = armr.und_r[0];2.321 - armr.r[14] = armr.und_r[1];2.322 - armr.spsr = armr.und_r[2];2.323 - break;2.324 + armr.r[13] = armr.und_r[0];2.325 + armr.r[14] = armr.und_r[1];2.326 + armr.spsr = armr.und_r[2];2.327 + break;2.328 case MODE_IRQ:2.329 - armr.r[13] = armr.irq_r[0];2.330 - armr.r[14] = armr.irq_r[1];2.331 - armr.spsr = armr.irq_r[2];2.332 - break;2.333 + armr.r[13] = armr.irq_r[0];2.334 + armr.r[14] = armr.irq_r[1];2.335 + armr.spsr = armr.irq_r[2];2.336 + break;2.337 case MODE_FIQ:2.338 - armr.user_r[0] = armr.r[8];2.339 - armr.user_r[1] = armr.r[9];2.340 - armr.user_r[2] = armr.r[10];2.341 - armr.user_r[3] = armr.r[11];2.342 - armr.user_r[4] = armr.r[12];2.343 - armr.r[8] = armr.fiq_r[0];2.344 - armr.r[9] = armr.fiq_r[1];2.345 - armr.r[10] = armr.fiq_r[2];2.346 - armr.r[11] = armr.fiq_r[3];2.347 - armr.r[12] = armr.fiq_r[4];2.348 - armr.r[13] = armr.fiq_r[5];2.349 - armr.r[14] = armr.fiq_r[6];2.350 - armr.spsr = armr.fiq_r[7];2.351 - break;2.352 + armr.user_r[0] = armr.r[8];2.353 + armr.user_r[1] = armr.r[9];2.354 + armr.user_r[2] = armr.r[10];2.355 + armr.user_r[3] = armr.r[11];2.356 + armr.user_r[4] = armr.r[12];2.357 + armr.r[8] = armr.fiq_r[0];2.358 + armr.r[9] = armr.fiq_r[1];2.359 + armr.r[10] = armr.fiq_r[2];2.360 + armr.r[11] = armr.fiq_r[3];2.361 + armr.r[12] = armr.fiq_r[4];2.362 + armr.r[13] = armr.fiq_r[5];2.363 + armr.r[14] = armr.fiq_r[6];2.364 + armr.spsr = armr.fiq_r[7];2.365 + break;2.366 }2.367 }2.369 @@ -418,54 +418,54 @@2.370 */2.371 static uint32_t arm_get_shift_operand( uint32_t ir )2.372 {2.373 - uint32_t operand, tmp;2.374 - if( IFLAG(ir) == 0 ) {2.375 - operand = RM(ir);2.376 - switch(SHIFT(ir)) {2.377 - case 0: /* (Rm << imm) */2.378 - operand = operand << SHIFTIMM(ir);2.379 - break;2.380 - case 1: /* (Rm << Rs) */2.381 - tmp = RS(ir)&0xFF;2.382 - if( tmp > 31 ) operand = 0;2.383 - else operand = operand << tmp;2.384 - break;2.385 - case 2: /* (Rm >> imm) */2.386 - operand = operand >> SHIFTIMM(ir);2.387 - break;2.388 - case 3: /* (Rm >> Rs) */2.389 - tmp = RS(ir) & 0xFF;2.390 - if( tmp > 31 ) operand = 0;2.391 - else operand = operand >> ir;2.392 - break;2.393 - case 4: /* (Rm >>> imm) */2.394 - tmp = SHIFTIMM(ir);2.395 - if( tmp == 0 ) operand = ((int32_t)operand) >> 31;2.396 - else operand = ((int32_t)operand) >> tmp;2.397 - break;2.398 - case 5: /* (Rm >>> Rs) */2.399 - tmp = RS(ir) & 0xFF;2.400 - if( tmp > 31 ) operand = ((int32_t)operand) >> 31;2.401 - else operand = ((int32_t)operand) >> tmp;2.402 - break;2.403 - case 6:2.404 - tmp = SHIFTIMM(ir);2.405 - if( tmp == 0 ) /* RRX aka rotate with carry */2.406 - operand = (operand >> 1) | (armr.c<<31);2.407 - else2.408 - operand = ROTATE_RIGHT_LONG(operand,tmp);2.409 - break;2.410 - case 7:2.411 - tmp = RS(ir)&0x1F;2.412 - operand = ROTATE_RIGHT_LONG(operand,tmp);2.413 - break;2.414 - }2.415 - } else {2.416 - operand = IMM8(ir);2.417 - tmp = IMMROT(ir);2.418 - operand = ROTATE_RIGHT_LONG(operand, tmp);2.419 - }2.420 - return operand;2.421 + uint32_t operand, tmp;2.422 + if( IFLAG(ir) == 0 ) {2.423 + operand = RM(ir);2.424 + switch(SHIFT(ir)) {2.425 + case 0: /* (Rm << imm) */2.426 + operand = operand << SHIFTIMM(ir);2.427 + break;2.428 + case 1: /* (Rm << Rs) */2.429 + tmp = RS(ir)&0xFF;2.430 + if( tmp > 31 ) operand = 0;2.431 + else operand = operand << tmp;2.432 + break;2.433 + case 2: /* (Rm >> imm) */2.434 + operand = operand >> SHIFTIMM(ir);2.435 + break;2.436 + case 3: /* (Rm >> Rs) */2.437 + tmp = RS(ir) & 0xFF;2.438 + if( tmp > 31 ) operand = 0;2.439 + else operand = operand >> ir;2.440 + break;2.441 + case 4: /* (Rm >>> imm) */2.442 + tmp = SHIFTIMM(ir);2.443 + if( tmp == 0 ) operand = ((int32_t)operand) >> 31;2.444 + else operand = ((int32_t)operand) >> tmp;2.445 + break;2.446 + case 5: /* (Rm >>> Rs) */2.447 + tmp = RS(ir) & 0xFF;2.448 + if( tmp > 31 ) operand = ((int32_t)operand) >> 31;2.449 + else operand = ((int32_t)operand) >> tmp;2.450 + break;2.451 + case 6:2.452 + tmp = SHIFTIMM(ir);2.453 + if( tmp == 0 ) /* RRX aka rotate with carry */2.454 + operand = (operand >> 1) | (armr.c<<31);2.455 + else2.456 + operand = ROTATE_RIGHT_LONG(operand,tmp);2.457 + break;2.458 + case 7:2.459 + tmp = RS(ir)&0x1F;2.460 + operand = ROTATE_RIGHT_LONG(operand,tmp);2.461 + break;2.462 + }2.463 + } else {2.464 + operand = IMM8(ir);2.465 + tmp = IMMROT(ir);2.466 + operand = ROTATE_RIGHT_LONG(operand, tmp);2.467 + }2.468 + return operand;2.469 }2.471 /**2.472 @@ -475,115 +475,115 @@2.473 */2.474 static uint32_t arm_get_shift_operand_s( uint32_t ir )2.475 {2.476 - uint32_t operand, tmp;2.477 - if( IFLAG(ir) == 0 ) {2.478 - operand = RM(ir);2.479 - switch(SHIFT(ir)) {2.480 - case 0: /* (Rm << imm) */2.481 - tmp = SHIFTIMM(ir);2.482 - if( tmp == 0 ) { /* Rm */2.483 - armr.shift_c = armr.c;2.484 - } else { /* Rm << imm */2.485 - armr.shift_c = (operand >> (32-tmp)) & 0x01;2.486 - operand = operand << tmp;2.487 - }2.488 - break;2.489 - case 1: /* (Rm << Rs) */2.490 - tmp = RS(ir)&0xFF;2.491 - if( tmp == 0 ) {2.492 - armr.shift_c = armr.c;2.493 - } else {2.494 - if( tmp <= 32 )2.495 - armr.shift_c = (operand >> (32-tmp)) & 0x01;2.496 - else armr.shift_c = 0;2.497 - if( tmp < 32 )2.498 - operand = operand << tmp;2.499 - else operand = 0;2.500 - }2.501 - break;2.502 - case 2: /* (Rm >> imm) */2.503 - tmp = SHIFTIMM(ir);2.504 - if( tmp == 0 ) {2.505 - armr.shift_c = operand >> 31;2.506 - operand = 0;2.507 - } else {2.508 - armr.shift_c = (operand >> (tmp-1)) & 0x01;2.509 - operand = RM(ir) >> tmp;2.510 - }2.511 - break;2.512 - case 3: /* (Rm >> Rs) */2.513 - tmp = RS(ir) & 0xFF;2.514 - if( tmp == 0 ) {2.515 - armr.shift_c = armr.c;2.516 - } else {2.517 - if( tmp <= 32 )2.518 - armr.shift_c = (operand >> (tmp-1))&0x01;2.519 - else armr.shift_c = 0;2.520 - if( tmp < 32 )2.521 - operand = operand >> tmp;2.522 - else operand = 0;2.523 - }2.524 - break;2.525 - case 4: /* (Rm >>> imm) */2.526 - tmp = SHIFTIMM(ir);2.527 - if( tmp == 0 ) {2.528 - armr.shift_c = operand >> 31;2.529 - operand = -armr.shift_c;2.530 - } else {2.531 - armr.shift_c = (operand >> (tmp-1)) & 0x01;2.532 - operand = ((int32_t)operand) >> tmp;2.533 - }2.534 - break;2.535 - case 5: /* (Rm >>> Rs) */2.536 - tmp = RS(ir) & 0xFF;2.537 - if( tmp == 0 ) {2.538 - armr.shift_c = armr.c;2.539 - } else {2.540 - if( tmp < 32 ) {2.541 - armr.shift_c = (operand >> (tmp-1))&0x01;2.542 - operand = ((int32_t)operand) >> tmp;2.543 - } else {2.544 - armr.shift_c = operand >> 31;2.545 - operand = ((int32_t)operand) >> 31;2.546 - }2.547 - }2.548 - break;2.549 - case 6:2.550 - tmp = SHIFTIMM(ir);2.551 - if( tmp == 0 ) { /* RRX aka rotate with carry */2.552 - armr.shift_c = operand&0x01;2.553 - operand = (operand >> 1) | (armr.c<<31);2.554 - } else {2.555 - armr.shift_c = operand>>(tmp-1);2.556 - operand = ROTATE_RIGHT_LONG(operand,tmp);2.557 - }2.558 - break;2.559 - case 7:2.560 - tmp = RS(ir)&0xFF;2.561 - if( tmp == 0 ) {2.562 - armr.shift_c = armr.c;2.563 - } else {2.564 - tmp &= 0x1F;2.565 - if( tmp == 0 ) {2.566 - armr.shift_c = operand>>31;2.567 - } else {2.568 - armr.shift_c = (operand>>(tmp-1))&0x1;2.569 - operand = ROTATE_RIGHT_LONG(operand,tmp);2.570 - }2.571 - }2.572 - break;2.573 - }2.574 - } else {2.575 - operand = IMM8(ir);2.576 - tmp = IMMROT(ir);2.577 - if( tmp == 0 ) {2.578 - armr.shift_c = armr.c;2.579 - } else {2.580 - operand = ROTATE_RIGHT_LONG(operand, tmp);2.581 - armr.shift_c = operand>>31;2.582 - }2.583 - }2.584 - return operand;2.585 + uint32_t operand, tmp;2.586 + if( IFLAG(ir) == 0 ) {2.587 + operand = RM(ir);2.588 + switch(SHIFT(ir)) {2.589 + case 0: /* (Rm << imm) */2.590 + tmp = SHIFTIMM(ir);2.591 + if( tmp == 0 ) { /* Rm */2.592 + armr.shift_c = armr.c;2.593 + } else { /* Rm << imm */2.594 + armr.shift_c = (operand >> (32-tmp)) & 0x01;2.595 + operand = operand << tmp;2.596 + }2.597 + break;2.598 + case 1: /* (Rm << Rs) */2.599 + tmp = RS(ir)&0xFF;2.600 + if( tmp == 0 ) {2.601 + armr.shift_c = armr.c;2.602 + } else {2.603 + if( tmp <= 32 )2.604 + armr.shift_c = (operand >> (32-tmp)) & 0x01;2.605 + else armr.shift_c = 0;2.606 + if( tmp < 32 )2.607 + operand = operand << tmp;2.608 + else operand = 0;2.609 + }2.610 + break;2.611 + case 2: /* (Rm >> imm) */2.612 + tmp = SHIFTIMM(ir);2.613 + if( tmp == 0 ) {2.614 + armr.shift_c = operand >> 31;2.615 + operand = 0;2.616 + } else {2.617 + armr.shift_c = (operand >> (tmp-1)) & 0x01;2.618 + operand = RM(ir) >> tmp;2.619 + }2.620 + break;2.621 + case 3: /* (Rm >> Rs) */2.622 + tmp = RS(ir) & 0xFF;2.623 + if( tmp == 0 ) {2.624 + armr.shift_c = armr.c;2.625 + } else {2.626 + if( tmp <= 32 )2.627 + armr.shift_c = (operand >> (tmp-1))&0x01;2.628 + else armr.shift_c = 0;2.629 + if( tmp < 32 )2.630 + operand = operand >> tmp;2.631 + else operand = 0;2.632 + }2.633 + break;2.634 + case 4: /* (Rm >>> imm) */2.635 + tmp = SHIFTIMM(ir);2.636 + if( tmp == 0 ) {2.637 + armr.shift_c = operand >> 31;2.638 + operand = -armr.shift_c;2.639 + } else {2.640 + armr.shift_c = (operand >> (tmp-1)) & 0x01;2.641 + operand = ((int32_t)operand) >> tmp;2.642 + }2.643 + break;2.644 + case 5: /* (Rm >>> Rs) */2.645 + tmp = RS(ir) & 0xFF;2.646 + if( tmp == 0 ) {2.647 + armr.shift_c = armr.c;2.648 + } else {2.649 + if( tmp < 32 ) {2.650 + armr.shift_c = (operand >> (tmp-1))&0x01;2.651 + operand = ((int32_t)operand) >> tmp;2.652 + } else {2.653 + armr.shift_c = operand >> 31;2.654 + operand = ((int32_t)operand) >> 31;2.655 + }2.656 + }2.657 + break;2.658 + case 6:2.659 + tmp = SHIFTIMM(ir);2.660 + if( tmp == 0 ) { /* RRX aka rotate with carry */2.661 + armr.shift_c = operand&0x01;2.662 + operand = (operand >> 1) | (armr.c<<31);2.663 + } else {2.664 + armr.shift_c = operand>>(tmp-1);2.665 + operand = ROTATE_RIGHT_LONG(operand,tmp);2.666 + }2.667 + break;2.668 + case 7:2.669 + tmp = RS(ir)&0xFF;2.670 + if( tmp == 0 ) {2.671 + armr.shift_c = armr.c;2.672 + } else {2.673 + tmp &= 0x1F;2.674 + if( tmp == 0 ) {2.675 + armr.shift_c = operand>>31;2.676 + } else {2.677 + armr.shift_c = (operand>>(tmp-1))&0x1;2.678 + operand = ROTATE_RIGHT_LONG(operand,tmp);2.679 + }2.680 + }2.681 + break;2.682 + }2.683 + } else {2.684 + operand = IMM8(ir);2.685 + tmp = IMMROT(ir);2.686 + if( tmp == 0 ) {2.687 + armr.shift_c = armr.c;2.688 + } else {2.689 + operand = ROTATE_RIGHT_LONG(operand, tmp);2.690 + armr.shift_c = operand>>31;2.691 + }2.692 + }2.693 + return operand;2.694 }2.696 /**2.697 @@ -595,31 +595,31 @@2.698 */2.699 static uint32_t arm_get_address_index( uint32_t ir )2.700 {2.701 - uint32_t operand = RM(ir);2.702 - uint32_t tmp;2.703 -2.704 - switch(SHIFT(ir)) {2.705 - case 0: /* (Rm << imm) */2.706 - operand = operand << SHIFTIMM(ir);2.707 - break;2.708 - case 2: /* (Rm >> imm) */2.709 - operand = operand >> SHIFTIMM(ir);2.710 - break;2.711 - case 4: /* (Rm >>> imm) */2.712 - tmp = SHIFTIMM(ir);2.713 - if( tmp == 0 ) operand = ((int32_t)operand) >> 31;2.714 - else operand = ((int32_t)operand) >> tmp;2.715 - break;2.716 - case 6:2.717 - tmp = SHIFTIMM(ir);2.718 - if( tmp == 0 ) /* RRX aka rotate with carry */2.719 - operand = (operand >> 1) | (armr.c<<31);2.720 - else2.721 - operand = ROTATE_RIGHT_LONG(operand,tmp);2.722 - break;2.723 - default: UNIMP(ir);2.724 - }2.725 - return operand;2.726 + uint32_t operand = RM(ir);2.727 + uint32_t tmp;2.728 +2.729 + switch(SHIFT(ir)) {2.730 + case 0: /* (Rm << imm) */2.731 + operand = operand << SHIFTIMM(ir);2.732 + break;2.733 + case 2: /* (Rm >> imm) */2.734 + operand = operand >> SHIFTIMM(ir);2.735 + break;2.736 + case 4: /* (Rm >>> imm) */2.737 + tmp = SHIFTIMM(ir);2.738 + if( tmp == 0 ) operand = ((int32_t)operand) >> 31;2.739 + else operand = ((int32_t)operand) >> tmp;2.740 + break;2.741 + case 6:2.742 + tmp = SHIFTIMM(ir);2.743 + if( tmp == 0 ) /* RRX aka rotate with carry */2.744 + operand = (operand >> 1) | (armr.c<<31);2.745 + else2.746 + operand = ROTATE_RIGHT_LONG(operand,tmp);2.747 + break;2.748 + default: UNIMP(ir);2.749 + }2.750 + return operand;2.751 }2.753 /**2.754 @@ -631,60 +631,60 @@2.755 */2.756 static uint32_t arm_get_address_operand( uint32_t ir )2.757 {2.758 - uint32_t addr=0;2.759 -2.760 - /* I P U . W */2.761 - switch( (ir>>21)&0x1D ) {2.762 - case 0: /* Rn -= imm offset (post-indexed) [5.2.8 A5-28] */2.763 - case 1:2.764 - addr = RN(ir);2.765 - LRN(ir) = addr - IMM12(ir);2.766 - break;2.767 - case 4: /* Rn += imm offsett (post-indexed) [5.2.8 A5-28] */2.768 - case 5:2.769 - addr = RN(ir);2.770 - LRN(ir) = addr + IMM12(ir);2.771 - break;2.772 - case 8: /* Rn - imm offset [5.2.2 A5-20] */2.773 - addr = RN(ir) - IMM12(ir);2.774 - break;2.775 - case 9: /* Rn -= imm offset (pre-indexed) [5.2.5 A5-24] */2.776 - addr = RN(ir) - IMM12(ir);2.777 - LRN(ir) = addr;2.778 - break;2.779 - case 12: /* Rn + imm offset [5.2.2 A5-20] */2.780 - addr = RN(ir) + IMM12(ir);2.781 - break;2.782 - case 13: /* Rn += imm offset [5.2.5 A5-24 ] */2.783 - addr = RN(ir) + IMM12(ir);2.784 - LRN(ir) = addr;2.785 - break;2.786 - case 16: /* Rn -= Rm (post-indexed) [5.2.10 A5-32 ] */2.787 - case 17:2.788 - addr = RN(ir);2.789 - LRN(ir) = addr - arm_get_address_index(ir);2.790 - break;2.791 - case 20: /* Rn += Rm (post-indexed) [5.2.10 A5-32 ] */2.792 - case 21:2.793 - addr = RN(ir);2.794 - LRN(ir) = addr - arm_get_address_index(ir);2.795 - break;2.796 - case 24: /* Rn - Rm [5.2.4 A5-23] */2.797 - addr = RN(ir) - arm_get_address_index(ir);2.798 - break;2.799 - case 25: /* RN -= Rm (pre-indexed) [5.2.7 A5-26] */2.800 - addr = RN(ir) - arm_get_address_index(ir);2.801 - LRN(ir) = addr;2.802 - break;2.803 - case 28: /* Rn + Rm [5.2.4 A5-23] */2.804 - addr = RN(ir) + arm_get_address_index(ir);2.805 - break;2.806 - case 29: /* RN += Rm (pre-indexed) [5.2.7 A5-26] */2.807 - addr = RN(ir) + arm_get_address_index(ir);2.808 - LRN(ir) = addr;2.809 - break;2.810 - }2.811 - return addr;2.812 + uint32_t addr=0;2.813 +2.814 + /* I P U . W */2.815 + switch( (ir>>21)&0x1D ) {2.816 + case 0: /* Rn -= imm offset (post-indexed) [5.2.8 A5-28] */2.817 + case 1:2.818 + addr = RN(ir);2.819 + LRN(ir) = addr - IMM12(ir);2.820 + break;2.821 + case 4: /* Rn += imm offsett (post-indexed) [5.2.8 A5-28] */2.822 + case 5:2.823 + addr = RN(ir);2.824 + LRN(ir) = addr + IMM12(ir);2.825 + break;2.826 + case 8: /* Rn - imm offset [5.2.2 A5-20] */2.827 + addr = RN(ir) - IMM12(ir);2.828 + break;2.829 + case 9: /* Rn -= imm offset (pre-indexed) [5.2.5 A5-24] */2.830 + addr = RN(ir) - IMM12(ir);2.831 + LRN(ir) = addr;2.832 + break;2.833 + case 12: /* Rn + imm offset [5.2.2 A5-20] */2.834 + addr = RN(ir) + IMM12(ir);2.835 + break;2.836 + case 13: /* Rn += imm offset [5.2.5 A5-24 ] */2.837 + addr = RN(ir) + IMM12(ir);2.838 + LRN(ir) = addr;2.839 + break;2.840 + case 16: /* Rn -= Rm (post-indexed) [5.2.10 A5-32 ] */2.841 + case 17:2.842 + addr = RN(ir);2.843 + LRN(ir) = addr - arm_get_address_index(ir);2.844 + break;2.845 + case 20: /* Rn += Rm (post-indexed) [5.2.10 A5-32 ] */2.846 + case 21:2.847 + addr = RN(ir);2.848 + LRN(ir) = addr - arm_get_address_index(ir);2.849 + break;2.850 + case 24: /* Rn - Rm [5.2.4 A5-23] */2.851 + addr = RN(ir) - arm_get_address_index(ir);2.852 + break;2.853 + case 25: /* RN -= Rm (pre-indexed) [5.2.7 A5-26] */2.854 + addr = RN(ir) - arm_get_address_index(ir);2.855 + LRN(ir) = addr;2.856 + break;2.857 + case 28: /* Rn + Rm [5.2.4 A5-23] */2.858 + addr = RN(ir) + arm_get_address_index(ir);2.859 + break;2.860 + case 29: /* RN += Rm (pre-indexed) [5.2.7 A5-26] */2.861 + addr = RN(ir) + arm_get_address_index(ir);2.862 + LRN(ir) = addr;2.863 + break;2.864 + }2.865 + return addr;2.866 }2.868 gboolean arm_execute_instruction( void )2.869 @@ -696,11 +696,11 @@2.871 tmp = armr.int_pending & (~armr.cpsr);2.872 if( tmp ) {2.873 - if( tmp & CPSR_F ) {2.874 - arm_raise_exception( EXC_FAST_IRQ );2.875 - } else {2.876 - arm_raise_exception( EXC_IRQ );2.877 - }2.878 + if( tmp & CPSR_F ) {2.879 + arm_raise_exception( EXC_FAST_IRQ );2.880 + } else {2.881 + arm_raise_exception( EXC_IRQ );2.882 + }2.883 }2.885 ir = MEM_READ_LONG(PC);2.886 @@ -713,673 +713,673 @@2.887 */2.888 switch( COND(ir) ) {2.889 case 0: /* EQ */2.890 - cond = armr.z;2.891 - break;2.892 + cond = armr.z;2.893 + break;2.894 case 1: /* NE */2.895 - cond = !armr.z;2.896 - break;2.897 + cond = !armr.z;2.898 + break;2.899 case 2: /* CS/HS */2.900 - cond = armr.c;2.901 - break;2.902 + cond = armr.c;2.903 + break;2.904 case 3: /* CC/LO */2.905 - cond = !armr.c;2.906 - break;2.907 + cond = !armr.c;2.908 + break;2.909 case 4: /* MI */2.910 - cond = armr.n;2.911 - break;2.912 + cond = armr.n;2.913 + break;2.914 case 5: /* PL */2.915 - cond = !armr.n;2.916 - break;2.917 + cond = !armr.n;2.918 + break;2.919 case 6: /* VS */2.920 - cond = armr.v;2.921 - break;2.922 + cond = armr.v;2.923 + break;2.924 case 7: /* VC */2.925 - cond = !armr.v;2.926 - break;2.927 + cond = !armr.v;2.928 + break;2.929 case 8: /* HI */2.930 - cond = armr.c && !armr.z;2.931 - break;2.932 + cond = armr.c && !armr.z;2.933 + break;2.934 case 9: /* LS */2.935 - cond = (!armr.c) || armr.z;2.936 - break;2.937 + cond = (!armr.c) || armr.z;2.938 + break;2.939 case 10: /* GE */2.940 - cond = (armr.n == armr.v);2.941 - break;2.942 + cond = (armr.n == armr.v);2.943 + break;2.944 case 11: /* LT */2.945 - cond = (armr.n != armr.v);2.946 - break;2.947 + cond = (armr.n != armr.v);2.948 + break;2.949 case 12: /* GT */2.950 - cond = (!armr.z) && (armr.n == armr.v);2.951 - break;2.952 + cond = (!armr.z) && (armr.n == armr.v);2.953 + break;2.954 case 13: /* LE */2.955 - cond = armr.z || (armr.n != armr.v);2.956 - break;2.957 + cond = armr.z || (armr.n != armr.v);2.958 + break;2.959 case 14: /* AL */2.960 - cond = 1;2.961 - break;2.962 + cond = 1;2.963 + break;2.964 case 15: /* (NV) */2.965 default:2.966 - cond = 0;2.967 - UNDEF(ir);2.968 + cond = 0;2.969 + UNDEF(ir);2.970 }2.971 if( cond ) {2.973 - /**2.974 - * Condition passed, now for the actual instructions...2.975 - */2.976 - switch( GRP(ir) ) {2.977 - case 0:2.978 - if( (ir & 0x0D900000) == 0x01000000 ) {2.979 - /* Instructions that aren't actual data processing even though2.980 - * they sit in the DP instruction block.2.981 - */2.982 - switch( ir & 0x0FF000F0 ) {2.983 - case 0x01200010: /* BX Rd */2.984 - armr.t = ir & 0x01;2.985 - armr.r[15] = RM(ir) & 0xFFFFFFFE;2.986 - break;2.987 - case 0x01000000: /* MRS Rd, CPSR */2.988 - LRD(ir) = arm_get_cpsr();2.989 - break;2.990 - case 0x01400000: /* MRS Rd, SPSR */2.991 - LRD(ir) = armr.spsr;2.992 - break;2.993 - case 0x01200000: /* MSR CPSR, Rd */2.994 - arm_set_cpsr( RM(ir), ir );2.995 - break;2.996 - case 0x01600000: /* MSR SPSR, Rd */2.997 - arm_set_spsr( RM(ir), ir );2.998 - break;2.999 - case 0x03200000: /* MSR CPSR, imm */2.1000 - arm_set_cpsr( ROTIMM12(ir), ir );2.1001 - break;2.1002 - case 0x03600000: /* MSR SPSR, imm */2.1003 - arm_set_spsr( ROTIMM12(ir), ir );2.1004 - break;2.1005 - default:2.1006 - UNIMP(ir);2.1007 - }2.1008 - } else if( (ir & 0x0E000090) == 0x00000090 ) {2.1009 - /* Neither are these */2.1010 - switch( (ir>>5)&0x03 ) {2.1011 - case 0:2.1012 - /* Arithmetic extension area */2.1013 - switch(OPCODE(ir)) {2.1014 - case 0: /* MUL */2.1015 - LRN(ir) = RM(ir) * RS(ir);2.1016 - break;2.1017 - case 1: /* MULS */2.1018 - tmp = RM(ir) * RS(ir);2.1019 - LRN(ir) = tmp;2.1020 - armr.n = tmp>>31;2.1021 - armr.z = (tmp == 0);2.1022 - break;2.1023 - case 2: /* MLA */2.1024 - LRN(ir) = RM(ir) * RS(ir) + RD(ir);2.1025 - break;2.1026 - case 3: /* MLAS */2.1027 - tmp = RM(ir) * RS(ir) + RD(ir);2.1028 - LRN(ir) = tmp;2.1029 - armr.n = tmp>>31;2.1030 - armr.z = (tmp == 0);2.1031 - break;2.1032 - case 8: /* UMULL */2.1033 - case 9: /* UMULLS */2.1034 - case 10: /* UMLAL */2.1035 - case 11: /* UMLALS */2.1036 - case 12: /* SMULL */2.1037 - case 13: /* SMULLS */2.1038 - case 14: /* SMLAL */2.1039 - case 15: /* SMLALS */2.1040 - UNIMP(ir);2.1041 - break;2.1042 - case 16: /* SWP */2.1043 - tmp = arm_read_long( RN(ir) );2.1044 - switch( RN(ir) & 0x03 ) {2.1045 - case 1:2.1046 - tmp = ROTATE_RIGHT_LONG(tmp, 8);2.1047 - break;2.1048 - case 2:2.1049 - tmp = ROTATE_RIGHT_LONG(tmp, 16);2.1050 - break;2.1051 - case 3:2.1052 - tmp = ROTATE_RIGHT_LONG(tmp, 24);2.1053 - break;2.1054 - }2.1055 - arm_write_long( RN(ir), RM(ir) );2.1056 - LRD(ir) = tmp;2.1057 - break;2.1058 - case 20: /* SWPB */2.1059 - tmp = arm_read_byte( RN(ir) );2.1060 - arm_write_byte( RN(ir), RM(ir) );2.1061 - LRD(ir) = tmp;2.1062 - break;2.1063 - default:2.1064 - UNIMP(ir);2.1065 - }2.1066 - break;2.1067 - case 1:2.1068 - if( LFLAG(ir) ) {2.1069 - /* LDRH */2.1070 - } else {2.1071 - /* STRH */2.1072 - }2.1073 - UNIMP(ir);2.1074 - break;2.1075 - case 2:2.1076 - if( LFLAG(ir) ) {2.1077 - /* LDRSB */2.1078 - } else {2.1079 - }2.1080 - UNIMP(ir);2.1081 - break;2.1082 - case 3:2.1083 - if( LFLAG(ir) ) {2.1084 - /* LDRSH */2.1085 - } else {2.1086 - }2.1087 - UNIMP(ir);2.1088 - break;2.1089 - }2.1090 - } else {2.1091 - /* Data processing */2.1092 + /**2.1093 + * Condition passed, now for the actual instructions...2.1094 + */2.1095 + switch( GRP(ir) ) {2.1096 + case 0:2.1097 + if( (ir & 0x0D900000) == 0x01000000 ) {2.1098 + /* Instructions that aren't actual data processing even though2.1099 + * they sit in the DP instruction block.2.1100 + */2.1101 + switch( ir & 0x0FF000F0 ) {2.1102 + case 0x01200010: /* BX Rd */2.1103 + armr.t = ir & 0x01;2.1104 + armr.r[15] = RM(ir) & 0xFFFFFFFE;2.1105 + break;2.1106 + case 0x01000000: /* MRS Rd, CPSR */2.1107 + LRD(ir) = arm_get_cpsr();2.1108 + break;2.1109 + case 0x01400000: /* MRS Rd, SPSR */2.1110 + LRD(ir) = armr.spsr;2.1111 + break;2.1112 + case 0x01200000: /* MSR CPSR, Rd */2.1113 + arm_set_cpsr( RM(ir), ir );2.1114 + break;2.1115 + case 0x01600000: /* MSR SPSR, Rd */2.1116 + arm_set_spsr( RM(ir), ir );2.1117 + break;2.1118 + case 0x03200000: /* MSR CPSR, imm */2.1119 + arm_set_cpsr( ROTIMM12(ir), ir );2.1120 + break;2.1121 + case 0x03600000: /* MSR SPSR, imm */2.1122 + arm_set_spsr( ROTIMM12(ir), ir );2.1123 + break;2.1124 + default:2.1125 + UNIMP(ir);2.1126 + }2.1127 + } else if( (ir & 0x0E000090) == 0x00000090 ) {2.1128 + /* Neither are these */2.1129 + switch( (ir>>5)&0x03 ) {2.1130 + case 0:2.1131 + /* Arithmetic extension area */2.1132 + switch(OPCODE(ir)) {2.1133 + case 0: /* MUL */2.1134 + LRN(ir) = RM(ir) * RS(ir);2.1135 + break;2.1136 + case 1: /* MULS */2.1137 + tmp = RM(ir) * RS(ir);2.1138 + LRN(ir) = tmp;2.1139 + armr.n = tmp>>31;2.1140 + armr.z = (tmp == 0);2.1141 + break;2.1142 + case 2: /* MLA */2.1143 + LRN(ir) = RM(ir) * RS(ir) + RD(ir);2.1144 + break;2.1145 + case 3: /* MLAS */2.1146 + tmp = RM(ir) * RS(ir) + RD(ir);2.1147 + LRN(ir) = tmp;2.1148 + armr.n = tmp>>31;2.1149 + armr.z = (tmp == 0);2.1150 + break;2.1151 + case 8: /* UMULL */2.1152 + case 9: /* UMULLS */2.1153 + case 10: /* UMLAL */2.1154 + case 11: /* UMLALS */2.1155 + case 12: /* SMULL */2.1156 + case 13: /* SMULLS */2.1157 + case 14: /* SMLAL */2.1158 + case 15: /* SMLALS */2.1159 + UNIMP(ir);2.1160 + break;2.1161 + case 16: /* SWP */2.1162 + tmp = arm_read_long( RN(ir) );2.1163 + switch( RN(ir) & 0x03 ) {2.1164 + case 1:2.1165 + tmp = ROTATE_RIGHT_LONG(tmp, 8);2.1166 + break;2.1167 + case 2:2.1168 + tmp = ROTATE_RIGHT_LONG(tmp, 16);2.1169 + break;2.1170 + case 3:2.1171 + tmp = ROTATE_RIGHT_LONG(tmp, 24);2.1172 + break;2.1173 + }2.1174 + arm_write_long( RN(ir), RM(ir) );2.1175 + LRD(ir) = tmp;2.1176 + break;2.1177 + case 20: /* SWPB */2.1178 + tmp = arm_read_byte( RN(ir) );2.1179 + arm_write_byte( RN(ir), RM(ir) );2.1180 + LRD(ir) = tmp;2.1181 + break;2.1182 + default:2.1183 + UNIMP(ir);2.1184 + }2.1185 + break;2.1186 + case 1:2.1187 + if( LFLAG(ir) ) {2.1188 + /* LDRH */2.1189 + } else {2.1190 + /* STRH */2.1191 + }2.1192 + UNIMP(ir);2.1193 + break;2.1194 + case 2:2.1195 + if( LFLAG(ir) ) {2.1196 + /* LDRSB */2.1197 + } else {2.1198 + }2.1199 + UNIMP(ir);2.1200 + break;2.1201 + case 3:2.1202 + if( LFLAG(ir) ) {2.1203 + /* LDRSH */2.1204 + } else {2.1205 + }2.1206 + UNIMP(ir);2.1207 + break;2.1208 + }2.1209 + } else {2.1210 + /* Data processing */2.1212 - switch(OPCODE(ir)) {2.1213 - case 0: /* AND Rd, Rn, operand */2.1214 - LRD(ir) = RN(ir) & arm_get_shift_operand(ir);2.1215 - break;2.1216 - case 1: /* ANDS Rd, Rn, operand */2.1217 - operand = arm_get_shift_operand_s(ir) & RN(ir);2.1218 - LRD(ir) = operand;2.1219 - if( RDn(ir) == 15 ) {2.1220 - arm_restore_cpsr();2.1221 - } else {2.1222 - armr.n = operand>>31;2.1223 - armr.z = (operand == 0);2.1224 - armr.c = armr.shift_c;2.1225 - }2.1226 - break;2.1227 - case 2: /* EOR Rd, Rn, operand */2.1228 - LRD(ir) = RN(ir) ^ arm_get_shift_operand(ir);2.1229 - break;2.1230 - case 3: /* EORS Rd, Rn, operand */2.1231 - operand = arm_get_shift_operand_s(ir) ^ RN(ir);2.1232 - LRD(ir) = operand;2.1233 - if( RDn(ir) == 15 ) {2.1234 - arm_restore_cpsr();2.1235 - } else {2.1236 - armr.n = operand>>31;2.1237 - armr.z = (operand == 0);2.1238 - armr.c = armr.shift_c;2.1239 - }2.1240 - break;2.1241 - case 4: /* SUB Rd, Rn, operand */2.1242 - LRD(ir) = RN(ir) - arm_get_shift_operand(ir);2.1243 - break;2.1244 - case 5: /* SUBS Rd, Rn, operand */2.1245 - operand = RN(ir);2.1246 - operand2 = arm_get_shift_operand(ir);2.1247 - tmp = operand - operand2;2.1248 - LRD(ir) = tmp;2.1249 - if( RDn(ir) == 15 ) {2.1250 - arm_restore_cpsr();2.1251 - } else {2.1252 - armr.n = tmp>>31;2.1253 - armr.z = (tmp == 0);2.1254 - armr.c = IS_NOTBORROW(tmp,operand,operand2);2.1255 - armr.v = IS_SUBOVERFLOW(tmp,operand,operand2);2.1256 - }2.1257 - break;2.1258 - case 6: /* RSB Rd, operand, Rn */2.1259 - LRD(ir) = arm_get_shift_operand(ir) - RN(ir);2.1260 - break;2.1261 - case 7: /* RSBS Rd, operand, Rn */2.1262 - operand = arm_get_shift_operand(ir);2.1263 - operand2 = RN(ir);2.1264 - tmp = operand - operand2;2.1265 - LRD(ir) = tmp;2.1266 - if( RDn(ir) == 15 ) {2.1267 - arm_restore_cpsr();2.1268 - } else {2.1269 - armr.n = tmp>>31;2.1270 - armr.z = (tmp == 0);2.1271 - armr.c = IS_NOTBORROW(tmp,operand,operand2);2.1272 - armr.v = IS_SUBOVERFLOW(tmp,operand,operand2);2.1273 - }2.1274 - break;2.1275 - case 8: /* ADD Rd, Rn, operand */2.1276 - LRD(ir) = RN(ir) + arm_get_shift_operand(ir);2.1277 - break;2.1278 - case 9: /* ADDS Rd, Rn, operand */2.1279 - operand = arm_get_shift_operand(ir);2.1280 - operand2 = RN(ir);2.1281 - tmp = operand + operand2;2.1282 - LRD(ir) = tmp;2.1283 - if( RDn(ir) == 15 ) {2.1284 - arm_restore_cpsr();2.1285 - } else {2.1286 - armr.n = tmp>>31;2.1287 - armr.z = (tmp == 0);2.1288 - armr.c = IS_CARRY(tmp,operand,operand2);2.1289 - armr.v = IS_ADDOVERFLOW(tmp,operand,operand2);2.1290 - }2.1291 - break;2.1292 - case 10: /* ADC */2.1293 - LRD(ir) = RN(ir) + arm_get_shift_operand(ir) +2.1294 - (armr.c ? 1 : 0);2.1295 - break;2.1296 - case 11: /* ADCS */2.1297 - operand = arm_get_shift_operand(ir);2.1298 - operand2 = RN(ir);2.1299 - tmp = operand + operand2;2.1300 - tmp2 = tmp + armr.c ? 1 : 0;2.1301 - LRD(ir) = tmp2;2.1302 - if( RDn(ir) == 15 ) {2.1303 - arm_restore_cpsr();2.1304 - } else {2.1305 - armr.n = tmp >> 31;2.1306 - armr.z = (tmp == 0 );2.1307 - armr.c = IS_CARRY(tmp,operand,operand2) ||2.1308 - (tmp2 < tmp);2.1309 - armr.v = IS_ADDOVERFLOW(tmp,operand, operand2) ||2.1310 - ((tmp&0x80000000) != (tmp2&0x80000000));2.1311 - }2.1312 - break;2.1313 - case 12: /* SBC */2.1314 - LRD(ir) = RN(ir) - arm_get_shift_operand(ir) -2.1315 - (armr.c ? 0 : 1);2.1316 - break;2.1317 - case 13: /* SBCS */2.1318 - operand = RN(ir);2.1319 - operand2 = arm_get_shift_operand(ir);2.1320 - tmp = operand - operand2;2.1321 - tmp2 = tmp - (armr.c ? 0 : 1);2.1322 - if( RDn(ir) == 15 ) {2.1323 - arm_restore_cpsr();2.1324 - } else {2.1325 - armr.n = tmp >> 31;2.1326 - armr.z = (tmp == 0 );2.1327 - armr.c = IS_NOTBORROW(tmp,operand,operand2) &&2.1328 - (tmp2<tmp);2.1329 - armr.v = IS_SUBOVERFLOW(tmp,operand,operand2) ||2.1330 - ((tmp&0x80000000) != (tmp2&0x80000000));2.1331 - }2.1332 - break;2.1333 - case 14: /* RSC */2.1334 - LRD(ir) = arm_get_shift_operand(ir) - RN(ir) -2.1335 - (armr.c ? 0 : 1);2.1336 - break;2.1337 - case 15: /* RSCS */2.1338 - operand = arm_get_shift_operand(ir);2.1339 - operand2 = RN(ir);2.1340 - tmp = operand - operand2;2.1341 - tmp2 = tmp - (armr.c ? 0 : 1);2.1342 - if( RDn(ir) == 15 ) {2.1343 - arm_restore_cpsr();2.1344 - } else {2.1345 - armr.n = tmp >> 31;2.1346 - armr.z = (tmp == 0 );2.1347 - armr.c = IS_NOTBORROW(tmp,operand,operand2) &&2.1348 - (tmp2<tmp);2.1349 - armr.v = IS_SUBOVERFLOW(tmp,operand,operand2) ||2.1350 - ((tmp&0x80000000) != (tmp2&0x80000000));2.1351 - }2.1352 - break;2.1353 - case 17: /* TST Rn, operand */2.1354 - operand = arm_get_shift_operand_s(ir) & RN(ir);2.1355 - armr.n = operand>>31;2.1356 - armr.z = (operand == 0);2.1357 - armr.c = armr.shift_c;2.1358 - break;2.1359 - case 19: /* TEQ Rn, operand */2.1360 - operand = arm_get_shift_operand_s(ir) ^ RN(ir);2.1361 - armr.n = operand>>31;2.1362 - armr.z = (operand == 0);2.1363 - armr.c = armr.shift_c;2.1364 - break;2.1365 - case 21: /* CMP Rn, operand */2.1366 - operand = RN(ir);2.1367 - operand2 = arm_get_shift_operand(ir);2.1368 - tmp = operand - operand2;2.1369 - armr.n = tmp>>31;2.1370 - armr.z = (tmp == 0);2.1371 - armr.c = IS_NOTBORROW(tmp,operand,operand2);2.1372 - armr.v = IS_SUBOVERFLOW(tmp,operand,operand2);2.1373 - break;2.1374 - case 23: /* CMN Rn, operand */2.1375 - operand = RN(ir);2.1376 - operand2 = arm_get_shift_operand(ir);2.1377 - tmp = operand + operand2;2.1378 - armr.n = tmp>>31;2.1379 - armr.z = (tmp == 0);2.1380 - armr.c = IS_CARRY(tmp,operand,operand2);2.1381 - armr.v = IS_ADDOVERFLOW(tmp,operand,operand2);2.1382 - break;2.1383 - case 24: /* ORR Rd, Rn, operand */2.1384 - LRD(ir) = RN(ir) | arm_get_shift_operand(ir);2.1385 - break;2.1386 - case 25: /* ORRS Rd, Rn, operand */2.1387 - operand = arm_get_shift_operand_s(ir) | RN(ir);2.1388 - LRD(ir) = operand;2.1389 - if( RDn(ir) == 15 ) {2.1390 - arm_restore_cpsr();2.1391 - } else {2.1392 - armr.n = operand>>31;2.1393 - armr.z = (operand == 0);2.1394 - armr.c = armr.shift_c;2.1395 - }2.1396 - break;2.1397 - case 26: /* MOV Rd, operand */2.1398 - LRD(ir) = arm_get_shift_operand(ir);2.1399 - break;2.1400 - case 27: /* MOVS Rd, operand */2.1401 - operand = arm_get_shift_operand_s(ir);2.1402 - LRD(ir) = operand;2.1403 - if( RDn(ir) == 15 ) {2.1404 - arm_restore_cpsr();2.1405 - } else {2.1406 - armr.n = operand>>31;2.1407 - armr.z = (operand == 0);2.1408 - armr.c = armr.shift_c;2.1409 - }2.1410 - break;2.1411 - case 28: /* BIC Rd, Rn, operand */2.1412 - LRD(ir) = RN(ir) & (~arm_get_shift_operand(ir));2.1413 - break;2.1414 - case 29: /* BICS Rd, Rn, operand */2.1415 - operand = RN(ir) & (~arm_get_shift_operand_s(ir));2.1416 - LRD(ir) = operand;2.1417 - if( RDn(ir) == 15 ) {2.1418 - arm_restore_cpsr();2.1419 - } else {2.1420 - armr.n = operand>>31;2.1421 - armr.z = (operand == 0);2.1422 - armr.c = armr.shift_c;2.1423 - }2.1424 - break;2.1425 - case 30: /* MVN Rd, operand */2.1426 - LRD(ir) = ~arm_get_shift_operand(ir);2.1427 - break;2.1428 - case 31: /* MVNS Rd, operand */2.1429 - operand = ~arm_get_shift_operand_s(ir);2.1430 - LRD(ir) = operand;2.1431 - if( RDn(ir) == 15 ) {2.1432 - arm_restore_cpsr();2.1433 - } else {2.1434 - armr.n = operand>>31;2.1435 - armr.z = (operand == 0);2.1436 - armr.c = armr.shift_c;2.1437 - }2.1438 - break;2.1439 - default:2.1440 - UNIMP(ir);2.1441 - }2.1442 - }2.1443 - break;2.1444 - case 1: /* Load/store */2.1445 - operand = arm_get_address_operand(ir);2.1446 - switch( (ir>>20)&0x17 ) {2.1447 - case 0: case 16: case 18: /* STR Rd, address */2.1448 - arm_write_long( operand, RD(ir) );2.1449 - break;2.1450 - case 1: case 17: case 19: /* LDR Rd, address */2.1451 - LRD(ir) = arm_read_long(operand);2.1452 - break;2.1453 - case 2: /* STRT Rd, address */2.1454 - arm_write_long_user( operand, RD(ir) );2.1455 - break;2.1456 - case 3: /* LDRT Rd, address */2.1457 - LRD(ir) = arm_read_long_user( operand );2.1458 - break;2.1459 - case 4: case 20: case 22: /* STRB Rd, address */2.1460 - arm_write_byte( operand, RD(ir) );2.1461 - break;2.1462 - case 5: case 21: case 23: /* LDRB Rd, address */2.1463 - LRD(ir) = arm_read_byte( operand );2.1464 - break;2.1465 - case 6: /* STRBT Rd, address */2.1466 - arm_write_byte_user( operand, RD(ir) );2.1467 - break;2.1468 - case 7: /* LDRBT Rd, address */2.1469 - LRD(ir) = arm_read_byte_user( operand );2.1470 - break;2.1471 - }2.1472 - break;2.1473 - case 2: /* Load/store multiple, branch*/2.1474 - if( (ir & 0x02000000) == 0x02000000 ) { /* B[L] imm24 */2.1475 - operand = (SIGNEXT24(ir&0x00FFFFFF) << 2);2.1476 - if( (ir & 0x01000000) == 0x01000000 ) {2.1477 - armr.r[14] = pc; /* BL */2.1478 - }2.1479 - armr.r[15] = pc + 4 + operand;2.1480 - } else { /* Load/store multiple */2.1481 - gboolean needRestore = FALSE;2.1482 - operand = RN(ir);2.1483 -2.1484 - switch( (ir & 0x01D00000) >> 20 ) {2.1485 - case 0: /* STMDA */2.1486 - if( ir & 0x8000 ) {2.1487 - arm_write_long( operand, armr.r[15]+4 );2.1488 - operand -= 4;2.1489 - }2.1490 - for( i=14; i>= 0; i-- ) {2.1491 - if( (ir & (1<<i)) ) {2.1492 - arm_write_long( operand, armr.r[i] );2.1493 - operand -= 4;2.1494 - }2.1495 - }2.1496 - break;2.1497 - case 1: /* LDMDA */2.1498 - for( i=15; i>= 0; i-- ) {2.1499 - if( (ir & (1<<i)) ) {2.1500 - armr.r[i] = arm_read_long( operand );2.1501 - operand -= 4;2.1502 - }2.1503 - }2.1504 - break;2.1505 - case 4: /* STMDA (S) */2.1506 - if( ir & 0x8000 ) {2.1507 - arm_write_long( operand, armr.r[15]+4 );2.1508 - operand -= 4;2.1509 - }2.1510 - for( i=14; i>= 0; i-- ) {2.1511 - if( (ir & (1<<i)) ) {2.1512 - arm_write_long( operand, USER_R(i) );2.1513 - operand -= 4;2.1514 - }2.1515 - }2.1516 - break;2.1517 - case 5: /* LDMDA (S) */2.1518 - if( (ir&0x00008000) ) { /* Load PC */2.1519 - for( i=15; i>= 0; i-- ) {2.1520 - if( (ir & (1<<i)) ) {2.1521 - armr.r[i] = arm_read_long( operand );2.1522 - operand -= 4;2.1523 - }2.1524 - }2.1525 - needRestore = TRUE;2.1526 - } else {2.1527 - for( i=15; i>= 0; i-- ) {2.1528 - if( (ir & (1<<i)) ) {2.1529 - USER_R(i) = arm_read_long( operand );2.1530 - operand -= 4;2.1531 - }2.1532 - }2.1533 - }2.1534 - break;2.1535 - case 8: /* STMIA */2.1536 - for( i=0; i< 15; i++ ) {2.1537 - if( (ir & (1<<i)) ) {2.1538 - arm_write_long( operand, armr.r[i] );2.1539 - operand += 4;2.1540 - }2.1541 - }2.1542 - if( ir & 0x8000 ) {2.1543 - arm_write_long( operand, armr.r[15]+4 );2.1544 - operand += 4;2.1545 - }2.1546 - break;2.1547 - case 9: /* LDMIA */2.1548 - for( i=0; i< 16; i++ ) {2.1549 - if( (ir & (1<<i)) ) {2.1550 - armr.r[i] = arm_read_long( operand );2.1551 - operand += 4;2.1552 - }2.1553 - }2.1554 - break;2.1555 - case 12: /* STMIA (S) */2.1556 - for( i=0; i< 15; i++ ) {2.1557 - if( (ir & (1<<i)) ) {2.1558 - arm_write_long( operand, USER_R(i) );2.1559 - operand += 4;2.1560 - }2.1561 - }2.1562 - if( ir & 0x8000 ) {2.1563 - arm_write_long( operand, armr.r[15]+4 );2.1564 - operand += 4;2.1565 - }2.1566 - break;2.1567 - case 13: /* LDMIA (S) */2.1568 - if( (ir&0x00008000) ) { /* Load PC */2.1569 - for( i=0; i < 16; i++ ) {2.1570 - if( (ir & (1<<i)) ) {2.1571 - armr.r[i] = arm_read_long( operand );2.1572 - operand += 4;2.1573 - }2.1574 - }2.1575 - needRestore = TRUE;2.1576 - } else {2.1577 - for( i=0; i < 16; i++ ) {2.1578 - if( (ir & (1<<i)) ) {2.1579 - USER_R(i) = arm_read_long( operand );2.1580 - operand += 4;2.1581 - }2.1582 - }2.1583 - }2.1584 - break;2.1585 - case 16: /* STMDB */2.1586 - if( ir & 0x8000 ) {2.1587 - operand -= 4;2.1588 - arm_write_long( operand, armr.r[15]+4 );2.1589 - }2.1590 - for( i=14; i>= 0; i-- ) {2.1591 - if( (ir & (1<<i)) ) {2.1592 - operand -= 4;2.1593 - arm_write_long( operand, armr.r[i] );2.1594 - }2.1595 - }2.1596 - break;2.1597 - case 17: /* LDMDB */2.1598 - for( i=15; i>= 0; i-- ) {2.1599 - if( (ir & (1<<i)) ) {2.1600 - operand -= 4;2.1601 - armr.r[i] = arm_read_long( operand );2.1602 - }2.1603 - }2.1604 - break;2.1605 - case 20: /* STMDB (S) */2.1606 - if( ir & 0x8000 ) {2.1607 - operand -= 4;2.1608 - arm_write_long( operand, armr.r[15]+4 );2.1609 - }2.1610 - for( i=14; i>= 0; i-- ) {2.1611 - if( (ir & (1<<i)) ) {2.1612 - operand -= 4;2.1613 - arm_write_long( operand, USER_R(i) );2.1614 - }2.1615 - }2.1616 - break;2.1617 - case 21: /* LDMDB (S) */2.1618 - if( (ir&0x00008000) ) { /* Load PC */2.1619 - for( i=15; i>= 0; i-- ) {2.1620 - if( (ir & (1<<i)) ) {2.1621 - operand -= 4;2.1622 - armr.r[i] = arm_read_long( operand );2.1623 - }2.1624 - }2.1625 - needRestore = TRUE;2.1626 - } else {2.1627 - for( i=15; i>= 0; i-- ) {2.1628 - if( (ir & (1<<i)) ) {2.1629 - operand -= 4;2.1630 - USER_R(i) = arm_read_long( operand );2.1631 - }2.1632 - }2.1633 - }2.1634 - break;2.1635 - case 24: /* STMIB */2.1636 - for( i=0; i< 15; i++ ) {2.1637 - if( (ir & (1<<i)) ) {2.1638 - operand += 4;2.1639 - arm_write_long( operand, armr.r[i] );2.1640 - }2.1641 - }2.1642 - if( ir & 0x8000 ) {2.1643 - operand += 4;2.1644 - arm_write_long( operand, armr.r[15]+4 );2.1645 - }2.1646 - break;2.1647 - case 25: /* LDMIB */2.1648 - for( i=0; i< 16; i++ ) {2.1649 - if( (ir & (1<<i)) ) {2.1650 - operand += 4;2.1651 - armr.r[i] = arm_read_long( operand );2.1652 - }2.1653 - }2.1654 - break;2.1655 - case 28: /* STMIB (S) */2.1656 - for( i=0; i< 15; i++ ) {2.1657 - if( (ir & (1<<i)) ) {2.1658 - operand += 4;2.1659 - arm_write_long( operand, USER_R(i) );2.1660 - }2.1661 - }2.1662 - if( ir & 0x8000 ) {2.1663 - operand += 4;2.1664 - arm_write_long( operand, armr.r[15]+4 );2.1665 - }2.1666 - break;2.1667 - case 29: /* LDMIB (S) */2.1668 - if( (ir&0x00008000) ) { /* Load PC */2.1669 - for( i=0; i < 16; i++ ) {2.1670 - if( (ir & (1<<i)) ) {2.1671 - operand += 4;2.1672 - armr.r[i] = arm_read_long( operand );2.1673 - }2.1674 - }2.1675 - needRestore = TRUE;2.1676 - } else {2.1677 - for( i=0; i < 16; i++ ) {2.1678 - if( (ir & (1<<i)) ) {2.1679 - operand += 4;2.1680 - USER_R(i) = arm_read_long( operand );2.1681 - }2.1682 - }2.1683 - }2.1684 - break;2.1685 - }2.1686 -2.1687 - if( WFLAG(ir) )2.1688 - LRN(ir) = operand;2.1689 - if( needRestore )2.1690 - arm_restore_cpsr();2.1691 - }2.1692 - break;2.1693 - case 3: /* Copro */2.1694 - if( (ir & 0x0F000000) == 0x0F000000 ) { /* SWI */2.1695 - arm_raise_exception( EXC_SOFTWARE );2.1696 - } else {2.1697 - UNIMP(ir);2.1698 - }2.1699 - break;2.1700 - }2.1701 + switch(OPCODE(ir)) {2.1702 + case 0: /* AND Rd, Rn, operand */2.1703 + LRD(ir) = RN(ir) & arm_get_shift_operand(ir);2.1704 + break;2.1705 + case 1: /* ANDS Rd, Rn, operand */2.1706 + operand = arm_get_shift_operand_s(ir) & RN(ir);2.1707 + LRD(ir) = operand;2.1708 + if( RDn(ir) == 15 ) {2.1709 + arm_restore_cpsr();2.1710 + } else {2.1711 + armr.n = operand>>31;2.1712 + armr.z = (operand == 0);2.1713 + armr.c = armr.shift_c;2.1714 + }2.1715 + break;2.1716 + case 2: /* EOR Rd, Rn, operand */2.1717 + LRD(ir) = RN(ir) ^ arm_get_shift_operand(ir);2.1718 + break;2.1719 + case 3: /* EORS Rd, Rn, operand */2.1720 + operand = arm_get_shift_operand_s(ir) ^ RN(ir);2.1721 + LRD(ir) = operand;2.1722 + if( RDn(ir) == 15 ) {2.1723 + arm_restore_cpsr();2.1724 + } else {2.1725 + armr.n = operand>>31;2.1726 + armr.z = (operand == 0);2.1727 + armr.c = armr.shift_c;2.1728 + }2.1729 + break;2.1730 + case 4: /* SUB Rd, Rn, operand */2.1731 + LRD(ir) = RN(ir) - arm_get_shift_operand(ir);2.1732 + break;2.1733 + case 5: /* SUBS Rd, Rn, operand */2.1734 + operand = RN(ir);2.1735 + operand2 = arm_get_shift_operand(ir);2.1736 + tmp = operand - operand2;2.1737 + LRD(ir) = tmp;2.1738 + if( RDn(ir) == 15 ) {2.1739 + arm_restore_cpsr();2.1740 + } else {2.1741 + armr.n = tmp>>31;2.1742 + armr.z = (tmp == 0);2.1743 + armr.c = IS_NOTBORROW(tmp,operand,operand2);2.1744 + armr.v = IS_SUBOVERFLOW(tmp,operand,operand2);2.1745 + }2.1746 + break;2.1747 + case 6: /* RSB Rd, operand, Rn */2.1748 + LRD(ir) = arm_get_shift_operand(ir) - RN(ir);2.1749 + break;2.1750 + case 7: /* RSBS Rd, operand, Rn */2.1751 + operand = arm_get_shift_operand(ir);2.1752 + operand2 = RN(ir);2.1753 + tmp = operand - operand2;2.1754 + LRD(ir) = tmp;2.1755 + if( RDn(ir) == 15 ) {2.1756 + arm_restore_cpsr();2.1757 + } else {2.1758 + armr.n = tmp>>31;2.1759 + armr.z = (tmp == 0);2.1760 + armr.c = IS_NOTBORROW(tmp,operand,operand2);2.1761 + armr.v = IS_SUBOVERFLOW(tmp,operand,operand2);2.1762 + }2.1763 + break;2.1764 + case 8: /* ADD Rd, Rn, operand */2.1765 + LRD(ir) = RN(ir) + arm_get_shift_operand(ir);2.1766 + break;2.1767 + case 9: /* ADDS Rd, Rn, operand */2.1768 + operand = arm_get_shift_operand(ir);2.1769 + operand2 = RN(ir);2.1770 + tmp = operand + operand2;2.1771 + LRD(ir) = tmp;2.1772 + if( RDn(ir) == 15 ) {2.1773 + arm_restore_cpsr();2.1774 + } else {2.1775 + armr.n = tmp>>31;2.1776 + armr.z = (tmp == 0);2.1777 + armr.c = IS_CARRY(tmp,operand,operand2);2.1778 + armr.v = IS_ADDOVERFLOW(tmp,operand,operand2);2.1779 + }2.1780 + break;2.1781 + case 10: /* ADC */2.1782 + LRD(ir) = RN(ir) + arm_get_shift_operand(ir) +2.1783 + (armr.c ? 1 : 0);2.1784 + break;2.1785 + case 11: /* ADCS */2.1786 + operand = arm_get_shift_operand(ir);2.1787 + operand2 = RN(ir);2.1788 + tmp = operand + operand2;2.1789 + tmp2 = tmp + armr.c ? 1 : 0;2.1790 + LRD(ir) = tmp2;2.1791 + if( RDn(ir) == 15 ) {2.1792 + arm_restore_cpsr();2.1793 + } else {2.1794 + armr.n = tmp >> 31;2.1795 + armr.z = (tmp == 0 );2.1796 + armr.c = IS_CARRY(tmp,operand,operand2) ||2.1797 + (tmp2 < tmp);2.1798 + armr.v = IS_ADDOVERFLOW(tmp,operand, operand2) ||2.1799 + ((tmp&0x80000000) != (tmp2&0x80000000));2.1800 + }2.1801 + break;2.1802 + case 12: /* SBC */2.1803 + LRD(ir) = RN(ir) - arm_get_shift_operand(ir) -2.1804 + (armr.c ? 0 : 1);2.1805 + break;2.1806 + case 13: /* SBCS */2.1807 + operand = RN(ir);2.1808 + operand2 = arm_get_shift_operand(ir);2.1809 + tmp = operand - operand2;2.1810 + tmp2 = tmp - (armr.c ? 0 : 1);2.1811 + if( RDn(ir) == 15 ) {2.1812 + arm_restore_cpsr();2.1813 + } else {2.1814 + armr.n = tmp >> 31;2.1815 + armr.z = (tmp == 0 );2.1816 + armr.c = IS_NOTBORROW(tmp,operand,operand2) &&2.1817 + (tmp2<tmp);2.1818 + armr.v = IS_SUBOVERFLOW(tmp,operand,operand2) ||2.1819 + ((tmp&0x80000000) != (tmp2&0x80000000));2.1820 + }2.1821 + break;2.1822 + case 14: /* RSC */2.1823 + LRD(ir) = arm_get_shift_operand(ir) - RN(ir) -2.1824 + (armr.c ? 0 : 1);2.1825 + break;2.1826 + case 15: /* RSCS */2.1827 + operand = arm_get_shift_operand(ir);2.1828 + operand2 = RN(ir);2.1829 + tmp = operand - operand2;2.1830 + tmp2 = tmp - (armr.c ? 0 : 1);2.1831 + if( RDn(ir) == 15 ) {2.1832 + arm_restore_cpsr();2.1833 + } else {2.1834 + armr.n = tmp >> 31;2.1835 + armr.z = (tmp == 0 );2.1836 + armr.c = IS_NOTBORROW(tmp,operand,operand2) &&2.1837 + (tmp2<tmp);2.1838 + armr.v = IS_SUBOVERFLOW(tmp,operand,operand2) ||2.1839 + ((tmp&0x80000000) != (tmp2&0x80000000));2.1840 + }2.1841 + break;2.1842 + case 17: /* TST Rn, operand */2.1843 + operand = arm_get_shift_operand_s(ir) & RN(ir);2.1844 + armr.n = operand>>31;2.1845 + armr.z = (operand == 0);2.1846 + armr.c = armr.shift_c;2.1847 + break;2.1848 + case 19: /* TEQ Rn, operand */2.1849 + operand = arm_get_shift_operand_s(ir) ^ RN(ir);2.1850 + armr.n = operand>>31;2.1851 + armr.z = (operand == 0);2.1852 + armr.c = armr.shift_c;2.1853 + break;2.1854 + case 21: /* CMP Rn, operand */2.1855 + operand = RN(ir);2.1856 + operand2 = arm_get_shift_operand(ir);2.1857 + tmp = operand - operand2;2.1858 + armr.n = tmp>>31;2.1859 + armr.z = (tmp == 0);2.1860 + armr.c = IS_NOTBORROW(tmp,operand,operand2);2.1861 + armr.v = IS_SUBOVERFLOW(tmp,operand,operand2);2.1862 + break;2.1863 + case 23: /* CMN Rn, operand */2.1864 + operand = RN(ir);2.1865 + operand2 = arm_get_shift_operand(ir);2.1866 + tmp = operand + operand2;2.1867 + armr.n = tmp>>31;2.1868 + armr.z = (tmp == 0);2.1869 + armr.c = IS_CARRY(tmp,operand,operand2);2.1870 + armr.v = IS_ADDOVERFLOW(tmp,operand,operand2);2.1871 + break;2.1872 + case 24: /* ORR Rd, Rn, operand */2.1873 + LRD(ir) = RN(ir) | arm_get_shift_operand(ir);2.1874 + break;2.1875 + case 25: /* ORRS Rd, Rn, operand */2.1876 + operand = arm_get_shift_operand_s(ir) | RN(ir);2.1877 + LRD(ir) = operand;2.1878 + if( RDn(ir) == 15 ) {2.1879 + arm_restore_cpsr();2.1880 + } else {2.1881 + armr.n = operand>>31;2.1882 + armr.z = (operand == 0);2.1883 + armr.c = armr.shift_c;2.1884 + }2.1885 + break;2.1886 + case 26: /* MOV Rd, operand */2.1887 + LRD(ir) = arm_get_shift_operand(ir);2.1888 + break;2.1889 + case 27: /* MOVS Rd, operand */2.1890 + operand = arm_get_shift_operand_s(ir);2.1891 + LRD(ir) = operand;2.1892 + if( RDn(ir) == 15 ) {2.1893 + arm_restore_cpsr();2.1894 + } else {2.1895 + armr.n = operand>>31;2.1896 + armr.z = (operand == 0);2.1897 + armr.c = armr.shift_c;2.1898 + }2.1899 + break;2.1900 + case 28: /* BIC Rd, Rn, operand */2.1901 + LRD(ir) = RN(ir) & (~arm_get_shift_operand(ir));2.1902 + break;2.1903 + case 29: /* BICS Rd, Rn, operand */2.1904 + operand = RN(ir) & (~arm_get_shift_operand_s(ir));2.1905 + LRD(ir) = operand;2.1906 + if( RDn(ir) == 15 ) {2.1907 + arm_restore_cpsr();2.1908 + } else {2.1909 + armr.n = operand>>31;2.1910 + armr.z = (operand == 0);2.1911 + armr.c = armr.shift_c;2.1912 + }2.1913 + break;2.1914 + case 30: /* MVN Rd, operand */2.1915 + LRD(ir) = ~arm_get_shift_operand(ir);2.1916 + break;2.1917 + case 31: /* MVNS Rd, operand */2.1918 + operand = ~arm_get_shift_operand_s(ir);2.1919 + LRD(ir) = operand;2.1920 + if( RDn(ir) == 15 ) {2.1921 + arm_restore_cpsr();2.1922 + } else {2.1923 + armr.n = operand>>31;2.1924 + armr.z = (operand == 0);2.1925 + armr.c = armr.shift_c;2.1926 + }2.1927 + break;2.1928 + default:2.1929 + UNIMP(ir);2.1930 + }2.1931 + }2.1932 + break;2.1933 + case 1: /* Load/store */2.1934 + operand = arm_get_address_operand(ir);2.1935 + switch( (ir>>20)&0x17 ) {2.1936 + case 0: case 16: case 18: /* STR Rd, address */2.1937 + arm_write_long( operand, RD(ir) );2.1938 + break;2.1939 + case 1: case 17: case 19: /* LDR Rd, address */2.1940 + LRD(ir) = arm_read_long(operand);2.1941 + break;2.1942 + case 2: /* STRT Rd, address */2.1943 + arm_write_long_user( operand, RD(ir) );2.1944 + break;2.1945 + case 3: /* LDRT Rd, address */2.1946 + LRD(ir) = arm_read_long_user( operand );2.1947 + break;2.1948 + case 4: case 20: case 22: /* STRB Rd, address */2.1949 + arm_write_byte( operand, RD(ir) );2.1950 + break;2.1951 + case 5: case 21: case 23: /* LDRB Rd, address */2.1952 + LRD(ir) = arm_read_byte( operand );2.1953 + break;2.1954 + case 6: /* STRBT Rd, address */2.1955 + arm_write_byte_user( operand, RD(ir) );2.1956 + break;2.1957 + case 7: /* LDRBT Rd, address */2.1958 + LRD(ir) = arm_read_byte_user( operand );2.1959 + break;2.1960 + }2.1961 + break;2.1962 + case 2: /* Load/store multiple, branch*/2.1963 + if( (ir & 0x02000000) == 0x02000000 ) { /* B[L] imm24 */2.1964 + operand = (SIGNEXT24(ir&0x00FFFFFF) << 2);2.1965 + if( (ir & 0x01000000) == 0x01000000 ) {2.1966 + armr.r[14] = pc; /* BL */2.1967 + }2.1968 + armr.r[15] = pc + 4 + operand;2.1969 + } else { /* Load/store multiple */2.1970 + gboolean needRestore = FALSE;2.1971 + operand = RN(ir);2.1972 +2.1973 + switch( (ir & 0x01D00000) >> 20 ) {2.1974 + case 0: /* STMDA */2.1975 + if( ir & 0x8000 ) {2.1976 + arm_write_long( operand, armr.r[15]+4 );2.1977 + operand -= 4;2.1978 + }2.1979 + for( i=14; i>= 0; i-- ) {2.1980 + if( (ir & (1<<i)) ) {2.1981 + arm_write_long( operand, armr.r[i] );2.1982 + operand -= 4;2.1983 + }2.1984 + }2.1985 + break;2.1986 + case 1: /* LDMDA */2.1987 + for( i=15; i>= 0; i-- ) {2.1988 + if( (ir & (1<<i)) ) {2.1989 + armr.r[i] = arm_read_long( operand );2.1990 + operand -= 4;2.1991 + }2.1992 + }2.1993 + break;2.1994 + case 4: /* STMDA (S) */2.1995 + if( ir & 0x8000 ) {2.1996 + arm_write_long( operand, armr.r[15]+4 );2.1997 + operand -= 4;2.1998 + }2.1999 + for( i=14; i>= 0; i-- ) {2.2000 + if( (ir & (1<<i)) ) {2.2001 + arm_write_long( operand, USER_R(i) );2.2002 + operand -= 4;2.2003 + }2.2004 + }2.2005 + break;2.2006 + case 5: /* LDMDA (S) */2.2007 + if( (ir&0x00008000) ) { /* Load PC */2.2008 + for( i=15; i>= 0; i-- ) {2.2009 + if( (ir & (1<<i)) ) {2.2010 + armr.r[i] = arm_read_long( operand );2.2011 + operand -= 4;2.2012 + }2.2013 + }2.2014 + needRestore = TRUE;2.2015 + } else {2.2016 + for( i=15; i>= 0; i-- ) {2.2017 + if( (ir & (1<<i)) ) {2.2018 + USER_R(i) = arm_read_long( operand );2.2019 + operand -= 4;2.2020 + }2.2021 + }2.2022 + }2.2023 + break;2.2024 + case 8: /* STMIA */2.2025 + for( i=0; i< 15; i++ ) {2.2026 + if( (ir & (1<<i)) ) {2.2027 + arm_write_long( operand, armr.r[i] );2.2028 + operand += 4;2.2029 + }2.2030 + }2.2031 + if( ir & 0x8000 ) {2.2032 + arm_write_long( operand, armr.r[15]+4 );2.2033 + operand += 4;2.2034 + }2.2035 + break;2.2036 + case 9: /* LDMIA */2.2037 + for( i=0; i< 16; i++ ) {2.2038 + if( (ir & (1<<i)) ) {2.2039 + armr.r[i] = arm_read_long( operand );2.2040 + operand += 4;2.2041 + }2.2042 + }2.2043 + break;2.2044 + case 12: /* STMIA (S) */2.2045 + for( i=0; i< 15; i++ ) {2.2046 + if( (ir & (1<<i)) ) {2.2047 + arm_write_long( operand, USER_R(i) );2.2048 + operand += 4;2.2049 + }2.2050 + }2.2051 + if( ir & 0x8000 ) {2.2052 + arm_write_long( operand, armr.r[15]+4 );2.2053 + operand += 4;2.2054 + }2.2055 + break;2.2056 + case 13: /* LDMIA (S) */2.2057 + if( (ir&0x00008000) ) { /* Load PC */2.2058 + for( i=0; i < 16; i++ ) {2.2059 + if( (ir & (1<<i)) ) {2.2060 + armr.r[i] = arm_read_long( operand );2.2061 + operand += 4;2.2062 + }2.2063 + }2.2064 + needRestore = TRUE;2.2065 + } else {2.2066 + for( i=0; i < 16; i++ ) {2.2067 + if( (ir & (1<<i)) ) {2.2068 + USER_R(i) = arm_read_long( operand );2.2069 + operand += 4;2.2070 + }2.2071 + }2.2072 + }2.2073 + break;2.2074 + case 16: /* STMDB */2.2075 + if( ir & 0x8000 ) {2.2076 + operand -= 4;2.2077 + arm_write_long( operand, armr.r[15]+4 );2.2078 + }2.2079 + for( i=14; i>= 0; i-- ) {2.2080 + if( (ir & (1<<i)) ) {2.2081 + operand -= 4;2.2082 + arm_write_long( operand, armr.r[i] );2.2083 + }2.2084 + }2.2085 + break;2.2086 + case 17: /* LDMDB */2.2087 + for( i=15; i>= 0; i-- ) {2.2088 + if( (ir & (1<<i)) ) {2.2089 + operand -= 4;2.2090 + armr.r[i] = arm_read_long( operand );2.2091 + }2.2092 + }2.2093 + break;2.2094 + case 20: /* STMDB (S) */2.2095 + if( ir & 0x8000 ) {2.2096 + operand -= 4;2.2097 + arm_write_long( operand, armr.r[15]+4 );2.2098 + }2.2099 + for( i=14; i>= 0; i-- ) {2.2100 + if( (ir & (1<<i)) ) {2.2101 + operand -= 4;2.2102 + arm_write_long( operand, USER_R(i) );2.2103 + }2.2104 + }2.2105 + break;2.2106 + case 21: /* LDMDB (S) */2.2107 + if( (ir&0x00008000) ) { /* Load PC */2.2108 + for( i=15; i>= 0; i-- ) {2.2109 + if( (ir & (1<<i)) ) {2.2110 + operand -= 4;2.2111 + armr.r[i] = arm_read_long( operand );2.2112 + }2.2113 + }2.2114 + needRestore = TRUE;2.2115 + } else {2.2116 + for( i=15; i>= 0; i-- ) {2.2117 + if( (ir & (1<<i)) ) {2.2118 + operand -= 4;2.2119 + USER_R(i) = arm_read_long( operand );2.2120 + }2.2121 + }2.2122 + }2.2123 + break;2.2124 + case 24: /* STMIB */2.2125 + for( i=0; i< 15; i++ ) {2.2126 + if( (ir & (1<<i)) ) {2.2127 + operand += 4;2.2128 + arm_write_long( operand, armr.r[i] );2.2129 + }2.2130 + }2.2131 + if( ir & 0x8000 ) {2.2132 + operand += 4;2.2133 + arm_write_long( operand, armr.r[15]+4 );2.2134 + }2.2135 + break;2.2136 + case 25: /* LDMIB */2.2137 + for( i=0; i< 16; i++ ) {2.2138 + if( (ir & (1<<i)) ) {2.2139 + operand += 4;2.2140 + armr.r[i] = arm_read_long( operand );2.2141 + }2.2142 + }2.2143 + break;2.2144 + case 28: /* STMIB (S) */2.2145 + for( i=0; i< 15; i++ ) {2.2146 + if( (ir & (1<<i)) ) {2.2147 + operand += 4;2.2148 + arm_write_long( operand, USER_R(i) );2.2149 + }2.2150 + }2.2151 + if( ir & 0x8000 ) {2.2152 + operand += 4;2.2153 + arm_write_long( operand, armr.r[15]+4 );2.2154 + }2.2155 + break;2.2156 + case 29: /* LDMIB (S) */2.2157 + if( (ir&0x00008000) ) { /* Load PC */2.2158 + for( i=0; i < 16; i++ ) {2.2159 + if( (ir & (1<<i)) ) {2.2160 + operand += 4;2.2161 + armr.r[i] = arm_read_long( operand );2.2162 + }2.2163 + }2.2164 + needRestore = TRUE;2.2165 + } else {2.2166 + for( i=0; i < 16; i++ ) {2.2167 + if( (ir & (1<<i)) ) {2.2168 + operand += 4;2.2169 + USER_R(i) = arm_read_long( operand );2.2170 + }2.2171 + }2.2172 + }2.2173 + break;2.2174 + }2.2175 +2.2176 + if( WFLAG(ir) )2.2177 + LRN(ir) = operand;2.2178 + if( needRestore )2.2179 + arm_restore_cpsr();2.2180 + }2.2181 + break;2.2182 + case 3: /* Copro */2.2183 + if( (ir & 0x0F000000) == 0x0F000000 ) { /* SWI */2.2184 + arm_raise_exception( EXC_SOFTWARE );2.2185 + } else {2.2186 + UNIMP(ir);2.2187 + }2.2188 + break;2.2189 + }2.2191 }2.2193 if( armr.r[15] >= 0x00200000 ) {2.2194 - armr.running = FALSE;2.2195 - WARN( "ARM Halted: BRANCH to invalid address %08X at %08X", armr.r[15], pc );2.2196 - return FALSE;2.2197 + armr.running = FALSE;2.2198 + WARN( "ARM Halted: BRANCH to invalid address %08X at %08X", armr.r[15], pc );2.2199 + return FALSE;2.2200 }2.2201 return TRUE;2.2202 }
3.1 --- a/src/aica/armcore.h Mon Jul 14 07:42:45 2008 +00003.2 +++ b/src/aica/armcore.h Mon Jul 14 07:44:42 2008 +00003.3 @@ -16,14 +16,18 @@3.4 * GNU General Public License for more details.3.5 */3.7 -#ifndef dream_armcore_H3.8 -#define dream_armcore_H 13.9 +#ifndef lxdream_armcore_H3.10 +#define lxdream_armcore_H 13.12 #include "lxdream.h"3.13 #include "mem.h"3.14 #include <stdint.h>3.15 #include <stdio.h>3.17 +#ifdef __cplusplus3.18 +extern "C" {3.19 +#endif3.20 +3.21 #define ARM_BASE_RATE 2 /* MHZ */3.22 extern uint32_t arm_cpu_freq;3.23 extern uint32_t arm_cpu_period;3.24 @@ -107,4 +111,9 @@3.25 int32_t arm_read_phys_word( uint32_t addr );3.26 int arm_has_page( uint32_t addr );3.27 void arm_mem_init(void);3.28 -#endif /* !dream_armcore_H */3.29 +3.30 +#ifdef __cplusplus3.31 +}3.32 +#endif3.33 +3.34 +#endif /* !lxdream_armcore_H */
4.1 --- a/src/aica/armdasm.c Mon Jul 14 07:42:45 2008 +00004.2 +++ b/src/aica/armdasm.c Mon Jul 14 07:44:42 2008 +00004.3 @@ -48,142 +48,142 @@4.6 const struct reg_desc_struct arm_reg_map[] =4.7 - { {"R0", REG_INT, &armr.r[0]}, {"R1", REG_INT, &armr.r[1]},4.8 - {"R2", REG_INT, &armr.r[2]}, {"R3", REG_INT, &armr.r[3]},4.9 - {"R4", REG_INT, &armr.r[4]}, {"R5", REG_INT, &armr.r[5]},4.10 - {"R6", REG_INT, &armr.r[6]}, {"R7", REG_INT, &armr.r[7]},4.11 - {"R8", REG_INT, &armr.r[8]}, {"R9", REG_INT, &armr.r[9]},4.12 - {"R10",REG_INT, &armr.r[10]}, {"R11",REG_INT, &armr.r[11]},4.13 - {"R12",REG_INT, &armr.r[12]}, {"R13",REG_INT, &armr.r[13]},4.14 - {"R14",REG_INT, &armr.r[14]}, {"R15",REG_INT, &armr.r[15]},4.15 - {"CPSR", REG_INT, &armr.cpsr}, {"SPSR", REG_INT, &armr.spsr},4.16 - {NULL, 0, NULL} };4.17 +{ {"R0", REG_INT, &armr.r[0]}, {"R1", REG_INT, &armr.r[1]},4.18 + {"R2", REG_INT, &armr.r[2]}, {"R3", REG_INT, &armr.r[3]},4.19 + {"R4", REG_INT, &armr.r[4]}, {"R5", REG_INT, &armr.r[5]},4.20 + {"R6", REG_INT, &armr.r[6]}, {"R7", REG_INT, &armr.r[7]},4.21 + {"R8", REG_INT, &armr.r[8]}, {"R9", REG_INT, &armr.r[9]},4.22 + {"R10",REG_INT, &armr.r[10]}, {"R11",REG_INT, &armr.r[11]},4.23 + {"R12",REG_INT, &armr.r[12]}, {"R13",REG_INT, &armr.r[13]},4.24 + {"R14",REG_INT, &armr.r[14]}, {"R15",REG_INT, &armr.r[15]},4.25 + {"CPSR", REG_INT, &armr.cpsr}, {"SPSR", REG_INT, &armr.spsr},4.26 + {NULL, 0, NULL} };4.29 const struct cpu_desc_struct arm_cpu_desc =4.30 - { "ARM7", arm_disasm_instruction, arm_execute_instruction, arm_has_page,4.31 - arm_set_breakpoint, arm_clear_breakpoint, arm_get_breakpoint, 4,4.32 - (char *)&armr, sizeof(armr), arm_reg_map,4.33 - &armr.r[15] };4.34 +{ "ARM7", arm_disasm_instruction, arm_execute_instruction, arm_has_page,4.35 + arm_set_breakpoint, arm_clear_breakpoint, arm_get_breakpoint, 4,4.36 + (char *)&armr, sizeof(armr), arm_reg_map,4.37 + &armr.r[15] };4.38 const struct cpu_desc_struct armt_cpu_desc =4.39 - { "ARM7T", armt_disasm_instruction, arm_execute_instruction, arm_has_page,4.40 - arm_set_breakpoint, arm_clear_breakpoint, arm_get_breakpoint, 2,4.41 - (char*)&armr, sizeof(armr), arm_reg_map,4.42 - &armr.r[15] };4.43 +{ "ARM7T", armt_disasm_instruction, arm_execute_instruction, arm_has_page,4.44 + arm_set_breakpoint, arm_clear_breakpoint, arm_get_breakpoint, 2,4.45 + (char*)&armr, sizeof(armr), arm_reg_map,4.46 + &armr.r[15] };4.51 char *conditionNames[] = { "EQ", "NE", "CS", "CC", "MI", "PL", "VS", "VC",4.52 - "HI", "LS", "GE", "LT", "GT", "LE", " " /*AL*/, "NV" };4.53 -4.54 - /* fsxc */4.55 + "HI", "LS", "GE", "LT", "GT", "LE", " " /*AL*/, "NV" };4.56 +4.57 +/* fsxc */4.58 char *msrFieldMask[] = { "", "c", "x", "xc", "s", "sc", "sx", "sxc",4.59 - "f", "fc", "fx", "fxc", "fs", "fsc", "fsx", "fsxc" };4.60 + "f", "fc", "fx", "fxc", "fs", "fsc", "fsx", "fsxc" };4.61 char *ldmModes[] = { "DA", "IA", "DB", "IB" };4.63 #define UNIMP(ir) snprintf( buf, len, "??? " )4.65 int arm_disasm_shift_operand( uint32_t ir, char *buf, int len )4.66 {4.67 - uint32_t operand, tmp;4.68 - if( IFLAG(ir) == 0 ) {4.69 - switch(SHIFT(ir)) {4.70 - case 0: /* (Rm << imm) */4.71 - tmp = SHIFTIMM(ir);4.72 - if( tmp != 0 ) {4.73 - return snprintf(buf, len, "R%d << %d", RM(ir), tmp );4.74 - } else {4.75 - return snprintf(buf, len, "R%d", RM(ir));4.76 - }4.77 - case 1: /* (Rm << Rs) */4.78 - return snprintf(buf, len, "R%d << R%d", RM(ir), RS(ir) );4.79 - case 2: /* (Rm >> imm) */4.80 - return snprintf(buf, len, "R%d >> %d", RM(ir), SHIFTIMM(ir) );4.81 - case 3: /* (Rm >> Rs) */4.82 - return snprintf(buf, len, "R%d >> R%d", RM(ir), RS(ir) );4.83 - case 4: /* (Rm >>> imm) */4.84 - return snprintf(buf, len, "R%d >>> %d", RM(ir), SHIFTIMM(ir) );4.85 - case 5: /* (Rm >>> Rs) */4.86 - return snprintf(buf, len, "R%d >>> R%d", RM(ir), RS(ir) );4.87 - case 6:4.88 - tmp = SHIFTIMM(ir);4.89 - if( tmp == 0 ) /* RRX aka rotate with carry */4.90 - return snprintf(buf, len, "R%d roc 1", RM(ir) );4.91 - else4.92 - return snprintf(buf, len, "R%d rot %d", RM(ir), SHIFTIMM(ir) );4.93 - case 7:4.94 - return snprintf(buf, len, "R%d rot R%d", RM(ir), RS(ir) );4.95 - }4.96 - } else {4.97 - operand = IMM8(ir);4.98 - tmp = IMMROT(ir);4.99 - operand = ROTATE_RIGHT_LONG(operand, tmp);4.100 - return snprintf(buf, len, "#%08Xh", operand );4.101 - }4.102 - return 0;4.103 + uint32_t operand, tmp;4.104 + if( IFLAG(ir) == 0 ) {4.105 + switch(SHIFT(ir)) {4.106 + case 0: /* (Rm << imm) */4.107 + tmp = SHIFTIMM(ir);4.108 + if( tmp != 0 ) {4.109 + return snprintf(buf, len, "R%d << %d", RM(ir), tmp );4.110 + } else {4.111 + return snprintf(buf, len, "R%d", RM(ir));4.112 + }4.113 + case 1: /* (Rm << Rs) */4.114 + return snprintf(buf, len, "R%d << R%d", RM(ir), RS(ir) );4.115 + case 2: /* (Rm >> imm) */4.116 + return snprintf(buf, len, "R%d >> %d", RM(ir), SHIFTIMM(ir) );4.117 + case 3: /* (Rm >> Rs) */4.118 + return snprintf(buf, len, "R%d >> R%d", RM(ir), RS(ir) );4.119 + case 4: /* (Rm >>> imm) */4.120 + return snprintf(buf, len, "R%d >>> %d", RM(ir), SHIFTIMM(ir) );4.121 + case 5: /* (Rm >>> Rs) */4.122 + return snprintf(buf, len, "R%d >>> R%d", RM(ir), RS(ir) );4.123 + case 6:4.124 + tmp = SHIFTIMM(ir);4.125 + if( tmp == 0 ) /* RRX aka rotate with carry */4.126 + return snprintf(buf, len, "R%d roc 1", RM(ir) );4.127 + else4.128 + return snprintf(buf, len, "R%d rot %d", RM(ir), SHIFTIMM(ir) );4.129 + case 7:4.130 + return snprintf(buf, len, "R%d rot R%d", RM(ir), RS(ir) );4.131 + }4.132 + } else {4.133 + operand = IMM8(ir);4.134 + tmp = IMMROT(ir);4.135 + operand = ROTATE_RIGHT_LONG(operand, tmp);4.136 + return snprintf(buf, len, "#%08Xh", operand );4.137 + }4.138 + return 0;4.139 }4.141 static int arm_disasm_address_index( uint32_t ir, char *buf, int len )4.142 {4.143 - uint32_t tmp;4.144 -4.145 - switch(SHIFT(ir)) {4.146 - case 0: /* (Rm << imm) */4.147 - tmp = SHIFTIMM(ir);4.148 - if( tmp != 0 ) {4.149 - return snprintf( buf, len, "R%d << %d", RM(ir), tmp );4.150 - } else {4.151 - return snprintf( buf, len, "R%d", RM(ir) );4.152 - }4.153 - case 2: /* (Rm >> imm) */4.154 - return snprintf( buf, len, "R%d >> %d", RM(ir), SHIFTIMM(ir) );4.155 - case 4: /* (Rm >>> imm) */4.156 - return snprintf( buf, len, "R%d >>> %d", RM(ir), SHIFTIMM(ir) );4.157 - case 6:4.158 - tmp = SHIFTIMM(ir);4.159 - if( tmp == 0 ) /* RRX aka rotate with carry */4.160 - return snprintf( buf, len, "R%d roc 1", RM(ir) );4.161 - else4.162 - return snprintf( buf, len, "R%d rot %d", RM(ir), tmp );4.163 - default:4.164 - return UNIMP(ir);4.165 - }4.166 + uint32_t tmp;4.167 +4.168 + switch(SHIFT(ir)) {4.169 + case 0: /* (Rm << imm) */4.170 + tmp = SHIFTIMM(ir);4.171 + if( tmp != 0 ) {4.172 + return snprintf( buf, len, "R%d << %d", RM(ir), tmp );4.173 + } else {4.174 + return snprintf( buf, len, "R%d", RM(ir) );4.175 + }4.176 + case 2: /* (Rm >> imm) */4.177 + return snprintf( buf, len, "R%d >> %d", RM(ir), SHIFTIMM(ir) );4.178 + case 4: /* (Rm >>> imm) */4.179 + return snprintf( buf, len, "R%d >>> %d", RM(ir), SHIFTIMM(ir) );4.180 + case 6:4.181 + tmp = SHIFTIMM(ir);4.182 + if( tmp == 0 ) /* RRX aka rotate with carry */4.183 + return snprintf( buf, len, "R%d roc 1", RM(ir) );4.184 + else4.185 + return snprintf( buf, len, "R%d rot %d", RM(ir), tmp );4.186 + default:4.187 + return UNIMP(ir);4.188 + }4.189 }4.191 static int arm_disasm_address_operand( uint32_t ir, char *buf, int len, int pc )4.192 {4.193 char shift[32];4.195 - char sign = UFLAG(ir) ? '+' : '-';4.196 - /* I P U . W */4.197 - switch( (ir>>21)&0x19 ) {4.198 - case 0: /* Rn -= imm offset (post-indexed) [5.2.8 A5-28] */4.199 - case 1:4.200 - return snprintf( buf, len, "[R%d], R%d %c= #%04Xh", RN(ir), RN(ir), sign, IMM12(ir) );4.201 - case 8: /* Rn - imm offset [5.2.2 A5-20] */4.202 - if( RN(ir) == 15 ) { /* PC relative - decode here */4.203 - uint32_t addr = pc + 8 + (UFLAG(ir) ? IMM12(ir) : -IMM12(ir));4.204 - return snprintf( buf, len, "[$%08Xh] <- #%08Xh", addr,4.205 - arm_read_long( addr ) );4.206 - } else {4.207 - return snprintf( buf, len, "[R%d %c #%04Xh]", RN(ir), sign, IMM12(ir) );4.208 - }4.209 - case 9: /* Rn -= imm offset (pre-indexed) [5.2.5 A5-24] */4.210 - return snprintf( buf, len, "[R%d %c= #%04Xh]", RN(ir), sign, IMM12(ir) );4.211 - case 16: /* Rn -= Rm (post-indexed) [5.2.10 A5-32 ] */4.212 - case 17:4.213 - arm_disasm_address_index( ir, shift, sizeof(shift) );4.214 - return snprintf( buf, len, "[R%d], R%d %c= %s", RN(ir), RN(ir), sign, shift );4.215 - case 24: /* Rn - Rm [5.2.4 A5-23] */4.216 - arm_disasm_address_index( ir, shift, sizeof(shift) );4.217 - return snprintf( buf, len, "[R%d %c %s]", RN(ir), sign, shift );4.218 - case 25: /* RN -= Rm (pre-indexed) [5.2.7 A5-26] */4.219 - arm_disasm_address_index( ir, shift, sizeof(shift) );4.220 - return snprintf( buf, len, "[R%d %c= %s]", RN(ir), sign, shift );4.221 - default:4.222 - return UNIMP(ir); /* Unreachable */4.223 - }4.224 + char sign = UFLAG(ir) ? '+' : '-';4.225 + /* I P U . W */4.226 + switch( (ir>>21)&0x19 ) {4.227 + case 0: /* Rn -= imm offset (post-indexed) [5.2.8 A5-28] */4.228 + case 1:4.229 + return snprintf( buf, len, "[R%d], R%d %c= #%04Xh", RN(ir), RN(ir), sign, IMM12(ir) );4.230 + case 8: /* Rn - imm offset [5.2.2 A5-20] */4.231 + if( RN(ir) == 15 ) { /* PC relative - decode here */4.232 + uint32_t addr = pc + 8 + (UFLAG(ir) ? IMM12(ir) : -IMM12(ir));4.233 + return snprintf( buf, len, "[$%08Xh] <- #%08Xh", addr,4.234 + arm_read_long( addr ) );4.235 + } else {4.236 + return snprintf( buf, len, "[R%d %c #%04Xh]", RN(ir), sign, IMM12(ir) );4.237 + }4.238 + case 9: /* Rn -= imm offset (pre-indexed) [5.2.5 A5-24] */4.239 + return snprintf( buf, len, "[R%d %c= #%04Xh]", RN(ir), sign, IMM12(ir) );4.240 + case 16: /* Rn -= Rm (post-indexed) [5.2.10 A5-32 ] */4.241 + case 17:4.242 + arm_disasm_address_index( ir, shift, sizeof(shift) );4.243 + return snprintf( buf, len, "[R%d], R%d %c= %s", RN(ir), RN(ir), sign, shift );4.244 + case 24: /* Rn - Rm [5.2.4 A5-23] */4.245 + arm_disasm_address_index( ir, shift, sizeof(shift) );4.246 + return snprintf( buf, len, "[R%d %c %s]", RN(ir), sign, shift );4.247 + case 25: /* RN -= Rm (pre-indexed) [5.2.7 A5-26] */4.248 + arm_disasm_address_index( ir, shift, sizeof(shift) );4.249 + return snprintf( buf, len, "[R%d %c= %s]", RN(ir), sign, shift );4.250 + default:4.251 + return UNIMP(ir); /* Unreachable */4.252 + }4.253 }4.255 uint32_t arm_disasm_instruction( uint32_t pc, char *buf, int len, char *opcode )4.256 @@ -191,320 +191,320 @@4.257 char operand[64];4.258 uint32_t ir = arm_read_long(pc);4.259 int i,j;4.260 -4.261 +4.262 sprintf( opcode, "%02X %02X %02X %02X", ir&0xFF, (ir>>8) & 0xFF,4.263 - (ir>>16)&0xFF, (ir>>24) );4.264 + (ir>>16)&0xFF, (ir>>24) );4.266 if( COND(ir) == 0x0F ) {4.267 - UNIMP(ir);4.268 - return pc+4;4.269 + UNIMP(ir);4.270 + return pc+4;4.271 }4.272 char *cond = conditionNames[COND(ir)];4.274 - switch( GRP(ir) ) {4.275 - case 0:4.276 - if( (ir & 0x0D900000) == 0x01000000 ) {4.277 - /* Instructions that aren't actual data processing */4.278 - switch( ir & 0x0FF000F0 ) {4.279 - case 0x01200010: /* BXcc */4.280 - snprintf(buf, len, "BX%s R%d", cond, RM(ir));4.281 - break;4.282 - case 0x01000000: /* MRS Rd, CPSR */4.283 - snprintf(buf, len, "MRS%s R%d, CPSR", cond, RD(ir));4.284 - break;4.285 - case 0x01400000: /* MRS Rd, SPSR */4.286 - snprintf(buf, len, "MRS%s R%d, SPSR", cond, RD(ir));4.287 - break;4.288 - case 0x01200000: /* MSR CPSR, Rm */4.289 - snprintf(buf, len, "MSR%s CPSR_%s, R%d", cond, FSXC(ir), RM(ir));4.290 - break;4.291 - case 0x01600000: /* MSR SPSR, Rm */4.292 - snprintf(buf, len, "MSR%s SPSR_%s, R%d", cond, FSXC(ir), RM(ir));4.293 - break;4.294 - case 0x03200000: /* MSR CPSR, imm */4.295 - snprintf(buf, len, "MSR%s CPSR_%s, #%08X", cond, FSXC(ir), ROTIMM12(ir));4.296 - break;4.297 - case 0x03600000: /* MSR SPSR, imm */4.298 - snprintf(buf, len, "MSR%s SPSR_%s, #%08X", cond, FSXC(ir), ROTIMM12(ir));4.299 - break;4.300 - default:4.301 - UNIMP();4.302 - }4.303 - } else if( (ir & 0x0E000090) == 0x00000090 ) {4.304 - /* Neither are these */4.305 - switch( (ir>>5)&0x03 ) {4.306 - case 0:4.307 - /* Arithmetic extension area */4.308 - switch(OPCODE(ir)) {4.309 - case 0: /* MUL */4.310 - snprintf(buf,len, "MUL%s R%d, R%d, R%d", cond, RN(ir), RM(ir), RS(ir) );4.311 - break;4.312 - case 1: /* MULS */4.313 - break;4.314 - case 2: /* MLA */4.315 - snprintf(buf,len, "MLA%s R%d, R%d, R%d, R%d", cond, RN(ir), RM(ir), RS(ir), RD(ir) );4.316 - break;4.317 - case 3: /* MLAS */4.318 - break;4.319 - case 8: /* UMULL */4.320 - snprintf(buf,len, "UMULL%s R%d, R%d, R%d, R%d", cond, RD(ir), RN(ir), RM(ir), RS(ir) );4.321 - break;4.322 - case 9: /* UMULLS */4.323 - break;4.324 - case 10: /* UMLAL */4.325 - snprintf(buf,len, "UMLAL%s R%d, R%d, R%d, R%d", cond, RD(ir), RN(ir), RM(ir), RS(ir) );4.326 - break;4.327 - case 11: /* UMLALS */4.328 - break;4.329 - case 12: /* SMULL */4.330 - snprintf(buf,len, "SMULL%s R%d, R%d, R%d, R%d", cond, RD(ir), RN(ir), RM(ir), RS(ir) );4.331 - break;4.332 - case 13: /* SMULLS */4.333 - break;4.334 - case 14: /* SMLAL */4.335 - snprintf(buf,len, "SMLAL%s R%d, R%d, R%d, R%d", cond, RD(ir), RN(ir), RM(ir), RS(ir) );4.336 - break;4.337 - case 15: /* SMLALS */4.338 + switch( GRP(ir) ) {4.339 + case 0:4.340 + if( (ir & 0x0D900000) == 0x01000000 ) {4.341 + /* Instructions that aren't actual data processing */4.342 + switch( ir & 0x0FF000F0 ) {4.343 + case 0x01200010: /* BXcc */4.344 + snprintf(buf, len, "BX%s R%d", cond, RM(ir));4.345 + break;4.346 + case 0x01000000: /* MRS Rd, CPSR */4.347 + snprintf(buf, len, "MRS%s R%d, CPSR", cond, RD(ir));4.348 + break;4.349 + case 0x01400000: /* MRS Rd, SPSR */4.350 + snprintf(buf, len, "MRS%s R%d, SPSR", cond, RD(ir));4.351 + break;4.352 + case 0x01200000: /* MSR CPSR, Rm */4.353 + snprintf(buf, len, "MSR%s CPSR_%s, R%d", cond, FSXC(ir), RM(ir));4.354 + break;4.355 + case 0x01600000: /* MSR SPSR, Rm */4.356 + snprintf(buf, len, "MSR%s SPSR_%s, R%d", cond, FSXC(ir), RM(ir));4.357 + break;4.358 + case 0x03200000: /* MSR CPSR, imm */4.359 + snprintf(buf, len, "MSR%s CPSR_%s, #%08X", cond, FSXC(ir), ROTIMM12(ir));4.360 + break;4.361 + case 0x03600000: /* MSR SPSR, imm */4.362 + snprintf(buf, len, "MSR%s SPSR_%s, #%08X", cond, FSXC(ir), ROTIMM12(ir));4.363 + break;4.364 + default:4.365 + UNIMP();4.366 + }4.367 + } else if( (ir & 0x0E000090) == 0x00000090 ) {4.368 + /* Neither are these */4.369 + switch( (ir>>5)&0x03 ) {4.370 + case 0:4.371 + /* Arithmetic extension area */4.372 + switch(OPCODE(ir)) {4.373 + case 0: /* MUL */4.374 + snprintf(buf,len, "MUL%s R%d, R%d, R%d", cond, RN(ir), RM(ir), RS(ir) );4.375 + break;4.376 + case 1: /* MULS */4.377 + break;4.378 + case 2: /* MLA */4.379 + snprintf(buf,len, "MLA%s R%d, R%d, R%d, R%d", cond, RN(ir), RM(ir), RS(ir), RD(ir) );4.380 + break;4.381 + case 3: /* MLAS */4.382 + break;4.383 + case 8: /* UMULL */4.384 + snprintf(buf,len, "UMULL%s R%d, R%d, R%d, R%d", cond, RD(ir), RN(ir), RM(ir), RS(ir) );4.385 + break;4.386 + case 9: /* UMULLS */4.387 + break;4.388 + case 10: /* UMLAL */4.389 + snprintf(buf,len, "UMLAL%s R%d, R%d, R%d, R%d", cond, RD(ir), RN(ir), RM(ir), RS(ir) );4.390 + break;4.391 + case 11: /* UMLALS */4.392 + break;4.393 + case 12: /* SMULL */4.394 + snprintf(buf,len, "SMULL%s R%d, R%d, R%d, R%d", cond, RD(ir), RN(ir), RM(ir), RS(ir) );4.395 + break;4.396 + case 13: /* SMULLS */4.397 + break;4.398 + case 14: /* SMLAL */4.399 + snprintf(buf,len, "SMLAL%s R%d, R%d, R%d, R%d", cond, RD(ir), RN(ir), RM(ir), RS(ir) );4.400 + break;4.401 + case 15: /* SMLALS */4.403 - break;4.404 - case 16: /* SWP */4.405 - snprintf(buf,len, "SWP%s R%d, R%d, [R%d]", cond, RD(ir), RN(ir), RM(ir) );4.406 - break;4.407 - case 20: /* SWPB */4.408 - snprintf(buf,len, "SWPB%s R%d, R%d, [R%d]", cond, RD(ir), RN(ir), RM(ir) );4.409 - break;4.410 - default:4.411 - UNIMP(ir);4.412 - }4.413 - break;4.414 - case 1:4.415 - if( LFLAG(ir) ) {4.416 - /* LDRH */4.417 - } else {4.418 - /* STRH */4.419 - }4.420 - UNIMP(ir);4.421 - break;4.422 - case 2:4.423 - if( LFLAG(ir) ) {4.424 - /* LDRSB */4.425 - } else {4.426 - }4.427 - UNIMP(ir);4.428 - break;4.429 - case 3:4.430 - if( LFLAG(ir) ) {4.431 - /* LDRSH */4.432 - } else {4.433 - }4.434 - UNIMP(ir);4.435 - break;4.436 - }4.437 - } else {4.438 - /* Data processing */4.439 + break;4.440 + case 16: /* SWP */4.441 + snprintf(buf,len, "SWP%s R%d, R%d, [R%d]", cond, RD(ir), RN(ir), RM(ir) );4.442 + break;4.443 + case 20: /* SWPB */4.444 + snprintf(buf,len, "SWPB%s R%d, R%d, [R%d]", cond, RD(ir), RN(ir), RM(ir) );4.445 + break;4.446 + default:4.447 + UNIMP(ir);4.448 + }4.449 + break;4.450 + case 1:4.451 + if( LFLAG(ir) ) {4.452 + /* LDRH */4.453 + } else {4.454 + /* STRH */4.455 + }4.456 + UNIMP(ir);4.457 + break;4.458 + case 2:4.459 + if( LFLAG(ir) ) {4.460 + /* LDRSB */4.461 + } else {4.462 + }4.463 + UNIMP(ir);4.464 + break;4.465 + case 3:4.466 + if( LFLAG(ir) ) {4.467 + /* LDRSH */4.468 + } else {4.469 + }4.470 + UNIMP(ir);4.471 + break;4.472 + }4.473 + } else {4.474 + /* Data processing */4.476 - switch(OPCODE(ir)) {4.477 - case 0: /* AND Rd, Rn, operand */4.478 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.479 - snprintf(buf, len, "AND%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.480 - break;4.481 - case 1: /* ANDS Rd, Rn, operand */4.482 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.483 - snprintf(buf, len, "ANDS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.484 - break;4.485 - case 2: /* EOR Rd, Rn, operand */4.486 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.487 - snprintf(buf, len, "EOR%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.488 - break;4.489 - case 3: /* EORS Rd, Rn, operand */4.490 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.491 - snprintf(buf, len, "EORS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.492 - break;4.493 - case 4: /* SUB Rd, Rn, operand */4.494 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.495 - snprintf(buf, len, "SUB%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.496 - break;4.497 - case 5: /* SUBS Rd, Rn, operand */4.498 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.499 - snprintf(buf, len, "SUBS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.500 - break;4.501 - case 6: /* RSB Rd, Rn, operand */4.502 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.503 - snprintf(buf, len, "RSB%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.504 - break;4.505 - case 7: /* RSBS Rd, Rn, operand */4.506 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.507 - snprintf(buf, len, "RSBS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.508 - break;4.509 - case 8: /* ADD Rd, Rn, operand */4.510 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.511 - snprintf(buf, len, "ADD%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.512 - break;4.513 - case 9: /* ADDS Rd, Rn, operand */4.514 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.515 - snprintf(buf, len, "ADDS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.516 - break;4.517 - case 10: /* ADC Rd, Rn, operand */4.518 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.519 - snprintf(buf, len, "ADC%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.520 - break;4.521 - case 11: /* ADCS Rd, Rn, operand */4.522 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.523 - snprintf(buf, len, "ADCS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.524 - break;4.525 - case 12: /* SBC Rd, Rn, operand */4.526 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.527 - snprintf(buf, len, "SBC%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.528 - break;4.529 - case 13: /* SBCS Rd, Rn, operand */4.530 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.531 - snprintf(buf, len, "SBCS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.532 - break;4.533 - case 14: /* RSC Rd, Rn, operand */4.534 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.535 - snprintf(buf, len, "RSC%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.536 - break;4.537 - case 15: /* RSCS Rd, Rn, operand */4.538 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.539 - snprintf(buf, len, "RSCS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.540 - break;4.541 - case 17: /* TST Rd, Rn, operand */4.542 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.543 - snprintf(buf, len, "TST%s R%d, %s", cond, RN(ir), operand);4.544 - break;4.545 - case 19: /* TEQ Rd, Rn, operand */4.546 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.547 - snprintf(buf, len, "TEQ%s R%d, %s", cond, RN(ir), operand);4.548 - break;4.549 - case 21: /* CMP Rd, Rn, operand */4.550 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.551 - snprintf(buf, len, "CMP%s R%d, %s", cond, RN(ir), operand);4.552 - break;4.553 - case 23: /* CMN Rd, Rn, operand */4.554 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.555 - snprintf(buf, len, "CMN%s R%d, %s", cond, RN(ir), operand);4.556 - break;4.557 - case 24: /* ORR Rd, Rn, operand */4.558 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.559 - snprintf(buf, len, "ORR%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.560 - break;4.561 - case 25: /* ORRS Rd, Rn, operand */4.562 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.563 - snprintf(buf, len, "ORRS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.564 - break;4.565 - case 26: /* MOV Rd, operand */4.566 - if( ir == 0xE1A00000 ) {4.567 - /* Not technically a different instruction,4.568 - * but this one is commonly used as a NOP,4.569 - * so...4.570 - */4.571 - snprintf(buf, len, "NOP");4.572 - } else {4.573 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.574 - snprintf(buf, len, "MOV%s R%d, %s", cond, RD(ir), operand);4.575 - }4.576 - break;4.577 - case 27: /* MOVS Rd, operand */4.578 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.579 - snprintf(buf, len, "MOVS%s R%d, %s", cond, RD(ir), operand);4.580 - break;4.581 - case 28: /* BIC Rd, Rn, operand */4.582 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.583 - snprintf(buf, len, "BIC%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.584 - break;4.585 - case 29: /* BICS Rd, Rn, operand */4.586 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.587 - snprintf(buf, len, "BICS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.588 - break;4.589 - case 30: /* MVN Rd, Rn, operand */4.590 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.591 - snprintf(buf, len, "MVN%s R%d, %s", cond, RD(ir), operand);4.592 - break;4.593 - case 31: /* MVNS Rd, Rn, operand */4.594 - arm_disasm_shift_operand(ir, operand, sizeof(operand));4.595 - snprintf(buf, len, "MVNS%s R%d, %s", cond, RD(ir), operand);4.596 - break;4.597 - default:4.598 - UNIMP(ir);4.599 - }4.600 - }4.601 - break;4.602 - case 1: /* Load/store */4.603 - arm_disasm_address_operand( ir, operand, sizeof(operand), pc );4.604 - switch( (ir>>20)&0x17 ) {4.605 - case 0:4.606 - case 16:4.607 - case 18:4.608 - snprintf(buf, len, "STR%s R%d, %s", cond, RD(ir), operand );4.609 - break;4.610 - case 1:4.611 - case 17:4.612 - case 19:4.613 - snprintf(buf, len, "LDR%s R%d, %s", cond, RD(ir), operand );4.614 - break;4.615 - case 2:4.616 - snprintf(buf, len, "STRT%s R%d, %s", cond, RD(ir), operand );4.617 - break;4.618 - case 3:4.619 - snprintf(buf, len, "LDRT%s R%d, %s", cond, RD(ir), operand );4.620 - break;4.621 - case 4:4.622 - case 20:4.623 - case 22:4.624 - snprintf(buf, len, "STRB%s R%d, %s", cond, RD(ir), operand );4.625 - break;4.626 - case 5:4.627 - case 21:4.628 - case 23:4.629 - snprintf(buf, len, "LDRB%s R%d, %s", cond, RD(ir), operand );4.630 - break;4.631 - case 6:4.632 - snprintf(buf, len, "STRBT%s R%d, %s", cond, RD(ir), operand );4.633 - break;4.634 - case 7:4.635 - snprintf(buf, len, "LDRBT%s R%d, %s", cond, RD(ir), operand );4.636 - break;4.637 - }4.638 - break;4.639 - case 2:4.640 - if( (ir & 0x02000000) == 0x02000000 ) {4.641 - int32_t offset = SIGNEXT24(ir&0x00FFFFFF) << 2;4.642 - if( (ir & 0x01000000) == 0x01000000 ) {4.643 - snprintf( buf, len, "BL%s $%08Xh", cond, pc + offset + 8 );4.644 - } else {4.645 - snprintf( buf, len, "B%s $%08Xh", cond, pc + offset + 8 );4.646 - }4.647 - } else {4.648 - /* Load/store multiple */4.649 - j = snprintf( buf, len, LFLAG(ir) ? "LDM%s%s R%d%c,":"STM%s%s R%d%c,",4.650 - ldmModes[(ir>>23)&0x03], cond, RN(ir), WFLAG(ir)?'!':' ' );4.651 - buf += j;4.652 - len -= j;4.653 - for( i = 0; i<16 && len > 2; i++ ) {4.654 - if( ir & (1<<i) ) {4.655 - j = snprintf( buf, len, "R%d", i );4.656 - buf+=j;4.657 - len-=j;4.658 - }4.659 - }4.660 - if( BFLAG(ir) && len > 0 ) {4.661 - buf[0] = '^';4.662 - buf[1] = '\0';4.663 - }4.664 - }4.665 - break;4.666 - case 3: /* Copro */4.667 - if( (ir & 0x0F000000) == 0x0F000000 ) {4.668 - snprintf( buf, len, "SWI%s #%08Xh", cond, SIGNEXT24(ir) );4.669 - } else {4.670 - UNIMP(ir);4.671 - }4.672 - break;4.673 - }4.674 -4.675 -4.676 -4.677 - return pc+4;4.678 + switch(OPCODE(ir)) {4.679 + case 0: /* AND Rd, Rn, operand */4.680 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.681 + snprintf(buf, len, "AND%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.682 + break;4.683 + case 1: /* ANDS Rd, Rn, operand */4.684 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.685 + snprintf(buf, len, "ANDS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.686 + break;4.687 + case 2: /* EOR Rd, Rn, operand */4.688 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.689 + snprintf(buf, len, "EOR%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.690 + break;4.691 + case 3: /* EORS Rd, Rn, operand */4.692 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.693 + snprintf(buf, len, "EORS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.694 + break;4.695 + case 4: /* SUB Rd, Rn, operand */4.696 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.697 + snprintf(buf, len, "SUB%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.698 + break;4.699 + case 5: /* SUBS Rd, Rn, operand */4.700 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.701 + snprintf(buf, len, "SUBS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.702 + break;4.703 + case 6: /* RSB Rd, Rn, operand */4.704 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.705 + snprintf(buf, len, "RSB%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.706 + break;4.707 + case 7: /* RSBS Rd, Rn, operand */4.708 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.709 + snprintf(buf, len, "RSBS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.710 + break;4.711 + case 8: /* ADD Rd, Rn, operand */4.712 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.713 + snprintf(buf, len, "ADD%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.714 + break;4.715 + case 9: /* ADDS Rd, Rn, operand */4.716 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.717 + snprintf(buf, len, "ADDS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.718 + break;4.719 + case 10: /* ADC Rd, Rn, operand */4.720 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.721 + snprintf(buf, len, "ADC%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.722 + break;4.723 + case 11: /* ADCS Rd, Rn, operand */4.724 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.725 + snprintf(buf, len, "ADCS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.726 + break;4.727 + case 12: /* SBC Rd, Rn, operand */4.728 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.729 + snprintf(buf, len, "SBC%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.730 + break;4.731 + case 13: /* SBCS Rd, Rn, operand */4.732 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.733 + snprintf(buf, len, "SBCS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.734 + break;4.735 + case 14: /* RSC Rd, Rn, operand */4.736 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.737 + snprintf(buf, len, "RSC%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.738 + break;4.739 + case 15: /* RSCS Rd, Rn, operand */4.740 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.741 + snprintf(buf, len, "RSCS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.742 + break;4.743 + case 17: /* TST Rd, Rn, operand */4.744 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.745 + snprintf(buf, len, "TST%s R%d, %s", cond, RN(ir), operand);4.746 + break;4.747 + case 19: /* TEQ Rd, Rn, operand */4.748 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.749 + snprintf(buf, len, "TEQ%s R%d, %s", cond, RN(ir), operand);4.750 + break;4.751 + case 21: /* CMP Rd, Rn, operand */4.752 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.753 + snprintf(buf, len, "CMP%s R%d, %s", cond, RN(ir), operand);4.754 + break;4.755 + case 23: /* CMN Rd, Rn, operand */4.756 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.757 + snprintf(buf, len, "CMN%s R%d, %s", cond, RN(ir), operand);4.758 + break;4.759 + case 24: /* ORR Rd, Rn, operand */4.760 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.761 + snprintf(buf, len, "ORR%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.762 + break;4.763 + case 25: /* ORRS Rd, Rn, operand */4.764 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.765 + snprintf(buf, len, "ORRS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.766 + break;4.767 + case 26: /* MOV Rd, operand */4.768 + if( ir == 0xE1A00000 ) {4.769 + /* Not technically a different instruction,4.770 + * but this one is commonly used as a NOP,4.771 + * so...4.772 + */4.773 + snprintf(buf, len, "NOP");4.774 + } else {4.775 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.776 + snprintf(buf, len, "MOV%s R%d, %s", cond, RD(ir), operand);4.777 + }4.778 + break;4.779 + case 27: /* MOVS Rd, operand */4.780 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.781 + snprintf(buf, len, "MOVS%s R%d, %s", cond, RD(ir), operand);4.782 + break;4.783 + case 28: /* BIC Rd, Rn, operand */4.784 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.785 + snprintf(buf, len, "BIC%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.786 + break;4.787 + case 29: /* BICS Rd, Rn, operand */4.788 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.789 + snprintf(buf, len, "BICS%s R%d, R%d, %s", cond, RD(ir), RN(ir), operand);4.790 + break;4.791 + case 30: /* MVN Rd, Rn, operand */4.792 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.793 + snprintf(buf, len, "MVN%s R%d, %s", cond, RD(ir), operand);4.794 + break;4.795 + case 31: /* MVNS Rd, Rn, operand */4.796 + arm_disasm_shift_operand(ir, operand, sizeof(operand));4.797 + snprintf(buf, len, "MVNS%s R%d, %s", cond, RD(ir), operand);4.798 + break;4.799 + default:4.800 + UNIMP(ir);4.801 + }4.802 + }4.803 + break;4.804 + case 1: /* Load/store */4.805 + arm_disasm_address_operand( ir, operand, sizeof(operand), pc );4.806 + switch( (ir>>20)&0x17 ) {4.807 + case 0:4.808 + case 16:4.809 + case 18:4.810 + snprintf(buf, len, "STR%s R%d, %s", cond, RD(ir), operand );4.811 + break;4.812 + case 1:4.813 + case 17:4.814 + case 19:4.815 + snprintf(buf, len, "LDR%s R%d, %s", cond, RD(ir), operand );4.816 + break;4.817 + case 2:4.818 + snprintf(buf, len, "STRT%s R%d, %s", cond, RD(ir), operand );4.819 + break;4.820 + case 3:4.821 + snprintf(buf, len, "LDRT%s R%d, %s", cond, RD(ir), operand );4.822 + break;4.823 + case 4:4.824 + case 20:4.825 + case 22:4.826 + snprintf(buf, len, "STRB%s R%d, %s", cond, RD(ir), operand );4.827 + break;4.828 + case 5:4.829 + case 21:4.830 + case 23:4.831 + snprintf(buf, len, "LDRB%s R%d, %s", cond, RD(ir), operand );4.832 + break;4.833 + case 6:4.834 + snprintf(buf, len, "STRBT%s R%d, %s", cond, RD(ir), operand );4.835 + break;4.836 + case 7:4.837 + snprintf(buf, len, "LDRBT%s R%d, %s", cond, RD(ir), operand );4.838 + break;4.839 + }4.840 + break;4.841 + case 2:4.842 + if( (ir & 0x02000000) == 0x02000000 ) {4.843 + int32_t offset = SIGNEXT24(ir&0x00FFFFFF) << 2;4.844 + if( (ir & 0x01000000) == 0x01000000 ) {4.845 + snprintf( buf, len, "BL%s $%08Xh", cond, pc + offset + 8 );4.846 + } else {4.847 + snprintf( buf, len, "B%s $%08Xh", cond, pc + offset + 8 );4.848 + }4.849 + } else {4.850 + /* Load/store multiple */4.851 + j = snprintf( buf, len, LFLAG(ir) ? "LDM%s%s R%d%c,":"STM%s%s R%d%c,",4.852 + ldmModes[(ir>>23)&0x03], cond, RN(ir), WFLAG(ir)?'!':' ' );4.853 + buf += j;4.854 + len -= j;4.855 + for( i = 0; i<16 && len > 2; i++ ) {4.856 + if( ir & (1<<i) ) {4.857 + j = snprintf( buf, len, "R%d", i );4.858 + buf+=j;4.859 + len-=j;4.860 + }4.861 + }4.862 + if( BFLAG(ir) && len > 0 ) {4.863 + buf[0] = '^';4.864 + buf[1] = '\0';4.865 + }4.866 + }4.867 + break;4.868 + case 3: /* Copro */4.869 + if( (ir & 0x0F000000) == 0x0F000000 ) {4.870 + snprintf( buf, len, "SWI%s #%08Xh", cond, SIGNEXT24(ir) );4.871 + } else {4.872 + UNIMP(ir);4.873 + }4.874 + break;4.875 + }4.876 +4.877 +4.878 +4.879 + return pc+4;4.880 }
5.1 --- a/src/aica/armdasm.h Mon Jul 14 07:42:45 2008 +00005.2 +++ b/src/aica/armdasm.h Mon Jul 14 07:44:42 2008 +00005.3 @@ -16,8 +16,8 @@5.4 * GNU General Public License for more details.5.5 */5.7 -#ifndef armdasm_H5.8 -#define armdasm_H 15.9 +#ifndef lxdream_armdasm_H5.10 +#define lxdream_armdasm_H 15.12 #include "cpu.h"5.14 @@ -36,4 +36,4 @@5.15 }5.16 #endif5.18 -#endif5.19 +#endif /* !lxdream_armdasm_H */
6.1 --- a/src/aica/armmem.c Mon Jul 14 07:42:45 2008 +00006.2 +++ b/src/aica/armmem.c Mon Jul 14 07:44:42 2008 +00006.3 @@ -31,35 +31,35 @@6.5 int arm_has_page( uint32_t addr ) {6.6 return ( addr < 0x00200000 ||6.7 - (addr >= 0x00800000 && addr <= 0x00805000 ) );6.8 + (addr >= 0x00800000 && addr <= 0x00805000 ) );6.9 }6.11 uint32_t arm_read_long( uint32_t addr ) {6.12 if( addr < 0x00200000 ) {6.13 - return *(int32_t *)(arm_mem + addr);6.14 - /* Main sound ram */6.15 + return *(int32_t *)(arm_mem + addr);6.16 + /* Main sound ram */6.17 } else {6.18 - uint32_t val;6.19 - switch( addr & 0xFFFFF000 ) {6.20 - case 0x00800000:6.21 - val = mmio_region_AICA0_read(addr&0x0FFF);6.22 - // DEBUG( "ARM long read from %08X => %08X", addr, val );6.23 - return val;6.24 - case 0x00801000:6.25 - val = mmio_region_AICA1_read(addr&0x0FFF);6.26 - // DEBUG( "ARM long read from %08X => %08X", addr, val );6.27 - return val;6.28 - case 0x00802000:6.29 - val = mmio_region_AICA2_read(addr&0x0FFF);6.30 - // DEBUG( "ARM long read from %08X => %08X", addr, val );6.31 - return val;6.32 - case 0x00803000:6.33 - case 0x00804000:6.34 - return *(int32_t *)(arm_mem_scratch + addr - 0x00803000);6.35 - }6.36 + uint32_t val;6.37 + switch( addr & 0xFFFFF000 ) {6.38 + case 0x00800000:6.39 + val = mmio_region_AICA0_read(addr&0x0FFF);6.40 + // DEBUG( "ARM long read from %08X => %08X", addr, val );6.41 + return val;6.42 + case 0x00801000:6.43 + val = mmio_region_AICA1_read(addr&0x0FFF);6.44 + // DEBUG( "ARM long read from %08X => %08X", addr, val );6.45 + return val;6.46 + case 0x00802000:6.47 + val = mmio_region_AICA2_read(addr&0x0FFF);6.48 + // DEBUG( "ARM long read from %08X => %08X", addr, val );6.49 + return val;6.50 + case 0x00803000:6.51 + case 0x00804000:6.52 + return *(int32_t *)(arm_mem_scratch + addr - 0x00803000);6.53 + }6.54 }6.55 ERROR( "Attempted long read to undefined page: %08X",6.56 - addr );6.57 + addr );6.58 /* Undefined memory */6.59 return 0;6.60 }6.61 @@ -75,31 +75,31 @@6.62 void arm_write_long( uint32_t addr, uint32_t value )6.63 {6.64 if( addr < 0x00200000 ) {6.65 - /* Main sound ram */6.66 - *(uint32_t *)(arm_mem + addr) = value;6.67 + /* Main sound ram */6.68 + *(uint32_t *)(arm_mem + addr) = value;6.69 } else {6.70 - switch( addr & 0xFFFFF000 ) {6.71 - case 0x00800000:6.72 - // DEBUG( "ARM long write to %08X <= %08X", addr, value );6.73 - mmio_region_AICA0_write(addr&0x0FFF, value);6.74 - break;6.75 - case 0x00801000:6.76 - // DEBUG( "ARM long write to %08X <= %08X", addr, value );6.77 - mmio_region_AICA1_write(addr&0x0FFF, value);6.78 - break;6.79 - case 0x00802000:6.80 - // DEBUG( "ARM long write to %08X <= %08X", addr, value );6.81 - mmio_region_AICA2_write(addr&0x0FFF, value);6.82 - break;6.83 - case 0x00803000:6.84 - case 0x00804000:6.85 - *(uint32_t *)(arm_mem_scratch + addr - 0x00803000) = value;6.86 - break;6.87 - default:6.88 - ERROR( "Attempted long write to undefined address: %08X",6.89 - addr );6.90 - /* Undefined memory */6.91 - }6.92 + switch( addr & 0xFFFFF000 ) {6.93 + case 0x00800000:6.94 + // DEBUG( "ARM long write to %08X <= %08X", addr, value );6.95 + mmio_region_AICA0_write(addr&0x0FFF, value);6.96 + break;6.97 + case 0x00801000:6.98 + // DEBUG( "ARM long write to %08X <= %08X", addr, value );6.99 + mmio_region_AICA1_write(addr&0x0FFF, value);6.100 + break;6.101 + case 0x00802000:6.102 + // DEBUG( "ARM long write to %08X <= %08X", addr, value );6.103 + mmio_region_AICA2_write(addr&0x0FFF, value);6.104 + break;6.105 + case 0x00803000:6.106 + case 0x00804000:6.107 + *(uint32_t *)(arm_mem_scratch + addr - 0x00803000) = value;6.108 + break;6.109 + default:6.110 + ERROR( "Attempted long write to undefined address: %08X",6.111 + addr );6.112 + /* Undefined memory */6.113 + }6.114 }6.115 return;6.116 }6.117 @@ -108,50 +108,50 @@6.118 {6.119 switch( addr & 0x03 ) {6.120 case 0:6.121 - return (val & 0xFFFFFF00) | byte;6.122 + return (val & 0xFFFFFF00) | byte;6.123 case 1:6.124 - return (val & 0xFFFF00FF) | (byte<<8);6.125 + return (val & 0xFFFF00FF) | (byte<<8);6.126 case 2:6.127 - return (val & 0xFF00FFFF) | (byte<<16);6.128 + return (val & 0xFF00FFFF) | (byte<<16);6.129 case 3:6.130 - return (val & 0x00FFFFFF) | (byte<<24);6.131 + return (val & 0x00FFFFFF) | (byte<<24);6.132 default:6.133 - return val; // Can't happen, but make gcc happy6.134 + return val; // Can't happen, but make gcc happy6.135 }6.136 }6.138 void arm_write_byte( uint32_t addr, uint32_t value )6.139 {6.140 if( addr < 0x00200000 ) {6.141 - /* Main sound ram */6.142 - *(uint8_t *)(arm_mem + addr) = (uint8_t)value;6.143 + /* Main sound ram */6.144 + *(uint8_t *)(arm_mem + addr) = (uint8_t)value;6.145 } else {6.146 - uint32_t tmp;6.147 - switch( addr & 0xFFFFF000 ) {6.148 - case 0x00800000:6.149 - tmp = MMIO_READ( AICA0, addr & 0x0FFC );6.150 - value = arm_combine_byte( addr, tmp, value );6.151 - mmio_region_AICA0_write(addr&0x0FFC, value);6.152 - break;6.153 - case 0x00801000:6.154 - tmp = MMIO_READ( AICA1, addr & 0x0FFC );6.155 - value = arm_combine_byte( addr, tmp, value );6.156 - mmio_region_AICA1_write(addr&0x0FFC, value);6.157 - break;6.158 - case 0x00802000:6.159 - tmp = MMIO_READ( AICA2, addr & 0x0FFC );6.160 - value = arm_combine_byte( addr, tmp, value );6.161 - mmio_region_AICA2_write(addr&0x0FFC, value);6.162 - break;6.163 - case 0x00803000:6.164 - case 0x00804000:6.165 - *(uint8_t *)(arm_mem_scratch + addr - 0x00803000) = (uint8_t)value;6.166 - break;6.167 - default:6.168 - ERROR( "Attempted byte write to undefined address: %08X",6.169 - addr );6.170 - /* Undefined memory */6.171 - }6.172 + uint32_t tmp;6.173 + switch( addr & 0xFFFFF000 ) {6.174 + case 0x00800000:6.175 + tmp = MMIO_READ( AICA0, addr & 0x0FFC );6.176 + value = arm_combine_byte( addr, tmp, value );6.177 + mmio_region_AICA0_write(addr&0x0FFC, value);6.178 + break;6.179 + case 0x00801000:6.180 + tmp = MMIO_READ( AICA1, addr & 0x0FFC );6.181 + value = arm_combine_byte( addr, tmp, value );6.182 + mmio_region_AICA1_write(addr&0x0FFC, value);6.183 + break;6.184 + case 0x00802000:6.185 + tmp = MMIO_READ( AICA2, addr & 0x0FFC );6.186 + value = arm_combine_byte( addr, tmp, value );6.187 + mmio_region_AICA2_write(addr&0x0FFC, value);6.188 + break;6.189 + case 0x00803000:6.190 + case 0x00804000:6.191 + *(uint8_t *)(arm_mem_scratch + addr - 0x00803000) = (uint8_t)value;6.192 + break;6.193 + default:6.194 + ERROR( "Attempted byte write to undefined address: %08X",6.195 + addr );6.196 + /* Undefined memory */6.197 + }6.198 }6.199 return;6.200 }
7.1 --- a/src/aica/audio.c Mon Jul 14 07:42:45 2008 +00007.2 +++ b/src/aica/audio.c Mon Jul 14 07:44:42 2008 +00007.3 @@ -33,19 +33,19 @@7.5 audio_driver_t audio_driver_list[] = {7.6 #ifdef HAVE_CORE_AUDIO7.7 - &audio_osx_driver,7.8 + &audio_osx_driver,7.9 #endif7.10 #ifdef HAVE_PULSE7.11 - &audio_pulse_driver,7.12 + &audio_pulse_driver,7.13 #endif7.14 #ifdef HAVE_ESOUND7.15 - &audio_esd_driver,7.16 + &audio_esd_driver,7.17 #endif7.18 #ifdef HAVE_ALSA7.19 - &audio_alsa_driver,7.20 + &audio_alsa_driver,7.21 #endif7.22 - &audio_null_driver,7.23 - NULL };7.24 + &audio_null_driver,7.25 + NULL };7.27 #define NUM_BUFFERS 37.28 #define MS_PER_BUFFER 1007.29 @@ -105,7 +105,7 @@7.30 fprintf( out, "Available audio drivers:\n" );7.31 for( i=0; audio_driver_list[i] != NULL; i++ ) {7.32 fprintf( out, " %-8s %s\n", audio_driver_list[i]->name,7.33 - gettext(audio_driver_list[i]->description) );7.34 + gettext(audio_driver_list[i]->description) );7.35 }7.36 }7.38 @@ -239,23 +239,23 @@7.39 */7.41 #define CLAMP_TO_SHORT(value) \7.42 -if (value > 32767) \7.43 + if (value > 32767) \7.44 value = 32767; \7.45 -else if (value < -32768) \7.46 + else if (value < -32768) \7.47 value = -32768; \7.49 static const int yamaha_indexscale[] = {7.50 - 230, 230, 230, 230, 307, 409, 512, 614,7.51 - 230, 230, 230, 230, 307, 409, 512, 6147.52 + 230, 230, 230, 230, 307, 409, 512, 614,7.53 + 230, 230, 230, 230, 307, 409, 512, 6147.54 };7.56 static const int yamaha_difflookup[] = {7.57 - 1, 3, 5, 7, 9, 11, 13, 15,7.58 - -1, -3, -5, -7, -9, -11, -13, -157.59 + 1, 3, 5, 7, 9, 11, 13, 15,7.60 + -1, -3, -5, -7, -9, -11, -13, -157.61 };7.63 static inline short adpcm_yamaha_decode_nibble( audio_channel_t c,7.64 - unsigned char nibble )7.65 + unsigned char nibble )7.66 {7.67 if( c->adpcm_step == 0 ) {7.68 c->adpcm_predict = 0;7.69 @@ -371,7 +371,7 @@7.70 }7.71 }7.72 }7.73 -7.74 +7.75 /* Down-render to the final output format */7.76 audio_buffer_t buf = audio.output_buffers[audio.write_buffer];7.77 if( buf->status == BUFFER_FULL ) {7.78 @@ -380,7 +380,7 @@7.79 return;7.80 }7.81 }7.82 -7.83 +7.84 switch( audio.output_format & AUDIO_FMT_SAMPLE_MASK ) {7.85 case AUDIO_FMT_FLOAT: {7.86 float scale = 1.0/SHRT_MAX;7.87 @@ -447,11 +447,11 @@7.88 void audio_start_stop_channel( int channel, gboolean start )7.89 {7.90 if( audio.channels[channel].active ) {7.91 - if( !start ) {7.92 - audio_stop_channel(channel);7.93 - }7.94 + if( !start ) {7.95 + audio_stop_channel(channel);7.96 + }7.97 } else if( start ) {7.98 - audio_start_channel(channel);7.99 + audio_start_channel(channel);7.100 }7.101 }7.103 @@ -467,9 +467,9 @@7.104 audio.channels[channel].posn_left = 0;7.105 audio.channels[channel].active = TRUE;7.106 if( audio.channels[channel].sample_format == AUDIO_FMT_ADPCM ) {7.107 - audio.channels[channel].adpcm_step = 0;7.108 - audio.channels[channel].adpcm_predict = 0;7.109 - uint8_t data = ((uint8_t *)(arm_mem + audio.channels[channel].start))[0];7.110 - adpcm_yamaha_decode_nibble( &audio.channels[channel], data & 0x0F );7.111 + audio.channels[channel].adpcm_step = 0;7.112 + audio.channels[channel].adpcm_predict = 0;7.113 + uint8_t data = ((uint8_t *)(arm_mem + audio.channels[channel].start))[0];7.114 + adpcm_yamaha_decode_nibble( &audio.channels[channel], data & 0x0F );7.115 }7.116 }
8.1 --- a/src/aica/audio.h Mon Jul 14 07:42:45 2008 +00008.2 +++ b/src/aica/audio.h Mon Jul 14 07:44:42 2008 +00008.3 @@ -15,15 +15,14 @@8.4 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8.5 * GNU General Public License for more details.8.6 */8.7 -#ifndef dream_audio_H8.8 -#define dream_audio_H 18.9 +#ifndef lxdream_audio_H8.10 +#define lxdream_audio_H 18.12 #include <stdint.h>8.13 #include <stdio.h>8.14 #include <glib/gtypes.h>8.15 #include <glib/gi18n.h>8.17 -8.18 #ifdef __cplusplus8.19 extern "C" {8.20 #endif8.21 @@ -135,4 +134,5 @@8.22 #ifdef __cplusplus8.23 }8.24 #endif8.25 -#endif8.26 \ No newline at end of file8.27 +8.28 +#endif /* !lxdream_audio_H */
9.1 --- a/src/asic.c Mon Jul 14 07:42:45 2008 +00009.2 +++ b/src/asic.c Mon Jul 14 07:44:42 2008 +00009.3 @@ -52,7 +52,7 @@9.4 static uint32_t g2_update_fifo_status( uint32_t slice_cycle );9.6 struct dreamcast_module asic_module = { "ASIC", asic_init, asic_reset, NULL, asic_run_slice,9.7 - NULL, asic_save_state, asic_load_state };9.8 + NULL, asic_save_state, asic_load_state };9.10 #define G2_BIT5_TICKS 609.11 #define G2_BIT4_TICKS 1609.12 @@ -73,33 +73,33 @@9.13 {9.14 g2_update_fifo_status(nanosecs);9.15 if( g2_state.bit5_off_timer <= (int32_t)nanosecs ) {9.16 - g2_state.bit5_off_timer = -1;9.17 + g2_state.bit5_off_timer = -1;9.18 } else {9.19 - g2_state.bit5_off_timer -= nanosecs;9.20 + g2_state.bit5_off_timer -= nanosecs;9.21 }9.23 if( g2_state.bit4_off_timer <= (int32_t)nanosecs ) {9.24 - g2_state.bit4_off_timer = -1;9.25 + g2_state.bit4_off_timer = -1;9.26 } else {9.27 - g2_state.bit4_off_timer -= nanosecs;9.28 + g2_state.bit4_off_timer -= nanosecs;9.29 }9.30 if( g2_state.bit4_on_timer <= (int32_t)nanosecs ) {9.31 - g2_state.bit4_on_timer = -1;9.32 + g2_state.bit4_on_timer = -1;9.33 } else {9.34 - g2_state.bit4_on_timer -= nanosecs;9.35 + g2_state.bit4_on_timer -= nanosecs;9.36 }9.37 -9.38 +9.39 if( g2_state.bit0_off_timer <= (int32_t)nanosecs ) {9.40 - g2_state.bit0_off_timer = -1;9.41 + g2_state.bit0_off_timer = -1;9.42 } else {9.43 - g2_state.bit0_off_timer -= nanosecs;9.44 + g2_state.bit0_off_timer -= nanosecs;9.45 }9.46 if( g2_state.bit0_on_timer <= (int32_t)nanosecs ) {9.47 - g2_state.bit0_on_timer = -1;9.48 + g2_state.bit0_on_timer = -1;9.49 } else {9.50 - g2_state.bit0_on_timer -= nanosecs;9.51 + g2_state.bit0_on_timer -= nanosecs;9.52 }9.53 -9.54 +9.55 return nanosecs;9.56 }9.58 @@ -123,9 +123,9 @@9.59 static int asic_load_state( FILE *f )9.60 {9.61 if( fread( &g2_state, sizeof(g2_state), 1, f ) != 1 )9.62 - return 1;9.63 + return 1;9.64 else9.65 - return 0;9.66 + return 0;9.67 }9.70 @@ -146,29 +146,29 @@9.71 void asic_g2_write_word()9.72 {9.73 if( g2_state.bit5_off_timer < (int32_t)sh4r.slice_cycle ) {9.74 - g2_state.bit5_off_timer = sh4r.slice_cycle + G2_BIT5_TICKS;9.75 + g2_state.bit5_off_timer = sh4r.slice_cycle + G2_BIT5_TICKS;9.76 } else {9.77 - g2_state.bit5_off_timer += G2_BIT5_TICKS;9.78 + g2_state.bit5_off_timer += G2_BIT5_TICKS;9.79 }9.81 if( g2_state.bit4_on_timer < (int32_t)sh4r.slice_cycle ) {9.82 - g2_state.bit4_on_timer = sh4r.slice_cycle + G2_BIT5_TICKS;9.83 + g2_state.bit4_on_timer = sh4r.slice_cycle + G2_BIT5_TICKS;9.84 }9.86 if( g2_state.bit4_off_timer < (int32_t)sh4r.slice_cycle ) {9.87 - g2_state.bit4_off_timer = g2_state.bit4_on_timer + G2_BIT4_TICKS;9.88 + g2_state.bit4_off_timer = g2_state.bit4_on_timer + G2_BIT4_TICKS;9.89 } else {9.90 - g2_state.bit4_off_timer += G2_BIT4_TICKS;9.91 + g2_state.bit4_off_timer += G2_BIT4_TICKS;9.92 }9.94 if( g2_state.bit0_on_timer < (int32_t)sh4r.slice_cycle ) {9.95 - g2_state.bit0_on_timer = sh4r.slice_cycle + G2_BIT0_ON_TICKS;9.96 + g2_state.bit0_on_timer = sh4r.slice_cycle + G2_BIT0_ON_TICKS;9.97 }9.99 if( g2_state.bit0_off_timer < (int32_t)sh4r.slice_cycle ) {9.100 - g2_state.bit0_off_timer = g2_state.bit0_on_timer + G2_BIT0_OFF_TICKS;9.101 + g2_state.bit0_off_timer = g2_state.bit0_on_timer + G2_BIT0_OFF_TICKS;9.102 } else {9.103 - g2_state.bit0_off_timer += G2_BIT0_OFF_TICKS;9.104 + g2_state.bit0_off_timer += G2_BIT0_OFF_TICKS;9.105 }9.107 MMIO_WRITE( ASIC, G2STATUS, MMIO_READ(ASIC, G2STATUS) | 0x20 );9.108 @@ -178,25 +178,25 @@9.109 {9.110 uint32_t val = MMIO_READ( ASIC, G2STATUS );9.111 if( ((uint32_t)g2_state.bit5_off_timer) <= nanos ) {9.112 - val = val & (~0x20);9.113 - g2_state.bit5_off_timer = -1;9.114 + val = val & (~0x20);9.115 + g2_state.bit5_off_timer = -1;9.116 }9.117 if( ((uint32_t)g2_state.bit4_on_timer) <= nanos ) {9.118 - val = val | 0x10;9.119 - g2_state.bit4_on_timer = -1;9.120 + val = val | 0x10;9.121 + g2_state.bit4_on_timer = -1;9.122 }9.123 if( ((uint32_t)g2_state.bit4_off_timer) <= nanos ) {9.124 - val = val & (~0x10);9.125 - g2_state.bit4_off_timer = -1;9.126 + val = val & (~0x10);9.127 + g2_state.bit4_off_timer = -1;9.128 }9.130 if( ((uint32_t)g2_state.bit0_on_timer) <= nanos ) {9.131 - val = val | 0x01;9.132 - g2_state.bit0_on_timer = -1;9.133 + val = val | 0x01;9.134 + g2_state.bit0_on_timer = -1;9.135 }9.136 if( ((uint32_t)g2_state.bit0_off_timer) <= nanos ) {9.137 - val = val & (~0x01);9.138 - g2_state.bit0_off_timer = -1;9.139 + val = val & (~0x01);9.140 + g2_state.bit0_off_timer = -1;9.141 }9.143 MMIO_WRITE( ASIC, G2STATUS, val );9.144 @@ -221,9 +221,9 @@9.145 intc_raise_interrupt( INT_IRQ9 );9.147 if( event >= 64 ) { /* Third word */9.148 - asic_event( EVENT_CASCADE2 );9.149 + asic_event( EVENT_CASCADE2 );9.150 } else if( event >= 32 ) { /* Second word */9.151 - asic_event( EVENT_CASCADE1 );9.152 + asic_event( EVENT_CASCADE1 );9.153 }9.154 }9.156 @@ -232,14 +232,14 @@9.157 uint32_t result = MMIO_READ(ASIC, PIRQ0 + offset) & (~(1<<(event&0x1F)));9.158 MMIO_WRITE( ASIC, PIRQ0 + offset, result );9.159 if( result == 0 ) {9.160 - /* clear cascades if necessary */9.161 - if( event >= 64 ) {9.162 - MMIO_WRITE( ASIC, PIRQ0, MMIO_READ( ASIC, PIRQ0 ) & 0x7FFFFFFF );9.163 - } else if( event >= 32 ) {9.164 - MMIO_WRITE( ASIC, PIRQ0, MMIO_READ( ASIC, PIRQ0 ) & 0xBFFFFFFF );9.165 - }9.166 + /* clear cascades if necessary */9.167 + if( event >= 64 ) {9.168 + MMIO_WRITE( ASIC, PIRQ0, MMIO_READ( ASIC, PIRQ0 ) & 0x7FFFFFFF );9.169 + } else if( event >= 32 ) {9.170 + MMIO_WRITE( ASIC, PIRQ0, MMIO_READ( ASIC, PIRQ0 ) & 0xBFFFFFFF );9.171 + }9.172 }9.173 -9.174 +9.175 asic_check_cleared_events();9.176 }9.178 @@ -248,17 +248,17 @@9.179 int i, setA = 0, setB = 0, setC = 0;9.180 uint32_t bits;9.181 for( i=0; i<12; i+=4 ) {9.182 - bits = MMIO_READ( ASIC, PIRQ0 + i );9.183 - setA |= (bits & MMIO_READ(ASIC, IRQA0 + i ));9.184 - setB |= (bits & MMIO_READ(ASIC, IRQB0 + i ));9.185 - setC |= (bits & MMIO_READ(ASIC, IRQC0 + i ));9.186 + bits = MMIO_READ( ASIC, PIRQ0 + i );9.187 + setA |= (bits & MMIO_READ(ASIC, IRQA0 + i ));9.188 + setB |= (bits & MMIO_READ(ASIC, IRQB0 + i ));9.189 + setC |= (bits & MMIO_READ(ASIC, IRQC0 + i ));9.190 }9.191 if( setA == 0 )9.192 - intc_clear_interrupt( INT_IRQ13 );9.193 + intc_clear_interrupt( INT_IRQ13 );9.194 if( setB == 0 )9.195 - intc_clear_interrupt( INT_IRQ11 );9.196 + intc_clear_interrupt( INT_IRQ11 );9.197 if( setC == 0 )9.198 - intc_clear_interrupt( INT_IRQ9 );9.199 + intc_clear_interrupt( INT_IRQ9 );9.200 }9.202 void asic_event_mask_changed( )9.203 @@ -266,23 +266,23 @@9.204 int i, setA = 0, setB = 0, setC = 0;9.205 uint32_t bits;9.206 for( i=0; i<12; i+=4 ) {9.207 - bits = MMIO_READ( ASIC, PIRQ0 + i );9.208 - setA |= (bits & MMIO_READ(ASIC, IRQA0 + i ));9.209 - setB |= (bits & MMIO_READ(ASIC, IRQB0 + i ));9.210 - setC |= (bits & MMIO_READ(ASIC, IRQC0 + i ));9.211 + bits = MMIO_READ( ASIC, PIRQ0 + i );9.212 + setA |= (bits & MMIO_READ(ASIC, IRQA0 + i ));9.213 + setB |= (bits & MMIO_READ(ASIC, IRQB0 + i ));9.214 + setC |= (bits & MMIO_READ(ASIC, IRQC0 + i ));9.215 }9.216 if( setA == 0 )9.217 - intc_clear_interrupt( INT_IRQ13 );9.218 + intc_clear_interrupt( INT_IRQ13 );9.219 else9.220 - intc_raise_interrupt( INT_IRQ13 );9.221 + intc_raise_interrupt( INT_IRQ13 );9.222 if( setB == 0 )9.223 - intc_clear_interrupt( INT_IRQ11 );9.224 + intc_clear_interrupt( INT_IRQ11 );9.225 else9.226 - intc_raise_interrupt( INT_IRQ11 );9.227 + intc_raise_interrupt( INT_IRQ11 );9.228 if( setC == 0 )9.229 - intc_clear_interrupt( INT_IRQ9 );9.230 + intc_clear_interrupt( INT_IRQ9 );9.231 else9.232 - intc_raise_interrupt( INT_IRQ9 );9.233 + intc_raise_interrupt( INT_IRQ9 );9.234 }9.236 void g2_dma_transfer( int channel )9.237 @@ -290,44 +290,44 @@9.238 uint32_t offset = channel << 5;9.240 if( MMIO_READ( EXTDMA, G2DMA0CTL1 + offset ) == 1 ) {9.241 - if( MMIO_READ( EXTDMA, G2DMA0CTL2 + offset ) == 1 ) {9.242 - uint32_t extaddr = MMIO_READ( EXTDMA, G2DMA0EXT + offset );9.243 - uint32_t sh4addr = MMIO_READ( EXTDMA, G2DMA0SH4 + offset );9.244 - uint32_t length = MMIO_READ( EXTDMA, G2DMA0SIZ + offset ) & 0x1FFFFFFF;9.245 - uint32_t dir = MMIO_READ( EXTDMA, G2DMA0DIR + offset );9.246 - // uint32_t mode = MMIO_READ( EXTDMA, G2DMA0MOD + offset );9.247 - unsigned char buf[length];9.248 - if( dir == 0 ) { /* SH4 to device */9.249 - mem_copy_from_sh4( buf, sh4addr, length );9.250 - mem_copy_to_sh4( extaddr, buf, length );9.251 - } else { /* Device to SH4 */9.252 - mem_copy_from_sh4( buf, extaddr, length );9.253 - mem_copy_to_sh4( sh4addr, buf, length );9.254 - }9.255 - MMIO_WRITE( EXTDMA, G2DMA0CTL2 + offset, 0 );9.256 - asic_event( EVENT_G2_DMA0 + channel );9.257 - } else {9.258 - MMIO_WRITE( EXTDMA, G2DMA0CTL2 + offset, 0 );9.259 - }9.260 + if( MMIO_READ( EXTDMA, G2DMA0CTL2 + offset ) == 1 ) {9.261 + uint32_t extaddr = MMIO_READ( EXTDMA, G2DMA0EXT + offset );9.262 + uint32_t sh4addr = MMIO_READ( EXTDMA, G2DMA0SH4 + offset );9.263 + uint32_t length = MMIO_READ( EXTDMA, G2DMA0SIZ + offset ) & 0x1FFFFFFF;9.264 + uint32_t dir = MMIO_READ( EXTDMA, G2DMA0DIR + offset );9.265 + // uint32_t mode = MMIO_READ( EXTDMA, G2DMA0MOD + offset );9.266 + unsigned char buf[length];9.267 + if( dir == 0 ) { /* SH4 to device */9.268 + mem_copy_from_sh4( buf, sh4addr, length );9.269 + mem_copy_to_sh4( extaddr, buf, length );9.270 + } else { /* Device to SH4 */9.271 + mem_copy_from_sh4( buf, extaddr, length );9.272 + mem_copy_to_sh4( sh4addr, buf, length );9.273 + }9.274 + MMIO_WRITE( EXTDMA, G2DMA0CTL2 + offset, 0 );9.275 + asic_event( EVENT_G2_DMA0 + channel );9.276 + } else {9.277 + MMIO_WRITE( EXTDMA, G2DMA0CTL2 + offset, 0 );9.278 + }9.279 }9.280 }9.282 void asic_ide_dma_transfer( )9.283 {9.284 if( MMIO_READ( EXTDMA, IDEDMACTL2 ) == 1 ) {9.285 - if( MMIO_READ( EXTDMA, IDEDMACTL1 ) == 1 ) {9.286 - MMIO_WRITE( EXTDMA, IDEDMATXSIZ, 0 );9.287 -9.288 - uint32_t addr = MMIO_READ( EXTDMA, IDEDMASH4 );9.289 - uint32_t length = MMIO_READ( EXTDMA, IDEDMASIZ );9.290 - // int dir = MMIO_READ( EXTDMA, IDEDMADIR );9.291 -9.292 - uint32_t xfer = ide_read_data_dma( addr, length );9.293 - MMIO_WRITE( EXTDMA, IDEDMATXSIZ, xfer );9.294 - MMIO_WRITE( EXTDMA, IDEDMACTL2, 0 );9.295 - } else { /* 0 */9.296 - MMIO_WRITE( EXTDMA, IDEDMACTL2, 0 );9.297 - }9.298 + if( MMIO_READ( EXTDMA, IDEDMACTL1 ) == 1 ) {9.299 + MMIO_WRITE( EXTDMA, IDEDMATXSIZ, 0 );9.300 +9.301 + uint32_t addr = MMIO_READ( EXTDMA, IDEDMASH4 );9.302 + uint32_t length = MMIO_READ( EXTDMA, IDEDMASIZ );9.303 + // int dir = MMIO_READ( EXTDMA, IDEDMADIR );9.304 +9.305 + uint32_t xfer = ide_read_data_dma( addr, length );9.306 + MMIO_WRITE( EXTDMA, IDEDMATXSIZ, xfer );9.307 + MMIO_WRITE( EXTDMA, IDEDMACTL2, 0 );9.308 + } else { /* 0 */9.309 + MMIO_WRITE( EXTDMA, IDEDMACTL2, 0 );9.310 + }9.311 }9.312 }9.314 @@ -338,14 +338,14 @@9.315 unsigned char *data = alloca( count );9.316 uint32_t rcount = DMAC_get_buffer( 2, data, count );9.317 if( rcount != count )9.318 - WARN( "PVR received %08X bytes from DMA, expected %08X", rcount, count );9.319 -9.320 + WARN( "PVR received %08X bytes from DMA, expected %08X", rcount, count );9.321 +9.322 pvr2_dma_write( destaddr, data, rcount );9.323 -9.324 +9.325 MMIO_WRITE( ASIC, PVRDMACTL, 0 );9.326 MMIO_WRITE( ASIC, PVRDMACNT, 0 );9.327 if( destaddr & 0x01000000 ) { /* Write to texture RAM */9.328 - MMIO_WRITE( ASIC, PVRDMADEST, destaddr + rcount );9.329 + MMIO_WRITE( ASIC, PVRDMADEST, destaddr + rcount );9.330 }9.331 asic_event( EVENT_PVR_DMA );9.332 }9.333 @@ -356,7 +356,7 @@9.334 sh4addr_t data_addr = MMIO_READ( ASIC, SORTDMADATA );9.335 int table_size = MMIO_READ( ASIC, SORTDMATSIZ );9.336 int data_size = MMIO_READ( ASIC, SORTDMADSIZ );9.337 -9.338 +9.339 WARN( "Sort DMA not implemented" );9.340 }9.342 @@ -364,21 +364,21 @@9.343 {9.344 switch( reg ) {9.345 case PIRQ1:9.346 - break; /* Treat this as read-only for the moment */9.347 + break; /* Treat this as read-only for the moment */9.348 case PIRQ0:9.349 - val = val & 0x3FFFFFFF; /* Top two bits aren't clearable */9.350 - MMIO_WRITE( ASIC, reg, MMIO_READ(ASIC, reg)&~val );9.351 - asic_check_cleared_events();9.352 - break;9.353 + val = val & 0x3FFFFFFF; /* Top two bits aren't clearable */9.354 + MMIO_WRITE( ASIC, reg, MMIO_READ(ASIC, reg)&~val );9.355 + asic_check_cleared_events();9.356 + break;9.357 case PIRQ2:9.358 - /* Clear any events */9.359 - val = MMIO_READ(ASIC, reg)&(~val);9.360 - MMIO_WRITE( ASIC, reg, val );9.361 - if( val == 0 ) { /* all clear - clear the cascade bit */9.362 - MMIO_WRITE( ASIC, PIRQ0, MMIO_READ( ASIC, PIRQ0 ) & 0x7FFFFFFF );9.363 - }9.364 - asic_check_cleared_events();9.365 - break;9.366 + /* Clear any events */9.367 + val = MMIO_READ(ASIC, reg)&(~val);9.368 + MMIO_WRITE( ASIC, reg, val );9.369 + if( val == 0 ) { /* all clear - clear the cascade bit */9.370 + MMIO_WRITE( ASIC, PIRQ0, MMIO_READ( ASIC, PIRQ0 ) & 0x7FFFFFFF );9.371 + }9.372 + asic_check_cleared_events();9.373 + break;9.374 case IRQA0:9.375 case IRQA1:9.376 case IRQA2:9.377 @@ -388,37 +388,37 @@9.378 case IRQC0:9.379 case IRQC1:9.380 case IRQC2:9.381 - MMIO_WRITE( ASIC, reg, val );9.382 - asic_event_mask_changed();9.383 - break;9.384 + MMIO_WRITE( ASIC, reg, val );9.385 + asic_event_mask_changed();9.386 + break;9.387 case SYSRESET:9.388 - if( val == 0x7611 ) {9.389 - dreamcast_reset();9.390 - } else {9.391 - WARN( "Unknown value %08X written to SYSRESET port", val );9.392 - }9.393 - break;9.394 + if( val == 0x7611 ) {9.395 + dreamcast_reset();9.396 + } else {9.397 + WARN( "Unknown value %08X written to SYSRESET port", val );9.398 + }9.399 + break;9.400 case MAPLE_STATE:9.401 - MMIO_WRITE( ASIC, reg, val );9.402 - if( val & 1 ) {9.403 - uint32_t maple_addr = MMIO_READ( ASIC, MAPLE_DMA) &0x1FFFFFE0;9.404 - maple_handle_buffer( maple_addr );9.405 - MMIO_WRITE( ASIC, reg, 0 );9.406 - }9.407 - break;9.408 + MMIO_WRITE( ASIC, reg, val );9.409 + if( val & 1 ) {9.410 + uint32_t maple_addr = MMIO_READ( ASIC, MAPLE_DMA) &0x1FFFFFE0;9.411 + maple_handle_buffer( maple_addr );9.412 + MMIO_WRITE( ASIC, reg, 0 );9.413 + }9.414 + break;9.415 case PVRDMADEST:9.416 - MMIO_WRITE( ASIC, reg, (val & 0x03FFFFE0) | 0x10000000 );9.417 - break;9.418 + MMIO_WRITE( ASIC, reg, (val & 0x03FFFFE0) | 0x10000000 );9.419 + break;9.420 case PVRDMACNT:9.421 - MMIO_WRITE( ASIC, reg, val & 0x00FFFFE0 );9.422 - break;9.423 + MMIO_WRITE( ASIC, reg, val & 0x00FFFFE0 );9.424 + break;9.425 case PVRDMACTL: /* Initiate PVR DMA transfer */9.426 - val = val & 0x01;9.427 - MMIO_WRITE( ASIC, reg, val );9.428 - if( val == 1 ) {9.429 - pvr_dma_transfer();9.430 - }9.431 - break;9.432 + val = val & 0x01;9.433 + MMIO_WRITE( ASIC, reg, val );9.434 + if( val == 1 ) {9.435 + pvr_dma_transfer();9.436 + }9.437 + break;9.438 case SORTDMATBL: case SORTDMADATA:9.439 MMIO_WRITE( ASIC, reg, (val & 0x0FFFFFE0) | 0x08000000 );9.440 break;9.441 @@ -433,10 +433,10 @@9.442 }9.443 break;9.444 case MAPLE_DMA:9.445 - MMIO_WRITE( ASIC, reg, val );9.446 - break;9.447 + MMIO_WRITE( ASIC, reg, val );9.448 + break;9.449 default:9.450 - MMIO_WRITE( ASIC, reg, val );9.451 + MMIO_WRITE( ASIC, reg, val );9.452 }9.453 }9.455 @@ -457,136 +457,136 @@9.456 case IRQC1:9.457 case IRQC2:9.458 case MAPLE_STATE:9.459 - val = MMIO_READ(ASIC, reg);9.460 - return val;9.461 + val = MMIO_READ(ASIC, reg);9.462 + return val;9.463 case G2STATUS:9.464 - return g2_read_status();9.465 + return g2_read_status();9.466 default:9.467 - val = MMIO_READ(ASIC, reg);9.468 - return val;9.469 + val = MMIO_READ(ASIC, reg);9.470 + return val;9.471 }9.472 -9.473 +9.474 }9.476 MMIO_REGION_WRITE_FN( EXTDMA, reg, val )9.477 {9.478 if( !idereg.interface_enabled && IS_IDE_REGISTER(reg) ) {9.479 - return; /* disabled */9.480 + return; /* disabled */9.481 }9.483 switch( reg ) {9.484 case IDEALTSTATUS: /* Device control */9.485 - ide_write_control( val );9.486 - break;9.487 + ide_write_control( val );9.488 + break;9.489 case IDEDATA:9.490 - ide_write_data_pio( val );9.491 - break;9.492 + ide_write_data_pio( val );9.493 + break;9.494 case IDEFEAT:9.495 - if( ide_can_write_regs() )9.496 - idereg.feature = (uint8_t)val;9.497 - break;9.498 + if( ide_can_write_regs() )9.499 + idereg.feature = (uint8_t)val;9.500 + break;9.501 case IDECOUNT:9.502 - if( ide_can_write_regs() )9.503 - idereg.count = (uint8_t)val;9.504 - break;9.505 + if( ide_can_write_regs() )9.506 + idereg.count = (uint8_t)val;9.507 + break;9.508 case IDELBA0:9.509 - if( ide_can_write_regs() )9.510 - idereg.lba0 = (uint8_t)val;9.511 - break;9.512 + if( ide_can_write_regs() )9.513 + idereg.lba0 = (uint8_t)val;9.514 + break;9.515 case IDELBA1:9.516 - if( ide_can_write_regs() )9.517 - idereg.lba1 = (uint8_t)val;9.518 - break;9.519 + if( ide_can_write_regs() )9.520 + idereg.lba1 = (uint8_t)val;9.521 + break;9.522 case IDELBA2:9.523 - if( ide_can_write_regs() )9.524 - idereg.lba2 = (uint8_t)val;9.525 - break;9.526 + if( ide_can_write_regs() )9.527 + idereg.lba2 = (uint8_t)val;9.528 + break;9.529 case IDEDEV:9.530 - if( ide_can_write_regs() )9.531 - idereg.device = (uint8_t)val;9.532 - break;9.533 + if( ide_can_write_regs() )9.534 + idereg.device = (uint8_t)val;9.535 + break;9.536 case IDECMD:9.537 - if( ide_can_write_regs() || val == IDE_CMD_NOP ) {9.538 - ide_write_command( (uint8_t)val );9.539 - }9.540 - break;9.541 + if( ide_can_write_regs() || val == IDE_CMD_NOP ) {9.542 + ide_write_command( (uint8_t)val );9.543 + }9.544 + break;9.545 case IDEDMASH4:9.546 - MMIO_WRITE( EXTDMA, reg, val & 0x1FFFFFE0 );9.547 - break;9.548 + MMIO_WRITE( EXTDMA, reg, val & 0x1FFFFFE0 );9.549 + break;9.550 case IDEDMASIZ:9.551 - MMIO_WRITE( EXTDMA, reg, val & 0x01FFFFFE );9.552 - break;9.553 + MMIO_WRITE( EXTDMA, reg, val & 0x01FFFFFE );9.554 + break;9.555 case IDEDMADIR:9.556 - MMIO_WRITE( EXTDMA, reg, val & 1 );9.557 - break;9.558 + MMIO_WRITE( EXTDMA, reg, val & 1 );9.559 + break;9.560 case IDEDMACTL1:9.561 case IDEDMACTL2:9.562 - MMIO_WRITE( EXTDMA, reg, val & 0x01 );9.563 - asic_ide_dma_transfer( );9.564 - break;9.565 + MMIO_WRITE( EXTDMA, reg, val & 0x01 );9.566 + asic_ide_dma_transfer( );9.567 + break;9.568 case IDEACTIVATE:9.569 - if( val == 0x001FFFFF ) {9.570 - idereg.interface_enabled = TRUE;9.571 - /* Conventional wisdom says that this is necessary but not9.572 - * sufficient to enable the IDE interface.9.573 - */9.574 - } else if( val == 0x000042FE ) {9.575 - idereg.interface_enabled = FALSE;9.576 - }9.577 - break;9.578 + if( val == 0x001FFFFF ) {9.579 + idereg.interface_enabled = TRUE;9.580 + /* Conventional wisdom says that this is necessary but not9.581 + * sufficient to enable the IDE interface.9.582 + */9.583 + } else if( val == 0x000042FE ) {9.584 + idereg.interface_enabled = FALSE;9.585 + }9.586 + break;9.587 case G2DMA0EXT: case G2DMA0SH4: case G2DMA0SIZ:9.588 case G2DMA1EXT: case G2DMA1SH4: case G2DMA1SIZ:9.589 case G2DMA2EXT: case G2DMA2SH4: case G2DMA2SIZ:9.590 case G2DMA3EXT: case G2DMA3SH4: case G2DMA3SIZ:9.591 - MMIO_WRITE( EXTDMA, reg, val & 0x9FFFFFE0 );9.592 - break;9.593 + MMIO_WRITE( EXTDMA, reg, val & 0x9FFFFFE0 );9.594 + break;9.595 case G2DMA0MOD: case G2DMA1MOD: case G2DMA2MOD: case G2DMA3MOD:9.596 - MMIO_WRITE( EXTDMA, reg, val & 0x07 );9.597 - break;9.598 + MMIO_WRITE( EXTDMA, reg, val & 0x07 );9.599 + break;9.600 case G2DMA0DIR: case G2DMA1DIR: case G2DMA2DIR: case G2DMA3DIR:9.601 - MMIO_WRITE( EXTDMA, reg, val & 0x01 );9.602 - break;9.603 + MMIO_WRITE( EXTDMA, reg, val & 0x01 );9.604 + break;9.605 case G2DMA0CTL1:9.606 case G2DMA0CTL2:9.607 - MMIO_WRITE( EXTDMA, reg, val & 1);9.608 - g2_dma_transfer( 0 );9.609 - break;9.610 + MMIO_WRITE( EXTDMA, reg, val & 1);9.611 + g2_dma_transfer( 0 );9.612 + break;9.613 case G2DMA0STOP:9.614 - MMIO_WRITE( EXTDMA, reg, val & 0x37 );9.615 - break;9.616 + MMIO_WRITE( EXTDMA, reg, val & 0x37 );9.617 + break;9.618 case G2DMA1CTL1:9.619 case G2DMA1CTL2:9.620 - MMIO_WRITE( EXTDMA, reg, val & 1);9.621 - g2_dma_transfer( 1 );9.622 - break;9.623 + MMIO_WRITE( EXTDMA, reg, val & 1);9.624 + g2_dma_transfer( 1 );9.625 + break;9.627 case G2DMA1STOP:9.628 - MMIO_WRITE( EXTDMA, reg, val & 0x37 );9.629 - break;9.630 + MMIO_WRITE( EXTDMA, reg, val & 0x37 );9.631 + break;9.632 case G2DMA2CTL1:9.633 case G2DMA2CTL2:9.634 - MMIO_WRITE( EXTDMA, reg, val &1 );9.635 - g2_dma_transfer( 2 );9.636 - break;9.637 + MMIO_WRITE( EXTDMA, reg, val &1 );9.638 + g2_dma_transfer( 2 );9.639 + break;9.640 case G2DMA2STOP:9.641 - MMIO_WRITE( EXTDMA, reg, val & 0x37 );9.642 - break;9.643 + MMIO_WRITE( EXTDMA, reg, val & 0x37 );9.644 + break;9.645 case G2DMA3CTL1:9.646 case G2DMA3CTL2:9.647 - MMIO_WRITE( EXTDMA, reg, val &1 );9.648 - g2_dma_transfer( 3 );9.649 - break;9.650 + MMIO_WRITE( EXTDMA, reg, val &1 );9.651 + g2_dma_transfer( 3 );9.652 + break;9.653 case G2DMA3STOP:9.654 - MMIO_WRITE( EXTDMA, reg, val & 0x37 );9.655 - break;9.656 + MMIO_WRITE( EXTDMA, reg, val & 0x37 );9.657 + break;9.658 case PVRDMA2CTL1:9.659 case PVRDMA2CTL2:9.660 - if( val != 0 ) {9.661 - ERROR( "Write to unimplemented DMA control register %08X", reg );9.662 - }9.663 - break;9.664 + if( val != 0 ) {9.665 + ERROR( "Write to unimplemented DMA control register %08X", reg );9.666 + }9.667 + break;9.668 default:9.669 - MMIO_WRITE( EXTDMA, reg, val );9.670 + MMIO_WRITE( EXTDMA, reg, val );9.671 }9.672 }9.674 @@ -594,13 +594,13 @@9.675 {9.676 uint32_t val;9.677 if( !idereg.interface_enabled && IS_IDE_REGISTER(reg) ) {9.678 - return 0xFFFFFFFF; /* disabled */9.679 + return 0xFFFFFFFF; /* disabled */9.680 }9.682 switch( reg ) {9.683 case IDEALTSTATUS:9.684 - val = idereg.status;9.685 - return val;9.686 + val = idereg.status;9.687 + return val;9.688 case IDEDATA: return ide_read_data_pio( );9.689 case IDEFEAT: return idereg.error;9.690 case IDECOUNT:return idereg.count;9.691 @@ -609,11 +609,11 @@9.692 case IDELBA2: return idereg.lba2;9.693 case IDEDEV: return idereg.device;9.694 case IDECMD:9.695 - val = ide_read_status();9.696 - return val;9.697 + val = ide_read_status();9.698 + return val;9.699 default:9.700 - val = MMIO_READ( EXTDMA, reg );9.701 - return val;9.702 + val = MMIO_READ( EXTDMA, reg );9.703 + return val;9.704 }9.705 }
10.1 --- a/src/bios.c Mon Jul 14 07:42:45 2008 +000010.2 +++ b/src/bios.c Mon Jul 14 07:44:42 2008 +000010.3 @@ -71,13 +71,13 @@10.4 DEBUG( "BIOS GD command %d", cmd->cmd_code );10.5 switch( cmd->cmd_code ) {10.6 case GD_CMD_INIT:10.7 - /* *shrug* */10.8 - cmd->status = GD_CMD_STATUS_DONE;10.9 - break;10.10 + /* *shrug* */10.11 + cmd->status = GD_CMD_STATUS_DONE;10.12 + break;10.13 default:10.14 - cmd->status = GD_CMD_STATUS_ERROR;10.15 - cmd->result[0] = GD_ERROR_SYSTEM;10.16 - break;10.17 + cmd->status = GD_CMD_STATUS_ERROR;10.18 + cmd->result[0] = GD_ERROR_SYSTEM;10.19 + break;10.20 }10.21 }10.23 @@ -90,12 +90,12 @@10.24 {10.25 int i;10.26 for( i=0; i<COMMAND_QUEUE_LENGTH; i++ ) {10.27 - if( gdrom_cmd_queue[i].status != GD_CMD_STATUS_ACTIVE ) {10.28 - gdrom_cmd_queue[i].status = GD_CMD_STATUS_ACTIVE;10.29 - gdrom_cmd_queue[i].cmd_code = cmd;10.30 - gdrom_cmd_queue[i].data = ptr;10.31 - return i;10.32 - }10.33 + if( gdrom_cmd_queue[i].status != GD_CMD_STATUS_ACTIVE ) {10.34 + gdrom_cmd_queue[i].status = GD_CMD_STATUS_ACTIVE;10.35 + gdrom_cmd_queue[i].cmd_code = cmd;10.36 + gdrom_cmd_queue[i].data = ptr;10.37 + return i;10.38 + }10.39 }10.40 return -1;10.41 }10.42 @@ -104,17 +104,17 @@10.43 {10.44 int i;10.45 for( i=0; i<COMMAND_QUEUE_LENGTH; i++ ) {10.46 - if( gdrom_cmd_queue[i].status == GD_CMD_STATUS_ACTIVE ) {10.47 - bios_gdrom_run_command( &gdrom_cmd_queue[i] );10.48 - }10.49 + if( gdrom_cmd_queue[i].status == GD_CMD_STATUS_ACTIVE ) {10.50 + bios_gdrom_run_command( &gdrom_cmd_queue[i] );10.51 + }10.52 }10.53 }10.55 gdrom_command_t bios_gdrom_get_command( uint32_t id )10.56 {10.57 if( id >= COMMAND_QUEUE_LENGTH ||10.58 - gdrom_cmd_queue[id].status == GD_CMD_STATUS_NONE )10.59 - return NULL;10.60 + gdrom_cmd_queue[id].status == GD_CMD_STATUS_NONE )10.61 + return NULL;10.62 return &gdrom_cmd_queue[id];10.63 }10.65 @@ -128,78 +128,78 @@10.67 switch( syscallid ) {10.68 case 0xB0: /* sysinfo */10.69 - break;10.70 + break;10.71 case 0xB4: /* Font */10.72 - break;10.73 + break;10.74 case 0xB8: /* Flash */10.75 - break;10.76 + break;10.77 case 0xBC: /* Misc/GD-Rom */10.78 - switch( sh4r.r[6] ) {10.79 - case 0: /* GD-Rom */10.80 - switch( sh4r.r[7] ) {10.81 - case 0: /* Send command */10.82 - if( sh4r.r[5] == 0 )10.83 - sh4r.r[0] = bios_gdrom_enqueue( sh4r.r[4], NULL );10.84 - else10.85 - sh4r.r[0] = bios_gdrom_enqueue( sh4r.r[4], mem_get_region(sh4r.r[5]) );10.86 - break;10.87 - case 1: /* Check command */10.88 - cmd = bios_gdrom_get_command( sh4r.r[4] );10.89 - if( cmd == NULL ) {10.90 - sh4r.r[0] = GD_CMD_STATUS_NONE;10.91 - } else {10.92 - sh4r.r[0] = cmd->status;10.93 - if( cmd->status == GD_CMD_STATUS_ERROR &&10.94 - sh4r.r[5] != 0 ) {10.95 - mem_copy_to_sh4( sh4r.r[5], (sh4ptr_t)&cmd->result, sizeof(cmd->result) );10.96 - }10.97 - }10.98 - break;10.99 - case 2: /* Mainloop */10.100 - bios_gdrom_run_queue();10.101 - break;10.102 - case 3: /* Init */10.103 - bios_gdrom_init();10.104 - break;10.105 - case 4: /* Drive status */10.106 - if( sh4r.r[4] != 0 ) {10.107 - mem_copy_to_sh4( sh4r.r[4], (sh4ptr_t)&bios_gdrom_status,10.108 - sizeof(bios_gdrom_status) );10.109 - }10.110 - sh4r.r[0] = 0;10.111 - break;10.112 - case 8: /* Abort command */10.113 - cmd = bios_gdrom_get_command( sh4r.r[4] );10.114 - if( cmd == NULL || cmd->status != GD_CMD_STATUS_ACTIVE ) {10.115 - sh4r.r[0] = -1;10.116 - } else {10.117 - cmd->status = GD_CMD_STATUS_ABORT;10.118 - sh4r.r[0] = 0;10.119 - }10.120 - break;10.121 - case 9: /* Reset */10.122 - break;10.123 - case 10: /* Set mode */10.124 - sh4r.r[0] = 0;10.125 - break;10.126 - }10.127 - break;10.128 - case -1: /* Misc */10.129 - break;10.130 - default: /* ??? */10.131 - break;10.132 - }10.133 - break;10.134 - case 0xE0: /* Menu */10.135 - switch( sh4r.r[7] ) {10.136 - case 0:10.137 - WARN( "Entering main program" );10.138 - break;10.139 - case 1:10.140 - WARN( "Program aborted to DC menu");10.141 - dreamcast_stop();10.142 - break;10.143 - }10.144 + switch( sh4r.r[6] ) {10.145 + case 0: /* GD-Rom */10.146 + switch( sh4r.r[7] ) {10.147 + case 0: /* Send command */10.148 + if( sh4r.r[5] == 0 )10.149 + sh4r.r[0] = bios_gdrom_enqueue( sh4r.r[4], NULL );10.150 + else10.151 + sh4r.r[0] = bios_gdrom_enqueue( sh4r.r[4], mem_get_region(sh4r.r[5]) );10.152 + break;10.153 + case 1: /* Check command */10.154 + cmd = bios_gdrom_get_command( sh4r.r[4] );10.155 + if( cmd == NULL ) {10.156 + sh4r.r[0] = GD_CMD_STATUS_NONE;10.157 + } else {10.158 + sh4r.r[0] = cmd->status;10.159 + if( cmd->status == GD_CMD_STATUS_ERROR &&10.160 + sh4r.r[5] != 0 ) {10.161 + mem_copy_to_sh4( sh4r.r[5], (sh4ptr_t)&cmd->result, sizeof(cmd->result) );10.162 + }10.163 + }10.164 + break;10.165 + case 2: /* Mainloop */10.166 + bios_gdrom_run_queue();10.167 + break;10.168 + case 3: /* Init */10.169 + bios_gdrom_init();10.170 + break;10.171 + case 4: /* Drive status */10.172 + if( sh4r.r[4] != 0 ) {10.173 + mem_copy_to_sh4( sh4r.r[4], (sh4ptr_t)&bios_gdrom_status,10.174 + sizeof(bios_gdrom_status) );10.175 + }10.176 + sh4r.r[0] = 0;10.177 + break;10.178 + case 8: /* Abort command */10.179 + cmd = bios_gdrom_get_command( sh4r.r[4] );10.180 + if( cmd == NULL || cmd->status != GD_CMD_STATUS_ACTIVE ) {10.181 + sh4r.r[0] = -1;10.182 + } else {10.183 + cmd->status = GD_CMD_STATUS_ABORT;10.184 + sh4r.r[0] = 0;10.185 + }10.186 + break;10.187 + case 9: /* Reset */10.188 + break;10.189 + case 10: /* Set mode */10.190 + sh4r.r[0] = 0;10.191 + break;10.192 + }10.193 + break;10.194 + case -1: /* Misc */10.195 + break;10.196 + default: /* ??? */10.197 + break;10.198 + }10.199 + break;10.200 + case 0xE0: /* Menu */10.201 + switch( sh4r.r[7] ) {10.202 + case 0:10.203 + WARN( "Entering main program" );10.204 + break;10.205 + case 1:10.206 + WARN( "Program aborted to DC menu");10.207 + dreamcast_stop();10.208 + break;10.209 + }10.210 }10.211 }
11.1 --- a/src/bootstrap.c Mon Jul 14 07:42:45 2008 +000011.2 +++ b/src/bootstrap.c Mon Jul 14 07:44:42 2008 +000011.3 @@ -58,20 +58,20 @@11.6 static char *dc_peripherals[] = { "Uses WinCE", "Unknown (0x0000002)",11.7 - "Unknown (0x0000004)", "Unknown (0x0000008)",11.8 - "VGA Box", "Unknown (0x0000020)",11.9 - "Unknown (0x0000040)", "Unknown (0x0000080)",11.10 - "Other Expansions", "Puru Puru pack",11.11 - "Mike", "Memory card",11.12 - "Basic controller", "C button",11.13 - "D button", "X button",11.14 - "Y button", "Z button",11.15 - "Expanded direction buttons",11.16 - "Analog R trigger", "Analog L trigger",11.17 - "Analog horizontal", "Analog vertical",11.18 - "Expanded analog horizontal",11.19 - "Expanded analog vertical",11.20 - "Gun", "Keyboard", "Mouse" };11.21 + "Unknown (0x0000004)", "Unknown (0x0000008)",11.22 + "VGA Box", "Unknown (0x0000020)",11.23 + "Unknown (0x0000040)", "Unknown (0x0000080)",11.24 + "Other Expansions", "Puru Puru pack",11.25 + "Mike", "Memory card",11.26 + "Basic controller", "C button",11.27 + "D button", "X button",11.28 + "Y button", "Z button",11.29 + "Expanded direction buttons",11.30 + "Analog R trigger", "Analog L trigger",11.31 + "Analog horizontal", "Analog vertical",11.32 + "Expanded analog horizontal",11.33 + "Expanded analog vertical",11.34 + "Gun", "Keyboard", "Mouse" };11.37 /* Expansion units */11.38 @@ -128,30 +128,30 @@11.39 INFO( " Product ID: %-10.10s Product Ver: %-6.6s Date: %-8.8s",11.40 head->product_id, head->product_ver, head->product_date );11.41 if( detail ) {11.42 - INFO( " Header CRC: %04X (Computed %04X)", hcrc, crc );11.43 - INFO( " Boot File: %-16.16s", head->boot_file );11.44 - INFO( " Disc ID: %-11.11s Regions: %-8.8s Peripherals: %07X",11.45 - head->gdrom_id, head->regions, periph );11.46 - strcpy( buf, " Supports: " );11.47 - got = 0;11.48 - for( i=0; i<28; i++ ) {11.49 - if( periph & (1<<i) ){11.50 - if( got ) strcat( buf, ", " );11.51 - strcat( buf, dc_peripherals[i] );11.52 - got = 1;11.53 - }11.54 - if( i == 11 ) i = 23; /* Skip 8-23 */11.55 - }11.56 - INFO( buf, NULL );11.57 - strcpy( buf, " Requires: " );11.58 - got = 0;11.59 - for( i=12; i<24; i++ ) {11.60 - if( periph & (1<<i) ) {11.61 - if( got ) strcat( buf, ", " );11.62 - strcat( buf, dc_peripherals[i] );11.63 - got = 1;11.64 - }11.65 - }11.66 - INFO( buf, NULL );11.67 + INFO( " Header CRC: %04X (Computed %04X)", hcrc, crc );11.68 + INFO( " Boot File: %-16.16s", head->boot_file );11.69 + INFO( " Disc ID: %-11.11s Regions: %-8.8s Peripherals: %07X",11.70 + head->gdrom_id, head->regions, periph );11.71 + strcpy( buf, " Supports: " );11.72 + got = 0;11.73 + for( i=0; i<28; i++ ) {11.74 + if( periph & (1<<i) ){11.75 + if( got ) strcat( buf, ", " );11.76 + strcat( buf, dc_peripherals[i] );11.77 + got = 1;11.78 + }11.79 + if( i == 11 ) i = 23; /* Skip 8-23 */11.80 + }11.81 + INFO( buf, NULL );11.82 + strcpy( buf, " Requires: " );11.83 + got = 0;11.84 + for( i=12; i<24; i++ ) {11.85 + if( periph & (1<<i) ) {11.86 + if( got ) strcat( buf, ", " );11.87 + strcat( buf, dc_peripherals[i] );11.88 + got = 1;11.89 + }11.90 + }11.91 + INFO( buf, NULL );11.92 }11.93 }
12.1 --- a/src/bootstrap.h Mon Jul 14 07:42:45 2008 +000012.2 +++ b/src/bootstrap.h Mon Jul 14 07:44:42 2008 +000012.3 @@ -19,15 +19,15 @@12.4 /*12.5 * IP.BIN related code. Ref: http://mc.pp.se/dc/ip0000.bin.html12.6 */12.7 -#ifndef dream_bootstrap_H12.8 -#define dream_bootstrap_H 112.9 +#ifndef lxdream_bootstrap_H12.10 +#define lxdream_bootstrap_H 112.11 +12.12 +#include "lxdream.h"12.14 #ifdef __cplusplus12.15 extern "C" {12.16 #endif12.18 -#include "dream.h"12.19 -12.20 /**12.21 * Dump the bootstrap info to the output log for infomational/debugging12.22 * purposes.12.23 @@ -37,4 +37,5 @@12.24 #ifdef __cplusplus12.25 }12.26 #endif12.27 -#endif /* !dream_bootstrap_H */12.28 +12.29 +#endif /* !lxdream_bootstrap_H */
13.1 --- a/src/clock.h Mon Jul 14 07:42:45 2008 +000013.2 +++ b/src/clock.h Mon Jul 14 07:44:42 2008 +000013.3 @@ -1,5 +1,6 @@13.4 /**13.5 * $Id$13.6 + *13.7 * External interface to the dreamcast serial port, implemented by13.8 * sh4/scif.c13.9 *13.10 @@ -15,8 +16,9 @@13.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13.12 * GNU General Public License for more details.13.13 */13.14 -#ifndef dream_clock_H13.15 -#define dream_clock_H 113.16 +13.17 +#ifndef lxdream_clock_H13.18 +#define lxdream_clock_H 113.20 #include <stdint.h>
14.1 --- a/src/cocoaui/cocoa_gd.c Mon Jul 14 07:42:45 2008 +000014.2 +++ b/src/cocoaui/cocoa_gd.c Mon Jul 14 07:44:42 2008 +000014.3 @@ -37,21 +37,21 @@14.4 [menu addItem: [NSMenuItem separatorItem]];14.5 } else {14.6 [[menu addItemWithTitle: [NSString stringWithCString: entry]14.7 - action: @selector(gdrom_list_action:) keyEquivalent: @""]14.8 - setTag: i];14.9 + action: @selector(gdrom_list_action:) keyEquivalent: @""]14.10 + setTag: i];14.11 }14.12 }14.13 [menu addItem: [NSMenuItem separatorItem]];14.14 [menu addItemWithTitle: NS_("Open image file...") action: @selector(mount_action:)14.15 - keyEquivalent: @"i"];14.16 + keyEquivalent: @"i"];14.17 }14.18 -14.19 +14.20 void cocoa_gdrom_menu_rebuild( NSMenu *menu )14.21 {14.22 while( [menu numberOfItems] > 0 ) {14.23 [ menu removeItemAtIndex: 0 ];14.24 }14.25 -14.26 +14.27 cocoa_gdrom_menu_build( menu );14.28 }14.30 @@ -61,11 +61,11 @@14.31 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];14.32 NSMenu *menu = (NSMenu *)user_data;14.33 int i;14.34 -14.35 +14.36 if( list_changed ) {14.37 cocoa_gdrom_menu_rebuild(menu);14.38 }14.39 -14.40 +14.41 for( i=0; i< [menu numberOfItems]; i++ ) {14.42 if( i == selection ) {14.43 [[menu itemAtIndex: i] setState: NSOnState];14.44 @@ -80,7 +80,7 @@14.45 {14.46 NSMenu *menu = [[NSMenu alloc] initWithTitle: @"GD-Rom Settings"];14.47 cocoa_gdrom_menu_build(menu);14.48 -14.49 +14.50 register_gdrom_list_change_hook(cocoa_gdrom_menu_update, menu);14.51 cocoa_gdrom_menu_update( FALSE, gdrom_list_get_selection(), menu );14.52 return menu;
15.1 --- a/src/cocoaui/cocoa_prefs.c Mon Jul 14 07:42:45 2008 +000015.2 +++ b/src/cocoaui/cocoa_prefs.c Mon Jul 14 07:44:42 2008 +000015.3 @@ -26,7 +26,8 @@15.4 NSDictionary *items;15.5 }15.6 - (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label15.7 - tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action;15.8 + tooltip: (NSString *)tooltip icon: (NSString *)icon15.9 + action: (SEL) action;15.10 @end15.12 @implementation LxdreamPrefsToolbarDelegate15.13 @@ -46,7 +47,7 @@15.14 }15.16 - (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label15.17 - tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action15.18 +tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action15.19 {15.20 NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier: id];15.21 [item setLabel: label];15.22 @@ -75,9 +76,9 @@15.23 }15.25 - (NSToolbarItem *) toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier15.26 - willBeInsertedIntoToolbar:(BOOL)flag15.27 +willBeInsertedIntoToolbar:(BOOL)flag15.28 {15.29 - return [items objectForKey: itemIdentifier];15.30 + return [items objectForKey: itemIdentifier];15.31 }15.32 - (void)paths_action: (id)sender15.33 {15.34 @@ -102,10 +103,10 @@15.35 - (id)initWithContentRect:(NSRect)contentRect15.36 {15.37 if( [super initWithContentRect: contentRect15.38 - styleMask: ( NSTitledWindowMask | NSClosableWindowMask |15.39 - NSMiniaturizableWindowMask | NSResizableWindowMask |15.40 - NSUnifiedTitleAndToolbarWindowMask )15.41 - backing: NSBackingStoreBuffered defer: NO ] == nil ) {15.42 + styleMask: ( NSTitledWindowMask | NSClosableWindowMask |15.43 + NSMiniaturizableWindowMask | NSResizableWindowMask |15.44 + NSUnifiedTitleAndToolbarWindowMask )15.45 + backing: NSBackingStoreBuffered defer: NO ] == nil ) {15.46 return nil;15.47 } else {15.48 [self setTitle: NS_("Preferences")];
16.1 --- a/src/cocoaui/cocoa_win.c Mon Jul 14 07:42:45 2008 +000016.2 +++ b/src/cocoaui/cocoa_win.c Mon Jul 14 07:44:42 2008 +000016.3 @@ -29,7 +29,8 @@16.4 NSDictionary *items;16.5 }16.6 - (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label16.7 - tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action;16.8 + tooltip: (NSString *)tooltip16.9 + icon: (NSString *)icon action: (SEL) action;16.10 @end16.12 @implementation LxdreamToolbarDelegate16.13 @@ -45,27 +46,27 @@16.14 tooltip: @"Pause dreamcast" icon: @"tb-pause"16.15 action: @selector(pause_action:)];16.16 NSToolbarItem *run = [self createToolbarItem: @"Run" label: @"Resume"16.17 - tooltip: @"Resume" icon: @"tb-run"16.18 - action: @selector(run_action:)];16.19 + tooltip: @"Resume" icon: @"tb-run"16.20 + action: @selector(run_action:)];16.21 NSToolbarItem *load = [self createToolbarItem: @"LoadState" label: @"Load State..."16.22 - tooltip: @"Load an lxdream save state" icon: @"tb-load"16.23 - action: @selector(load_action:)];16.24 + tooltip: @"Load an lxdream save state" icon: @"tb-load"16.25 + action: @selector(load_action:)];16.26 NSToolbarItem *save = [self createToolbarItem: @"SaveState" label: @"Save State..."16.27 - tooltip: @"Create an lxdream save state" icon: @"tb-save"16.28 - action: @selector(save_action:)];16.29 + tooltip: @"Create an lxdream save state" icon: @"tb-save"16.30 + action: @selector(save_action:)];16.31 [pause setEnabled: NO];16.32 identifiers =16.33 [NSArray arrayWithObjects: @"GdromMount", @"Reset", @"Pause", @"Run", @"LoadState", @"SaveState", nil ];16.34 defaults =16.35 [NSArray arrayWithObjects: @"GdromMount", @"Reset", @"Pause", @"Run",16.36 - NSToolbarSeparatorItemIdentifier, @"LoadState", @"SaveState", nil ];16.37 + NSToolbarSeparatorItemIdentifier, @"LoadState", @"SaveState", nil ];16.38 NSArray *values = [NSArray arrayWithObjects: mount, reset, pause, run, load, save, nil ];16.39 items = [NSDictionary dictionaryWithObjects: values forKeys: identifiers];16.40 return self;16.41 }16.43 - (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label16.44 - tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action16.45 +tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action16.46 {16.47 NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier: id];16.48 [item setLabel: label];16.49 @@ -94,9 +95,9 @@16.50 }16.52 - (NSToolbarItem *) toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier16.53 - willBeInsertedIntoToolbar:(BOOL)flag16.54 +willBeInsertedIntoToolbar:(BOOL)flag16.55 {16.56 - return [items objectForKey: itemIdentifier];16.57 + return [items objectForKey: itemIdentifier];16.58 }16.59 @end16.61 @@ -106,16 +107,16 @@16.62 NSRect contentRect = NSMakeRect(videoRect.origin.x,videoRect.origin.y,16.63 videoRect.size.width,videoRect.size.height+STATUSBAR_HEIGHT);16.64 if( [super initWithContentRect: contentRect16.65 - styleMask: ( NSTitledWindowMask | NSClosableWindowMask |16.66 - NSMiniaturizableWindowMask | NSResizableWindowMask |16.67 - NSUnifiedTitleAndToolbarWindowMask )16.68 - backing: NSBackingStoreBuffered defer: NO ] == nil ) {16.69 + styleMask: ( NSTitledWindowMask | NSClosableWindowMask |16.70 + NSMiniaturizableWindowMask | NSResizableWindowMask |16.71 + NSUnifiedTitleAndToolbarWindowMask )16.72 + backing: NSBackingStoreBuffered defer: NO ] == nil ) {16.73 return nil;16.74 } else {16.75 isGrabbed = NO;16.76 video = video_osx_create_drawable();16.77 [video setFrameOrigin: NSMakePoint(0.0,STATUSBAR_HEIGHT)];16.78 -16.79 +16.80 status =16.81 [[NSTextField alloc] initWithFrame: NSMakeRect(0.0,0.0,videoRect.size.width,STATUS_TEXT_HEIGHT)];16.82 [status setStringValue: @"Idle"];16.83 @@ -185,7 +186,7 @@16.85 NSWindow *cocoa_gui_create_main_window()16.86 {16.87 - NSRect contentRect = {{0,0},{640,480}};16.88 - NSWindow *main_win = [[LxdreamMainWindow alloc] initWithContentRect: contentRect];16.89 - return main_win;16.90 + NSRect contentRect = {{0,0},{640,480}};16.91 + NSWindow *main_win = [[LxdreamMainWindow alloc] initWithContentRect: contentRect];16.92 + return main_win;16.93 }
17.1 --- a/src/cocoaui/cocoaui.c Mon Jul 14 07:42:45 2008 +000017.2 +++ b/src/cocoaui/cocoaui.c Mon Jul 14 07:44:42 2008 +000017.3 @@ -36,11 +36,11 @@17.4 uint32_t cocoa_gui_run_slice( uint32_t nanosecs );17.6 struct dreamcast_module cocoa_gui_module = { "gui", NULL,17.7 - cocoa_gui_update,17.8 - cocoa_gui_start,17.9 - cocoa_gui_run_slice,17.10 - cocoa_gui_stop,17.11 - NULL, NULL };17.12 + cocoa_gui_update,17.13 + cocoa_gui_start,17.14 + cocoa_gui_run_slice,17.15 + cocoa_gui_stop,17.16 + NULL, NULL };17.18 /**17.19 * Count of running nanoseconds - used to cut back on the GUI runtime17.20 @@ -61,17 +61,17 @@17.21 NSMenuItem *menuItem;17.22 NSString *title;17.23 NSString *appName;17.24 -17.25 +17.26 appName = @"Lxdream";17.27 appleMenu = [[NSMenu alloc] initWithTitle:@""];17.29 /* Add menu items */17.30 title = [@"About " stringByAppendingString:appName];17.31 [appleMenu addItemWithTitle:title action:@selector(about_action:) keyEquivalent:@""];17.32 -17.33 -// [appleMenu addItem:[NSMenuItem separatorItem]];17.34 -// [appleMenu addItemWithTitle: NS_("Preferences...") action:@selector(preferences_action:) keyEquivalent:@","];17.35 -17.36 +17.37 + // [appleMenu addItem:[NSMenuItem separatorItem]];17.38 + // [appleMenu addItemWithTitle: NS_("Preferences...") action:@selector(preferences_action:) keyEquivalent:@","];17.39 +17.40 // Services Menu17.41 [appleMenu addItem:[NSMenuItem separatorItem]];17.42 services = [[[NSMenu alloc] init] autorelease];17.43 @@ -84,8 +84,8 @@17.45 // Hide Others17.46 menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others"17.47 - action:@selector(hideOtherApplications:)17.48 - keyEquivalent:@"h"];17.49 + action:@selector(hideOtherApplications:)17.50 + keyEquivalent:@"h"];17.51 [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];17.53 // Show All17.54 @@ -101,9 +101,9 @@17.55 [menuItem setSubmenu: appleMenu];17.56 NSMenu *menu = [NSMenu new];17.57 [menu addItem: menuItem];17.58 -17.59 +17.60 NSMenu *gdromMenu = cocoa_gdrom_menu_new();17.61 -17.62 +17.63 NSMenu *fileMenu = [[NSMenu alloc] initWithTitle: NS_("File")];17.64 [fileMenu addItemWithTitle: NS_("Load Binary") action: @selector(load_binary_action:) keyEquivalent: @"b"];17.65 [[fileMenu addItemWithTitle: NS_("GD-Rom") action: nil keyEquivalent: @""]17.66 @@ -116,11 +116,11 @@17.67 [fileMenu addItem: [NSMenuItem separatorItem]];17.68 [fileMenu addItemWithTitle: NS_("Load State") action: @selector(load_action:) keyEquivalent: @"o"];17.69 [fileMenu addItemWithTitle: NS_("Save State") action: @selector(save_action:) keyEquivalent: @"s"];17.70 -17.71 +17.72 menuItem = [[NSMenuItem alloc] initWithTitle:NS_("File") action: nil keyEquivalent: @""];17.73 [menuItem setSubmenu: fileMenu];17.74 [menu addItem: menuItem];17.75 -17.76 +17.77 /* Tell the application object that this is now the application menu */17.78 [NSApp setMainMenu: menu];17.79 [NSApp setAppleMenu: appleMenu];17.80 @@ -235,9 +235,9 @@17.81 gboolean gui_parse_cmdline( int *argc, char **argv[] )17.82 {17.83 /* If started from the finder, the first (and only) arg will look something like17.84 - * -psn_0_... - we want to remove this so that lxdream doesn't try to process it17.85 - * normally17.86 - */17.87 + * -psn_0_... - we want to remove this so that lxdream doesn't try to process it17.88 + * normally17.89 + */17.90 if( *argc == 2 && strncmp((*argv)[1], "-psn_", 5) == 0 ) {17.91 *argc = 1;17.92 }17.93 @@ -247,10 +247,10 @@17.94 gboolean gui_init( gboolean withDebug )17.95 {17.96 dreamcast_register_module( &cocoa_gui_module );17.97 -17.98 +17.99 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];17.100 [NSApplication sharedApplication];17.101 -17.102 +17.103 LxdreamDelegate *delegate = [[LxdreamDelegate alloc] init];17.104 [NSApp setDelegate: delegate];17.105 NSString *iconFile = [[NSBundle mainBundle] pathForResource:@"dcemu" ofType:@"gif"];17.106 @@ -261,7 +261,7 @@17.107 NSWindow *window = cocoa_gui_create_main_window();17.108 [window makeKeyAndOrderFront: nil];17.109 [NSApp activateIgnoringOtherApps: YES];17.110 -17.111 +17.112 [pool release];17.113 }17.115 @@ -271,8 +271,8 @@17.116 cocoa_gui_autorun = YES;17.117 }17.118 cocoa_gui_is_running = YES;17.119 - [NSApp run];17.120 - cocoa_gui_is_running = NO;17.121 + [NSApp run];17.122 + cocoa_gui_is_running = NO;17.123 }17.125 void gui_update_state(void)17.126 @@ -352,7 +352,7 @@17.128 void cocoa_gui_update( void )17.129 {17.130 -17.131 +17.132 }17.134 void cocoa_gui_start( void )17.135 @@ -375,8 +375,8 @@17.136 void cocoa_gui_run_later( void )17.137 {17.138 [[NSRunLoop currentRunLoop] performSelector: @selector(run_immediate)17.139 - target: [NSApp delegate] argument: nil order: 117.140 - modes: [NSArray arrayWithObject: NSDefaultRunLoopMode] ];17.141 + target: [NSApp delegate] argument: nil order: 117.142 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode] ];17.143 }17.145 NSImage *NSImage_new_from_framebuffer( frame_buffer_t buffer )17.146 @@ -384,11 +384,11 @@17.147 NSBitmapImageRep *rep =17.148 [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: &buffer->data17.149 pixelsWide: buffer->width pixelsHigh: buffer->height17.150 - bitsPerSample: 8 samplesPerPixel: 317.151 - hasAlpha: NO isPlanar: NO17.152 - colorSpaceName: NSDeviceRGBColorSpace bitmapFormat: 017.153 - bytesPerRow: buffer->rowstride bitsPerPixel: 24];17.154 -17.155 + bitsPerSample: 8 samplesPerPixel: 317.156 + hasAlpha: NO isPlanar: NO17.157 + colorSpaceName: NSDeviceRGBColorSpace bitmapFormat: 017.158 + bytesPerRow: buffer->rowstride bitsPerPixel: 24];17.159 +17.160 NSImage *image = [[NSImage alloc] initWithSize: NSMakeSize(0.0,0.0)];17.161 [image addRepresentation: rep];17.162 return image;
18.1 --- a/src/cocoaui/cocoaui.h Mon Jul 14 07:42:45 2008 +000018.2 +++ b/src/cocoaui/cocoaui.h Mon Jul 14 07:44:42 2008 +000018.3 @@ -16,12 +16,16 @@18.4 * GNU General Public License for more details.18.5 */18.7 +#ifndef lxdream_cocoaui_H18.8 +#define lxdream_cocoaui_H18.9 +18.10 #import <AppKit/AppKit.h>18.11 #include <glib/gi18n.h>18.13 -#ifndef lxdream_cocoaui_H18.14 -#define lxdream_cocoaui_H18.15 -18.16 +#ifdef __cplusplus18.17 +extern "C" {18.18 +#endif18.19 +18.20 #define NS_(x) [NSString stringWithUTF8String: _(x)]18.22 NSWindow *cocoa_gui_create_main_window();18.23 @@ -47,4 +51,8 @@18.24 - (id)initWithContentRect:(NSRect)contentRect;18.25 @end18.27 +#ifdef __cplusplus18.28 +}18.29 +#endif18.30 +18.31 #endif /* lxdream_cocoaui_H */18.32 \ No newline at end of file
19.1 --- a/src/config.c Mon Jul 14 07:42:45 2008 +000019.2 +++ b/src/config.c Mon Jul 14 07:44:42 2008 +000019.3 @@ -36,27 +36,27 @@19.4 gboolean lxdream_save_config_stream( FILE *f );19.6 static struct lxdream_config_entry global_config[] =19.7 - {{ "bios", N_("Bios ROM"), CONFIG_TYPE_FILE, "dcboot.rom" },19.8 - { "flash", N_("Flash ROM"), CONFIG_TYPE_FILE, "dcflash.rom" },19.9 - { "default path", N_("Default disc path"), CONFIG_TYPE_PATH, "." },19.10 - { "save path", N_("Save-state path"), CONFIG_TYPE_PATH, "save" },19.11 - { "bootstrap", N_("Bootstrap IP.BIN"), CONFIG_TYPE_FILE, "IP.BIN" },19.12 - { "gdrom", NULL, CONFIG_TYPE_FILE, NULL },19.13 - { "recent", NULL, CONFIG_TYPE_FILE, NULL },19.14 - { NULL, CONFIG_TYPE_NONE }};19.15 + {{ "bios", N_("Bios ROM"), CONFIG_TYPE_FILE, "dcboot.rom" },19.16 + { "flash", N_("Flash ROM"), CONFIG_TYPE_FILE, "dcflash.rom" },19.17 + { "default path", N_("Default disc path"), CONFIG_TYPE_PATH, "." },19.18 + { "save path", N_("Save-state path"), CONFIG_TYPE_PATH, "save" },19.19 + { "bootstrap", N_("Bootstrap IP.BIN"), CONFIG_TYPE_FILE, "IP.BIN" },19.20 + { "gdrom", NULL, CONFIG_TYPE_FILE, NULL },19.21 + { "recent", NULL, CONFIG_TYPE_FILE, NULL },19.22 + { NULL, CONFIG_TYPE_NONE }};19.24 static struct lxdream_config_entry serial_config[] =19.25 - {{ "device", N_("Serial device"), CONFIG_TYPE_FILE, "/dev/ttyS1" },19.26 - { NULL, CONFIG_TYPE_NONE }};19.27 + {{ "device", N_("Serial device"), CONFIG_TYPE_FILE, "/dev/ttyS1" },19.28 + { NULL, CONFIG_TYPE_NONE }};19.30 struct lxdream_config_group lxdream_config_root[] =19.31 - {{ "global", global_config },19.32 - { "controllers", NULL },19.33 - { "serial", serial_config },19.34 + {{ "global", global_config },19.35 + { "controllers", NULL },19.36 + { "serial", serial_config },19.37 #ifdef HAVE_ALSA19.38 - { "alsa", alsa_config },19.39 + { "alsa", alsa_config },19.40 #endif19.41 - { NULL, CONFIG_TYPE_NONE }};19.42 + { NULL, CONFIG_TYPE_NONE }};19.44 static gchar *lxdream_config_load_filename = NULL;19.45 static gchar *lxdream_config_save_filename = NULL;19.46 @@ -66,19 +66,19 @@19.47 gboolean result = TRUE;19.48 char *home = getenv("HOME");19.49 if( lxdream_config_save_filename == NULL ) {19.50 - lxdream_config_save_filename = g_strdup_printf("%s/.%s", home, DEFAULT_CONFIG_FILENAME);19.51 + lxdream_config_save_filename = g_strdup_printf("%s/.%s", home, DEFAULT_CONFIG_FILENAME);19.52 }19.53 if( lxdream_config_load_filename == NULL ) {19.54 - if( access(lxdream_config_save_filename, R_OK) == 0 ) {19.55 - lxdream_config_load_filename = g_strdup(lxdream_config_save_filename);19.56 - } else if( access( PACKAGE_CONF_DIR "/" DEFAULT_CONFIG_FILENAME, R_OK ) == 0 ) {19.57 - lxdream_config_load_filename = g_strdup(PACKAGE_CONF_DIR "/" DEFAULT_CONFIG_FILENAME);19.58 - } else if( access( "./" DEFAULT_CONFIG_FILENAME, R_OK ) == 0 ) {19.59 - lxdream_config_load_filename = g_strdup("./" DEFAULT_CONFIG_FILENAME);19.60 - } else {19.61 - lxdream_config_load_filename = g_strdup(lxdream_config_save_filename);19.62 - result = FALSE;19.63 - }19.64 + if( access(lxdream_config_save_filename, R_OK) == 0 ) {19.65 + lxdream_config_load_filename = g_strdup(lxdream_config_save_filename);19.66 + } else if( access( PACKAGE_CONF_DIR "/" DEFAULT_CONFIG_FILENAME, R_OK ) == 0 ) {19.67 + lxdream_config_load_filename = g_strdup(PACKAGE_CONF_DIR "/" DEFAULT_CONFIG_FILENAME);19.68 + } else if( access( "./" DEFAULT_CONFIG_FILENAME, R_OK ) == 0 ) {19.69 + lxdream_config_load_filename = g_strdup("./" DEFAULT_CONFIG_FILENAME);19.70 + } else {19.71 + lxdream_config_load_filename = g_strdup(lxdream_config_save_filename);19.72 + result = FALSE;19.73 + }19.74 }19.75 return result;19.76 }19.77 @@ -86,11 +86,11 @@19.78 void lxdream_set_config_filename( const gchar *filename )19.79 {19.80 if( lxdream_config_load_filename != NULL ) {19.81 - g_free(lxdream_config_load_filename);19.82 + g_free(lxdream_config_load_filename);19.83 }19.84 lxdream_config_load_filename = g_strdup(filename);19.85 if( lxdream_config_save_filename != NULL ) {19.86 - g_free(lxdream_config_save_filename);19.87 + g_free(lxdream_config_save_filename);19.88 }19.89 lxdream_config_save_filename = g_strdup(filename);19.90 }19.91 @@ -99,18 +99,18 @@19.92 {19.93 struct lxdream_config_group *group = lxdream_config_root;19.94 while( group->key != NULL ) {19.95 - struct lxdream_config_entry *param = group->params;19.96 - if( param != NULL ) {19.97 - while( param->key != NULL ) {19.98 - if( param->value != param->default_value ) {19.99 - if( param->value != NULL )19.100 - free( param->value );19.101 - param->value = (gchar *)param->default_value;19.102 - }19.103 - param++;19.104 - }19.105 - }19.106 - group++;19.107 + struct lxdream_config_entry *param = group->params;19.108 + if( param != NULL ) {19.109 + while( param->key != NULL ) {19.110 + if( param->value != param->default_value ) {19.111 + if( param->value != NULL )19.112 + free( param->value );19.113 + param->value = (gchar *)param->default_value;19.114 + }19.115 + param++;19.116 + }19.117 + }19.118 + group++;19.119 }19.120 maple_detach_all();19.121 }19.122 @@ -123,10 +123,10 @@19.123 void lxdream_set_config_value( lxdream_config_entry_t param, const gchar *value )19.124 {19.125 if( param->value != value ) {19.126 - if( param->value != param->default_value && param->value != NULL ) {19.127 - free( param->value );19.128 - }19.129 - param->value = g_strdup(value);19.130 + if( param->value != param->default_value && param->value != NULL ) {19.131 + free( param->value );19.132 + }19.133 + param->value = g_strdup(value);19.134 }19.135 }19.137 @@ -144,10 +144,10 @@19.138 {19.139 int i;19.140 for( i=0; group->params[i].key != NULL; i++ ) {19.141 - if( strcasecmp( group->params[i].key, key ) == 0 ) {19.142 - lxdream_set_config_value( &group->params[i], value );19.143 - return TRUE;19.144 - }19.145 + if( strcasecmp( group->params[i].key, key ) == 0 ) {19.146 + lxdream_set_config_value( &group->params[i], value );19.147 + return TRUE;19.148 + }19.149 }19.150 return FALSE;19.151 }19.152 @@ -156,14 +156,14 @@19.153 {19.154 int i;19.155 for( i=0; src[i].key != NULL; i++ ) {19.156 - lxdream_set_config_value( &dest[i], src[i].value );19.157 + lxdream_set_config_value( &dest[i], src[i].value );19.158 }19.159 }19.161 gboolean lxdream_load_config( )19.162 {19.163 if( lxdream_config_load_filename == NULL ) {19.164 - lxdream_find_config();19.165 + lxdream_find_config();19.166 }19.167 return lxdream_load_config_file(lxdream_config_load_filename);19.168 }19.169 @@ -171,7 +171,7 @@19.170 gboolean lxdream_save_config( )19.171 {19.172 if( lxdream_config_save_filename == NULL ) {19.173 - lxdream_find_config();19.174 + lxdream_find_config();19.175 }19.176 return lxdream_save_config_file(lxdream_config_save_filename);19.177 }19.178 @@ -182,16 +182,16 @@19.179 gboolean result;19.181 if( access(filename, F_OK) != 0 ) {19.182 - INFO( "Configuration file '%s' does not exist, creating from defaults" );19.183 - lxdream_set_default_config();19.184 - lxdream_save_config();19.185 + INFO( "Configuration file '%s' does not exist, creating from defaults" );19.186 + lxdream_set_default_config();19.187 + lxdream_save_config();19.188 }19.190 f = fopen(filename, "ro");19.191 if( f == NULL ) {19.192 - ERROR( "Unable to open configuration file '%s': %s", filename, strerror(errno) );19.193 - lxdream_set_default_config();19.194 - return FALSE;19.195 + ERROR( "Unable to open configuration file '%s': %s", filename, strerror(errno) );19.196 + lxdream_set_default_config();19.197 + return FALSE;19.198 }19.200 result = lxdream_load_config_stream( f );19.201 @@ -210,77 +210,77 @@19.202 lxdream_set_default_config();19.204 while( fgets( buf, sizeof(buf), f ) != NULL ) {19.205 - g_strstrip(buf);19.206 - if( buf[0] == '#' )19.207 - continue;19.208 - if( *buf == '[' ) {19.209 - char *p = strchr(buf, ']');19.210 - if( p != NULL ) {19.211 - struct lxdream_config_group *tmp_group;19.212 - maple_device = maple_subdevice = -1;19.213 - *p = '\0';19.214 - g_strstrip(buf+1);19.215 - tmp_group = &lxdream_config_root[0];19.216 - while( tmp_group->key != NULL ) {19.217 - if( strcasecmp(tmp_group->key, buf+1) == 0 ) {19.218 - group = tmp_group;19.219 - break;19.220 - }19.221 - tmp_group++;19.222 - }19.223 - }19.224 - } else if( group != NULL ) {19.225 - char *value = strchr( buf, '=' );19.226 - if( value != NULL ) {19.227 - struct lxdream_config_entry *param = group->params;19.228 - *value = '\0';19.229 - value++;19.230 - g_strstrip(buf);19.231 - g_strstrip(value);19.232 - if( strcmp(group->key,"controllers") == 0 ) {19.233 - if( g_strncasecmp( buf, "device ", 7 ) == 0 ) {19.234 - maple_device = strtoul( buf+7, NULL, 0 );19.235 - if( maple_device < 0 || maple_device > 3 ) {19.236 - ERROR( "Device number must be between 0..3 (not '%s')", buf+7);19.237 - continue;19.238 - }19.239 - maple_subdevice = 0;19.240 - device = maple_new_device( value );19.241 - if( device == NULL ) {19.242 - ERROR( "Unrecognized device '%s'", value );19.243 - } else {19.244 - devgroup.key = "controllers";19.245 - devgroup.params = maple_get_device_config(device);19.246 - maple_attach_device( device, maple_device, maple_subdevice );19.247 - group = &devgroup;19.248 - }19.249 - continue;19.250 - } else if( g_strncasecmp( buf, "subdevice ", 10 ) == 0 ) {19.251 - maple_subdevice = strtoul( buf+10, NULL, 0 );19.252 - if( maple_device == -1 ) {19.253 - ERROR( "Subdevice not allowed without primary device" );19.254 - } else if( maple_subdevice < 1 || maple_subdevice > 5 ) {19.255 - ERROR( "Subdevice must be between 1..5 (not '%s')", buf+10 );19.256 - } else if( (device = maple_new_device(value)) == NULL ) {19.257 - ERROR( "Unrecognized subdevice '%s'", value );19.258 - } else {19.259 - devgroup.key = "controllers";19.260 - devgroup.params = maple_get_device_config(device);19.261 - maple_attach_device( device, maple_device, maple_subdevice );19.262 - group = &devgroup;19.263 - }19.264 - continue;19.265 - }19.266 - }19.267 - while( param->key != NULL ) {19.268 - if( strcasecmp( param->key, buf ) == 0 ) {19.269 - param->value = g_strdup(value);19.270 - break;19.271 - }19.272 - param++;19.273 - }19.274 - }19.275 - }19.276 + g_strstrip(buf);19.277 + if( buf[0] == '#' )19.278 + continue;19.279 + if( *buf == '[' ) {19.280 + char *p = strchr(buf, ']');19.281 + if( p != NULL ) {19.282 + struct lxdream_config_group *tmp_group;19.283 + maple_device = maple_subdevice = -1;19.284 + *p = '\0';19.285 + g_strstrip(buf+1);19.286 + tmp_group = &lxdream_config_root[0];19.287 + while( tmp_group->key != NULL ) {19.288 + if( strcasecmp(tmp_group->key, buf+1) == 0 ) {19.289 + group = tmp_group;19.290 + break;19.291 + }19.292 + tmp_group++;19.293 + }19.294 + }19.295 + } else if( group != NULL ) {19.296 + char *value = strchr( buf, '=' );19.297 + if( value != NULL ) {19.298 + struct lxdream_config_entry *param = group->params;19.299 + *value = '\0';19.300 + value++;19.301 + g_strstrip(buf);19.302 + g_strstrip(value);19.303 + if( strcmp(group->key,"controllers") == 0 ) {19.304 + if( g_strncasecmp( buf, "device ", 7 ) == 0 ) {19.305 + maple_device = strtoul( buf+7, NULL, 0 );19.306 + if( maple_device < 0 || maple_device > 3 ) {19.307 + ERROR( "Device number must be between 0..3 (not '%s')", buf+7);19.308 + continue;19.309 + }19.310 + maple_subdevice = 0;19.311 + device = maple_new_device( value );19.312 + if( device == NULL ) {19.313 + ERROR( "Unrecognized device '%s'", value );19.314 + } else {19.315 + devgroup.key = "controllers";19.316 + devgroup.params = maple_get_device_config(device);19.317 + maple_attach_device( device, maple_device, maple_subdevice );19.318 + group = &devgroup;19.319 + }19.320 + continue;19.321 + } else if( g_strncasecmp( buf, "subdevice ", 10 ) == 0 ) {19.322 + maple_subdevice = strtoul( buf+10, NULL, 0 );19.323 + if( maple_device == -1 ) {19.324 + ERROR( "Subdevice not allowed without primary device" );19.325 + } else if( maple_subdevice < 1 || maple_subdevice > 5 ) {19.326 + ERROR( "Subdevice must be between 1..5 (not '%s')", buf+10 );19.327 + } else if( (device = maple_new_device(value)) == NULL ) {19.328 + ERROR( "Unrecognized subdevice '%s'", value );19.329 + } else {19.330 + devgroup.key = "controllers";19.331 + devgroup.params = maple_get_device_config(device);19.332 + maple_attach_device( device, maple_device, maple_subdevice );19.333 + group = &devgroup;19.334 + }19.335 + continue;19.336 + }19.337 + }19.338 + while( param->key != NULL ) {19.339 + if( strcasecmp( param->key, buf ) == 0 ) {19.340 + param->value = g_strdup(value);19.341 + break;19.342 + }19.343 + param++;19.344 + }19.345 + }19.346 + }19.347 }19.348 return TRUE;19.349 }19.350 @@ -290,8 +290,8 @@19.351 FILE *f = fopen(filename, "wo");19.352 gboolean result;19.353 if( f == NULL ) {19.354 - ERROR( "Unable to open '%s': %s", filename, strerror(errno) );19.355 - return FALSE;19.356 + ERROR( "Unable to open '%s': %s", filename, strerror(errno) );19.357 + return FALSE;19.358 }19.359 result = lxdream_save_config_stream(f);19.360 fclose(f);19.361 @@ -301,42 +301,42 @@19.362 gboolean lxdream_save_config_stream( FILE *f )19.363 {19.364 struct lxdream_config_group *group = &lxdream_config_root[0];19.365 -19.366 +19.367 while( group->key != NULL ) {19.368 - struct lxdream_config_entry *entry = group->params;19.369 - fprintf( f, "[%s]\n", group->key );19.370 -19.371 - if( entry != NULL ) {19.372 - while( entry->key != NULL ) {19.373 - if( entry->value != NULL ) {19.374 - fprintf( f, "%s = %s\n", entry->key, entry->value );19.375 - }19.376 - entry++;19.377 - }19.378 - } else if( strcmp(group->key, "controllers") == 0 ) {19.379 - int i,j;19.380 - for( i=0; i<4; i++ ) {19.381 - for( j=0; j<6; j++ ) {19.382 - maple_device_t dev = maple_get_device( i, j );19.383 - if( dev != NULL ) {19.384 - if( j == 0 )19.385 - fprintf( f, "Device %d = %s\n", i, dev->device_class->name );19.386 - else19.387 - fprintf( f, "Subdevice %d = %s\n", j, dev->device_class->name );19.388 - if( dev->get_config != NULL && ((entry = dev->get_config(dev)) != NULL) ) {19.389 - while( entry->key != NULL ) {19.390 - if( entry->value != NULL ) {19.391 - fprintf( f, "%*c%s = %s\n", j==0?4:8, ' ',entry->key, entry->value );19.392 - }19.393 - entry++;19.394 - }19.395 - }19.396 - }19.397 - }19.398 - }19.399 - }19.400 - fprintf( f, "\n" );19.401 - group++;19.402 + struct lxdream_config_entry *entry = group->params;19.403 + fprintf( f, "[%s]\n", group->key );19.404 +19.405 + if( entry != NULL ) {19.406 + while( entry->key != NULL ) {19.407 + if( entry->value != NULL ) {19.408 + fprintf( f, "%s = %s\n", entry->key, entry->value );19.409 + }19.410 + entry++;19.411 + }19.412 + } else if( strcmp(group->key, "controllers") == 0 ) {19.413 + int i,j;19.414 + for( i=0; i<4; i++ ) {19.415 + for( j=0; j<6; j++ ) {19.416 + maple_device_t dev = maple_get_device( i, j );19.417 + if( dev != NULL ) {19.418 + if( j == 0 )19.419 + fprintf( f, "Device %d = %s\n", i, dev->device_class->name );19.420 + else19.421 + fprintf( f, "Subdevice %d = %s\n", j, dev->device_class->name );19.422 + if( dev->get_config != NULL && ((entry = dev->get_config(dev)) != NULL) ) {19.423 + while( entry->key != NULL ) {19.424 + if( entry->value != NULL ) {19.425 + fprintf( f, "%*c%s = %s\n", j==0?4:8, ' ',entry->key, entry->value );19.426 + }19.427 + entry++;19.428 + }19.429 + }19.430 + }19.431 + }19.432 + }19.433 + }19.434 + fprintf( f, "\n" );19.435 + group++;19.436 }19.437 return TRUE;19.438 }
20.1 --- a/src/config.h Mon Jul 14 07:42:45 2008 +000020.2 +++ b/src/config.h Mon Jul 14 07:44:42 2008 +000020.3 @@ -22,6 +22,10 @@20.4 #include <glib/gtypes.h>20.5 #include <glib/gi18n.h>20.7 +#ifdef __cplusplus20.8 +extern "C" {20.9 +#endif20.10 +20.11 #define CONFIG_TYPE_NONE 020.12 #define CONFIG_TYPE_FILE 120.13 #define CONFIG_TYPE_PATH 220.14 @@ -88,5 +92,8 @@20.15 */20.16 gboolean lxdream_save_config( );20.18 +#ifdef __cplusplus20.19 +}20.20 +#endif20.22 #endif /* !lxdream_config_H */
21.1 --- a/src/cpu.h Mon Jul 14 07:42:45 2008 +000021.2 +++ b/src/cpu.h Mon Jul 14 07:44:42 2008 +000021.3 @@ -16,8 +16,8 @@21.4 * GNU General Public License for more details.21.5 */21.7 -#ifndef dream_cpu_H21.8 -#define dream_cpu_H 121.9 +#ifndef lxdream_cpu_H21.10 +#define lxdream_cpu_H 121.12 #include "lxdream.h"21.13 #include "mem.h"21.14 @@ -71,4 +71,4 @@21.15 }21.16 #endif21.18 -#endif /* !dream_cpu_H */21.19 +#endif /* !lxdream_cpu_H */
22.1 --- a/src/dcload.c Mon Jul 14 07:42:45 2008 +000022.2 +++ b/src/dcload.c Mon Jul 14 07:44:42 2008 +000022.3 @@ -69,9 +69,9 @@22.4 {22.5 int i;22.6 for( i=0; i<MAX_OPEN_FDS; i++ ) {22.7 - if( open_fds[i] == -1 ) {22.8 - return i;22.9 - }22.10 + if( open_fds[i] == -1 ) {22.11 + return i;22.12 + }22.13 }22.14 return -1;22.15 }22.16 @@ -82,76 +82,76 @@22.17 int fd;22.18 switch( sh4r.r[4] ) {22.19 case SYS_READ:22.20 - fd = sh4r.r[5];22.21 - if( fd < 0 || fd >= MAX_OPEN_FDS || open_fds[fd] == -1 ) {22.22 - sh4r.r[0] = -1;22.23 - } else {22.24 - sh4ptr_t buf = mem_get_region( sh4r.r[6] );22.25 - int length = sh4r.r[7];22.26 - sh4r.r[0] = read( open_fds[fd], buf, length );22.27 - }22.28 - break;22.29 + fd = sh4r.r[5];22.30 + if( fd < 0 || fd >= MAX_OPEN_FDS || open_fds[fd] == -1 ) {22.31 + sh4r.r[0] = -1;22.32 + } else {22.33 + sh4ptr_t buf = mem_get_region( sh4r.r[6] );22.34 + int length = sh4r.r[7];22.35 + sh4r.r[0] = read( open_fds[fd], buf, length );22.36 + }22.37 + break;22.38 case SYS_WRITE:22.39 - fd = sh4r.r[5];22.40 - if( fd < 0 || fd >= MAX_OPEN_FDS || open_fds[fd] == -1 ) {22.41 - sh4r.r[0] = -1;22.42 - } else {22.43 - sh4ptr_t buf = mem_get_region( sh4r.r[6] );22.44 - int length = sh4r.r[7];22.45 - sh4r.r[0] = write( open_fds[fd], buf, length );22.46 - }22.47 - break;22.48 + fd = sh4r.r[5];22.49 + if( fd < 0 || fd >= MAX_OPEN_FDS || open_fds[fd] == -1 ) {22.50 + sh4r.r[0] = -1;22.51 + } else {22.52 + sh4ptr_t buf = mem_get_region( sh4r.r[6] );22.53 + int length = sh4r.r[7];22.54 + sh4r.r[0] = write( open_fds[fd], buf, length );22.55 + }22.56 + break;22.57 case SYS_LSEEK:22.58 - fd = sh4r.r[5];22.59 - if( fd < 0 || fd >= MAX_OPEN_FDS || open_fds[fd] == -1 ) {22.60 - sh4r.r[0] = -1;22.61 - } else {22.62 - sh4r.r[0] = lseek( open_fds[fd], sh4r.r[6], sh4r.r[7] );22.63 - }22.64 - break;22.65 + fd = sh4r.r[5];22.66 + if( fd < 0 || fd >= MAX_OPEN_FDS || open_fds[fd] == -1 ) {22.67 + sh4r.r[0] = -1;22.68 + } else {22.69 + sh4r.r[0] = lseek( open_fds[fd], sh4r.r[6], sh4r.r[7] );22.70 + }22.71 + break;22.73 -/* Secure access only */22.74 + /* Secure access only */22.75 case SYS_OPEN:22.76 - if( dcload_allow_unsafe ) {22.77 - fd = dcload_alloc_fd();22.78 - if( fd == -1 ) {22.79 - sh4r.r[0] = -1;22.80 - } else {22.81 - char *filename = (char *)mem_get_region( sh4r.r[5] );22.82 - int realfd = open( filename, sh4r.r[6] );22.83 - open_fds[fd] = realfd;22.84 - sh4r.r[0] = realfd;22.85 - }22.86 - } else {22.87 - ERROR( "Denying access to local filesystem" );22.88 - sh4r.r[0] = -1;22.89 - }22.90 - break;22.91 + if( dcload_allow_unsafe ) {22.92 + fd = dcload_alloc_fd();22.93 + if( fd == -1 ) {22.94 + sh4r.r[0] = -1;22.95 + } else {22.96 + char *filename = (char *)mem_get_region( sh4r.r[5] );22.97 + int realfd = open( filename, sh4r.r[6] );22.98 + open_fds[fd] = realfd;22.99 + sh4r.r[0] = realfd;22.100 + }22.101 + } else {22.102 + ERROR( "Denying access to local filesystem" );22.103 + sh4r.r[0] = -1;22.104 + }22.105 + break;22.106 case SYS_CLOSE:22.107 - if( dcload_allow_unsafe ) {22.108 - fd = sh4r.r[5];22.109 - if( fd < 0 || fd >= MAX_OPEN_FDS || open_fds[fd] == -1 ) {22.110 - sh4r.r[0] = -1;22.111 - } else {22.112 - if( open_fds[fd] > 2 ) {22.113 - sh4r.r[0] = close( open_fds[fd] );22.114 - } else {22.115 - /* Don't actually close real fds 0-2 */22.116 - sh4r.r[0] = 0;22.117 - }22.118 - open_fds[fd] = -1;22.119 - }22.120 - }22.121 - break;22.122 + if( dcload_allow_unsafe ) {22.123 + fd = sh4r.r[5];22.124 + if( fd < 0 || fd >= MAX_OPEN_FDS || open_fds[fd] == -1 ) {22.125 + sh4r.r[0] = -1;22.126 + } else {22.127 + if( open_fds[fd] > 2 ) {22.128 + sh4r.r[0] = close( open_fds[fd] );22.129 + } else {22.130 + /* Don't actually close real fds 0-2 */22.131 + sh4r.r[0] = 0;22.132 + }22.133 + open_fds[fd] = -1;22.134 + }22.135 + }22.136 + break;22.137 case SYS_EXIT:22.138 - if( dcload_allow_unsafe ) {22.139 - dreamcast_shutdown();22.140 - exit( sh4r.r[5] );22.141 - } else {22.142 - dreamcast_stop();22.143 - }22.144 + if( dcload_allow_unsafe ) {22.145 + dreamcast_shutdown();22.146 + exit( sh4r.r[5] );22.147 + } else {22.148 + dreamcast_stop();22.149 + }22.150 default:22.151 - sh4r.r[0] = -1;22.152 + sh4r.r[0] = -1;22.153 }22.155 }
23.1 --- a/src/display.c Mon Jul 14 07:42:45 2008 +000023.2 +++ b/src/display.c Mon Jul 14 07:44:42 2008 +000023.3 @@ -26,14 +26,14 @@23.5 display_driver_t display_driver_list[] = {23.6 #ifdef HAVE_GTK23.7 - &display_gtk_driver,23.8 + &display_gtk_driver,23.9 #else23.10 #ifdef HAVE_COCOA23.11 - &display_osx_driver,23.12 + &display_osx_driver,23.13 #endif23.14 #endif23.15 - &display_null_driver,23.16 - NULL };23.17 + &display_null_driver,23.18 + NULL };23.20 /* Some explanation:23.21 * The system has at least one "root" device representing the main display23.22 @@ -76,17 +76,17 @@23.23 * Colour format information23.24 */23.25 struct colour_format colour_formats[] = {23.26 - { GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_BGRA, GL_RGB5_A1, 2 },23.27 - { GL_UNSIGNED_SHORT_5_6_5, GL_RGB, GL_RGB5, 2 },23.28 - { GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_BGRA, GL_RGBA4, 2 },23.29 - { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 }, /* YUV decoded to ARGB8888 */23.30 - { GL_UNSIGNED_BYTE, GL_BGR, GL_RGB, 3 },23.31 - { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 },23.32 - { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 }, /* Index4 decoded */23.33 - { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 }, /* Index8 decoded */23.34 - { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 },23.35 - { GL_UNSIGNED_BYTE, GL_RGB, GL_RGB, 3 },23.36 -23.37 + { GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_BGRA, GL_RGB5_A1, 2 },23.38 + { GL_UNSIGNED_SHORT_5_6_5, GL_RGB, GL_RGB5, 2 },23.39 + { GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_BGRA, GL_RGBA4, 2 },23.40 + { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 }, /* YUV decoded to ARGB8888 */23.41 + { GL_UNSIGNED_BYTE, GL_BGR, GL_RGB, 3 },23.42 + { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 },23.43 + { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 }, /* Index4 decoded */23.44 + { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 }, /* Index8 decoded */23.45 + { GL_UNSIGNED_BYTE, GL_BGRA, GL_RGBA8, 4 },23.46 + { GL_UNSIGNED_BYTE, GL_RGB, GL_RGB, 3 },23.47 +23.48 };23.50 /**23.51 @@ -104,10 +104,10 @@23.52 {23.53 GList *ptr;23.54 for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {23.55 - input_driver_entry_t entry = (input_driver_entry_t)ptr->data;23.56 - if( strcasecmp( entry->driver->id, driver->id ) == 0 ) {23.57 - return FALSE;23.58 - }23.59 + input_driver_entry_t entry = (input_driver_entry_t)ptr->data;23.60 + if( strcasecmp( entry->driver->id, driver->id ) == 0 ) {23.61 + return FALSE;23.62 + }23.63 }23.65 input_driver_entry_t entry = g_malloc0( sizeof(struct input_driver_entry) + (sizeof(keymap_entry_t) * max_keycode) );23.66 @@ -121,10 +121,10 @@23.67 {23.68 GList *ptr;23.69 for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {23.70 - input_driver_entry_t entry = (input_driver_entry_t)ptr->data;23.71 - if( strcasecmp(entry->driver->id, id) == 0 ) {23.72 - return TRUE;23.73 - }23.74 + input_driver_entry_t entry = (input_driver_entry_t)ptr->data;23.75 + if( strcasecmp(entry->driver->id, id) == 0 ) {23.76 + return TRUE;23.77 + }23.78 }23.79 return FALSE;23.80 }23.81 @@ -134,15 +134,15 @@23.82 {23.83 GList *ptr;23.84 for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {23.85 - input_driver_entry_t entry = (input_driver_entry_t)ptr->data;23.86 - if( entry->driver == driver ) {23.87 - if( driver->destroy != NULL ) {23.88 - driver->destroy(driver);23.89 - }23.90 - input_drivers = g_list_remove(input_drivers, (gpointer)entry);23.91 - g_free( entry );23.92 - return;23.93 - }23.94 + input_driver_entry_t entry = (input_driver_entry_t)ptr->data;23.95 + if( entry->driver == driver ) {23.96 + if( driver->destroy != NULL ) {23.97 + driver->destroy(driver);23.98 + }23.99 + input_drivers = g_list_remove(input_drivers, (gpointer)entry);23.100 + g_free( entry );23.101 + return;23.102 + }23.103 }23.104 }23.106 @@ -153,43 +153,43 @@23.107 static struct keymap_entry **input_entry_from_keysym( const gchar *keysym )23.108 {23.109 if( keysym == NULL || keysym[0] == 0 ) {23.110 - return NULL;23.111 + return NULL;23.112 }23.113 char **strv = g_strsplit(keysym,":",2);23.114 if( strv[1] == NULL ) {23.115 - /* root device */23.116 - if( display_driver == NULL || display_driver->resolve_keysym == NULL) {23.117 - // Root device has no input handling23.118 - g_strfreev(strv);23.119 - return NULL;23.120 - }23.121 - uint16_t keycode = display_driver->resolve_keysym(g_strstrip(strv[0]));23.122 - g_strfreev(strv);23.123 - if( keycode == 0 ) {23.124 - return NULL;23.125 - }23.126 - return &root_keymap[keycode-1];23.127 + /* root device */23.128 + if( display_driver == NULL || display_driver->resolve_keysym == NULL) {23.129 + // Root device has no input handling23.130 + g_strfreev(strv);23.131 + return NULL;23.132 + }23.133 + uint16_t keycode = display_driver->resolve_keysym(g_strstrip(strv[0]));23.134 + g_strfreev(strv);23.135 + if( keycode == 0 ) {23.136 + return NULL;23.137 + }23.138 + return &root_keymap[keycode-1];23.139 } else {23.140 - char *id = g_strstrip(strv[0]);23.141 - GList *ptr;23.142 - for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {23.143 - input_driver_entry_t entry = (input_driver_entry_t)ptr->data;23.144 - if( strcasecmp( entry->driver->id, id ) == 0 ) {23.145 - /* we have ze device */23.146 - if( entry->driver->resolve_keysym == NULL ) {23.147 - g_strfreev(strv);23.148 - return NULL;23.149 - }23.150 - uint16_t keycode = entry->driver->resolve_keysym(entry->driver, g_strstrip(strv[1]));23.151 - g_strfreev(strv);23.152 - if( keycode == 0 || keycode > entry->entry_count ) {23.153 - return NULL;23.154 - }23.155 - return &entry->keymap[keycode-1];23.156 - }23.157 - }23.158 - g_strfreev(strv);23.159 - return NULL; // device not found23.160 + char *id = g_strstrip(strv[0]);23.161 + GList *ptr;23.162 + for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {23.163 + input_driver_entry_t entry = (input_driver_entry_t)ptr->data;23.164 + if( strcasecmp( entry->driver->id, id ) == 0 ) {23.165 + /* we have ze device */23.166 + if( entry->driver->resolve_keysym == NULL ) {23.167 + g_strfreev(strv);23.168 + return NULL;23.169 + }23.170 + uint16_t keycode = entry->driver->resolve_keysym(entry->driver, g_strstrip(strv[1]));23.171 + g_strfreev(strv);23.172 + if( keycode == 0 || keycode > entry->entry_count ) {23.173 + return NULL;23.174 + }23.175 + return &entry->keymap[keycode-1];23.176 + }23.177 + }23.178 + g_strfreev(strv);23.179 + return NULL; // device not found23.180 }23.181 }23.183 @@ -198,22 +198,22 @@23.184 GList *ptr;23.186 if( keycode == 0 ) {23.187 - return NULL;23.188 + return NULL;23.189 }23.191 if( driver == NULL ) {23.192 - return &root_keymap[keycode-1];23.193 + return &root_keymap[keycode-1];23.194 }23.196 for( ptr = input_drivers; ptr != NULL; ptr = g_list_next(ptr) ) {23.197 - input_driver_entry_t entry = (input_driver_entry_t)ptr->data;23.198 - if( entry->driver == driver ) {23.199 - if( keycode > entry->entry_count ) {23.200 - return NULL;23.201 - } else {23.202 - return &entry->keymap[keycode-1];23.203 - }23.204 - }23.205 + input_driver_entry_t entry = (input_driver_entry_t)ptr->data;23.206 + if( entry->driver == driver ) {23.207 + if( keycode > entry->entry_count ) {23.208 + return NULL;23.209 + } else {23.210 + return &entry->keymap[keycode-1];23.211 + }23.212 + }23.213 }23.214 return NULL;23.215 }23.216 @@ -221,71 +221,71 @@23.217 static gchar *input_keysym_for_keycode( input_driver_t driver, uint16_t keycode )23.218 {23.219 if( keycode == 0 ) {23.220 - return NULL;23.221 + return NULL;23.222 }23.223 if( driver == NULL ) {23.224 - if( display_driver != NULL && display_driver->get_keysym_for_keycode != NULL ) {23.225 - return display_driver->get_keysym_for_keycode(keycode);23.226 - }23.227 + if( display_driver != NULL && display_driver->get_keysym_for_keycode != NULL ) {23.228 + return display_driver->get_keysym_for_keycode(keycode);23.229 + }23.230 } else if( driver->get_keysym_for_keycode ) {23.231 - gchar *sym = driver->get_keysym_for_keycode(driver,keycode);23.232 - if( sym != NULL ) {23.233 - gchar *result = g_strdup_printf( "%s: %s", driver->id, sym );23.234 - g_free(sym);23.235 - return result;23.236 - }23.237 + gchar *sym = driver->get_keysym_for_keycode(driver,keycode);23.238 + if( sym != NULL ) {23.239 + gchar *result = g_strdup_printf( "%s: %s", driver->id, sym );23.240 + g_free(sym);23.241 + return result;23.242 + }23.243 }23.244 return NULL;23.245 }23.248 gboolean input_register_key( const gchar *keysym, input_key_callback_t callback,23.249 - void *data, uint32_t value )23.250 + void *data, uint32_t value )23.251 {23.252 if( keysym == NULL ) {23.253 - return FALSE;23.254 + return FALSE;23.255 }23.256 int keys = 0;23.257 gchar **strv = g_strsplit(keysym, ",", 16);23.258 gchar **s = strv;23.259 while( *s != NULL ) {23.260 - keymap_entry_t *entryp = input_entry_from_keysym(*s);23.261 - if( entryp != NULL ) {23.262 - *entryp = g_malloc0(sizeof(struct keymap_entry));23.263 - (*entryp)->callback = callback;23.264 - (*entryp)->data = data;23.265 - (*entryp)->value = value;23.266 - keys++;23.267 - }23.268 - s++;23.269 + keymap_entry_t *entryp = input_entry_from_keysym(*s);23.270 + if( entryp != NULL ) {23.271 + *entryp = g_malloc0(sizeof(struct keymap_entry));23.272 + (*entryp)->callback = callback;23.273 + (*entryp)->data = data;23.274 + (*entryp)->value = value;23.275 + keys++;23.276 + }23.277 + s++;23.278 }23.279 g_strfreev(strv);23.280 return keys != 0;23.281 }23.283 void input_unregister_key( const gchar *keysym, input_key_callback_t callback,23.284 - void *data, uint32_t value )23.285 + void *data, uint32_t value )23.286 {23.287 if( keysym == NULL ) {23.288 - return;23.289 + return;23.290 }23.292 gchar **strv = g_strsplit(keysym, ",", 16);23.293 gchar **s = strv;23.294 while( *s != NULL ) {23.295 - keymap_entry_t *entryp = input_entry_from_keysym(*s);23.296 - if( entryp != NULL && *entryp != NULL && (*entryp)->callback == callback &&23.297 - (*entryp)->data == data && (*entryp)->value == value ) {23.298 - g_free( *entryp );23.299 - *entryp = NULL;23.300 - }23.301 - s++;23.302 + keymap_entry_t *entryp = input_entry_from_keysym(*s);23.303 + if( entryp != NULL && *entryp != NULL && (*entryp)->callback == callback &&23.304 + (*entryp)->data == data && (*entryp)->value == value ) {23.305 + g_free( *entryp );23.306 + *entryp = NULL;23.307 + }23.308 + s++;23.309 }23.310 g_strfreev(strv);23.311 }23.313 gboolean input_register_hook( input_key_callback_t callback,23.314 - void *data )23.315 + void *data )23.316 {23.317 keymap_entry_t key = malloc( sizeof( struct keymap_entry ) );23.318 assert( key != NULL );23.319 @@ -297,29 +297,29 @@23.320 }23.322 void input_unregister_hook( input_key_callback_t callback,23.323 - void *data )23.324 + void *data )23.325 {23.326 keymap_entry_t key = keyhooks;23.327 if( key != NULL ) {23.328 - if( key->callback == callback && key->data == data ) {23.329 - keyhooks = keyhooks->next;23.330 - free(key);23.331 - return;23.332 - }23.333 - while( key->next != NULL ) {23.334 - if( key->next->callback == callback && key->next->data == data ) {23.335 + if( key->callback == callback && key->data == data ) {23.336 + keyhooks = keyhooks->next;23.337 + free(key);23.338 + return;23.339 + }23.340 + while( key->next != NULL ) {23.341 + if( key->next->callback == callback && key->next->data == data ) {23.342 keymap_entry_t next = key->next;23.343 - key->next = next->next;23.344 - free(next);23.345 - return;23.346 - }23.347 - key = key->next;23.348 - }23.349 + key->next = next->next;23.350 + free(next);23.351 + return;23.352 + }23.353 + key = key->next;23.354 + }23.355 }23.356 }23.358 gboolean input_register_mouse_hook( gboolean relative, input_mouse_callback_t callback,23.359 - void *data )23.360 + void *data )23.361 {23.362 mouse_entry_t ent = malloc( sizeof( struct mouse_entry ) );23.363 assert( ent != NULL );23.364 @@ -334,20 +334,20 @@23.365 {23.366 mouse_entry_t ent = mousehooks;23.367 if( ent != NULL ) {23.368 - if( ent->callback == callback && ent->data == data ) {23.369 - mousehooks = mousehooks->next;23.370 - free(ent);23.371 - return;23.372 - }23.373 - while( ent->next != NULL ) {23.374 - if( ent->next->callback == callback && ent->next->data == data ) {23.375 + if( ent->callback == callback && ent->data == data ) {23.376 + mousehooks = mousehooks->next;23.377 + free(ent);23.378 + return;23.379 + }23.380 + while( ent->next != NULL ) {23.381 + if( ent->next->callback == callback && ent->next->data == data ) {23.382 mouse_entry_t next = ent->next;23.383 - ent->next = next->next;23.384 - free(next);23.385 - return;23.386 - }23.387 - ent = ent->next;23.388 - }23.389 + ent->next = next->next;23.390 + free(next);23.391 + return;23.392 + }23.393 + ent = ent->next;23.394 + }23.395 }23.396 }23.398 @@ -355,8 +355,8 @@23.399 {23.400 mouse_entry_t ent = mousehooks;23.401 while( ent != NULL ) {23.402 - ent->callback(ent->data, buttons, x, y);23.403 - ent = ent->next;23.404 + ent->callback(ent->data, buttons, x, y);23.405 + ent = ent->next;23.406 }23.407 }23.409 @@ -375,38 +375,38 @@23.410 void input_event_keydown( input_driver_t driver, uint16_t keycode, uint32_t pressure )23.411 {23.412 if( display_focused ) {23.413 - keymap_entry_t *entryp = input_entry_from_keycode(driver,keycode);23.414 - if( entryp != NULL && *entryp != NULL ) {23.415 - (*entryp)->callback( (*entryp)->data, (*entryp)->value, pressure, TRUE );23.416 - }23.417 - keymap_entry_t key = keyhooks;23.418 - while( key != NULL ) {23.419 - key->callback( key->data, keycode, pressure, TRUE );23.420 - key = key->next;23.421 - }23.422 + keymap_entry_t *entryp = input_entry_from_keycode(driver,keycode);23.423 + if( entryp != NULL && *entryp != NULL ) {23.424 + (*entryp)->callback( (*entryp)->data, (*entryp)->value, pressure, TRUE );23.425 + }23.426 + keymap_entry_t key = keyhooks;23.427 + while( key != NULL ) {23.428 + key->callback( key->data, keycode, pressure, TRUE );23.429 + key = key->next;23.430 + }23.431 }23.432 if( display_keysym_hook != NULL ) {23.433 - gchar *sym = input_keysym_for_keycode( driver, keycode );23.434 - if( sym != NULL ) {23.435 - display_keysym_hook(display_keysym_hook_data, sym);23.436 - g_free(sym);23.437 - }23.438 + gchar *sym = input_keysym_for_keycode( driver, keycode );23.439 + if( sym != NULL ) {23.440 + display_keysym_hook(display_keysym_hook_data, sym);23.441 + g_free(sym);23.442 + }23.443 }23.444 }23.446 void input_event_keyup( input_driver_t driver, uint16_t keycode, uint32_t pressure )23.447 {23.448 if( display_focused ) {23.449 - keymap_entry_t *entryp = input_entry_from_keycode(driver,keycode);23.450 - if( entryp != NULL && *entryp != NULL ) {23.451 - (*entryp)->callback( (*entryp)->data, (*entryp)->value, pressure, FALSE );23.452 - }23.453 + keymap_entry_t *entryp = input_entry_from_keycode(driver,keycode);23.454 + if( entryp != NULL && *entryp != NULL ) {23.455 + (*entryp)->callback( (*entryp)->data, (*entryp)->value, pressure, FALSE );23.456 + }23.458 - keymap_entry_t key = keyhooks;23.459 - while( key != NULL ) {23.460 - key->callback( key->data, keycode, pressure, FALSE );23.461 - key = key->next;23.462 - }23.463 + keymap_entry_t key = keyhooks;23.464 + while( key != NULL ) {23.465 + key->callback( key->data, keycode, pressure, FALSE );23.466 + key = key->next;23.467 + }23.468 }23.469 }23.471 @@ -421,7 +421,7 @@23.472 fprintf( out, "Available video drivers:\n" );23.473 for( i=0; display_driver_list[i] != NULL; i++ ) {23.474 fprintf( out, " %-8s %s\n", display_driver_list[i]->name,23.475 - gettext(display_driver_list[i]->description) );23.476 + gettext(display_driver_list[i]->description) );23.477 }23.478 }23.480 @@ -429,12 +429,12 @@23.481 {23.482 int i;23.483 if( name == NULL ) {23.484 - return display_driver_list[0];23.485 + return display_driver_list[0];23.486 }23.487 for( i=0; display_driver_list[i] != NULL; i++ ) {23.488 - if( strcasecmp( display_driver_list[i]->name, name ) == 0 ) {23.489 - return display_driver_list[i];23.490 - }23.491 + if( strcasecmp( display_driver_list[i]->name, name ) == 0 ) {23.492 + return display_driver_list[i];23.493 + }23.494 }23.496 return NULL;23.497 @@ -445,13 +445,13 @@23.498 {23.499 gboolean rv = TRUE;23.500 if( display_driver != NULL && display_driver->shutdown_driver != NULL )23.501 - display_driver->shutdown_driver();23.502 + display_driver->shutdown_driver();23.504 display_driver = driver;23.505 if( driver->init_driver != NULL )23.506 - rv = driver->init_driver();23.507 + rv = driver->init_driver();23.508 if( !rv ) {23.509 - display_driver = NULL;23.510 + display_driver = NULL;23.511 }23.512 return rv;23.513 }
24.1 --- a/src/display.h Mon Jul 14 07:42:45 2008 +000024.2 +++ b/src/display.h Mon Jul 14 07:44:42 2008 +000024.3 @@ -17,8 +17,8 @@24.4 * GNU General Public License for more details.24.5 */24.7 -#ifndef dream_video_H24.8 -#define dream_video_H24.9 +#ifndef lxdream_display_H24.10 +#define lxdream_display_H 124.12 #define GL_GLEXT_PROTOTYPES 124.14 @@ -181,7 +181,7 @@24.15 * @param format colour format to output the data in.24.16 */24.17 gboolean (*read_render_buffer)( unsigned char *target, render_buffer_t buffer,24.18 - int rowstride, int format );24.19 + int rowstride, int format );24.21 } *display_driver_t;24.23 @@ -217,10 +217,10 @@24.24 typedef void (*input_mouse_callback_t)( void *data, uint32_t buttons, int32_t x, int32_t y );24.26 gboolean input_register_key( const gchar *keysym, input_key_callback_t callback,24.27 - void *data, uint32_t value );24.28 + void *data, uint32_t value );24.30 void input_unregister_key( const gchar *keysym, input_key_callback_t callback,24.31 - void *data, uint32_t value );24.32 + void *data, uint32_t value );24.34 /**24.35 * Register a hook to receive all input events24.36 @@ -328,4 +328,4 @@24.37 #ifdef __cplusplus24.38 }24.39 #endif24.40 -#endif24.41 +#endif /* !lxdream_display_H */
25.1 --- a/src/dream.h Mon Jul 14 07:42:45 2008 +000025.2 +++ b/src/dream.h Mon Jul 14 07:44:42 2008 +000025.3 @@ -16,8 +16,8 @@25.4 * GNU General Public License for more details.25.5 */25.7 -#ifndef dream_H25.8 -#define dream_H 125.9 +#ifndef lxdream_dream_H25.10 +#define lxdream_dream_H 125.12 #include <stdio.h>25.13 #include <stdlib.h>25.14 @@ -103,4 +103,4 @@25.15 #ifdef __cplusplus25.16 }25.17 #endif25.18 -#endif25.19 +#endif /* !lxdream_dream_H */
26.1 --- a/src/dreamcast.c Mon Jul 14 07:42:45 2008 +000026.2 +++ b/src/dreamcast.c Mon Jul 14 07:44:42 2008 +000026.3 @@ -35,8 +35,8 @@26.4 * Current state of the DC virtual machine26.5 */26.6 typedef enum { STATE_UNINIT=0, STATE_RUNNING,26.7 - STATE_STOPPING, STATE_STOPPED } dreamcast_state_t;26.8 -26.9 + STATE_STOPPING, STATE_STOPPED } dreamcast_state_t;26.10 +26.11 static volatile dreamcast_state_t dreamcast_state = STATE_UNINIT;26.12 static gboolean dreamcast_has_bios = FALSE;26.13 static gboolean dreamcast_exit_on_stop = FALSE;26.14 @@ -54,7 +54,7 @@26.15 * declaration26.16 */26.17 struct dreamcast_module unknown_module = { "****", NULL, NULL, NULL, NULL,26.18 - NULL, NULL, NULL };26.19 + NULL, NULL, NULL };26.21 /**26.22 * This function is responsible for defining how all the pieces of the26.23 @@ -75,11 +75,11 @@26.24 mem_create_ram_region( 0x00703000, 8 KB, MEM_REGION_AUDIO_SCRATCH );26.25 mem_create_ram_region( 0x05000000, 8 MB, MEM_REGION_VIDEO );26.26 dreamcast_has_bios = mem_load_rom( lxdream_get_config_value(CONFIG_BIOS_PATH),26.27 - 0x00000000, 0x00200000, 0x89f2b1a1,26.28 - MEM_REGION_BIOS );26.29 + 0x00000000, 0x00200000, 0x89f2b1a1,26.30 + MEM_REGION_BIOS );26.31 mem_create_ram_region( 0x00200000, 0x00020000, MEM_REGION_FLASH );26.32 mem_load_block( lxdream_get_config_value(CONFIG_FLASH_PATH),26.33 - 0x00200000, 0x00020000 );26.34 + 0x00200000, 0x00020000 );26.36 /* Load in the rest of the core modules */26.37 dreamcast_register_module( &sh4_module );26.38 @@ -93,10 +93,10 @@26.39 void dreamcast_config_changed(void)26.40 {26.41 dreamcast_has_bios = mem_load_rom( lxdream_get_config_value(CONFIG_BIOS_PATH),26.42 - 0x00000000, 0x00200000, 0x89f2b1a1,26.43 - MEM_REGION_BIOS );26.44 + 0x00000000, 0x00200000, 0x89f2b1a1,26.45 + MEM_REGION_BIOS );26.46 mem_load_block( lxdream_get_config_value(CONFIG_FLASH_PATH),26.47 - 0x00200000, 0x00020000 );26.48 + 0x00200000, 0x00020000 );26.49 }26.51 void dreamcast_save_flash()26.52 @@ -123,7 +123,7 @@26.53 {26.54 modules[num_modules++] = module;26.55 if( module->init != NULL )26.56 - module->init();26.57 + module->init();26.58 }26.60 void dreamcast_set_run_time( uint32_t secs, uint32_t nanosecs )26.61 @@ -146,39 +146,39 @@26.62 {26.63 int i;26.64 if( sh4_xlat_is_running() ) {26.65 - sh4_translate_exit( XLAT_EXIT_SYSRESET );26.66 + sh4_translate_exit( XLAT_EXIT_SYSRESET );26.67 }26.68 for( i=0; i<num_modules; i++ ) {26.69 - if( modules[i]->reset != NULL )26.70 - modules[i]->reset();26.71 + if( modules[i]->reset != NULL )26.72 + modules[i]->reset();26.73 }26.74 }26.76 void dreamcast_run( void )26.77 {26.78 int i;26.79 -26.80 +26.81 if( dreamcast_state != STATE_RUNNING ) {26.82 for( i=0; i<num_modules; i++ ) {26.83 if( modules[i]->start != NULL )26.84 modules[i]->start();26.85 }26.86 }26.87 -26.88 +26.89 dreamcast_state = STATE_RUNNING;26.90 -26.91 +26.92 if( run_time_nanosecs != 0 ) {26.93 while( dreamcast_state == STATE_RUNNING ) {26.94 uint32_t time_to_run = timeslice_length;26.95 if( run_time_nanosecs < time_to_run ) {26.96 time_to_run = (uint32_t)run_time_nanosecs;26.97 }26.98 -26.99 +26.100 for( i=0; i<num_modules; i++ ) {26.101 if( modules[i]->run_time_slice != NULL )26.102 time_to_run = modules[i]->run_time_slice( time_to_run );26.103 }26.104 -26.105 +26.106 if( run_time_nanosecs > time_to_run ) {26.107 run_time_nanosecs -= time_to_run;26.108 } else {26.109 @@ -202,7 +202,7 @@26.110 modules[i]->stop();26.111 }26.112 dreamcast_state = STATE_STOPPED;26.113 -26.114 +26.115 if( dreamcast_exit_on_stop ) {26.116 dreamcast_shutdown();26.117 exit(0);26.118 @@ -212,10 +212,10 @@26.119 void dreamcast_stop( void )26.120 {26.121 if( sh4_xlat_is_running() ) {26.122 - sh4_translate_exit( XLAT_EXIT_HALT );26.123 + sh4_translate_exit( XLAT_EXIT_HALT );26.124 }26.125 if( dreamcast_state == STATE_RUNNING )26.126 - dreamcast_state = STATE_STOPPING;26.127 + dreamcast_state = STATE_STOPPING;26.128 }26.130 void dreamcast_shutdown()26.131 @@ -251,7 +251,7 @@26.132 gboolean dreamcast_can_run(void)26.133 {26.134 return dreamcast_state != STATE_UNINIT &&26.135 - (dreamcast_has_bios || dreamcast_program_name != NULL);26.136 + (dreamcast_has_bios || dreamcast_program_name != NULL);26.137 }26.139 /********************************* Save States *****************************/26.140 @@ -277,19 +277,19 @@26.141 {26.142 struct save_state_header header;26.143 if( fread( &header, sizeof(header), 1, f ) != 1 ) {26.144 - return 0;26.145 + return 0;26.146 }26.147 if( strncmp( header.magic, DREAMCAST_SAVE_MAGIC, 16 ) != 0 ) {26.148 - ERROR( "Not a %s save state file", APP_NAME );26.149 - return 0;26.150 + ERROR( "Not a %s save state file", APP_NAME );26.151 + return 0;26.152 }26.153 if( header.version != DREAMCAST_SAVE_VERSION ) {26.154 - ERROR( "%s save state version not supported", APP_NAME );26.155 - return 0;26.156 + ERROR( "%s save state version not supported", APP_NAME );26.157 + return 0;26.158 }26.159 if( header.module_count > MAX_MODULES ) {26.160 - ERROR( "%s save state is corrupted (bad module count)", APP_NAME );26.161 - return 0;26.162 + ERROR( "%s save state is corrupted (bad module count)", APP_NAME );26.163 + return 0;26.164 }26.165 return header.module_count;26.166 }26.167 @@ -311,37 +311,37 @@26.168 int i;26.169 FILE *f = fopen( filename, "r" );26.170 if( f == NULL ) return NULL;26.171 -26.172 +26.173 int module_count = dreamcast_read_save_state_header(f);26.174 if( module_count <= 0 ) {26.175 - fclose(f);26.176 - return NULL;26.177 + fclose(f);26.178 + return NULL;26.179 }26.180 for( i=0; i<module_count; i++ ) {26.181 - struct chunk_header head;26.182 - if( fread( &head, sizeof(head), 1, f ) != 1 ) {26.183 - fclose(f);26.184 - return NULL;26.185 - }26.186 - if( memcmp("BLCK", head.marker, 4) != 0 ) {26.187 - fclose(f);26.188 - return NULL;26.189 - }26.190 + struct chunk_header head;26.191 + if( fread( &head, sizeof(head), 1, f ) != 1 ) {26.192 + fclose(f);26.193 + return NULL;26.194 + }26.195 + if( memcmp("BLCK", head.marker, 4) != 0 ) {26.196 + fclose(f);26.197 + return NULL;26.198 + }26.200 - if( strcmp("PVR2", head.name) == 0 ) {26.201 - uint32_t buf_count;26.202 - int has_front;26.203 - fread( &buf_count, sizeof(buf_count), 1, f );26.204 - fread( &has_front, sizeof(has_front), 1, f );26.205 - if( buf_count != 0 && has_front ) {26.206 - frame_buffer_t result = read_png_from_stream(f);26.207 - fclose(f);26.208 - return result;26.209 - }26.210 - break;26.211 - } else {26.212 - fseek( f, head.block_length, SEEK_CUR );26.213 - }26.214 + if( strcmp("PVR2", head.name) == 0 ) {26.215 + uint32_t buf_count;26.216 + int has_front;26.217 + fread( &buf_count, sizeof(buf_count), 1, f );26.218 + fread( &has_front, sizeof(has_front), 1, f );26.219 + if( buf_count != 0 && has_front ) {26.220 + frame_buffer_t result = read_png_from_stream(f);26.221 + fclose(f);26.222 + return result;26.223 + }26.224 + break;26.225 + } else {26.226 + fseek( f, head.block_length, SEEK_CUR );26.227 + }26.228 }26.229 return NULL;26.230 }26.231 @@ -357,54 +357,54 @@26.233 module_count = dreamcast_read_save_state_header(f);26.234 if( module_count <= 0 ) {26.235 - fclose(f);26.236 - return 1;26.237 + fclose(f);26.238 + return 1;26.239 }26.241 for( i=0; i<MAX_MODULES; i++ ) {26.242 - have_read[i] = 0;26.243 + have_read[i] = 0;26.244 }26.246 for( i=0; i<module_count; i++ ) {26.247 - struct chunk_header chunk;26.248 - fread( &chunk, sizeof(chunk), 1, f );26.249 - if( strncmp(chunk.marker, "BLCK", 4) != 0 ) {26.250 - ERROR( "%s save state is corrupted (missing block header %d)", APP_NAME, i );26.251 - fclose(f);26.252 - return 2;26.253 - }26.254 -26.255 - /* Find the matching module by name */26.256 - for( j=0; j<num_modules; j++ ) {26.257 - if( strcmp(modules[j]->name,chunk.name) == 0 ) {26.258 - have_read[j] = 1;26.259 - if( modules[j]->load == NULL ) {26.260 - ERROR( "%s save state is corrupted (no loader for %s)", APP_NAME, modules[j]->name );26.261 - fclose(f);26.262 - return 2;26.263 - } else if( modules[j]->load(f) != 0 ) {26.264 - ERROR( "%s save state is corrupted (%s failed)", APP_NAME, modules[j]->name );26.265 - fclose(f);26.266 - return 2;26.267 - }26.268 - break;26.269 - }26.270 - }26.271 - if( j == num_modules ) {26.272 - fclose(f);26.273 - ERROR( "%s save state contains unrecognized section", APP_NAME );26.274 - return 2;26.275 - }26.276 + struct chunk_header chunk;26.277 + fread( &chunk, sizeof(chunk), 1, f );26.278 + if( strncmp(chunk.marker, "BLCK", 4) != 0 ) {26.279 + ERROR( "%s save state is corrupted (missing block header %d)", APP_NAME, i );26.280 + fclose(f);26.281 + return 2;26.282 + }26.283 +26.284 + /* Find the matching module by name */26.285 + for( j=0; j<num_modules; j++ ) {26.286 + if( strcmp(modules[j]->name,chunk.name) == 0 ) {26.287 + have_read[j] = 1;26.288 + if( modules[j]->load == NULL ) {26.289 + ERROR( "%s save state is corrupted (no loader for %s)", APP_NAME, modules[j]->name );26.290 + fclose(f);26.291 + return 2;26.292 + } else if( modules[j]->load(f) != 0 ) {26.293 + ERROR( "%s save state is corrupted (%s failed)", APP_NAME, modules[j]->name );26.294 + fclose(f);26.295 + return 2;26.296 + }26.297 + break;26.298 + }26.299 + }26.300 + if( j == num_modules ) {26.301 + fclose(f);26.302 + ERROR( "%s save state contains unrecognized section", APP_NAME );26.303 + return 2;26.304 + }26.305 }26.306 -26.307 +26.308 /* Any modules that we didn't load - reset to the default state.26.309 * (ie it's not an error to skip a module if you don't actually26.310 * care about its state).26.311 */26.312 for( j=0; j<num_modules; j++ ) {26.313 - if( have_read[j] == 0 && modules[j]->reset != NULL ) {26.314 - modules[j]->reset();26.315 - }26.316 + if( have_read[j] == 0 && modules[j]->reset != NULL ) {26.317 + modules[j]->reset();26.318 + }26.319 }26.320 fclose(f);26.321 INFO( "Save state read from %s", filename );26.322 @@ -416,31 +416,31 @@26.323 int i;26.324 FILE *f;26.325 struct save_state_header header;26.326 -26.327 +26.328 f = fopen( filename, "w" );26.329 if( f == NULL )26.330 - return errno;26.331 + return errno;26.332 strcpy( header.magic, DREAMCAST_SAVE_MAGIC );26.333 header.version = DREAMCAST_SAVE_VERSION;26.334 header.module_count = 0;26.336 for( i=0; i<num_modules; i++ ) {26.337 - if( modules[i]->save != NULL )26.338 - header.module_count++;26.339 + if( modules[i]->save != NULL )26.340 + header.module_count++;26.341 }26.342 fwrite( &header, sizeof(header), 1, f );26.343 for( i=0; i<num_modules; i++ ) {26.344 - if( modules[i]->save != NULL ) {26.345 - uint32_t blocklen, posn1, posn2;26.346 - dreamcast_write_chunk_header( modules[i]->name, 0, f );26.347 - posn1 = ftell(f);26.348 - modules[i]->save(f);26.349 - posn2 = ftell(f);26.350 - blocklen = posn2 - posn1;26.351 - fseek( f, posn1-4, SEEK_SET );26.352 - fwrite( &blocklen, sizeof(blocklen), 1, f );26.353 - fseek( f, posn2, SEEK_SET );26.354 - }26.355 + if( modules[i]->save != NULL ) {26.356 + uint32_t blocklen, posn1, posn2;26.357 + dreamcast_write_chunk_header( modules[i]->name, 0, f );26.358 + posn1 = ftell(f);26.359 + modules[i]->save(f);26.360 + posn2 = ftell(f);26.361 + blocklen = posn2 - posn1;26.362 + fseek( f, posn1-4, SEEK_SET );26.363 + fwrite( &blocklen, sizeof(blocklen), 1, f );26.364 + fseek( f, posn2, SEEK_SET );26.365 + }26.366 }26.367 fclose( f );26.368 INFO( "Save state written to %s", filename );
27.1 --- a/src/dreamcast.h Mon Jul 14 07:42:45 2008 +000027.2 +++ b/src/dreamcast.h Mon Jul 14 07:44:42 2008 +000027.3 @@ -19,8 +19,8 @@27.4 * GNU General Public License for more details.27.5 */27.7 -#ifndef dreamcast_H27.8 -#define dreamcast_H 127.9 +#ifndef lxdream_dreamcast_H27.10 +#define lxdream_dreamcast_H 127.12 #include <stdio.h>27.13 #include "lxdream.h"27.14 @@ -82,4 +82,4 @@27.15 }27.16 #endif27.18 -#endif /* !dreamcast_H */27.19 +#endif /* !lxdream_dreamcast_H */
28.1 --- a/src/drivers/audio_alsa.c Mon Jul 14 07:42:45 2008 +000028.2 +++ b/src/drivers/audio_alsa.c Mon Jul 14 07:44:42 2008 +000028.3 @@ -32,8 +32,8 @@28.6 struct lxdream_config_entry alsa_config[] = {28.7 - {"device", N_("Audio output device"), CONFIG_TYPE_FILE, "default"},28.8 - {NULL, CONFIG_TYPE_NONE}28.9 + {"device", N_("Audio output device"), CONFIG_TYPE_FILE, "default"},28.10 + {NULL, CONFIG_TYPE_NONE}28.11 };28.14 @@ -51,12 +51,12 @@28.16 // Open the device we were told to open.28.17 err = snd_pcm_open( &_soundDevice, alsa_config[0].value,28.18 - SND_PCM_STREAM_PLAYBACK, 0 );28.19 + SND_PCM_STREAM_PLAYBACK, 0 );28.21 // Check for error on open.28.22 if ( err < 0 ) {28.23 ERROR( "Init: cannot open audio device %s (%s)\n",28.24 - alsa_config[0].value, snd_strerror( err ) );28.25 + alsa_config[0].value, snd_strerror( err ) );28.26 return FALSE;28.27 } else {28.28 DEBUG( "Audio device opened successfully." );28.29 @@ -69,26 +69,26 @@28.30 // Allocate the hardware parameter structure.28.31 if ( ( err = snd_pcm_hw_params_malloc( &hw_params ) ) < 0 ) {28.32 ERROR( "Init: cannot allocate hardware parameter structure (%s)\n",28.33 - snd_strerror( err ) );28.34 + snd_strerror( err ) );28.35 return FALSE;28.36 }28.38 if ( ( err = snd_pcm_hw_params_any( _soundDevice, hw_params ) ) < 0 ) {28.39 ERROR( "Init: cannot allocate hardware parameter structure (%s)\n",28.40 - snd_strerror( err ) );28.41 + snd_strerror( err ) );28.42 return FALSE;28.43 }28.44 // Set access to RW interleaved.28.45 if ( ( err = snd_pcm_hw_params_set_access( _soundDevice, hw_params,28.46 - SND_PCM_ACCESS_RW_INTERLEAVED ) )28.47 - < 0 ) {28.48 + SND_PCM_ACCESS_RW_INTERLEAVED ) )28.49 + < 0 ) {28.50 ERROR( " Init: cannot set access type (%s)\n", snd_strerror( err ) );28.51 return FALSE;28.52 }28.54 if ( ( err = snd_pcm_hw_params_set_format( _soundDevice, hw_params,28.55 - SND_PCM_FORMAT_S16_LE ) ) <28.56 - 0 ) {28.57 + SND_PCM_FORMAT_S16_LE ) ) <28.58 + 0 ) {28.59 ERROR( "Init: cannot set sample format (%s)\n", snd_strerror( err ) );28.60 return FALSE;28.61 }28.62 @@ -96,7 +96,7 @@28.63 err = snd_pcm_hw_params_set_rate_near( _soundDevice, hw_params, &rate, 0 );28.64 if ( err < 0 ) {28.65 ERROR( "Init: Resampling setup failed for playback: %s\n",28.66 - snd_strerror( err ) );28.67 + snd_strerror( err ) );28.68 return err;28.69 }28.70 // Set channels to stereo (2).28.71 @@ -143,14 +143,14 @@28.72 snd_pcm_sw_params_set_start_threshold( _soundDevice, sw_params, bufferSize/2 );28.73 err = snd_pcm_sw_params( _soundDevice, sw_params );28.74 if( err < 0 ) {28.75 - ERROR("Unable to set sw params for alsa driver: %s\n", snd_strerror(err));28.76 - return FALSE;28.77 + ERROR("Unable to set sw params for alsa driver: %s\n", snd_strerror(err));28.78 + return FALSE;28.79 }28.81 err = snd_pcm_prepare( _soundDevice );28.82 if ( err < 0 ) {28.83 ERROR( "Init: cannot prepare audio interface for use (%s)\n",28.84 - snd_strerror( err ) );28.85 + snd_strerror( err ) );28.86 return FALSE;28.87 }28.88 return TRUE;28.89 @@ -166,9 +166,9 @@28.91 err = snd_pcm_writei( _soundDevice, buffer->data, length );28.92 if( err == -EPIPE ) {28.93 - snd_pcm_prepare( _soundDevice );28.94 + snd_pcm_prepare( _soundDevice );28.95 } else if( err == -ESTRPIPE ) {28.96 - snd_pcm_resume( _soundDevice );28.97 + snd_pcm_resume( _soundDevice );28.98 }28.100 return TRUE;28.101 @@ -183,13 +183,13 @@28.104 struct audio_driver audio_alsa_driver = {28.105 - "alsa",28.106 - N_("Linux ALSA system driver"),28.107 - DEFAULT_SAMPLE_RATE,28.108 - DEFAULT_SAMPLE_FORMAT,28.109 - audio_alsa_init,28.110 - NULL,28.111 - audio_alsa_process_buffer,28.112 - NULL,28.113 - audio_alsa_shutdown28.114 + "alsa",28.115 + N_("Linux ALSA system driver"),28.116 + DEFAULT_SAMPLE_RATE,28.117 + DEFAULT_SAMPLE_FORMAT,28.118 + audio_alsa_init,28.119 + NULL,28.120 + audio_alsa_process_buffer,28.121 + NULL,28.122 + audio_alsa_shutdown28.123 };
29.1 --- a/src/drivers/audio_esd.c Mon Jul 14 07:42:45 2008 +000029.2 +++ b/src/drivers/audio_esd.c Mon Jul 14 07:44:42 2008 +000029.3 @@ -29,7 +29,7 @@29.4 {29.5 int format = DEFAULT_SAMPLE_FORMAT;29.6 int rate = DEFAULT_SAMPLE_RATE;29.7 -29.8 +29.9 if( esd_handle != -1 ) {29.10 esd_close(esd_handle);29.11 }
30.1 --- a/src/drivers/audio_null.c Mon Jul 14 07:42:45 2008 +000030.2 +++ b/src/drivers/audio_null.c Mon Jul 14 07:44:42 2008 +000030.3 @@ -20,7 +20,7 @@30.5 gboolean audio_null_init()30.6 {30.7 - return TRUE;30.8 + return TRUE;30.9 }30.11 gboolean audio_null_process_buffer( audio_buffer_t buffer )30.12 @@ -30,7 +30,7 @@30.14 gboolean audio_null_shutdown()30.15 {30.16 - return TRUE;30.17 + return TRUE;30.18 }30.20 struct audio_driver audio_null_driver = {
31.1 --- a/src/drivers/audio_osx.c Mon Jul 14 07:42:45 2008 +000031.2 +++ b/src/drivers/audio_osx.c Mon Jul 14 07:44:42 2008 +000031.3 @@ -28,12 +28,12 @@31.4 static uint32_t buffer_size;31.6 OSStatus audio_osx_callback( AudioDeviceID inDevice,31.7 - const AudioTimeStamp *inNow,31.8 - const AudioBufferList *inInputData,31.9 - const AudioTimeStamp *inInputTime,31.10 - AudioBufferList *outOutputData,31.11 - const AudioTimeStamp *inOutputTime,31.12 - void *inClientData)31.13 + const AudioTimeStamp *inNow,31.14 + const AudioBufferList *inInputData,31.15 + const AudioTimeStamp *inInputTime,31.16 + AudioBufferList *outOutputData,31.17 + const AudioTimeStamp *inOutputTime,31.18 + void *inClientData)31.19 {31.20 char *output = outOutputData->mBuffers[0].mData;31.21 int data_requested = buffer_size;31.22 @@ -69,25 +69,25 @@31.23 UInt32 size = sizeof(output_device);31.24 AudioStreamBasicDescription outputDesc;31.25 UInt32 outputDescSize = sizeof(outputDesc);31.26 -31.27 +31.28 if( AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,31.29 - &size, &output_device) != noErr ||31.30 - output_device == kAudioDeviceUnknown ) {31.31 + &size, &output_device) != noErr ||31.32 + output_device == kAudioDeviceUnknown ) {31.33 return FALSE;31.34 }31.35 -31.36 +31.37 if( AudioDeviceGetProperty( output_device, 1, 0, kAudioDevicePropertyStreamFormat,31.38 &outputDescSize, &outputDesc ) != noErr ) {31.39 return FALSE;31.40 }31.41 -31.42 +31.43 buffer_size = BUFFER_SIZE;31.44 -31.45 +31.46 if( AudioDeviceSetProperty( output_device, 0, 0, 0, kAudioDevicePropertyBufferSize,31.47 - sizeof(buffer_size), &buffer_size ) != noErr ) {31.48 + sizeof(buffer_size), &buffer_size ) != noErr ) {31.49 return FALSE;31.50 }31.51 -31.52 +31.53 AudioDeviceAddIOProc( output_device, audio_osx_callback, NULL );31.54 return TRUE;31.55 }
32.1 --- a/src/drivers/audio_pulse.c Mon Jul 14 07:42:45 2008 +000032.2 +++ b/src/drivers/audio_pulse.c Mon Jul 14 07:44:42 2008 +000032.3 @@ -39,18 +39,18 @@32.4 } else {32.5 ss.format = PA_SAMPLE_U8;32.6 }32.7 -32.8 +32.9 if( format & AUDIO_FMT_STEREO ) {32.10 - ss.channels = 2;32.11 + ss.channels = 2;32.12 } else {32.13 ss.channels = 1;32.14 }32.16 pulse_server = pa_simple_new(NULL, APP_NAME, PA_STREAM_PLAYBACK,32.17 - NULL, "Audio", &ss, NULL, NULL, NULL);32.18 + NULL, "Audio", &ss, NULL, NULL, NULL);32.19 if( pulse_server == NULL ) {32.20 - ERROR( "Unable to open audio output (pulseaudio)" );32.21 - return FALSE;32.22 + ERROR( "Unable to open audio output (pulseaudio)" );32.23 + return FALSE;32.24 }32.25 return TRUE;32.26 }32.27 @@ -60,18 +60,18 @@32.28 if( pulse_server != NULL ) {32.29 int error;32.30 pa_simple_write( pulse_server, buffer->data, buffer->length, &error );32.31 - return TRUE;32.32 + return TRUE;32.33 } else {32.34 - ERROR( "Pulseaudio not initialized" );32.35 - return FALSE;32.36 + ERROR( "Pulseaudio not initialized" );32.37 + return FALSE;32.38 }32.39 }32.41 gboolean audio_pulse_shutdown()32.42 {32.43 - pa_simple_free(pulse_server);32.44 - pulse_server = NULL;32.45 - return TRUE;32.46 + pa_simple_free(pulse_server);32.47 + pulse_server = NULL;32.48 + return TRUE;32.49 }32.51 struct audio_driver audio_pulse_driver = {
33.1 --- a/src/drivers/cd_linux.c Mon Jul 14 07:42:45 2008 +000033.2 +++ b/src/drivers/cd_linux.c Mon Jul 14 07:44:42 2008 +000033.3 @@ -51,13 +51,13 @@33.4 static gdrom_disc_t linux_open_device( const gchar *filename, FILE *f );33.5 static gdrom_error_t linux_read_disc_toc( gdrom_image_t disc );33.6 static gdrom_error_t linux_read_sector( gdrom_disc_t disc, uint32_t sector,33.7 - int mode, unsigned char *buf, uint32_t *length );33.8 + int mode, unsigned char *buf, uint32_t *length );33.9 static gdrom_error_t linux_send_command( int fd, char *cmd, unsigned char *buffer, size_t *buflen,33.10 - int direction );33.11 + int direction );33.12 static int linux_drive_status( gdrom_disc_t disc );33.14 struct gdrom_image_class cdrom_device_class = { "Linux", NULL,33.15 - linux_image_is_valid, linux_open_device };33.16 + linux_image_is_valid, linux_open_device };33.17 GList *cdrom_get_native_devices(void)33.18 {33.19 GList *list = NULL;33.20 @@ -65,19 +65,19 @@33.21 struct stat st;33.22 setfsent();33.23 while( (ent = getfsent()) != NULL ) {33.24 - if( (stat(ent->fs_spec, &st) != -1) &&33.25 - S_ISBLK(st.st_mode) ) {33.26 - /* Got a valid block device - is it a CDROM? */33.27 - int fd = open(ent->fs_spec, O_RDONLY|O_NONBLOCK);33.28 - if( fd == -1 )33.29 - continue;33.30 - int caps = ioctl(fd, CDROM_GET_CAPABILITY);33.31 - if( caps != -1 ) {33.32 - /* Appears to support CDROM functions */33.33 - list = g_list_append( list, gdrom_device_new(ent->fs_spec, ent->fs_spec));33.34 - }33.35 - close(fd);33.36 - }33.37 + if( (stat(ent->fs_spec, &st) != -1) &&33.38 + S_ISBLK(st.st_mode) ) {33.39 + /* Got a valid block device - is it a CDROM? */33.40 + int fd = open(ent->fs_spec, O_RDONLY|O_NONBLOCK);33.41 + if( fd == -1 )33.42 + continue;33.43 + int caps = ioctl(fd, CDROM_GET_CAPABILITY);33.44 + if( caps != -1 ) {33.45 + /* Appears to support CDROM functions */33.46 + list = g_list_append( list, gdrom_device_new(ent->fs_spec, ent->fs_spec));33.47 + }33.48 + close(fd);33.49 + }33.50 }33.51 return list;33.52 }33.53 @@ -93,15 +93,15 @@33.54 struct cdrom_tochdr tochdr;33.56 if( fstat(fileno(f), &st) == -1 ) {33.57 - return FALSE; /* can't stat device? */33.58 + return FALSE; /* can't stat device? */33.59 }33.60 if( !S_ISBLK(st.st_mode) ) {33.61 - return FALSE; /* Not a block device */33.62 + return FALSE; /* Not a block device */33.63 }33.65 if( ioctl(fileno(f), CDROMREADTOCHDR, &tochdr) == -1 ) {33.66 - /* Quick check that this is really a CD */33.67 - return FALSE;33.68 + /* Quick check that this is really a CD */33.69 + return FALSE;33.70 }33.72 return TRUE;33.73 @@ -113,20 +113,20 @@33.75 disc = gdrom_image_new(filename, f);33.76 if( disc == NULL ) {33.77 - ERROR("Unable to allocate memory!");33.78 - return NULL;33.79 + ERROR("Unable to allocate memory!");33.80 + return NULL;33.81 }33.83 gdrom_error_t status = linux_read_disc_toc( (gdrom_image_t)disc );33.84 if( status != 0 ) {33.85 - gdrom_image_destroy_no_close(disc);33.86 - if( status == 0xFFFF ) {33.87 - ERROR("Unable to load disc table of contents (%s)", strerror(errno));33.88 - } else {33.89 - ERROR("Unable to load disc table of contents (sense %d,%d)",33.90 - status &0xFF, status >> 8 );33.91 - }33.92 - return NULL;33.93 + gdrom_image_destroy_no_close(disc);33.94 + if( status == 0xFFFF ) {33.95 + ERROR("Unable to load disc table of contents (%s)", strerror(errno));33.96 + } else {33.97 + ERROR("Unable to load disc table of contents (sense %d,%d)",33.98 + status &0xFF, status >> 8 );33.99 + }33.100 + return NULL;33.101 }33.102 disc->read_sector = linux_read_sector;33.103 disc->drive_status = linux_drive_status;33.104 @@ -138,13 +138,13 @@33.105 int fd = fileno(((gdrom_image_t)disc)->file);33.106 int status = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);33.107 if( status == CDS_DISC_OK ) {33.108 - status = ioctl(fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT);33.109 - if( status != 0 ) {33.110 - linux_read_disc_toc( (gdrom_image_t)disc);33.111 - }33.112 - return ((gdrom_image_t)disc)->disc_type | IDE_DISC_READY;33.113 + status = ioctl(fd, CDROM_MEDIA_CHANGED, CDSL_CURRENT);33.114 + if( status != 0 ) {33.115 + linux_read_disc_toc( (gdrom_image_t)disc);33.116 + }33.117 + return ((gdrom_image_t)disc)->disc_type | IDE_DISC_READY;33.118 } else {33.119 - return IDE_DISC_NONE;33.120 + return IDE_DISC_NONE;33.121 }33.122 }33.123 /**33.124 @@ -156,7 +156,7 @@33.125 unsigned char buf[MAXTOCSIZE];33.126 size_t buflen = sizeof(buf);33.127 char cmd[12] = { 0x43, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };33.128 -33.129 +33.130 cmd[7] = (sizeof(buf))>>8;33.131 cmd[8] = (sizeof(buf))&0xFF;33.132 memset( buf, 0, sizeof(buf) );33.133 @@ -168,7 +168,7 @@33.134 return 0;33.135 }33.137 - gdrom_error_t linux_play_audio( gdrom_disc_t disc, uint32_t lba, uint32_t endlba )33.138 +gdrom_error_t linux_play_audio( gdrom_disc_t disc, uint32_t lba, uint32_t endlba )33.139 {33.140 int fd = fileno( ((gdrom_image_t)disc)->file );33.141 uint32_t real_sector = lba - CD_MSF_OFFSET;33.142 @@ -183,7 +183,7 @@33.143 cmd[7] = (length >> 16) & 0xFF;33.144 cmd[8] = (length >> 8) & 0xFF;33.145 cmd[9] = length & 0xFF;33.146 -33.147 +33.148 return linux_send_command( fd, cmd, NULL, &buflen, CGC_DATA_NONE );33.149 }33.151 @@ -196,16 +196,16 @@33.152 }33.154 static gdrom_error_t linux_read_sector( gdrom_disc_t disc, uint32_t sector,33.155 - int mode, unsigned char *buf, uint32_t *length )33.156 + int mode, unsigned char *buf, uint32_t *length )33.157 {33.158 gdrom_image_t image = (gdrom_image_t)disc;33.159 int fd = fileno(image->file);33.160 uint32_t real_sector = sector - CD_MSF_OFFSET;33.161 uint32_t sector_size = MAX_SECTOR_SIZE;33.162 char cmd[12];33.163 -33.164 +33.165 mmc_make_read_cd_cmd( cmd, real_sector, mode );33.166 -33.167 +33.168 gdrom_error_t status = linux_send_command( fd, cmd, buf, §or_size, CGC_DATA_READ );33.169 if( status != 0 ) {33.170 return status;33.171 @@ -220,7 +220,7 @@33.172 * code on a device error.33.173 */33.174 static gdrom_error_t linux_send_command( int fd, char *cmd, unsigned char *buffer, size_t *buflen,33.175 - int direction )33.176 + int direction )33.177 {33.178 struct request_sense sense;33.179 struct cdrom_generic_command cgc;33.180 @@ -232,16 +232,16 @@33.181 cgc.buflen = *buflen;33.182 cgc.sense = &sense;33.183 cgc.data_direction = direction;33.184 -33.185 +33.186 if( ioctl(fd, CDROM_SEND_PACKET, &cgc) < 0 ) {33.187 - if( sense.sense_key == 0 ) {33.188 - return -1;33.189 - } else {33.190 - /* TODO: Map newer codes back to the ones used by the gd-rom. */33.191 - return sense.sense_key | (sense.asc<<8);33.192 - }33.193 + if( sense.sense_key == 0 ) {33.194 + return -1;33.195 + } else {33.196 + /* TODO: Map newer codes back to the ones used by the gd-rom. */33.197 + return sense.sense_key | (sense.asc<<8);33.198 + }33.199 } else {33.200 - *buflen = cgc.buflen;33.201 - return 0;33.202 + *buflen = cgc.buflen;33.203 + return 0;33.204 }33.205 }
34.1 --- a/src/drivers/cd_none.c Mon Jul 14 07:42:45 2008 +000034.2 +++ b/src/drivers/cd_none.c Mon Jul 14 07:44:42 2008 +000034.3 @@ -22,7 +22,7 @@34.4 static gdrom_disc_t cdnone_open_device( const gchar *filename, FILE *f );34.6 struct gdrom_image_class cdrom_device_class = { "None", NULL,34.7 - cdnone_image_is_valid, cdnone_open_device };34.8 + cdnone_image_is_valid, cdnone_open_device };34.10 GList *cdrom_get_native_devices(void)34.11 {
35.1 --- a/src/drivers/cd_osx.c Mon Jul 14 07:42:45 2008 +000035.2 +++ b/src/drivers/cd_osx.c Mon Jul 14 07:44:42 2008 +000035.3 @@ -37,10 +37,10 @@35.4 static gdrom_disc_t cdrom_osx_open_device( const gchar *filename, FILE *f );35.5 static gdrom_error_t cdrom_osx_read_toc( gdrom_image_t disc );35.6 static gdrom_error_t cdrom_osx_read_sector( gdrom_disc_t disc, uint32_t sector,35.7 - int mode, unsigned char *buf, uint32_t *length );35.8 + int mode, unsigned char *buf, uint32_t *length );35.10 struct gdrom_image_class cdrom_device_class = { "osx", NULL,35.11 - cdrom_osx_image_is_valid, cdrom_osx_open_device };35.12 + cdrom_osx_image_is_valid, cdrom_osx_open_device };35.14 #define OSX_DRIVE(disc) ( (osx_cdrom_drive_t)(((gdrom_image_t)disc)->private) )35.16 @@ -69,7 +69,7 @@35.17 sprintf( tmp, "dvd://%s", name );35.18 gdrom_image_t image = (gdrom_image_t)gdrom_image_new(tmp, NULL);35.19 image->private = drive;35.20 -35.21 +35.22 image->disc.read_sector = cdrom_osx_read_sector;35.23 image->disc.close = cdrom_osx_destroy;35.24 cdrom_osx_read_toc(image);35.25 @@ -80,7 +80,7 @@35.26 gdrom_disc_t cdrom_open_device( const gchar *method, const gchar *path )35.27 {35.28 gdrom_disc_t result = NULL;35.29 -35.30 +35.31 osx_cdrom_drive_t drive = osx_cdrom_open_drive(path);35.32 if( drive == NULL ) {35.33 return NULL;35.34 @@ -106,7 +106,7 @@35.35 {35.36 GList *list = NULL;35.37 find_cdrom_drive(cdrom_enum_callback, &list);35.38 -35.39 +35.40 osx_register_iokit_notifications();35.41 return list;35.42 }35.43 @@ -126,7 +126,7 @@35.44 static gdrom_error_t cdrom_osx_read_toc( gdrom_image_t image )35.45 {35.46 osx_cdrom_drive_t drive = OSX_DRIVE(image);35.47 -35.48 +35.49 int fh = osx_cdrom_get_media_handle(drive);35.50 if( fh == -1 ) {35.51 image->disc_type = IDE_DISC_NONE;35.52 @@ -141,7 +141,7 @@35.53 readtoc.address.session = 0;35.54 readtoc.bufferLength = sizeof(buf);35.55 readtoc.buffer = buf;35.56 -35.57 +35.58 if( ioctl(fh, DKIOCCDREADTOC, &readtoc ) == -1 ) {35.59 ERROR( "Failed to read TOC: %s", strerror(errno) );35.60 image->disc_type = IDE_DISC_NONE;35.61 @@ -155,7 +155,7 @@35.62 }35.64 static gdrom_error_t cdrom_osx_read_sector( gdrom_disc_t disc, uint32_t sector,35.65 - int mode, unsigned char *buf, uint32_t *length )35.66 + int mode, unsigned char *buf, uint32_t *length )35.67 {35.68 osx_cdrom_drive_t drive = OSX_DRIVE(disc);35.69 int fh = osx_cdrom_get_media_handle(drive);35.70 @@ -190,7 +190,7 @@35.71 }35.72 }35.73 }35.74 -35.75 +35.76 readcd.offset = *length * (sector - 150);35.77 readcd.sectorType = READ_CD_MODE(mode)>>1;35.78 readcd.bufferLength = *length;
36.1 --- a/src/drivers/gl_fbo.c Mon Jul 14 07:42:45 2008 +000036.2 +++ b/src/drivers/gl_fbo.c Mon Jul 14 07:44:42 2008 +000036.3 @@ -58,8 +58,8 @@36.5 static struct gl_fbo_info fbo[MAX_FRAMEBUFFERS];36.6 const static int ATTACHMENT_POINTS[MAX_TEXTURES_PER_FB] = {36.7 - GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT,36.8 - GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT };36.9 + GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT,36.10 + GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT };36.11 static int last_used_fbo;36.13 gboolean gl_fbo_is_supported()36.14 @@ -76,18 +76,18 @@36.15 int i,j;36.16 GLuint fbids[MAX_FRAMEBUFFERS];36.17 GLuint rbids[MAX_FRAMEBUFFERS*2]; /* depth buffer, stencil buffer per fb */36.18 -36.19 +36.20 glGenFramebuffersEXT( MAX_FRAMEBUFFERS, &fbids[0] );36.21 glGenRenderbuffersEXT( MAX_FRAMEBUFFERS*2, &rbids[0] );36.22 for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {36.23 - fbo[i].fb_id = fbids[i];36.24 - fbo[i].depth_id = rbids[i*2];36.25 - fbo[i].stencil_id = rbids[i*2+1];36.26 - fbo[i].width = -1;36.27 - fbo[i].height = -1;36.28 - for( j=0; j<MAX_TEXTURES_PER_FB; j++ ) {36.29 - fbo[i].tex_ids[j] = -1;36.30 - }36.31 + fbo[i].fb_id = fbids[i];36.32 + fbo[i].depth_id = rbids[i*2];36.33 + fbo[i].stencil_id = rbids[i*2+1];36.34 + fbo[i].width = -1;36.35 + fbo[i].height = -1;36.36 + for( j=0; j<MAX_TEXTURES_PER_FB; j++ ) {36.37 + fbo[i].tex_ids[j] = -1;36.38 + }36.39 }36.40 last_used_fbo = 0;36.42 @@ -109,8 +109,8 @@36.43 int i;36.44 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );36.45 for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {36.46 - glDeleteFramebuffersEXT( 1, &fbo[i].fb_id );36.47 - glDeleteRenderbuffersEXT( 2, &fbo[i].depth_id );36.48 + glDeleteFramebuffersEXT( 1, &fbo[i].fb_id );36.49 + glDeleteRenderbuffersEXT( 2, &fbo[i].depth_id );36.50 }36.51 }36.53 @@ -120,13 +120,13 @@36.54 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);36.55 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);36.56 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,36.57 - GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);36.58 + GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);36.59 /* Stencil doesn't work on ATI, and we're not using it at the moment anyway, so...36.60 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].stencil_id);36.61 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX, width, height);36.62 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,36.63 GL_RENDERBUFFER_EXT, fbo[bufno].stencil_id);36.64 - */36.65 + */36.66 fbo[bufno].width = width;36.67 fbo[bufno].height = height;36.68 }36.69 @@ -136,24 +136,24 @@36.70 int bufno = -1, i;36.71 /* find a compatible framebuffer context */36.72 for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {36.73 - if( fbo[i].width == -1 && bufno == -1 ) {36.74 - bufno = i;36.75 - } else if( fbo[i].width == width && fbo[i].height == height ) {36.76 - bufno = i;36.77 - break;36.78 - }36.79 + if( fbo[i].width == -1 && bufno == -1 ) {36.80 + bufno = i;36.81 + } else if( fbo[i].width == width && fbo[i].height == height ) {36.82 + bufno = i;36.83 + break;36.84 + }36.85 }36.86 if( bufno == -1 ) {36.87 - bufno = last_used_fbo + 1;36.88 - if( bufno > MAX_FRAMEBUFFERS ) {36.89 - bufno = 0;36.90 - }36.91 - last_used_fbo = bufno;36.92 + bufno = last_used_fbo + 1;36.93 + if( bufno > MAX_FRAMEBUFFERS ) {36.94 + bufno = 0;36.95 + }36.96 + last_used_fbo = bufno;36.97 }36.98 if( fbo[bufno].width == width && fbo[bufno].height == height ) {36.99 - glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fbo[bufno].fb_id );36.100 + glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fbo[bufno].fb_id );36.101 } else {36.102 - gl_fbo_setup_framebuffer( bufno, width, height );36.103 + gl_fbo_setup_framebuffer( bufno, width, height );36.104 }36.105 return bufno;36.106 }36.107 @@ -165,22 +165,22 @@36.108 static GLint gl_fbo_attach_texture( int fbo_no, GLint tex_id ) {36.109 int attach = -1, i;36.110 for( i=0; i<MAX_TEXTURES_PER_FB; i++ ) {36.111 - if( fbo[fbo_no].tex_ids[i] == tex_id ) {36.112 - glDrawBuffer(ATTACHMENT_POINTS[i]);36.113 - glReadBuffer(ATTACHMENT_POINTS[i]);36.114 - return ATTACHMENT_POINTS[i]; // already attached36.115 - } else if( fbo[fbo_no].tex_ids[i] == -1 && attach == -1 ) {36.116 - attach = i;36.117 - }36.118 + if( fbo[fbo_no].tex_ids[i] == tex_id ) {36.119 + glDrawBuffer(ATTACHMENT_POINTS[i]);36.120 + glReadBuffer(ATTACHMENT_POINTS[i]);36.121 + return ATTACHMENT_POINTS[i]; // already attached36.122 + } else if( fbo[fbo_no].tex_ids[i] == -1 && attach == -1 ) {36.123 + attach = i;36.124 + }36.125 }36.126 if( attach == -1 ) {36.127 - /* should never happen */36.128 - attach = 0;36.129 + /* should never happen */36.130 + attach = 0;36.131 }36.132 fbo[fbo_no].tex_ids[attach] = tex_id;36.133 glBindTexture( GL_TEXTURE_RECTANGLE_ARB, 0 ); // Ensure the output texture is unbound36.134 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ATTACHMENT_POINTS[attach],36.135 - GL_TEXTURE_RECTANGLE_ARB, tex_id, 0 );36.136 + GL_TEXTURE_RECTANGLE_ARB, tex_id, 0 );36.137 /* Set draw/read buffers by default */36.138 glDrawBuffer(ATTACHMENT_POINTS[attach]);36.139 glReadBuffer(ATTACHMENT_POINTS[attach]);36.140 @@ -188,12 +188,12 @@36.142 GLint status = glGetError();36.143 if( status != GL_NO_ERROR ) {36.144 - ERROR( "GL error setting render target (%x)!", status );36.145 + ERROR( "GL error setting render target (%x)!", status );36.146 }36.147 status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);36.148 if( status != GL_FRAMEBUFFER_COMPLETE_EXT ) {36.149 - ERROR( "Framebuffer failure: %x", status );36.150 - exit(1);36.151 + ERROR( "Framebuffer failure: %x", status );36.152 + exit(1);36.153 }36.155 return ATTACHMENT_POINTS[attach];36.156 @@ -218,16 +218,16 @@36.157 {36.158 int i,j;36.159 for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {36.160 - for( j=0; j < MAX_TEXTURES_PER_FB; j++ ) {36.161 - if( fbo[i].tex_ids[j] == buffer->buf_id ) {36.162 - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo[i].fb_id);36.163 - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ATTACHMENT_POINTS[j],36.164 - GL_TEXTURE_RECTANGLE_ARB, GL_NONE, 0 );36.165 - fbo[i].tex_ids[j] = -1;36.166 - }36.167 - }36.168 + for( j=0; j < MAX_TEXTURES_PER_FB; j++ ) {36.169 + if( fbo[i].tex_ids[j] == buffer->buf_id ) {36.170 + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo[i].fb_id);36.171 + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ATTACHMENT_POINTS[j],36.172 + GL_TEXTURE_RECTANGLE_ARB, GL_NONE, 0 );36.173 + fbo[i].tex_ids[j] = -1;36.174 + }36.175 + }36.176 }36.177 -36.178 +36.179 glDeleteTextures( 1, &buffer->buf_id );36.180 buffer->buf_id = 0;36.181 free( buffer );36.182 @@ -241,7 +241,7 @@36.183 gl_fbo_attach_texture( fb, buffer->buf_id );36.184 /* setup the gl context */36.185 glViewport( 0, 0, buffer->width, buffer->height );36.186 -36.187 +36.188 return TRUE;36.189 }36.191 @@ -278,7 +278,7 @@36.192 }36.194 static gboolean gl_fbo_read_render_buffer( unsigned char *target, render_buffer_t buffer,36.195 - int rowstride, int format )36.196 + int rowstride, int format )36.197 {36.198 int fb = gl_fbo_get_framebuffer( buffer->width, buffer->height );36.199 gl_fbo_attach_texture( fb, buffer->buf_id );
37.1 --- a/src/drivers/joy_linux.c Mon Jul 14 07:42:45 2008 +000037.2 +++ b/src/drivers/joy_linux.c Mon Jul 14 07:44:42 2008 +000037.3 @@ -51,7 +51,7 @@37.4 } *linux_joystick_t;37.6 static gboolean linux_joystick_callback( GIOChannel *source, GIOCondition condition,37.7 - gpointer data );37.8 + gpointer data );37.9 static int linux_joystick_scan();37.10 static linux_joystick_t linux_joystick_new( const gchar *filename, int fd );37.11 static uint16_t linux_joystick_resolve_keysym( input_driver_t dev, const gchar *str );37.12 @@ -70,25 +70,25 @@37.13 {37.14 linux_joystick_t joy = (linux_joystick_t)dev;37.15 if( strncasecmp( str, "Button", 6 ) == 0 ){37.16 - unsigned long button = strtoul( str+6, NULL, 10 );37.17 - if( button > joy->button_count ) {37.18 - return 0;37.19 - }37.20 - return (uint16_t)button;37.21 + unsigned long button = strtoul( str+6, NULL, 10 );37.22 + if( button > joy->button_count ) {37.23 + return 0;37.24 + }37.25 + return (uint16_t)button;37.26 } else if( strncasecmp( str, "Axis", 4 ) == 0 ) {37.27 - char *endptr;37.28 - unsigned long axis = strtoul( str+4, &endptr, 10 );37.29 - if( axis > joy->axis_count || axis == 0 ) {37.30 - return 0;37.31 - }37.32 - int keycode = ((axis - 1) << 1) + joy->button_count + 1;37.33 - if( *endptr == '-' ) {37.34 - return keycode + 1;37.35 - } else {37.36 - return keycode;37.37 - }37.38 + char *endptr;37.39 + unsigned long axis = strtoul( str+4, &endptr, 10 );37.40 + if( axis > joy->axis_count || axis == 0 ) {37.41 + return 0;37.42 + }37.43 + int keycode = ((axis - 1) << 1) + joy->button_count + 1;37.44 + if( *endptr == '-' ) {37.45 + return keycode + 1;37.46 + } else {37.47 + return keycode;37.48 + }37.49 } else {37.50 - return 0;37.51 + return 0;37.52 }37.53 }37.55 @@ -96,18 +96,18 @@37.56 {37.57 linux_joystick_t joy = (linux_joystick_t)dev;37.58 if( keycode == 0 ) {37.59 - return NULL;37.60 + return NULL;37.61 }37.62 if( keycode <= joy->button_count ) {37.63 - return g_strdup_printf( "Button%d", keycode );37.64 + return g_strdup_printf( "Button%d", keycode );37.65 }37.66 if( keycode <= joy->button_count + joy->axis_count*2 ) {37.67 - int axis = keycode - joy->button_count - 1;37.68 - if( (axis & 1) == 0 ) {37.69 - return g_strdup_printf( "Axis%d+", (axis >> 1)+1 );37.70 - } else {37.71 - return g_strdup_printf( "Axis%d-", (axis >> 1)+1 );37.72 - }37.73 + int axis = keycode - joy->button_count - 1;37.74 + if( (axis & 1) == 0 ) {37.75 + return g_strdup_printf( "Axis%d+", (axis >> 1)+1 );37.76 + } else {37.77 + return g_strdup_printf( "Axis%d-", (axis >> 1)+1 );37.78 + }37.79 }37.80 return NULL;37.81 }37.82 @@ -129,39 +129,39 @@37.83 * On error, close the channel and delete the device.37.84 */37.85 static gboolean linux_joystick_callback( GIOChannel *source, GIOCondition condition,37.86 - gpointer data )37.87 + gpointer data )37.88 {37.89 linux_joystick_t joy = (linux_joystick_t)data;37.91 if( condition & G_IO_HUP ) {37.92 - INFO( "Joystick '%s' disconnected\n", joy->name );37.93 - input_unregister_device((input_driver_t)joy);37.94 - return FALSE;37.95 + INFO( "Joystick '%s' disconnected\n", joy->name );37.96 + input_unregister_device((input_driver_t)joy);37.97 + return FALSE;37.98 }37.99 if( condition & G_IO_IN ) {37.100 - struct js_event event;37.101 - while( read( joy->fd, &event, sizeof(event) ) == sizeof(event) ) {37.102 - if( event.type == JS_EVENT_BUTTON ) {37.103 - int keycode = event.number+1;37.104 - if( event.value == 0 ) {37.105 - input_event_keyup( (input_driver_t)joy, keycode, 0 );37.106 - } else {37.107 - input_event_keydown( (input_driver_t)joy, keycode, event.value );37.108 - }37.109 - } else if( event.type == JS_EVENT_AXIS ) {37.110 - int keycode = (event.number*2) + joy->button_count + 1;37.111 - if( event.value == 0 ) {37.112 - input_event_keyup( (input_driver_t)joy, keycode, 0 );37.113 - input_event_keyup( (input_driver_t)joy, keycode+1, 0 );37.114 - } else if( event.value < 0 ) {37.115 - input_event_keydown( (input_driver_t)joy, keycode+1, -event.value );37.116 - input_event_keyup( (input_driver_t)joy, keycode, 0 );37.117 - } else {37.118 - input_event_keydown( (input_driver_t)joy, keycode, event.value );37.119 - input_event_keyup( (input_driver_t)joy, keycode+1, 0 );37.120 - }37.121 - }37.122 - }37.123 + struct js_event event;37.124 + while( read( joy->fd, &event, sizeof(event) ) == sizeof(event) ) {37.125 + if( event.type == JS_EVENT_BUTTON ) {37.126 + int keycode = event.number+1;37.127 + if( event.value == 0 ) {37.128 + input_event_keyup( (input_driver_t)joy, keycode, 0 );37.129 + } else {37.130 + input_event_keydown( (input_driver_t)joy, keycode, event.value );37.131 + }37.132 + } else if( event.type == JS_EVENT_AXIS ) {37.133 + int keycode = (event.number*2) + joy->button_count + 1;37.134 + if( event.value == 0 ) {37.135 + input_event_keyup( (input_driver_t)joy, keycode, 0 );37.136 + input_event_keyup( (input_driver_t)joy, keycode+1, 0 );37.137 + } else if( event.value < 0 ) {37.138 + input_event_keydown( (input_driver_t)joy, keycode+1, -event.value );37.139 + input_event_keyup( (input_driver_t)joy, keycode, 0 );37.140 + } else {37.141 + input_event_keydown( (input_driver_t)joy, keycode, event.value );37.142 + input_event_keyup( (input_driver_t)joy, keycode+1, 0 );37.143 + }37.144 + }37.145 + }37.146 }37.147 return TRUE;37.148 }37.149 @@ -183,17 +183,17 @@37.151 char *p = strrchr(filename, '/');37.152 if( p == NULL ) {37.153 - joy->driver.id = filename;37.154 + joy->driver.id = filename;37.155 } else {37.156 - joy->driver.id = p+1;37.157 + joy->driver.id = p+1;37.158 }37.160 if( ioctl( fd, JSIOCGNAME(128), joy->name ) == -1 ||37.161 - ioctl( fd, JSIOCGAXES, &joy->axis_count ) == -1 ||37.162 - ioctl( fd, JSIOCGBUTTONS, &joy->button_count ) == -1 ) {37.163 - ERROR( "Error reading joystick data from %s (%s)\n", filename, strerror(errno) );37.164 - g_free(joy);37.165 - return NULL;37.166 + ioctl( fd, JSIOCGAXES, &joy->axis_count ) == -1 ||37.167 + ioctl( fd, JSIOCGBUTTONS, &joy->button_count ) == -1 ) {37.168 + ERROR( "Error reading joystick data from %s (%s)\n", filename, strerror(errno) );37.169 + g_free(joy);37.170 + return NULL;37.171 }37.173 joy->channel = g_io_channel_unix_new(fd);37.174 @@ -208,24 +208,24 @@37.175 DIR *dir = opendir(INPUT_PATH);37.177 if( dir == NULL ) {37.178 - return 0;37.179 + return 0;37.180 }37.181 -37.182 +37.183 while( (ent = readdir(dir)) != NULL ) {37.184 - if( ent->d_name[0] == 'j' && ent->d_name[1] == 's' &&37.185 - isdigit(ent->d_name[2]) && !input_has_device(ent->d_name) ) {37.186 - gchar *name = g_strdup_printf( "%s/%s", INPUT_PATH, ent->d_name );37.187 - int fd = open(name, O_RDONLY|O_NONBLOCK);37.188 - if( fd == -1 ) {37.189 - g_free( name );37.190 - } else {37.191 - linux_joystick_t joy = linux_joystick_new( name, fd );37.192 - input_register_device( (input_driver_t)joy, (joy->axis_count*2) + joy->button_count );37.193 - INFO( "Attached joystick %s named '%s', (%d buttons, %d axes)",37.194 - joy->driver.id, joy->name, joy->button_count, joy->axis_count );37.195 - joysticks++;37.196 - }37.197 - }37.198 + if( ent->d_name[0] == 'j' && ent->d_name[1] == 's' &&37.199 + isdigit(ent->d_name[2]) && !input_has_device(ent->d_name) ) {37.200 + gchar *name = g_strdup_printf( "%s/%s", INPUT_PATH, ent->d_name );37.201 + int fd = open(name, O_RDONLY|O_NONBLOCK);37.202 + if( fd == -1 ) {37.203 + g_free( name );37.204 + } else {37.205 + linux_joystick_t joy = linux_joystick_new( name, fd );37.206 + input_register_device( (input_driver_t)joy, (joy->axis_count*2) + joy->button_count );37.207 + INFO( "Attached joystick %s named '%s', (%d buttons, %d axes)",37.208 + joy->driver.id, joy->name, joy->button_count, joy->axis_count );37.209 + joysticks++;37.210 + }37.211 + }37.212 }37.214 closedir(dir);37.215 @@ -235,7 +235,7 @@37.216 gboolean linux_joystick_init()37.217 {37.218 if( !linux_joystick_install_watch(INPUT_PATH) ) {37.219 - return FALSE;37.220 + return FALSE;37.221 }37.222 linux_joystick_scan();37.223 return TRUE;37.224 @@ -254,11 +254,11 @@37.225 static gboolean gtk_loop_check_input(gpointer data)37.226 {37.227 if( need_input_rescan == 1 ) {37.228 - need_input_rescan = 0;37.229 - int js = linux_joystick_scan();37.230 - if( js > 0 ) {37.231 - maple_reattach_all();37.232 - }37.233 + need_input_rescan = 0;37.234 + int js = linux_joystick_scan();37.235 + if( js > 0 ) {37.236 + maple_reattach_all();37.237 + }37.238 }37.239 return need_input_rescan != 2;37.240 }37.241 @@ -272,14 +272,14 @@37.242 {37.243 int fd = open( dir, O_RDONLY|O_NONBLOCK );37.244 if( fd == -1 ) {37.245 - return FALSE;37.246 + return FALSE;37.247 }37.248 -37.249 +37.250 signal( SIGRTMIN+1, dnotify_handler );37.251 fcntl(fd, F_SETSIG, SIGRTMIN + 1);37.252 if( fcntl(fd, F_NOTIFY, DN_CREATE|DN_MULTISHOT) == -1 ) {37.253 - close(fd);37.254 - return FALSE;37.255 + close(fd);37.256 + return FALSE;37.257 }37.258 watch_dir_fd = fd;37.259 g_timeout_add( 500, gtk_loop_check_input, NULL );
38.1 --- a/src/drivers/joy_linux.h Mon Jul 14 07:42:45 2008 +000038.2 +++ b/src/drivers/joy_linux.h Mon Jul 14 07:44:42 2008 +000038.3 @@ -19,6 +19,10 @@38.4 #ifndef lxdream_joy_linux_H38.5 #define lxdream_joy_linux_H38.7 +#ifdef __cplusplus38.8 +extern "C" {38.9 +#endif38.10 +38.11 /**38.12 * Initialize the linux joystick code, and scan for devices38.13 */38.14 @@ -29,6 +33,8 @@38.15 */38.16 void linux_joystick_shutdown();38.18 -38.19 +#ifdef __cplusplus38.20 +}38.21 +#endif38.23 #endif /* !lxdream_joy_linux_H */
39.1 --- a/src/drivers/osx_iokit.c Mon Jul 14 07:42:45 2008 +000039.2 +++ b/src/drivers/osx_iokit.c Mon Jul 14 07:44:42 2008 +000039.3 @@ -52,7 +52,7 @@39.4 * we're interested in is service termination.39.5 */39.6 static void osx_cdrom_media_notify( void *ref, io_service_t service, uint32_t msgType,39.7 - void *msgArgument )39.8 + void *msgArgument )39.9 {39.10 if( msgType == kIOMessageServiceIsTerminated ) {39.11 osx_cdrom_drive_t drive = (osx_cdrom_drive_t)ref;39.12 @@ -79,13 +79,13 @@39.13 static void osx_cdrom_media_inserted( void *ref, io_iterator_t iterator )39.14 {39.15 osx_cdrom_drive_t drive = (osx_cdrom_drive_t)ref;39.16 -39.17 +39.18 io_object_t object;39.19 while( (object = IOIteratorNext(iterator)) != 0 ) {39.20 io_string_t iopath = "";39.21 IORegistryEntryGetPath( object, kIOServicePlane, iopath );39.22 if( drive != NULL && g_str_has_prefix(iopath, drive->ioservice_path ) &&39.23 - get_bsdname_for_iomedia(object, drive->media_path, sizeof(drive->media_path)) ) {39.24 + get_bsdname_for_iomedia(object, drive->media_path, sizeof(drive->media_path)) ) {39.25 // A disc was inserted within the drive of interest39.26 if( drive->media_fh != -1 ) {39.27 close(drive->media_fh);39.28 @@ -98,7 +98,7 @@39.29 // Add a notification listener to get removal events.39.30 IOServiceAddInterestNotification( notify_port, object, kIOGeneralInterest,39.31 osx_cdrom_media_notify, drive, &drive->media_unload_iterator );39.32 -39.33 +39.34 }39.35 IOObjectRelease( object );39.36 }39.37 @@ -106,11 +106,11 @@39.39 static void osx_drives_changed( void *ref, io_iterator_t iterator )39.40 {39.41 - io_object_t object;39.42 - while( (object = IOIteratorNext(iterator)) != 0 ) {39.43 - IOObjectRelease(object);39.44 - }39.45 -39.46 + io_object_t object;39.47 + while( (object = IOIteratorNext(iterator)) != 0 ) {39.48 + IOObjectRelease(object);39.49 + }39.50 +39.51 }39.53 /******************** Support functions *********************/39.54 @@ -123,13 +123,13 @@39.55 {39.56 gboolean result = FALSE;39.57 CFTypeRef pathRef = IORegistryEntryCreateCFProperty(iomedia, CFSTR(kIOBSDNameKey),39.58 - kCFAllocatorDefault, 0 );39.59 + kCFAllocatorDefault, 0 );39.60 if( pathRef ) {39.61 char pathlen;39.62 strcpy( buf, _PATH_DEV "r" );39.63 pathlen = strlen(buf);39.64 if( CFStringGetCString( pathRef, buf + pathlen, buflen-pathlen,39.65 - kCFStringEncodingASCII ) != noErr ) {39.66 + kCFStringEncodingASCII ) != noErr ) {39.67 result = TRUE;39.68 }39.69 CFRelease(pathRef);39.70 @@ -138,7 +138,7 @@39.71 }39.73 static gboolean osx_cdrom_drive_get_name( io_object_t object, char *vendor, int vendor_len,39.74 - char *product, int product_len )39.75 + char *product, int product_len )39.76 {39.77 gboolean result = FALSE;39.78 CFMutableDictionaryRef props = 0;39.79 @@ -152,7 +152,7 @@39.80 } else {39.81 vendor[0] = 0;39.82 }39.83 -39.84 +39.85 value = CFDictionaryGetValue(dict, CFSTR(kIOPropertyProductNameKey));39.86 if ( value && CFGetTypeID(value) == CFStringGetTypeID() ) {39.87 CFStringGetCString( (CFStringRef)value, product, product_len, kCFStringEncodingUTF8 );39.88 @@ -174,7 +174,7 @@39.89 static osx_cdrom_drive_t osx_cdrom_drive_new( io_object_t device )39.90 {39.91 osx_cdrom_drive_t drive = g_malloc0(sizeof(struct osx_cdrom_drive));39.92 -39.93 +39.94 IORegistryEntryGetPath( device, kIOServicePlane, drive->ioservice_path );39.95 osx_cdrom_drive_get_name( device, drive->vendor_name, sizeof(drive->vendor_name),39.96 drive->product_name, sizeof(drive->product_name) );39.97 @@ -199,7 +199,7 @@39.98 if( object == MACH_PORT_NULL ) {39.99 return NULL;39.100 }39.101 -39.102 +39.103 osx_cdrom_drive_t drive = osx_cdrom_drive_new( object );39.104 IOObjectRelease( object );39.105 return drive;39.106 @@ -258,7 +258,7 @@39.107 }39.108 IOObjectRelease(iterator);39.109 }39.110 -39.111 +39.113 /**39.114 * Search for a CD or DVD drive (instance of IODVDServices or IOCompactDiscServices).39.115 @@ -276,21 +276,21 @@39.116 CFMutableDictionaryRef match;39.117 io_iterator_t services;39.118 io_object_t result;39.119 -39.120 +39.121 if( IOMasterPort( MACH_PORT_NULL, &master_port ) != KERN_SUCCESS ) {39.122 return 0; // Failed to get the master port?39.123 }39.124 -39.125 +39.126 match = IOServiceMatching("IODVDServices");39.127 if( IOServiceGetMatchingServices(master_port, match, &services) != kIOReturnSuccess ) {39.128 return 0;39.129 }39.130 -39.131 +39.132 result = iterator_find_cdrom( services, callback, user_data );39.133 if( result != 0 ) {39.134 return result;39.135 }39.136 -39.137 +39.138 match = IOServiceMatching("IOCompactDiscServices");39.139 if( IOServiceGetMatchingServices(master_port, match, &services) != kIOReturnSuccess ) {39.140 return 0;39.141 @@ -330,7 +330,7 @@39.142 ERROR( "IOServiceAddMatchingNotification failed" );39.143 }39.144 osx_drives_changed(NULL, iokit_iterators[1]);39.145 -39.146 +39.147 if( IOServiceAddMatchingNotification( notify_port, kIOFirstPublishNotification,39.148 IOServiceMatching(kIOHIDDeviceKey),39.149 osx_hid_inserted, NULL, &iokit_iterators[4] ) != kIOReturnSuccess ) {
40.1 --- a/src/drivers/osx_iokit.h Mon Jul 14 07:42:45 2008 +000040.2 +++ b/src/drivers/osx_iokit.h Mon Jul 14 07:44:42 2008 +000040.3 @@ -32,7 +32,7 @@40.4 * (and not freed)40.5 */40.6 typedef gboolean (*find_drive_callback_t)( io_object_t object, char *vendor, char *product,40.7 - char *iopath, void *user_data );40.8 + char *iopath, void *user_data );40.10 /**40.11 * Search for a CD or DVD drive (instance of IODVDServices or IOCompactDiscServices).
41.1 --- a/src/drivers/video_gdk.c Mon Jul 14 07:42:45 2008 +000041.2 +++ b/src/drivers/video_gdk.c Mon Jul 14 07:44:42 2008 +000041.3 @@ -63,12 +63,12 @@41.4 {41.5 unsigned int i;41.6 for( i=0; i<pixbuf_max; i++ ) {41.7 - if( pixbuf_array[i] == NULL ) {41.8 - return i;41.9 - }41.10 + if( pixbuf_array[i] == NULL ) {41.11 + return i;41.12 + }41.13 }41.14 if( i < MAX_PIXBUF ) {41.15 - return pixbuf_max++;41.16 + return pixbuf_max++;41.17 }41.18 return -1;41.19 }41.20 @@ -77,10 +77,10 @@41.21 {41.22 unsigned int i;41.23 for( i=0; i<pixbuf_max; i++ ) {41.24 - if( pixbuf_array[i] != NULL ) {41.25 - g_free(pixbuf_array[i]);41.26 - pixbuf_array[i] = NULL;41.27 - }41.28 + if( pixbuf_array[i] != NULL ) {41.29 + g_free(pixbuf_array[i]);41.30 + pixbuf_array[i] = NULL;41.31 + }41.32 }41.33 pixbuf_max = 0;41.34 OSMesaDestroyContext( osmesa_context );41.35 @@ -103,7 +103,7 @@41.36 g_free(pixbuf_array[buffer->buf_id] );41.37 pixbuf_array[buffer->buf_id] = NULL;41.38 if( buffer->buf_id == (pixbuf_max-1) ) {41.39 - pixbuf_max--;41.40 + pixbuf_max--;41.41 }41.42 }41.44 @@ -123,30 +123,30 @@41.47 if( ah > video_height ) {41.48 - int w = (video_height/0.75);41.49 - x1 = (video_width - w)/2;41.50 - x2 -= x1;41.51 - gdk_gc_set_foreground( gc, &black );41.52 - gdk_gc_set_background( gc, &black );41.53 - gdk_draw_rectangle( gtk_video_drawable->window, gc, TRUE, 0, 0, x1, video_height );41.54 - gdk_draw_rectangle( gtk_video_drawable->window, gc, TRUE, x2, 0, video_width, video_height );41.55 + int w = (video_height/0.75);41.56 + x1 = (video_width - w)/2;41.57 + x2 -= x1;41.58 + gdk_gc_set_foreground( gc, &black );41.59 + gdk_gc_set_background( gc, &black );41.60 + gdk_draw_rectangle( gtk_video_drawable->window, gc, TRUE, 0, 0, x1, video_height );41.61 + gdk_draw_rectangle( gtk_video_drawable->window, gc, TRUE, x2, 0, video_width, video_height );41.62 } else if( ah < video_height ) {41.63 - y1 = (video_height - ah)/2;41.64 - y2 -= y1;41.65 - gdk_gc_set_foreground( gc, &black );41.66 - gdk_gc_set_background( gc, &black );41.67 - gdk_draw_rectangle( gtk_video_drawable->window, gc, TRUE, 0, 0, video_width, y1 );41.68 - gdk_draw_rectangle( gtk_video_drawable->window, gc, TRUE, 0, y2, video_width, video_height );41.69 + y1 = (video_height - ah)/2;41.70 + y2 -= y1;41.71 + gdk_gc_set_foreground( gc, &black );41.72 + gdk_gc_set_background( gc, &black );41.73 + gdk_draw_rectangle( gtk_video_drawable->window, gc, TRUE, 0, 0, video_width, y1 );41.74 + gdk_draw_rectangle( gtk_video_drawable->window, gc, TRUE, 0, y2, video_width, video_height );41.75 }41.76 int w = x2-x1;41.77 int h = y2-y1;41.78 -41.79 +41.80 if( w != buffer->width || h != buffer->height ) {41.81 - gdk_draw_rgb_32_image( gtk_video_drawable->window, gc, x1, y1, buffer->width, buffer->height, GDK_RGB_DITHER_NONE,41.82 - pb, buffer->width*4 );41.83 + gdk_draw_rgb_32_image( gtk_video_drawable->window, gc, x1, y1, buffer->width, buffer->height, GDK_RGB_DITHER_NONE,41.84 + pb, buffer->width*4 );41.85 } else {41.86 - gdk_draw_rgb_32_image( gtk_video_drawable->window, gc, x1, y1, buffer->width, buffer->height, GDK_RGB_DITHER_NONE,41.87 - pb, buffer->width*4 );41.88 + gdk_draw_rgb_32_image( gtk_video_drawable->window, gc, x1, y1, buffer->width, buffer->height, GDK_RGB_DITHER_NONE,41.89 + pb, buffer->width*4 );41.90 }41.91 }41.93 @@ -165,7 +165,7 @@41.94 glFinish();41.95 void *pb = pixbuf_array[buffer->buf_id];41.96 OSMesaMakeCurrent( osmesa_context, pb, GL_UNSIGNED_BYTE,41.97 - buffer->width, buffer->height );41.98 + buffer->width, buffer->height );41.99 //OSMesaPixelStore( OSMESA_Y_UP, 0 );41.100 glViewport( 0, 0, buffer->width, buffer->height );41.101 glDrawBuffer(GL_FRONT);41.102 @@ -177,12 +177,12 @@41.103 glFinish();41.104 void *pb = pixbuf_array[buffer->buf_id];41.105 OSMesaMakeCurrent( osmesa_context, pb, GL_UNSIGNED_BYTE,41.106 - buffer->width, buffer->height );41.107 + buffer->width, buffer->height );41.108 GLenum type = colour_formats[frame->colour_format].type;41.109 GLenum format = colour_formats[frame->colour_format].format;41.110 int bpp = colour_formats[frame->colour_format].bpp;41.111 int rowstride = (frame->rowstride / bpp) - frame->width;41.112 -41.113 +41.114 gl_reset_state();41.115 glPixelStorei( GL_UNPACK_ROW_LENGTH, rowstride );41.116 glRasterPos2f(0.375, frame->height-0.375);41.117 @@ -196,7 +196,7 @@41.118 glFinish();41.119 void *pb = pixbuf_array[buffer->buf_id];41.120 OSMesaMakeCurrent( osmesa_context, pb, GL_UNSIGNED_BYTE,41.121 - buffer->width, buffer->height );41.122 + buffer->width, buffer->height );41.123 glReadBuffer( GL_FRONT );41.124 return gl_read_render_buffer( target, buffer, rowstride, format );
42.1 --- a/src/drivers/video_gl.c Mon Jul 14 07:42:45 2008 +000042.2 +++ b/src/drivers/video_gl.c Mon Jul 14 07:44:42 2008 +000042.3 @@ -55,11 +55,11 @@42.4 {42.5 float top, bottom;42.6 if( inverted ) {42.7 - top = ((float)height);42.8 - bottom = 0;42.9 + top = ((float)height);42.10 + bottom = 0;42.11 } else {42.12 - top = 0;42.13 - bottom = ((float)height);42.14 + top = 0;42.15 + bottom = ((float)height);42.16 }42.18 /* Reset display parameters */42.19 @@ -71,33 +71,33 @@42.20 int ah = video_width * 0.75;42.22 if( ah > video_height ) {42.23 - int w = (video_height/0.75);42.24 - x1 = (video_width - w)/2;42.25 - x2 -= x1;42.26 + int w = (video_height/0.75);42.27 + x1 = (video_width - w)/2;42.28 + x2 -= x1;42.30 - glBegin( GL_QUADS );42.31 - glVertex2f( 0, 0 );42.32 - glVertex2f( x1, 0 );42.33 - glVertex2f( x1, video_height );42.34 - glVertex2f( 0, video_height);42.35 - glVertex2f( x2, 0 );42.36 - glVertex2f( video_width, 0 );42.37 - glVertex2f( video_width, video_height );42.38 - glVertex2f( x2, video_height);42.39 - glEnd();42.40 + glBegin( GL_QUADS );42.41 + glVertex2f( 0, 0 );42.42 + glVertex2f( x1, 0 );42.43 + glVertex2f( x1, video_height );42.44 + glVertex2f( 0, video_height);42.45 + glVertex2f( x2, 0 );42.46 + glVertex2f( video_width, 0 );42.47 + glVertex2f( video_width, video_height );42.48 + glVertex2f( x2, video_height);42.49 + glEnd();42.50 } else if( ah < video_height ) {42.51 - y1 = (video_height - ah)/2;42.52 - y2 -= y1;42.53 - glBegin( GL_QUADS );42.54 - glVertex2f( 0, 0 );42.55 - glVertex2f( video_width, 0 );42.56 - glVertex2f( video_width, y1 );42.57 - glVertex2f( 0, y1 );42.58 - glVertex2f( 0, y2 );42.59 - glVertex2f( video_width, y2 );42.60 - glVertex2f( video_width, video_height );42.61 - glVertex2f( 0, video_height );42.62 - glEnd();42.63 + y1 = (video_height - ah)/2;42.64 + y2 -= y1;42.65 + glBegin( GL_QUADS );42.66 + glVertex2f( 0, 0 );42.67 + glVertex2f( video_width, 0 );42.68 + glVertex2f( video_width, y1 );42.69 + glVertex2f( 0, y1 );42.70 + glVertex2f( 0, y2 );42.71 + glVertex2f( video_width, y2 );42.72 + glVertex2f( video_width, video_height );42.73 + glVertex2f( 0, video_height );42.74 + glEnd();42.75 }42.77 /* Render the textured rectangle */42.78 @@ -128,11 +128,11 @@42.79 GLenum format = colour_formats[frame->colour_format].format;42.80 int bpp = colour_formats[frame->colour_format].bpp;42.81 int rowstride = (frame->rowstride / bpp) - frame->width;42.82 -42.83 +42.84 glPixelStorei( GL_UNPACK_ROW_LENGTH, rowstride );42.85 glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex_id );42.86 glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0,0,42.87 - frame->width, frame->height, format, type, frame->data );42.88 + frame->width, frame->height, format, type, frame->data );42.89 return TRUE;42.90 }42.92 @@ -150,7 +150,7 @@42.93 * there's only one buffer this needs to be wrapped.42.94 */42.95 gboolean gl_read_render_buffer( unsigned char *target, render_buffer_t buffer,42.96 - int rowstride, int colour_format )42.97 + int rowstride, int colour_format )42.98 {42.99 glFinish();42.100 GLenum type = colour_formats[colour_format].type;42.101 @@ -159,7 +159,7 @@42.102 // int size = line_size * buffer->height;42.103 int glrowstride = (rowstride / colour_formats[colour_format].bpp) - buffer->width;42.104 glPixelStorei( GL_PACK_ROW_LENGTH, glrowstride );42.105 -42.106 +42.107 glReadPixels( 0, 0, buffer->width, buffer->height, format, type, target );42.108 return TRUE;42.109 }
43.1 --- a/src/drivers/video_gl.h Mon Jul 14 07:42:45 2008 +000043.2 +++ b/src/drivers/video_gl.h Mon Jul 14 07:44:42 2008 +000043.3 @@ -16,8 +16,12 @@43.4 * GNU General Public License for more details.43.5 */43.7 -#ifndef video_gl_common_H43.8 -#define video_gl_common_H43.9 +#ifndef lxdream_video_gl_H43.10 +#define lxdream_video_gl_H 143.11 +43.12 +#ifdef __cplusplus43.13 +extern "C" {43.14 +#endif43.16 /**43.17 * Generic GL routine to draw the given frame buffer into a texture43.18 @@ -50,7 +54,7 @@43.19 * there's only one buffer this needs to be wrapped.43.20 */43.21 gboolean gl_read_render_buffer( unsigned char *target, render_buffer_t buffer,43.22 - int rowstride, int colour_format );43.23 + int rowstride, int colour_format );43.26 /****** FBO handling (gl_fbo.c) ******/43.27 @@ -59,4 +63,8 @@43.28 void gl_fbo_init( display_driver_t driver );43.29 void gl_fbo_detach();43.31 -#endif /* !video_gl_common_H */43.32 +#ifdef __cplusplus43.33 +}43.34 +#endif43.35 +43.36 +#endif /* !lxdream_video_gl_H */
44.1 --- a/src/drivers/video_glx.c Mon Jul 14 07:42:45 2008 +000044.2 +++ b/src/drivers/video_glx.c Mon Jul 14 07:44:42 2008 +000044.3 @@ -58,7 +58,7 @@44.4 * @return TRUE if supported, otherwise FALSE.44.5 */44.6 gboolean isServerGLXExtensionSupported( Display *display, int screen,44.7 - const char *extension )44.8 + const char *extension )44.9 {44.10 const char *extensions = NULL;44.11 const char *start;44.12 @@ -67,18 +67,18 @@44.13 /* Extension names should not have spaces. */44.14 where = strchr(extension, ' ');44.15 if (where || *extension == '\0')44.16 - return 0;44.17 + return 0;44.18 extensions = glXQueryServerString(display, screen, GLX_EXTENSIONS);44.19 start = extensions;44.20 for (;;) {44.21 - where = strstr((const char *) start, extension);44.22 - if (!where)44.23 - break;44.24 - terminator = where + strlen(extension);44.25 - if (where == start || *(where - 1) == ' ')44.26 - if (*terminator == ' ' || *terminator == '\0')44.27 - return TRUE;44.28 - start = terminator;44.29 + where = strstr((const char *) start, extension);44.30 + if (!where)44.31 + break;44.32 + terminator = where + strlen(extension);44.33 + if (where == start || *(where - 1) == ' ')44.34 + if (*terminator == ' ' || *terminator == '\0')44.35 + return TRUE;44.36 + start = terminator;44.37 }44.38 return FALSE;44.39 }44.40 @@ -95,45 +95,45 @@44.41 if( result != False ) {44.42 glx_version = (major*100) + minor;44.43 }44.44 -44.45 +44.46 glx_fbconfig_supported = (glx_version >= 103 ||44.47 - isServerGLXExtensionSupported(display, screen,44.48 - "GLX_SGIX_fbconfig") );44.49 + isServerGLXExtensionSupported(display, screen,44.50 + "GLX_SGIX_fbconfig") );44.51 glx_pbuffer_supported = (glx_version >= 103 ||44.52 - isServerGLXExtensionSupported(display, screen,44.53 - "GLX_SGIX_pbuffer") );44.54 + isServerGLXExtensionSupported(display, screen,44.55 + "GLX_SGIX_pbuffer") );44.56 if( glx_fbconfig_supported ) {44.57 - int nelem;44.58 + int nelem;44.59 int fb_attribs[] = { GLX_DRAWABLE_TYPE,44.60 - GLX_PBUFFER_BIT|GLX_WINDOW_BIT,44.61 - GLX_RENDER_TYPE, GLX_RGBA_BIT,44.62 - GLX_DEPTH_SIZE, 24, 0 };44.63 - GLXFBConfig *configs = glXChooseFBConfig( display, screen,44.64 - fb_attribs, &nelem );44.65 + GLX_PBUFFER_BIT|GLX_WINDOW_BIT,44.66 + GLX_RENDER_TYPE, GLX_RGBA_BIT,44.67 + GLX_DEPTH_SIZE, 24, 0 };44.68 + GLXFBConfig *configs = glXChooseFBConfig( display, screen,44.69 + fb_attribs, &nelem );44.71 - if( configs == NULL || nelem == 0 ) {44.72 - /* Try a 16-bit depth buffer and see if it helps */44.73 - fb_attribs[5] = 16;44.74 - configs = glXChooseFBConfig( display, screen, fb_attribs, &nelem );44.75 - if( nelem > 0 ) {44.76 + if( configs == NULL || nelem == 0 ) {44.77 + /* Try a 16-bit depth buffer and see if it helps */44.78 + fb_attribs[5] = 16;44.79 + configs = glXChooseFBConfig( display, screen, fb_attribs, &nelem );44.80 + if( nelem > 0 ) {44.81 WARN( "Using a 16-bit depth buffer - expect video glitches" );44.82 }44.84 }44.85 if( configs == NULL || nelem == 0 ) {44.86 - /* Still didn't work. Fallback to 1.2 methods */44.87 - glx_fbconfig_supported = FALSE;44.88 - glx_pbuffer_supported = FALSE;44.89 - } else {44.90 - glx_fbconfig = configs[0];44.91 - glx_visual = glXGetVisualFromFBConfig(display, glx_fbconfig);44.92 - XFree(configs);44.93 - }44.94 + /* Still didn't work. Fallback to 1.2 methods */44.95 + glx_fbconfig_supported = FALSE;44.96 + glx_pbuffer_supported = FALSE;44.97 + } else {44.98 + glx_fbconfig = configs[0];44.99 + glx_visual = glXGetVisualFromFBConfig(display, glx_fbconfig);44.100 + XFree(configs);44.101 + }44.102 }44.104 if( !glx_fbconfig_supported ) {44.105 int attribs[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, 0 };44.106 - glx_visual = glXChooseVisual( display, screen, attribs );44.107 + glx_visual = glXChooseVisual( display, screen, attribs );44.108 if( glx_visual == NULL ) {44.109 /* Try the 16-bit fallback here too */44.110 attribs[2] = 16;44.111 @@ -156,34 +156,34 @@44.112 {44.113 if( glx_fbconfig_supported ) {44.114 glx_context = glXCreateNewContext( display, glx_fbconfig,44.115 - GLX_RGBA_TYPE, NULL, True );44.116 - if( glx_context == NULL ) {44.117 - ERROR( "Unable to create a GLX Context.");44.118 - return FALSE;44.119 - }44.120 + GLX_RGBA_TYPE, NULL, True );44.121 + if( glx_context == NULL ) {44.122 + ERROR( "Unable to create a GLX Context.");44.123 + return FALSE;44.124 + }44.126 - if( glXMakeContextCurrent( display, window, window,44.127 - glx_context ) == False ) {44.128 - ERROR( "Unable to prepare GLX context for drawing" );44.129 - glXDestroyContext( display, glx_context );44.130 - return FALSE;44.131 - }44.132 + if( glXMakeContextCurrent( display, window, window,44.133 + glx_context ) == False ) {44.134 + ERROR( "Unable to prepare GLX context for drawing" );44.135 + glXDestroyContext( display, glx_context );44.136 + return FALSE;44.137 + }44.138 } else {44.139 glx_context = glXCreateContext( display, glx_visual, None, True );44.140 - if( glx_context == NULL ) {44.141 - ERROR( "Unable to create a GLX Context.");44.142 - return FALSE;44.143 - }44.144 -44.145 - if( glXMakeCurrent( display, window, glx_context ) == False ) {44.146 - ERROR( "Unable to prepare GLX context for drawing" );44.147 - glXDestroyContext( display, glx_context );44.148 - return FALSE;44.149 - }44.150 + if( glx_context == NULL ) {44.151 + ERROR( "Unable to create a GLX Context.");44.152 + return FALSE;44.153 + }44.154 +44.155 + if( glXMakeCurrent( display, window, glx_context ) == False ) {44.156 + ERROR( "Unable to prepare GLX context for drawing" );44.157 + glXDestroyContext( display, glx_context );44.158 + return FALSE;44.159 + }44.160 }44.162 if( !glXIsDirect(display, glx_context) ) {44.163 - WARN( "Not using direct rendering - this is likely to be slow" );44.164 + WARN( "Not using direct rendering - this is likely to be slow" );44.165 }44.167 video_x11_display = display;44.168 @@ -195,13 +195,13 @@44.169 gboolean video_glx_init_driver( display_driver_t driver )44.170 {44.171 if( gl_fbo_is_supported() ) { // First preference44.172 - gl_fbo_init(driver);44.173 + gl_fbo_init(driver);44.174 } else if( glx_pbuffer_supported ) {44.175 - glx_pbuffer_init(driver);44.176 + glx_pbuffer_init(driver);44.177 } else {44.178 ERROR( "Unable to create render buffers (requires either EXT_framebuffer_object or GLX 1.3+)" );44.179 video_glx_shutdown();44.180 - return FALSE;44.181 + return FALSE;44.182 }44.183 return TRUE;44.184 }44.185 @@ -209,15 +209,15 @@44.187 void video_glx_shutdown()44.188 {44.189 - // texcache_gl_shutdown();44.190 + // texcache_gl_shutdown();44.191 glx_is_initialized = FALSE;44.192 if( glx_context != NULL ) {44.193 glXDestroyContext( video_x11_display, glx_context );44.194 - glx_context = NULL;44.195 + glx_context = NULL;44.196 }44.197 if( glx_visual != NULL ) {44.198 XFree(glx_visual);44.199 - glx_visual = NULL;44.200 + glx_visual = NULL;44.201 }44.202 }44.204 @@ -233,8 +233,8 @@44.205 int lists;44.206 XFontStruct *font = XLoadQueryFont(video_x11_display, font_name );44.207 if (font == NULL)44.208 - return -1;44.209 -44.210 + return -1;44.211 +44.212 lists = glGenLists(96);44.213 glXUseXFont(font->fid, 32, 96, lists);44.214 XFreeFont(video_x11_display, font);44.215 @@ -279,11 +279,11 @@44.216 static render_buffer_t glx_pbuffer_create_render_buffer( uint32_t width, uint32_t height )44.217 {44.218 int attribs[] = { GLX_PBUFFER_WIDTH, width, GLX_PBUFFER_HEIGHT, height,44.219 - GLX_PRESERVED_CONTENTS, True, 0 };44.220 + GLX_PRESERVED_CONTENTS, True, 0 };44.221 GLXPbuffer pb = glXCreatePbuffer( video_x11_display, glx_fbconfig, attribs );44.222 if( pb == (GLXPbuffer)NULL ) {44.223 - ERROR( "Unable to create pbuffer" );44.224 - return NULL;44.225 + ERROR( "Unable to create pbuffer" );44.226 + return NULL;44.227 }44.228 render_buffer_t buffer = calloc( sizeof(struct render_buffer), 1 );44.229 buffer->width = width;44.230 @@ -303,12 +303,12 @@44.231 {44.232 glFinish();44.233 if( glXMakeContextCurrent( video_x11_display, (GLXPbuffer)buffer->buf_id, (GLXPbuffer)buffer->buf_id, glx_context ) == False ) {44.234 - ERROR( "Make context current (pbuffer) failed!" );44.235 + ERROR( "Make context current (pbuffer) failed!" );44.236 }44.237 /* setup the gl context */44.238 glViewport( 0, 0, buffer->width, buffer->height );44.239 glDrawBuffer(GL_FRONT);44.240 -44.241 +44.242 return TRUE;44.243 }44.245 @@ -336,7 +336,7 @@44.246 GLenum format = colour_formats[frame->colour_format].format;44.247 int bpp = colour_formats[frame->colour_format].bpp;44.248 int rowstride = (frame->rowstride / bpp) - frame->width;44.249 -44.250 +44.251 gl_reset_state();44.252 glPixelStorei( GL_UNPACK_ROW_LENGTH, rowstride );44.253 glRasterPos2f(0.375, frame->height-0.375);44.254 @@ -353,7 +353,7 @@44.255 }44.257 static gboolean glx_pbuffer_read_render_buffer( unsigned char *target, render_buffer_t buffer,44.258 - int rowstride, int format )44.259 + int rowstride, int format )44.260 {44.261 glXMakeCurrent( video_x11_display, (GLXDrawable)buffer->buf_id, glx_context );44.262 glReadBuffer( GL_FRONT );
45.1 --- a/src/drivers/video_glx.h Mon Jul 14 07:42:45 2008 +000045.2 +++ b/src/drivers/video_glx.h Mon Jul 14 07:44:42 2008 +000045.3 @@ -16,12 +16,16 @@45.4 * GNU General Public License for more details.45.5 */45.7 -#ifndef video_glx_driver_H45.8 -#define video_glx_driver_H45.9 +#ifndef lxdream_video_glx_H45.10 +#define lxdream_video_glx_H 145.12 #include "X11/Xlib.h"45.13 #include "display.h"45.15 +#ifdef __cplusplus45.16 +extern "C" {45.17 +#endif45.18 +45.19 /**45.20 * Initialize GLX support. Detect capabilities, visuals, etc.45.21 * Must be called before any other GLX functions45.22 @@ -52,4 +56,8 @@45.23 */45.24 void video_glx_shutdown();45.26 +#ifdef __cplusplus45.27 +}45.28 #endif45.29 +45.30 +#endif
46.1 --- a/src/drivers/video_gtk.c Mon Jul 14 07:42:45 2008 +000046.2 +++ b/src/drivers/video_gtk.c Mon Jul 14 07:44:42 2008 +000046.3 @@ -37,18 +37,18 @@46.5 guint gdk_keycode_to_modifier( GdkDisplay *display, guint keycode )46.6 {46.7 - int i;46.8 - int result = 0;46.9 - Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);46.10 - XModifierKeymap *keymap = XGetModifierMapping( xdisplay );46.11 - for( i=0; i<8*keymap->max_keypermod; i++ ) {46.12 - if( keymap->modifiermap[i] == keycode ) {46.13 - result = 1 << (i/keymap->max_keypermod);46.14 - break;46.15 + int i;46.16 + int result = 0;46.17 + Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);46.18 + XModifierKeymap *keymap = XGetModifierMapping( xdisplay );46.19 + for( i=0; i<8*keymap->max_keypermod; i++ ) {46.20 + if( keymap->modifiermap[i] == keycode ) {46.21 + result = 1 << (i/keymap->max_keypermod);46.22 + break;46.23 + }46.24 }46.25 - }46.26 - XFreeModifiermap(keymap);46.27 - return result;46.28 + XFreeModifiermap(keymap);46.29 + return result;46.30 }46.32 #if !(GTK_CHECK_VERSION(2,8,0))46.33 @@ -84,17 +84,17 @@46.34 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.46.35 */46.36 void gdk_display_warp_pointer (GdkDisplay *display,46.37 - GdkScreen *screen,46.38 - gint x,46.39 - gint y)46.40 + GdkScreen *screen,46.41 + gint x,46.42 + gint y)46.43 {46.44 - Display *xdisplay;46.45 - Window dest;46.46 + Display *xdisplay;46.47 + Window dest;46.49 - xdisplay = GDK_DISPLAY_XDISPLAY (display);46.50 - dest = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen));46.51 + xdisplay = GDK_DISPLAY_XDISPLAY (display);46.52 + dest = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen));46.54 - XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0, x, y);46.55 + XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0, x, y);46.56 }46.58 #endif46.59 @@ -109,7 +109,7 @@46.61 guint gdk_keycode_to_modifier( GdkDisplay *display, guint keycode )46.62 {46.63 - return 0;46.64 + return 0;46.65 }46.67 #endif46.68 @@ -136,12 +136,12 @@46.69 NULL,46.70 NULL, NULL, NULL, NULL, NULL,46.71 video_gtk_display_blank, NULL };46.72 -46.73 +46.74 uint16_t video_gtk_resolve_keysym( const gchar *keysym )46.75 {46.76 int val = gdk_keyval_from_name( keysym );46.77 if( val == GDK_VoidSymbol )46.78 - return 0;46.79 + return 0;46.80 return (uint16_t)val;46.81 }46.83 @@ -162,9 +162,9 @@46.84 uint16_t video_gtk_keycode_to_dckeysym(uint16_t keycode)46.85 {46.86 if( keycode >= 'a' && keycode <= 'z' ) {46.87 - return (keycode - 'a') + DCKB_a;46.88 + return (keycode - 'a') + DCKB_a;46.89 } else if( keycode >= '1' && keycode <= '9' ) {46.90 - return (keycode - '1') + DCKB_1;46.91 + return (keycode - '1') + DCKB_1;46.92 }46.93 switch(keycode) {46.94 case GDK_0: return DCKB_0;46.95 @@ -244,9 +244,9 @@46.96 GTK_WIDGET_SET_FLAGS(drawable, GTK_CAN_FOCUS|GTK_CAN_DEFAULT);46.98 g_signal_connect( drawable, "expose_event",46.99 - G_CALLBACK(video_gtk_expose_callback), NULL );46.100 + G_CALLBACK(video_gtk_expose_callback), NULL );46.101 g_signal_connect( drawable, "configure_event",46.102 - G_CALLBACK(video_gtk_resize_callback), NULL );46.103 + G_CALLBACK(video_gtk_resize_callback), NULL );46.105 #ifdef HAVE_GLX46.106 Display *display = gdk_x11_display_get_xdisplay( gtk_widget_get_display(drawable));46.107 @@ -270,9 +270,9 @@46.109 gboolean video_gtk_init()46.110 {46.111 -46.112 +46.113 if( gtk_video_drawable == NULL ) {46.114 - return FALSE;46.115 + return FALSE;46.116 }46.118 video_width = gtk_video_drawable->allocation.width;46.119 @@ -284,21 +284,21 @@46.120 Display *display = gdk_x11_display_get_xdisplay( gtk_widget_get_display(GTK_WIDGET(gtk_video_drawable)));46.121 Window window = GDK_WINDOW_XWINDOW( GTK_WIDGET(gtk_video_drawable)->window );46.122 if( ! video_glx_init_context( display, window ) ||46.123 - ! video_glx_init_driver( &display_gtk_driver ) ) {46.124 + ! video_glx_init_driver( &display_gtk_driver ) ) {46.125 return FALSE;46.126 }46.127 #else46.128 #ifdef HAVE_NSGL46.129 NSView *view = gdk_quartz_window_get_nsview(gtk_video_drawable->window);46.130 if( ! video_nsgl_init_driver( view, &display_gtk_driver ) ) {46.131 - return FALSE;46.132 + return FALSE;46.133 }46.134 #endif46.135 #endif46.136 #endif46.138 pvr2_setup_gl_context();46.139 -46.140 +46.141 #ifdef HAVE_LINUX_JOYSTICK46.142 linux_joystick_init();46.143 #endif46.144 @@ -325,10 +325,10 @@46.145 video_gdk_shutdown();46.146 #else46.147 #ifdef HAVE_GLX46.148 - video_glx_shutdown();46.149 + video_glx_shutdown();46.150 #else46.151 #ifdef HAVE_NSGL46.152 - video_nsgl_shutdown();46.153 + video_nsgl_shutdown();46.154 #endif46.155 #endif46.156 #endif
47.1 --- a/src/drivers/video_nsgl.c Mon Jul 14 07:42:45 2008 +000047.2 +++ b/src/drivers/video_nsgl.c Mon Jul 14 07:44:42 2008 +000047.3 @@ -26,27 +26,27 @@47.4 gboolean video_nsgl_init_driver( NSView *view, display_driver_t driver )47.5 {47.6 NSAutoreleasePool *pool = [NSAutoreleasePool new];47.7 - NSOpenGLPixelFormatAttribute attributes[] = {47.8 - NSOpenGLPFAWindow,47.9 -// NSOpenGLPFADoubleBuffer,47.10 - NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24,47.11 - (NSOpenGLPixelFormatAttribute)nil };47.12 -47.13 - NSOpenGLPixelFormat *pixelFormat =47.14 - [[[NSOpenGLPixelFormat alloc] initWithAttributes: attributes] autorelease];47.15 - nsgl_context =47.16 - [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: nil];47.17 - [nsgl_context setView: view];47.18 - [nsgl_context makeCurrentContext];47.19 - [pool release];47.20 - if( gl_fbo_is_supported() ) {47.21 - gl_fbo_init(driver);47.22 - } else {47.23 - ERROR( "FBO not supported" );47.24 - return FALSE;47.25 - }47.26 + NSOpenGLPixelFormatAttribute attributes[] = {47.27 + NSOpenGLPFAWindow,47.28 + // NSOpenGLPFADoubleBuffer,47.29 + NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24,47.30 + (NSOpenGLPixelFormatAttribute)nil };47.32 - return TRUE;47.33 + NSOpenGLPixelFormat *pixelFormat =47.34 + [[[NSOpenGLPixelFormat alloc] initWithAttributes: attributes] autorelease];47.35 + nsgl_context =47.36 + [[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: nil];47.37 + [nsgl_context setView: view];47.38 + [nsgl_context makeCurrentContext];47.39 + [pool release];47.40 + if( gl_fbo_is_supported() ) {47.41 + gl_fbo_init(driver);47.42 + } else {47.43 + ERROR( "FBO not supported" );47.44 + return FALSE;47.45 + }47.46 +47.47 + return TRUE;47.48 }47.50 void video_nsgl_update()47.51 @@ -72,9 +72,9 @@47.53 void video_nsgl_shutdown()47.54 {47.55 - if( nsgl_context != nil ) {47.56 - [NSOpenGLContext clearCurrentContext];47.57 - [nsgl_context release];47.58 - nsgl_context = nil;47.59 - }47.60 + if( nsgl_context != nil ) {47.61 + [NSOpenGLContext clearCurrentContext];47.62 + [nsgl_context release];47.63 + nsgl_context = nil;47.64 + }47.65 }
48.1 --- a/src/drivers/video_nsgl.h Mon Jul 14 07:42:45 2008 +000048.2 +++ b/src/drivers/video_nsgl.h Mon Jul 14 07:44:42 2008 +000048.3 @@ -16,12 +16,16 @@48.4 * GNU General Public License for more details.48.5 */48.7 -#ifndef video_nsgl_H48.8 -#define video_nsgl_H48.9 +#ifndef lxdream_video_nsgl_H48.10 +#define lxdream_video_nsgl_H 148.12 #include <AppKit/NSView.h>48.13 #include "display.h"48.15 +#ifdef __cplusplus48.16 +extern "C" {48.17 +#endif48.18 +48.19 /**48.20 * Initialize the display driver by setting the appropriate methods48.21 * for NSGL support48.22 @@ -38,4 +42,8 @@48.23 */48.24 void video_nsgl_swap_buffers();48.26 +#ifdef __cplusplus48.27 +}48.28 +#endif48.29 +48.30 #endif /* !video_nsgl_H */48.31 \ No newline at end of file
49.1 --- a/src/drivers/video_null.c Mon Jul 14 07:42:45 2008 +000049.2 +++ b/src/drivers/video_null.c Mon Jul 14 07:44:42 2008 +000049.3 @@ -1,6 +1,3 @@49.4 -49.5 -49.6 -49.7 /**49.8 * $Id$49.9 *49.10 @@ -40,14 +37,14 @@49.11 }49.13 static gboolean video_null_read_render_buffer( unsigned char *target,49.14 - render_buffer_t buffer,49.15 - int rowstride, int format )49.16 + render_buffer_t buffer,49.17 + int rowstride, int format )49.18 {49.19 return TRUE;49.20 }49.22 static void video_null_load_frame_buffer( frame_buffer_t frame,49.23 - render_buffer_t buffer )49.24 + render_buffer_t buffer )49.25 {49.26 }
50.1 --- a/src/drivers/video_osx.c Mon Jul 14 07:42:45 2008 +000050.2 +++ b/src/drivers/video_osx.c Mon Jul 14 07:44:42 2008 +000050.3 @@ -81,15 +81,15 @@50.4 }50.5 - (BOOL)isOpaque50.6 {50.7 - return YES;50.8 + return YES;50.9 }50.10 - (BOOL)acceptsFirstResponder50.11 {50.12 - return YES;50.13 + return YES;50.14 }50.15 - (BOOL)isFlipped50.16 {50.17 - return YES;50.18 + return YES;50.19 }50.20 //--------------------------------------------------------------------50.21 - (void)drawRect: (NSRect) rect50.22 @@ -122,7 +122,7 @@50.23 CGAssociateMouseAndMouseCursorPosition(YES);50.24 [((LxdreamMainWindow *)[self window]) setIsGrabbed: NO];50.25 }50.26 -50.27 +50.28 if( flagsMask[keycode] == 0 ) {50.29 input_event_keydown( NULL, keycode+1, 1 );50.30 flagsMask[keycode] = 1;50.31 @@ -206,14 +206,14 @@50.33 static gboolean video_osx_init()50.34 {50.35 - if( video_view == NULL ) {50.36 - return FALSE;50.37 - }50.38 - if( !video_nsgl_init_driver(video_view, &display_osx_driver) ) {50.39 - return FALSE;50.40 - }50.41 - pvr2_setup_gl_context();50.42 - return TRUE;50.43 + if( video_view == NULL ) {50.44 + return FALSE;50.45 + }50.46 + if( !video_nsgl_init_driver(video_view, &display_osx_driver) ) {50.47 + return FALSE;50.48 + }50.49 + pvr2_setup_gl_context();50.50 + return TRUE;50.51 }50.53 static void video_osx_shutdown()
51.1 --- a/src/eventq.c Mon Jul 14 07:42:45 2008 +000051.2 +++ b/src/eventq.c Mon Jul 14 07:44:42 2008 +000051.3 @@ -20,6 +20,7 @@51.4 */51.6 #include <assert.h>51.7 +#include "dream.h"51.8 #include "dreamcast.h"51.9 #include "eventq.h"51.10 #include "asic.h"51.11 @@ -53,29 +54,29 @@51.12 int event_load_state( FILE * f );51.14 struct dreamcast_module eventq_module = { "EVENTQ", event_init, event_reset, NULL, event_run_slice,51.15 - NULL, event_save_state, event_load_state };51.16 + NULL, event_save_state, event_load_state };51.18 static void event_update_pending( )51.19 {51.20 if( event_head == NULL ) {51.21 - if( !(sh4r.event_types & PENDING_IRQ) ) {51.22 - sh4r.event_pending = NOT_SCHEDULED;51.23 - }51.24 - sh4r.event_types &= (~PENDING_EVENT);51.25 + if( !(sh4r.event_types & PENDING_IRQ) ) {51.26 + sh4r.event_pending = NOT_SCHEDULED;51.27 + }51.28 + sh4r.event_types &= (~PENDING_EVENT);51.29 } else {51.30 - if( !(sh4r.event_types & PENDING_IRQ) ) {51.31 - sh4r.event_pending = event_head->nanosecs;51.32 - }51.33 - sh4r.event_types |= PENDING_EVENT;51.34 + if( !(sh4r.event_types & PENDING_IRQ) ) {51.35 + sh4r.event_pending = event_head->nanosecs;51.36 + }51.37 + sh4r.event_types |= PENDING_EVENT;51.38 }51.39 }51.41 uint32_t event_get_next_time( )51.42 {51.43 if( event_head == NULL ) {51.44 - return NOT_SCHEDULED;51.45 + return NOT_SCHEDULED;51.46 } else {51.47 - return event_head->nanosecs;51.48 + return event_head->nanosecs;51.49 }51.50 }51.52 @@ -85,61 +86,61 @@51.53 static void event_enqueue( event_t event )51.54 {51.55 if( event_head == NULL || event->nanosecs < event_head->nanosecs ) {51.56 - event->next = event_head;51.57 - event_head = event;51.58 - event_update_pending();51.59 + event->next = event_head;51.60 + event_head = event;51.61 + event_update_pending();51.62 } else {51.63 - event_t cur = event_head;51.64 - event_t next = cur->next;51.65 - while( next != NULL && event->nanosecs >= next->nanosecs ) {51.66 - cur = next;51.67 - next = cur->next;51.68 - }51.69 - event->next = next;51.70 - cur->next = event;51.71 + event_t cur = event_head;51.72 + event_t next = cur->next;51.73 + while( next != NULL && event->nanosecs >= next->nanosecs ) {51.74 + cur = next;51.75 + next = cur->next;51.76 + }51.77 + event->next = next;51.78 + cur->next = event;51.79 }51.80 }51.82 static void event_dequeue( event_t event )51.83 {51.84 if( event_head == NULL ) {51.85 - ERROR( "Empty event queue but should contain event %d", event->id );51.86 + ERROR( "Empty event queue but should contain event %d", event->id );51.87 } else if( event_head == event ) {51.88 - /* removing queue head */51.89 - event_head = event_head->next;51.90 - event_update_pending();51.91 + /* removing queue head */51.92 + event_head = event_head->next;51.93 + event_update_pending();51.94 } else {51.95 - event_t cur = event_head;51.96 - event_t next = cur->next;51.97 - while( next != NULL ) {51.98 - if( next == event ) {51.99 - cur->next = next->next;51.100 - break;51.101 - }51.102 - cur = next;51.103 - next = cur->next;51.104 - }51.105 + event_t cur = event_head;51.106 + event_t next = cur->next;51.107 + while( next != NULL ) {51.108 + if( next == event ) {51.109 + cur->next = next->next;51.110 + break;51.111 + }51.112 + cur = next;51.113 + next = cur->next;51.114 + }51.115 }51.116 }51.118 static void event_dequeue_long( event_t event )51.119 {51.120 if( long_event_head == NULL ) {51.121 - ERROR( "Empty long event queue but should contain event %d", event->id );51.122 + ERROR( "Empty long event queue but should contain event %d", event->id );51.123 } else if( long_event_head == event ) {51.124 - /* removing queue head */51.125 - long_event_head = long_event_head->next;51.126 + /* removing queue head */51.127 + long_event_head = long_event_head->next;51.128 } else {51.129 - event_t cur = long_event_head;51.130 - event_t next = cur->next;51.131 - while( next != NULL ) {51.132 - if( next == event ) {51.133 - cur->next = next->next;51.134 - break;51.135 - }51.136 - cur = next;51.137 - next = cur->next;51.138 - }51.139 + event_t cur = long_event_head;51.140 + event_t next = cur->next;51.141 + while( next != NULL ) {51.142 + if( next == event ) {51.143 + cur->next = next->next;51.144 + break;51.145 + }51.146 + cur = next;51.147 + next = cur->next;51.148 + }51.149 }51.150 }51.152 @@ -155,49 +156,49 @@51.153 event_t event = &events[eventid];51.155 if( event->nanosecs != NOT_SCHEDULED ) {51.156 - /* Event is already scheduled. Remove it from the list first */51.157 - event_cancel(eventid);51.158 + /* Event is already scheduled. Remove it from the list first */51.159 + event_cancel(eventid);51.160 }51.162 event->id = eventid;51.163 event->seconds = 0;51.164 event->nanosecs = nanosecs;51.165 -51.166 +51.167 event_enqueue( event );51.168 }51.170 void event_schedule_long( int eventid, uint32_t seconds, uint32_t nanosecs ) {51.171 if( seconds == 0 ) {51.172 - event_schedule( eventid, nanosecs );51.173 + event_schedule( eventid, nanosecs );51.174 } else {51.175 - event_t event = &events[eventid];51.176 + event_t event = &events[eventid];51.178 - if( event->nanosecs != NOT_SCHEDULED ) {51.179 - /* Event is already scheduled. Remove it from the list first */51.180 - event_cancel(eventid);51.181 - }51.182 + if( event->nanosecs != NOT_SCHEDULED ) {51.183 + /* Event is already scheduled. Remove it from the list first */51.184 + event_cancel(eventid);51.185 + }51.187 - event->id = eventid;51.188 - event->seconds = seconds;51.189 - event->nanosecs = nanosecs;51.190 - event->next = long_event_head;51.191 - long_event_head = event;51.192 + event->id = eventid;51.193 + event->seconds = seconds;51.194 + event->nanosecs = nanosecs;51.195 + event->next = long_event_head;51.196 + long_event_head = event;51.197 }51.198 -51.199 +51.200 }51.202 void event_cancel( int eventid )51.203 {51.204 event_t event = &events[eventid];51.205 if( event->nanosecs == NOT_SCHEDULED ) {51.206 - return; /* not scheduled */51.207 + return; /* not scheduled */51.208 } else {51.209 - event->nanosecs = NOT_SCHEDULED;51.210 - if( event->seconds != 0 ) { /* long term event */51.211 - event_dequeue_long( event );51.212 - } else {51.213 - event_dequeue( event );51.214 - }51.215 + event->nanosecs = NOT_SCHEDULED;51.216 + if( event->seconds != 0 ) { /* long term event */51.217 + event_dequeue_long( event );51.218 + } else {51.219 + event_dequeue( event );51.220 + }51.221 }51.222 }51.224 @@ -206,12 +207,12 @@51.225 {51.226 /* Loop in case we missed some or got a couple scheduled for the same time */51.227 while( event_head != NULL && event_head->nanosecs <= sh4r.slice_cycle ) {51.228 - event_t event = event_head;51.229 - event_head = event->next;51.230 - event->nanosecs = NOT_SCHEDULED;51.231 - // Note: Make sure the internal state is consistent before calling the51.232 - // user function, as it will (quite likely) enqueue another event.51.233 - event->func( event->id );51.234 + event_t event = event_head;51.235 + event_head = event->next;51.236 + event->nanosecs = NOT_SCHEDULED;51.237 + // Note: Make sure the internal state is consistent before calling the51.238 + // user function, as it will (quite likely) enqueue another event.51.239 + event->func( event->id );51.240 }51.242 event_update_pending();51.243 @@ -226,14 +227,14 @@51.244 {51.245 int i;51.246 for( i=0; i<MAX_EVENT_ID; i++ ) {51.247 - events[i].id = i;51.248 - events[i].nanosecs = NOT_SCHEDULED;51.249 - if( i < 96 ) {51.250 - events[i].func = event_asic_callback;51.251 - } else {51.252 - events[i].func = NULL;51.253 - }51.254 - events[i].next = NULL;51.255 + events[i].id = i;51.256 + events[i].nanosecs = NOT_SCHEDULED;51.257 + if( i < 96 ) {51.258 + events[i].func = event_asic_callback;51.259 + } else {51.260 + events[i].func = NULL;51.261 + }51.262 + events[i].next = NULL;51.263 }51.264 event_head = NULL;51.265 long_event_head = NULL;51.266 @@ -249,7 +250,7 @@51.267 long_event_head = NULL;51.268 long_scan_time_remaining = LONG_SCAN_PERIOD;51.269 for( i=0; i<MAX_EVENT_ID; i++ ) {51.270 - events[i].nanosecs = NOT_SCHEDULED;51.271 + events[i].nanosecs = NOT_SCHEDULED;51.272 }51.273 }51.275 @@ -262,9 +263,9 @@51.276 fwrite( &id, sizeof(id), 1, f );51.277 fwrite( &long_scan_time_remaining, sizeof(long_scan_time_remaining), 1, f );51.278 for( i=0; i<MAX_EVENT_ID; i++ ) {51.279 - fwrite( &events[i].id, sizeof(uint32_t), 3, f ); /* First 3 words from structure */51.280 - id = events[i].next == NULL ? -1 : events[i].next->id;51.281 - fwrite( &id, sizeof(id), 1, f );51.282 + fwrite( &events[i].id, sizeof(uint32_t), 3, f ); /* First 3 words from structure */51.283 + id = events[i].next == NULL ? -1 : events[i].next->id;51.284 + fwrite( &id, sizeof(id), 1, f );51.285 }51.286 }51.288 @@ -277,9 +278,9 @@51.289 long_event_head = id == -1 ? NULL : &events[id];51.290 fread( &long_scan_time_remaining, sizeof(long_scan_time_remaining), 1, f );51.291 for( i=0; i<MAX_EVENT_ID; i++ ) {51.292 - fread( &events[i].id, sizeof(uint32_t), 3, f );51.293 - fread( &id, sizeof(id), 1, f );51.294 - events[i].next = id == -1 ? NULL : &events[id];51.295 + fread( &events[i].id, sizeof(uint32_t), 3, f );51.296 + fread( &id, sizeof(id), 1, f );51.297 + events[i].next = id == -1 ? NULL : &events[id];51.298 }51.299 return 0;51.300 }51.301 @@ -291,23 +292,23 @@51.302 static void event_scan_long()51.303 {51.304 while( long_event_head != NULL && --long_event_head->seconds == 0 ) {51.305 - event_t event = long_event_head;51.306 - long_event_head = event->next;51.307 - event_enqueue(event);51.308 + event_t event = long_event_head;51.309 + long_event_head = event->next;51.310 + event_enqueue(event);51.311 }51.313 if( long_event_head != NULL ) {51.314 - event_t last = long_event_head;51.315 - event_t cur = last->next;51.316 - while( cur != NULL ) {51.317 - if( --cur->seconds == 0 ) {51.318 - last->next = cur->next;51.319 - event_enqueue(cur);51.320 - } else {51.321 - last = cur;51.322 - }51.323 - cur = last->next;51.324 - }51.325 + event_t last = long_event_head;51.326 + event_t cur = last->next;51.327 + while( cur != NULL ) {51.328 + if( --cur->seconds == 0 ) {51.329 + last->next = cur->next;51.330 + event_enqueue(cur);51.331 + } else {51.332 + last = cur;51.333 + }51.334 + cur = last->next;51.335 + }51.336 }51.337 }51.339 @@ -320,18 +321,18 @@51.340 {51.341 event_t event = event_head;51.342 while( event != NULL ) {51.343 - if( event->nanosecs <= nanosecs ) {51.344 - event->nanosecs = 0;51.345 - } else {51.346 - event->nanosecs -= nanosecs;51.347 - }51.348 - event = event->next;51.349 + if( event->nanosecs <= nanosecs ) {51.350 + event->nanosecs = 0;51.351 + } else {51.352 + event->nanosecs -= nanosecs;51.353 + }51.354 + event = event->next;51.355 }51.357 long_scan_time_remaining -= nanosecs;51.358 if( long_scan_time_remaining <= 0 ) {51.359 - long_scan_time_remaining += LONG_SCAN_PERIOD;51.360 - event_scan_long();51.361 + long_scan_time_remaining += LONG_SCAN_PERIOD;51.362 + event_scan_long();51.363 }51.365 event_update_pending();
52.1 --- a/src/eventq.h Mon Jul 14 07:42:45 2008 +000052.2 +++ b/src/eventq.h Mon Jul 14 07:44:42 2008 +000052.3 @@ -19,7 +19,14 @@52.4 * GNU General Public License for more details.52.5 */52.7 -#include "dream.h"52.8 +#ifndef lxdream_eventq_H52.9 +#define lxdream_eventq_H 152.10 +52.11 +#include "lxdream.h"52.12 +52.13 +#ifdef __cplusplus52.14 +extern "C" {52.15 +#endif52.17 #define NOT_SCHEDULED 0xFFFFFFFF /* Sentinel value */52.19 @@ -71,3 +78,9 @@52.20 #define EVENT_TMU0 9752.21 #define EVENT_TMU1 9852.22 #define EVENT_TMU2 9952.23 +52.24 +#ifdef __cplusplus52.25 +}52.26 +#endif52.27 +52.28 +#endif /* !lxdream_eventq_H */
53.1 --- a/src/gdlist.c Mon Jul 14 07:42:45 2008 +000053.2 +++ b/src/gdlist.c Mon Jul 14 07:44:42 2008 +000053.3 @@ -126,7 +126,7 @@53.4 list_changed = TRUE;53.5 }53.6 }53.7 -53.8 +53.9 lxdream_set_global_config_value( CONFIG_GDROM, disc_name );53.10 lxdream_save_config();53.12 @@ -159,7 +159,7 @@53.13 }53.14 gdrom_device_count = g_list_length(gdrom_device_list);53.15 gdrom_recent_count = g_list_length(gdrom_recent_list);53.16 -53.17 +53.18 // Run the hooks in case anyone registered before the list was initialized53.19 CALL_HOOKS( gdrom_list_change_hook, TRUE, gdrom_list_get_selection() );53.20 }53.21 @@ -170,18 +170,18 @@53.22 gdrom_unmount_disc();53.23 return TRUE;53.24 }53.25 -53.26 +53.27 if( posn <= gdrom_device_count ) {53.28 gdrom_device_t device = g_list_nth_data(gdrom_device_list, posn-1);53.29 return gdrom_mount_image(device->name);53.30 }53.31 -53.32 +53.33 posn -= FIRST_RECENT_INDEX;53.34 if( posn >= 0 && posn < gdrom_recent_count ) {53.35 gchar *entry = g_list_nth_data(gdrom_recent_list, posn);53.36 return gdrom_mount_image(entry);53.37 }53.38 -53.39 +53.40 return FALSE;53.41 }53.43 @@ -205,16 +205,16 @@53.44 if( posn == 0 ) {53.45 return _("Empty");53.46 }53.47 -53.48 +53.49 if( posn <= gdrom_device_count ) {53.50 gdrom_device_t device = g_list_nth_data(gdrom_device_list, posn-1);53.51 return device->device_name;53.52 }53.53 -53.54 +53.55 if( posn == gdrom_device_count + 1) {53.56 return "";53.57 }53.58 -53.59 +53.60 if( posn < 0 || posn > gdrom_list_size() ) {53.61 return NULL;53.62 }53.63 @@ -225,22 +225,22 @@53.65 const gchar *gdrom_list_get_filename( int posn )53.66 {53.67 - if( posn == 0 ) {53.68 - return _("Empty");53.69 - }53.70 -53.71 - if( posn <= gdrom_device_count ) {53.72 - gdrom_device_t device = g_list_nth_data(gdrom_device_list, posn-1);53.73 - return device->name;53.74 - }53.75 -53.76 - if( posn == gdrom_device_count + 1) {53.77 - return "";53.78 - }53.79 -53.80 - if( posn < 0 || posn > gdrom_list_size() ) {53.81 - return NULL;53.82 - }53.83 + if( posn == 0 ) {53.84 + return _("Empty");53.85 + }53.87 - return g_list_nth_data(gdrom_recent_list, posn-FIRST_RECENT_INDEX);53.88 + if( posn <= gdrom_device_count ) {53.89 + gdrom_device_t device = g_list_nth_data(gdrom_device_list, posn-1);53.90 + return device->name;53.91 + }53.92 +53.93 + if( posn == gdrom_device_count + 1) {53.94 + return "";53.95 + }53.96 +53.97 + if( posn < 0 || posn > gdrom_list_size() ) {53.98 + return NULL;53.99 + }53.100 +53.101 + return g_list_nth_data(gdrom_recent_list, posn-FIRST_RECENT_INDEX);53.102 }
54.1 --- a/src/gdlist.h Mon Jul 14 07:42:45 2008 +000054.2 +++ b/src/gdlist.h Mon Jul 14 07:44:42 2008 +000054.3 @@ -22,6 +22,10 @@54.5 #include "hook.h"54.7 +#ifdef __cplusplus54.8 +extern "C" {54.9 +#endif54.10 +54.11 typedef gboolean (*gdrom_list_change_hook_t)(gboolean list_changed, int selection, void *user_data);54.12 DECLARE_HOOK(gdrom_list_change_hook, gdrom_list_change_hook_t);54.14 @@ -64,4 +68,8 @@54.15 */54.16 gboolean gdrom_list_set_selection(int posn);54.18 +#ifdef __cplusplus54.19 +}54.20 +#endif54.21 +54.22 #endif /* lxdream_gdlist_H */
55.1 --- a/src/gdrom/cdi.c Mon Jul 14 07:42:45 2008 +000055.2 +++ b/src/gdrom/cdi.c Mon Jul 14 07:44:42 2008 +000055.3 @@ -33,10 +33,10 @@55.4 static gdrom_disc_t cdi_image_open( const gchar *filename, FILE *f );55.6 struct gdrom_image_class cdi_image_class = { "DiscJuggler", "cdi",55.7 - cdi_image_is_valid, cdi_image_open };55.8 + cdi_image_is_valid, cdi_image_open };55.10 static const char TRACK_START_MARKER[20] = { 0,0,1,0,0,0,255,255,255,255,55.11 - 0,0,1,0,0,0,255,255,255,255 };55.12 + 0,0,1,0,0,0,255,255,255,255 };55.13 static const char EXT_MARKER[9] = {0,255,255,255,255,255,255,255,255 };55.15 struct cdi_trailer {55.16 @@ -66,10 +66,10 @@55.17 len = ftell(f)+8;55.18 fread( &trail, sizeof(trail), 1, f );55.19 if( trail.header_offset >= len ||55.20 - trail.header_offset == 0 )55.21 - return FALSE;55.22 + trail.header_offset == 0 )55.23 + return FALSE;55.24 return trail.cdi_version == CDI_V2_ID || trail.cdi_version == CDI_V3_ID ||55.25 - trail.cdi_version == CDI_V35_ID;55.26 + trail.cdi_version == CDI_V35_ID;55.27 }55.29 gdrom_disc_t cdi_image_open( const gchar *filename, FILE *f )55.30 @@ -89,119 +89,119 @@55.31 len = ftell(f)+8;55.32 fread( &trail, sizeof(trail), 1, f );55.33 if( trail.header_offset >= len ||55.34 - trail.header_offset == 0 )55.35 - return NULL;55.36 -55.37 + trail.header_offset == 0 )55.38 + return NULL;55.39 +55.40 if( trail.cdi_version != CDI_V2_ID && trail.cdi_version != CDI_V3_ID &&55.41 - trail.cdi_version != CDI_V35_ID ) {55.42 - return NULL;55.43 + trail.cdi_version != CDI_V35_ID ) {55.44 + return NULL;55.45 }55.47 if( trail.cdi_version == CDI_V35_ID ) {55.48 - fseek( f, -trail.header_offset, SEEK_END );55.49 + fseek( f, -trail.header_offset, SEEK_END );55.50 } else {55.51 - fseek( f, trail.header_offset, SEEK_SET );55.52 + fseek( f, trail.header_offset, SEEK_SET );55.53 }55.54 fread( &session_count, sizeof(session_count), 1, f );55.55 -55.56 +55.57 disc = gdrom_image_new(filename, f);55.58 if( disc == NULL ) {55.59 - ERROR("Unable to allocate memory!");55.60 - return NULL;55.61 + ERROR("Unable to allocate memory!");55.62 + return NULL;55.63 }55.64 image = (gdrom_image_t)disc;55.66 for( i=0; i< session_count; i++ ) {55.67 - fread( &track_count, sizeof(track_count), 1, f );55.68 - if( track_count + total_tracks > 99 ) {55.69 - ERROR( "Invalid number of tracks, bad cdi image\n" );55.70 - gdrom_image_destroy_no_close(disc);55.71 - return NULL;55.72 - }55.73 + fread( &track_count, sizeof(track_count), 1, f );55.74 + if( track_count + total_tracks > 99 ) {55.75 + ERROR( "Invalid number of tracks, bad cdi image\n" );55.76 + gdrom_image_destroy_no_close(disc);55.77 + return NULL;55.78 + }55.79 for( j=0; j<track_count; j++ ) {55.80 struct cdi_track_data trk;55.81 uint32_t new_fmt = 0;55.82 - uint8_t fnamelen = 0;55.83 + uint8_t fnamelen = 0;55.84 fread( &new_fmt, sizeof(new_fmt), 1, f );55.85 if( new_fmt != 0 ) { /* Additional data 3.00.780+ ?? */55.86 - fseek( f, 8, SEEK_CUR ); /* Skip */55.87 + fseek( f, 8, SEEK_CUR ); /* Skip */55.88 }55.89 fread( marker, 20, 1, f );55.90 if( memcmp( marker, TRACK_START_MARKER, 20) != 0 ) {55.91 - ERROR( "Track start marker not found, error reading cdi image\n" );55.92 - gdrom_image_destroy_no_close(disc);55.93 - return NULL;55.94 - }55.95 - fseek( f, 4, SEEK_CUR );55.96 + ERROR( "Track start marker not found, error reading cdi image\n" );55.97 + gdrom_image_destroy_no_close(disc);55.98 + return NULL;55.99 + }55.100 + fseek( f, 4, SEEK_CUR );55.101 fread( &fnamelen, 1, 1, f );55.102 fseek( f, (int)fnamelen, SEEK_CUR ); /* skip over the filename */55.103 - fseek( f, 19, SEEK_CUR );55.104 - fread( &new_fmt, sizeof(new_fmt), 1, f );55.105 - if( new_fmt == 0x80000000 ) {55.106 - fseek( f, 10, SEEK_CUR );55.107 - } else {55.108 - fseek( f, 2, SEEK_CUR );55.109 - }55.110 + fseek( f, 19, SEEK_CUR );55.111 + fread( &new_fmt, sizeof(new_fmt), 1, f );55.112 + if( new_fmt == 0x80000000 ) {55.113 + fseek( f, 10, SEEK_CUR );55.114 + } else {55.115 + fseek( f, 2, SEEK_CUR );55.116 + }55.117 fread( &trk, sizeof(trk), 1, f );55.118 - image->track[total_tracks].session = i;55.119 - image->track[total_tracks].lba = trk.start_lba + 150;55.120 - image->track[total_tracks].sector_count = trk.length;55.121 - switch( trk.mode ) {55.122 - case 0:55.123 - image->track[total_tracks].mode = GDROM_CDDA;55.124 - image->track[total_tracks].sector_size = 2352;55.125 - image->track[total_tracks].flags = 0x01;55.126 - if( trk.sector_size != 2 ) {55.127 - ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );55.128 - gdrom_image_destroy_no_close(disc);55.129 - return NULL;55.130 - }55.131 - break;55.132 - case 1:55.133 - image->track[total_tracks].mode = GDROM_MODE1;55.134 - image->track[total_tracks].sector_size = 2048;55.135 - image->track[total_tracks].flags = 0x41;55.136 - if( trk.sector_size != 0 ) {55.137 - ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );55.138 - gdrom_image_destroy_no_close(disc);55.139 - return NULL;55.140 - }55.141 - break;55.142 - case 2:55.143 - image->track[total_tracks].flags = 0x41;55.144 - switch( trk.sector_size ) {55.145 - case 0:55.146 - image->track[total_tracks].mode = GDROM_MODE2_FORM1;55.147 - image->track[total_tracks].sector_size = 2048;55.148 - break;55.149 - case 1:55.150 - image->track[total_tracks].mode = GDROM_SEMIRAW_MODE2;55.151 - image->track[total_tracks].sector_size = 2336;55.152 - break;55.153 - case 2:55.154 - default:55.155 - ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );55.156 - gdrom_image_destroy_no_close(disc);55.157 - return NULL;55.158 - }55.159 - break;55.160 - default:55.161 - ERROR( "Unsupported track mode %d", trk.mode );55.162 - gdrom_image_destroy_no_close(disc);55.163 - return NULL;55.164 - }55.165 - image->track[total_tracks].offset = posn +55.166 - trk.pregap_length * image->track[total_tracks].sector_size ;55.167 - posn += trk.total_length * image->track[total_tracks].sector_size;55.168 - total_tracks++;55.169 - fread( marker, 1, 9, f );55.170 - if( memcmp( marker, EXT_MARKER, 9 ) == 0 ) {55.171 - fseek( f, 79, SEEK_CUR );55.172 - } else {55.173 - fseek( f, -9, SEEK_CUR );55.174 - }55.175 - }55.176 - fseek( f, 12, SEEK_CUR );55.177 + image->track[total_tracks].session = i;55.178 + image->track[total_tracks].lba = trk.start_lba + 150;55.179 + image->track[total_tracks].sector_count = trk.length;55.180 + switch( trk.mode ) {55.181 + case 0:55.182 + image->track[total_tracks].mode = GDROM_CDDA;55.183 + image->track[total_tracks].sector_size = 2352;55.184 + image->track[total_tracks].flags = 0x01;55.185 + if( trk.sector_size != 2 ) {55.186 + ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );55.187 + gdrom_image_destroy_no_close(disc);55.188 + return NULL;55.189 + }55.190 + break;55.191 + case 1:55.192 + image->track[total_tracks].mode = GDROM_MODE1;55.193 + image->track[total_tracks].sector_size = 2048;55.194 + image->track[total_tracks].flags = 0x41;55.195 + if( trk.sector_size != 0 ) {55.196 + ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );55.197 + gdrom_image_destroy_no_close(disc);55.198 + return NULL;55.199 + }55.200 + break;55.201 + case 2:55.202 + image->track[total_tracks].flags = 0x41;55.203 + switch( trk.sector_size ) {55.204 + case 0:55.205 + image->track[total_tracks].mode = GDROM_MODE2_FORM1;55.206 + image->track[total_tracks].sector_size = 2048;55.207 + break;55.208 + case 1:55.209 + image->track[total_tracks].mode = GDROM_SEMIRAW_MODE2;55.210 + image->track[total_tracks].sector_size = 2336;55.211 + break;55.212 + case 2:55.213 + default:55.214 + ERROR( "Invalid combination of mode %d with size %d", trk.mode, trk.sector_size );55.215 + gdrom_image_destroy_no_close(disc);55.216 + return NULL;55.217 + }55.218 + break;55.219 + default:55.220 + ERROR( "Unsupported track mode %d", trk.mode );55.221 + gdrom_image_destroy_no_close(disc);55.222 + return NULL;55.223 + }55.224 + image->track[total_tracks].offset = posn +55.225 + trk.pregap_length * image->track[total_tracks].sector_size ;55.226 + posn += trk.total_length * image->track[total_tracks].sector_size;55.227 + total_tracks++;55.228 + fread( marker, 1, 9, f );55.229 + if( memcmp( marker, EXT_MARKER, 9 ) == 0 ) {55.230 + fseek( f, 79, SEEK_CUR );55.231 + } else {55.232 + fseek( f, -9, SEEK_CUR );55.233 + }55.234 + }55.235 + fseek( f, 12, SEEK_CUR );55.236 }55.237 image->track_count = total_tracks;55.238 return disc;
56.1 --- a/src/gdrom/gddriver.h Mon Jul 14 07:42:45 2008 +000056.2 +++ b/src/gdrom/gddriver.h Mon Jul 14 07:44:42 2008 +000056.3 @@ -18,14 +18,18 @@56.4 * GNU General Public License for more details.56.5 */56.7 -#ifndef lxdream_gdrom_driver_H56.8 -#define lxdream_gdrom_driver_H 156.9 +#ifndef lxdream_gddriver_H56.10 +#define lxdream_gddriver_H 156.12 #include <stdio.h>56.13 #include "lxdream.h"56.14 #include "gdrom/gdrom.h"56.15 #include <glib/gstrfuncs.h>56.17 +#ifdef __cplusplus56.18 +extern "C" {56.19 +#endif56.20 +56.21 #define MAX_SECTOR_SIZE 235256.23 #define CD_FRAMES_PER_SECOND 7556.24 @@ -48,20 +52,20 @@56.25 */56.26 typedef enum {56.27 GDROM_MODE0, // Mode 0 - should never actually see this56.28 -/* Data-only modes (image file contains only the user data) */56.29 + /* Data-only modes (image file contains only the user data) */56.30 GDROM_MODE1, // Standard CD-Rom Mode 1 data track56.31 GDROM_MODE2_FORMLESS, // Mode 2 data track with no sub-structure (rare)56.32 GDROM_MODE2_FORM1, // Mode 2/Form 1 data track (standard for multisession)56.33 GDROM_MODE2_FORM2, // Mode 2/Form 2 data track (also fairly uncommon).56.34 GDROM_CDDA, // Standard audio track56.36 -/* This one is somewhat special - the image file contains the 2336 bytes of56.37 - * "extended user data", which in turn contains either a form 1 or form 256.38 - * sector. In other words it's a raw mode2 XA sector without the 16-byte header.56.39 - */56.40 + /* This one is somewhat special - the image file contains the 2336 bytes of56.41 + * "extended user data", which in turn contains either a form 1 or form 256.42 + * sector. In other words it's a raw mode2 XA sector without the 16-byte header.56.43 + */56.44 GDROM_SEMIRAW_MODE2,56.45 -/* Raw modes (image contains the full 2352-byte sector). Split into XA/Non-XA56.46 - * here for convenience, although it's really a session level flag. */56.47 + /* Raw modes (image contains the full 2352-byte sector). Split into XA/Non-XA56.48 + * here for convenience, although it's really a session level flag. */56.49 GDROM_RAW_XA,56.50 GDROM_RAW_NONXA,56.51 } gdrom_track_mode_t;56.52 @@ -105,9 +109,9 @@56.53 * @return PKT_ERR_OK on success, or another PKT_ERR_* code on failure.56.54 */56.55 gdrom_error_t (*read_sector)( struct gdrom_disc *disc,56.56 - uint32_t lba, int mode,56.57 - unsigned char *buf, uint32_t *length );56.58 -56.59 + uint32_t lba, int mode,56.60 + unsigned char *buf, uint32_t *length );56.61 +56.62 /**56.63 * Read the TOC from the disc and write it into the specified buffer.56.64 * The method is responsible for returning the data in gd-rom56.65 @@ -222,4 +226,5 @@56.66 * Construct a Read CD command for the given sector + mode56.67 */56.68 void mmc_make_read_cd_cmd( char *cmd, uint32_t sector, int mode );56.69 -#endif56.70 +56.71 +#endif /* !lxdream_gddriver_H */
57.1 --- a/src/gdrom/gdi.c Mon Jul 14 07:42:45 2008 +000057.2 +++ b/src/gdrom/gdi.c Mon Jul 14 07:44:42 2008 +000057.3 @@ -30,20 +30,20 @@57.4 static gdrom_disc_t gdi_image_open( const gchar *filename, FILE *f );57.6 struct gdrom_image_class gdi_image_class = { "NullDC GD-Rom Image", "gdi",57.7 - gdi_image_is_valid, gdi_image_open };57.8 + gdi_image_is_valid, gdi_image_open };57.10 static gboolean gdi_image_is_valid( FILE *f )57.11 {57.12 char line[512];57.13 uint32_t track_count;57.14 -57.15 +57.16 fseek(f, 0, SEEK_SET);57.17 if( fgets( line, sizeof(line), f ) == NULL ) {57.18 - return FALSE;57.19 + return FALSE;57.20 }57.21 track_count = strtoul(line, NULL, 0);57.22 if( track_count == 0 || track_count > 99 ) {57.23 - return FALSE;57.24 + return FALSE;57.25 }57.26 return TRUE;57.27 }57.28 @@ -59,79 +59,79 @@57.29 gchar *dirname;57.31 fseek(f, 0, SEEK_SET);57.32 -57.33 +57.34 if( fgets( line, sizeof(line), f ) == NULL ) {57.35 - return FALSE;57.36 + return FALSE;57.37 }57.38 track_count = strtoul(line, NULL, 0);57.39 if( track_count == 0 || track_count > 99 ) {57.40 - return NULL;57.41 + return NULL;57.42 }57.44 disc = gdrom_image_new(filename, f);57.45 if( disc == NULL ) {57.46 - ERROR("Unable to allocate memory!");57.47 - return NULL;57.48 + ERROR("Unable to allocate memory!");57.49 + return NULL;57.50 }57.51 dirname = g_path_get_dirname(filename);57.52 image = (gdrom_image_t)disc;57.53 image->disc_type = IDE_DISC_GDROM;57.54 image->track_count = track_count;57.55 for( i=0; i<track_count; i++ ) {57.56 - int track_no, start_lba, flags, size, offset;57.57 - char filename[256];57.58 + int track_no, start_lba, flags, size, offset;57.59 + char filename[256];57.61 - if( fgets( line, sizeof(line), f ) == NULL ) {57.62 - gdrom_image_destroy_no_close(disc);57.63 - return NULL;57.64 - }57.65 - sscanf( line, "%d %d %d %d %s %d", &track_no, &start_lba, &flags, &size,57.66 - filename, &offset );57.67 - if( start_lba >= 45000 ) {57.68 - image->track[i].session = 1;57.69 - } else {57.70 - image->track[i].session = 0;57.71 - }57.72 - image->track[i].lba = start_lba + 150; // 2-second offset57.73 - image->track[i].flags = (flags & 0x0F)<<4;57.74 - image->track[i].sector_size = size;57.75 - if( strcasecmp( filename, "none" ) == 0 ) {57.76 - image->track[i].file = NULL;57.77 - image->track[i].sector_count = 0;57.78 - image->track[i].mode = GDROM_MODE1;57.79 - } else {57.80 - gchar *pathname = g_strdup_printf( "%s%c%s", dirname, G_DIR_SEPARATOR, filename );57.81 - image->track[i].file = fopen( pathname, "ro" );57.82 - g_free(pathname);57.83 - if( image->track[i].file == NULL ) {57.84 - gdrom_image_destroy_no_close(disc);57.85 - g_free(dirname);57.86 - return NULL;57.87 - }57.88 - fstat( fileno(image->track[i].file), &st );57.89 - image->track[i].sector_count = st.st_size / size;57.90 - if( image->track[i].flags & TRACK_DATA ) {57.91 - /* Data track */57.92 - switch(size) {57.93 - case 2048: image->track[i].mode = GDROM_MODE1; break;57.94 - case 2336: image->track[i].mode = GDROM_SEMIRAW_MODE2; break;57.95 - case 2352: image->track[i].mode = GDROM_RAW_XA; break;57.96 - default:57.97 - gdrom_image_destroy_no_close(disc);57.98 - g_free(dirname);57.99 - return NULL;57.100 - }57.101 - } else {57.102 - /* Audio track */57.103 - image->track[i].mode = GDROM_CDDA;57.104 - if( size != 2352 ) {57.105 - gdrom_image_destroy_no_close(disc);57.106 - g_free(dirname);57.107 - return NULL;57.108 - }57.109 - }57.110 - }57.111 - image->track[i].offset = offset;57.112 + if( fgets( line, sizeof(line), f ) == NULL ) {57.113 + gdrom_image_destroy_no_close(disc);57.114 + return NULL;57.115 + }57.116 + sscanf( line, "%d %d %d %d %s %d", &track_no, &start_lba, &flags, &size,57.117 + filename, &offset );57.118 + if( start_lba >= 45000 ) {57.119 + image->track[i].session = 1;57.120 + } else {57.121 + image->track[i].session = 0;57.122 + }57.123 + image->track[i].lba = start_lba + 150; // 2-second offset57.124 + image->track[i].flags = (flags & 0x0F)<<4;57.125 + image->track[i].sector_size = size;57.126 + if( strcasecmp( filename, "none" ) == 0 ) {57.127 + image->track[i].file = NULL;57.128 + image->track[i].sector_count = 0;57.129 + image->track[i].mode = GDROM_MODE1;57.130 + } else {57.131 + gchar *pathname = g_strdup_printf( "%s%c%s", dirname, G_DIR_SEPARATOR, filename );57.132 + image->track[i].file = fopen( pathname, "ro" );57.133 + g_free(pathname);57.134 + if( image->track[i].file == NULL ) {57.135 + gdrom_image_destroy_no_close(disc);57.136 + g_free(dirname);57.137 + return NULL;57.138 + }57.139 + fstat( fileno(image->track[i].file), &st );57.140 + image->track[i].sector_count = st.st_size / size;57.141 + if( image->track[i].flags & TRACK_DATA ) {57.142 + /* Data track */57.143 + switch(size) {57.144 + case 2048: image->track[i].mode = GDROM_MODE1; break;57.145 + case 2336: image->track[i].mode = GDROM_SEMIRAW_MODE2; break;57.146 + case 2352: image->track[i].mode = GDROM_RAW_XA; break;57.147 + default:57.148 + gdrom_image_destroy_no_close(disc);57.149 + g_free(dirname);57.150 + return NULL;57.151 + }57.152 + } else {57.153 + /* Audio track */57.154 + image->track[i].mode = GDROM_CDDA;57.155 + if( size != 2352 ) {57.156 + gdrom_image_destroy_no_close(disc);57.157 + g_free(dirname);57.158 + return NULL;57.159 + }57.160 + }57.161 + }57.162 + image->track[i].offset = offset;57.163 }57.164 g_free(dirname);57.165 return disc;
58.1 --- a/src/gdrom/gdimage.c Mon Jul 14 07:42:45 2008 +000058.2 +++ b/src/gdrom/gdimage.c Mon Jul 14 07:44:42 2008 +000058.3 @@ -17,6 +17,7 @@58.4 */58.6 #include <assert.h>58.7 +#include <string.h>58.8 #include <netinet/in.h>58.10 #include "gdrom/gddriver.h"58.11 @@ -26,7 +27,7 @@58.13 static void gdrom_image_destroy( gdrom_disc_t disc );58.14 static gdrom_error_t gdrom_image_read_sector( gdrom_disc_t disc, uint32_t lba, int mode,58.15 - unsigned char *buf, uint32_t *readlength );58.16 + unsigned char *buf, uint32_t *readlength );58.17 static gdrom_error_t gdrom_image_read_toc( gdrom_disc_t disc, unsigned char *buf );58.18 static gdrom_error_t gdrom_image_read_session( gdrom_disc_t disc, int session, unsigned char *buf );58.19 static gdrom_error_t gdrom_image_read_position( gdrom_disc_t disc, uint32_t lba, unsigned char *buf );58.20 @@ -67,18 +68,18 @@58.22 gdrom_disc_t gdrom_image_new( const gchar *filename, FILE *f )58.23 {58.24 - gdrom_image_t image = (gdrom_image_t)calloc(sizeof(struct gdrom_image), 1);58.25 + gdrom_image_t image = (gdrom_image_t)g_malloc0(sizeof(struct gdrom_image));58.26 if( image == NULL ) {58.27 - return NULL;58.28 + return NULL;58.29 }58.30 image->disc_type = IDE_DISC_CDROMXA;58.31 image->file = f;58.32 gdrom_disc_t disc = (gdrom_disc_t)image;58.33 gdrom_image_init(disc);58.34 if( filename == NULL ) {58.35 - disc->name = NULL;58.36 + disc->name = NULL;58.37 } else {58.38 - disc->name = g_strdup(filename);58.39 + disc->name = g_strdup(filename);58.40 }58.42 return disc;58.43 @@ -90,19 +91,19 @@58.44 FILE *lastfile = NULL;58.45 gdrom_image_t img = (gdrom_image_t)disc;58.46 if( img->file != NULL ) {58.47 - fclose(img->file);58.48 - img->file = NULL;58.49 + fclose(img->file);58.50 + img->file = NULL;58.51 }58.52 for( i=0; i<img->track_count; i++ ) {58.53 - if( img->track[i].file != NULL && img->track[i].file != lastfile ) {58.54 - lastfile = img->track[i].file;58.55 - fclose(lastfile);58.56 - img->track[i].file = NULL;58.57 - }58.58 + if( img->track[i].file != NULL && img->track[i].file != lastfile ) {58.59 + lastfile = img->track[i].file;58.60 + fclose(lastfile);58.61 + img->track[i].file = NULL;58.62 + }58.63 }58.64 if( disc->name != NULL ) {58.65 - g_free( (gpointer)disc->name );58.66 - disc->name = NULL;58.67 + g_free( (gpointer)disc->name );58.68 + disc->name = NULL;58.69 }58.70 free( disc );58.71 }58.72 @@ -113,18 +114,18 @@58.73 FILE *lastfile = NULL;58.74 gdrom_image_t img = (gdrom_image_t)disc;58.75 if( img->file != NULL ) {58.76 - img->file = NULL;58.77 + img->file = NULL;58.78 }58.79 for( i=0; i<img->track_count; i++ ) {58.80 - if( img->track[i].file != NULL && img->track[i].file != lastfile ) {58.81 - lastfile = img->track[i].file;58.82 - fclose(lastfile);58.83 - img->track[i].file = NULL;58.84 - }58.85 + if( img->track[i].file != NULL && img->track[i].file != lastfile ) {58.86 + lastfile = img->track[i].file;58.87 + fclose(lastfile);58.88 + img->track[i].file = NULL;58.89 + }58.90 }58.91 if( disc->name != NULL ) {58.92 - g_free( (gpointer)disc->name );58.93 - disc->name = NULL;58.94 + g_free( (gpointer)disc->name );58.95 + disc->name = NULL;58.96 }58.97 free( disc );58.98 }58.99 @@ -133,10 +134,10 @@58.100 {58.101 int i;58.102 for( i=0; i<image->track_count; i++ ) {58.103 - if( image->track[i].lba <= lba &&58.104 - lba < (image->track[i].lba + image->track[i].sector_count) ) {58.105 - return i+1;58.106 - }58.107 + if( image->track[i].lba <= lba &&58.108 + lba < (image->track[i].lba + image->track[i].sector_count) ) {58.109 + return i+1;58.110 + }58.111 }58.112 return -1;58.113 }58.114 @@ -148,22 +149,22 @@58.115 static gboolean gdrom_read_block( unsigned char *buf, int file_offset, int length, FILE *f )58.116 {58.117 if( file_offset < 0 ) {58.118 - int size = -file_offset;58.119 - if( size >= length ) {58.120 - memset( buf, 0, length );58.121 - return TRUE;58.122 - } else {58.123 - memset( buf, 0, size );58.124 - file_offset = 0;58.125 - length -= size;58.126 - }58.127 + int size = -file_offset;58.128 + if( size >= length ) {58.129 + memset( buf, 0, length );58.130 + return TRUE;58.131 + } else {58.132 + memset( buf, 0, size );58.133 + file_offset = 0;58.134 + length -= size;58.135 + }58.136 }58.137 fseek( f, file_offset, SEEK_SET );58.138 return fread( buf, length, 1, f ) == 1;58.139 }58.141 static void gdrom_build_sector_header( unsigned char *buf, uint32_t lba,58.142 - gdrom_track_mode_t sector_mode )58.143 + gdrom_track_mode_t sector_mode )58.144 {58.145 memcpy( buf, gdrom_default_sync, 12 );58.146 cd_build_address( buf, sector_mode, lba );58.147 @@ -179,19 +180,19 @@58.148 {58.149 switch( read_mode ) {58.150 case READ_CD_MODE_ANY:58.151 - return TRUE;58.152 + return TRUE;58.153 case READ_CD_MODE_CDDA:58.154 - return track_mode == GDROM_CDDA;58.155 + return track_mode == GDROM_CDDA;58.156 case READ_CD_MODE_1:58.157 - return track_mode == GDROM_MODE1 || track_mode == GDROM_MODE2_FORM1;58.158 + return track_mode == GDROM_MODE1 || track_mode == GDROM_MODE2_FORM1;58.159 case READ_CD_MODE_2_FORM_1:58.160 - return track_mode == GDROM_MODE1 || track_mode == GDROM_MODE2_FORM1;58.161 + return track_mode == GDROM_MODE1 || track_mode == GDROM_MODE2_FORM1;58.162 case READ_CD_MODE_2_FORM_2:58.163 - return track_mode == GDROM_MODE2_FORM2;58.164 + return track_mode == GDROM_MODE2_FORM2;58.165 case READ_CD_MODE_2:58.166 - return track_mode == GDROM_MODE2_FORMLESS;58.167 + return track_mode == GDROM_MODE2_FORMLESS;58.168 default:58.169 - return FALSE;58.170 + return FALSE;58.171 }58.172 }58.174 @@ -202,26 +203,26 @@58.175 static void gdrom_get_read_bounds( int sector_mode, int read_mode, int *start, int *size )58.176 {58.177 if( READ_CD_RAW(read_mode) ) {58.178 - // whole sector58.179 - *start = 0;58.180 - *size = 2352;58.181 + // whole sector58.182 + *start = 0;58.183 + *size = 2352;58.184 } else {58.185 - *size = 0;58.186 - if( READ_CD_DATA(read_mode) ) {58.187 - *start = gdrom_data_offset[sector_mode];58.188 - *size = gdrom_sector_size[sector_mode];58.189 - }58.190 + *size = 0;58.191 + if( READ_CD_DATA(read_mode) ) {58.192 + *start = gdrom_data_offset[sector_mode];58.193 + *size = gdrom_sector_size[sector_mode];58.194 + }58.196 - if( READ_CD_SUBHEAD(read_mode) &&58.197 - (sector_mode == GDROM_MODE2_FORM1 || sector_mode == GDROM_MODE2_FORM2) ) {58.198 - *start = SECTOR_HEADER_SIZE;58.199 - *size += SECTOR_SUBHEADER_SIZE;58.200 - }58.201 + if( READ_CD_SUBHEAD(read_mode) &&58.202 + (sector_mode == GDROM_MODE2_FORM1 || sector_mode == GDROM_MODE2_FORM2) ) {58.203 + *start = SECTOR_HEADER_SIZE;58.204 + *size += SECTOR_SUBHEADER_SIZE;58.205 + }58.207 - if( READ_CD_HEADER(read_mode) ) {58.208 - *size += SECTOR_HEADER_SIZE;58.209 - *start = 0;58.210 - }58.211 + if( READ_CD_HEADER(read_mode) ) {58.212 + *size += SECTOR_HEADER_SIZE;58.213 + *start = 0;58.214 + }58.216 }58.217 }58.218 @@ -242,7 +243,7 @@58.219 * data correction codes.58.220 */58.221 static gdrom_error_t gdrom_image_read_sector( gdrom_disc_t disc, uint32_t lba,58.222 - int mode, unsigned char *buf, uint32_t *length )58.223 + int mode, unsigned char *buf, uint32_t *length )58.224 {58.225 gdrom_image_t image = (gdrom_image_t)disc;58.226 struct cdrom_sector_header secthead;58.227 @@ -252,44 +253,44 @@58.229 track_no = gdrom_image_get_track_by_lba( image, lba );58.230 if( track_no == -1 ) {58.231 - return PKT_ERR_BADREAD;58.232 + return PKT_ERR_BADREAD;58.233 }58.234 struct gdrom_track *track = &image->track[track_no-1];58.235 file_offset = track->offset + track->sector_size * (lba - track->lba);58.236 read_len = track->sector_size;58.237 if( track->file != NULL ) {58.238 - f = track->file;58.239 + f = track->file;58.240 } else {58.241 - f = image->file;58.242 + f = image->file;58.243 }58.245 /* First figure out what the real sector mode is for raw/semiraw sectors */58.246 int sector_mode;58.247 switch( track->mode ) {58.248 case GDROM_RAW_NONXA:58.249 - gdrom_read_block( (unsigned char *)(§head), file_offset, sizeof(secthead), f );58.250 - sector_mode = (secthead.mode == 1) ? GDROM_MODE1 : GDROM_MODE2_FORMLESS;58.251 - break;58.252 + gdrom_read_block( (unsigned char *)(§head), file_offset, sizeof(secthead), f );58.253 + sector_mode = (secthead.mode == 1) ? GDROM_MODE1 : GDROM_MODE2_FORMLESS;58.254 + break;58.255 case GDROM_RAW_XA:58.256 - gdrom_read_block( (unsigned char *)(§head), file_offset, sizeof(secthead), f );58.257 - if( secthead.mode == 1 ) {58.258 - sector_mode = GDROM_MODE1;58.259 - } else {58.260 - sector_mode = ((secthead.subhead[2] & 0x20) == 0 ) ? GDROM_MODE2_FORM1 : GDROM_MODE2_FORM2;58.261 - }58.262 - break;58.263 + gdrom_read_block( (unsigned char *)(§head), file_offset, sizeof(secthead), f );58.264 + if( secthead.mode == 1 ) {58.265 + sector_mode = GDROM_MODE1;58.266 + } else {58.267 + sector_mode = ((secthead.subhead[2] & 0x20) == 0 ) ? GDROM_MODE2_FORM1 : GDROM_MODE2_FORM2;58.268 + }58.269 + break;58.270 case GDROM_SEMIRAW_MODE2:58.271 - gdrom_read_block( secthead.subhead, file_offset, 8, f );58.272 - sector_mode = ((secthead.subhead[2] & 0x20) == 0 ) ? GDROM_MODE2_FORM1 : GDROM_MODE2_FORM2;58.273 - break;58.274 + gdrom_read_block( secthead.subhead, file_offset, 8, f );58.275 + sector_mode = ((secthead.subhead[2] & 0x20) == 0 ) ? GDROM_MODE2_FORM1 : GDROM_MODE2_FORM2;58.276 + break;58.277 default:58.278 - /* In the other cases, the track mode completely defines the sector mode */58.279 - sector_mode = track->mode;58.280 - break;58.281 + /* In the other cases, the track mode completely defines the sector mode */58.282 + sector_mode = track->mode;58.283 + break;58.284 }58.286 if( !gdrom_is_compatible_read_mode(sector_mode, READ_CD_MODE(mode)) ) {58.287 - return PKT_ERR_BADREADMODE;58.288 + return PKT_ERR_BADREADMODE;58.289 }58.291 /* Ok, we've got a valid sector, check what parts of the sector we need to58.292 @@ -298,70 +299,70 @@58.293 int channels = READ_CD_CHANNELS(mode);58.295 if( channels == 0 ) {58.296 - // legal, if weird58.297 - *length = 0;58.298 - return PKT_ERR_OK;58.299 + // legal, if weird58.300 + *length = 0;58.301 + return PKT_ERR_OK;58.302 } else if( channels == 0xA0 &&58.303 - (sector_mode == GDROM_MODE2_FORM1 || sector_mode == GDROM_MODE2_FORM2 )) {58.304 - // caller requested a non-contiguous region58.305 - return PKT_ERR_BADFIELD;58.306 + (sector_mode == GDROM_MODE2_FORM1 || sector_mode == GDROM_MODE2_FORM2 )) {58.307 + // caller requested a non-contiguous region58.308 + return PKT_ERR_BADFIELD;58.309 } else if( READ_CD_RAW(channels) ) {58.310 - channels = 0xF0; // implies everything58.311 + channels = 0xF0; // implies everything58.312 }58.314 read_len = 0;58.315 int start, size;58.316 switch( track->mode ) {58.317 case GDROM_CDDA:58.318 - // audio is nice and simple (assume perfect reads for now)58.319 - *length = 2352;58.320 - gdrom_read_block( buf, file_offset, track->sector_size, f );58.321 - return PKT_ERR_OK;58.322 + // audio is nice and simple (assume perfect reads for now)58.323 + *length = 2352;58.324 + gdrom_read_block( buf, file_offset, track->sector_size, f );58.325 + return PKT_ERR_OK;58.326 case GDROM_RAW_XA:58.327 case GDROM_RAW_NONXA:58.328 - gdrom_get_read_bounds( sector_mode, channels, &start, &size );58.329 - gdrom_read_block( buf, file_offset+start, size, f );58.330 - read_len = size;58.331 - break;58.332 + gdrom_get_read_bounds( sector_mode, channels, &start, &size );58.333 + gdrom_read_block( buf, file_offset+start, size, f );58.334 + read_len = size;58.335 + break;58.336 case GDROM_SEMIRAW_MODE2:58.337 - gdrom_get_read_bounds( sector_mode, channels, &start, &size );58.338 - if( READ_CD_HEADER(channels) ) {58.339 - gdrom_build_sector_header( buf, lba, sector_mode );58.340 - read_len += SECTOR_HEADER_SIZE;58.341 - size -= SECTOR_HEADER_SIZE;58.342 - } else {58.343 - start -= SECTOR_HEADER_SIZE;58.344 - }58.345 - gdrom_read_block( buf + read_len, file_offset+start, size, f );58.346 - read_len += size;58.347 - break;58.348 + gdrom_get_read_bounds( sector_mode, channels, &start, &size );58.349 + if( READ_CD_HEADER(channels) ) {58.350 + gdrom_build_sector_header( buf, lba, sector_mode );58.351 + read_len += SECTOR_HEADER_SIZE;58.352 + size -= SECTOR_HEADER_SIZE;58.353 + } else {58.354 + start -= SECTOR_HEADER_SIZE;58.355 + }58.356 + gdrom_read_block( buf + read_len, file_offset+start, size, f );58.357 + read_len += size;58.358 + break;58.359 default: // Data track w/ data only in file58.360 - if( READ_CD_RAW(channels) ) {58.361 - gdrom_read_block( buf + gdrom_data_offset[track->mode], file_offset,58.362 - track->sector_size, f );58.363 - do_encode_L2( buf, sector_mode, lba );58.364 - read_len = 2352;58.365 - } else {58.366 - if( READ_CD_HEADER(channels) ) {58.367 - gdrom_build_sector_header( buf, lba, sector_mode );58.368 - read_len += SECTOR_HEADER_SIZE;58.369 - }58.370 - if( READ_CD_SUBHEAD(channels) &&58.371 - (sector_mode == GDROM_MODE2_FORM1 || sector_mode == GDROM_MODE2_FORM2) ) {58.372 - if( sector_mode == GDROM_MODE2_FORM1 ) {58.373 - *((uint32_t *)(buf+read_len)) = 0;58.374 - *((uint32_t *)(buf+read_len+4)) = 0;58.375 - } else {58.376 - *((uint32_t *)(buf+read_len)) = 0x00200000;58.377 - *((uint32_t *)(buf+read_len+4)) = 0x00200000;58.378 - }58.379 - read_len += 8;58.380 - }58.381 - if( READ_CD_DATA(channels) ) {58.382 - gdrom_read_block( buf+read_len, file_offset, track->sector_size, f );58.383 - read_len += track->sector_size;58.384 - }58.385 - }58.386 + if( READ_CD_RAW(channels) ) {58.387 + gdrom_read_block( buf + gdrom_data_offset[track->mode], file_offset,58.388 + track->sector_size, f );58.389 + do_encode_L2( buf, sector_mode, lba );58.390 + read_len = 2352;58.391 + } else {58.392 + if( READ_CD_HEADER(channels) ) {58.393 + gdrom_build_sector_header( buf, lba, sector_mode );58.394 + read_len += SECTOR_HEADER_SIZE;58.395 + }58.396 + if( READ_CD_SUBHEAD(channels) &&58.397 + (sector_mode == GDROM_MODE2_FORM1 || sector_mode == GDROM_MODE2_FORM2) ) {58.398 + if( sector_mode == GDROM_MODE2_FORM1 ) {58.399 + *((uint32_t *)(buf+read_len)) = 0;58.400 + *((uint32_t *)(buf+read_len+4)) = 0;58.401 + } else {58.402 + *((uint32_t *)(buf+read_len)) = 0x00200000;58.403 + *((uint32_t *)(buf+read_len+4)) = 0x00200000;58.404 + }58.405 + read_len += 8;58.406 + }58.407 + if( READ_CD_DATA(channels) ) {58.408 + gdrom_read_block( buf+read_len, file_offset, track->sector_size, f );58.409 + read_len += track->sector_size;58.410 + }58.411 + }58.412 }58.413 *length = read_len;58.414 return PKT_ERR_OK;58.415 @@ -374,14 +375,14 @@58.416 int i;58.418 for( i=0; i<image->track_count; i++ ) {58.419 - toc->track[i] = htonl( image->track[i].lba ) | image->track[i].flags;58.420 + toc->track[i] = htonl( image->track[i].lba ) | image->track[i].flags;58.421 }58.422 toc->first = 0x0100 | image->track[0].flags;58.423 toc->last = (image->track_count<<8) | image->track[i-1].flags;58.424 toc->leadout = htonl(image->track[i-1].lba + image->track[i-1].sector_count) |58.425 - image->track[i-1].flags;58.426 + image->track[i-1].flags;58.427 for( ;i<99; i++ )58.428 - toc->track[i] = 0xFFFFFFFF;58.429 + toc->track[i] = 0xFFFFFFFF;58.430 return PKT_ERR_OK;58.431 }58.433 @@ -395,23 +396,23 @@58.434 buf[1] = 0;58.436 if( session == 0 ) {58.437 - buf[2] = last_track->session+1; /* last session */58.438 - buf[3] = (end_of_disc >> 16) & 0xFF;58.439 - buf[4] = (end_of_disc >> 8) & 0xFF;58.440 - buf[5] = end_of_disc & 0xFF;58.441 - return PKT_ERR_OK;58.442 + buf[2] = last_track->session+1; /* last session */58.443 + buf[3] = (end_of_disc >> 16) & 0xFF;58.444 + buf[4] = (end_of_disc >> 8) & 0xFF;58.445 + buf[5] = end_of_disc & 0xFF;58.446 + return PKT_ERR_OK;58.447 } else {58.448 - session--;58.449 - for( i=0; i<image->track_count; i++ ) {58.450 - if( image->track[i].session == session ) {58.451 - buf[2] = i+1; /* first track of session */58.452 - buf[3] = (image->track[i].lba >> 16) & 0xFF;58.453 - buf[4] = (image->track[i].lba >> 8) & 0xFF;58.454 - buf[5] = image->track[i].lba & 0xFF;58.455 - return PKT_ERR_OK;58.456 - }58.457 - }58.458 - return PKT_ERR_BADFIELD; /* No such session */58.459 + session--;58.460 + for( i=0; i<image->track_count; i++ ) {58.461 + if( image->track[i].session == session ) {58.462 + buf[2] = i+1; /* first track of session */58.463 + buf[3] = (image->track[i].lba >> 16) & 0xFF;58.464 + buf[4] = (image->track[i].lba >> 8) & 0xFF;58.465 + buf[5] = image->track[i].lba & 0xFF;58.466 + return PKT_ERR_OK;58.467 + }58.468 + }58.469 + return PKT_ERR_BADFIELD; /* No such session */58.470 }58.471 }58.473 @@ -420,8 +421,8 @@58.474 gdrom_image_t image = (gdrom_image_t)disc;58.475 int track_no = gdrom_image_get_track_by_lba( image, lba );58.476 if( track_no == -1 ) {58.477 - track_no = 1;58.478 - lba = 150;58.479 + track_no = 1;58.480 + lba = 150;58.481 }58.482 struct gdrom_track *track = &image->track[track_no-1];58.483 uint32_t offset = lba - track->lba;58.484 @@ -455,29 +456,29 @@58.485 gboolean is_bootable = FALSE;58.487 INFO( "Disc ID: %s, %d tracks in %d sessions", disc->mcn, disc->track_count,58.488 - disc->track[disc->track_count-1].session + 1 );58.489 + disc->track[disc->track_count-1].session + 1 );58.490 if( last_session > 0 ) {58.491 - /* Boot track is the first data track of the last session, provided that it58.492 - * cannot be a single-session disc.58.493 - */58.494 - int boot_track = -1;58.495 - for( i=disc->track_count-1; i>=0 && disc->track[i].session == last_session; i-- ) {58.496 - if( disc->track[i].flags & TRACK_DATA ) {58.497 - boot_track = i;58.498 - }58.499 - }58.500 - if( boot_track != -1 ) {58.501 - unsigned char boot_sector[MAX_SECTOR_SIZE];58.502 - uint32_t length = sizeof(boot_sector);58.503 - if( d->read_sector( d, disc->track[boot_track].lba, 0x28,58.504 - boot_sector, &length ) == PKT_ERR_OK ) {58.505 - bootstrap_dump(boot_sector, FALSE);58.506 - is_bootable = TRUE;58.507 - }58.508 - }58.509 + /* Boot track is the first data track of the last session, provided that it58.510 + * cannot be a single-session disc.58.511 + */58.512 + int boot_track = -1;58.513 + for( i=disc->track_count-1; i>=0 && disc->track[i].session == last_session; i-- ) {58.514 + if( disc->track[i].flags & TRACK_DATA ) {58.515 + boot_track = i;58.516 + }58.517 + }58.518 + if( boot_track != -1 ) {58.519 + unsigned char boot_sector[MAX_SECTOR_SIZE];58.520 + uint32_t length = sizeof(boot_sector);58.521 + if( d->read_sector( d, disc->track[boot_track].lba, 0x28,58.522 + boot_sector, &length ) == PKT_ERR_OK ) {58.523 + bootstrap_dump(boot_sector, FALSE);58.524 + is_bootable = TRUE;58.525 + }58.526 + }58.527 }58.528 if( !is_bootable ) {58.529 - WARN( "Disc does not appear to be bootable" );58.530 + WARN( "Disc does not appear to be bootable" );58.531 }58.532 }58.534 @@ -501,4 +502,3 @@58.535 }58.536 g_free( dev );58.537 }58.538 -58.539 \ No newline at end of file
59.1 --- a/src/gdrom/gdrom.c Mon Jul 14 07:42:45 2008 +000059.2 +++ b/src/gdrom/gdrom.c Mon Jul 14 07:44:42 2008 +000059.3 @@ -37,13 +37,13 @@59.4 }59.6 gdrom_image_class_t gdrom_image_classes[] = { &cdrom_device_class,59.7 - &nrg_image_class,59.8 - &cdi_image_class,59.9 - &gdi_image_class,59.10 - NULL };59.11 + &nrg_image_class,59.12 + &cdi_image_class,59.13 + &gdi_image_class,59.14 + NULL };59.16 char *gdrom_mode_names[] = { "Mode 0", "Mode 1", "Mode 2", "Mode 2 Form 1", "Mode 2 Form 2", "Audio",59.17 - "Mode 2 semiraw", "XA Raw", "Non-XA Raw" };59.18 + "Mode 2 semiraw", "XA Raw", "Non-XA Raw" };59.19 uint32_t gdrom_sector_size[] = { 0, 2048, 2336, 2048, 2324, 2352, 2336, 2352, 2352 };59.21 gdrom_disc_t gdrom_image_open( const gchar *inFilename )59.22 @@ -64,7 +64,7 @@59.23 gchar method[method_len + 1];59.24 memcpy( method, filename, method_len );59.25 method[method_len] = '\0';59.26 -59.27 +59.28 if( strcasecmp( method, "file" ) == 0 ) {59.29 filename = path;59.30 } else if( strcasecmp( method, "dvd" ) == 0 ||59.31 @@ -76,7 +76,7 @@59.32 return NULL;59.33 }59.34 }59.35 -59.36 +59.37 fd = open( filename, O_RDONLY | O_NONBLOCK );59.38 if( fd == -1 ) {59.39 return NULL;59.40 @@ -87,31 +87,31 @@59.42 /* try extensions */59.43 if( ext != NULL ) {59.44 - ext++; /* Skip the '.' */59.45 - for( i=0; gdrom_image_classes[i] != NULL; i++ ) {59.46 - if( gdrom_image_classes[i]->extension != NULL &&59.47 - strcasecmp( gdrom_image_classes[i]->extension, ext ) == 0 ) {59.48 - extclz = gdrom_image_classes[i];59.49 - if( extclz->is_valid_file(f) ) {59.50 - disc = extclz->open_image_file(filename, f);59.51 - if( disc != NULL )59.52 - return disc;59.53 - }59.54 - break;59.55 - }59.56 - }59.57 + ext++; /* Skip the '.' */59.58 + for( i=0; gdrom_image_classes[i] != NULL; i++ ) {59.59 + if( gdrom_image_classes[i]->extension != NULL &&59.60 + strcasecmp( gdrom_image_classes[i]->extension, ext ) == 0 ) {59.61 + extclz = gdrom_image_classes[i];59.62 + if( extclz->is_valid_file(f) ) {59.63 + disc = extclz->open_image_file(filename, f);59.64 + if( disc != NULL )59.65 + return disc;59.66 + }59.67 + break;59.68 + }59.69 + }59.70 }59.72 /* Okay, fall back to magic */59.73 gboolean recognized = FALSE;59.74 for( i=0; gdrom_image_classes[i] != NULL; i++ ) {59.75 - if( gdrom_image_classes[i] != extclz &&59.76 - gdrom_image_classes[i]->is_valid_file(f) ) {59.77 - recognized = TRUE;59.78 - disc = gdrom_image_classes[i]->open_image_file(filename, f);59.79 - if( disc != NULL )59.80 - return disc;59.81 - }59.82 + if( gdrom_image_classes[i] != extclz &&59.83 + gdrom_image_classes[i]->is_valid_file(f) ) {59.84 + recognized = TRUE;59.85 + disc = gdrom_image_classes[i]->open_image_file(filename, f);59.86 + if( disc != NULL )59.87 + return disc;59.88 + }59.89 }59.91 fclose(f);
60.1 --- a/src/gdrom/gdrom.h Mon Jul 14 07:42:45 2008 +000060.2 +++ b/src/gdrom/gdrom.h Mon Jul 14 07:44:42 2008 +000060.3 @@ -24,6 +24,10 @@60.4 #include "hook.h"60.5 #include <glib/glist.h>60.7 +#ifdef __cplusplus60.8 +extern "C" {60.9 +#endif60.10 +60.11 typedef uint16_t gdrom_error_t;60.14 @@ -70,7 +74,7 @@60.15 const gchar *gdrom_get_current_disc_name();60.17 uint32_t gdrom_read_sectors( uint32_t sector, uint32_t sector_count,60.18 - int mode, unsigned char *buf, uint32_t *length );60.19 + int mode, unsigned char *buf, uint32_t *length );60.22 /**60.23 @@ -110,4 +114,8 @@60.24 */60.25 gdrom_disc_t cdrom_open_device( const gchar *method, const gchar *name );60.27 +#ifdef __cplusplus60.28 +}60.29 #endif60.30 +60.31 +#endif /* !lxdream_gdrom_H */
61.1 --- a/src/gdrom/ide.c Mon Jul 14 07:42:45 2008 +000061.2 +++ b/src/gdrom/ide.c Mon Jul 14 07:44:42 2008 +000061.3 @@ -46,7 +46,7 @@61.4 static void ide_read_next_sector(void);61.6 struct dreamcast_module ide_module = { "IDE", ide_init, ide_reset, NULL, ide_run_slice,61.7 - NULL, ide_save_state, ide_load_state };61.8 + NULL, ide_save_state, ide_load_state };61.10 struct ide_registers idereg;61.11 gdrom_disc_t gdrom_disc = NULL;61.12 @@ -58,76 +58,76 @@61.14 /* 10 bytes followed by "SE REV 6.42990316" */61.15 unsigned char default_gdrom_mode[GDROM_MODE_LENGTH] =61.16 - { 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x19, 0x00, 0x00, 0x08,61.17 - 0x53, 0x45, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,61.18 - 0x52, 0x65, 0x76, 0x20, 0x36, 0x2e, 0x34, 0x32, 0x39, 0x39, 0x30, 0x33, 0x31, 0x36 };61.19 -61.20 +{ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x19, 0x00, 0x00, 0x08,61.21 + 0x53, 0x45, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,61.22 + 0x52, 0x65, 0x76, 0x20, 0x36, 0x2e, 0x34, 0x32, 0x39, 0x39, 0x30, 0x33, 0x31, 0x36 };61.23 +61.24 unsigned char gdrom_71[] = { 0x3E, 0x0F, 0x90, 0xBE, 0x1D, 0xD9, 0x89, 0x04, 0x28, 0x3A, 0x8E, 0x26, 0x5C, 0x95, 0x10, 0x5A,61.25 - 0x0A, 0x99, 0xEE, 0xFB, 0x69, 0xCE, 0xD9, 0x63, 0x00, 0xF5, 0x0A, 0xBC, 0x2C, 0x0D, 0xF8, 0xE2,61.26 - 0x05, 0x02, 0x00, 0x7C, 0x03, 0x00, 0x3D, 0x08, 0xD8, 0x8D, 0x08, 0x7A, 0x6D, 0x00, 0x35, 0x06,61.27 - 0xBA, 0x66, 0x10, 0x00, 0x91, 0x08, 0x10, 0x29, 0xD0, 0x45, 0xDA, 0x00, 0x2D, 0x05, 0x69, 0x09,61.28 - 0x00, 0x5E, 0x0F, 0x70, 0x86, 0x12, 0x6C, 0x77, 0x5A, 0xFB, 0xCD, 0x56, 0xFB, 0xF7, 0xB7, 0x00,61.29 - 0x5D, 0x07, 0x19, 0x99, 0xF2, 0xAF, 0x00, 0x63, 0x03, 0x00, 0xF0, 0x10, 0xBE, 0xD7, 0xA0, 0x63,61.30 - 0xFA, 0x84, 0xA7, 0x74, 0x94, 0xEF, 0xAD, 0xC2, 0xAC, 0x00, 0x78, 0x07, 0x9F, 0x57, 0x0B, 0x62,61.31 - 0x00, 0xFE, 0x08, 0x08, 0x5D, 0x5A, 0x6A, 0x54, 0x00, 0xE2, 0x09, 0x93, 0x7E, 0x62, 0x2A, 0x5E,61.32 - 0xDA, 0x00, 0x7E, 0x0F, 0xF0, 0x07, 0x01, 0x6D, 0x50, 0x86, 0xDD, 0x4A, 0x15, 0x54, 0xC7, 0xEC,61.33 - 0x00, 0xF2, 0x0B, 0x07, 0xF8, 0x1A, 0xB0, 0x99, 0x3B, 0xF1, 0x36, 0x00, 0x94, 0x07, 0x34, 0xE3,61.34 - 0xBC, 0x6E, 0x00, 0x34, 0x0D, 0x6F, 0xDA, 0xBD, 0xEE, 0xF7, 0xCC, 0xCE, 0x39, 0x7E, 0xE3, 0x00,61.35 - 0x14, 0x08, 0xDC, 0xD2, 0xB9, 0xF9, 0x31, 0x00, 0xB0, 0x0C, 0x10, 0xA3, 0x45, 0x12, 0xC7, 0xCD,61.36 - 0xBF, 0x05, 0x37, 0x00, 0xC4, 0x0D, 0x5F, 0xE0, 0x59, 0xBB, 0x01, 0x59, 0x03, 0xD6, 0x29, 0x9C,61.37 - 0x00, 0x01, 0x0A, 0x09, 0xAA, 0xA8, 0xA8, 0x24, 0x0B, 0x66, 0x00, 0x5C, 0x05, 0xA5, 0xCE, 0x00,61.38 - 0xC1, 0x0B, 0xB7, 0xA0, 0x6F, 0xE9, 0x2B, 0xCC, 0xB5, 0xFC, 0x00, 0x8D, 0x05, 0xF4, 0xAC, 0x00,61.39 - 0x57, 0x04, 0xB6, 0x00, 0xFC, 0x03, 0x00, 0xC3, 0x10, 0x43, 0x3B, 0xBE, 0xA2, 0x96, 0xC3, 0x65,61.40 - 0x9F, 0x9A, 0x88, 0xD5, 0x49, 0x68, 0x00, 0xDC, 0x11, 0x56, 0x23, 0x2D, 0xF9, 0xFC, 0xF5, 0x8B,61.41 - 0x1B, 0xB1, 0xB7, 0x10, 0x21, 0x1C, 0x12, 0x00, 0x0D, 0x0D, 0xEB, 0x86, 0xA2, 0x49, 0x8D, 0x8D,61.42 - 0xBE, 0xA1, 0x6D, 0x53, 0x00, 0xE1, 0x0A, 0x8E, 0x67, 0xAA, 0x16, 0x79, 0x39, 0x59, 0x00, 0x36,61.43 - 0x0B, 0x2A, 0x4E, 0xAE, 0x51, 0x4B, 0xD0, 0x66, 0x33, 0x00, 0x8A, 0x07, 0xCD, 0x6F, 0xBA, 0x92,61.44 - 0x00, 0x1A, 0x0E, 0xDF, 0x4A, 0xB3, 0x77, 0x1F, 0xA5, 0x90, 0x19, 0xFA, 0x59, 0xD7, 0x00, 0x04,61.45 - 0x0F, 0xAC, 0xCA, 0x9F, 0xA4, 0xFC, 0x6D, 0x90, 0x86, 0x9E, 0x1F, 0x44, 0x40, 0x00, 0x9F, 0x04,61.46 - 0x56, 0x00, 0x22, 0x03, 0x00, 0xB8, 0x10, 0x2C, 0x7A, 0x53, 0xA4, 0xBF, 0xA3, 0x90, 0x90, 0x14,61.47 - 0x9D, 0x46, 0x6C, 0x96, 0x00, 0xC6, 0x0B, 0x9B, 0xBB, 0xB0, 0xAE, 0x60, 0x92, 0x8E, 0x0C, 0x00,61.48 - 0x14, 0x06, 0x4B, 0xAE, 0x7F, 0x00, 0x5C, 0x0B, 0x23, 0xFA, 0xE7, 0x51, 0xDA, 0x61, 0x49, 0x5E,61.49 - 0x00, 0xD7, 0x0B, 0x01, 0xFC, 0x55, 0x31, 0x84, 0xC5, 0x0C, 0x98, 0x00, 0x97, 0x50, 0x6E, 0xF9,61.50 - 0xEE, 0x75, 0x92, 0x53, 0xD3, 0x66, 0xA4, 0xAF, 0x3B, 0xFE, 0x7B, 0x27, 0x30, 0xBB, 0xB6, 0xF2,61.51 - 0x76, 0x22, 0x45, 0x42, 0xCA, 0xF9, 0xF0, 0xDE, 0x9F, 0x45, 0x16, 0x68, 0x22, 0xB9, 0x84, 0x28,61.52 - 0x8F, 0x2B, 0xB5, 0x5C, 0xD2, 0xF5, 0x45, 0x36, 0x3E, 0x76, 0xC6, 0xBF, 0x32, 0x5C, 0x41, 0xA6,61.53 - 0x26, 0xC7, 0x82, 0x2F, 0x2E, 0xB5, 0x75, 0xC6, 0xE6, 0x67, 0x9E, 0x77, 0x94, 0xAF, 0x6A, 0x05,61.54 - 0xC0, 0x05, 0x61, 0x71, 0x89, 0x5A, 0xB1, 0xD0, 0xFC, 0x7E, 0xC0, 0x9B, 0xCB, 0x3B, 0x69, 0xD9,61.55 - 0x5F, 0xAF, 0xCA, 0xAB, 0x25, 0xD5, 0xBE, 0x8A, 0x6B, 0xB0, 0xFB, 0x61, 0x6C, 0xEB, 0x85, 0x6E,61.56 - 0x7A, 0x48, 0xFF, 0x97, 0x91, 0x06, 0x3D, 0x4D, 0x68, 0xD3, 0x65, 0x83, 0x90, 0xA0, 0x08, 0x5C,61.57 - 0xFC, 0xEE, 0x7C, 0x33, 0x43, 0x7F, 0x80, 0x52, 0x8B, 0x19, 0x72, 0xF2, 0xC9, 0xAB, 0x93, 0xAF,61.58 - 0x16, 0xED, 0x36, 0x48, 0xAB, 0xC9, 0xD1, 0x03, 0xB3, 0xDC, 0x2F, 0xF2, 0x92, 0x3F, 0x0A, 0x19,61.59 - 0x25, 0xE2, 0xEF, 0x7A, 0x22, 0xDA, 0xDB, 0xCB, 0x32, 0x12, 0x61, 0x49, 0x5B, 0x74, 0x7C, 0x65,61.60 - 0x20, 0x89, 0x54, 0x9E, 0x0E, 0xC9, 0x52, 0xE3, 0xC9, 0x9A, 0x44, 0xC9, 0x5D, 0xA6, 0x77, 0xC0,61.61 - 0xE7, 0x60, 0x91, 0x80, 0x50, 0x1F, 0x33, 0xB1, 0xCD, 0xAD, 0xF4, 0x0D, 0xBB, 0x08, 0xB1, 0xD0,61.62 - 0x13, 0x95, 0xAE, 0xC9, 0xE2, 0x64, 0xA2, 0x65, 0xFB, 0x8F, 0xE9, 0xA2, 0x8A, 0xBC, 0x98, 0x81,61.63 - 0x45, 0xB4, 0x55, 0x4E, 0xB9, 0x74, 0xB4, 0x50, 0x76, 0xBF, 0xF0, 0x45, 0xE7, 0xEE, 0x41, 0x64,61.64 - 0x9F, 0xB5, 0xE0, 0xBB, 0x1C, 0xBB, 0x28, 0x66, 0x1B, 0xDD, 0x2B, 0x02, 0x66, 0xBF, 0xFD, 0x7D,61.65 - 0x37, 0x35, 0x1D, 0x76, 0x21, 0xC3, 0x8F, 0xAF, 0xF6, 0xF9, 0xE9, 0x27, 0x48, 0xE7, 0x3D, 0x95,61.66 - 0x74, 0x0C, 0x77, 0x88, 0x56, 0xD9, 0x84, 0xC8, 0x7D, 0x20, 0x31, 0x43, 0x53, 0xF1, 0xC1, 0xC7,61.67 - 0xC9, 0xF7, 0x5C, 0xC0, 0xA6, 0x5A, 0x27, 0x0A, 0x41, 0xD4, 0x44, 0x94, 0x65, 0x4F, 0xE2, 0x53,61.68 - 0x60, 0x0B, 0xD1, 0x23, 0x6C, 0x0C, 0xBC, 0x70, 0x6C, 0x26, 0x1A, 0x61, 0x1D, 0x35, 0x88, 0xEC,61.69 - 0xB8, 0x15, 0xE3, 0xB4, 0x82, 0xEE, 0xB3, 0x21, 0xAC, 0x6C, 0xB7, 0x33, 0x6D, 0x78, 0x0C, 0x0D,61.70 - 0xB4, 0x0B, 0x29, 0xF2, 0xD4, 0x8C, 0x3F, 0xDD, 0x3F, 0x47, 0xDD, 0xF2, 0xD8, 0x39, 0x57, 0x20,61.71 - 0x28, 0xD8, 0xDD, 0x32, 0xE2, 0x6A, 0x47, 0x53, 0x57, 0xC6, 0xFA, 0x7A, 0x38, 0x30, 0x31, 0x8F,61.72 - 0xE7, 0xD3, 0x84, 0x2B, 0x5D, 0x4F, 0x95, 0x98, 0xED, 0x0B, 0xD7, 0x50, 0x0C, 0x49, 0xDA, 0x59,61.73 - 0x15, 0xF1, 0x39, 0xF3, 0x40, 0xDC, 0xDC, 0x25, 0x24, 0x56, 0x6E, 0xA9, 0x2F, 0xF0, 0x00, 0x00 };61.74 + 0x0A, 0x99, 0xEE, 0xFB, 0x69, 0xCE, 0xD9, 0x63, 0x00, 0xF5, 0x0A, 0xBC, 0x2C, 0x0D, 0xF8, 0xE2,61.75 + 0x05, 0x02, 0x00, 0x7C, 0x03, 0x00, 0x3D, 0x08, 0xD8, 0x8D, 0x08, 0x7A, 0x6D, 0x00, 0x35, 0x06,61.76 + 0xBA, 0x66, 0x10, 0x00, 0x91, 0x08, 0x10, 0x29, 0xD0, 0x45, 0xDA, 0x00, 0x2D, 0x05, 0x69, 0x09,61.77 + 0x00, 0x5E, 0x0F, 0x70, 0x86, 0x12, 0x6C, 0x77, 0x5A, 0xFB, 0xCD, 0x56, 0xFB, 0xF7, 0xB7, 0x00,61.78 + 0x5D, 0x07, 0x19, 0x99, 0xF2, 0xAF, 0x00, 0x63, 0x03, 0x00, 0xF0, 0x10, 0xBE, 0xD7, 0xA0, 0x63,61.79 + 0xFA, 0x84, 0xA7, 0x74, 0x94, 0xEF, 0xAD, 0xC2, 0xAC, 0x00, 0x78, 0x07, 0x9F, 0x57, 0x0B, 0x62,61.80 + 0x00, 0xFE, 0x08, 0x08, 0x5D, 0x5A, 0x6A, 0x54, 0x00, 0xE2, 0x09, 0x93, 0x7E, 0x62, 0x2A, 0x5E,61.81 + 0xDA, 0x00, 0x7E, 0x0F, 0xF0, 0x07, 0x01, 0x6D, 0x50, 0x86, 0xDD, 0x4A, 0x15, 0x54, 0xC7, 0xEC,61.82 + 0x00, 0xF2, 0x0B, 0x07, 0xF8, 0x1A, 0xB0, 0x99, 0x3B, 0xF1, 0x36, 0x00, 0x94, 0x07, 0x34, 0xE3,61.83 + 0xBC, 0x6E, 0x00, 0x34, 0x0D, 0x6F, 0xDA, 0xBD, 0xEE, 0xF7, 0xCC, 0xCE, 0x39, 0x7E, 0xE3, 0x00,61.84 + 0x14, 0x08, 0xDC, 0xD2, 0xB9, 0xF9, 0x31, 0x00, 0xB0, 0x0C, 0x10, 0xA3, 0x45, 0x12, 0xC7, 0xCD,61.85 + 0xBF, 0x05, 0x37, 0x00, 0xC4, 0x0D, 0x5F, 0xE0, 0x59, 0xBB, 0x01, 0x59, 0x03, 0xD6, 0x29, 0x9C,61.86 + 0x00, 0x01, 0x0A, 0x09, 0xAA, 0xA8, 0xA8, 0x24, 0x0B, 0x66, 0x00, 0x5C, 0x05, 0xA5, 0xCE, 0x00,61.87 + 0xC1, 0x0B, 0xB7, 0xA0, 0x6F, 0xE9, 0x2B, 0xCC, 0xB5, 0xFC, 0x00, 0x8D, 0x05, 0xF4, 0xAC, 0x00,61.88 + 0x57, 0x04, 0xB6, 0x00, 0xFC, 0x03, 0x00, 0xC3, 0x10, 0x43, 0x3B, 0xBE, 0xA2, 0x96, 0xC3, 0x65,61.89 + 0x9F, 0x9A, 0x88, 0xD5, 0x49, 0x68, 0x00, 0xDC, 0x11, 0x56, 0x23, 0x2D, 0xF9, 0xFC, 0xF5, 0x8B,61.90 + 0x1B, 0xB1, 0xB7, 0x10, 0x21, 0x1C, 0x12, 0x00, 0x0D, 0x0D, 0xEB, 0x86, 0xA2, 0x49, 0x8D, 0x8D,61.91 + 0xBE, 0xA1, 0x6D, 0x53, 0x00, 0xE1, 0x0A, 0x8E, 0x67, 0xAA, 0x16, 0x79, 0x39, 0x59, 0x00, 0x36,61.92 + 0x0B, 0x2A, 0x4E, 0xAE, 0x51, 0x4B, 0xD0, 0x66, 0x33, 0x00, 0x8A, 0x07, 0xCD, 0x6F, 0xBA, 0x92,61.93 + 0x00, 0x1A, 0x0E, 0xDF, 0x4A, 0xB3, 0x77, 0x1F, 0xA5, 0x90, 0x19, 0xFA, 0x59, 0xD7, 0x00, 0x04,61.94 + 0x0F, 0xAC, 0xCA, 0x9F, 0xA4, 0xFC, 0x6D, 0x90, 0x86, 0x9E, 0x1F, 0x44, 0x40, 0x00, 0x9F, 0x04,61.95 + 0x56, 0x00, 0x22, 0x03, 0x00, 0xB8, 0x10, 0x2C, 0x7A, 0x53, 0xA4, 0xBF, 0xA3, 0x90, 0x90, 0x14,61.96 + 0x9D, 0x46, 0x6C, 0x96, 0x00, 0xC6, 0x0B, 0x9B, 0xBB, 0xB0, 0xAE, 0x60, 0x92, 0x8E, 0x0C, 0x00,61.97 + 0x14, 0x06, 0x4B, 0xAE, 0x7F, 0x00, 0x5C, 0x0B, 0x23, 0xFA, 0xE7, 0x51, 0xDA, 0x61, 0x49, 0x5E,61.98 + 0x00, 0xD7, 0x0B, 0x01, 0xFC, 0x55, 0x31, 0x84, 0xC5, 0x0C, 0x98, 0x00, 0x97, 0x50, 0x6E, 0xF9,61.99 + 0xEE, 0x75, 0x92, 0x53, 0xD3, 0x66, 0xA4, 0xAF, 0x3B, 0xFE, 0x7B, 0x27, 0x30, 0xBB, 0xB6, 0xF2,61.100 + 0x76, 0x22, 0x45, 0x42, 0xCA, 0xF9, 0xF0, 0xDE, 0x9F, 0x45, 0x16, 0x68, 0x22, 0xB9, 0x84, 0x28,61.101 + 0x8F, 0x2B, 0xB5, 0x5C, 0xD2, 0xF5, 0x45, 0x36, 0x3E, 0x76, 0xC6, 0xBF, 0x32, 0x5C, 0x41, 0xA6,61.102 + 0x26, 0xC7, 0x82, 0x2F, 0x2E, 0xB5, 0x75, 0xC6, 0xE6, 0x67, 0x9E, 0x77, 0x94, 0xAF, 0x6A, 0x05,61.103 + 0xC0, 0x05, 0x61, 0x71, 0x89, 0x5A, 0xB1, 0xD0, 0xFC, 0x7E, 0xC0, 0x9B, 0xCB, 0x3B, 0x69, 0xD9,61.104 + 0x5F, 0xAF, 0xCA, 0xAB, 0x25, 0xD5, 0xBE, 0x8A, 0x6B, 0xB0, 0xFB, 0x61, 0x6C, 0xEB, 0x85, 0x6E,61.105 + 0x7A, 0x48, 0xFF, 0x97, 0x91, 0x06, 0x3D, 0x4D, 0x68, 0xD3, 0x65, 0x83, 0x90, 0xA0, 0x08, 0x5C,61.106 + 0xFC, 0xEE, 0x7C, 0x33, 0x43, 0x7F, 0x80, 0x52, 0x8B, 0x19, 0x72, 0xF2, 0xC9, 0xAB, 0x93, 0xAF,61.107 + 0x16, 0xED, 0x36, 0x48, 0xAB, 0xC9, 0xD1, 0x03, 0xB3, 0xDC, 0x2F, 0xF2, 0x92, 0x3F, 0x0A, 0x19,61.108 + 0x25, 0xE2, 0xEF, 0x7A, 0x22, 0xDA, 0xDB, 0xCB, 0x32, 0x12, 0x61, 0x49, 0x5B, 0x74, 0x7C, 0x65,61.109 + 0x20, 0x89, 0x54, 0x9E, 0x0E, 0xC9, 0x52, 0xE3, 0xC9, 0x9A, 0x44, 0xC9, 0x5D, 0xA6, 0x77, 0xC0,61.110 + 0xE7, 0x60, 0x91, 0x80, 0x50, 0x1F, 0x33, 0xB1, 0xCD, 0xAD, 0xF4, 0x0D, 0xBB, 0x08, 0xB1, 0xD0,61.111 + 0x13, 0x95, 0xAE, 0xC9, 0xE2, 0x64, 0xA2, 0x65, 0xFB, 0x8F, 0xE9, 0xA2, 0x8A, 0xBC, 0x98, 0x81,61.112 + 0x45, 0xB4, 0x55, 0x4E, 0xB9, 0x74, 0xB4, 0x50, 0x76, 0xBF, 0xF0, 0x45, 0xE7, 0xEE, 0x41, 0x64,61.113 + 0x9F, 0xB5, 0xE0, 0xBB, 0x1C, 0xBB, 0x28, 0x66, 0x1B, 0xDD, 0x2B, 0x02, 0x66, 0xBF, 0xFD, 0x7D,61.114 + 0x37, 0x35, 0x1D, 0x76, 0x21, 0xC3, 0x8F, 0xAF, 0xF6, 0xF9, 0xE9, 0x27, 0x48, 0xE7, 0x3D, 0x95,61.115 + 0x74, 0x0C, 0x77, 0x88, 0x56, 0xD9, 0x84, 0xC8, 0x7D, 0x20, 0x31, 0x43, 0x53, 0xF1, 0xC1, 0xC7,61.116 + 0xC9, 0xF7, 0x5C, 0xC0, 0xA6, 0x5A, 0x27, 0x0A, 0x41, 0xD4, 0x44, 0x94, 0x65, 0x4F, 0xE2, 0x53,61.117 + 0x60, 0x0B, 0xD1, 0x23, 0x6C, 0x0C, 0xBC, 0x70, 0x6C, 0x26, 0x1A, 0x61, 0x1D, 0x35, 0x88, 0xEC,61.118 + 0xB8, 0x15, 0xE3, 0xB4, 0x82, 0xEE, 0xB3, 0x21, 0xAC, 0x6C, 0xB7, 0x33, 0x6D, 0x78, 0x0C, 0x0D,61.119 + 0xB4, 0x0B, 0x29, 0xF2, 0xD4, 0x8C, 0x3F, 0xDD, 0x3F, 0x47, 0xDD, 0xF2, 0xD8, 0x39, 0x57, 0x20,61.120 + 0x28, 0xD8, 0xDD, 0x32, 0xE2, 0x6A, 0x47, 0x53, 0x57, 0xC6, 0xFA, 0x7A, 0x38, 0x30, 0x31, 0x8F,61.121 + 0xE7, 0xD3, 0x84, 0x2B, 0x5D, 0x4F, 0x95, 0x98, 0xED, 0x0B, 0xD7, 0x50, 0x0C, 0x49, 0xDA, 0x59,61.122 + 0x15, 0xF1, 0x39, 0xF3, 0x40, 0xDC, 0xDC, 0x25, 0x24, 0x56, 0x6E, 0xA9, 0x2F, 0xF0, 0x00, 0x00 };61.125 char gdrom_status[] = {61.126 - 0x00, 0x15, 0x00, 0x64, 0x00, 0x40, 0x00, 0x00,61.127 - 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,61.128 - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,61.129 - 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,61.130 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,61.131 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,61.132 - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,61.133 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,61.134 - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x40,61.135 - 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,61.136 - 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x40, 0x40,61.137 - 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0x00,61.138 - 0x00, 0x40, 0x00, 0x00 };61.139 + 0x00, 0x15, 0x00, 0x64, 0x00, 0x40, 0x00, 0x00,61.140 + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,61.141 + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,61.142 + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,61.143 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,61.144 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,61.145 + 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,61.146 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,61.147 + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x40,61.148 + 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,61.149 + 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x40, 0x40,61.150 + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0x00,61.151 + 0x00, 0x40, 0x00, 0x00 };61.154 static void ide_init( void )61.155 @@ -161,7 +161,7 @@61.156 static uint32_t ide_run_slice( uint32_t nanosecs )61.157 {61.158 if( gdrom_disc != NULL && gdrom_disc->run_time_slice != NULL ) {61.159 - gdrom_disc->run_time_slice(gdrom_disc, nanosecs);61.160 + gdrom_disc->run_time_slice(gdrom_disc, nanosecs);61.161 }61.162 return nanosecs;61.163 }61.164 @@ -189,11 +189,11 @@61.165 idereg.error = (result & 0x0F) << 4;61.166 idereg.count = 3;61.167 if( result != 0 ) {61.168 - idereg.status = 0x51;61.169 - idereg.state = IDE_STATE_IDLE;61.170 - ide_raise_interrupt();61.171 + idereg.status = 0x51;61.172 + idereg.state = IDE_STATE_IDLE;61.173 + ide_raise_interrupt();61.174 } else {61.175 - idereg.status = idereg.status & ~(IDE_STATUS_BSY|IDE_STATUS_CHK);61.176 + idereg.status = idereg.status & ~(IDE_STATUS_BSY|IDE_STATUS_CHK);61.177 }61.178 }61.180 @@ -220,14 +220,14 @@61.181 idereg.data_length = length;61.182 idereg.data_offset = 0;61.183 if( dma ) {61.184 - idereg.state = IDE_STATE_DMA_READ;61.185 - idereg.status = 0xD0;61.186 + idereg.state = IDE_STATE_DMA_READ;61.187 + idereg.status = 0xD0;61.188 } else {61.189 - idereg.state = IDE_STATE_PIO_READ;61.190 - idereg.status = 0x58;61.191 - idereg.lba1 = length & 0xFF;61.192 - idereg.lba2 = length >> 8;61.193 - ide_raise_interrupt( );61.194 + idereg.state = IDE_STATE_PIO_READ;61.195 + idereg.status = 0x58;61.196 + idereg.lba1 = length & 0xFF;61.197 + idereg.lba2 = length >> 8;61.198 + ide_raise_interrupt( );61.199 }61.200 }61.202 @@ -237,14 +237,14 @@61.203 idereg.data_length = length;61.204 idereg.data_offset = 0;61.205 if( dma ) {61.206 - idereg.state = IDE_STATE_DMA_WRITE;61.207 - idereg.status = 0xD0;61.208 + idereg.state = IDE_STATE_DMA_WRITE;61.209 + idereg.status = 0xD0;61.210 } else {61.211 - idereg.state = IDE_STATE_PIO_WRITE;61.212 - idereg.status = 0x58;61.213 - idereg.lba1 = length & 0xFF;61.214 - idereg.lba2 = length >> 8;61.215 - ide_raise_interrupt( );61.216 + idereg.state = IDE_STATE_PIO_WRITE;61.217 + idereg.status = 0x58;61.218 + idereg.lba1 = length & 0xFF;61.219 + idereg.lba2 = length >> 8;61.220 + ide_raise_interrupt( );61.221 }61.222 }61.224 @@ -265,18 +265,18 @@61.225 static void ide_raise_interrupt( void )61.226 {61.227 if( idereg.intrq_pending == 0 ) {61.228 - idereg.intrq_pending = 1;61.229 - if( IS_IDE_IRQ_ENABLED() )61.230 - asic_event( EVENT_IDE );61.231 + idereg.intrq_pending = 1;61.232 + if( IS_IDE_IRQ_ENABLED() )61.233 + asic_event( EVENT_IDE );61.234 }61.235 }61.237 static void ide_clear_interrupt( void )61.238 {61.239 if( idereg.intrq_pending != 0 ) {61.240 - idereg.intrq_pending = 0;61.241 - if( IS_IDE_IRQ_ENABLED() )61.242 - asic_clear_event( EVENT_IDE );61.243 + idereg.intrq_pending = 0;61.244 + if( IS_IDE_IRQ_ENABLED() )61.245 + asic_clear_event( EVENT_IDE );61.246 }61.247 }61.249 @@ -289,25 +289,25 @@61.250 uint8_t ide_read_status( void )61.251 {61.252 if( (idereg.status & IDE_STATUS_BSY) == 0 )61.253 - ide_clear_interrupt();61.254 + ide_clear_interrupt();61.255 return idereg.status;61.256 }61.258 uint16_t ide_read_data_pio( void ) {61.259 if( idereg.state == IDE_STATE_PIO_READ ) {61.260 - uint16_t rv = READ_BUFFER();61.261 - idereg.data_offset += 2;61.262 - if( idereg.data_offset >= idereg.data_length ) {61.263 - idereg.state = IDE_STATE_IDLE;61.264 - idereg.status &= ~IDE_STATUS_DRQ;61.265 - idereg.data_offset = -1;61.266 - idereg.count = 3; /* complete */61.267 - ide_raise_interrupt();61.268 - if( idereg.sectors_left > 0 ) {61.269 - ide_read_next_sector();61.270 - }61.271 - }61.272 - return rv;61.273 + uint16_t rv = READ_BUFFER();61.274 + idereg.data_offset += 2;61.275 + if( idereg.data_offset >= idereg.data_length ) {61.276 + idereg.state = IDE_STATE_IDLE;61.277 + idereg.status &= ~IDE_STATUS_DRQ;61.278 + idereg.data_offset = -1;61.279 + idereg.count = 3; /* complete */61.280 + ide_raise_interrupt();61.281 + if( idereg.sectors_left > 0 ) {61.282 + ide_read_next_sector();61.283 + }61.284 + }61.285 + return rv;61.286 } else {61.287 return 0xFFFF;61.288 }61.289 @@ -327,63 +327,63 @@61.290 {61.291 uint32_t xfercount = 0;61.292 while( xfercount < length && idereg.state == IDE_STATE_DMA_READ ) {61.293 - int xferlen = length - xfercount;61.294 - int remaining = idereg.data_length - idereg.data_offset;61.295 - if( xferlen > remaining ) {61.296 - xferlen = remaining;61.297 - }61.298 - mem_copy_to_sh4( addr, (data_buffer + idereg.data_offset), xferlen );61.299 - xfercount += xferlen;61.300 - addr += xferlen;61.301 - idereg.data_offset += xferlen;61.302 - if( idereg.data_offset >= idereg.data_length ) {61.303 - if( idereg.sectors_left > 0 ) {61.304 - ide_read_next_sector();61.305 - } else {61.306 - idereg.data_offset = -1;61.307 - idereg.state = IDE_STATE_IDLE;61.308 - idereg.status = 0x50;61.309 - idereg.count = 0x03;61.310 - ide_raise_interrupt();61.311 - asic_event( EVENT_IDE_DMA );61.312 - break;61.313 - }61.314 - }61.315 + int xferlen = length - xfercount;61.316 + int remaining = idereg.data_length - idereg.data_offset;61.317 + if( xferlen > remaining ) {61.318 + xferlen = remaining;61.319 + }61.320 + mem_copy_to_sh4( addr, (data_buffer + idereg.data_offset), xferlen );61.321 + xfercount += xferlen;61.322 + addr += xferlen;61.323 + idereg.data_offset += xferlen;61.324 + if( idereg.data_offset >= idereg.data_length ) {61.325 + if( idereg.sectors_left > 0 ) {61.326 + ide_read_next_sector();61.327 + } else {61.328 + idereg.data_offset = -1;61.329 + idereg.state = IDE_STATE_IDLE;61.330 + idereg.status = 0x50;61.331 + idereg.count = 0x03;61.332 + ide_raise_interrupt();61.333 + asic_event( EVENT_IDE_DMA );61.334 + break;61.335 + }61.336 + }61.337 }61.338 return xfercount;61.339 }61.341 void ide_write_data_pio( uint16_t val ) {61.342 if( idereg.state == IDE_STATE_CMD_WRITE ) {61.343 - WRITE_BUFFER(val);61.344 - idereg.data_offset+=2;61.345 - if( idereg.data_offset >= idereg.data_length ) {61.346 - idereg.state = IDE_STATE_BUSY;61.347 - idereg.status = (idereg.status & ~IDE_STATUS_DRQ) | IDE_STATUS_BSY;61.348 - idereg.data_offset = -1;61.349 - ide_packet_command(data_buffer);61.350 - }61.351 + WRITE_BUFFER(val);61.352 + idereg.data_offset+=2;61.353 + if( idereg.data_offset >= idereg.data_length ) {61.354 + idereg.state = IDE_STATE_BUSY;61.355 + idereg.status = (idereg.status & ~IDE_STATUS_DRQ) | IDE_STATUS_BSY;61.356 + idereg.data_offset = -1;61.357 + ide_packet_command(data_buffer);61.358 + }61.359 } else if( idereg.state == IDE_STATE_PIO_WRITE ) {61.360 - WRITE_BUFFER(val);61.361 - idereg.data_offset +=2;61.362 - if( idereg.data_offset >= idereg.data_length ) {61.363 - idereg.state = IDE_STATE_IDLE;61.364 - idereg.status &= ~IDE_STATUS_DRQ;61.365 - idereg.data_offset = -1;61.366 - idereg.count = 3; /* complete */61.367 - ide_raise_interrupt();61.368 - ide_write_buffer( data_buffer, idereg.data_length );61.369 - }61.370 + WRITE_BUFFER(val);61.371 + idereg.data_offset +=2;61.372 + if( idereg.data_offset >= idereg.data_length ) {61.373 + idereg.state = IDE_STATE_IDLE;61.374 + idereg.status &= ~IDE_STATUS_DRQ;61.375 + idereg.data_offset = -1;61.376 + idereg.count = 3; /* complete */61.377 + ide_raise_interrupt();61.378 + ide_write_buffer( data_buffer, idereg.data_length );61.379 + }61.380 }61.381 }61.383 void ide_write_control( uint8_t val ) {61.384 if( IS_IDE_IRQ_ENABLED() ) {61.385 - if( (val & 0x02) != 0 && idereg.intrq_pending != 0 )61.386 - asic_clear_event( EVENT_IDE );61.387 + if( (val & 0x02) != 0 && idereg.intrq_pending != 0 )61.388 + asic_clear_event( EVENT_IDE );61.389 } else {61.390 - if( (val & 0x02) == 0 && idereg.intrq_pending != 0 )61.391 - asic_event( EVENT_IDE );61.392 + if( (val & 0x02) == 0 && idereg.intrq_pending != 0 )61.393 + asic_event( EVENT_IDE );61.394 }61.395 idereg.control = val;61.396 }61.397 @@ -393,59 +393,59 @@61.398 idereg.command = val;61.399 switch( val ) {61.400 case IDE_CMD_NOP: /* Effectively an "abort" */61.401 - idereg.state = IDE_STATE_IDLE;61.402 - idereg.status = 0x51;61.403 - idereg.error = 0x04;61.404 - idereg.data_offset = -1;61.405 - ide_raise_interrupt();61.406 - return;61.407 + idereg.state = IDE_STATE_IDLE;61.408 + idereg.status = 0x51;61.409 + idereg.error = 0x04;61.410 + idereg.data_offset = -1;61.411 + ide_raise_interrupt();61.412 + return;61.413 case IDE_CMD_RESET_DEVICE:61.414 - ide_reset();61.415 - break;61.416 + ide_reset();61.417 + break;61.418 case IDE_CMD_PACKET:61.419 - ide_start_command_packet_write();61.420 - break;61.421 + ide_start_command_packet_write();61.422 + break;61.423 case IDE_CMD_SET_FEATURE:61.424 - switch( idereg.feature ) {61.425 - case IDE_FEAT_SET_TRANSFER_MODE:61.426 - switch( idereg.count & 0xF8 ) {61.427 - case IDE_XFER_PIO:61.428 - INFO( "Set PIO default mode: %d", idereg.count&0x07 );61.429 - break;61.430 - case IDE_XFER_PIO_FLOW:61.431 - INFO( "Set PIO Flow-control mode: %d", idereg.count&0x07 );61.432 - break;61.433 - case IDE_XFER_MULTI_DMA:61.434 - INFO( "Set Multiword DMA mode: %d", idereg.count&0x07 );61.435 - break;61.436 - case IDE_XFER_ULTRA_DMA:61.437 - INFO( "Set Ultra DMA mode: %d", idereg.count&0x07 );61.438 - break;61.439 - default:61.440 - INFO( "Setting unknown transfer mode: %02X", idereg.count );61.441 - break;61.442 - }61.443 - break;61.444 - default:61.445 - WARN( "IDE: unimplemented feature: %02X", idereg.feature );61.446 - }61.447 - idereg.status = 0x50;61.448 - idereg.error = 0x00;61.449 - idereg.lba1 = 0x00;61.450 - idereg.lba2 = 0x00;61.451 - ide_raise_interrupt();61.452 - break;61.453 - default:61.454 - WARN( "IDE: Unimplemented command: %02X", val );61.455 + switch( idereg.feature ) {61.456 + case IDE_FEAT_SET_TRANSFER_MODE:61.457 + switch( idereg.count & 0xF8 ) {61.458 + case IDE_XFER_PIO:61.459 + INFO( "Set PIO default mode: %d", idereg.count&0x07 );61.460 + break;61.461 + case IDE_XFER_PIO_FLOW:61.462 + INFO( "Set PIO Flow-control mode: %d", idereg.count&0x07 );61.463 + break;61.464 + case IDE_XFER_MULTI_DMA:61.465 + INFO( "Set Multiword DMA mode: %d", idereg.count&0x07 );61.466 + break;61.467 + case IDE_XFER_ULTRA_DMA:61.468 + INFO( "Set Ultra DMA mode: %d", idereg.count&0x07 );61.469 + break;61.470 + default:61.471 + INFO( "Setting unknown transfer mode: %02X", idereg.count );61.472 + break;61.473 + }61.474 + break;61.475 + default:61.476 + WARN( "IDE: unimplemented feature: %02X", idereg.feature );61.477 + }61.478 + idereg.status = 0x50;61.479 + idereg.error = 0x00;61.480 + idereg.lba1 = 0x00;61.481 + idereg.lba2 = 0x00;61.482 + ide_raise_interrupt();61.483 + break;61.484 + default:61.485 + WARN( "IDE: Unimplemented command: %02X", val );61.486 }61.487 }61.489 uint8_t ide_get_drive_status( void )61.490 {61.491 if( gdrom_disc == NULL ) {61.492 - return IDE_DISC_NONE;61.493 + return IDE_DISC_NONE;61.494 } else {61.495 - return gdrom_disc->drive_status(gdrom_disc);61.496 + return gdrom_disc->drive_status(gdrom_disc);61.497 }61.498 }61.500 @@ -459,18 +459,18 @@61.501 uint32_t sector_size;61.502 REQUIRE_DISC();61.503 gdrom_error_t status =61.504 - gdrom_disc->read_sector( gdrom_disc, idereg.current_lba, idereg.current_mode,61.505 - data_buffer, §or_size );61.506 + gdrom_disc->read_sector( gdrom_disc, idereg.current_lba, idereg.current_mode,61.507 + data_buffer, §or_size );61.508 if( status != PKT_ERR_OK ) {61.509 - ide_set_packet_result( status );61.510 - idereg.gdrom_sense[5] = (idereg.current_lba >> 16) & 0xFF;61.511 - idereg.gdrom_sense[6] = (idereg.current_lba >> 8) & 0xFF;61.512 - idereg.gdrom_sense[7] = idereg.current_lba & 0xFF;61.513 - WARN( " => Read CD returned sense key %02X, %02X", status & 0xFF, status >> 8 );61.514 + ide_set_packet_result( status );61.515 + idereg.gdrom_sense[5] = (idereg.current_lba >> 16) & 0xFF;61.516 + idereg.gdrom_sense[6] = (idereg.current_lba >> 8) & 0xFF;61.517 + idereg.gdrom_sense[7] = idereg.current_lba & 0xFF;61.518 + WARN( " => Read CD returned sense key %02X, %02X", status & 0xFF, status >> 8 );61.519 } else {61.520 - idereg.current_lba++;61.521 - idereg.sectors_left--;61.522 - ide_start_read( sector_size, (idereg.feature & IDE_FEAT_DMA) ? TRUE : FALSE );61.523 + idereg.current_lba++;61.524 + idereg.sectors_left--;61.525 + ide_start_read( sector_size, (idereg.feature & IDE_FEAT_DMA) ? TRUE : FALSE );61.526 }61.527 }61.529 @@ -486,133 +486,133 @@61.531 /* Okay we have the packet in the command buffer */61.532 INFO( "ATAPI packet: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",61.533 - cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6], cmd[7],61.534 - cmd[8], cmd[9], cmd[10], cmd[11] );61.535 + cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6], cmd[7],61.536 + cmd[8], cmd[9], cmd[10], cmd[11] );61.538 if( cmd[0] != PKT_CMD_SENSE && idereg.was_reset ) {61.539 - ide_set_packet_result( PKT_ERR_RESET );61.540 - idereg.was_reset = FALSE;61.541 - return;61.542 + ide_set_packet_result( PKT_ERR_RESET );61.543 + idereg.was_reset = FALSE;61.544 + return;61.545 }61.547 switch( cmd[0] ) {61.548 case PKT_CMD_TEST_READY:61.549 - REQUIRE_DISC();61.550 - ide_set_packet_result( 0 );61.551 - ide_raise_interrupt();61.552 - idereg.status = 0x50;61.553 - break;61.554 + REQUIRE_DISC();61.555 + ide_set_packet_result( 0 );61.556 + ide_raise_interrupt();61.557 + idereg.status = 0x50;61.558 + break;61.559 case PKT_CMD_MODE_SENSE:61.560 - lba = cmd[2];61.561 - if( lba >= GDROM_MODE_LENGTH ) {61.562 - ide_set_error(PKT_ERR_BADFIELD);61.563 - } else {61.564 - length = cmd[4];61.565 - if( lba+length > GDROM_MODE_LENGTH )61.566 - length = GDROM_MODE_LENGTH - lba;61.567 - memcpy( data_buffer, idereg.gdrom_mode + lba, length );61.568 - ide_start_packet_read( length, 0 );61.569 - }61.570 - break;61.571 + lba = cmd[2];61.572 + if( lba >= GDROM_MODE_LENGTH ) {61.573 + ide_set_error(PKT_ERR_BADFIELD);61.574 + } else {61.575 + length = cmd[4];61.576 + if( lba+length > GDROM_MODE_LENGTH )61.577 + length = GDROM_MODE_LENGTH - lba;61.578 + memcpy( data_buffer, idereg.gdrom_mode + lba, length );61.579 + ide_start_packet_read( length, 0 );61.580 + }61.581 + break;61.582 case PKT_CMD_MODE_SELECT:61.583 - lba = cmd[2];61.584 - if( lba >= GDROM_MODE_LENGTH ) {61.585 - ide_set_error(PKT_ERR_BADFIELD);61.586 - } else {61.587 - length = cmd[4];61.588 - if( lba+length > GDROM_MODE_LENGTH )61.589 - length = GDROM_MODE_LENGTH - lba;61.590 - idereg.current_lba = lba;61.591 - ide_start_packet_write( length, 0 );61.592 - }61.593 - break;61.594 + lba = cmd[2];61.595 + if( lba >= GDROM_MODE_LENGTH ) {61.596 + ide_set_error(PKT_ERR_BADFIELD);61.597 + } else {61.598 + length = cmd[4];61.599 + if( lba+length > GDROM_MODE_LENGTH )61.600 + length = GDROM_MODE_LENGTH - lba;61.601 + idereg.current_lba = lba;61.602 + ide_start_packet_write( length, 0 );61.603 + }61.604 + break;61.605 case PKT_CMD_SENSE:61.606 - length = cmd[4];61.607 - if( length > 10 )61.608 - length = 10;61.609 - memcpy( data_buffer, idereg.gdrom_sense, length );61.610 - ide_start_packet_read( length, 0 );61.611 - break;61.612 + length = cmd[4];61.613 + if( length > 10 )61.614 + length = 10;61.615 + memcpy( data_buffer, idereg.gdrom_sense, length );61.616 + ide_start_packet_read( length, 0 );61.617 + break;61.618 case PKT_CMD_READ_TOC:61.619 - REQUIRE_DISC();61.620 - length = (cmd[3]<<8) | cmd[4];61.621 - if( length > sizeof(struct gdrom_toc) )61.622 - length = sizeof(struct gdrom_toc);61.623 + REQUIRE_DISC();61.624 + length = (cmd[3]<<8) | cmd[4];61.625 + if( length > sizeof(struct gdrom_toc) )61.626 + length = sizeof(struct gdrom_toc);61.628 - status = gdrom_disc->read_toc( gdrom_disc, data_buffer );61.629 - if( status != PKT_ERR_OK ) {61.630 - ide_set_packet_result( status );61.631 - } else {61.632 - ide_start_packet_read( length, 0 );61.633 - }61.634 - break;61.635 + status = gdrom_disc->read_toc( gdrom_disc, data_buffer );61.636 + if( status != PKT_ERR_OK ) {61.637 + ide_set_packet_result( status );61.638 + } else {61.639 + ide_start_packet_read( length, 0 );61.640 + }61.641 + break;61.642 case PKT_CMD_SESSION_INFO:61.643 - REQUIRE_DISC();61.644 - length = cmd[4];61.645 - if( length > 6 )61.646 - length = 6;61.647 - status = gdrom_disc->read_session( gdrom_disc, cmd[2], data_buffer );61.648 - if( status != PKT_ERR_OK ) {61.649 - ide_set_packet_result( status );61.650 - } else {61.651 - ide_start_packet_read( length, 0 );61.652 - }61.653 - break;61.654 + REQUIRE_DISC();61.655 + length = cmd[4];61.656 + if( length > 6 )61.657 + length = 6;61.658 + status = gdrom_disc->read_session( gdrom_disc, cmd[2], data_buffer );61.659 + if( status != PKT_ERR_OK ) {61.660 + ide_set_packet_result( status );61.661 + } else {61.662 + ide_start_packet_read( length, 0 );61.663 + }61.664 + break;61.665 case PKT_CMD_PLAY_AUDIO:61.666 - REQUIRE_DISC();61.667 - ide_set_packet_result( 0 );61.668 - ide_raise_interrupt();61.669 - idereg.status = 0x50;61.670 - break;61.671 + REQUIRE_DISC();61.672 + ide_set_packet_result( 0 );61.673 + ide_raise_interrupt();61.674 + idereg.status = 0x50;61.675 + break;61.676 case PKT_CMD_READ_SECTOR:61.677 - REQUIRE_DISC();61.678 - idereg.current_lba = cmd[2] << 16 | cmd[3] << 8 | cmd[4];61.679 - idereg.sectors_left = cmd[8] << 16 | cmd[9] << 8 | cmd[10]; /* blocks */61.680 - idereg.current_mode = cmd[1];61.681 - ide_read_next_sector();61.682 - break;61.683 + REQUIRE_DISC();61.684 + idereg.current_lba = cmd[2] << 16 | cmd[3] << 8 | cmd[4];61.685 + idereg.sectors_left = cmd[8] << 16 | cmd[9] << 8 | cmd[10]; /* blocks */61.686 + idereg.current_mode = cmd[1];61.687 + ide_read_next_sector();61.688 + break;61.689 case PKT_CMD_SPIN_UP:61.690 - REQUIRE_DISC();61.691 - /* do nothing? */61.692 - ide_set_packet_result( PKT_ERR_OK );61.693 - ide_raise_interrupt();61.694 - break;61.695 + REQUIRE_DISC();61.696 + /* do nothing? */61.697 + ide_set_packet_result( PKT_ERR_OK );61.698 + ide_raise_interrupt();61.699 + break;61.700 case PKT_CMD_STATUS:61.701 - REQUIRE_DISC();61.702 - length = cmd[4];61.703 - switch( cmd[1] ) {61.704 - case 0:61.705 - if( length > sizeof(gdrom_status) ) {61.706 - length = sizeof(gdrom_status);61.707 - }61.708 - memcpy( data_buffer, gdrom_status, length );61.709 - ide_start_packet_read( length, 0 );61.710 - break;61.711 - case 1:61.712 - if( length > 14 ) {61.713 - length = 14;61.714 - }61.715 - gdrom_disc->read_position( gdrom_disc, idereg.current_lba, data_buffer );61.716 - data_buffer[0] = 0x00;61.717 - data_buffer[1] = 0x15; /* audio status ? */61.718 - data_buffer[2] = 0x00;61.719 - data_buffer[3] = 0x0E;61.720 - ide_start_packet_read( length, 0 );61.721 - break;61.722 - }61.723 - break;61.724 - case PKT_CMD_71:61.725 - /* This is a weird one. As far as I can tell it returns random garbage61.726 - * (and not even the same length each time, never mind the same data).61.727 - * For sake of something to do, it returns the results from a test dump61.728 - */61.729 - REQUIRE_DISC();61.730 - memcpy( data_buffer, gdrom_71, sizeof(gdrom_71) );61.731 - ide_start_packet_read( sizeof(gdrom_71), 0 );61.732 - break;61.733 - default:61.734 - ide_set_packet_result( PKT_ERR_BADCMD ); /* Invalid command */61.735 - return;61.736 + REQUIRE_DISC();61.737 + length = cmd[4];61.738 + switch( cmd[1] ) {61.739 + case 0:61.740 + if( length > sizeof(gdrom_status) ) {61.741 + length = sizeof(gdrom_status);61.742 + }61.743 + memcpy( data_buffer, gdrom_status, length );61.744 + ide_start_packet_read( length, 0 );61.745 + break;61.746 + case 1:61.747 + if( length > 14 ) {61.748 + length = 14;61.749 + }61.750 + gdrom_disc->read_position( gdrom_disc, idereg.current_lba, data_buffer );61.751 + data_buffer[0] = 0x00;61.752 + data_buffer[1] = 0x15; /* audio status ? */61.753 + data_buffer[2] = 0x00;61.754 + data_buffer[3] = 0x0E;61.755 + ide_start_packet_read( length, 0 );61.756 + break;61.757 + }61.758 + break;61.759 + case PKT_CMD_71:61.760 + /* This is a weird one. As far as I can tell it returns random garbage61.761 + * (and not even the same length each time, never mind the same data).61.762 + * For sake of something to do, it returns the results from a test dump61.763 + */61.764 + REQUIRE_DISC();61.765 + memcpy( data_buffer, gdrom_71, sizeof(gdrom_71) );61.766 + ide_start_packet_read( sizeof(gdrom_71), 0 );61.767 + break;61.768 + default:61.769 + ide_set_packet_result( PKT_ERR_BADCMD ); /* Invalid command */61.770 + return;61.771 }61.772 idereg.last_packet_command = cmd[0];61.773 }61.774 @@ -621,14 +621,14 @@61.775 {61.776 switch( idereg.last_packet_command ) {61.777 case PKT_CMD_MODE_SELECT:61.778 - if( idereg.current_lba < 10 ) {61.779 - if( idereg.current_lba + length > 10 ) {61.780 - length = 10 - idereg.current_lba;61.781 - }61.782 - memcpy( idereg.gdrom_mode + idereg.current_lba, data, length );61.783 - }61.784 - break;61.785 + if( idereg.current_lba < 10 ) {61.786 + if( idereg.current_lba + length > 10 ) {61.787 + length = 10 - idereg.current_lba;61.788 + }61.789 + memcpy( idereg.gdrom_mode + idereg.current_lba, data, length );61.790 + }61.791 + break;61.792 default:61.793 - WARN( "Don't know what to do with received data buffer for command %02X", idereg.last_packet_command );61.794 + WARN( "Don't know what to do with received data buffer for command %02X", idereg.last_packet_command );61.795 }61.796 }
62.1 --- a/src/gdrom/ide.h Mon Jul 14 07:42:45 2008 +000062.2 +++ b/src/gdrom/ide.h Mon Jul 14 07:44:42 2008 +000062.3 @@ -20,10 +20,14 @@62.4 * GNU General Public License for more details.62.5 */62.7 -#ifndef dream_ide_H62.8 -#define dream_ide_H 162.9 +#ifndef lxdream_ide_H62.10 +#define lxdream_ide_H 162.12 -#include "dream.h"62.13 +#include "lxdream.h"62.14 +62.15 +#ifdef __cplusplus62.16 +extern "C" {62.17 +#endif62.19 #define GDROM_SENSE_LENGTH 1062.20 #define GDROM_MODE_LENGTH 3262.21 @@ -126,4 +130,9 @@62.22 void ide_write_control( uint8_t value );62.24 void ide_dma_read_req( uint32_t addr, uint32_t length );62.25 +62.26 +#ifdef __cplusplus62.27 +}62.28 #endif62.29 +62.30 +#endif /* !lxdream_ide_H */
63.1 --- a/src/gdrom/nrg.c Mon Jul 14 07:42:45 2008 +000063.2 +++ b/src/gdrom/nrg.c Mon Jul 14 07:44:42 2008 +000063.3 @@ -28,7 +28,7 @@63.4 static gdrom_disc_t nrg_image_open( const gchar *filename, FILE *f );63.6 struct gdrom_image_class nrg_image_class = { "Nero", "nrg",63.7 - nrg_image_is_valid, nrg_image_open };63.8 + nrg_image_is_valid, nrg_image_open };63.10 #define NERO_V55_ID 0x4e45523563.11 #define NERO_V50_ID 0x4e45524f63.12 @@ -52,13 +52,13 @@63.14 union nrg_footer {63.15 struct nrg_footer_v50 {63.16 - uint32_t dummy;63.17 - uint32_t id;63.18 - uint32_t offset;63.19 + uint32_t dummy;63.20 + uint32_t id;63.21 + uint32_t offset;63.22 } v50;63.23 struct nrg_footer_v55 {63.24 - uint32_t id;63.25 - uint64_t offset;63.26 + uint32_t id;63.27 + uint64_t offset;63.28 } v55;63.29 };63.31 @@ -98,13 +98,13 @@63.32 uint8_t unknown[2]; /* always 01 01? */63.33 uint8_t track_count;63.34 struct nrg_daoi_track {63.35 - char unknown[10];63.36 - uint32_t sector_size __attribute__((packed)); /* Always 0? */63.37 - uint8_t mode;63.38 - uint8_t unknown2[3]; /* Always 00 00 01? */63.39 - uint32_t pregap __attribute__((packed));63.40 - uint32_t offset __attribute__((packed));63.41 - uint32_t end __attribute__((packed));63.42 + char unknown[10];63.43 + uint32_t sector_size __attribute__((packed)); /* Always 0? */63.44 + uint8_t mode;63.45 + uint8_t unknown2[3]; /* Always 00 00 01? */63.46 + uint32_t pregap __attribute__((packed));63.47 + uint32_t offset __attribute__((packed));63.48 + uint32_t end __attribute__((packed));63.49 } track[0];63.50 } __attribute__((packed));63.52 @@ -115,13 +115,13 @@63.53 uint8_t unknown[2]; /* always 01 01? */63.54 uint8_t track_count;63.55 struct nrg_daox_track {63.56 - char unknown[10];63.57 - uint32_t sector_size __attribute__((packed)); /* Always 0? */63.58 - uint8_t mode;63.59 - uint8_t unknown2[3]; /* Always 00 00 01? */63.60 - uint64_t pregap __attribute__((packed));63.61 - uint64_t offset __attribute__((packed));63.62 - uint64_t end __attribute__((packed));63.63 + char unknown[10];63.64 + uint32_t sector_size __attribute__((packed)); /* Always 0? */63.65 + uint8_t mode;63.66 + uint8_t unknown2[3]; /* Always 00 00 01? */63.67 + uint64_t pregap __attribute__((packed));63.68 + uint64_t offset __attribute__((packed));63.69 + uint64_t end __attribute__((packed));63.70 } track[0];63.71 } __attribute__((packed));63.73 @@ -158,8 +158,8 @@63.74 case 3: return GDROM_SEMIRAW_MODE2;63.75 case 7: return GDROM_CDDA;63.76 default:63.77 - ERROR( "Unrecognized track mode %d in Nero image", mode );63.78 - return -1;63.79 + ERROR( "Unrecognized track mode %d in Nero image", mode );63.80 + return -1;63.81 }63.82 }63.84 @@ -170,10 +170,10 @@63.85 fseek( f, -12, SEEK_END );63.86 fread( &footer, sizeof(footer), 1, f );63.87 if( GUINT32_FROM_BE(footer.v50.id) == NERO_V50_ID ||63.88 - GUINT32_FROM_BE(footer.v55.id) == NERO_V55_ID ) {63.89 - return TRUE;63.90 + GUINT32_FROM_BE(footer.v55.id) == NERO_V55_ID ) {63.91 + return TRUE;63.92 } else {63.93 - return FALSE;63.94 + return FALSE;63.95 }63.96 }63.98 @@ -198,151 +198,151 @@63.99 fseek( f, -12, SEEK_END );63.100 fread( &footer, sizeof(footer), 1, f );63.101 if( GUINT32_FROM_BE(footer.v50.id) == NERO_V50_ID ) {63.102 - INFO( "Loading Nero 5.0 image" );63.103 - fseek( f, GUINT32_FROM_BE(footer.v50.offset), SEEK_SET );63.104 + INFO( "Loading Nero 5.0 image" );63.105 + fseek( f, GUINT32_FROM_BE(footer.v50.offset), SEEK_SET );63.106 } else if( GUINT32_FROM_BE(footer.v55.id) == NERO_V55_ID ) {63.107 - INFO( "Loading Nero 5.5+ image" );63.108 - fseek( f, (uint32_t)GUINT64_FROM_BE(footer.v55.offset), SEEK_SET );63.109 + INFO( "Loading Nero 5.5+ image" );63.110 + fseek( f, (uint32_t)GUINT64_FROM_BE(footer.v55.offset), SEEK_SET );63.111 } else {63.112 - /* Not a (recognized) Nero image */63.113 - return NULL;63.114 + /* Not a (recognized) Nero image */63.115 + return NULL;63.116 }63.117 -63.118 +63.119 disc = gdrom_image_new(filename, f);63.120 if( disc == NULL ) {63.121 - ERROR("Unable to allocate memory!");63.122 - return NULL;63.123 + ERROR("Unable to allocate memory!");63.124 + return NULL;63.125 }63.126 image = (gdrom_image_t)disc;63.128 do {63.129 - fread( &chunk, sizeof(chunk), 1, f );63.130 - chunk.length = GUINT32_FROM_BE(chunk.length);63.131 - char data[chunk.length];63.132 - fread( data, chunk.length, 1, f );63.133 - chunk_id = GUINT32_FROM_BE(chunk.id);63.134 - switch( chunk_id ) {63.135 - case CUES_ID:63.136 - case CUEX_ID:63.137 - cue_track_id = track_id;63.138 - cue_track_count = ((chunk.length / sizeof(struct nrg_cues)) >> 1) - 1;63.139 - track_id += cue_track_count;63.140 - for( i=0; i<chunk.length; i+= sizeof(struct nrg_cues) ) {63.141 - struct nrg_cues *cue = (struct nrg_cues *)(data+i);63.142 - int track = 0;63.143 - uint32_t lba;63.144 - if( chunk_id == CUEX_ID ) {63.145 - lba = GUINT32_FROM_BE( cue->addr ) + GDROM_PREGAP;63.146 - } else {63.147 - lba = msf_to_lba( cue->addr );63.148 - }63.149 - if( cue->track == 0 )63.150 - continue; /* Track 0. Leadin? always 0? */63.151 - if( cue->track == 0xAA ) { /* end of disc */63.152 - image->track[track_id-1].sector_count =63.153 - lba - image->track[track_id-1].lba;63.154 - } else {63.155 - track = cue_track_id + bcd_to_uint8(cue->track) - 1;63.156 - if( (cue->control & 0x01) == 0 ) {63.157 - /* Pre-gap address. */63.158 - if( track != 0 ) {63.159 - image->track[track-1].sector_count =63.160 - lba - image->track[track-1].lba;63.161 - }63.162 - } else { /* Track-start address */63.163 - image->track[track].lba = lba;63.164 - image->track[track].flags = cue->type;63.165 - }63.166 - }63.167 - }63.168 - break;63.169 - case DAOI_ID:63.170 - dao = (struct nrg_daoi *)data;63.171 - memcpy( image->mcn, dao->mcn, 13 );63.172 - image->mcn[13] = '\0';63.173 - assert( dao->track_count * 30 + 22 == chunk.length );63.174 - assert( dao->track_count == cue_track_count );63.175 - for( i=0; i<dao->track_count; i++ ) {63.176 - image->track[cue_track_id].sector_size = GUINT32_FROM_BE(dao->track[i].sector_size);63.177 - image->track[cue_track_id].offset = GUINT32_FROM_BE(dao->track[i].offset);63.178 - image->track[cue_track_id].mode = nrg_track_mode( dao->track[i].mode );63.179 - image->track[cue_track_id].sector_count =63.180 - (GUINT32_FROM_BE(dao->track[i].end) - GUINT32_FROM_BE(dao->track[i].offset))/63.181 - GUINT32_FROM_BE(dao->track[i].sector_size);63.182 - cue_track_id++;63.183 - }63.184 - break;63.185 - case DAOX_ID:63.186 - daox = (struct nrg_daox *)data;63.187 - memcpy( image->mcn, daox->mcn, 13 );63.188 - image->mcn[13] = '\0';63.189 - assert( daox->track_count * 42 + 22 == chunk.length );63.190 - assert( daox->track_count == cue_track_count );63.191 - for( i=0; i<daox->track_count; i++ ) {63.192 - image->track[cue_track_id].sector_size = GUINT32_FROM_BE(daox->track[i].sector_size);63.193 - image->track[cue_track_id].offset = GUINT64_FROM_BE(daox->track[i].offset);63.194 - image->track[cue_track_id].mode = nrg_track_mode( daox->track[i].mode );63.195 - image->track[cue_track_id].sector_count =63.196 - (GUINT64_FROM_BE(daox->track[i].end) - GUINT64_FROM_BE(daox->track[i].offset))/63.197 - GUINT32_FROM_BE(daox->track[i].sector_size);63.198 - cue_track_id++;63.199 - }63.200 - break;63.201 -63.202 - case SINF_ID:63.203 - /* Data is a single 32-bit number representing number of tracks in session */63.204 - i = GUINT32_FROM_BE( *(uint32_t *)data );63.205 - while( i-- > 0 )63.206 - image->track[session_track_id++].session = session_id;63.207 - session_id++;63.208 - break;63.209 - case ETNF_ID:63.210 - etnf = (struct nrg_etnf *)data;63.211 - count = chunk.length / sizeof(struct nrg_etnf);63.212 - for( i=0; i < count; i++, etnf++ ) {63.213 - image->track[track_id].offset = GUINT32_FROM_BE(etnf->offset);63.214 - image->track[track_id].lba = GUINT32_FROM_BE(etnf->lba) + (i+1)*GDROM_PREGAP;63.215 - image->track[track_id].mode = nrg_track_mode( GUINT32_FROM_BE(etnf->mode) );63.216 - if( image->track[track_id].mode == -1 ) {63.217 - gdrom_image_destroy_no_close(disc);63.218 - return NULL;63.219 - }63.220 - if( image->track[track_id].mode == GDROM_CDDA )63.221 - image->track[track_id].flags = 0x01;63.222 - else63.223 - image->track[track_id].flags = 0x01 | TRACK_DATA;63.224 - image->track[track_id].sector_size = GDROM_SECTOR_SIZE(image->track[track_id].mode);63.225 - image->track[track_id].sector_count = GUINT32_FROM_BE(etnf->length) /63.226 - image->track[track_id].sector_size;63.227 - track_id++;63.228 - }63.229 - break;63.230 - case ETN2_ID:63.231 - etn2 = (struct nrg_etn2 *)data;63.232 - count = chunk.length / sizeof(struct nrg_etn2);63.233 - for( i=0; i < count; i++, etn2++ ) {63.234 - image->track[track_id].offset = (uint32_t)GUINT64_FROM_BE(etn2->offset);63.235 - image->track[track_id].lba = GUINT32_FROM_BE(etn2->lba) + (i+1)*GDROM_PREGAP;63.236 - image->track[track_id].mode = nrg_track_mode( GUINT32_FROM_BE(etn2->mode) );63.237 - if( image->track[track_id].mode == -1 ) {63.238 - gdrom_image_destroy_no_close(disc);63.239 - return NULL;63.240 - }63.241 - if( image->track[track_id].mode == GDROM_CDDA )63.242 - image->track[track_id].flags = 0x01;63.243 - else63.244 - image->track[track_id].flags = 0x01 | TRACK_DATA;63.245 - image->track[track_id].sector_size = GDROM_SECTOR_SIZE(image->track[track_id].mode);63.246 - image->track[track_id].sector_count = (uint32_t)(GUINT64_FROM_BE(etn2->length) /63.247 - image->track[track_id].sector_size);63.248 - track_id++;63.249 - }63.250 - break;63.251 + fread( &chunk, sizeof(chunk), 1, f );63.252 + chunk.length = GUINT32_FROM_BE(chunk.length);63.253 + char data[chunk.length];63.254 + fread( data, chunk.length, 1, f );63.255 + chunk_id = GUINT32_FROM_BE(chunk.id);63.256 + switch( chunk_id ) {63.257 + case CUES_ID:63.258 + case CUEX_ID:63.259 + cue_track_id = track_id;63.260 + cue_track_count = ((chunk.length / sizeof(struct nrg_cues)) >> 1) - 1;63.261 + track_id += cue_track_count;63.262 + for( i=0; i<chunk.length; i+= sizeof(struct nrg_cues) ) {63.263 + struct nrg_cues *cue = (struct nrg_cues *)(data+i);63.264 + int track = 0;63.265 + uint32_t lba;63.266 + if( chunk_id == CUEX_ID ) {63.267 + lba = GUINT32_FROM_BE( cue->addr ) + GDROM_PREGAP;63.268 + } else {63.269 + lba = msf_to_lba( cue->addr );63.270 + }63.271 + if( cue->track == 0 )63.272 + continue; /* Track 0. Leadin? always 0? */63.273 + if( cue->track == 0xAA ) { /* end of disc */63.274 + image->track[track_id-1].sector_count =63.275 + lba - image->track[track_id-1].lba;63.276 + } else {63.277 + track = cue_track_id + bcd_to_uint8(cue->track) - 1;63.278 + if( (cue->control & 0x01) == 0 ) {63.279 + /* Pre-gap address. */63.280 + if( track != 0 ) {63.281 + image->track[track-1].sector_count =63.282 + lba - image->track[track-1].lba;63.283 + }63.284 + } else { /* Track-start address */63.285 + image->track[track].lba = lba;63.286 + image->track[track].flags = cue->type;63.287 + }63.288 + }63.289 + }63.290 + break;63.291 + case DAOI_ID:63.292 + dao = (struct nrg_daoi *)data;63.293 + memcpy( image->mcn, dao->mcn, 13 );63.294 + image->mcn[13] = '\0';63.295 + assert( dao->track_count * 30 + 22 == chunk.length );63.296 + assert( dao->track_count == cue_track_count );63.297 + for( i=0; i<dao->track_count; i++ ) {63.298 + image->track[cue_track_id].sector_size = GUINT32_FROM_BE(dao->track[i].sector_size);63.299 + image->track[cue_track_id].offset = GUINT32_FROM_BE(dao->track[i].offset);63.300 + image->track[cue_track_id].mode = nrg_track_mode( dao->track[i].mode );63.301 + image->track[cue_track_id].sector_count =63.302 + (GUINT32_FROM_BE(dao->track[i].end) - GUINT32_FROM_BE(dao->track[i].offset))/63.303 + GUINT32_FROM_BE(dao->track[i].sector_size);63.304 + cue_track_id++;63.305 + }63.306 + break;63.307 + case DAOX_ID:63.308 + daox = (struct nrg_daox *)data;63.309 + memcpy( image->mcn, daox->mcn, 13 );63.310 + image->mcn[13] = '\0';63.311 + assert( daox->track_count * 42 + 22 == chunk.length );63.312 + assert( daox->track_count == cue_track_count );63.313 + for( i=0; i<daox->track_count; i++ ) {63.314 + image->track[cue_track_id].sector_size = GUINT32_FROM_BE(daox->track[i].sector_size);63.315 + image->track[cue_track_id].offset = GUINT64_FROM_BE(daox->track[i].offset);63.316 + image->track[cue_track_id].mode = nrg_track_mode( daox->track[i].mode );63.317 + image->track[cue_track_id].sector_count =63.318 + (GUINT64_FROM_BE(daox->track[i].end) - GUINT64_FROM_BE(daox->track[i].offset))/63.319 + GUINT32_FROM_BE(daox->track[i].sector_size);63.320 + cue_track_id++;63.321 + }63.322 + break;63.324 - case END_ID:63.325 - end = TRUE;63.326 - break;63.327 - }63.328 + case SINF_ID:63.329 + /* Data is a single 32-bit number representing number of tracks in session */63.330 + i = GUINT32_FROM_BE( *(uint32_t *)data );63.331 + while( i-- > 0 )63.332 + image->track[session_track_id++].session = session_id;63.333 + session_id++;63.334 + break;63.335 + case ETNF_ID:63.336 + etnf = (struct nrg_etnf *)data;63.337 + count = chunk.length / sizeof(struct nrg_etnf);63.338 + for( i=0; i < count; i++, etnf++ ) {63.339 + image->track[track_id].offset = GUINT32_FROM_BE(etnf->offset);63.340 + image->track[track_id].lba = GUINT32_FROM_BE(etnf->lba) + (i+1)*GDROM_PREGAP;63.341 + image->track[track_id].mode = nrg_track_mode( GUINT32_FROM_BE(etnf->mode) );63.342 + if( image->track[track_id].mode == -1 ) {63.343 + gdrom_image_destroy_no_close(disc);63.344 + return NULL;63.345 + }63.346 + if( image->track[track_id].mode == GDROM_CDDA )63.347 + image->track[track_id].flags = 0x01;63.348 + else63.349 + image->track[track_id].flags = 0x01 | TRACK_DATA;63.350 + image->track[track_id].sector_size = GDROM_SECTOR_SIZE(image->track[track_id].mode);63.351 + image->track[track_id].sector_count = GUINT32_FROM_BE(etnf->length) /63.352 + image->track[track_id].sector_size;63.353 + track_id++;63.354 + }63.355 + break;63.356 + case ETN2_ID:63.357 + etn2 = (struct nrg_etn2 *)data;63.358 + count = chunk.length / sizeof(struct nrg_etn2);63.359 + for( i=0; i < count; i++, etn2++ ) {63.360 + image->track[track_id].offset = (uint32_t)GUINT64_FROM_BE(etn2->offset);63.361 + image->track[track_id].lba = GUINT32_FROM_BE(etn2->lba) + (i+1)*GDROM_PREGAP;63.362 + image->track[track_id].mode = nrg_track_mode( GUINT32_FROM_BE(etn2->mode) );63.363 + if( image->track[track_id].mode == -1 ) {63.364 + gdrom_image_destroy_no_close(disc);63.365 + return NULL;63.366 + }63.367 + if( image->track[track_id].mode == GDROM_CDDA )63.368 + image->track[track_id].flags = 0x01;63.369 + else63.370 + image->track[track_id].flags = 0x01 | TRACK_DATA;63.371 + image->track[track_id].sector_size = GDROM_SECTOR_SIZE(image->track[track_id].mode);63.372 + image->track[track_id].sector_count = (uint32_t)(GUINT64_FROM_BE(etn2->length) /63.373 + image->track[track_id].sector_size);63.374 + track_id++;63.375 + }63.376 + break;63.377 +63.378 + case END_ID:63.379 + end = TRUE;63.380 + break;63.381 + }63.382 } while( !end );63.383 image->track_count = track_id;63.384 return disc;
64.1 --- a/src/gdrom/packet.h Mon Jul 14 07:42:45 2008 +000064.2 +++ b/src/gdrom/packet.h Mon Jul 14 07:44:42 2008 +000064.3 @@ -17,6 +17,9 @@64.4 * GNU General Public License for more details.64.5 */64.7 +#ifndef lxdream_packet_H64.8 +#define lxdream_packet_H 164.9 +64.10 /**64.11 * Valid command codes (hex):64.12 * 00 Test64.13 @@ -80,3 +83,5 @@64.14 #define READ_CD_SUBHEAD(x) ((x)&0x40)64.15 #define READ_CD_DATA(x) ((x)&0x20)64.16 #define READ_CD_RAW(x) ((x)&0x10)64.17 +64.18 +#endif /* !lxdream_packet_H */
65.1 --- a/src/gtkui/ctrl_dlg.c Mon Jul 14 07:42:45 2008 +000065.2 +++ b/src/gtkui/ctrl_dlg.c Mon Jul 14 07:44:42 2008 +000065.3 @@ -44,8 +44,8 @@65.4 } *maple_slot_data_t;65.6 static struct maple_config_class maple_device_config[] = {65.7 - { "Sega Controller", controller_device_configure },65.8 - { NULL, NULL } };65.9 + { "Sega Controller", controller_device_configure },65.10 + { NULL, NULL } };65.12 static struct maple_slot_data maple_data[MAX_DEVICES];65.14 @@ -61,9 +61,9 @@65.15 {65.16 gboolean keypress_mode = GPOINTER_TO_INT(g_object_get_data( G_OBJECT(widget), "keypress_mode"));65.17 if( !keypress_mode ) {65.18 - gtk_entry_set_text( GTK_ENTRY(widget), _("<press key>") );65.19 - g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(TRUE) );65.20 - input_set_keysym_hook(config_keysym_hook, widget);65.21 + gtk_entry_set_text( GTK_ENTRY(widget), _("<press key>") );65.22 + g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(TRUE) );65.23 + input_set_keysym_hook(config_keysym_hook, widget);65.24 }65.25 return FALSE;65.26 }65.27 @@ -72,64 +72,64 @@65.28 {65.29 gboolean keypress_mode = GPOINTER_TO_INT(g_object_get_data( G_OBJECT(widget), "keypress_mode"));65.30 if( keypress_mode ) {65.31 - if( event->keyval == GDK_Escape ) {65.32 - gtk_entry_set_text( GTK_ENTRY(widget), "" );65.33 - g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(FALSE) );65.34 - return TRUE;65.35 - }65.36 - GdkKeymap *keymap = gdk_keymap_get_default();65.37 - guint keyval;65.38 -65.39 - gdk_keymap_translate_keyboard_state( keymap, event->hardware_keycode, 0, 0, &keyval,65.40 - NULL, NULL, NULL );65.41 - gtk_entry_set_text( GTK_ENTRY(widget), gdk_keyval_name(keyval) );65.42 - g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(FALSE) );65.43 - input_set_keysym_hook(NULL, NULL);65.44 - return TRUE;65.45 + if( event->keyval == GDK_Escape ) {65.46 + gtk_entry_set_text( GTK_ENTRY(widget), "" );65.47 + g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(FALSE) );65.48 + return TRUE;65.49 + }65.50 + GdkKeymap *keymap = gdk_keymap_get_default();65.51 + guint keyval;65.52 +65.53 + gdk_keymap_translate_keyboard_state( keymap, event->hardware_keycode, 0, 0, &keyval,65.54 + NULL, NULL, NULL );65.55 + gtk_entry_set_text( GTK_ENTRY(widget), gdk_keyval_name(keyval) );65.56 + g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(FALSE) );65.57 + input_set_keysym_hook(NULL, NULL);65.58 + return TRUE;65.59 } else {65.60 - switch( event->keyval ) {65.61 - case GDK_Return:65.62 - case GDK_KP_Enter:65.63 - gtk_entry_set_text( GTK_ENTRY(widget), _("<press key>") );65.64 - g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(TRUE) );65.65 - input_set_keysym_hook(config_keysym_hook, widget);65.66 - return TRUE;65.67 - case GDK_BackSpace:65.68 - case GDK_Delete:65.69 - gtk_entry_set_text( GTK_ENTRY(widget), "" );65.70 - return TRUE;65.71 - }65.72 - return FALSE;65.73 + switch( event->keyval ) {65.74 + case GDK_Return:65.75 + case GDK_KP_Enter:65.76 + gtk_entry_set_text( GTK_ENTRY(widget), _("<press key>") );65.77 + g_object_set_data( G_OBJECT(widget), "keypress_mode", GINT_TO_POINTER(TRUE) );65.78 + input_set_keysym_hook(config_keysym_hook, widget);65.79 + return TRUE;65.80 + case GDK_BackSpace:65.81 + case GDK_Delete:65.82 + gtk_entry_set_text( GTK_ENTRY(widget), "" );65.83 + return TRUE;65.84 + }65.85 + return FALSE;65.86 }65.87 -65.88 +65.89 }65.91 static void controller_config_done( GtkWidget *panel, gboolean isOK )65.92 {65.93 if( isOK ) {65.94 - maple_device_t device = (maple_device_t)gtk_object_get_data( GTK_OBJECT(panel), "maple_device" );65.95 - lxdream_config_entry_t conf = device->get_config(device);65.96 - int i;65.97 - for( i=0; conf[i].key != NULL; i++ ) {65.98 - char buf[64];65.99 - GtkWidget *entry1, *entry2;65.100 - const gchar *key1, *key2;65.101 - snprintf( buf, sizeof(buf), "%s.1", conf[i].key );65.102 - entry1 = GTK_WIDGET(g_object_get_qdata( G_OBJECT(panel), g_quark_from_string(buf)));65.103 - key1 = gtk_entry_get_text(GTK_ENTRY(entry1));65.104 - snprintf( buf, sizeof(buf), "%s.2", conf[i].key );65.105 - entry2 = GTK_WIDGET(g_object_get_qdata( G_OBJECT(panel), g_quark_from_string(buf)));65.106 - key2 = gtk_entry_get_text(GTK_ENTRY(entry2));65.107 - if( key1 == NULL || key1[0] == '\0') {65.108 - lxdream_set_config_value( &conf[i], key2 );65.109 - } else if( key2 == NULL || key2[0] == '\0') {65.110 - lxdream_set_config_value( &conf[i], key1 );65.111 - } else {65.112 - char buf[64];65.113 - snprintf( buf, sizeof(buf), "%s, %s", key1, key2 );65.114 - lxdream_set_config_value( &conf[i], buf );65.115 - }65.116 - }65.117 + maple_device_t device = (maple_device_t)gtk_object_get_data( GTK_OBJECT(panel), "maple_device" );65.118 + lxdream_config_entry_t conf = device->get_config(device);65.119 + int i;65.120 + for( i=0; conf[i].key != NULL; i++ ) {65.121 + char buf[64];65.122 + GtkWidget *entry1, *entry2;65.123 + const gchar *key1, *key2;65.124 + snprintf( buf, sizeof(buf), "%s.1", conf[i].key );65.125 + entry1 = GTK_WIDGET(g_object_get_qdata( G_OBJECT(panel), g_quark_from_string(buf)));65.126 + key1 = gtk_entry_get_text(GTK_ENTRY(entry1));65.127 + snprintf( buf, sizeof(buf), "%s.2", conf[i].key );65.128 + entry2 = GTK_WIDGET(g_object_get_qdata( G_OBJECT(panel), g_quark_from_string(buf)));65.129 + key2 = gtk_entry_get_text(GTK_ENTRY(entry2));65.130 + if( key1 == NULL || key1[0] == '\0') {65.131 + lxdream_set_config_value( &conf[i], key2 );65.132 + } else if( key2 == NULL || key2[0] == '\0') {65.133 + lxdream_set_config_value( &conf[i], key1 );65.134 + } else {65.135 + char buf[64];65.136 + snprintf( buf, sizeof(buf), "%s, %s", key1, key2 );65.137 + lxdream_set_config_value( &conf[i], buf );65.138 + }65.139 + }65.140 }65.141 input_set_keysym_hook(NULL, NULL);65.142 }65.143 @@ -144,50 +144,50 @@65.144 GList *focus_chain = NULL;65.145 gtk_object_set_data( GTK_OBJECT(table), "maple_device", device );65.146 for( i=0; i<count; i++ ) {65.147 - GtkWidget *text, *text2;65.148 - char buf[64];65.149 - int x=0;65.150 - int y=i;65.151 - if( i >= (count+1)>>1 ) {65.152 - x = 3;65.153 - y -= (count+1)>>1;65.154 - }65.155 - gtk_table_attach( GTK_TABLE(table), gtk_label_new(conf[i].key), x, x+1, y, y+1,65.156 - GTK_SHRINK, GTK_SHRINK, 0, 0 );65.157 - text = gtk_entry_new();65.158 - gtk_entry_set_width_chars( GTK_ENTRY(text), 11 );65.159 - gtk_entry_set_editable( GTK_ENTRY(text), FALSE );65.160 - g_signal_connect( text, "key_press_event",65.161 - G_CALLBACK(config_key_keypress), NULL );65.162 - g_signal_connect( text, "button_press_event",65.163 - G_CALLBACK(config_key_buttonpress), NULL );65.164 - snprintf( buf, sizeof(buf), "%s.1", conf[i].key );65.165 - g_object_set_data( G_OBJECT(text), "keypress_mode", GINT_TO_POINTER(FALSE) );65.166 - g_object_set_qdata( G_OBJECT(table), g_quark_from_string(buf), text );65.167 - gtk_table_attach_defaults( GTK_TABLE(table), text, x+1, x+2, y, y+1);65.168 - focus_chain = g_list_append( focus_chain, text );65.169 - text2 = gtk_entry_new();65.170 - gtk_entry_set_width_chars( GTK_ENTRY(text2), 11 );65.171 - gtk_entry_set_editable( GTK_ENTRY(text2), FALSE );65.172 - g_signal_connect( text2, "key_press_event",65.173 - G_CALLBACK(config_key_keypress), NULL );65.174 - g_signal_connect( text2, "button_press_event",65.175 - G_CALLBACK(config_key_buttonpress), NULL );65.176 - snprintf( buf, sizeof(buf), "%s.2", conf[i].key );65.177 - g_object_set_data( G_OBJECT(text2), "keypress_mode", GINT_TO_POINTER(FALSE) );65.178 - g_object_set_qdata( G_OBJECT(table), g_quark_from_string(buf), text2 );65.179 - gtk_table_attach_defaults( GTK_TABLE(table), text2, x+2, x+3, y, y+1);65.180 - focus_chain = g_list_append( focus_chain, text2 );65.181 - if( conf[i].value != NULL ) {65.182 - gchar **parts = g_strsplit(conf[i].value,",",3);65.183 - if( parts[0] != NULL ) {65.184 - gtk_entry_set_text( GTK_ENTRY(text), g_strstrip(parts[0]) );65.185 - if( parts[1] != NULL ) {65.186 - gtk_entry_set_text( GTK_ENTRY(text2), g_strstrip(parts[1]) );65.187 - }65.188 - }65.189 - g_strfreev(parts);65.190 - }65.191 + GtkWidget *text, *text2;65.192 + char buf[64];65.193 + int x=0;65.194 + int y=i;65.195 + if( i >= (count+1)>>1 ) {65.196 + x = 3;65.197 + y -= (count+1)>>1;65.198 + }65.199 + gtk_table_attach( GTK_TABLE(table), gtk_label_new(conf[i].key), x, x+1, y, y+1,65.200 + GTK_SHRINK, GTK_SHRINK, 0, 0 );65.201 + text = gtk_entry_new();65.202 + gtk_entry_set_width_chars( GTK_ENTRY(text), 11 );65.203 + gtk_entry_set_editable( GTK_ENTRY(text), FALSE );65.204 + g_signal_connect( text, "key_press_event",65.205 + G_CALLBACK(config_key_keypress), NULL );65.206 + g_signal_connect( text, "button_press_event",65.207 + G_CALLBACK(config_key_buttonpress), NULL );65.208 + snprintf( buf, sizeof(buf), "%s.1", conf[i].key );65.209 + g_object_set_data( G_OBJECT(text), "keypress_mode", GINT_TO_POINTER(FALSE) );65.210 + g_object_set_qdata( G_OBJECT(table), g_quark_from_string(buf), text );65.211 + gtk_table_attach_defaults( GTK_TABLE(table), text, x+1, x+2, y, y+1);65.212 + focus_chain = g_list_append( focus_chain, text );65.213 + text2 = gtk_entry_new();65.214 + gtk_entry_set_width_chars( GTK_ENTRY(text2), 11 );65.215 + gtk_entry_set_editable( GTK_ENTRY(text2), FALSE );65.216 + g_signal_connect( text2, "key_press_event",65.217 + G_CALLBACK(config_key_keypress), NULL );65.218 + g_signal_connect( text2, "button_press_event",65.219 + G_CALLBACK(config_key_buttonpress), NULL );65.220 + snprintf( buf, sizeof(buf), "%s.2", conf[i].key );65.221 + g_object_set_data( G_OBJECT(text2), "keypress_mode", GINT_TO_POINTER(FALSE) );65.222 + g_object_set_qdata( G_OBJECT(table), g_quark_from_string(buf), text2 );65.223 + gtk_table_attach_defaults( GTK_TABLE(table), text2, x+2, x+3, y, y+1);65.224 + focus_chain = g_list_append( focus_chain, text2 );65.225 + if( conf[i].value != NULL ) {65.226 + gchar **parts = g_strsplit(conf[i].value,",",3);65.227 + if( parts[0] != NULL ) {65.228 + gtk_entry_set_text( GTK_ENTRY(text), g_strstrip(parts[0]) );65.229 + if( parts[1] != NULL ) {65.230 + gtk_entry_set_text( GTK_ENTRY(text2), g_strstrip(parts[1]) );65.231 + }65.232 + }65.233 + g_strfreev(parts);65.234 + }65.235 }65.236 gtk_container_set_focus_chain( GTK_CONTAINER(table), focus_chain );65.237 gtk_gui_run_property_dialog( _("Controller Configuration"), table, controller_config_done );65.238 @@ -197,20 +197,20 @@65.239 {65.240 maple_slot_data_t data = (maple_slot_data_t)user_data;65.241 if( data->new_device != NULL ) {65.242 - int i;65.243 - for( i=0; maple_device_config[i].name != NULL; i++ ) {65.244 - if( strcmp(data->new_device->device_class->name, maple_device_config[i].name) == 0 ) {65.245 - if( data->new_device == data->old_device ) {65.246 - // Make a copy at this point if we haven't already65.247 - data->new_device = data->old_device->clone(data->old_device);65.248 - }65.249 - maple_device_config[i].config_func(data->new_device);65.250 - break;65.251 - }65.252 - }65.253 - if( maple_device_config[i].name == NULL ) {65.254 - gui_error_dialog( _("No configuration page available for device type") );65.255 - }65.256 + int i;65.257 + for( i=0; maple_device_config[i].name != NULL; i++ ) {65.258 + if( strcmp(data->new_device->device_class->name, maple_device_config[i].name) == 0 ) {65.259 + if( data->new_device == data->old_device ) {65.260 + // Make a copy at this point if we haven't already65.261 + data->new_device = data->old_device->clone(data->old_device);65.262 + }65.263 + maple_device_config[i].config_func(data->new_device);65.264 + break;65.265 + }65.266 + }65.267 + if( maple_device_config[i].name == NULL ) {65.268 + gui_error_dialog( _("No configuration page available for device type") );65.269 + }65.270 }65.271 return TRUE;65.272 }65.273 @@ -221,25 +221,25 @@65.274 int active = gtk_combo_box_get_active(combo);65.275 gboolean has_config = FALSE;65.276 if( active != 0 ) {65.277 - gchar *devname = gtk_combo_box_get_active_text(combo);65.278 - const maple_device_class_t devclz = maple_get_device_class(devname);65.279 - assert(devclz != NULL);65.280 - if( data->new_device != NULL ) {65.281 - if( data->new_device->device_class != devclz ) {65.282 - if( data->new_device != data->old_device ) {65.283 - data->new_device->destroy(data->new_device);65.284 - }65.285 - data->new_device = maple_new_device(devname);65.286 - }65.287 - } else {65.288 - data->new_device = maple_new_device(devname);65.289 - }65.290 - has_config = data->new_device != NULL && data->new_device->get_config != NULL;65.291 + gchar *devname = gtk_combo_box_get_active_text(combo);65.292 + const maple_device_class_t devclz = maple_get_device_class(devname);65.293 + assert(devclz != NULL);65.294 + if( data->new_device != NULL ) {65.295 + if( data->new_device->device_class != devclz ) {65.296 + if( data->new_device != data->old_device ) {65.297 + data->new_device->destroy(data->new_device);65.298 + }65.299 + data->new_device = maple_new_device(devname);65.300 + }65.301 + } else {65.302 + data->new_device = maple_new_device(devname);65.303 + }65.304 + has_config = data->new_device != NULL && data->new_device->get_config != NULL;65.305 } else {65.306 - if( data->new_device != NULL && data->new_device != data->old_device ) {65.307 - data->new_device->destroy(data->new_device);65.308 - }65.309 - data->new_device = NULL;65.310 + if( data->new_device != NULL && data->new_device != data->old_device ) {65.311 + data->new_device->destroy(data->new_device);65.312 + }65.313 + data->new_device = NULL;65.314 }65.315 gtk_widget_set_sensitive(data->button, has_config);65.316 return TRUE;65.317 @@ -248,26 +248,26 @@65.318 void maple_dialog_done( GtkWidget *panel, gboolean isOK )65.319 {65.320 if( isOK ) {65.321 - int i;65.322 - for( i=0; i<MAX_DEVICES; i++ ) {65.323 - if( maple_data[i].new_device != maple_data[i].old_device ) {65.324 - if( maple_data[i].old_device != NULL ) {65.325 - maple_detach_device(i,0);65.326 - }65.327 - if( maple_data[i].new_device != NULL ) {65.328 - maple_attach_device(maple_data[i].new_device, i, 0 );65.329 - }65.330 - }65.331 - }65.332 - lxdream_save_config();65.333 + int i;65.334 + for( i=0; i<MAX_DEVICES; i++ ) {65.335 + if( maple_data[i].new_device != maple_data[i].old_device ) {65.336 + if( maple_data[i].old_device != NULL ) {65.337 + maple_detach_device(i,0);65.338 + }65.339 + if( maple_data[i].new_device != NULL ) {65.340 + maple_attach_device(maple_data[i].new_device, i, 0 );65.341 + }65.342 + }65.343 + }65.344 + lxdream_save_config();65.345 } else {65.346 - int i;65.347 - for( i=0; i<MAX_DEVICES; i++ ) {65.348 - if( maple_data[i].new_device != NULL &&65.349 - maple_data[i].new_device != maple_data[i].old_device ) {65.350 - maple_data[i].new_device->destroy(maple_data[i].new_device);65.351 - }65.352 - }65.353 + int i;65.354 + for( i=0; i<MAX_DEVICES; i++ ) {65.355 + if( maple_data[i].new_device != NULL &&65.356 + maple_data[i].new_device != maple_data[i].old_device ) {65.357 + maple_data[i].new_device->destroy(maple_data[i].new_device);65.358 + }65.359 + }65.360 }65.362 }65.363 @@ -279,34 +279,34 @@65.364 const struct maple_device_class **devices = maple_get_device_classes();65.366 for( i=0; i< MAX_DEVICES; i++ ) {65.367 - char buf[12];65.368 - GtkWidget *combo, *button;65.369 - int active = 0;65.370 - maple_device_t device = maple_get_device(i,0);65.371 - sprintf( buf, _("Slot %d."), i );65.372 - gtk_table_attach_defaults( GTK_TABLE(table), gtk_label_new(buf), 0, 1, i, i+1 );65.373 - combo = gtk_combo_box_new_text();65.374 - gtk_combo_box_append_text( GTK_COMBO_BOX(combo), _("<empty>") );65.375 - for( j=0; devices[j] != NULL; j++ ) {65.376 - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), devices[j]->name);65.377 - if( device != NULL && device->device_class == devices[j] ) {65.378 - active = j+1;65.379 - }65.380 - }65.381 - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), active);65.382 - gtk_table_attach_defaults( GTK_TABLE(table), combo, 1, 2, i, i+1 );65.383 - button = gtk_button_new_from_stock( GTK_STOCK_PROPERTIES );65.384 - gtk_widget_set_sensitive(button, active != 0 && device->get_config != NULL);65.385 - gtk_table_attach_defaults( GTK_TABLE(table), button, 2, 3, i, i+1 );65.386 + char buf[12];65.387 + GtkWidget *combo, *button;65.388 + int active = 0;65.389 + maple_device_t device = maple_get_device(i,0);65.390 + sprintf( buf, _("Slot %d."), i );65.391 + gtk_table_attach_defaults( GTK_TABLE(table), gtk_label_new(buf), 0, 1, i, i+1 );65.392 + combo = gtk_combo_box_new_text();65.393 + gtk_combo_box_append_text( GTK_COMBO_BOX(combo), _("<empty>") );65.394 + for( j=0; devices[j] != NULL; j++ ) {65.395 + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), devices[j]->name);65.396 + if( device != NULL && device->device_class == devices[j] ) {65.397 + active = j+1;65.398 + }65.399 + }65.400 + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), active);65.401 + gtk_table_attach_defaults( GTK_TABLE(table), combo, 1, 2, i, i+1 );65.402 + button = gtk_button_new_from_stock( GTK_STOCK_PROPERTIES );65.403 + gtk_widget_set_sensitive(button, active != 0 && device->get_config != NULL);65.404 + gtk_table_attach_defaults( GTK_TABLE(table), button, 2, 3, i, i+1 );65.406 - maple_data[i].old_device = device;65.407 - maple_data[i].new_device = device;65.408 - maple_data[i].combo = combo;65.409 - maple_data[i].button = button;65.410 - g_signal_connect( button, "clicked",65.411 - G_CALLBACK( maple_properties_activated ), &maple_data[i] );65.412 - g_signal_connect( combo, "changed",65.413 - G_CALLBACK( maple_device_changed ), &maple_data[i] );65.414 + maple_data[i].old_device = device;65.415 + maple_data[i].new_device = device;65.416 + maple_data[i].combo = combo;65.417 + maple_data[i].button = button;65.418 + g_signal_connect( button, "clicked",65.419 + G_CALLBACK( maple_properties_activated ), &maple_data[i] );65.420 + g_signal_connect( combo, "changed",65.421 + G_CALLBACK( maple_device_changed ), &maple_data[i] );65.423 }65.424 return table;
66.1 --- a/src/gtkui/debug_win.c Mon Jul 14 07:42:45 2008 +000066.2 +++ b/src/gtkui/debug_win.c Mon Jul 14 07:44:42 2008 +000066.3 @@ -29,7 +29,7 @@66.4 #include "aica/armdasm.h"66.6 GdkColor *msg_colors[] = { &gui_colour_error, &gui_colour_error, &gui_colour_warn,66.7 - &gui_colour_normal,&gui_colour_debug, &gui_colour_trace };66.8 + &gui_colour_normal,&gui_colour_debug, &gui_colour_trace };66.10 const cpu_desc_t cpu_list[4] = { &sh4_cpu_desc, &arm_cpu_desc, &armt_cpu_desc, NULL };66.12 @@ -45,9 +45,9 @@66.13 gpointer user_data);66.14 void on_jump_pc_btn_clicked( GtkButton *button, gpointer user_data);66.15 void on_disasm_list_select_row (GtkCList *clist, gint row, gint column,66.16 - GdkEvent *event, gpointer user_data);66.17 + GdkEvent *event, gpointer user_data);66.18 void on_disasm_list_unselect_row (GtkCList *clist, gint row, gint column,66.19 - GdkEvent *event, gpointer user_data);66.20 + GdkEvent *event, gpointer user_data);66.21 gboolean on_debug_delete_event(GtkWidget *widget, GdkEvent event, gpointer user_data);66.23 struct debug_window_info {66.24 @@ -65,10 +65,10 @@66.25 };66.27 debug_window_t debug_window_new( const gchar *title, GtkWidget *menubar,66.28 - GtkWidget *toolbar, GtkAccelGroup *accel_group )66.29 + GtkWidget *toolbar, GtkAccelGroup *accel_group )66.30 {66.31 debug_window_t data = g_malloc0( sizeof(struct debug_window_info) + cpu_list[0]->regs_size );66.32 - GtkWidget *vbox;66.33 + GtkWidget *vbox;66.35 data->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);66.36 gtk_window_set_default_size (GTK_WINDOW (data->window), 700, 480);66.37 @@ -88,15 +88,15 @@66.38 GtkWidget *hbox1 = gtk_hbox_new (FALSE, 0);66.39 gtk_box_pack_start (GTK_BOX (disasm_box), hbox1, FALSE, FALSE, 3);66.40 gtk_box_pack_start (GTK_BOX (hbox1), gtk_label_new (_("Page")), FALSE, FALSE, 4);66.41 -66.42 +66.43 data->page_field = GTK_ENTRY(gtk_entry_new ());66.44 gtk_box_pack_start (GTK_BOX (hbox1), GTK_WIDGET(data->page_field), FALSE, TRUE, 0);66.45 -66.46 +66.47 GtkWidget *jump_pc_btn = gtk_button_new_with_mnemonic (_(" Jump to PC "));66.48 gtk_box_pack_start (GTK_BOX (hbox1), jump_pc_btn, FALSE, FALSE, 4);66.49 -66.50 +66.51 gtk_box_pack_start (GTK_BOX (hbox1), gtk_label_new(_("Mode")), FALSE, FALSE, 5);66.52 -66.53 +66.54 GtkWidget *mode_box = gtk_combo_new ();66.55 gtk_box_pack_start (GTK_BOX (hbox1), mode_box, FALSE, FALSE, 0);66.56 GList *mode_box_items = NULL;66.57 @@ -119,19 +119,19 @@66.58 gtk_clist_set_column_width( data->disasm_list, 1, 16 );66.59 gtk_clist_column_titles_hide (GTK_CLIST (data->disasm_list));66.60 gtk_container_add (GTK_CONTAINER (disasm_scroll), GTK_WIDGET(data->disasm_list));66.61 -66.62 +66.63 GtkWidget *reg_scroll = gtk_scrolled_window_new (NULL, NULL);66.64 gtk_paned_pack2 (GTK_PANED (hpaned), reg_scroll, FALSE, TRUE);66.65 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (reg_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);66.66 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (reg_scroll), GTK_SHADOW_IN);66.67 -66.68 +66.69 data->regs_list = GTK_CLIST(gtk_clist_new (2));66.70 gtk_container_add (GTK_CONTAINER (reg_scroll), GTK_WIDGET(data->regs_list));66.71 gtk_clist_set_column_width (GTK_CLIST (data->regs_list), 0, 80);66.72 gtk_clist_set_column_width (GTK_CLIST (data->regs_list), 1, 80);66.73 gtk_clist_column_titles_hide (GTK_CLIST (data->regs_list));66.74 gtk_widget_modify_font( GTK_WIDGET(data->regs_list), gui_fixed_font );66.75 -66.76 +66.77 vbox = gtk_vbox_new(FALSE, 0);66.78 gtk_container_add( GTK_CONTAINER(data->window), vbox );66.79 gtk_box_pack_start( GTK_BOX(vbox), menubar, FALSE, FALSE, 0 );66.80 @@ -140,30 +140,30 @@66.81 gtk_box_pack_start( GTK_BOX(vbox), data->statusbar, FALSE, FALSE, 0 );66.83 g_signal_connect ((gpointer) data->page_field, "key_press_event",66.84 - G_CALLBACK (on_page_field_key_press_event),66.85 - data);66.86 + G_CALLBACK (on_page_field_key_press_event),66.87 + data);66.88 g_signal_connect ((gpointer) jump_pc_btn, "clicked",66.89 - G_CALLBACK (on_jump_pc_btn_clicked),66.90 - data);66.91 + G_CALLBACK (on_jump_pc_btn_clicked),66.92 + data);66.93 g_signal_connect ((gpointer) mode_field, "changed",66.94 - G_CALLBACK (on_mode_field_changed),66.95 - data);66.96 + G_CALLBACK (on_mode_field_changed),66.97 + data);66.98 g_signal_connect ((gpointer) data->disasm_list, "select_row",66.99 - G_CALLBACK (on_disasm_list_select_row),66.100 - data);66.101 + G_CALLBACK (on_disasm_list_select_row),66.102 + data);66.103 g_signal_connect ((gpointer) data->disasm_list, "unselect_row",66.104 - G_CALLBACK (on_disasm_list_unselect_row),66.105 - data);66.106 + G_CALLBACK (on_disasm_list_unselect_row),66.107 + data);66.108 g_signal_connect ((gpointer) data->window, "delete_event",66.109 - G_CALLBACK (on_debug_delete_event),66.110 - data);66.111 -66.112 + G_CALLBACK (on_debug_delete_event),66.113 + data);66.114 +66.115 data->disasm_from = -1;66.116 data->disasm_to = -1;66.117 data->disasm_pc = -1;66.118 data->cpu = cpu_list[0];66.119 data->cpu_list = cpu_list;66.120 -66.121 +66.122 init_register_list( data );66.123 gtk_object_set_data( GTK_OBJECT(data->window), "debug_data", data );66.124 set_disassembly_pc( data, *data->cpu->pc, FALSE );66.125 @@ -176,18 +176,18 @@66.126 void debug_window_show( debug_window_t data, gboolean show )66.127 {66.128 if( show ) {66.129 - gtk_widget_show( data->window );66.130 + gtk_widget_show( data->window );66.131 } else {66.132 - gtk_widget_hide( data->window );66.133 + gtk_widget_hide( data->window );66.134 }66.135 }66.137 int debug_window_get_selected_row( debug_window_t data )66.138 {66.139 if( data->disasm_list->selection == NULL ) {66.140 - return -1;66.141 + return -1;66.142 } else {66.143 - return GPOINTER_TO_INT(data->disasm_list->selection->data);66.144 + return GPOINTER_TO_INT(data->disasm_list->selection->data);66.145 }66.146 }66.148 @@ -253,7 +253,7 @@66.149 char *arr[4] = { addr, " ", opcode, buf };66.150 unsigned int from = page & 0xFFFFF000;66.151 unsigned int to = from + 4096;66.152 -66.153 +66.154 gtk_clist_clear(data->disasm_list);66.156 sprintf( addr, "%08X", from );66.157 @@ -265,26 +265,26 @@66.158 gtk_clist_set_foreground( data->disasm_list, 0, &gui_colour_error );66.159 } else {66.160 for( i=from; i<to; i = next ) {66.161 - next = data->cpu->disasm_func( i, buf, sizeof(buf), opcode );66.162 + next = data->cpu->disasm_func( i, buf, sizeof(buf), opcode );66.163 sprintf( addr, "%08X", i );66.164 posn = gtk_clist_append( data->disasm_list, arr );66.165 if( buf[0] == '?' )66.166 gtk_clist_set_foreground( data->disasm_list, posn, &gui_colour_warn );66.167 - if( data->cpu->get_breakpoint != NULL ) {66.168 - int type = data->cpu->get_breakpoint( i );66.169 - switch(type) {66.170 - case BREAK_ONESHOT:66.171 - gtk_clist_set_background( data->disasm_list, posn, &gui_colour_temp_break );66.172 - break;66.173 - case BREAK_KEEP:66.174 - gtk_clist_set_background( data->disasm_list, posn, &gui_colour_break );66.175 - break;66.176 - }66.177 - }66.178 + if( data->cpu->get_breakpoint != NULL ) {66.179 + int type = data->cpu->get_breakpoint( i );66.180 + switch(type) {66.181 + case BREAK_ONESHOT:66.182 + gtk_clist_set_background( data->disasm_list, posn, &gui_colour_temp_break );66.183 + break;66.184 + case BREAK_KEEP:66.185 + gtk_clist_set_background( data->disasm_list, posn, &gui_colour_break );66.186 + break;66.187 + }66.188 + }66.189 }66.190 if( data->disasm_pc != -1 && data->disasm_pc >= from && data->disasm_pc < to )66.191 gtk_clist_set_foreground( data->disasm_list, address_to_row(data, data->disasm_pc),66.192 - &gui_colour_pc );66.193 + &gui_colour_pc );66.194 }66.196 if( page != from ) { /* not a page boundary */66.197 @@ -297,7 +297,7 @@66.198 void jump_to_disassembly( debug_window_t data, unsigned int addr, gboolean select )66.199 {66.200 int row;66.201 -66.202 +66.203 if( addr < data->disasm_from || addr >= data->disasm_to )66.204 set_disassembly_region(data,addr);66.206 @@ -318,13 +318,13 @@66.207 void set_disassembly_pc( debug_window_t data, unsigned int pc, gboolean select )66.208 {66.209 int row;66.210 -66.211 +66.212 jump_to_disassembly( data, pc, select );66.213 if( data->disasm_pc != -1 && data->disasm_pc >= data->disasm_from &&66.214 - data->disasm_pc < data->disasm_to )66.215 + data->disasm_pc < data->disasm_to )66.216 gtk_clist_set_foreground( data->disasm_list,66.217 - (data->disasm_pc - data->disasm_from) / data->cpu->instr_size,66.218 - &gui_colour_normal );66.219 + (data->disasm_pc - data->disasm_from) / data->cpu->instr_size,66.220 + &gui_colour_normal );66.221 row = address_to_row( data, pc );66.222 gtk_clist_set_foreground( data->disasm_list, row, &gui_colour_pc );66.223 data->disasm_pc = pc;66.224 @@ -334,15 +334,15 @@66.225 {66.226 int i;66.227 for( i=0; data->cpu_list[i] != NULL; i++ ) {66.228 - if( strcmp( data->cpu_list[i]->name, cpu ) == 0 ) {66.229 - if( data->cpu != data->cpu_list[i] ) {66.230 - data->cpu = data->cpu_list[i];66.231 - data->disasm_from = data->disasm_to = -1; /* Force reload */66.232 - set_disassembly_pc( data, *data->cpu->pc, FALSE );66.233 - init_register_list( data );66.234 - }66.235 - return;66.236 - }66.237 + if( strcmp( data->cpu_list[i]->name, cpu ) == 0 ) {66.238 + if( data->cpu != data->cpu_list[i] ) {66.239 + data->cpu = data->cpu_list[i];66.240 + data->disasm_from = data->disasm_to = -1; /* Force reload */66.241 + set_disassembly_pc( data, *data->cpu->pc, FALSE );66.242 + init_register_list( data );66.243 + }66.244 + return;66.245 + }66.246 }66.247 }66.249 @@ -351,11 +351,11 @@66.250 uint32_t pc = row_to_address( data, row );66.251 int oldType = data->cpu->get_breakpoint( pc );66.252 if( oldType != BREAK_NONE ) {66.253 - data->cpu->clear_breakpoint( pc, oldType );66.254 - gtk_clist_set_background( data->disasm_list, row, &gui_colour_white );66.255 + data->cpu->clear_breakpoint( pc, oldType );66.256 + gtk_clist_set_background( data->disasm_list, row, &gui_colour_white );66.257 } else {66.258 - data->cpu->set_breakpoint( pc, BREAK_KEEP );66.259 - gtk_clist_set_background( data->disasm_list, row, &gui_colour_break );66.260 + data->cpu->set_breakpoint( pc, BREAK_KEEP );66.261 + gtk_clist_set_background( data->disasm_list, row, &gui_colour_break );66.262 }66.263 }66.265 @@ -382,12 +382,12 @@66.267 int address_to_row( debug_window_t data, uint32_t address ) {66.268 if( data->disasm_from > address || data->disasm_to <= address )66.269 - return -1;66.270 + return -1;66.271 return (address - data->disasm_from) / data->cpu->instr_size;66.272 }66.274 debug_window_t get_debug_info( GtkWidget *widget ) {66.275 -66.276 +66.277 GtkWidget *win = gtk_widget_get_toplevel(widget);66.278 debug_window_t data = (debug_window_t)gtk_object_get_data( GTK_OBJECT(win), "debug_data" );66.279 return data;66.280 @@ -396,8 +396,8 @@66.281 void debug_window_set_running( debug_window_t data, gboolean isRunning )66.282 {66.283 if( data != NULL ) {66.284 - gtk_gui_enable_action( "SingleStep", !isRunning );66.285 - gtk_gui_enable_action( "RunTo", !isRunning && dreamcast_can_run() );66.286 + gtk_gui_enable_action( "SingleStep", !isRunning );66.287 + gtk_gui_enable_action( "RunTo", !isRunning && dreamcast_can_run() );66.288 }66.289 }66.291 @@ -412,7 +412,7 @@66.292 gpointer user_data)66.293 {66.294 if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {66.295 - debug_window_t data = get_debug_info(widget);66.296 + debug_window_t data = get_debug_info(widget);66.297 const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );66.298 gchar *endptr;66.299 unsigned int val = strtoul( text, &endptr, 16 );66.300 @@ -435,14 +435,14 @@66.301 }66.303 void on_disasm_list_select_row (GtkCList *clist, gint row, gint column,66.304 - GdkEvent *event, gpointer user_data)66.305 + GdkEvent *event, gpointer user_data)66.306 {66.307 gtk_gui_enable_action( "SetBreakpoint", TRUE );66.308 gtk_gui_enable_action( "RunTo", dreamcast_can_run() );66.309 }66.311 void on_disasm_list_unselect_row (GtkCList *clist, gint row, gint column,66.312 - GdkEvent *event, gpointer user_data)66.313 + GdkEvent *event, gpointer user_data)66.314 {66.315 gtk_gui_enable_action( "SetBreakpoint", FALSE );66.316 gtk_gui_enable_action( "RunTo", FALSE );
67.1 --- a/src/gtkui/dump_win.c Mon Jul 14 07:42:45 2008 +000067.2 +++ b/src/gtkui/dump_win.c Mon Jul 14 07:44:42 2008 +000067.3 @@ -46,7 +46,7 @@67.4 static dump_window_t dump_list_head = NULL;67.6 gboolean on_dump_window_delete_event( GtkWidget *widget, GdkEvent *event,67.7 - gpointer user_data );67.8 + gpointer user_data );67.9 void on_dump_window_button_view_clicked( GtkWidget *widget, gpointer user_data );67.10 void dump_window_set_text( dump_window_t data, unsigned char *old_data, unsigned char *new_data );67.12 @@ -78,7 +78,7 @@67.13 dump->toInput = gtk_entry_new ();67.14 gtk_entry_set_text( GTK_ENTRY(dump->toInput), "" );67.15 dump_view_button = gtk_button_new_with_mnemonic (_("View"));67.16 -67.17 +67.18 gtk_box_pack_start (GTK_BOX (hbox2), gtk_label_new(_(" From ")), FALSE, FALSE, 0);67.19 gtk_box_pack_start (GTK_BOX (hbox2), dump->fromInput, FALSE, TRUE, 0);67.20 gtk_box_pack_start (GTK_BOX (hbox2), gtk_label_new(_(" To ")), FALSE, FALSE, 0);67.21 @@ -90,7 +90,7 @@67.22 dump->textArea = gtk_text_view_new ();67.23 dump->textBuffer = gtk_text_buffer_new(NULL);67.24 dump->changedTag = gtk_text_buffer_create_tag(dump->textBuffer, "changed",67.25 - "foreground", "blue", NULL);67.26 + "foreground", "blue", NULL);67.27 gtk_widget_modify_font(GTK_WIDGET(dump->textArea),gui_fixed_font);67.28 gtk_text_view_set_editable(GTK_TEXT_VIEW(dump->textArea), FALSE);67.29 gtk_text_view_set_buffer(GTK_TEXT_VIEW(dump->textArea), dump->textBuffer);67.30 @@ -98,7 +98,7 @@67.31 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow9), GTK_SHADOW_IN);67.32 gtk_container_add (GTK_CONTAINER (scrolledwindow9), dump->textArea);67.33 gtk_box_pack_start (GTK_BOX (vbox3), scrolledwindow9, TRUE, TRUE, 0);67.34 -67.35 +67.36 g_signal_connect (dump->window, "delete_event",67.37 G_CALLBACK (on_dump_window_delete_event),67.38 dump);67.39 @@ -132,7 +132,7 @@67.40 }67.42 gboolean on_dump_window_delete_event( GtkWidget *widget, GdkEvent *event,67.43 - gpointer user_data )67.44 + gpointer user_data )67.45 {67.46 dump_window_t data = (dump_window_t)user_data;67.47 if( data->data != NULL )67.48 @@ -158,7 +158,7 @@67.50 assert( data != NULL );67.51 assert( data->_tag == DUMP_WINDOW_TAG );67.52 -67.53 +67.54 startVal = gtk_entry_get_hex_value(GTK_ENTRY(data->fromInput), data->start);67.55 endVal = gtk_entry_get_hex_value(GTK_ENTRY(data->toInput), data->end);67.56 if( startVal != data->start || endVal != data->end ) {67.57 @@ -171,7 +171,7 @@67.58 endVal = startVal + MAX_DUMP_SIZE;67.60 gtk_entry_set_hex_value(GTK_ENTRY(data->fromInput),startVal);67.61 - gtk_entry_set_hex_value(GTK_ENTRY(data->toInput),endVal);67.62 + gtk_entry_set_hex_value(GTK_ENTRY(data->toInput),endVal);67.63 data->start = startVal;67.64 data->end = endVal;67.66 @@ -218,7 +218,7 @@67.67 gtk_text_buffer_get_end_iter(buf,&endIter);67.68 gtk_text_buffer_delete(buf,&iter,&endIter);67.69 gtk_text_buffer_get_start_iter(buf,&iter);67.70 -67.71 +67.72 for( offset = 0, i=data->start; i<data->end; i+=16, offset+=16 ) {67.73 char text[80];67.74 sprintf(text, "%08X:", i );67.75 @@ -234,7 +234,7 @@67.76 gtk_text_buffer_insert( buf, &iter, text, 3 );67.77 else67.78 gtk_text_buffer_insert_with_tags( buf, &iter, text, 3,67.79 - changedTag, NULL );67.80 + changedTag, NULL );67.81 } else {67.82 gtk_text_buffer_insert( buf, &iter, " ", 3 );67.83 }67.84 @@ -250,7 +250,7 @@67.85 gtk_text_buffer_insert( buf, &iter, text, 1 );67.86 else67.87 gtk_text_buffer_insert_with_tags( buf, &iter, text, 1,67.88 - changedTag, NULL );67.89 + changedTag, NULL );67.90 }67.91 gtk_text_buffer_insert( buf, &iter, "\n", 1 );67.92 }
68.1 --- a/src/gtkui/gdrom_menu.c Mon Jul 14 07:42:45 2008 +000068.2 +++ b/src/gtkui/gdrom_menu.c Mon Jul 14 07:44:42 2008 +000068.3 @@ -47,7 +47,7 @@68.4 {68.5 unsigned int i, len;68.6 GSList *group = NULL;68.7 -68.8 +68.9 len = gdrom_list_size();68.10 for( i=0; i < len; i++ ) {68.11 const gchar *entry = gdrom_list_get_display_name(i);68.12 @@ -107,6 +107,6 @@68.13 register_gdrom_list_change_hook(gdrom_menu_update, menu);68.14 gdrom_menu_update( FALSE, gdrom_list_get_selection(), menu );68.15 gtk_widget_show_all(menu);68.16 -68.17 +68.18 return menu;68.19 }
69.1 --- a/src/gtkui/gtkcb.c Mon Jul 14 07:42:45 2008 +000069.2 +++ b/src/gtkui/gtkcb.c Mon Jul 14 07:44:42 2008 +000069.3 @@ -28,58 +28,58 @@69.4 static void add_file_pattern( GtkFileChooser *chooser, char *pattern, char *patname )69.5 {69.6 if( pattern != NULL ) {69.7 - GtkFileFilter *filter = gtk_file_filter_new();69.8 - gtk_file_filter_add_pattern( filter, pattern );69.9 - gtk_file_filter_set_name( filter, patname );69.10 - gtk_file_chooser_add_filter( chooser, filter );69.11 - filter = gtk_file_filter_new();69.12 - gtk_file_filter_set_name( filter, _("All files") );69.13 - gtk_file_filter_add_pattern( filter, "*" );69.14 - gtk_file_chooser_add_filter( chooser, filter );69.15 + GtkFileFilter *filter = gtk_file_filter_new();69.16 + gtk_file_filter_add_pattern( filter, pattern );69.17 + gtk_file_filter_set_name( filter, patname );69.18 + gtk_file_chooser_add_filter( chooser, filter );69.19 + filter = gtk_file_filter_new();69.20 + gtk_file_filter_set_name( filter, _("All files") );69.21 + gtk_file_filter_add_pattern( filter, "*" );69.22 + gtk_file_chooser_add_filter( chooser, filter );69.23 }69.24 }69.26 void open_file_dialog( char *title, file_callback_t action, char *pattern, char *patname,69.27 - gchar const *initial_dir )69.28 + gchar const *initial_dir )69.29 {69.30 GtkWidget *file;69.31 gchar *initial_path = get_absolute_path(initial_dir);69.32 file = gtk_file_chooser_dialog_new( title, NULL,69.33 - GTK_FILE_CHOOSER_ACTION_OPEN,69.34 - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,69.35 - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,69.36 - NULL );69.37 + GTK_FILE_CHOOSER_ACTION_OPEN,69.38 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,69.39 + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,69.40 + NULL );69.41 add_file_pattern( GTK_FILE_CHOOSER(file), pattern, patname );69.42 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), initial_path );69.43 gtk_window_set_modal( GTK_WINDOW(file), TRUE );69.44 gtk_dialog_set_default_response( GTK_DIALOG(file), GTK_RESPONSE_ACCEPT );69.45 int result = gtk_dialog_run( GTK_DIALOG(file) );69.46 if( result == GTK_RESPONSE_ACCEPT ) {69.47 - gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );69.48 - action( filename );69.49 + gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );69.50 + action( filename );69.51 }69.52 gtk_widget_destroy(file);69.53 g_free(initial_path);69.54 }69.56 void save_file_dialog( char *title, file_callback_t action, char *pattern, char *patname,69.57 - gchar const *initial_dir )69.58 + gchar const *initial_dir )69.59 {69.60 GtkWidget *file;69.61 gchar *initial_path = get_absolute_path(initial_dir);69.62 file = gtk_file_chooser_dialog_new( title, NULL,69.63 - GTK_FILE_CHOOSER_ACTION_SAVE,69.64 - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,69.65 - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,69.66 - NULL );69.67 + GTK_FILE_CHOOSER_ACTION_SAVE,69.68 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,69.69 + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,69.70 + NULL );69.71 add_file_pattern( GTK_FILE_CHOOSER(file), pattern, patname );69.72 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), initial_path );69.73 gtk_window_set_modal( GTK_WINDOW(file), TRUE );69.74 gtk_dialog_set_default_response( GTK_DIALOG(file), GTK_RESPONSE_ACCEPT );69.75 int result = gtk_dialog_run( GTK_DIALOG(file) );69.76 if( result == GTK_RESPONSE_ACCEPT ) {69.77 - gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );69.78 - action( filename );69.79 + gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );69.80 + action( filename );69.81 }69.82 gtk_widget_destroy(file);69.83 g_free(initial_path);69.84 @@ -115,18 +115,18 @@69.85 {69.86 GtkWidget *preview = GTK_WIDGET(user_data);69.87 gchar *filename = gtk_file_chooser_get_preview_filename(chooser);69.88 -69.89 +69.90 frame_buffer_t data = dreamcast_load_preview(filename);69.91 if( data != NULL ) {69.92 - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_frame_buffer(data);69.93 - GdkPixbuf *scaled = gdk_pixbuf_scale_simple(pixbuf, 320, 240,69.94 - GDK_INTERP_BILINEAR);69.95 - g_object_unref(pixbuf);69.96 - gtk_image_set_from_pixbuf( GTK_IMAGE(preview), scaled );69.97 - g_object_unref(scaled);69.98 - gtk_widget_show(preview);69.99 + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_frame_buffer(data);69.100 + GdkPixbuf *scaled = gdk_pixbuf_scale_simple(pixbuf, 320, 240,69.101 + GDK_INTERP_BILINEAR);69.102 + g_object_unref(pixbuf);69.103 + gtk_image_set_from_pixbuf( GTK_IMAGE(preview), scaled );69.104 + g_object_unref(scaled);69.105 + gtk_widget_show(preview);69.106 } else {69.107 - gtk_widget_hide(preview);69.108 + gtk_widget_hide(preview);69.109 }69.110 }69.112 @@ -137,10 +137,10 @@69.113 const gchar *dir = lxdream_get_config_value(CONFIG_SAVE_PATH);69.114 gchar *path = get_absolute_path(dir);69.115 file = gtk_file_chooser_dialog_new( _("Load state..."), NULL,69.116 - GTK_FILE_CHOOSER_ACTION_OPEN,69.117 - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,69.118 - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,69.119 - NULL );69.120 + GTK_FILE_CHOOSER_ACTION_OPEN,69.121 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,69.122 + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,69.123 + NULL );69.124 add_file_pattern( GTK_FILE_CHOOSER(file), "*.dst", _("lxDream Save State (*.dst)") );69.125 gtk_object_set_data( GTK_OBJECT(file), "file_action", action );69.127 @@ -157,13 +157,13 @@69.128 gtk_widget_show( align );69.129 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(file), align);69.130 g_signal_connect( file, "update-preview", G_CALLBACK(load_state_preview_callback),69.131 - preview );69.132 + preview );69.133 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), path );69.134 gtk_window_set_modal( GTK_WINDOW(file), TRUE );69.135 int result = gtk_dialog_run( GTK_DIALOG(file) );69.136 if( result == GTK_RESPONSE_ACCEPT ) {69.137 - gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );69.138 - dreamcast_load_state( filename );69.139 + gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );69.140 + dreamcast_load_state( filename );69.141 }69.142 gtk_widget_destroy(file);69.143 g_free(path);69.144 @@ -176,16 +176,16 @@69.145 }69.146 void about_action_callback( GtkAction *action, gpointer user_data)69.147 {69.148 -69.149 +69.150 GtkWidget *dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,69.151 - "name", APP_NAME,69.152 - "version", APP_VERSION,69.153 - "copyright", "(C) 2003-2007 Nathan Keynes",69.154 - NULL);69.155 + "name", APP_NAME,69.156 + "version", APP_VERSION,69.157 + "copyright", "(C) 2003-2007 Nathan Keynes",69.158 + NULL);69.159 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);69.160 gtk_dialog_run(GTK_DIALOG(dialog));69.161 gtk_widget_destroy(dialog);69.162 -69.163 +69.164 }69.166 void exit_action_callback( GtkAction *action, gpointer user_data)69.167 @@ -258,8 +258,8 @@69.168 if( selected_row == -1 ) {69.169 WARN( _("No address selected, so can't run to it"), NULL );69.170 } else {69.171 - debug_window_set_oneshot_breakpoint( debug, selected_row );69.172 - dreamcast_run();69.173 + debug_window_set_oneshot_breakpoint( debug, selected_row );69.174 + dreamcast_run();69.175 }69.176 }69.178 @@ -268,6 +268,6 @@69.179 debug_window_t debug = gtk_gui_get_debugger();69.180 int selected_row = debug_window_get_selected_row(debug);69.181 if( selected_row != -1 ) {69.182 - debug_window_toggle_breakpoint( debug, selected_row );69.183 + debug_window_toggle_breakpoint( debug, selected_row );69.184 }69.185 }
70.1 --- a/src/gtkui/gtkui.c Mon Jul 14 07:42:45 2008 +000070.2 +++ b/src/gtkui/gtkui.c Mon Jul 14 07:44:42 2008 +000070.3 @@ -35,11 +35,11 @@70.4 uint32_t gtk_gui_run_slice( uint32_t nanosecs );70.6 struct dreamcast_module gtk_gui_module = { "gui", NULL,70.7 - gtk_gui_update,70.8 - gtk_gui_start,70.9 - gtk_gui_run_slice,70.10 - gtk_gui_stop,70.11 - NULL, NULL };70.12 + gtk_gui_update,70.13 + gtk_gui_start,70.14 + gtk_gui_run_slice,70.15 + gtk_gui_stop,70.16 + NULL, NULL };70.18 /**70.19 * Single-instance windows (at most one)70.20 @@ -68,38 +68,38 @@70.22 // UI Actions70.23 static const GtkActionEntry ui_actions[] = {70.24 - { "FileMenu", NULL, N_("_File") },70.25 - { "SettingsMenu", NULL, N_("_Settings") },70.26 - { "HelpMenu", NULL, N_("_Help") },70.27 - { "LoadBinary", NULL, N_("Load _Binary..."), NULL, N_("Load and run a program binary"), G_CALLBACK(load_binary_action_callback) },70.28 - { "Reset", GTK_STOCK_REFRESH, N_("_Reset"), "<control>R", N_("Reset dreamcast"), G_CALLBACK(reset_action_callback) },70.29 - { "Pause", GTK_STOCK_MEDIA_PAUSE, N_("_Pause"), NULL, N_("Pause dreamcast"), G_CALLBACK(pause_action_callback) },70.30 - { "Run", GTK_STOCK_MEDIA_PLAY, N_("Resume"), NULL, N_("Resume"), G_CALLBACK(resume_action_callback) },70.31 - { "LoadState", GTK_STOCK_REVERT_TO_SAVED, N_("_Load state..."), "F4", N_("Load an lxdream save state"), G_CALLBACK(load_state_action_callback) },70.32 - { "SaveState", GTK_STOCK_SAVE_AS, N_("_Save state..."), "F3", N_("Create an lxdream save state"), G_CALLBACK(save_state_action_callback) },70.33 - { "Exit", GTK_STOCK_QUIT, N_("E_xit"), NULL, N_("Exit lxdream"), G_CALLBACK(exit_action_callback) },70.34 - { "GdromSettings", NULL, N_("_GD-Rom...") },70.35 - { "GdromUnmount", NULL, N_("_Empty") },70.36 - { "GdromMount", GTK_STOCK_CDROM, N_("_Open Image..."), "<control>O", N_("Mount a cdrom disc"), G_CALLBACK(mount_action_callback) },70.37 - { "PathSettings", NULL, N_("_Paths..."), NULL, N_("Configure files and paths"), G_CALLBACK(path_settings_callback) },70.38 - { "AudioSettings", NULL, N_("_Audio..."), NULL, N_("Configure audio output"), G_CALLBACK(audio_settings_callback) },70.39 - { "ControllerSettings", NULL, N_("_Controllers..."), NULL, N_("Configure controllers"), G_CALLBACK(maple_settings_callback) },70.40 - { "NetworkSettings", NULL, N_("_Network..."), NULL, N_("Configure network settings"), G_CALLBACK(network_settings_callback) },70.41 - { "VideoSettings", NULL, N_("_Video..."), NULL,N_( "Configure video output"), G_CALLBACK(video_settings_callback) },70.42 - { "About", GTK_STOCK_ABOUT, N_("_About..."), NULL, N_("About lxdream"), G_CALLBACK(about_action_callback) },70.43 - { "DebugMenu", NULL, N_("_Debug") },70.44 - { "Debugger", NULL, N_("_Debugger"), NULL, N_("Open debugger window"), G_CALLBACK(debugger_action_callback) },70.45 - { "DebugMem", NULL, N_("View _Memory"), NULL, N_("View memory dump"), G_CALLBACK(debug_memory_action_callback) },70.46 - { "DebugMmio", NULL, N_("View IO _Registers"), NULL, N_("View MMIO Registers"), G_CALLBACK(debug_mmio_action_callback) },70.47 - { "SaveScene", NULL, N_("_Save Scene"), NULL, N_("Save next rendered scene"), G_CALLBACK(save_scene_action_callback) },70.48 - { "SingleStep", GTK_STOCK_REDO, N_("_Single Step"), NULL, N_("Single step"), G_CALLBACK(debug_step_action_callback) },70.49 - { "RunTo", GTK_STOCK_GOTO_LAST, N_("Run _To"), NULL, N_("Run to"), G_CALLBACK( debug_runto_action_callback) },70.50 - { "SetBreakpoint", GTK_STOCK_CLOSE, N_("_Breakpoint"), NULL, N_("Toggle breakpoint"), G_CALLBACK( debug_breakpoint_action_callback) }70.51 + { "FileMenu", NULL, N_("_File") },70.52 + { "SettingsMenu", NULL, N_("_Settings") },70.53 + { "HelpMenu", NULL, N_("_Help") },70.54 + { "LoadBinary", NULL, N_("Load _Binary..."), NULL, N_("Load and run a program binary"), G_CALLBACK(load_binary_action_callback) },70.55 + { "Reset", GTK_STOCK_REFRESH, N_("_Reset"), "<control>R", N_("Reset dreamcast"), G_CALLBACK(reset_action_callback) },70.56 + { "Pause", GTK_STOCK_MEDIA_PAUSE, N_("_Pause"), NULL, N_("Pause dreamcast"), G_CALLBACK(pause_action_callback) },70.57 + { "Run", GTK_STOCK_MEDIA_PLAY, N_("Resume"), NULL, N_("Resume"), G_CALLBACK(resume_action_callback) },70.58 + { "LoadState", GTK_STOCK_REVERT_TO_SAVED, N_("_Load state..."), "F4", N_("Load an lxdream save state"), G_CALLBACK(load_state_action_callback) },70.59 + { "SaveState", GTK_STOCK_SAVE_AS, N_("_Save state..."), "F3", N_("Create an lxdream save state"), G_CALLBACK(save_state_action_callback) },70.60 + { "Exit", GTK_STOCK_QUIT, N_("E_xit"), NULL, N_("Exit lxdream"), G_CALLBACK(exit_action_callback) },70.61 + { "GdromSettings", NULL, N_("_GD-Rom...") },70.62 + { "GdromUnmount", NULL, N_("_Empty") },70.63 + { "GdromMount", GTK_STOCK_CDROM, N_("_Open Image..."), "<control>O", N_("Mount a cdrom disc"), G_CALLBACK(mount_action_callback) },70.64 + { "PathSettings", NULL, N_("_Paths..."), NULL, N_("Configure files and paths"), G_CALLBACK(path_settings_callback) },70.65 + { "AudioSettings", NULL, N_("_Audio..."), NULL, N_("Configure audio output"), G_CALLBACK(audio_settings_callback) },70.66 + { "ControllerSettings", NULL, N_("_Controllers..."), NULL, N_("Configure controllers"), G_CALLBACK(maple_settings_callback) },70.67 + { "NetworkSettings", NULL, N_("_Network..."), NULL, N_("Configure network settings"), G_CALLBACK(network_settings_callback) },70.68 + { "VideoSettings", NULL, N_("_Video..."), NULL,N_( "Configure video output"), G_CALLBACK(video_settings_callback) },70.69 + { "About", GTK_STOCK_ABOUT, N_("_About..."), NULL, N_("About lxdream"), G_CALLBACK(about_action_callback) },70.70 + { "DebugMenu", NULL, N_("_Debug") },70.71 + { "Debugger", NULL, N_("_Debugger"), NULL, N_("Open debugger window"), G_CALLBACK(debugger_action_callback) },70.72 + { "DebugMem", NULL, N_("View _Memory"), NULL, N_("View memory dump"), G_CALLBACK(debug_memory_action_callback) },70.73 + { "DebugMmio", NULL, N_("View IO _Registers"), NULL, N_("View MMIO Registers"), G_CALLBACK(debug_mmio_action_callback) },70.74 + { "SaveScene", NULL, N_("_Save Scene"), NULL, N_("Save next rendered scene"), G_CALLBACK(save_scene_action_callback) },70.75 + { "SingleStep", GTK_STOCK_REDO, N_("_Single Step"), NULL, N_("Single step"), G_CALLBACK(debug_step_action_callback) },70.76 + { "RunTo", GTK_STOCK_GOTO_LAST, N_("Run _To"), NULL, N_("Run to"), G_CALLBACK( debug_runto_action_callback) },70.77 + { "SetBreakpoint", GTK_STOCK_CLOSE, N_("_Breakpoint"), NULL, N_("Toggle breakpoint"), G_CALLBACK( debug_breakpoint_action_callback) }70.78 };70.79 static const GtkToggleActionEntry ui_toggle_actions[] = {70.80 - { "FullScreen", NULL, "_Full Screen", "<alt>Return", "Toggle full screen video", G_CALLBACK(fullscreen_toggle_callback), 0 },70.81 + { "FullScreen", NULL, "_Full Screen", "<alt>Return", "Toggle full screen video", G_CALLBACK(fullscreen_toggle_callback), 0 },70.82 };70.83 -70.84 +70.85 // Menus and toolbars70.86 static const char *ui_description =70.87 "<ui>"70.88 @@ -199,43 +199,43 @@70.89 gboolean gui_init( gboolean withDebug )70.90 {70.91 if( gtk_gui_init_ok ) {70.92 - GError *error = NULL;70.93 - dreamcast_register_module( >k_gui_module );70.94 - gtk_gui_alloc_resources();70.95 -70.96 - global_action_group = gtk_action_group_new("MenuActions");70.97 - gtk_action_group_set_translation_domain( global_action_group, NULL );70.98 - gtk_action_group_add_actions( global_action_group, ui_actions, G_N_ELEMENTS(ui_actions), NULL );70.99 - gtk_action_group_add_toggle_actions( global_action_group, ui_toggle_actions, G_N_ELEMENTS(ui_toggle_actions), NULL );70.100 - gtk_gui_enable_action("AudioSettings", FALSE);70.101 - gtk_gui_enable_action("NetworkSettings", FALSE);70.102 - gtk_gui_enable_action("VideoSettings", FALSE);70.103 -70.104 - global_ui_manager = gtk_ui_manager_new();70.105 - gtk_ui_manager_set_add_tearoffs(global_ui_manager, TRUE);70.106 - gtk_ui_manager_insert_action_group( global_ui_manager, global_action_group, 0 );70.107 -70.108 - if (!gtk_ui_manager_add_ui_from_string (global_ui_manager, ui_description, -1, &error)) {70.109 - g_message ("building menus failed: %s", error->message);70.110 - g_error_free (error);70.111 - exit(1);70.112 - }70.113 - GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group (global_ui_manager);70.114 - GtkWidget *menubar = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu");70.115 - GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/MainToolbar");70.116 -70.117 - GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu/FileMenu/GdromSettings");70.118 - GtkWidget *gdrommenu = gdrom_menu_new();70.119 - gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );70.120 - main_win = main_window_new( APP_NAME " " APP_VERSION, menubar, toolbar, accel_group );70.121 - main_window_set_use_grab(main_win, TRUE);70.122 - if( withDebug ) {70.123 - gtk_gui_show_debugger();70.124 - }70.125 + GError *error = NULL;70.126 + dreamcast_register_module( >k_gui_module );70.127 + gtk_gui_alloc_resources();70.129 - return TRUE;70.130 + global_action_group = gtk_action_group_new("MenuActions");70.131 + gtk_action_group_set_translation_domain( global_action_group, NULL );70.132 + gtk_action_group_add_actions( global_action_group, ui_actions, G_N_ELEMENTS(ui_actions), NULL );70.133 + gtk_action_group_add_toggle_actions( global_action_group, ui_toggle_actions, G_N_ELEMENTS(ui_toggle_actions), NULL );70.134 + gtk_gui_enable_action("AudioSettings", FALSE);70.135 + gtk_gui_enable_action("NetworkSettings", FALSE);70.136 + gtk_gui_enable_action("VideoSettings", FALSE);70.137 +70.138 + global_ui_manager = gtk_ui_manager_new();70.139 + gtk_ui_manager_set_add_tearoffs(global_ui_manager, TRUE);70.140 + gtk_ui_manager_insert_action_group( global_ui_manager, global_action_group, 0 );70.141 +70.142 + if (!gtk_ui_manager_add_ui_from_string (global_ui_manager, ui_description, -1, &error)) {70.143 + g_message ("building menus failed: %s", error->message);70.144 + g_error_free (error);70.145 + exit(1);70.146 + }70.147 + GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group (global_ui_manager);70.148 + GtkWidget *menubar = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu");70.149 + GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/MainToolbar");70.150 +70.151 + GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu/FileMenu/GdromSettings");70.152 + GtkWidget *gdrommenu = gdrom_menu_new();70.153 + gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );70.154 + main_win = main_window_new( APP_NAME " " APP_VERSION, menubar, toolbar, accel_group );70.155 + main_window_set_use_grab(main_win, TRUE);70.156 + if( withDebug ) {70.157 + gtk_gui_show_debugger();70.158 + }70.159 +70.160 + return TRUE;70.161 } else {70.162 - return FALSE;70.163 + return FALSE;70.164 }70.165 }70.167 @@ -258,18 +258,18 @@70.168 gboolean gui_error_dialog( const char *msg, ... )70.169 {70.170 if( main_win != NULL ) {70.171 - va_list args;70.172 - GtkWidget *dialog =70.173 - gtk_message_dialog_new( main_window_get_frame(main_win), GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,70.174 - GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, NULL );70.175 - va_start(args, msg);70.176 - gchar *markup = g_markup_vprintf_escaped( msg, args );70.177 - va_end( args );70.178 - gtk_message_dialog_set_markup( GTK_MESSAGE_DIALOG(dialog), markup );70.179 - g_free(markup);70.180 - gtk_dialog_run(GTK_DIALOG(dialog));70.181 - gtk_widget_destroy(dialog);70.182 - return TRUE;70.183 + va_list args;70.184 + GtkWidget *dialog =70.185 + gtk_message_dialog_new( main_window_get_frame(main_win), GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,70.186 + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, NULL );70.187 + va_start(args, msg);70.188 + gchar *markup = g_markup_vprintf_escaped( msg, args );70.189 + va_end( args );70.190 + gtk_message_dialog_set_markup( GTK_MESSAGE_DIALOG(dialog), markup );70.191 + g_free(markup);70.192 + gtk_dialog_run(GTK_DIALOG(dialog));70.193 + gtk_widget_destroy(dialog);70.194 + return TRUE;70.195 }70.196 return FALSE;70.197 }70.198 @@ -282,28 +282,28 @@70.199 void gtk_gui_show_debugger()70.200 {70.201 if( debug_win ) {70.202 - debug_window_show(debug_win, TRUE);70.203 + debug_window_show(debug_win, TRUE);70.204 } else {70.205 - GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group (global_ui_manager);70.206 - GtkWidget *menubar = gtk_ui_manager_get_widget(global_ui_manager, "/DebugMenu");70.207 - GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/DebugToolbar");70.208 - GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/DebugMenu/FileMenu/GdromSettings");70.209 - GtkWidget *gdrommenu = gdrom_menu_new();70.210 - gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );70.211 - gchar *title = g_strdup_printf( APP_NAME " " APP_VERSION " :: %s", _("Debugger"));70.212 - debug_win = debug_window_new( title, menubar, toolbar, accel_group );70.213 - g_free(title);70.214 + GtkAccelGroup *accel_group = gtk_ui_manager_get_accel_group (global_ui_manager);70.215 + GtkWidget *menubar = gtk_ui_manager_get_widget(global_ui_manager, "/DebugMenu");70.216 + GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/DebugToolbar");70.217 + GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/DebugMenu/FileMenu/GdromSettings");70.218 + GtkWidget *gdrommenu = gdrom_menu_new();70.219 + gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );70.220 + gchar *title = g_strdup_printf( APP_NAME " " APP_VERSION " :: %s", _("Debugger"));70.221 + debug_win = debug_window_new( title, menubar, toolbar, accel_group );70.222 + g_free(title);70.223 }70.224 }70.226 void gtk_gui_show_mmio()70.227 {70.228 if( mmio_win ) {70.229 - mmio_window_show(mmio_win, TRUE);70.230 + mmio_window_show(mmio_win, TRUE);70.231 } else {70.232 - gchar *title = g_strdup_printf( APP_NAME " " APP_VERSION " :: %s", _("MMIO Registers"));70.233 - mmio_win = mmio_window_new( title );70.234 - g_free(title);70.235 + gchar *title = g_strdup_printf( APP_NAME " " APP_VERSION " :: %s", _("MMIO Registers"));70.236 + mmio_win = mmio_window_new( title );70.237 + g_free(title);70.238 }70.239 }70.241 @@ -331,7 +331,7 @@70.242 {70.243 main_window_set_running( main_win, TRUE );70.244 if( debug_win != NULL ) {70.245 - debug_window_set_running( debug_win, TRUE );70.246 + debug_window_set_running( debug_win, TRUE );70.247 }70.248 gtk_gui_nanos = 0;70.249 gettimeofday(>k_gui_lasttv,NULL);70.250 @@ -350,15 +350,15 @@70.251 void gtk_gui_update( void )70.252 {70.253 if( global_action_group ) {70.254 - gtk_gui_enable_action("Run", dreamcast_can_run() && !dreamcast_is_running() );70.255 - gtk_gui_enable_action("Pause", dreamcast_is_running() );70.256 + gtk_gui_enable_action("Run", dreamcast_can_run() && !dreamcast_is_running() );70.257 + gtk_gui_enable_action("Pause", dreamcast_is_running() );70.258 }70.259 if( debug_win ) {70.260 - debug_window_set_running( debug_win, FALSE );70.261 - debug_window_update(debug_win);70.262 + debug_window_set_running( debug_win, FALSE );70.263 + debug_window_update(debug_win);70.264 }70.265 if( mmio_win ) {70.266 - mmio_window_update(mmio_win);70.267 + mmio_window_update(mmio_win);70.268 }70.269 dump_window_update_all();70.270 }70.271 @@ -453,17 +453,17 @@70.272 gint gtk_gui_run_property_dialog( const gchar *title, GtkWidget *panel, gtk_dialog_done_fn fn )70.273 {70.274 GtkWidget *dialog =70.275 - gtk_dialog_new_with_buttons(title, main_window_get_frame(main_win),70.276 - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,70.277 - GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,70.278 - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,70.279 - NULL);70.280 + gtk_dialog_new_with_buttons(title, main_window_get_frame(main_win),70.281 + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,70.282 + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,70.283 + GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,70.284 + NULL);70.285 gint result;70.286 gtk_widget_show_all(panel);70.287 gtk_container_add( GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), panel );70.288 result = gtk_dialog_run( GTK_DIALOG(dialog) );70.289 if( fn != NULL ) {70.290 - fn(panel, result == GTK_RESPONSE_ACCEPT);70.291 + fn(panel, result == GTK_RESPONSE_ACCEPT);70.292 }70.293 gtk_widget_destroy( dialog );70.294 return result;70.295 @@ -477,21 +477,21 @@70.296 static void delete_frame_buffer( guchar *pixels, gpointer buffer )70.297 {70.298 if( buffer != NULL ) {70.299 - g_free(buffer);70.300 + g_free(buffer);70.301 }70.302 }70.304 GdkPixbuf *gdk_pixbuf_new_from_frame_buffer( frame_buffer_t buffer )70.305 {70.306 return gdk_pixbuf_new_from_data( (unsigned char *)buffer->data,70.307 - GDK_COLORSPACE_RGB,70.308 - (buffer->colour_format == COLFMT_BGRA8888),70.309 - 8,70.310 - buffer->width,70.311 - buffer->height,70.312 - buffer->rowstride,70.313 - delete_frame_buffer,70.314 - buffer );70.315 + GDK_COLORSPACE_RGB,70.316 + (buffer->colour_format == COLFMT_BGRA8888),70.317 + 8,70.318 + buffer->width,70.319 + buffer->height,70.320 + buffer->rowstride,70.321 + delete_frame_buffer,70.322 + buffer );70.323 }70.325 /**70.326 @@ -504,9 +504,9 @@70.327 {70.328 GdkKeymap *keymap = gdk_keymap_get_default();70.329 guint keyval;70.330 -70.331 +70.332 gdk_keymap_translate_keyboard_state( keymap, event->hardware_keycode, 0, 0, &keyval,70.333 - NULL, NULL, NULL );70.334 + NULL, NULL, NULL );70.335 return keyval;70.336 }70.338 @@ -514,13 +514,13 @@70.339 {70.340 char tmp[PATH_MAX];70.341 if( in_path == NULL ) {70.342 - return NULL;70.343 + return NULL;70.344 }70.345 if( in_path[0] == '/' || in_path[0] == 0 ) {70.346 - return g_strdup(in_path);70.347 + return g_strdup(in_path);70.348 } else {70.349 - getcwd(tmp, sizeof(tmp));70.350 - return g_strdup_printf("%s%c%s", tmp, G_DIR_SEPARATOR, in_path);70.351 + getcwd(tmp, sizeof(tmp));70.352 + return g_strdup_printf("%s%c%s", tmp, G_DIR_SEPARATOR, in_path);70.353 }70.354 }
71.1 --- a/src/gtkui/gtkui.h Mon Jul 14 07:42:45 2008 +000071.2 +++ b/src/gtkui/gtkui.h Mon Jul 14 07:44:42 2008 +000071.3 @@ -16,8 +16,8 @@71.4 * GNU General Public License for more details.71.5 */71.7 -#ifndef __lxdream_gtkui_H71.8 -#define __lxdream_gtkui_H71.9 +#ifndef lxdream_gtkui_H71.10 +#define lxdream_gtkui_H 171.12 #include "lxdream.h"71.13 #include <gtk/gtk.h>71.14 @@ -25,6 +25,10 @@71.15 #include "gui.h"71.16 #include "cpu.h"71.18 +#ifdef __cplusplus71.19 +extern "C" {71.20 +#endif71.21 +71.22 /********************* Top-level windows *********************/71.24 typedef struct main_window_info *main_window_t;71.25 @@ -37,7 +41,7 @@71.26 * opaque pointer to the window.71.27 */71.28 main_window_t main_window_new( const gchar *title, GtkWidget *menubar,71.29 - GtkWidget *toolbar, GtkAccelGroup *accel );71.30 + GtkWidget *toolbar, GtkAccelGroup *accel );71.31 GtkWindow *main_window_get_frame( main_window_t win );71.32 GtkWidget *main_window_get_renderarea( main_window_t win );71.33 void main_window_set_running( main_window_t win, gboolean running );71.34 @@ -47,7 +51,7 @@71.35 void main_window_set_use_grab( main_window_t win, gboolean grab );71.37 debug_window_t debug_window_new( const gchar *title, GtkWidget *menubar,71.38 - GtkWidget *toolbar, GtkAccelGroup *accel );71.39 + GtkWidget *toolbar, GtkAccelGroup *accel );71.40 void debug_window_show( debug_window_t win, gboolean show );71.41 void debug_window_set_running( debug_window_t win, gboolean running );71.42 void debug_window_update(debug_window_t win);71.43 @@ -82,7 +86,7 @@71.45 typedef gboolean (*file_callback_t)( const gchar *filename );71.46 void open_file_dialog( char *title, file_callback_t action, char *pattern, char *patname,71.47 - gchar const *initial_dir );71.48 + gchar const *initial_dir );71.49 /**71.50 * Extract the keyval of the key event if no modifier keys were pressed -71.51 * in other words get the keyval of the key by itself. The other way around71.52 @@ -155,4 +159,8 @@71.53 extern GdkColor gui_colour_trace, gui_colour_break, gui_colour_temp_break;71.54 extern GdkColor gui_colour_white;71.56 -#endif /* __lxdream_gtkui_H */71.57 +#ifdef __cplusplus71.58 +}71.59 +#endif71.60 +71.61 +#endif /* lxdream_gtkui_H */
72.1 --- a/src/gtkui/main_win.c Mon Jul 14 07:42:45 2008 +000072.2 +++ b/src/gtkui/main_win.c Mon Jul 14 07:44:42 2008 +000072.3 @@ -66,7 +66,7 @@72.4 gdk_drawable_get_size(GDK_DRAWABLE(win->video->window), &width, &height);72.5 x += width / 2;72.6 y += height / 2;72.7 -72.8 +72.9 gdk_display_warp_pointer( display, screen, x, y );72.10 win->mouse_x = width/2;72.11 win->mouse_y = height/2;72.12 @@ -90,15 +90,15 @@72.13 gdk_pixmap_unref(pixmap);72.15 gboolean success =72.16 - gdk_pointer_grab( gdkwin, FALSE,72.17 - GDK_POINTER_MOTION_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK,72.18 - gdkwin, cursor, GDK_CURRENT_TIME ) == GDK_GRAB_SUCCESS;72.19 + gdk_pointer_grab( gdkwin, FALSE,72.20 + GDK_POINTER_MOTION_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK,72.21 + gdkwin, cursor, GDK_CURRENT_TIME ) == GDK_GRAB_SUCCESS;72.22 gdk_cursor_unref(cursor);72.23 if( success ) {72.24 - success = gdk_keyboard_grab( gdkwin, FALSE, GDK_CURRENT_TIME ) == GDK_GRAB_SUCCESS;72.25 - if( !success ) {72.26 - gdk_pointer_ungrab(GDK_CURRENT_TIME);72.27 - }72.28 + success = gdk_keyboard_grab( gdkwin, FALSE, GDK_CURRENT_TIME ) == GDK_GRAB_SUCCESS;72.29 + if( !success ) {72.30 + gdk_pointer_ungrab(GDK_CURRENT_TIME);72.31 + }72.32 }72.33 win->is_grabbed = success;72.34 main_window_set_running(win, dreamcast_is_running());72.35 @@ -117,74 +117,74 @@72.36 }72.38 static gboolean on_video_window_mouse_motion( GtkWidget *widget, GdkEventMotion *event,72.39 - gpointer user_data )72.40 + gpointer user_data )72.41 {72.42 main_window_t win = (main_window_t)user_data;72.43 int32_t x = (int32_t)event->x;72.44 int32_t y = (int32_t)event->y;72.45 if( win->is_grabbed &&72.46 - (x != win->mouse_x || y != win->mouse_y) ) {72.47 - uint32_t buttons = (event->state >> 8)&0x1F;72.48 - input_event_mouse( buttons, x - win->mouse_x, y - win->mouse_y );72.49 - video_window_center_pointer(win);72.50 + (x != win->mouse_x || y != win->mouse_y) ) {72.51 + uint32_t buttons = (event->state >> 8)&0x1F;72.52 + input_event_mouse( buttons, x - win->mouse_x, y - win->mouse_y );72.53 + video_window_center_pointer(win);72.54 }72.55 return TRUE;72.56 }72.58 static gboolean on_video_window_mouse_pressed( GtkWidget *widget, GdkEventButton *event,72.59 - gpointer user_data )72.60 + gpointer user_data )72.61 {72.62 main_window_t win = (main_window_t)user_data;72.63 if( win->is_grabbed ) {72.64 - // Get the buttons from the event state, and remove the released button72.65 - uint32_t buttons = ((event->state >> 8) & 0x1F) | (1<<(event->button-1));72.66 - input_event_mouse( buttons, 0, 0 );72.67 + // Get the buttons from the event state, and remove the released button72.68 + uint32_t buttons = ((event->state >> 8) & 0x1F) | (1<<(event->button-1));72.69 + input_event_mouse( buttons, 0, 0 );72.70 }72.71 return TRUE;72.72 }72.74 static gboolean on_video_window_mouse_released( GtkWidget *widget, GdkEventButton *event,72.75 - gpointer user_data )72.76 + gpointer user_data )72.77 {72.78 main_window_t win = (main_window_t)user_data;72.79 if( win->is_grabbed ) {72.80 - // Get the buttons from the event state, and remove the released button72.81 - uint32_t buttons = ((event->state >> 8) & 0x1F) & (~(1<<(event->button-1)));72.82 - input_event_mouse( buttons, 0, 0 );72.83 + // Get the buttons from the event state, and remove the released button72.84 + uint32_t buttons = ((event->state >> 8) & 0x1F) & (~(1<<(event->button-1)));72.85 + input_event_mouse( buttons, 0, 0 );72.86 } else if( win->use_grab) {72.87 - video_window_grab_display(win);72.88 + video_window_grab_display(win);72.89 }72.90 return TRUE;72.91 }72.93 static gboolean on_video_window_key_pressed( GtkWidget *widget, GdkEventKey *event,72.94 - gpointer user_data )72.95 + gpointer user_data )72.96 {72.97 main_window_t win = (main_window_t)user_data;72.98 if( win->is_grabbed ) {72.99 #ifdef HAVE_GTK_OSX72.100 - /* On OSX, use the command key rather than ctrl-alt. Mainly because GTK/OSX72.101 - * doesn't seem to be able to get ctrl-alt reliably72.102 - **/72.103 - if( event->keyval == GDK_Meta_L || event->keyval == GDK_Meta_R ) {72.104 - video_window_ungrab_display(win);72.105 - return TRUE;72.106 - }72.107 + /* On OSX, use the command key rather than ctrl-alt. Mainly because GTK/OSX72.108 + * doesn't seem to be able to get ctrl-alt reliably72.109 + **/72.110 + if( event->keyval == GDK_Meta_L || event->keyval == GDK_Meta_R ) {72.111 + video_window_ungrab_display(win);72.112 + return TRUE;72.113 + }72.114 #else72.115 - /* Check for ungrab key combo (ctrl-alt). Unfortunately GDK sends it as72.116 - * a singly-modified keypress rather than a double-modified 'null' press,72.117 - * so we have to do a little more work.72.118 - * Only check Ctrl/Shift/Alt for state - don't want to check numlock/capslock/72.119 - * mouse buttons/etc72.120 - */72.121 + /* Check for ungrab key combo (ctrl-alt). Unfortunately GDK sends it as72.122 + * a singly-modified keypress rather than a double-modified 'null' press,72.123 + * so we have to do a little more work.72.124 + * Only check Ctrl/Shift/Alt for state - don't want to check numlock/capslock/72.125 + * mouse buttons/etc72.126 + */72.127 int mod = gdk_keycode_to_modifier(gtk_widget_get_display(widget), event->hardware_keycode);72.128 - int state = event->state & gtk_accelerator_get_default_mod_mask();72.129 - if( (state == GDK_CONTROL_MASK && mod == GDK_MOD1_MASK) ||72.130 - (state == GDK_MOD1_MASK && mod == GDK_CONTROL_MASK) ) {72.131 - video_window_ungrab_display(win);72.132 - // Consume the keypress, DC doesn't get it.72.133 - return TRUE;72.134 - }72.135 + int state = event->state & gtk_accelerator_get_default_mod_mask();72.136 + if( (state == GDK_CONTROL_MASK && mod == GDK_MOD1_MASK) ||72.137 + (state == GDK_MOD1_MASK && mod == GDK_CONTROL_MASK) ) {72.138 + video_window_ungrab_display(win);72.139 + // Consume the keypress, DC doesn't get it.72.140 + return TRUE;72.141 + }72.142 #endif72.143 }72.144 input_event_keydown( NULL, gtk_get_unmodified_keyval(event), 1 );72.145 @@ -192,14 +192,14 @@72.146 }72.148 static gboolean on_video_window_key_released( GtkWidget *widget, GdkEventKey *event,72.149 - gpointer user_data )72.150 + gpointer user_data )72.151 {72.152 input_event_keyup( NULL, gtk_get_unmodified_keyval(event), 0 );72.153 return TRUE;72.154 }72.156 static gboolean on_video_window_focus_changed( GtkWidget *widget, GdkEventFocus *event,72.157 - gpointer user_data )72.158 + gpointer user_data )72.159 {72.160 display_set_focused(event->in);72.161 return TRUE;72.162 @@ -214,35 +214,35 @@72.163 }72.165 static void on_main_window_state_changed( GtkWidget *widget, GdkEventWindowState *state,72.166 - gpointer userdata )72.167 + gpointer userdata )72.168 {72.169 main_window_t win = (main_window_t)userdata;72.170 if( state->changed_mask & GDK_WINDOW_STATE_FULLSCREEN ) {72.171 - gboolean fs = (state->new_window_state & GDK_WINDOW_STATE_FULLSCREEN);72.172 - GtkWidget *frame = gtk_widget_get_parent(win->video);72.173 - if( frame->style == NULL ) {72.174 - gtk_widget_set_style( frame, gtk_style_new() );72.175 - }72.176 - if( fs ) {72.177 - gtk_widget_hide( win->menubar );72.178 - gtk_widget_hide( win->toolbar );72.179 - gtk_widget_hide( win->statusbar );72.180 -72.181 - frame->style->xthickness = 0;72.182 - frame->style->ythickness = 0;72.183 - } else {72.184 - frame->style->xthickness = 2;72.185 - frame->style->ythickness = 2;72.186 - gtk_widget_show( win->menubar );72.187 - gtk_widget_show( win->toolbar );72.188 - gtk_widget_show( win->statusbar );72.189 - }72.190 - gtk_widget_queue_draw( win->window );72.191 + gboolean fs = (state->new_window_state & GDK_WINDOW_STATE_FULLSCREEN);72.192 + GtkWidget *frame = gtk_widget_get_parent(win->video);72.193 + if( frame->style == NULL ) {72.194 + gtk_widget_set_style( frame, gtk_style_new() );72.195 + }72.196 + if( fs ) {72.197 + gtk_widget_hide( win->menubar );72.198 + gtk_widget_hide( win->toolbar );72.199 + gtk_widget_hide( win->statusbar );72.200 +72.201 + frame->style->xthickness = 0;72.202 + frame->style->ythickness = 0;72.203 + } else {72.204 + frame->style->xthickness = 2;72.205 + frame->style->ythickness = 2;72.206 + gtk_widget_show( win->menubar );72.207 + gtk_widget_show( win->toolbar );72.208 + gtk_widget_show( win->statusbar );72.209 + }72.210 + gtk_widget_queue_draw( win->window );72.211 }72.212 }72.214 main_window_t main_window_new( const gchar *title, GtkWidget *menubar, GtkWidget *toolbar,72.215 - GtkAccelGroup *accel_group )72.216 + GtkAccelGroup *accel_group )72.217 {72.218 GtkWidget *vbox;72.219 GtkWidget *frame;72.220 @@ -275,33 +275,33 @@72.221 gtk_box_pack_start( GTK_BOX(vbox), win->statusbar, FALSE, FALSE, 0 );72.222 gtk_widget_show_all( win->window );72.223 gtk_widget_grab_focus( win->video );72.224 -72.225 +72.226 gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, "Stopped" );72.228 g_signal_connect( win->window, "delete_event",72.229 - G_CALLBACK(on_main_window_deleted), win );72.230 + G_CALLBACK(on_main_window_deleted), win );72.231 g_signal_connect( win->window, "window-state-event",72.232 - G_CALLBACK(on_main_window_state_changed), win );72.233 + G_CALLBACK(on_main_window_state_changed), win );72.235 g_signal_connect( win->video, "key-press-event",72.236 - G_CALLBACK(on_video_window_key_pressed), win );72.237 + G_CALLBACK(on_video_window_key_pressed), win );72.238 g_signal_connect( win->video, "key-release-event",72.239 - G_CALLBACK(on_video_window_key_released), win );72.240 + G_CALLBACK(on_video_window_key_released), win );72.241 g_signal_connect( win->video, "motion-notify-event",72.242 - G_CALLBACK(on_video_window_mouse_motion), win );72.243 + G_CALLBACK(on_video_window_mouse_motion), win );72.244 g_signal_connect( win->video, "button-press-event",72.245 - G_CALLBACK(on_video_window_mouse_pressed), win );72.246 + G_CALLBACK(on_video_window_mouse_pressed), win );72.247 g_signal_connect( win->video, "button-release-event",72.248 - G_CALLBACK(on_video_window_mouse_released), win );72.249 + G_CALLBACK(on_video_window_mouse_released), win );72.250 g_signal_connect( win->video, "focus-in-event",72.251 - G_CALLBACK(on_video_window_focus_changed), win);72.252 + G_CALLBACK(on_video_window_focus_changed), win);72.253 g_signal_connect( win->video, "focus-out-event",72.254 - G_CALLBACK(on_video_window_focus_changed), win);72.255 + G_CALLBACK(on_video_window_focus_changed), win);72.257 gtk_widget_add_events( win->video,72.258 - GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |72.259 - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |72.260 - GDK_POINTER_MOTION_MASK | GDK_FOCUS_CHANGE_MASK );72.261 + GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |72.262 + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |72.263 + GDK_POINTER_MOTION_MASK | GDK_FOCUS_CHANGE_MASK );72.265 return win;72.266 }72.267 @@ -310,15 +310,15 @@72.268 {72.269 gtk_statusbar_pop( GTK_STATUSBAR(win->statusbar), 1 );72.270 if( win->is_grabbed ) {72.271 - char buf[128];72.272 + char buf[128];72.273 #ifdef HAVE_GTK_OSX72.274 - snprintf( buf, sizeof(buf), "%s %s", text, _("(Press <command> to release grab)") );72.275 + snprintf( buf, sizeof(buf), "%s %s", text, _("(Press <command> to release grab)") );72.276 #else72.277 - snprintf( buf, sizeof(buf), "%s %s", text, _("(Press <ctrl><alt> to release grab)") );72.278 + snprintf( buf, sizeof(buf), "%s %s", text, _("(Press <ctrl><alt> to release grab)") );72.279 #endif72.280 - gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, buf );72.281 + gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, buf );72.282 } else {72.283 - gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, text );72.284 + gtk_statusbar_push( GTK_STATUSBAR(win->statusbar), 1, text );72.285 }72.286 }72.288 @@ -357,25 +357,25 @@72.289 void main_window_set_fullscreen( main_window_t win, gboolean fullscreen )72.290 {72.291 if( fullscreen ) {72.292 - gtk_window_fullscreen( GTK_WINDOW(win->window) );72.293 + gtk_window_fullscreen( GTK_WINDOW(win->window) );72.294 } else {72.295 - gtk_window_unfullscreen( GTK_WINDOW(win->window) );72.296 + gtk_window_unfullscreen( GTK_WINDOW(win->window) );72.297 }72.298 }72.300 void main_window_set_use_grab( main_window_t win, gboolean use_grab )72.301 {72.302 if( use_grab != win->use_grab ) {72.303 - if( use_grab ) {72.304 - GdkCursor *cursor = gdk_cursor_new( GDK_HAND2 );72.305 - gdk_window_set_cursor( win->video->window, cursor );72.306 - gdk_cursor_unref( cursor );72.307 - } else {72.308 - gdk_window_set_cursor( win->video->window, NULL );72.309 - if( gdk_pointer_is_grabbed() ) {72.310 - video_window_ungrab_display(win);72.311 - }72.312 - }72.313 - win->use_grab = use_grab;72.314 + if( use_grab ) {72.315 + GdkCursor *cursor = gdk_cursor_new( GDK_HAND2 );72.316 + gdk_window_set_cursor( win->video->window, cursor );72.317 + gdk_cursor_unref( cursor );72.318 + } else {72.319 + gdk_window_set_cursor( win->video->window, NULL );72.320 + if( gdk_pointer_is_grabbed() ) {72.321 + video_window_ungrab_display(win);72.322 + }72.323 + }72.324 + win->use_grab = use_grab;72.325 }72.326 }
73.1 --- a/src/gtkui/mmio_win.c Mon Jul 14 07:42:45 2008 +000073.2 +++ b/src/gtkui/mmio_win.c Mon Jul 14 07:44:42 2008 +000073.3 @@ -57,14 +57,14 @@73.4 }73.5 *out = '\0';73.6 }73.7 -73.8 +73.12 gboolean73.13 on_mmio_delete_event (GtkWidget *widget,73.14 - GdkEvent *event,73.15 - gpointer user_data)73.16 + GdkEvent *event,73.17 + gpointer user_data)73.18 {73.19 gtk_widget_hide(widget);73.20 return TRUE;73.21 @@ -78,12 +78,12 @@73.24 void on_trace_button_toggled (GtkToggleButton *button,73.25 - gpointer user_data)73.26 + gpointer user_data)73.27 {73.28 struct mmio_region *io_rgn = (struct mmio_region *)user_data;73.29 gboolean isActive = gtk_toggle_button_get_active(button);73.30 if( io_rgn != NULL ) {73.31 - io_rgn->trace_flag = isActive ? 1 : 0;73.32 + io_rgn->trace_flag = isActive ? 1 : 0;73.33 }73.34 }73.36 @@ -116,23 +116,23 @@73.37 gtk_widget_modify_font( GTK_WIDGET(list), gui_fixed_font );73.38 tab = gtk_label_new(_(name));73.39 gtk_container_add( GTK_CONTAINER(scroll), GTK_WIDGET(list) );73.40 -73.41 +73.42 vbox = GTK_VBOX(gtk_vbox_new( FALSE, 0 ));73.43 gtk_container_add( GTK_CONTAINER(vbox), GTK_WIDGET(scroll) );73.45 trace_button = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(_("Trace access")));73.46 if( io_rgn != NULL ) {73.47 - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(trace_button),73.48 - io_rgn->trace_flag ? TRUE : FALSE);73.49 + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(trace_button),73.50 + io_rgn->trace_flag ? TRUE : FALSE);73.51 }73.52 gtk_container_add( GTK_CONTAINER(vbox), GTK_WIDGET(trace_button) );73.53 gtk_box_set_child_packing( GTK_BOX(vbox), GTK_WIDGET(trace_button),73.54 - FALSE, FALSE, 0, GTK_PACK_START );73.55 + FALSE, FALSE, 0, GTK_PACK_START );73.56 gtk_notebook_append_page( GTK_NOTEBOOK(mmio->notebook), GTK_WIDGET(vbox), tab );73.57 gtk_object_set_data( GTK_OBJECT(mmio->window), name, list );73.58 g_signal_connect ((gpointer) trace_button, "toggled",73.59 - G_CALLBACK (on_trace_button_toggled),73.60 - io_rgn);73.61 + G_CALLBACK (on_trace_button_toggled),73.62 + io_rgn);73.63 return list;73.64 }73.66 @@ -141,7 +141,7 @@73.67 mmio_window_t mmio_window_new( const gchar *title )73.68 {73.69 mmio_window_t mmio = g_malloc0( sizeof(struct mmio_window_info) );73.70 -73.71 +73.72 int i, j;73.73 GtkCList *all_list;73.74 GtkWidget *vbox1;73.75 @@ -162,7 +162,7 @@73.76 hbuttonbox1 = gtk_hbutton_box_new ();73.77 gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, FALSE, TRUE, 0);73.78 gtk_box_set_spacing (GTK_BOX (hbuttonbox1), 30);73.79 -73.80 +73.81 mmr_close = gtk_button_new_with_mnemonic (_("Close"));73.82 gtk_container_add (GTK_CONTAINER (hbuttonbox1), mmr_close);73.83 GTK_WIDGET_SET_FLAGS (mmr_close, GTK_CAN_DEFAULT);73.84 @@ -175,7 +175,7 @@73.85 int sz = io_rgn[i]->ports[j].width;73.86 char addr[10], data[10], bits[40];73.87 char *arr[] = { addr, io_rgn[i]->ports[j].id, data, bits,73.88 - io_rgn[i]->ports[j].desc };73.89 + io_rgn[i]->ports[j].desc };73.90 sprintf( addr, "%08X",73.91 io_rgn[i]->base + io_rgn[i]->ports[j].offset );73.92 printhex( data, sz, *io_rgn[i]->ports[j].val );73.93 @@ -185,18 +185,18 @@73.94 gtk_clist_append( all_list, arr );73.95 }73.96 }73.97 -73.98 +73.99 g_signal_connect ((gpointer) mmio->window, "delete_event",73.100 - G_CALLBACK (on_mmio_delete_event),73.101 - NULL);73.102 + G_CALLBACK (on_mmio_delete_event),73.103 + NULL);73.104 g_signal_connect ((gpointer) mmr_close, "clicked",73.105 - G_CALLBACK (on_mmio_close_clicked),73.106 - mmio);73.107 + G_CALLBACK (on_mmio_close_clicked),73.108 + mmio);73.110 gtk_widget_show_all( mmio->window );73.111 return mmio;73.112 }73.113 -73.114 +73.115 void mmio_window_update( mmio_window_t mmio )73.116 {73.117 int i,j, count = 0;73.118 @@ -204,10 +204,10 @@73.119 char data[10], bits[40];73.121 all_page = GTK_CLIST(gtk_object_get_data( GTK_OBJECT(mmio->window), "All" ));73.122 -73.123 +73.124 for( i=0; i < num_io_rgns; i++ ) {73.125 page = GTK_CLIST(gtk_object_get_data( GTK_OBJECT(mmio->window),73.126 - io_rgn[i]->id ));73.127 + io_rgn[i]->id ));73.128 for( j=0; io_rgn[i]->ports[j].id != NULL; j++ ) {73.129 if( *io_rgn[i]->ports[j].val !=73.130 *(uint32_t *)(io_rgn[i]->save_mem+io_rgn[i]->ports[j].offset)){73.131 @@ -215,15 +215,15 @@73.132 /* Changed */73.133 printhex( data, sz, *io_rgn[i]->ports[j].val );73.134 printbits( bits, sz, *io_rgn[i]->ports[j].val );73.135 -73.136 +73.137 gtk_clist_set_text( page, j, 2, data );73.138 gtk_clist_set_text( page, j, 3, bits );73.139 gtk_clist_set_foreground( page, j, &gui_colour_changed );73.140 -73.141 +73.142 gtk_clist_set_text( all_page, count, 2, data );73.143 gtk_clist_set_text( all_page, count, 3, bits );73.144 gtk_clist_set_foreground( all_page, count, &gui_colour_changed );73.145 -73.146 +73.147 } else {73.148 gtk_clist_set_foreground( page, j, &gui_colour_normal );73.149 gtk_clist_set_foreground( all_page, count, &gui_colour_normal );73.150 @@ -237,9 +237,9 @@73.151 void mmio_window_show( mmio_window_t mmio, gboolean show )73.152 {73.153 if( show ) {73.154 - gtk_widget_show( mmio->window );73.155 + gtk_widget_show( mmio->window );73.156 } else {73.157 - gtk_widget_hide( mmio->window );73.158 + gtk_widget_hide( mmio->window );73.159 }73.160 }
74.1 --- a/src/gtkui/path_dlg.c Mon Jul 14 07:42:45 2008 +000074.2 +++ b/src/gtkui/path_dlg.c Mon Jul 14 07:44:42 2008 +000074.3 @@ -26,15 +26,15 @@74.4 #include "gtkui/gtkui.h"74.6 static const gchar *path_label[] = { N_("Bios rom"), N_("Flash rom"), N_("Default disc path"),74.7 - N_("Save state path"), N_("Bootstrap IP.BIN") };74.8 + N_("Save state path"), N_("Bootstrap IP.BIN") };74.9 static const int path_id[] = { CONFIG_BIOS_PATH, CONFIG_FLASH_PATH, CONFIG_DEFAULT_PATH,74.10 - CONFIG_SAVE_PATH, CONFIG_BOOTSTRAP };74.11 + CONFIG_SAVE_PATH, CONFIG_BOOTSTRAP };74.12 static GtkFileChooserAction path_action[] = {74.13 - GTK_FILE_CHOOSER_ACTION_OPEN,74.14 - GTK_FILE_CHOOSER_ACTION_OPEN,74.15 - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,74.16 - GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,74.17 - GTK_FILE_CHOOSER_ACTION_OPEN };74.18 + GTK_FILE_CHOOSER_ACTION_OPEN,74.19 + GTK_FILE_CHOOSER_ACTION_OPEN,74.20 + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,74.21 + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,74.22 + GTK_FILE_CHOOSER_ACTION_OPEN };74.24 static GtkWidget *path_entry[5];74.26 @@ -42,18 +42,18 @@74.27 {74.28 GtkWidget *entry = GTK_WIDGET(user_data);74.29 GtkWidget *file = gtk_file_chooser_dialog_new( _("Select file"), NULL,74.30 - GTK_FILE_CHOOSER_ACTION_OPEN,74.31 - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,74.32 - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,74.33 - NULL );74.34 + GTK_FILE_CHOOSER_ACTION_OPEN,74.35 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,74.36 + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,74.37 + NULL );74.38 const gchar *filename = gtk_entry_get_text(GTK_ENTRY(entry));74.39 gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(file), filename );74.40 gtk_window_set_modal( GTK_WINDOW(file), TRUE );74.41 gtk_widget_show_all( file );74.42 gint result = gtk_dialog_run(GTK_DIALOG(file));74.43 if( result == GTK_RESPONSE_ACCEPT ) {74.44 - filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );74.45 - gtk_entry_set_text(GTK_ENTRY(entry), filename);74.46 + filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );74.47 + gtk_entry_set_text(GTK_ENTRY(entry), filename);74.48 }74.49 gtk_widget_destroy(file);74.50 return TRUE;74.51 @@ -63,10 +63,10 @@74.52 {74.53 GtkWidget *entry = GTK_WIDGET(user_data);74.54 GtkWidget *file = gtk_file_chooser_dialog_new( _("Select file"), NULL,74.55 - GTK_FILE_CHOOSER_ACTION_OPEN,74.56 - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,74.57 - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,74.58 - NULL );74.59 + GTK_FILE_CHOOSER_ACTION_OPEN,74.60 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,74.61 + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,74.62 + NULL );74.63 const gchar *filename = gtk_entry_get_text(GTK_ENTRY(entry));74.64 gtk_file_chooser_set_action( GTK_FILE_CHOOSER(file), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER );74.65 gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(file), filename );74.66 @@ -74,8 +74,8 @@74.67 gtk_widget_show_all( file );74.68 gint result = gtk_dialog_run(GTK_DIALOG(file));74.69 if( result == GTK_RESPONSE_ACCEPT ) {74.70 - filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );74.71 - gtk_entry_set_text(GTK_ENTRY(entry), filename);74.72 + filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );74.73 + gtk_entry_set_text(GTK_ENTRY(entry), filename);74.74 }74.75 gtk_widget_destroy(file);74.76 return TRUE;74.77 @@ -86,23 +86,23 @@74.78 GtkWidget *table = gtk_table_new( 5, 3, FALSE );74.79 int i;74.80 for( i=0; i<5; i++ ) {74.81 - GtkWidget *text = path_entry[i] = gtk_entry_new();74.82 - GtkWidget *button = gtk_button_new();74.83 - gtk_table_attach( GTK_TABLE(table), gtk_label_new(Q_(path_label[i])), 0, 1, i, i+1,74.84 - GTK_SHRINK, GTK_SHRINK, 0, 0);74.85 - gtk_entry_set_text( GTK_ENTRY(text), lxdream_get_config_value(path_id[i]) );74.86 - gtk_entry_set_width_chars( GTK_ENTRY(text), 48 );74.87 - gtk_table_attach_defaults( GTK_TABLE(table), text, 1, 2, i, i+1 );74.88 - gtk_table_attach( GTK_TABLE(table), button, 2, 3, i, i+1, GTK_SHRINK, GTK_SHRINK, 0, 0 );74.89 - if( path_action[i] == GTK_FILE_CHOOSER_ACTION_OPEN ) {74.90 - GtkWidget *image = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);74.91 - gtk_button_set_image( GTK_BUTTON(button), image );74.92 - g_signal_connect( button, "clicked", G_CALLBACK(path_file_button_clicked), text );74.93 - } else {74.94 - GtkWidget *image = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);74.95 - gtk_button_set_image( GTK_BUTTON(button), image );74.96 - g_signal_connect( button, "clicked", G_CALLBACK(path_dir_button_clicked), text );74.97 - }74.98 + GtkWidget *text = path_entry[i] = gtk_entry_new();74.99 + GtkWidget *button = gtk_button_new();74.100 + gtk_table_attach( GTK_TABLE(table), gtk_label_new(Q_(path_label[i])), 0, 1, i, i+1,74.101 + GTK_SHRINK, GTK_SHRINK, 0, 0);74.102 + gtk_entry_set_text( GTK_ENTRY(text), lxdream_get_config_value(path_id[i]) );74.103 + gtk_entry_set_width_chars( GTK_ENTRY(text), 48 );74.104 + gtk_table_attach_defaults( GTK_TABLE(table), text, 1, 2, i, i+1 );74.105 + gtk_table_attach( GTK_TABLE(table), button, 2, 3, i, i+1, GTK_SHRINK, GTK_SHRINK, 0, 0 );74.106 + if( path_action[i] == GTK_FILE_CHOOSER_ACTION_OPEN ) {74.107 + GtkWidget *image = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);74.108 + gtk_button_set_image( GTK_BUTTON(button), image );74.109 + g_signal_connect( button, "clicked", G_CALLBACK(path_file_button_clicked), text );74.110 + } else {74.111 + GtkWidget *image = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);74.112 + gtk_button_set_image( GTK_BUTTON(button), image );74.113 + g_signal_connect( button, "clicked", G_CALLBACK(path_dir_button_clicked), text );74.114 + }74.115 }74.116 return table;74.118 @@ -111,15 +111,15 @@74.119 void path_panel_done( GtkWidget *panel, gboolean isOK )74.120 {74.121 if( isOK ) {74.122 - int i;74.123 - for(i=0; i<5; i++ ) {74.124 - const char *filename = gtk_entry_get_text( GTK_ENTRY(path_entry[i]) );74.125 - lxdream_set_global_config_value( path_id[i], filename );74.126 - }74.127 -74.128 - lxdream_save_config();74.129 - dreamcast_config_changed();74.130 - gtk_gui_update();74.131 + int i;74.132 + for(i=0; i<5; i++ ) {74.133 + const char *filename = gtk_entry_get_text( GTK_ENTRY(path_entry[i]) );74.134 + lxdream_set_global_config_value( path_id[i], filename );74.135 + }74.136 +74.137 + lxdream_save_config();74.138 + dreamcast_config_changed();74.139 + gtk_gui_update();74.140 }74.141 }
75.1 --- a/src/gui.h Mon Jul 14 07:42:45 2008 +000075.2 +++ b/src/gui.h Mon Jul 14 07:44:42 2008 +000075.3 @@ -16,11 +16,15 @@75.4 * GNU General Public License for more details.75.5 */75.7 -#ifndef __lxdream_gui_H75.8 -#define __lxdream_gui_H75.9 +#ifndef lxdream_gui_H75.10 +#define lxdream_gui_H75.12 #include <glib/gtypes.h>75.14 +#ifdef __cplusplus75.15 +extern "C" {75.16 +#endif75.17 +75.18 /* Base GUI clock is 10ms */75.19 #define GUI_TICK_PERIOD 1000000075.21 @@ -65,4 +69,8 @@75.22 */75.23 void gui_update_io_activity( io_activity_type activity, gboolean active );75.25 -#endif /* __lxdream_gui_H */75.26 +#ifdef __cplusplus75.27 +}75.28 +#endif75.29 +75.30 +#endif /* lxdream_gui_H */
76.1 --- a/src/loader.c Mon Jul 14 07:42:45 2008 +000076.2 +++ b/src/loader.c Mon Jul 14 07:44:42 2008 +000076.3 @@ -19,6 +19,7 @@76.5 #include <unistd.h>76.6 #include <stdio.h>76.7 +#include <string.h>76.8 #include <fcntl.h>76.9 #include <sys/stat.h>76.10 #include <errno.h>76.11 @@ -33,9 +34,9 @@76.12 char bootstrap_magic[32] = "SEGA SEGAKATANA SEGA ENTERPRISES";76.13 char iso_magic[6] = "\001CD001";76.14 char *file_loader_extensions[][2] = {76.15 - { "sbi", "Self Boot Inducer" },76.16 - { "bin", "SH4 Bin file" },76.17 - { NULL, NULL } };76.18 + { "sbi", "Self Boot Inducer" },76.19 + { "bin", "SH4 Bin file" },76.20 + { NULL, NULL } };76.22 #define BOOTSTRAP_LOAD_ADDR 0x8C00800076.23 #define BOOTSTRAP_SIZE 3276876.24 @@ -53,14 +54,14 @@76.25 char buf[32];76.26 struct stat st;76.27 gboolean result = TRUE;76.28 -76.29 +76.30 int fd = open( filename, O_RDONLY );76.31 if( fd == -1 ) {76.32 return FALSE;76.33 }76.34 -76.35 +76.36 fstat( fd, &st );76.37 -76.38 +76.39 /* begin magic */76.40 if( read( fd, buf, 32 ) != 32 ) {76.41 ERROR( "Unable to read from file '%s'", filename );76.42 @@ -74,7 +75,7 @@76.43 lseek( fd, 0, SEEK_SET );76.44 read( fd, load, BOOTSTRAP_SIZE );76.45 bootstrap_dump( load, TRUE );76.46 - dreamcast_program_loaded( filename, BOOTSTRAP_LOAD_ADDR + 0x300 );76.47 + dreamcast_program_loaded( filename, BOOTSTRAP_LOAD_ADDR + 0x300 );76.48 } else {76.49 /* look for a valid ISO9660 header */76.50 lseek( fd, 32768, SEEK_SET );76.51 @@ -82,23 +83,23 @@76.52 if( memcmp( buf, iso_magic, 6 ) == 0 ) {76.53 /* Alright, got it */76.54 INFO( "Loading ISO9660 filesystem from '%s'",76.55 - filename );76.56 + filename );76.57 }76.58 }76.59 } else if( memcmp( buf, "PK\x03\x04", 4 ) == 0 ) {76.60 - /* ZIP file, aka SBI file */76.61 - WARN( "SBI files not supported yet" );76.62 - result = FALSE;76.63 + /* ZIP file, aka SBI file */76.64 + WARN( "SBI files not supported yet" );76.65 + result = FALSE;76.66 } else if( memcmp( buf, DREAMCAST_SAVE_MAGIC, 16 ) == 0 ) {76.67 - /* Save state */76.68 - result = (dreamcast_load_state( filename )==0);76.69 + /* Save state */76.70 + result = (dreamcast_load_state( filename )==0);76.71 } else if( buf[0] == 0x7F && buf[1] == 'E' &&76.72 - buf[2] == 'L' && buf[3] == 'F' ) {76.73 - /* ELF binary */76.74 - lseek( fd, 0, SEEK_SET );76.75 - result = file_load_elf_fd( filename, fd );76.76 + buf[2] == 'L' && buf[3] == 'F' ) {76.77 + /* ELF binary */76.78 + lseek( fd, 0, SEEK_SET );76.79 + result = file_load_elf_fd( filename, fd );76.80 } else {76.81 - result = FALSE;76.82 + result = FALSE;76.83 }76.84 close(fd);76.85 return result;76.86 @@ -108,13 +109,13 @@76.87 {76.88 const gchar *bootstrap_file = lxdream_get_config_value(CONFIG_BOOTSTRAP);76.89 if( bootstrap_file != NULL ) {76.90 - /* Load in a bootstrap before the binary, to initialize everything76.91 - * correctly76.92 - */76.93 + /* Load in a bootstrap before the binary, to initialize everything76.94 + * correctly76.95 + */76.96 if( mem_load_block( bootstrap_file, BOOTSTRAP_LOAD_ADDR, BOOTSTRAP_SIZE ) == 0 ) {76.97 - dreamcast_program_loaded( filename, BOOTSTRAP_LOAD_ADDR+0x300 );76.98 - return;76.99 - }76.100 + dreamcast_program_loaded( filename, BOOTSTRAP_LOAD_ADDR+0x300 );76.101 + return;76.102 + }76.103 }76.104 dreamcast_program_loaded( filename, pc );76.105 }76.106 @@ -124,10 +125,10 @@76.107 {76.108 /* Load the binary itself */76.109 if( mem_load_block( filename, BINARY_LOAD_ADDR, -1 ) == 0 ) {76.110 - file_load_postload( filename, BINARY_LOAD_ADDR );76.111 - return TRUE;76.112 + file_load_postload( filename, BINARY_LOAD_ADDR );76.113 + return TRUE;76.114 } else {76.115 - return FALSE;76.116 + return FALSE;76.117 }76.118 }76.120 @@ -138,32 +139,32 @@76.121 int i;76.123 if( read( fd, &head, sizeof(head) ) != sizeof(head) )76.124 - return FALSE;76.125 + return FALSE;76.126 if( head.e_ident[EI_CLASS] != ELFCLASS32 ||76.127 - head.e_ident[EI_DATA] != ELFDATA2LSB ||76.128 - head.e_ident[EI_VERSION] != 1 ||76.129 - head.e_type != ET_EXEC ||76.130 - head.e_machine != EM_SH ||76.131 - head.e_version != 1 ) {76.132 - ERROR( "File is not an SH4 ELF executable file" );76.133 - return FALSE;76.134 + head.e_ident[EI_DATA] != ELFDATA2LSB ||76.135 + head.e_ident[EI_VERSION] != 1 ||76.136 + head.e_type != ET_EXEC ||76.137 + head.e_machine != EM_SH ||76.138 + head.e_version != 1 ) {76.139 + ERROR( "File is not an SH4 ELF executable file" );76.140 + return FALSE;76.141 }76.143 /* Program headers */76.144 for( i=0; i<head.e_phnum; i++ ) {76.145 - lseek( fd, head.e_phoff + i*head.e_phentsize, SEEK_SET );76.146 - read( fd, &phdr, sizeof(phdr) );76.147 - if( phdr.p_type == PT_LOAD ) {76.148 - lseek( fd, phdr.p_offset, SEEK_SET );76.149 - sh4ptr_t target = mem_get_region( phdr.p_vaddr );76.150 - read( fd, target, phdr.p_filesz );76.151 - if( phdr.p_memsz > phdr.p_filesz ) {76.152 - memset( target + phdr.p_filesz, 0, phdr.p_memsz - phdr.p_filesz );76.153 - }76.154 - INFO( "Loaded %d bytes to %08X", phdr.p_filesz, phdr.p_vaddr );76.155 - }76.156 + lseek( fd, head.e_phoff + i*head.e_phentsize, SEEK_SET );76.157 + read( fd, &phdr, sizeof(phdr) );76.158 + if( phdr.p_type == PT_LOAD ) {76.159 + lseek( fd, phdr.p_offset, SEEK_SET );76.160 + sh4ptr_t target = mem_get_region( phdr.p_vaddr );76.161 + read( fd, target, phdr.p_filesz );76.162 + if( phdr.p_memsz > phdr.p_filesz ) {76.163 + memset( target + phdr.p_filesz, 0, phdr.p_memsz - phdr.p_filesz );76.164 + }76.165 + INFO( "Loaded %d bytes to %08X", phdr.p_filesz, phdr.p_vaddr );76.166 + }76.167 }76.168 -76.169 +76.170 file_load_postload( filename, head.e_entry );76.171 return TRUE;76.172 }
77.1 --- a/src/loader.h Mon Jul 14 07:42:45 2008 +000077.2 +++ b/src/loader.h Mon Jul 14 07:44:42 2008 +000077.3 @@ -16,8 +16,8 @@77.4 * GNU General Public License for more details.77.5 */77.7 -#ifndef dreamcast_loader_H77.8 -#define dreamcast_loader_H 177.9 +#ifndef lxdream_loader_H77.10 +#define lxdream_loader_H 177.12 #include <stdio.h>77.13 #include <glib/gtypes.h>77.14 @@ -68,5 +68,5 @@77.15 }77.16 #endif77.18 -#endif /* !dream_loader_H */77.19 +#endif /* !lxdream_loader_H */
78.1 --- a/src/lxdream.h Mon Jul 14 07:42:45 2008 +000078.2 +++ b/src/lxdream.h Mon Jul 14 07:44:42 2008 +000078.3 @@ -16,8 +16,8 @@78.4 * GNU General Public License for more details.78.5 */78.7 -#ifndef lxdream_common_H78.8 -#define lxdream_common_H 178.9 +#ifndef lxdream_lxdream_H78.10 +#define lxdream_lxdream_H 178.12 #include <stdint.h>78.13 #include <glib/gtypes.h>78.14 @@ -89,4 +89,4 @@78.15 }78.16 #endif78.18 -#endif /* !lxdream_common_H */78.19 +#endif /* !lxdream_lxdream_H */
79.1 --- a/src/main.c Mon Jul 14 07:42:45 2008 +000079.2 +++ b/src/main.c Mon Jul 14 07:44:42 2008 +000079.3 @@ -73,7 +73,7 @@79.4 {79.5 print_version();79.6 printf( "Usage: lxdream [options] [disc-file] [program-file]\n\n" );79.7 -79.8 +79.9 printf( "Options:\n" );79.10 printf( " -a, --aica=PROGFILE %s\n", _("Run the AICA SPU only, with the supplied program") );79.11 printf( " -A, --audio=DRIVER %s\n", _("Use the specified audio driver (? to list)") );79.12 @@ -108,7 +108,7 @@79.13 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);79.14 #endif79.15 textdomain(PACKAGE);79.16 -79.17 +79.18 #endif79.19 }79.21 @@ -124,84 +124,84 @@79.22 display_ok = gui_parse_cmdline(&argc, &argv);79.24 while( (opt = getopt_long( argc, argv, option_list, longopts, NULL )) != -1 ) {79.25 - switch( opt ) {79.26 - case 'a': /* AICA only mode - argument is an AICA program */79.27 - aica_program = optarg;79.28 - break;79.29 - case 'A': /* Audio driver */79.30 - audio_driver_name = optarg;79.31 - if( strcmp(audio_driver_name, "?") == 0 ) {79.32 + switch( opt ) {79.33 + case 'a': /* AICA only mode - argument is an AICA program */79.34 + aica_program = optarg;79.35 + break;79.36 + case 'A': /* Audio driver */79.37 + audio_driver_name = optarg;79.38 + if( strcmp(audio_driver_name, "?") == 0 ) {79.39 + print_version();79.40 + print_audio_drivers(stdout);79.41 + exit(0);79.42 + }79.43 + break;79.44 + case 'c': /* Config file */79.45 + lxdream_set_config_filename(optarg);79.46 + break;79.47 + case 'd': /* Launch w/ debugger */79.48 + show_debugger = TRUE;79.49 + break;79.50 + case 'h': /* help */79.51 + case '?':79.52 + print_usage();79.53 + exit(0);79.54 + break;79.55 + case 'H': /* Headless - shorthand for -V null */79.56 + display_driver_name = "null";79.57 + break;79.58 + case 'l': /* Log verbosity */79.59 + if( !set_global_log_level(optarg) ) {79.60 + ERROR( "Unrecognized log level '%s'", optarg );79.61 + }79.62 + break;79.63 + case 'm': /* Set SH4 CPU clock multiplier (default 0.5) */79.64 + t = strtod(optarg, NULL);79.65 + sh4_cpu_multiplier = (int)(1000.0/t);79.66 + break;79.67 + case 'n': /* Don't start immediately */79.68 + no_start = TRUE;79.69 + start_immediately = FALSE;79.70 + break;79.71 + case 'p': /* Start immediately */79.72 + start_immediately = TRUE;79.73 + no_start = FALSE;79.74 + break;79.75 + case 't': /* Time limit + auto quit */79.76 + t = strtod(optarg, NULL);79.77 + time_secs = (uint32_t)t;79.78 + time_nanos = (int)((t - time_secs) * 1000000000);79.79 + dreamcast_set_run_time( time_secs, time_nanos );79.80 + dreamcast_set_exit_on_stop( TRUE );79.81 + break;79.82 + case 'T': /* trace regions */79.83 + trace_regions = optarg;79.84 + set_global_log_level("trace");79.85 + break;79.86 + case 'u': /* Allow unsafe dcload syscalls */79.87 + dcload_set_allow_unsafe(TRUE);79.88 + break;79.89 + case 'v':79.90 print_version();79.91 - print_audio_drivers(stdout);79.92 exit(0);79.93 + break;79.94 + case 'V': /* Video driver */79.95 + display_driver_name = optarg;79.96 + if( strcmp(display_driver_name,"?") == 0 ) {79.97 + print_version();79.98 + print_display_drivers(stdout);79.99 + exit(0);79.100 + }79.101 + break;79.102 + case 'x': /* Disable translator */79.103 + use_xlat = FALSE;79.104 + break;79.105 }79.106 - break;79.107 - case 'c': /* Config file */79.108 - lxdream_set_config_filename(optarg);79.109 - break;79.110 - case 'd': /* Launch w/ debugger */79.111 - show_debugger = TRUE;79.112 - break;79.113 - case 'h': /* help */79.114 - case '?':79.115 - print_usage();79.116 - exit(0);79.117 - break;79.118 - case 'H': /* Headless - shorthand for -V null */79.119 - display_driver_name = "null";79.120 - break;79.121 - case 'l': /* Log verbosity */79.122 - if( !set_global_log_level(optarg) ) {79.123 - ERROR( "Unrecognized log level '%s'", optarg );79.124 - }79.125 - break;79.126 - case 'm': /* Set SH4 CPU clock multiplier (default 0.5) */79.127 - t = strtod(optarg, NULL);79.128 - sh4_cpu_multiplier = (int)(1000.0/t);79.129 - break;79.130 - case 'n': /* Don't start immediately */79.131 - no_start = TRUE;79.132 - start_immediately = FALSE;79.133 - break;79.134 - case 'p': /* Start immediately */79.135 - start_immediately = TRUE;79.136 - no_start = FALSE;79.137 - break;79.138 - case 't': /* Time limit + auto quit */79.139 - t = strtod(optarg, NULL);79.140 - time_secs = (uint32_t)t;79.141 - time_nanos = (int)((t - time_secs) * 1000000000);79.142 - dreamcast_set_run_time( time_secs, time_nanos );79.143 - dreamcast_set_exit_on_stop( TRUE );79.144 - break;79.145 - case 'T': /* trace regions */79.146 - trace_regions = optarg;79.147 - set_global_log_level("trace");79.148 - break;79.149 - case 'u': /* Allow unsafe dcload syscalls */79.150 - dcload_set_allow_unsafe(TRUE);79.151 - break;79.152 - case 'v':79.153 - print_version();79.154 - exit(0);79.155 - break;79.156 - case 'V': /* Video driver */79.157 - display_driver_name = optarg;79.158 - if( strcmp(display_driver_name,"?") == 0 ) {79.159 - print_version();79.160 - print_display_drivers(stdout);79.161 - exit(0);79.162 - }79.163 - break;79.164 - case 'x': /* Disable translator */79.165 - use_xlat = FALSE;79.166 - break;79.167 - }79.168 }79.170 lxdream_load_config( );79.171 gdrom_list_init();79.172 -79.173 +79.174 if( aica_program == NULL ) {79.175 dreamcast_init();79.176 } else {79.177 @@ -211,7 +211,7 @@79.178 mem_set_trace( trace_regions, TRUE );79.180 audio_init_driver( audio_driver_name, 44100, AUDIO_FMT_16ST );79.181 -79.182 +79.183 headless = display_driver_name != NULL && strcasecmp( display_driver_name, "null" ) == 0;79.184 if( headless ) {79.185 display_set_driver( &display_null_driver );
80.1 --- a/src/maple/controller.c Mon Jul 14 07:42:45 2008 +000080.2 +++ b/src/maple/controller.c Mon Jul 14 07:44:42 2008 +000080.3 @@ -43,26 +43,26 @@80.4 struct maple_device_class controller_class = { "Sega Controller", controller_new };80.6 static struct controller_device base_controller = {80.7 - { MAPLE_DEVICE_TAG, &controller_class, CONTROLLER_IDENT, CONTROLLER_VERSION,80.8 - controller_get_config, controller_attach, controller_detach, controller_destroy,80.9 - controller_clone, NULL, NULL, controller_get_cond, NULL, NULL, NULL },80.10 - {0x0000FFFF, 0x80808080},80.11 - {{ "dpad left", N_("Dpad left"), CONFIG_TYPE_KEY },80.12 - { "dpad right", N_("Dpad right"), CONFIG_TYPE_KEY },80.13 - { "dpad up", N_("Dpad up"), CONFIG_TYPE_KEY },80.14 - { "dpad down", N_("Dpad down"), CONFIG_TYPE_KEY },80.15 - { "analog left", N_("Analog left"), CONFIG_TYPE_KEY },80.16 - { "analog right", N_("Analog right"), CONFIG_TYPE_KEY },80.17 - { "analog up", N_("Analog up"), CONFIG_TYPE_KEY },80.18 - { "analog down", N_("Analog down"), CONFIG_TYPE_KEY },80.19 - { "button X", N_("Button X"), CONFIG_TYPE_KEY },80.20 - { "button Y", N_("Button Y"), CONFIG_TYPE_KEY },80.21 - { "button A", N_("Button A"), CONFIG_TYPE_KEY },80.22 - { "button B", N_("Button B"), CONFIG_TYPE_KEY },80.23 - { "trigger left", N_("Trigger left"), CONFIG_TYPE_KEY },80.24 - { "trigger right", N_("Trigger right"), CONFIG_TYPE_KEY },80.25 - { "start", N_("Start button"), CONFIG_TYPE_KEY },80.26 - { NULL, CONFIG_TYPE_NONE }} };80.27 + { MAPLE_DEVICE_TAG, &controller_class, CONTROLLER_IDENT, CONTROLLER_VERSION,80.28 + controller_get_config, controller_attach, controller_detach, controller_destroy,80.29 + controller_clone, NULL, NULL, controller_get_cond, NULL, NULL, NULL },80.30 + {0x0000FFFF, 0x80808080},80.31 + {{ "dpad left", N_("Dpad left"), CONFIG_TYPE_KEY },80.32 + { "dpad right", N_("Dpad right"), CONFIG_TYPE_KEY },80.33 + { "dpad up", N_("Dpad up"), CONFIG_TYPE_KEY },80.34 + { "dpad down", N_("Dpad down"), CONFIG_TYPE_KEY },80.35 + { "analog left", N_("Analog left"), CONFIG_TYPE_KEY },80.36 + { "analog right", N_("Analog right"), CONFIG_TYPE_KEY },80.37 + { "analog up", N_("Analog up"), CONFIG_TYPE_KEY },80.38 + { "analog down", N_("Analog down"), CONFIG_TYPE_KEY },80.39 + { "button X", N_("Button X"), CONFIG_TYPE_KEY },80.40 + { "button Y", N_("Button Y"), CONFIG_TYPE_KEY },80.41 + { "button A", N_("Button A"), CONFIG_TYPE_KEY },80.42 + { "button B", N_("Button B"), CONFIG_TYPE_KEY },80.43 + { "trigger left", N_("Trigger left"), CONFIG_TYPE_KEY },80.44 + { "trigger right", N_("Trigger right"), CONFIG_TYPE_KEY },80.45 + { "start", N_("Start button"), CONFIG_TYPE_KEY },80.46 + { NULL, CONFIG_TYPE_NONE }} };80.48 #define CONTROLLER(x) ((controller_device_t)(x))80.50 @@ -89,43 +89,43 @@80.51 {80.52 controller_device_t dev = (controller_device_t)mdev;80.53 if( isKeyDown ) {80.54 - switch( value ) {80.55 - case JOY_LEFT:80.56 - dev->condition[1] &= ~JOY_X_AXIS;80.57 - break;80.58 - case JOY_RIGHT:80.59 - dev->condition[1] |= JOY_X_AXIS;80.60 - break;80.61 - case JOY_UP:80.62 - dev->condition[1] &= ~JOY_Y_AXIS;80.63 - break;80.64 - case JOY_DOWN:80.65 - dev->condition[1] |= JOY_Y_AXIS;80.66 - break;80.67 - case BUTTON_LEFT_TRIGGER:80.68 - case BUTTON_RIGHT_TRIGGER:80.69 - dev->condition[0] |= value;80.70 - break;80.71 - default:80.72 - dev->condition[0] &= ~value;80.73 - }80.74 + switch( value ) {80.75 + case JOY_LEFT:80.76 + dev->condition[1] &= ~JOY_X_AXIS;80.77 + break;80.78 + case JOY_RIGHT:80.79 + dev->condition[1] |= JOY_X_AXIS;80.80 + break;80.81 + case JOY_UP:80.82 + dev->condition[1] &= ~JOY_Y_AXIS;80.83 + break;80.84 + case JOY_DOWN:80.85 + dev->condition[1] |= JOY_Y_AXIS;80.86 + break;80.87 + case BUTTON_LEFT_TRIGGER:80.88 + case BUTTON_RIGHT_TRIGGER:80.89 + dev->condition[0] |= value;80.90 + break;80.91 + default:80.92 + dev->condition[0] &= ~value;80.93 + }80.94 } else {80.95 - switch(value ) {80.96 - case JOY_LEFT:80.97 - case JOY_RIGHT:80.98 - dev->condition[1] = (dev->condition[1] & ~JOY_X_AXIS)| JOY_X_AXIS_CENTER;80.99 - break;80.100 - case JOY_UP:80.101 - case JOY_DOWN:80.102 - dev->condition[1] = (dev->condition[1] & ~JOY_Y_AXIS)| JOY_Y_AXIS_CENTER;80.103 - break;80.104 - case BUTTON_LEFT_TRIGGER:80.105 - case BUTTON_RIGHT_TRIGGER:80.106 - dev->condition[0] &= ~value;80.107 - break;80.108 - default:80.109 - dev->condition[0] |= value;80.110 - }80.111 + switch(value ) {80.112 + case JOY_LEFT:80.113 + case JOY_RIGHT:80.114 + dev->condition[1] = (dev->condition[1] & ~JOY_X_AXIS)| JOY_X_AXIS_CENTER;80.115 + break;80.116 + case JOY_UP:80.117 + case JOY_DOWN:80.118 + dev->condition[1] = (dev->condition[1] & ~JOY_Y_AXIS)| JOY_Y_AXIS_CENTER;80.119 + break;80.120 + case BUTTON_LEFT_TRIGGER:80.121 + case BUTTON_RIGHT_TRIGGER:80.122 + dev->condition[0] &= ~value;80.123 + break;80.124 + default:80.125 + dev->condition[0] |= value;80.126 + }80.127 }80.128 }
81.1 --- a/src/maple/controller.h Mon Jul 14 07:42:45 2008 +000081.2 +++ b/src/maple/controller.h Mon Jul 14 07:44:42 2008 +000081.3 @@ -16,6 +16,9 @@81.4 * GNU General Public License for more details.81.5 */81.7 +#ifndef lxdream_controller_H81.8 +#define lxdream_controller_H 181.9 +81.10 /* First word of controller condition */81.11 #define BUTTON_C 0x00000001 /* not on standard controller */81.12 #define BUTTON_B 0x0000000281.13 @@ -50,16 +53,18 @@81.15 /* Standard controller ID */81.16 #define CONTROLLER_IDENT {0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, \81.17 -0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x72, 0x65, 0x61, 0x6d, 0x63, 0x61, 0x73, 0x74, 0x20, \81.18 - 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \81.19 - 0x20, 0x20, 0x20, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x42, 0x79, 0x20, \81.20 - 0x6f, 0x72, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, \81.21 - 0x20, 0x46, 0x72, 0x6f, 0x6d, 0x20, 0x53, 0x45, 0x47, 0x41, 0x20, 0x45, 0x4e, 0x54, 0x45, 0x52, \81.22 - 0x50, 0x52, 0x49, 0x53, 0x45, 0x53, 0x2c, 0x4c, 0x54, 0x44, 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20, \81.23 - 0xae, 0x01, 0xf4, 0x01}81.24 + 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x72, 0x65, 0x61, 0x6d, 0x63, 0x61, 0x73, 0x74, 0x20, \81.25 + 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \81.26 + 0x20, 0x20, 0x20, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x42, 0x79, 0x20, \81.27 + 0x6f, 0x72, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, \81.28 + 0x20, 0x46, 0x72, 0x6f, 0x6d, 0x20, 0x53, 0x45, 0x47, 0x41, 0x20, 0x45, 0x4e, 0x54, 0x45, 0x52, \81.29 + 0x50, 0x52, 0x49, 0x53, 0x45, 0x53, 0x2c, 0x4c, 0x54, 0x44, 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20, \81.30 + 0xae, 0x01, 0xf4, 0x01}81.31 #define CONTROLLER_VERSION {0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x2e, 0x30, 0x31, \81.32 - 0x30, 0x2c, 0x31, 0x39, 0x39, 0x38, 0x2f, 0x30, 0x39, 0x2f, 0x32, 0x38, 0x2c, 0x33, 0x31, 0x35, \81.33 - 0x2d, 0x36, 0x32, 0x31, 0x31, 0x2d, 0x41, 0x42, 0x20, 0x20, 0x20, 0x2c, 0x41, 0x6e, 0x61, 0x6c, \81.34 - 0x6f, 0x67, 0x20, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x3a, 0x20, 0x54, 0x68, 0x65, 0x20, \81.35 - 0x34, 0x74, 0x68, 0x20, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x35, 0x2f, 0x38, 0x20, \81.36 - 0x20, 0x2b, 0x44, 0x46 }81.37 + 0x30, 0x2c, 0x31, 0x39, 0x39, 0x38, 0x2f, 0x30, 0x39, 0x2f, 0x32, 0x38, 0x2c, 0x33, 0x31, 0x35, \81.38 + 0x2d, 0x36, 0x32, 0x31, 0x31, 0x2d, 0x41, 0x42, 0x20, 0x20, 0x20, 0x2c, 0x41, 0x6e, 0x61, 0x6c, \81.39 + 0x6f, 0x67, 0x20, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x3a, 0x20, 0x54, 0x68, 0x65, 0x20, \81.40 + 0x34, 0x74, 0x68, 0x20, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x35, 0x2f, 0x38, 0x20, \81.41 + 0x20, 0x2b, 0x44, 0x46 }81.42 +81.43 +#endif /* !lxdream_controller_H */
82.1 --- a/src/maple/kbd.c Mon Jul 14 07:42:45 2008 +000082.2 +++ b/src/maple/kbd.c Mon Jul 14 07:44:42 2008 +000082.3 @@ -24,27 +24,27 @@82.4 #include "maple.h"82.6 #define KEYBOARD_IDENT { 0x00, 0x00, 0x00, 0x40, 0x02, 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, \82.7 - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x4b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x20, \82.8 - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \82.9 - 0x20, 0x20, 0x20, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x42, 0x79, 0x20, \82.10 - 0x6f, 0x72, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, \82.11 - 0x20, 0x46, 0x72, 0x6f, 0x6d, 0x20, 0x53, 0x45, 0x47, 0x41, 0x20, 0x45, 0x4e, 0x54, 0x45, 0x52, \82.12 - 0x50, 0x52, 0x49, 0x53, 0x45, 0x53, 0x2c, 0x4c, 0x54, 0x44, 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20, \82.13 - 0x2c, 0x01, 0x90, 0x01 }82.14 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x4b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x20, 0x20, \82.15 + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, \82.16 + 0x20, 0x20, 0x20, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x42, 0x79, 0x20, \82.17 + 0x6f, 0x72, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, \82.18 + 0x20, 0x46, 0x72, 0x6f, 0x6d, 0x20, 0x53, 0x45, 0x47, 0x41, 0x20, 0x45, 0x4e, 0x54, 0x45, 0x52, \82.19 + 0x50, 0x52, 0x49, 0x53, 0x45, 0x53, 0x2c, 0x4c, 0x54, 0x44, 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20, \82.20 + 0x2c, 0x01, 0x90, 0x01 }82.22 #define KEYBOARD_VERSION {0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x2e, 0x30, 0x31, \82.23 - 0x30, 0x2c, 0x31, 0x39, 0x39, 0x39, 0x2f, 0x30, 0x34, 0x2f, 0x32, 0x37, 0x2c, 0x33, 0x31, 0x35, \82.24 - 0x2d, 0x36, 0x32, 0x31, 0x31, 0x2d, 0x41, 0x4d, 0x20, 0x20, 0x20, 0x2c, 0x4b, 0x65, 0x79, 0x20, \82.25 - 0x53, 0x63, 0x61, 0x6e, 0x20, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x3a, 0x20, 0x54, 0x68, \82.26 - 0x65, 0x20, 0x32, 0x6e, 0x64, 0x20, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x20, 0x30, \82.27 - 0x34, 0x2f, 0x32, 0x35 }82.28 + 0x30, 0x2c, 0x31, 0x39, 0x39, 0x39, 0x2f, 0x30, 0x34, 0x2f, 0x32, 0x37, 0x2c, 0x33, 0x31, 0x35, \82.29 + 0x2d, 0x36, 0x32, 0x31, 0x31, 0x2d, 0x41, 0x4d, 0x20, 0x20, 0x20, 0x2c, 0x4b, 0x65, 0x79, 0x20, \82.30 + 0x53, 0x63, 0x61, 0x6e, 0x20, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x3a, 0x20, 0x54, 0x68, \82.31 + 0x65, 0x20, 0x32, 0x6e, 0x64, 0x20, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x20, 0x30, \82.32 + 0x34, 0x2f, 0x32, 0x35 }82.34 void keyboard_attach( maple_device_t dev );82.35 void keyboard_detach( maple_device_t dev );82.36 maple_device_t keyboard_clone( maple_device_t dev );82.37 maple_device_t keyboard_new();82.38 int keyboard_get_cond( maple_device_t dev, int function, unsigned char *outbuf,82.39 - unsigned int *outlen );82.40 + unsigned int *outlen );82.42 typedef struct keyboard_device {82.43 struct maple_device dev;82.44 @@ -54,10 +54,10 @@82.45 struct maple_device_class keyboard_class = { "Sega Keyboard", keyboard_new };82.47 static struct keyboard_device base_keyboard = {82.48 - { MAPLE_DEVICE_TAG, &keyboard_class, KEYBOARD_IDENT, KEYBOARD_VERSION,82.49 - NULL, keyboard_attach, keyboard_detach, maple_default_destroy,82.50 - keyboard_clone, NULL, NULL, keyboard_get_cond, NULL, NULL, NULL },82.51 - {0,0,0,0,0,0,0,0},82.52 + { MAPLE_DEVICE_TAG, &keyboard_class, KEYBOARD_IDENT, KEYBOARD_VERSION,82.53 + NULL, keyboard_attach, keyboard_detach, maple_default_destroy,82.54 + keyboard_clone, NULL, NULL, keyboard_get_cond, NULL, NULL, NULL },82.55 + {0,0,0,0,0,0,0,0},82.56 };82.58 #define KEYBOARD(x) ((keyboard_device_t)(x))82.59 @@ -81,12 +81,12 @@82.60 {82.61 int i;82.62 for( i=2; i<8; i++ ) {82.63 - if( dev->condition[i] == key ) {82.64 - return; // key already down, missed event or repeat82.65 - } else if( dev->condition[i] == 0 ) {82.66 - dev->condition[i] = key;82.67 - return;82.68 - }82.69 + if( dev->condition[i] == key ) {82.70 + return; // key already down, missed event or repeat82.71 + } else if( dev->condition[i] == 0 ) {82.72 + dev->condition[i] = key;82.73 + return;82.74 + }82.75 }82.76 /* Key array is full - skip for the moment */82.77 }82.78 @@ -95,13 +95,13 @@82.79 {82.80 int i;82.81 for( i=2; i<8; i++ ) {82.82 - if( dev->condition[i] == key ) {82.83 - for( ; i<7; i++ ) {82.84 - dev->condition[i] = dev->condition[i+1];82.85 - }82.86 - dev->condition[7] = 0;82.87 - break;82.88 - }82.89 + if( dev->condition[i] == key ) {82.90 + for( ; i<7; i++ ) {82.91 + dev->condition[i] = dev->condition[i+1];82.92 + }82.93 + dev->condition[7] = 0;82.94 + break;82.95 + }82.96 }82.97 }82.99 @@ -110,26 +110,26 @@82.100 keyboard_device_t dev = (keyboard_device_t)mdev;82.101 uint16_t key = input_keycode_to_dckeysym( keycode );82.102 if( key != 0 ) {82.103 - if( key >> 8 == 0xFF ) { // shift82.104 - if( isKeyDown ) {82.105 - dev->condition[0] |= (key&0xFF);82.106 - } else {82.107 - dev->condition[0] &= ~(key&0xFF);82.108 - }82.109 - } else {82.110 - if( isKeyDown ) {82.111 - keyboard_key_down( dev, (uint8_t)key );82.112 - } else {82.113 - keyboard_key_up( dev, (uint8_t)key );82.114 - }82.115 - }82.116 + if( key >> 8 == 0xFF ) { // shift82.117 + if( isKeyDown ) {82.118 + dev->condition[0] |= (key&0xFF);82.119 + } else {82.120 + dev->condition[0] &= ~(key&0xFF);82.121 + }82.122 + } else {82.123 + if( isKeyDown ) {82.124 + keyboard_key_down( dev, (uint8_t)key );82.125 + } else {82.126 + keyboard_key_up( dev, (uint8_t)key );82.127 + }82.128 + }82.129 }82.130 /*82.131 fprintf( stderr, "Key cond: %02X %02X %02X %02X %02X %02X %02X %02X\n",82.132 dev->condition[0], dev->condition[1], dev->condition[2],82.133 dev->condition[3], dev->condition[4], dev->condition[5],82.134 dev->condition[6], dev->condition[7] );82.135 - */82.136 + */82.137 }82.139 /**82.140 @@ -148,7 +148,7 @@82.143 int keyboard_get_cond( maple_device_t mdev, int function, unsigned char *outbuf,82.144 - unsigned int *outlen )82.145 + unsigned int *outlen )82.146 {82.147 keyboard_device_t dev = (keyboard_device_t)mdev;82.148 if( function == MAPLE_FUNC_KEYBOARD ) {
83.1 --- a/src/maple/maple.c Mon Jul 14 07:42:45 2008 +000083.2 +++ b/src/maple/maple.c Mon Jul 14 07:44:42 2008 +000083.3 @@ -27,10 +27,10 @@83.4 void maple_init( void );83.6 struct dreamcast_module maple_module = { "Maple", maple_init, NULL, NULL, NULL,83.7 - NULL, NULL, NULL };83.8 + NULL, NULL, NULL };83.10 struct maple_device_class *maple_device_classes[] = {83.11 - &controller_class, &keyboard_class, &mouse_class, NULL };83.12 + &controller_class, &keyboard_class, &mouse_class, NULL };83.14 void maple_init( void )83.15 {83.16 @@ -41,7 +41,7 @@83.17 {83.18 maple_device_class_t clz = maple_get_device_class(name);83.19 if( clz != NULL ) {83.20 - return clz->new_device();83.21 + return clz->new_device();83.22 }83.23 return NULL;83.24 }83.25 @@ -50,8 +50,8 @@83.26 {83.27 int i;83.28 for( i=0; maple_device_classes[i] != NULL; i++ ) {83.29 - if( g_strcasecmp(maple_device_classes[i]->name, name ) == 0 )83.30 - return maple_device_classes[i];83.31 + if( g_strcasecmp(maple_device_classes[i]->name, name ) == 0 )83.32 + return maple_device_classes[i];83.33 }83.34 return NULL;83.35 }83.36 @@ -64,7 +64,7 @@83.37 lxdream_config_entry_t maple_get_device_config( maple_device_t dev )83.38 {83.39 if( dev->get_config == NULL )83.40 - return NULL;83.41 + return NULL;83.42 return dev->get_config(dev);83.43 }83.45 @@ -97,9 +97,9 @@83.47 maple_device_t maple_get_device( unsigned int port, unsigned int periph ) {83.48 if( port >= 4 )83.49 - return NULL;83.50 + return NULL;83.51 if( periph >= 6 )83.52 - return NULL;83.53 + return NULL;83.54 return maple_devices[port][periph];83.55 }83.57 @@ -115,21 +115,21 @@83.58 unsigned int cmd, recv_addr, send_addr;83.59 uint32_t return_addr;83.60 unsigned char *return_buf;83.61 -83.62 +83.63 last = GETBYTE(3) & 0x80; /* indicates last packet */83.64 port = GETBYTE(2) & 0x03;83.65 mode = GETBYTE(1) & 0x07;83.66 length = GETBYTE(0) & 0xFF;83.67 return_addr = GETWORD(4);83.69 - if( mode == 0x07 ) {83.70 - buf += 4;83.71 - address +=4; /* skip? */83.72 - continue;83.73 - }83.74 + if( mode == 0x07 ) {83.75 + buf += 4;83.76 + address +=4; /* skip? */83.77 + continue;83.78 + }83.79 if( (return_addr & 0x1C000000) != 0x0C000000 ) {83.80 - ERROR( "Bad return address in maple packet: %08X", return_addr );83.81 - break;83.82 + ERROR( "Bad return address in maple packet: %08X", return_addr );83.83 + break;83.84 }83.85 return_buf = mem_get_region(return_addr);83.86 cmd = GETBYTE(8);83.87 @@ -137,13 +137,13 @@83.88 send_addr = GETBYTE(10);83.89 /* Sanity checks */83.90 if( GETBYTE(11) != length ||83.91 - send_addr >> 6 != port ||83.92 - recv_addr >> 6 != port ||83.93 - return_buf == NULL ) {83.94 - ERROR( "Received bad packet: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",83.95 - buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7],83.96 - buf[8], buf[9], buf[10], buf[11] );83.97 - break;83.98 + send_addr >> 6 != port ||83.99 + recv_addr >> 6 != port ||83.100 + return_buf == NULL ) {83.101 + ERROR( "Received bad packet: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",83.102 + buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7],83.103 + buf[8], buf[9], buf[10], buf[11] );83.104 + break;83.105 }83.106 periph = 0;83.107 periph_id = recv_addr & 0x3F;83.108 @@ -167,77 +167,77 @@83.109 int status, func, block;83.110 out_length = 0;83.111 switch( cmd ) {83.112 - case MAPLE_CMD_INFO:83.113 - status = MAPLE_RESP_INFO;83.114 - memcpy( return_buf+4, dev->ident, 112 );83.115 - out_length = 0x1C;83.116 - break;83.117 - case MAPLE_CMD_EXT_INFO:83.118 - status = MAPLE_RESP_EXT_INFO;83.119 - memcpy( return_buf+4, dev->ident, 192 );83.120 - out_length = 0x30;83.121 - break;83.122 - case MAPLE_CMD_RESET:83.123 - if( dev->reset == NULL )83.124 - status = MAPLE_RESP_ACK;83.125 - else status = dev->reset(dev);83.126 - break;83.127 - case MAPLE_CMD_SHUTDOWN:83.128 - if( dev->shutdown == NULL )83.129 - status = MAPLE_RESP_ACK;83.130 - else status = dev->shutdown(dev);83.131 - break;83.132 - case MAPLE_CMD_GET_COND:83.133 - func = GETWORD(12);83.134 - if( dev->get_condition == NULL )83.135 - status = MAPLE_ERR_CMD_UNKNOWN;83.136 - else status = dev->get_condition(dev, func,83.137 - return_buf+8,83.138 - &out_length );83.139 - if( status == 0 ) {83.140 - out_length++;83.141 - status = MAPLE_RESP_DATA;83.142 - PUTWORD(4,func);83.143 - }83.144 - break;83.145 - case MAPLE_CMD_SET_COND:83.146 - func = GETWORD(12);83.147 - if( dev->set_condition == NULL )83.148 - status = MAPLE_ERR_CMD_UNKNOWN;83.149 - else status = dev->set_condition(dev, func,83.150 - buf+16,83.151 - length);83.152 + case MAPLE_CMD_INFO:83.153 + status = MAPLE_RESP_INFO;83.154 + memcpy( return_buf+4, dev->ident, 112 );83.155 + out_length = 0x1C;83.156 + break;83.157 + case MAPLE_CMD_EXT_INFO:83.158 + status = MAPLE_RESP_EXT_INFO;83.159 + memcpy( return_buf+4, dev->ident, 192 );83.160 + out_length = 0x30;83.161 + break;83.162 + case MAPLE_CMD_RESET:83.163 + if( dev->reset == NULL )83.164 + status = MAPLE_RESP_ACK;83.165 + else status = dev->reset(dev);83.166 + break;83.167 + case MAPLE_CMD_SHUTDOWN:83.168 + if( dev->shutdown == NULL )83.169 + status = MAPLE_RESP_ACK;83.170 + else status = dev->shutdown(dev);83.171 + break;83.172 + case MAPLE_CMD_GET_COND:83.173 + func = GETWORD(12);83.174 + if( dev->get_condition == NULL )83.175 + status = MAPLE_ERR_CMD_UNKNOWN;83.176 + else status = dev->get_condition(dev, func,83.177 + return_buf+8,83.178 + &out_length );83.179 + if( status == 0 ) {83.180 + out_length++;83.181 + status = MAPLE_RESP_DATA;83.182 + PUTWORD(4,func);83.183 + }83.184 + break;83.185 + case MAPLE_CMD_SET_COND:83.186 + func = GETWORD(12);83.187 + if( dev->set_condition == NULL )83.188 + status = MAPLE_ERR_CMD_UNKNOWN;83.189 + else status = dev->set_condition(dev, func,83.190 + buf+16,83.191 + length);83.192 + if( status == 0 )83.193 + status = MAPLE_RESP_ACK;83.194 + break;83.195 + case MAPLE_CMD_READ_BLOCK:83.196 + func = GETWORD(12);83.197 + block = GETWORD(16);83.198 + if( dev->read_block == NULL )83.199 + status = MAPLE_ERR_CMD_UNKNOWN;83.200 + else status = dev->read_block(dev, func, block,83.201 + return_buf+12,83.202 + &out_length );83.203 + if( status == 0 ) {83.204 + status = MAPLE_RESP_DATA;83.205 + PUTWORD(4,func);83.206 + PUTWORD(8,block);83.207 + }83.208 + break;83.209 + case MAPLE_CMD_WRITE_BLOCK:83.210 + func = GETWORD(12);83.211 + block = GETWORD(16);83.212 + if( dev->write_block == NULL )83.213 + status = MAPLE_ERR_CMD_UNKNOWN;83.214 + else {83.215 + status = dev->write_block(dev, func, block,83.216 + buf+20, length);83.217 if( status == 0 )83.218 status = MAPLE_RESP_ACK;83.219 - break;83.220 - case MAPLE_CMD_READ_BLOCK:83.221 - func = GETWORD(12);83.222 - block = GETWORD(16);83.223 - if( dev->read_block == NULL )83.224 - status = MAPLE_ERR_CMD_UNKNOWN;83.225 - else status = dev->read_block(dev, func, block,83.226 - return_buf+12,83.227 - &out_length );83.228 - if( status == 0 ) {83.229 - status = MAPLE_RESP_DATA;83.230 - PUTWORD(4,func);83.231 - PUTWORD(8,block);83.232 - }83.233 - break;83.234 - case MAPLE_CMD_WRITE_BLOCK:83.235 - func = GETWORD(12);83.236 - block = GETWORD(16);83.237 - if( dev->write_block == NULL )83.238 - status = MAPLE_ERR_CMD_UNKNOWN;83.239 - else {83.240 - status = dev->write_block(dev, func, block,83.241 - buf+20, length);83.242 - if( status == 0 )83.243 - status = MAPLE_RESP_ACK;83.244 - }83.245 - break;83.246 - default:83.247 - status = MAPLE_ERR_CMD_UNKNOWN;83.248 + }83.249 + break;83.250 + default:83.251 + status = MAPLE_ERR_CMD_UNKNOWN;83.252 }83.253 return_buf[0] = status;83.254 return_buf[1] = send_addr;83.255 @@ -247,7 +247,7 @@83.256 return_buf[3] = out_length;83.257 }83.258 buf += 12 + (length<<2);83.259 - address += 12 + (length<<2);83.260 + address += 12 + (length<<2);83.261 }83.262 asic_event( EVENT_MAPLE_DMA );83.263 }83.264 @@ -262,7 +262,7 @@83.265 /* Detach existing peripheral first */83.266 maple_detach_device( port, periph );83.267 }83.268 -83.269 +83.270 maple_devices[port][periph] = dev;83.271 if( periph != 0 )83.272 maple_periph_mask[port] |= (1<<(periph-1));83.273 @@ -284,7 +284,7 @@83.274 dev->detach(dev);83.275 }83.276 if( dev->destroy != NULL ) {83.277 - dev->destroy(dev);83.278 + dev->destroy(dev);83.279 }83.280 if( periph == 0 ) {83.281 /* If we detach the main peripheral, we also have to detach all the83.282 @@ -298,37 +298,37 @@83.283 } else {83.284 maple_periph_mask[port] &= (~(1<<(periph-1)));83.285 }83.286 -83.287 +83.288 }83.290 void maple_detach_all() {83.291 int i, j;83.292 for( i=0; i<4; i++ ) {83.293 - for( j=0; j<6; j++ ) {83.294 - if( maple_devices[i][j] != NULL ) {83.295 - maple_device_t dev = maple_devices[i][j];83.296 - if( dev->detach != NULL )83.297 - dev->detach(dev);83.298 - if( dev->destroy != NULL )83.299 - dev->destroy(dev);83.300 - }83.301 - }83.302 - maple_periph_mask[i] = 0;83.303 + for( j=0; j<6; j++ ) {83.304 + if( maple_devices[i][j] != NULL ) {83.305 + maple_device_t dev = maple_devices[i][j];83.306 + if( dev->detach != NULL )83.307 + dev->detach(dev);83.308 + if( dev->destroy != NULL )83.309 + dev->destroy(dev);83.310 + }83.311 + }83.312 + maple_periph_mask[i] = 0;83.313 }83.314 }83.316 void maple_reattach_all() {83.317 int i, j;83.318 for( i=0; i<4; i++ ) {83.319 - for( j=0; j<6; j++ ) {83.320 - if( maple_devices[i][j] != NULL ) {83.321 - maple_device_t dev = maple_devices[i][j];83.322 - if( dev->detach != NULL )83.323 - dev->detach(dev);83.324 - if( dev->attach != NULL )83.325 - dev->attach(dev);83.326 - }83.327 - }83.328 + for( j=0; j<6; j++ ) {83.329 + if( maple_devices[i][j] != NULL ) {83.330 + maple_device_t dev = maple_devices[i][j];83.331 + if( dev->detach != NULL )83.332 + dev->detach(dev);83.333 + if( dev->attach != NULL )83.334 + dev->attach(dev);83.335 + }83.336 + }83.337 }83.338 }
84.1 --- a/src/maple/maple.h Mon Jul 14 07:42:45 2008 +000084.2 +++ b/src/maple/maple.h Mon Jul 14 07:44:42 2008 +000084.3 @@ -19,6 +19,10 @@84.4 #ifndef lxdream_maple_H84.5 #define lxdream_maple_H 184.7 +#ifdef __cplusplus84.8 +extern "C" {84.9 +#endif84.10 +84.11 #include <stdint.h>84.12 #include "config.h"84.14 @@ -109,4 +113,8 @@84.15 */84.16 void maple_default_destroy( maple_device_t dev );84.18 +#ifdef __cplusplus84.19 +}84.20 +#endif84.21 +84.22 #endif /* !lxdream_maple_H */
85.1 --- a/src/maple/mouse.c Mon Jul 14 07:42:45 2008 +000085.2 +++ b/src/maple/mouse.c Mon Jul 14 07:44:42 2008 +000085.3 @@ -22,19 +22,19 @@85.4 #include "maple/maple.h"85.6 #define MOUSE_IDENT { 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,\85.7 - 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x72, 0x65, 0x61, 0x6d, 0x63, 0x61, 0x73, 0x74, 0x20,\85.8 - 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\85.9 - 0x20, 0x20, 0x20, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x42, 0x79, 0x20,\85.10 - 0x6f, 0x72, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65,\85.11 - 0x20, 0x46, 0x72, 0x6f, 0x6d, 0x20, 0x53, 0x45, 0x47, 0x41, 0x20, 0x45, 0x4e, 0x54, 0x45, 0x52,\85.12 - 0x50, 0x52, 0x49, 0x53, 0x45, 0x53, 0x2c, 0x4c, 0x54, 0x44, 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20,\85.13 - 0x90, 0x01, 0xf4, 0x01 }85.14 + 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x72, 0x65, 0x61, 0x6d, 0x63, 0x61, 0x73, 0x74, 0x20,\85.15 + 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,\85.16 + 0x20, 0x20, 0x20, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x20, 0x42, 0x79, 0x20,\85.17 + 0x6f, 0x72, 0x20, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65,\85.18 + 0x20, 0x46, 0x72, 0x6f, 0x6d, 0x20, 0x53, 0x45, 0x47, 0x41, 0x20, 0x45, 0x4e, 0x54, 0x45, 0x52,\85.19 + 0x50, 0x52, 0x49, 0x53, 0x45, 0x53, 0x2c, 0x4c, 0x54, 0x44, 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20,\85.20 + 0x90, 0x01, 0xf4, 0x01 }85.21 #define MOUSE_VERSION { 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x2e, 0x30, 0x30,\85.22 - 0x30, 0x2c, 0x32, 0x30, 0x30, 0x30, 0x2f, 0x30, 0x32, 0x2f, 0x32, 0x35, 0x2c, 0x33, 0x31, 0x35,\85.23 - 0x2d, 0x36, 0x32, 0x31, 0x31, 0x2d, 0x41, 0x54, 0x20, 0x20, 0x20, 0x2c, 0x33, 0x20, 0x42, 0x75,\85.24 - 0x74, 0x74, 0x6f, 0x6e, 0x20, 0x26, 0x20, 0x58, 0x2d, 0x59, 0x20, 0x42, 0x61, 0x6c, 0x6c, 0x20,\85.25 - 0x26, 0x20, 0x5a, 0x20, 0x57, 0x68, 0x65, 0x65, 0x6c, 0x20, 0x2c, 0x34, 0x30, 0x30, 0x64, 0x70,\85.26 - 0x69, 0x20, 0x20, 0x20 }85.27 + 0x30, 0x2c, 0x32, 0x30, 0x30, 0x30, 0x2f, 0x30, 0x32, 0x2f, 0x32, 0x35, 0x2c, 0x33, 0x31, 0x35,\85.28 + 0x2d, 0x36, 0x32, 0x31, 0x31, 0x2d, 0x41, 0x54, 0x20, 0x20, 0x20, 0x2c, 0x33, 0x20, 0x42, 0x75,\85.29 + 0x74, 0x74, 0x6f, 0x6e, 0x20, 0x26, 0x20, 0x58, 0x2d, 0x59, 0x20, 0x42, 0x61, 0x6c, 0x6c, 0x20,\85.30 + 0x26, 0x20, 0x5a, 0x20, 0x57, 0x68, 0x65, 0x65, 0x6c, 0x20, 0x2c, 0x34, 0x30, 0x30, 0x64, 0x70,\85.31 + 0x69, 0x20, 0x20, 0x20 }85.33 #define BUTTON_MIDDLE 0x0185.34 #define BUTTON_RIGHT 0x0285.35 @@ -46,7 +46,7 @@85.36 maple_device_t mouse_clone( maple_device_t dev );85.37 maple_device_t mouse_new();85.38 int mouse_get_cond( maple_device_t dev, int function, unsigned char *outbuf,85.39 - unsigned int *outlen );85.40 + unsigned int *outlen );85.42 typedef struct mouse_device {85.43 struct maple_device dev;85.44 @@ -57,10 +57,10 @@85.45 struct maple_device_class mouse_class = { "Sega Mouse", mouse_new };85.47 static struct mouse_device base_mouse = {85.48 - { MAPLE_DEVICE_TAG, &mouse_class, MOUSE_IDENT, MOUSE_VERSION,85.49 - NULL, mouse_attach, mouse_detach, maple_default_destroy,85.50 - mouse_clone, NULL, NULL, mouse_get_cond, NULL, NULL, NULL },85.51 - 0, {0,0,0,0,0,0,0,0},85.52 + { MAPLE_DEVICE_TAG, &mouse_class, MOUSE_IDENT, MOUSE_VERSION,85.53 + NULL, mouse_attach, mouse_detach, maple_default_destroy,85.54 + mouse_clone, NULL, NULL, mouse_get_cond, NULL, NULL, NULL },85.55 + 0, {0,0,0,0,0,0,0,0},85.56 };85.58 static int32_t mouse_axis_scale_factors[8] = { 10, 10, 1, 1, 1, 1, 1, 1 };85.59 @@ -88,16 +88,16 @@85.60 mouse_device_t dev = (mouse_device_t)mdev;85.61 dev->buttons = 0xFF;85.62 if( buttons & 0x01 ) {85.63 - dev->buttons &= ~BUTTON_LEFT;85.64 + dev->buttons &= ~BUTTON_LEFT;85.65 }85.66 if( buttons & 0x02 ) {85.67 - dev->buttons &= ~BUTTON_MIDDLE;85.68 + dev->buttons &= ~BUTTON_MIDDLE;85.69 }85.70 if( buttons & 0x04 ) {85.71 - dev->buttons &= ~BUTTON_RIGHT;85.72 + dev->buttons &= ~BUTTON_RIGHT;85.73 }85.74 if( buttons & 0x08 ) {85.75 - dev->buttons &= ~BUTTON_THUMB;85.76 + dev->buttons &= ~BUTTON_THUMB;85.77 }85.78 dev->axis[0] += x;85.79 dev->axis[1] += y;85.80 @@ -114,26 +114,26 @@85.81 }85.83 int mouse_get_cond( maple_device_t mdev, int function, unsigned char *outbuf,85.84 - unsigned int *outlen )85.85 + unsigned int *outlen )85.86 {85.87 mouse_device_t dev = (mouse_device_t)mdev;85.88 if( function == MAPLE_FUNC_MOUSE ) {85.89 *outlen = 5;85.90 - *(uint32_t *)outbuf = dev->buttons;85.91 - uint16_t *p = (uint16_t *)(outbuf+4);85.92 - int i;85.93 - // Axis values are in the range 0..0x3FF, where 0x200 is zero movement85.94 - for( i=0; i<8; i++ ) {85.95 - int32_t value = dev->axis[i] / mouse_axis_scale_factors[i];85.96 - if( value < -0x200 ) {85.97 - p[i] = 0;85.98 - } else if( value > 0x1FF ) {85.99 - p[i] = 0x3FF;85.100 - } else {85.101 - p[i] = 0x200 + value;85.102 - }85.103 - dev->axis[i] = 0; // clear after returning.85.104 - }85.105 + *(uint32_t *)outbuf = dev->buttons;85.106 + uint16_t *p = (uint16_t *)(outbuf+4);85.107 + int i;85.108 + // Axis values are in the range 0..0x3FF, where 0x200 is zero movement85.109 + for( i=0; i<8; i++ ) {85.110 + int32_t value = dev->axis[i] / mouse_axis_scale_factors[i];85.111 + if( value < -0x200 ) {85.112 + p[i] = 0;85.113 + } else if( value > 0x1FF ) {85.114 + p[i] = 0x3FF;85.115 + } else {85.116 + p[i] = 0x200 + value;85.117 + }85.118 + dev->axis[i] = 0; // clear after returning.85.119 + }85.120 return 0;85.121 } else {85.122 return MAPLE_ERR_FUNC_UNSUP;
86.1 --- a/src/mem.c Mon Jul 14 07:42:45 2008 +000086.2 +++ b/src/mem.c Mon Jul 14 07:44:42 2008 +000086.3 @@ -40,7 +40,7 @@86.4 int mem_load(FILE *f);86.5 void mem_save(FILE *f);86.6 struct dreamcast_module mem_module =86.7 - { "MEM", mem_init, mem_reset, NULL, NULL, NULL, mem_save, mem_load };86.8 +{ "MEM", mem_init, mem_reset, NULL, NULL, NULL, mem_save, mem_load };86.10 struct mem_region mem_rgn[MAX_MEM_REGIONS];86.11 struct mmio_region *io_rgn[MAX_IO_REGIONS];86.12 @@ -51,7 +51,7 @@86.13 void *mem_alloc_pages( int n )86.14 {86.15 void *mem = mmap( NULL, n * 4096,86.16 - PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0 );86.17 + PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0 );86.18 if( mem == MAP_FAILED ) {86.19 ERROR( "Memory allocation failure! (%s)", strerror(errno) );86.20 return NULL;86.21 @@ -63,7 +63,7 @@86.22 void mem_init( void )86.23 {86.24 page_map = mmap( NULL, sizeof(sh4ptr_t) * PAGE_TABLE_ENTRIES,86.25 - PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0 );86.26 + PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0 );86.27 if( page_map == MAP_FAILED ) {86.28 ERROR( "Unable to allocate page map! (%s)", strerror(errno) );86.29 page_map = NULL;86.30 @@ -80,9 +80,9 @@86.31 for( i=1; i<num_io_rgns; i++ ) {86.32 for( j=0; io_rgn[i]->ports[j].id != NULL; j++ ) {86.33 if( io_rgn[i]->ports[j].def_val != UNDEFINED &&86.34 - io_rgn[i]->ports[j].def_val != *io_rgn[i]->ports[j].val ) {86.35 + io_rgn[i]->ports[j].def_val != *io_rgn[i]->ports[j].val ) {86.36 io_rgn[i]->io_write( io_rgn[i]->ports[j].offset,86.37 - io_rgn[i]->ports[j].def_val );86.38 + io_rgn[i]->ports[j].def_val );86.39 }86.40 }86.41 }86.42 @@ -92,26 +92,26 @@86.43 {86.44 int i;86.45 uint32_t len;86.46 -86.47 +86.48 /* All memory regions */86.49 fwrite( &num_mem_rgns, sizeof(num_mem_rgns), 1, f );86.50 for( i=0; i<num_mem_rgns; i++ ) {86.51 - fwrite_string( mem_rgn[i].name, f );86.52 - fwrite( &mem_rgn[i].base, sizeof(uint32_t), 1, f );86.53 - fwrite( &mem_rgn[i].flags, sizeof(uint32_t), 1, f );86.54 - fwrite( &mem_rgn[i].size, sizeof(uint32_t), 1, f );86.55 - if( mem_rgn[i].flags != MEM_FLAG_ROM )86.56 - fwrite_gzip( mem_rgn[i].mem, mem_rgn[i].size, 1, f );86.57 + fwrite_string( mem_rgn[i].name, f );86.58 + fwrite( &mem_rgn[i].base, sizeof(uint32_t), 1, f );86.59 + fwrite( &mem_rgn[i].flags, sizeof(uint32_t), 1, f );86.60 + fwrite( &mem_rgn[i].size, sizeof(uint32_t), 1, f );86.61 + if( mem_rgn[i].flags != MEM_FLAG_ROM )86.62 + fwrite_gzip( mem_rgn[i].mem, mem_rgn[i].size, 1, f );86.63 }86.65 /* All MMIO regions */86.66 fwrite( &num_io_rgns, sizeof(num_io_rgns), 1, f );86.67 for( i=0; i<num_io_rgns; i++ ) {86.68 - fwrite_string( io_rgn[i]->id, f );86.69 - fwrite( &io_rgn[i]->base, sizeof( uint32_t ), 1, f );86.70 - len = 4096;86.71 - fwrite( &len, sizeof(len), 1, f );86.72 - fwrite_gzip( io_rgn[i]->mem, len, 1, f );86.73 + fwrite_string( io_rgn[i]->id, f );86.74 + fwrite( &io_rgn[i]->base, sizeof( uint32_t ), 1, f );86.75 + len = 4096;86.76 + fwrite( &len, sizeof(len), 1, f );86.77 + fwrite_gzip( io_rgn[i]->mem, len, 1, f );86.78 }86.79 }86.81 @@ -126,38 +126,38 @@86.82 /* All memory regions */86.83 fread( &len, sizeof(len), 1, f );86.84 if( len != num_mem_rgns )86.85 - return -1;86.86 + return -1;86.87 for( i=0; i<len; i++ ) {86.88 - fread_string( tmp, sizeof(tmp), f );86.89 - fread( &base, sizeof(base), 1, f );86.90 - fread( &flags, sizeof(flags), 1, f );86.91 - fread( &size, sizeof(size), 1, f );86.92 - if( strcmp( mem_rgn[i].name, tmp ) != 0 ||86.93 - base != mem_rgn[i].base ||86.94 - flags != mem_rgn[i].flags ||86.95 - size != mem_rgn[i].size ) {86.96 - ERROR( "Bad memory region %d %s", i, tmp );86.97 - return -1;86.98 - }86.99 - if( flags != MEM_FLAG_ROM )86.100 - fread_gzip( mem_rgn[i].mem, size, 1, f );86.101 + fread_string( tmp, sizeof(tmp), f );86.102 + fread( &base, sizeof(base), 1, f );86.103 + fread( &flags, sizeof(flags), 1, f );86.104 + fread( &size, sizeof(size), 1, f );86.105 + if( strcmp( mem_rgn[i].name, tmp ) != 0 ||86.106 + base != mem_rgn[i].base ||86.107 + flags != mem_rgn[i].flags ||86.108 + size != mem_rgn[i].size ) {86.109 + ERROR( "Bad memory region %d %s", i, tmp );86.110 + return -1;86.111 + }86.112 + if( flags != MEM_FLAG_ROM )86.113 + fread_gzip( mem_rgn[i].mem, size, 1, f );86.114 }86.116 /* All MMIO regions */86.117 fread( &len, sizeof(len), 1, f );86.118 if( len != num_io_rgns )86.119 - return -1;86.120 + return -1;86.121 for( i=0; i<len; i++ ) {86.122 - fread_string( tmp, sizeof(tmp), f );86.123 - fread( &base, sizeof(base), 1, f );86.124 - fread( &size, sizeof(size), 1, f );86.125 - if( strcmp( io_rgn[i]->id, tmp ) != 0 ||86.126 - base != io_rgn[i]->base ||86.127 - size != 4096 ) {86.128 - ERROR( "Bad MMIO region %d %s", i, tmp );86.129 - return -1;86.130 - }86.131 - fread_gzip( io_rgn[i]->mem, size, 1, f );86.132 + fread_string( tmp, sizeof(tmp), f );86.133 + fread( &base, sizeof(base), 1, f );86.134 + fread( &size, sizeof(size), 1, f );86.135 + if( strcmp( io_rgn[i]->id, tmp ) != 0 ||86.136 + base != io_rgn[i]->base ||86.137 + size != 4096 ) {86.138 + ERROR( "Bad MMIO region %d %s", i, tmp );86.139 + return -1;86.140 + }86.141 + fread_gzip( io_rgn[i]->mem, size, 1, f );86.142 }86.143 return 0;86.144 }86.145 @@ -170,20 +170,20 @@86.146 FILE *f = fopen(file,"w");86.148 if( f == NULL )86.149 - return errno;86.150 -86.151 + return errno;86.152 +86.153 while( total < length ) {86.154 - region = mem_get_region(addr);86.155 - len = 4096 - (addr & 0x0FFF);86.156 - if( len > (length-total) )86.157 - len = (length-total);86.158 - if( fwrite( region, len, 1, f ) != 1 ) {86.159 - ERROR( "Unexpected error writing blocks: %d (%s)", len, strerror(errno) );86.160 - break;86.161 - }86.162 -86.163 - addr += len;86.164 - total += len;86.165 + region = mem_get_region(addr);86.166 + len = 4096 - (addr & 0x0FFF);86.167 + if( len > (length-total) )86.168 + len = (length-total);86.169 + if( fwrite( region, len, 1, f ) != 1 ) {86.170 + ERROR( "Unexpected error writing blocks: %d (%s)", len, strerror(errno) );86.171 + break;86.172 + }86.173 +86.174 + addr += len;86.175 + total += len;86.176 }86.177 fclose( f );86.178 INFO( "Loaded %d of %d bytes to %08X", total, length, start );86.179 @@ -199,25 +199,25 @@86.180 FILE *f = fopen(file,"r");86.182 if( f == NULL ) {86.183 - WARN( "Unable to load file '%s': %s", file, strerror(errno) );86.184 - return -1;86.185 + WARN( "Unable to load file '%s': %s", file, strerror(errno) );86.186 + return -1;86.187 }86.188 fstat( fileno(f), &st );86.189 if( length == 0 || length == -1 || length > st.st_size )86.190 - length = st.st_size;86.191 -86.192 + length = st.st_size;86.193 +86.194 while( total < length ) {86.195 - region = mem_get_region(addr);86.196 - len = 4096 - (addr & 0x0FFF);86.197 - if( len > (length-total) )86.198 - len = (length-total);86.199 - if( fread( region, len, 1, f ) != 1 ) {86.200 - ERROR( "Unexpected error reading: %d (%s)", len, strerror(errno) );86.201 - break;86.202 - }86.203 -86.204 - addr += len;86.205 - total += len;86.206 + region = mem_get_region(addr);86.207 + len = 4096 - (addr & 0x0FFF);86.208 + if( len > (length-total) )86.209 + len = (length-total);86.210 + if( fread( region, len, 1, f ) != 1 ) {86.211 + ERROR( "Unexpected error reading: %d (%s)", len, strerror(errno) );86.212 + break;86.213 + }86.214 +86.215 + addr += len;86.216 + total += len;86.217 }86.218 fclose( f );86.219 INFO( "Loaded %d of %d bytes to %08X", total, length, start );86.220 @@ -226,7 +226,7 @@86.222 struct mem_region *mem_map_region( void *mem, uint32_t base, uint32_t size,86.223 const char *name, int flags, uint32_t repeat_offset,86.224 - uint32_t repeat_until )86.225 + uint32_t repeat_until )86.226 {86.227 int i;86.228 mem_rgn[num_mem_rgns].base = base;86.229 @@ -237,9 +237,9 @@86.230 num_mem_rgns++;86.232 do {86.233 - for( i=0; i<size>>PAGE_BITS; i++ )86.234 - page_map[(base>>PAGE_BITS)+i] = mem + (i<<PAGE_BITS);86.235 - base += repeat_offset;86.236 + for( i=0; i<size>>PAGE_BITS; i++ )86.237 + page_map[(base>>PAGE_BITS)+i] = mem + (i<<PAGE_BITS);86.238 + base += repeat_offset;86.239 } while( base <= repeat_until );86.241 return &mem_rgn[num_mem_rgns-1];86.242 @@ -251,10 +251,10 @@86.243 }86.245 void *mem_create_repeating_ram_region( uint32_t base, uint32_t size, const char *name,86.246 - uint32_t repeat_offset, uint32_t repeat_until )86.247 + uint32_t repeat_offset, uint32_t repeat_until )86.248 {86.249 char *mem;86.250 -86.251 +86.252 assert( (base&0xFFFFF000) == base ); /* must be page aligned */86.253 assert( (size&0x00000FFF) == 0 );86.254 assert( num_mem_rgns < MAX_MEM_REGIONS );86.255 @@ -263,12 +263,12 @@86.256 mem = mem_alloc_pages( size>>PAGE_BITS );86.258 mem_map_region( mem, base, size, name, MEM_FLAG_RAM, repeat_offset, repeat_until );86.259 -86.260 +86.261 return mem;86.262 }86.264 gboolean mem_load_rom( const gchar *file, uint32_t base, uint32_t size, uint32_t crc,86.265 - const gchar *region_name )86.266 + const gchar *region_name )86.267 {86.268 sh4ptr_t mem;86.269 uint32_t calc_crc;86.270 @@ -276,29 +276,29 @@86.272 mem = mem_get_region(base);86.273 if( mem == NULL ) {86.274 - mem = mmap( NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_PRIVATE, -1, 0 );86.275 - if( mem == MAP_FAILED ) {86.276 - ERROR( "Unable to allocate ROM memory: %s (%s)", file, strerror(errno) );86.277 - return FALSE;86.278 - }86.279 - mem_map_region( mem, base, size, region_name, MEM_FLAG_ROM, size, base );86.280 + mem = mmap( NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_PRIVATE, -1, 0 );86.281 + if( mem == MAP_FAILED ) {86.282 + ERROR( "Unable to allocate ROM memory: %s (%s)", file, strerror(errno) );86.283 + return FALSE;86.284 + }86.285 + mem_map_region( mem, base, size, region_name, MEM_FLAG_ROM, size, base );86.286 } else {86.287 - mprotect( mem, size, PROT_READ|PROT_WRITE );86.288 + mprotect( mem, size, PROT_READ|PROT_WRITE );86.289 }86.291 status = mem_load_block( file, base, size );86.292 mprotect( mem, size, PROT_READ );86.294 if( status == 0 ) {86.295 - /* CRC check only if we loaded something */86.296 - calc_crc = crc32(0L, (sh4ptr_t)mem, size);86.297 - if( calc_crc != crc ) {86.298 - WARN( "Bios CRC Mismatch in %s: %08X (expected %08X)",86.299 - file, calc_crc, crc);86.300 - }86.301 - return TRUE;86.302 + /* CRC check only if we loaded something */86.303 + calc_crc = crc32(0L, (sh4ptr_t)mem, size);86.304 + if( calc_crc != crc ) {86.305 + WARN( "Bios CRC Mismatch in %s: %08X (expected %08X)",86.306 + file, calc_crc, crc);86.307 + }86.308 + return TRUE;86.309 }86.310 -86.311 +86.312 return FALSE;86.313 }86.315 @@ -315,7 +315,7 @@86.316 void register_io_region( struct mmio_region *io )86.317 {86.318 int i;86.319 -86.320 +86.321 assert(io);86.322 io->mem = mem_alloc_pages(2);86.323 io->save_mem = io->mem + PAGE_SIZE;86.324 @@ -375,13 +375,13 @@86.325 struct mmio_region *mem_get_io_region( uint32_t addr )86.326 {86.327 if( addr > 0xFF000000 ) {86.328 - return P4_io[(addr&0x00FFFFFF)>>12];86.329 + return P4_io[(addr&0x00FFFFFF)>>12];86.330 }86.331 sh4ptr_t page = page_map[(addr&0x1FFFFFFF)>>12];86.332 if( ((uintptr_t)page) < MAX_IO_REGIONS ) {86.333 - return io_rgn[(uintptr_t)page];86.334 + return io_rgn[(uintptr_t)page];86.335 } else {86.336 - return NULL;86.337 + return NULL;86.338 }86.339 }86.341 @@ -389,9 +389,9 @@86.342 {86.343 int i;86.344 for( i=0; i<num_io_rgns; i++ ) {86.345 - if( strcasecmp(io_rgn[i]->id, name) == 0 ) {86.346 - return io_rgn[i];86.347 - }86.348 + if( strcasecmp(io_rgn[i]->id, name) == 0 ) {86.349 + return io_rgn[i];86.350 + }86.351 }86.352 return NULL;86.353 }86.354 @@ -399,25 +399,25 @@86.355 void mem_set_trace( const gchar *tracelist, gboolean flag )86.356 {86.357 if( tracelist != NULL ) {86.358 - gchar ** tracev = g_strsplit_set( tracelist, ",:; \t\r\n", 0 );86.359 - int i;86.360 - for( i=0; tracev[i] != NULL; i++ ) {86.361 - // Special case "all" - trace everything86.362 - if( strcasecmp(tracev[i], "all") == 0 ) {86.363 - int j;86.364 - for( j=0; j<num_io_rgns; j++ ) {86.365 - io_rgn[j]->trace_flag = flag ? 1 : 0;86.366 - }86.367 - break;86.368 - }86.369 - struct mmio_region *region = mem_get_io_region_by_name( tracev[i] );86.370 - if( region == NULL ) {86.371 - WARN( "Unknown IO region '%s'", tracev[i] );86.372 - } else {86.373 - region->trace_flag = flag ? 1 : 0;86.374 - }86.375 - }86.376 - g_strfreev( tracev );86.377 + gchar ** tracev = g_strsplit_set( tracelist, ",:; \t\r\n", 0 );86.378 + int i;86.379 + for( i=0; tracev[i] != NULL; i++ ) {86.380 + // Special case "all" - trace everything86.381 + if( strcasecmp(tracev[i], "all") == 0 ) {86.382 + int j;86.383 + for( j=0; j<num_io_rgns; j++ ) {86.384 + io_rgn[j]->trace_flag = flag ? 1 : 0;86.385 + }86.386 + break;86.387 + }86.388 + struct mmio_region *region = mem_get_io_region_by_name( tracev[i] );86.389 + if( region == NULL ) {86.390 + WARN( "Unknown IO region '%s'", tracev[i] );86.391 + } else {86.392 + region->trace_flag = flag ? 1 : 0;86.393 + }86.394 + }86.395 + g_strfreev( tracev );86.396 }86.397 }
87.1 --- a/src/mem.h Mon Jul 14 07:42:45 2008 +000087.2 +++ b/src/mem.h Mon Jul 14 07:44:42 2008 +000087.3 @@ -17,8 +17,8 @@87.4 * GNU General Public License for more details.87.5 */87.7 -#ifndef dream_mem_H87.8 -#define dream_mem_H87.9 +#ifndef lxdream_mem_H87.10 +#define lxdream_mem_H 187.12 #include <stdint.h>87.13 #include "lxdream.h"87.14 @@ -102,7 +102,9 @@87.15 watch_point_t mem_is_watched( uint32_t addr, int size, int op );87.17 extern sh4ptr_t *page_map;87.18 +87.19 #ifdef __cplusplus87.20 }87.21 #endif87.22 -#endif87.23 +87.24 +#endif /* !lxdream_mem_H */
88.1 --- a/src/pvr2/gl_sl.c Mon Jul 14 07:42:45 2008 +000088.2 +++ b/src/pvr2/gl_sl.c Mon Jul 14 07:44:42 2008 +000088.3 @@ -27,8 +27,8 @@88.4 gboolean glsl_is_supported()88.5 {88.6 return isGLExtensionSupported("GL_ARB_fragment_shader") &&88.7 - isGLExtensionSupported("GL_ARB_vertex_shader") &&88.8 - isGLExtensionSupported("GL_ARB_shading_language_100");88.9 + isGLExtensionSupported("GL_ARB_vertex_shader") &&88.10 + isGLExtensionSupported("GL_ARB_shading_language_100");88.11 }88.13 #ifdef GL_ARB_shader_objects88.14 @@ -48,8 +48,8 @@88.16 glGetObjectParameterivARB(obj, GL_OBJECT_COMPILE_STATUS_ARB, &value);88.17 if( value == 0 ) {88.18 - glsl_print_error(msg, obj);88.19 - return FALSE;88.20 + glsl_print_error(msg, obj);88.21 + return FALSE;88.22 }88.23 return TRUE;88.24 }88.25 @@ -57,7 +57,7 @@88.26 gboolean glsl_check_program_error( char *msg, GLhandleARB obj )88.27 {88.28 if( glGetError() != GL_NO_ERROR ) {88.29 - glsl_print_error(msg, obj);88.30 + glsl_print_error(msg, obj);88.31 }88.32 return TRUE;88.33 }88.34 @@ -68,40 +68,40 @@88.35 gboolean vsok = TRUE, fsok = TRUE, pok = FALSE;88.37 if( vertex_src == NULL && fragment_src == NULL ) {88.38 - return TRUE; // nothing to do88.39 + return TRUE; // nothing to do88.40 }88.42 glsl_program = glCreateProgramObjectARB();88.44 if( vertex_src != NULL ) {88.45 - glsl_vert_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);88.46 - glShaderSourceARB( glsl_vert_shader, 1, &vertex_src, NULL );88.47 - glCompileShaderARB(glsl_vert_shader);88.48 - vsok = glsl_check_shader_error("Failed to compile vertex shader", glsl_vert_shader);88.49 + glsl_vert_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);88.50 + glShaderSourceARB( glsl_vert_shader, 1, &vertex_src, NULL );88.51 + glCompileShaderARB(glsl_vert_shader);88.52 + vsok = glsl_check_shader_error("Failed to compile vertex shader", glsl_vert_shader);88.53 }88.54 if( fragment_src != NULL ) {88.55 - glsl_frag_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);88.56 - glShaderSourceARB( glsl_frag_shader, 1, &fragment_src, NULL );88.57 - glCompileShaderARB(glsl_frag_shader);88.58 - fsok = glsl_check_shader_error("Failed to compile fragment shader", glsl_frag_shader);88.59 + glsl_frag_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);88.60 + glShaderSourceARB( glsl_frag_shader, 1, &fragment_src, NULL );88.61 + glCompileShaderARB(glsl_frag_shader);88.62 + fsok = glsl_check_shader_error("Failed to compile fragment shader", glsl_frag_shader);88.63 }88.65 if( vsok && fsok ) {88.66 - if( vertex_src != NULL ) {88.67 - glAttachObjectARB(glsl_program, glsl_vert_shader);88.68 - }88.69 - if( fragment_src != NULL ) {88.70 - glAttachObjectARB(glsl_program, glsl_frag_shader);88.71 - }88.72 - glLinkProgramARB(glsl_program);88.73 - pok = glsl_check_program_error( "Failed to link shader program", glsl_program );88.74 + if( vertex_src != NULL ) {88.75 + glAttachObjectARB(glsl_program, glsl_vert_shader);88.76 + }88.77 + if( fragment_src != NULL ) {88.78 + glAttachObjectARB(glsl_program, glsl_frag_shader);88.79 + }88.80 + glLinkProgramARB(glsl_program);88.81 + pok = glsl_check_program_error( "Failed to link shader program", glsl_program );88.82 }88.83 if( pok ) {88.84 - glUseProgramObjectARB(glsl_program);88.85 - pok = glsl_check_program_error( "Failed to apply shader program", glsl_program );88.86 - glsl_enable_shaders(FALSE); // initially disabled88.87 + glUseProgramObjectARB(glsl_program);88.88 + pok = glsl_check_program_error( "Failed to apply shader program", glsl_program );88.89 + glsl_enable_shaders(FALSE); // initially disabled88.90 } else {88.91 - glsl_unload_shaders();88.92 + glsl_unload_shaders();88.93 }88.94 return pok;88.95 }88.96 @@ -109,11 +109,11 @@88.97 void glsl_enable_shaders(gboolean en)88.98 {88.99 if( glsl_program != 0 ) {88.100 - if( en ) {88.101 - glUseProgramObjectARB(glsl_program);88.102 - } else {88.103 - glUseProgramObjectARB(0);88.104 - }88.105 + if( en ) {88.106 + glUseProgramObjectARB(glsl_program);88.107 + } else {88.108 + glUseProgramObjectARB(0);88.109 + }88.110 }88.111 }88.113 @@ -136,22 +136,22 @@88.115 glGetShaderiv( shader, GL_COMPILE_STATUS, &value );88.116 if( value == 0 ) {88.117 - char buf[MAX_ERROR_BUF];88.118 - GLsizei length;88.119 - glGetShaderInfoLog( shader, sizeof(buf), &length, buf );88.120 - ERROR( "%s: %s", msg, buf );88.121 - return FALSE;88.122 + char buf[MAX_ERROR_BUF];88.123 + GLsizei length;88.124 + glGetShaderInfoLog( shader, sizeof(buf), &length, buf );88.125 + ERROR( "%s: %s", msg, buf );88.126 + return FALSE;88.127 }88.128 return TRUE;88.129 }88.130 gboolean glsl_check_program_error( char *msg, GLuint program )88.131 {88.132 if( glGetError() != GL_NO_ERROR ) {88.133 - char buf[MAX_ERROR_BUF];88.134 - GLsizei length;88.135 - glGetProgramInfoLog( program, sizeof(buf), &length, buf );88.136 - ERROR( "%s: %s", msg, buf );88.137 - return FALSE;88.138 + char buf[MAX_ERROR_BUF];88.139 + GLsizei length;88.140 + glGetProgramInfoLog( program, sizeof(buf), &length, buf );88.141 + ERROR( "%s: %s", msg, buf );88.142 + return FALSE;88.143 }88.144 return TRUE;88.145 }88.146 @@ -161,41 +161,41 @@88.147 gboolean vsok = TRUE, fsok = TRUE, pok = FALSE;88.149 if( vertex_src == NULL && fragment_src == NULL ) {88.150 - return TRUE;88.151 + return TRUE;88.152 }88.154 glsl_program = glCreateProgram();88.156 if( vertex_src != NULL ) {88.157 - glsl_vert_shader = glCreateShader(GL_VERTEX_SHADER);88.158 - glShaderSource( glsl_vert_shader, 1, &vertex_src, NULL );88.159 - glCompileShader(glsl_vert_shader);88.160 - vsok = glsl_check_shader_error( "Failed to compile vertex shader", glsl_vert_shader );88.161 + glsl_vert_shader = glCreateShader(GL_VERTEX_SHADER);88.162 + glShaderSource( glsl_vert_shader, 1, &vertex_src, NULL );88.163 + glCompileShader(glsl_vert_shader);88.164 + vsok = glsl_check_shader_error( "Failed to compile vertex shader", glsl_vert_shader );88.165 }88.166 if( fragment_src != NULL ) {88.167 - glsl_frag_shader = glCreateShader(GL_FRAGMENT_SHADER);88.168 - glShaderSource( glsl_frag_shader, 1, &fragment_src, NULL );88.169 - glCompileShader(glsl_frag_shader);88.170 - fsok = glsl_check_shader_error( "Failed to compile fragment shader", glsl_frag_shader );88.171 + glsl_frag_shader = glCreateShader(GL_FRAGMENT_SHADER);88.172 + glShaderSource( glsl_frag_shader, 1, &fragment_src, NULL );88.173 + glCompileShader(glsl_frag_shader);88.174 + fsok = glsl_check_shader_error( "Failed to compile fragment shader", glsl_frag_shader );88.175 }88.177 if( vsok && fsok ) {88.178 - if( vertex_src != NULL ) {88.179 - glAttachShader(glsl_program, glsl_vert_shader);88.180 - }88.181 - if( fragment_src != NULL ) {88.182 - glAttachShader(glsl_program, glsl_frag_shader);88.183 - }88.184 - glLinkProgram(glsl_program);88.185 - pok = glsl_check_program_error( "Failed to link shader program", glsl_program );88.186 + if( vertex_src != NULL ) {88.187 + glAttachShader(glsl_program, glsl_vert_shader);88.188 + }88.189 + if( fragment_src != NULL ) {88.190 + glAttachShader(glsl_program, glsl_frag_shader);88.191 + }88.192 + glLinkProgram(glsl_program);88.193 + pok = glsl_check_program_error( "Failed to link shader program", glsl_program );88.194 }88.196 if( pok ) {88.197 - glUseProgram(glsl_program);88.198 - pok = glsl_check_program_error( "Failed to apply shader program", glsl_program );88.199 - glsl_enable_shaders(FALSE); // initially disabled88.200 + glUseProgram(glsl_program);88.201 + pok = glsl_check_program_error( "Failed to apply shader program", glsl_program );88.202 + glsl_enable_shaders(FALSE); // initially disabled88.203 } else {88.204 - glsl_unload_shaders();88.205 + glsl_unload_shaders();88.206 }88.207 return pok;88.208 }88.209 @@ -204,11 +204,11 @@88.210 void glsl_enable_shaders(gboolean en)88.211 {88.212 if( glsl_program != 0 ) {88.213 - if( en ) {88.214 - glUseProgram(glsl_program);88.215 - } else {88.216 - glUseProgram(0);88.217 - }88.218 + if( en ) {88.219 + glUseProgram(glsl_program);88.220 + } else {88.221 + glUseProgram(0);88.222 + }88.223 }88.224 }
89.1 --- a/src/pvr2/glrender.c Mon Jul 14 07:42:45 2008 +000089.2 +++ b/src/pvr2/glrender.c Mon Jul 14 07:44:42 2008 +000089.3 @@ -25,25 +25,25 @@89.4 #include "pvr2/glutil.h"89.6 int pvr2_poly_depthmode[8] = { GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL,89.7 - GL_GREATER, GL_NOTEQUAL, GL_GEQUAL,89.8 - GL_ALWAYS };89.9 + GL_GREATER, GL_NOTEQUAL, GL_GEQUAL,89.10 + GL_ALWAYS };89.11 int pvr2_poly_srcblend[8] = {89.12 - GL_ZERO, GL_ONE, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR,89.13 - GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA,89.14 - GL_ONE_MINUS_DST_ALPHA };89.15 + GL_ZERO, GL_ONE, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR,89.16 + GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA,89.17 + GL_ONE_MINUS_DST_ALPHA };89.18 int pvr2_poly_dstblend[8] = {89.19 - GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,89.20 - GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA,89.21 - GL_ONE_MINUS_DST_ALPHA };89.22 + GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,89.23 + GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA,89.24 + GL_ONE_MINUS_DST_ALPHA };89.25 int pvr2_poly_texblend[4] = {89.26 - GL_REPLACE,89.27 - GL_MODULATE,89.28 - GL_DECAL,89.29 - GL_MODULATE89.30 + GL_REPLACE,89.31 + GL_MODULATE,89.32 + GL_DECAL,89.33 + GL_MODULATE89.34 };89.35 int pvr2_render_colour_format[8] = {89.36 - COLFMT_BGRA1555, COLFMT_RGB565, COLFMT_BGRA4444, COLFMT_BGRA1555,89.37 - COLFMT_BGR888, COLFMT_BGRA8888, COLFMT_BGRA8888, COLFMT_BGRA4444 };89.38 + COLFMT_BGRA1555, COLFMT_RGB565, COLFMT_BGRA4444, COLFMT_BGRA1555,89.39 + COLFMT_BGR888, COLFMT_BGRA8888, COLFMT_BGRA8888, COLFMT_BGRA4444 };89.42 /**89.43 @@ -63,20 +63,20 @@89.44 {89.45 int i;89.46 for( i=0; i < pvr2_scene.poly_count; i++ ) {89.47 - struct polygon_struct *poly = &pvr2_scene.poly_array[i];89.48 - if( POLY1_TEXTURED(poly->context[0]) ) {89.49 - poly->tex_id = texcache_get_texture( poly->context[2],89.50 - POLY2_TEX_WIDTH(poly->context[1]),89.51 - POLY2_TEX_HEIGHT(poly->context[1]) );89.52 - if( poly->mod_vertex_index != -1 ) {89.53 - poly->mod_tex_id = texcache_get_texture( poly->context[4],89.54 - POLY2_TEX_WIDTH(poly->context[3]),89.55 - POLY2_TEX_HEIGHT(poly->context[3]) );89.56 - }89.57 - } else {89.58 - poly->tex_id = -1;89.59 - poly->mod_tex_id = -1;89.60 - }89.61 + struct polygon_struct *poly = &pvr2_scene.poly_array[i];89.62 + if( POLY1_TEXTURED(poly->context[0]) ) {89.63 + poly->tex_id = texcache_get_texture( poly->context[2],89.64 + POLY2_TEX_WIDTH(poly->context[1]),89.65 + POLY2_TEX_HEIGHT(poly->context[1]) );89.66 + if( poly->mod_vertex_index != -1 ) {89.67 + poly->mod_tex_id = texcache_get_texture( poly->context[4],89.68 + POLY2_TEX_WIDTH(poly->context[3]),89.69 + POLY2_TEX_HEIGHT(poly->context[3]) );89.70 + }89.71 + } else {89.72 + poly->tex_id = -1;89.73 + poly->mod_tex_id = -1;89.74 + }89.75 }89.76 }89.78 @@ -89,11 +89,11 @@89.79 {89.81 if( glsl_is_supported() ) {89.82 - if( !glsl_load_shaders( glsl_vertex_shader_src, NULL ) ) {89.83 + if( !glsl_load_shaders( glsl_vertex_shader_src, NULL ) ) {89.84 WARN( "Unable to load GL shaders" );89.85 }89.86 }89.87 -89.88 +89.89 texcache_gl_init(); // Allocate texture IDs89.90 glCullFace( GL_BACK );89.91 glEnable( GL_BLEND );89.92 @@ -101,7 +101,7 @@89.93 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);89.94 glMatrixMode(GL_MODELVIEW);89.95 glLoadIdentity();89.96 -89.97 +89.98 #ifdef HAVE_OPENGL_CLAMP_COLOR89.99 if( isGLExtensionSupported("GL_ARB_color_buffer_float") ) {89.100 glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE );89.101 @@ -129,57 +129,57 @@89.102 {89.103 uint32_t poly1 = context[0], poly2, texture;89.104 if( render_mode == RENDER_FULLMOD ) {89.105 - poly2 = context[3];89.106 - texture = context[4];89.107 + poly2 = context[3];89.108 + texture = context[4];89.109 } else {89.110 - poly2 = context[1];89.111 - texture = context[2];89.112 + poly2 = context[1];89.113 + texture = context[2];89.114 }89.115 -89.116 +89.117 glDepthFunc( POLY1_DEPTH_MODE(poly1) );89.118 glDepthMask( POLY1_DEPTH_WRITE(poly1) ? GL_TRUE : GL_FALSE );89.119 -89.120 +89.121 switch( POLY1_CULL_MODE(poly1) ) {89.122 case CULL_NONE:89.123 case CULL_SMALL:89.124 - glDisable( GL_CULL_FACE );89.125 - break;89.126 + glDisable( GL_CULL_FACE );89.127 + break;89.128 case CULL_CCW:89.129 - glEnable( GL_CULL_FACE );89.130 - glFrontFace( GL_CW );89.131 - break;89.132 + glEnable( GL_CULL_FACE );89.133 + glFrontFace( GL_CW );89.134 + break;89.135 case CULL_CW:89.136 - glEnable( GL_CULL_FACE );89.137 - glFrontFace( GL_CCW );89.138 - break;89.139 + glEnable( GL_CULL_FACE );89.140 + glFrontFace( GL_CCW );89.141 + break;89.142 }89.144 if( POLY1_SPECULAR(poly1) ) {89.145 - glEnable(GL_COLOR_SUM);89.146 + glEnable(GL_COLOR_SUM);89.147 } else {89.148 - glDisable(GL_COLOR_SUM);89.149 + glDisable(GL_COLOR_SUM);89.150 }89.153 if( POLY1_TEXTURED(poly1) ) {89.154 - glEnable(GL_TEXTURE_2D);89.155 - glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, pvr2_poly_texblend[POLY2_TEX_BLEND(poly2)] );89.156 - if( POLY2_TEX_CLAMP_U(poly2) ) {89.157 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );89.158 - } else if( POLY2_TEX_MIRROR_U(poly2) ) {89.159 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT_ARB );89.160 - } else {89.161 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );89.162 - }89.163 - if( POLY2_TEX_CLAMP_V(poly2) ) {89.164 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );89.165 - } else if( POLY2_TEX_MIRROR_V(poly2) ) {89.166 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT_ARB );89.167 - } else {89.168 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );89.169 - }89.170 + glEnable(GL_TEXTURE_2D);89.171 + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, pvr2_poly_texblend[POLY2_TEX_BLEND(poly2)] );89.172 + if( POLY2_TEX_CLAMP_U(poly2) ) {89.173 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );89.174 + } else if( POLY2_TEX_MIRROR_U(poly2) ) {89.175 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT_ARB );89.176 + } else {89.177 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );89.178 + }89.179 + if( POLY2_TEX_CLAMP_V(poly2) ) {89.180 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );89.181 + } else if( POLY2_TEX_MIRROR_V(poly2) ) {89.182 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT_ARB );89.183 + } else {89.184 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );89.185 + }89.186 } else {89.187 - glDisable( GL_TEXTURE_2D );89.188 + glDisable( GL_TEXTURE_2D );89.189 }89.191 glShadeModel( POLY1_SHADE_MODEL(poly1) );89.192 @@ -189,7 +189,7 @@89.193 glBlendFunc( srcblend, destblend );89.195 if( POLY2_SRC_BLEND_TARGET(poly2) || POLY2_DEST_BLEND_TARGET(poly2) ) {89.196 - ERROR( "Accumulation buffer not supported" );89.197 + ERROR( "Accumulation buffer not supported" );89.198 }89.200 }89.201 @@ -198,7 +198,7 @@89.202 static void gl_render_poly( struct polygon_struct *poly )89.203 {89.204 if( poly->tex_id != -1 ) {89.205 - glBindTexture(GL_TEXTURE_2D, poly->tex_id);89.206 + glBindTexture(GL_TEXTURE_2D, poly->tex_id);89.207 }89.208 render_set_context( poly->context, RENDER_NORMAL );89.209 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );89.210 @@ -228,29 +228,29 @@89.211 struct polygon_struct *poly;89.213 while(1) {89.214 - uint32_t entry = *tile_list++;89.215 - switch( entry >> 28 ) {89.216 - case 0x0F:89.217 - return; // End-of-list89.218 - case 0x0E:89.219 - tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));89.220 - break;89.221 - case 0x08: case 0x09: case 0x0A: case 0x0B:89.222 - strip_count = ((entry >> 25) & 0x0F)+1;89.223 - poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];89.224 - while( strip_count > 0 ) {89.225 - assert( poly != NULL );89.226 - gl_render_poly( poly );89.227 - poly = poly->next;89.228 - strip_count--;89.229 - }89.230 - break;89.231 - default:89.232 - if( entry & 0x7E000000 ) {89.233 - poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];89.234 - gl_render_poly( poly );89.235 - }89.236 - }89.237 + uint32_t entry = *tile_list++;89.238 + switch( entry >> 28 ) {89.239 + case 0x0F:89.240 + return; // End-of-list89.241 + case 0x0E:89.242 + tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));89.243 + break;89.244 + case 0x08: case 0x09: case 0x0A: case 0x0B:89.245 + strip_count = ((entry >> 25) & 0x0F)+1;89.246 + poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];89.247 + while( strip_count > 0 ) {89.248 + assert( poly != NULL );89.249 + gl_render_poly( poly );89.250 + poly = poly->next;89.251 + strip_count--;89.252 + }89.253 + break;89.254 + default:89.255 + if( entry & 0x7E000000 ) {89.256 + poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];89.257 + gl_render_poly( poly );89.258 + }89.259 + }89.260 }89.261 }89.263 @@ -267,10 +267,10 @@89.264 display_driver->set_render_target(buffer);89.265 pvr2_check_palette_changed();89.266 pvr2_scene_load_textures();89.267 -89.268 +89.269 gettimeofday( &tex_tv, NULL );89.270 uint32_t ms = (tex_tv.tv_sec - start_tv.tv_sec) * 1000 +89.271 - (tex_tv.tv_usec - start_tv.tv_usec)/1000;89.272 + (tex_tv.tv_usec - start_tv.tv_usec)/1000;89.273 DEBUG( "Scene setup in %dms", ms );89.275 /* Setup view projection matrix */89.276 @@ -282,7 +282,7 @@89.277 farz*= 4.0;89.278 }89.279 glOrtho( 0, pvr2_scene.buffer_width, pvr2_scene.buffer_height, 0,89.280 - -farz, -nearz );89.281 + -farz, -nearz );89.282 float alphaRef = ((float)(MMIO_READ(PVR2, RENDER_ALPHA_REF)&0xFF)+1)/256.0;89.283 glAlphaFunc( GL_GEQUAL, alphaRef );89.285 @@ -302,39 +302,39 @@89.287 /* Render the background */89.288 gl_render_bkgnd( pvr2_scene.bkgnd_poly );89.289 -89.290 +89.291 glEnable( GL_SCISSOR_TEST );89.293 /* Process the segment list */89.294 struct tile_segment *segment = pvr2_scene.segment_list;89.295 do {89.296 - int tilex = SEGMENT_X(segment->control);89.297 - int tiley = SEGMENT_Y(segment->control);89.298 -89.299 - uint32_t tile_bounds[4] = { tilex << 5, (tilex+1)<<5, tiley<<5, (tiley+1)<<5 };89.300 - if( !clip_tile_bounds(tile_bounds, pvr2_scene.bounds) ) {89.301 - continue; // fully clipped, skip tile89.302 - }89.303 + int tilex = SEGMENT_X(segment->control);89.304 + int tiley = SEGMENT_Y(segment->control);89.306 - /* Clip to the visible part of the tile */89.307 - glScissor( tile_bounds[0], pvr2_scene.buffer_height-tile_bounds[3],89.308 - tile_bounds[1]-tile_bounds[0], tile_bounds[3] - tile_bounds[2] );89.309 - if( IS_TILE_PTR(segment->opaque_ptr) ) {89.310 - gl_render_tilelist(segment->opaque_ptr);89.311 - }89.312 - if( IS_TILE_PTR(segment->trans_ptr) ) {89.313 - if( pvr2_scene.sort_mode == SORT_NEVER ||89.314 - (pvr2_scene.sort_mode == SORT_TILEFLAG && (segment->control&SEGMENT_SORT_TRANS))) {89.315 - gl_render_tilelist(segment->trans_ptr);89.316 - } else {89.317 - render_autosort_tile(segment->trans_ptr, RENDER_NORMAL );89.318 - }89.319 - }89.320 - if( IS_TILE_PTR(segment->punchout_ptr) ) {89.321 - glEnable(GL_ALPHA_TEST );89.322 - render_autosort_tile(segment->punchout_ptr, RENDER_NORMAL );89.323 - glDisable(GL_ALPHA_TEST );89.324 - }89.325 + uint32_t tile_bounds[4] = { tilex << 5, (tilex+1)<<5, tiley<<5, (tiley+1)<<5 };89.326 + if( !clip_tile_bounds(tile_bounds, pvr2_scene.bounds) ) {89.327 + continue; // fully clipped, skip tile89.328 + }89.329 +89.330 + /* Clip to the visible part of the tile */89.331 + glScissor( tile_bounds[0], pvr2_scene.buffer_height-tile_bounds[3],89.332 + tile_bounds[1]-tile_bounds[0], tile_bounds[3] - tile_bounds[2] );89.333 + if( IS_TILE_PTR(segment->opaque_ptr) ) {89.334 + gl_render_tilelist(segment->opaque_ptr);89.335 + }89.336 + if( IS_TILE_PTR(segment->trans_ptr) ) {89.337 + if( pvr2_scene.sort_mode == SORT_NEVER ||89.338 + (pvr2_scene.sort_mode == SORT_TILEFLAG && (segment->control&SEGMENT_SORT_TRANS))) {89.339 + gl_render_tilelist(segment->trans_ptr);89.340 + } else {89.341 + render_autosort_tile(segment->trans_ptr, RENDER_NORMAL );89.342 + }89.343 + }89.344 + if( IS_TILE_PTR(segment->punchout_ptr) ) {89.345 + glEnable(GL_ALPHA_TEST );89.346 + render_autosort_tile(segment->punchout_ptr, RENDER_NORMAL );89.347 + glDisable(GL_ALPHA_TEST );89.348 + }89.349 } while( !IS_LAST_SEGMENT(segment++) );89.350 glDisable( GL_SCISSOR_TEST );89.352 @@ -342,6 +342,6 @@89.354 gettimeofday( &end_tv, NULL );89.355 ms = (end_tv.tv_sec - tex_tv.tv_sec) * 1000 +89.356 - (end_tv.tv_usec - tex_tv.tv_usec)/1000;89.357 + (end_tv.tv_usec - tex_tv.tv_usec)/1000;89.358 DEBUG( "Scene render in %dms", ms );89.359 }
90.1 --- a/src/pvr2/glutil.c Mon Jul 14 07:42:45 2008 +000090.2 +++ b/src/pvr2/glutil.c Mon Jul 14 07:44:42 2008 +000090.3 @@ -15,28 +15,29 @@90.4 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the90.5 * GNU General Public License for more details.90.6 */90.7 +90.8 #include <string.h>90.9 #include <glib/gstrfuncs.h>90.10 #include "pvr2/glutil.h"90.12 gboolean isGLSecondaryColorSupported()90.13 {90.14 - return isGLExtensionSupported("GL_EXT_secondary_color");90.15 + return isGLExtensionSupported("GL_EXT_secondary_color");90.16 }90.18 gboolean isGLVertexBufferSupported()90.19 {90.20 - return isGLExtensionSupported("GL_ARB_vertex_buffer_object");90.21 + return isGLExtensionSupported("GL_ARB_vertex_buffer_object");90.22 }90.24 gboolean isGLPixelBufferSupported()90.25 {90.26 - return isGLExtensionSupported("GL_ARB_pixel_buffer_object");90.27 + return isGLExtensionSupported("GL_ARB_pixel_buffer_object");90.28 }90.30 gboolean isGLMirroredTextureSupported()90.31 {90.32 - return isGLExtensionSupported("GL_ARB_texture_mirrored_repeat");90.33 + return isGLExtensionSupported("GL_ARB_texture_mirrored_repeat");90.34 }90.36 /**90.37 @@ -53,26 +54,26 @@90.38 /* Extension names should not have spaces. */90.39 where = (GLubyte *) strchr(extension, ' ');90.40 if (where || *extension == '\0')90.41 - return 0;90.42 + return 0;90.43 extensions = glGetString(GL_EXTENSIONS);90.44 if( extensions == NULL ) {90.45 - /* No GL available, so we're pretty sure the extension isn't90.46 - * available either. */90.47 - return FALSE;90.48 + /* No GL available, so we're pretty sure the extension isn't90.49 + * available either. */90.50 + return FALSE;90.51 }90.52 /* It takes a bit of care to be fool-proof about parsing the90.53 OpenGL extensions string. Don't be fooled by sub-strings,90.54 etc. */90.55 start = extensions;90.56 for (;;) {90.57 - where = (GLubyte *) strstr((const char *) start, extension);90.58 - if (!where)90.59 - break;90.60 - terminator = where + strlen(extension);90.61 - if (where == start || *(where - 1) == ' ')90.62 - if (*terminator == ' ' || *terminator == '\0')90.63 - return TRUE;90.64 - start = terminator;90.65 + where = (GLubyte *) strstr((const char *) start, extension);90.66 + if (!where)90.67 + break;90.68 + terminator = where + strlen(extension);90.69 + if (where == start || *(where - 1) == ' ')90.70 + if (*terminator == ' ' || *terminator == '\0')90.71 + return TRUE;90.72 + start = terminator;90.73 }90.74 return FALSE;90.75 }90.76 @@ -82,11 +83,11 @@90.77 const gchar *extensions = (const gchar *)glGetString(GL_EXTENSIONS);90.78 gchar **ext_split = g_strsplit(extensions, " ", 0);90.79 unsigned int i;90.80 -90.81 +90.82 fprintf( out, "GL Vendor: %s\n", glGetString(GL_VENDOR) );90.83 fprintf( out, "GL Renderer: %s\n", glGetString(GL_RENDERER) );90.84 fprintf( out, "GL Version: %s\n", glGetString(GL_VERSION) );90.85 -90.86 +90.87 fprintf( out, "Supported GL Extensions:\n" );90.88 for( i=0; ext_split[i] != NULL; i++ ) {90.89 fprintf( out, " %s\n", ext_split[i] );
91.1 --- a/src/pvr2/glutil.h Mon Jul 14 07:42:45 2008 +000091.2 +++ b/src/pvr2/glutil.h Mon Jul 14 07:44:42 2008 +000091.3 @@ -22,6 +22,10 @@91.4 #include <stdio.h>91.5 #include "display.h"91.7 +#ifdef __cplusplus91.8 +extern "C" {91.9 +#endif91.10 +91.11 /**91.12 * Test if a specific extension is supported. From opengl.org91.13 * @param extension extension name to check for91.14 @@ -52,4 +56,8 @@91.15 extern const char *glsl_vertex_shader_src;91.16 extern const char *glsl_fragment_shader_src;91.18 +#ifdef __cplusplus91.19 +}91.20 +#endif91.21 +91.22 #endif /* !lxdream_glutil_H */
92.1 --- a/src/pvr2/pvr2.c Mon Jul 14 07:42:45 2008 +000092.2 +++ b/src/pvr2/pvr2.c Mon Jul 14 07:44:42 2008 +000092.3 @@ -55,8 +55,8 @@92.4 static int output_colour_formats[] = { COLFMT_BGRA1555, COLFMT_RGB565, COLFMT_BGR888, COLFMT_BGRA8888 };92.6 struct dreamcast_module pvr2_module = { "PVR2", pvr2_init, pvr2_reset, NULL,92.7 - pvr2_run_slice, NULL,92.8 - pvr2_save_state, pvr2_load_state };92.9 + pvr2_run_slice, NULL,92.10 + pvr2_save_state, pvr2_load_state };92.13 display_driver_t display_driver = NULL;92.14 @@ -102,13 +102,13 @@92.15 asic_event( eventid );92.16 pvr2_update_raster_posn(sh4r.slice_cycle);92.17 if( pvr2_state.irq_hpos_mode == HPOS_PER_LINECOUNT ) {92.18 - pvr2_state.irq_hpos_line += pvr2_state.irq_hpos_line_count;92.19 - while( pvr2_state.irq_hpos_line > (pvr2_state.total_lines>>1) ) {92.20 - pvr2_state.irq_hpos_line -= (pvr2_state.total_lines>>1);92.21 - }92.22 + pvr2_state.irq_hpos_line += pvr2_state.irq_hpos_line_count;92.23 + while( pvr2_state.irq_hpos_line > (pvr2_state.total_lines>>1) ) {92.24 + pvr2_state.irq_hpos_line -= (pvr2_state.total_lines>>1);92.25 + }92.26 }92.27 pvr2_schedule_scanline_event( eventid, pvr2_state.irq_hpos_line, 1,92.28 - pvr2_state.irq_hpos_time_ns );92.29 + pvr2_state.irq_hpos_time_ns );92.30 }92.32 /**92.33 @@ -119,9 +119,9 @@92.34 asic_event( eventid );92.35 pvr2_update_raster_posn(sh4r.slice_cycle);92.36 if( eventid == EVENT_SCANLINE1 ) {92.37 - pvr2_schedule_scanline_event( eventid, pvr2_state.irq_vpos1, 1, 0 );92.38 + pvr2_schedule_scanline_event( eventid, pvr2_state.irq_vpos1, 1, 0 );92.39 } else {92.40 - pvr2_schedule_scanline_event( eventid, pvr2_state.irq_vpos2, 1, 0 );92.41 + pvr2_schedule_scanline_event( eventid, pvr2_state.irq_vpos2, 1, 0 );92.42 }92.43 }92.45 @@ -140,7 +140,7 @@92.46 pvr2_ta_reset();92.47 save_next_render_filename = NULL;92.48 for( i=0; i<MAX_RENDER_BUFFERS; i++ ) {92.49 - render_buffers[i] = NULL;92.50 + render_buffers[i] = NULL;92.51 }92.52 render_buffer_count = 0;92.53 displayed_render_buffer = NULL;92.54 @@ -162,16 +162,16 @@92.55 mmio_region_PVR2_write( DISP_SYNCTIME, 0x07D6A53F );92.56 mmio_region_PVR2_write( YUV_ADDR, 0 );92.57 mmio_region_PVR2_write( YUV_CFG, 0 );92.58 -92.59 +92.60 pvr2_ta_init();92.61 texcache_flush();92.62 if( display_driver ) {92.63 - display_driver->display_blank(0);92.64 - for( i=0; i<render_buffer_count; i++ ) {92.65 - display_driver->destroy_render_buffer(render_buffers[i]);92.66 - render_buffers[i] = NULL;92.67 - }92.68 - render_buffer_count = 0;92.69 + display_driver->display_blank(0);92.70 + for( i=0; i<render_buffer_count; i++ ) {92.71 + display_driver->destroy_render_buffer(render_buffers[i]);92.72 + render_buffers[i] = NULL;92.73 + }92.74 + render_buffer_count = 0;92.75 }92.76 }92.78 @@ -185,7 +185,7 @@92.79 fbuf.colour_format = COLFMT_BGR888;92.80 fbuf.inverted = buffer->inverted;92.81 fbuf.data = g_malloc0( buffer->width * buffer->height * 3 );92.82 -92.83 +92.84 display_driver->read_render_buffer( fbuf.data, buffer, fbuf.rowstride, COLFMT_BGR888 );92.85 write_png_to_stream( f, &fbuf );92.86 g_free( fbuf.data );92.87 @@ -196,29 +196,29 @@92.88 fwrite( &buffer->scale, sizeof(buffer->scale), 1, f );92.89 int32_t flushed = (int32_t)buffer->flushed; // Force to 32-bits for save-file consistency92.90 fwrite( &flushed, sizeof(flushed), 1, f );92.91 -92.92 +92.93 }92.95 render_buffer_t pvr2_load_render_buffer( FILE *f )92.96 {92.97 frame_buffer_t frame = read_png_from_stream( f );92.98 if( frame == NULL ) {92.99 - return NULL;92.100 + return NULL;92.101 }92.103 render_buffer_t buffer = pvr2_frame_buffer_to_render_buffer(frame);92.104 if( buffer != NULL ) {92.105 int32_t flushed;92.106 - fread( &buffer->rowstride, sizeof(buffer->rowstride), 1, f );92.107 - fread( &buffer->colour_format, sizeof(buffer->colour_format), 1, f );92.108 - fread( &buffer->address, sizeof(buffer->address), 1, f );92.109 - fread( &buffer->scale, sizeof(buffer->scale), 1, f );92.110 - fread( &flushed, sizeof(flushed), 1, f );92.111 - buffer->flushed = (gboolean)flushed;92.112 + fread( &buffer->rowstride, sizeof(buffer->rowstride), 1, f );92.113 + fread( &buffer->colour_format, sizeof(buffer->colour_format), 1, f );92.114 + fread( &buffer->address, sizeof(buffer->address), 1, f );92.115 + fread( &buffer->scale, sizeof(buffer->scale), 1, f );92.116 + fread( &flushed, sizeof(flushed), 1, f );92.117 + buffer->flushed = (gboolean)flushed;92.118 } else {92.119 - fseek( f, sizeof(buffer->rowstride)+sizeof(buffer->colour_format)+92.120 - sizeof(buffer->address)+sizeof(buffer->scale)+92.121 - sizeof(int32_t), SEEK_CUR );92.122 + fseek( f, sizeof(buffer->rowstride)+sizeof(buffer->colour_format)+92.123 + sizeof(buffer->address)+sizeof(buffer->scale)+92.124 + sizeof(int32_t), SEEK_CUR );92.125 }92.126 return buffer;92.127 }92.128 @@ -232,18 +232,18 @@92.129 uint32_t has_frontbuffer;92.130 fwrite( &render_buffer_count, sizeof(render_buffer_count), 1, f );92.131 if( displayed_render_buffer != NULL ) {92.132 - has_frontbuffer = 1;92.133 - fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );92.134 - pvr2_save_render_buffer( f, displayed_render_buffer );92.135 + has_frontbuffer = 1;92.136 + fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );92.137 + pvr2_save_render_buffer( f, displayed_render_buffer );92.138 } else {92.139 - has_frontbuffer = 0;92.140 - fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );92.141 + has_frontbuffer = 0;92.142 + fwrite( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );92.143 }92.145 for( i=0; i<render_buffer_count; i++ ) {92.146 - if( render_buffers[i] != displayed_render_buffer && render_buffers[i] != NULL ) {92.147 - pvr2_save_render_buffer( f, render_buffers[i] );92.148 - }92.149 + if( render_buffers[i] != displayed_render_buffer && render_buffers[i] != NULL ) {92.150 + pvr2_save_render_buffer( f, render_buffers[i] );92.151 + }92.152 }92.153 }92.155 @@ -254,27 +254,27 @@92.157 fread( &count, sizeof(count), 1, f );92.158 if( count > MAX_RENDER_BUFFERS ) {92.159 - return FALSE;92.160 + return FALSE;92.161 }92.162 fread( &has_frontbuffer, sizeof(has_frontbuffer), 1, f );92.163 for( i=0; i<render_buffer_count; i++ ) {92.164 - display_driver->destroy_render_buffer(render_buffers[i]);92.165 - render_buffers[i] = NULL;92.166 + display_driver->destroy_render_buffer(render_buffers[i]);92.167 + render_buffers[i] = NULL;92.168 }92.169 render_buffer_count = 0;92.171 if( has_frontbuffer ) {92.172 - displayed_render_buffer = pvr2_load_render_buffer(f);92.173 - display_driver->display_render_buffer( displayed_render_buffer );92.174 - count--;92.175 + displayed_render_buffer = pvr2_load_render_buffer(f);92.176 + display_driver->display_render_buffer( displayed_render_buffer );92.177 + count--;92.178 }92.180 for( i=0; i<count; i++ ) {92.181 - pvr2_load_render_buffer( f );92.182 + pvr2_load_render_buffer( f );92.183 }92.184 return TRUE;92.185 }92.186 -92.187 +92.189 static void pvr2_save_state( FILE *f )92.190 {92.191 @@ -287,11 +287,11 @@92.192 static int pvr2_load_state( FILE *f )92.193 {92.194 if( !pvr2_load_render_buffers(f) )92.195 - return 1;92.196 + return 1;92.197 if( fread( &pvr2_state, sizeof(pvr2_state), 1, f ) != 1 )92.198 - return 1;92.199 + return 1;92.200 if( pvr2_ta_load_state(f) ) {92.201 - return 1;92.202 + return 1;92.203 }92.204 return pvr2_yuv_load_state(f);92.205 }92.206 @@ -305,26 +305,26 @@92.207 {92.208 uint32_t old_line_count = pvr2_state.line_count;92.209 if( pvr2_state.line_time_ns == 0 ) {92.210 - return; /* do nothing */92.211 + return; /* do nothing */92.212 }92.213 pvr2_state.line_remainder += (nanosecs - pvr2_state.cycles_run);92.214 pvr2_state.cycles_run = nanosecs;92.215 while( pvr2_state.line_remainder >= pvr2_state.line_time_ns ) {92.216 - pvr2_state.line_count ++;92.217 - pvr2_state.line_remainder -= pvr2_state.line_time_ns;92.218 + pvr2_state.line_count ++;92.219 + pvr2_state.line_remainder -= pvr2_state.line_time_ns;92.220 }92.222 if( pvr2_state.line_count >= pvr2_state.total_lines ) {92.223 - pvr2_state.line_count -= pvr2_state.total_lines;92.224 - if( pvr2_state.interlaced ) {92.225 - pvr2_state.odd_even_field = !pvr2_state.odd_even_field;92.226 - }92.227 + pvr2_state.line_count -= pvr2_state.total_lines;92.228 + if( pvr2_state.interlaced ) {92.229 + pvr2_state.odd_even_field = !pvr2_state.odd_even_field;92.230 + }92.231 }92.232 if( pvr2_state.line_count >= pvr2_state.retrace_end_line &&92.233 - (old_line_count < pvr2_state.retrace_end_line ||92.234 - old_line_count > pvr2_state.line_count) ) {92.235 - pvr2_state.frame_count++;92.236 - pvr2_display_frame();92.237 + (old_line_count < pvr2_state.retrace_end_line ||92.238 + old_line_count > pvr2_state.line_count) ) {92.239 + pvr2_state.frame_count++;92.240 + pvr2_display_frame();92.241 }92.242 }92.244 @@ -354,7 +354,7 @@92.245 gboolean pvr2_save_next_scene( const gchar *filename )92.246 {92.247 if( save_next_render_filename != NULL ) {92.248 - g_free( save_next_render_filename );92.249 + g_free( save_next_render_filename );92.250 }92.251 save_next_render_filename = g_strdup(filename);92.252 return TRUE;92.253 @@ -374,66 +374,66 @@92.254 gboolean bEnabled = (dispmode & DISPMODE_ENABLE) && (vidcfg & DISPCFG_VO ) ? TRUE : FALSE;92.256 if( display_driver == NULL ) {92.257 - return; /* can't really do anything much */92.258 + return; /* can't really do anything much */92.259 } else if( !bEnabled ) {92.260 - /* Output disabled == black */92.261 - displayed_render_buffer = NULL;92.262 - displayed_border_colour = 0;92.263 - display_driver->display_blank( 0 );92.264 + /* Output disabled == black */92.265 + displayed_render_buffer = NULL;92.266 + displayed_border_colour = 0;92.267 + display_driver->display_blank( 0 );92.268 } else if( MMIO_READ( PVR2, DISP_CFG2 ) & 0x08 ) {92.269 - /* Enabled but blanked - border colour */92.270 - displayed_border_colour = MMIO_READ( PVR2, DISP_BORDER );92.271 - displayed_render_buffer = NULL;92.272 - display_driver->display_blank( displayed_border_colour );92.273 + /* Enabled but blanked - border colour */92.274 + displayed_border_colour = MMIO_READ( PVR2, DISP_BORDER );92.275 + displayed_render_buffer = NULL;92.276 + display_driver->display_blank( displayed_border_colour );92.277 } else {92.278 - /* Real output - determine dimensions etc */92.279 - struct frame_buffer fbuf;92.280 - uint32_t dispsize = MMIO_READ( PVR2, DISP_SIZE );92.281 - int vid_stride = (((dispsize & DISPSIZE_MODULO) >> 20) - 1);92.282 - int vid_ppl = ((dispsize & DISPSIZE_PPL)) + 1;92.283 + /* Real output - determine dimensions etc */92.284 + struct frame_buffer fbuf;92.285 + uint32_t dispsize = MMIO_READ( PVR2, DISP_SIZE );92.286 + int vid_stride = (((dispsize & DISPSIZE_MODULO) >> 20) - 1);92.287 + int vid_ppl = ((dispsize & DISPSIZE_PPL)) + 1;92.289 - fbuf.colour_format = output_colour_formats[(dispmode & DISPMODE_COLFMT) >> 2];92.290 - fbuf.width = vid_ppl << 2 / colour_formats[fbuf.colour_format].bpp;92.291 - fbuf.height = ((dispsize & DISPSIZE_LPF) >> 10) + 1;92.292 - fbuf.size = vid_ppl << 2 * fbuf.height;92.293 - fbuf.rowstride = (vid_ppl + vid_stride) << 2;92.294 + fbuf.colour_format = output_colour_formats[(dispmode & DISPMODE_COLFMT) >> 2];92.295 + fbuf.width = vid_ppl << 2 / colour_formats[fbuf.colour_format].bpp;92.296 + fbuf.height = ((dispsize & DISPSIZE_LPF) >> 10) + 1;92.297 + fbuf.size = vid_ppl << 2 * fbuf.height;92.298 + fbuf.rowstride = (vid_ppl + vid_stride) << 2;92.300 - /* Determine the field to display, and deinterlace if possible */92.301 - if( pvr2_state.interlaced ) {92.302 - if( vid_ppl == vid_stride ) { /* Magic deinterlace */92.303 - fbuf.height = fbuf.height << 1;92.304 - fbuf.rowstride = vid_ppl << 2;92.305 - fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );92.306 - } else {92.307 - /* Just display the field as is, folks. This is slightly tricky -92.308 - * we pick the field based on which frame is about to come through,92.309 - * which may not be the same as the odd_even_field.92.310 - */92.311 - gboolean oddfield = pvr2_state.odd_even_field;92.312 - if( pvr2_state.line_count >= pvr2_state.retrace_start_line ) {92.313 - oddfield = !oddfield;92.314 - }92.315 - if( oddfield ) {92.316 - fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );92.317 - } else {92.318 - fbuf.address = MMIO_READ( PVR2, DISP_ADDR2 );92.319 - }92.320 - }92.321 - } else {92.322 - fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );92.323 - }92.324 - fbuf.address = (fbuf.address & 0x00FFFFFF) + PVR2_RAM_BASE;92.325 - fbuf.inverted = FALSE;92.326 - fbuf.data = video_base + (fbuf.address&0x00FFFFFF);92.327 + /* Determine the field to display, and deinterlace if possible */92.328 + if( pvr2_state.interlaced ) {92.329 + if( vid_ppl == vid_stride ) { /* Magic deinterlace */92.330 + fbuf.height = fbuf.height << 1;92.331 + fbuf.rowstride = vid_ppl << 2;92.332 + fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );92.333 + } else {92.334 + /* Just display the field as is, folks. This is slightly tricky -92.335 + * we pick the field based on which frame is about to come through,92.336 + * which may not be the same as the odd_even_field.92.337 + */92.338 + gboolean oddfield = pvr2_state.odd_even_field;92.339 + if( pvr2_state.line_count >= pvr2_state.retrace_start_line ) {92.340 + oddfield = !oddfield;92.341 + }92.342 + if( oddfield ) {92.343 + fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );92.344 + } else {92.345 + fbuf.address = MMIO_READ( PVR2, DISP_ADDR2 );92.346 + }92.347 + }92.348 + } else {92.349 + fbuf.address = MMIO_READ( PVR2, DISP_ADDR1 );92.350 + }92.351 + fbuf.address = (fbuf.address & 0x00FFFFFF) + PVR2_RAM_BASE;92.352 + fbuf.inverted = FALSE;92.353 + fbuf.data = video_base + (fbuf.address&0x00FFFFFF);92.355 - render_buffer_t rbuf = pvr2_get_render_buffer( &fbuf );92.356 - if( rbuf == NULL ) {92.357 - rbuf = pvr2_frame_buffer_to_render_buffer( &fbuf );92.358 - }92.359 - displayed_render_buffer = rbuf;92.360 - if( rbuf != NULL ) {92.361 - display_driver->display_render_buffer( rbuf );92.362 - }92.363 + render_buffer_t rbuf = pvr2_get_render_buffer( &fbuf );92.364 + if( rbuf == NULL ) {92.365 + rbuf = pvr2_frame_buffer_to_render_buffer( &fbuf );92.366 + }92.367 + displayed_render_buffer = rbuf;92.368 + if( rbuf != NULL ) {92.369 + display_driver->display_render_buffer( rbuf );92.370 + }92.371 }92.372 }92.374 @@ -447,256 +447,256 @@92.375 MMIO_WRITE( PVR2, reg, val );92.376 return;92.377 }92.378 -92.379 +92.380 switch(reg) {92.381 case PVRID:92.382 case PVRVER:92.383 case GUNPOS: /* Read only registers */92.384 - break;92.385 + break;92.386 case PVRRESET:92.387 - val &= 0x00000007; /* Do stuff? */92.388 - MMIO_WRITE( PVR2, reg, val );92.389 - break;92.390 + val &= 0x00000007; /* Do stuff? */92.391 + MMIO_WRITE( PVR2, reg, val );92.392 + break;92.393 case RENDER_START: /* Don't really care what value */92.394 - if( save_next_render_filename != NULL ) {92.395 - if( pvr2_render_save_scene(save_next_render_filename) == 0 ) {92.396 - INFO( "Saved scene to %s", save_next_render_filename);92.397 - }92.398 - g_free( save_next_render_filename );92.399 - save_next_render_filename = NULL;92.400 - }92.401 - pvr2_scene_read();92.402 - render_buffer_t buffer = pvr2_next_render_buffer();92.403 - if( buffer != NULL ) {92.404 - pvr2_scene_render( buffer );92.405 - }92.406 - asic_event( EVENT_PVR_RENDER_DONE );92.407 - break;92.408 + if( save_next_render_filename != NULL ) {92.409 + if( pvr2_render_save_scene(save_next_render_filename) == 0 ) {92.410 + INFO( "Saved scene to %s", save_next_render_filename);92.411 + }92.412 + g_free( save_next_render_filename );92.413 + save_next_render_filename = NULL;92.414 + }92.415 + pvr2_scene_read();92.416 + render_buffer_t buffer = pvr2_next_render_buffer();92.417 + if( buffer != NULL ) {92.418 + pvr2_scene_render( buffer );92.419 + }92.420 + asic_event( EVENT_PVR_RENDER_DONE );92.421 + break;92.422 case RENDER_POLYBASE:92.423 - MMIO_WRITE( PVR2, reg, val&0x00F00000 );92.424 - break;92.425 + MMIO_WRITE( PVR2, reg, val&0x00F00000 );92.426 + break;92.427 case RENDER_TSPCFG:92.428 - MMIO_WRITE( PVR2, reg, val&0x00010101 );92.429 - break;92.430 + MMIO_WRITE( PVR2, reg, val&0x00010101 );92.431 + break;92.432 case DISP_BORDER:92.433 - MMIO_WRITE( PVR2, reg, val&0x01FFFFFF );92.434 - break;92.435 + MMIO_WRITE( PVR2, reg, val&0x01FFFFFF );92.436 + break;92.437 case DISP_MODE:92.438 - MMIO_WRITE( PVR2, reg, val&0x00FFFF7F );92.439 - break;92.440 + MMIO_WRITE( PVR2, reg, val&0x00FFFF7F );92.441 + break;92.442 case RENDER_MODE:92.443 - MMIO_WRITE( PVR2, reg, val&0x00FFFF0F );92.444 - break;92.445 + MMIO_WRITE( PVR2, reg, val&0x00FFFF0F );92.446 + break;92.447 case RENDER_SIZE:92.448 - MMIO_WRITE( PVR2, reg, val&0x000001FF );92.449 - break;92.450 + MMIO_WRITE( PVR2, reg, val&0x000001FF );92.451 + break;92.452 case DISP_ADDR1:92.453 - val &= 0x00FFFFFC;92.454 - MMIO_WRITE( PVR2, reg, val );92.455 - pvr2_update_raster_posn(sh4r.slice_cycle);92.456 - break;92.457 + val &= 0x00FFFFFC;92.458 + MMIO_WRITE( PVR2, reg, val );92.459 + pvr2_update_raster_posn(sh4r.slice_cycle);92.460 + break;92.461 case DISP_ADDR2:92.462 - MMIO_WRITE( PVR2, reg, val&0x00FFFFFC );92.463 - pvr2_update_raster_posn(sh4r.slice_cycle);92.464 - break;92.465 + MMIO_WRITE( PVR2, reg, val&0x00FFFFFC );92.466 + pvr2_update_raster_posn(sh4r.slice_cycle);92.467 + break;92.468 case DISP_SIZE:92.469 - MMIO_WRITE( PVR2, reg, val&0x3FFFFFFF );92.470 - break;92.471 + MMIO_WRITE( PVR2, reg, val&0x3FFFFFFF );92.472 + break;92.473 case RENDER_ADDR1:92.474 case RENDER_ADDR2:92.475 - MMIO_WRITE( PVR2, reg, val&0x01FFFFFC );92.476 - break;92.477 + MMIO_WRITE( PVR2, reg, val&0x01FFFFFC );92.478 + break;92.479 case RENDER_HCLIP:92.480 - MMIO_WRITE( PVR2, reg, val&0x07FF07FF );92.481 - break;92.482 + MMIO_WRITE( PVR2, reg, val&0x07FF07FF );92.483 + break;92.484 case RENDER_VCLIP:92.485 - MMIO_WRITE( PVR2, reg, val&0x03FF03FF );92.486 - break;92.487 + MMIO_WRITE( PVR2, reg, val&0x03FF03FF );92.488 + break;92.489 case DISP_HPOSIRQ:92.490 - MMIO_WRITE( PVR2, reg, val&0x03FF33FF );92.491 - pvr2_state.irq_hpos_line = val & 0x03FF;92.492 - pvr2_state.irq_hpos_time_ns = 2000000*((val>>16)&0x03FF)/pvr2_state.dot_clock;92.493 - pvr2_state.irq_hpos_mode = (val >> 12) & 0x03;92.494 - switch( pvr2_state.irq_hpos_mode ) {92.495 - case 3: /* Reserved - treat as 0 */92.496 - case 0: /* Once per frame at specified line */92.497 - pvr2_state.irq_hpos_mode = HPOS_PER_FRAME;92.498 - break;92.499 - case 2: /* Once per line - as per-line-count */92.500 - pvr2_state.irq_hpos_line = 1;92.501 - pvr2_state.irq_hpos_mode = 1;92.502 - case 1: /* Once per N lines */92.503 - pvr2_state.irq_hpos_line_count = pvr2_state.irq_hpos_line;92.504 - pvr2_state.irq_hpos_line = (pvr2_state.line_count >> 1) +92.505 - pvr2_state.irq_hpos_line_count;92.506 - while( pvr2_state.irq_hpos_line > (pvr2_state.total_lines>>1) ) {92.507 - pvr2_state.irq_hpos_line -= (pvr2_state.total_lines>>1);92.508 - }92.509 - pvr2_state.irq_hpos_mode = HPOS_PER_LINECOUNT;92.510 - }92.511 - pvr2_schedule_scanline_event( EVENT_HPOS, pvr2_state.irq_hpos_line, 0,92.512 - pvr2_state.irq_hpos_time_ns );92.513 - break;92.514 - case DISP_VPOSIRQ:92.515 - val = val & 0x03FF03FF;92.516 - pvr2_state.irq_vpos1 = (val >> 16);92.517 - pvr2_state.irq_vpos2 = val & 0x03FF;92.518 - pvr2_update_raster_posn(sh4r.slice_cycle);92.519 - pvr2_schedule_scanline_event( EVENT_SCANLINE1, pvr2_state.irq_vpos1, 0, 0 );92.520 - pvr2_schedule_scanline_event( EVENT_SCANLINE2, pvr2_state.irq_vpos2, 0, 0 );92.521 - MMIO_WRITE( PVR2, reg, val );92.522 - break;92.523 - case RENDER_NEARCLIP:92.524 - MMIO_WRITE( PVR2, reg, val & 0x7FFFFFFF );92.525 - break;92.526 - case RENDER_SHADOW:92.527 - MMIO_WRITE( PVR2, reg, val&0x000001FF );92.528 - break;92.529 - case RENDER_OBJCFG:92.530 - MMIO_WRITE( PVR2, reg, val&0x003FFFFF );92.531 - break;92.532 - case RENDER_TSPCLIP:92.533 - MMIO_WRITE( PVR2, reg, val&0x7FFFFFFF );92.534 - break;92.535 - case RENDER_FARCLIP:92.536 - MMIO_WRITE( PVR2, reg, val&0xFFFFFFF0 );92.537 - break;92.538 - case RENDER_BGPLANE:92.539 - MMIO_WRITE( PVR2, reg, val&0x1FFFFFFF );92.540 - break;92.541 - case RENDER_ISPCFG:92.542 - MMIO_WRITE( PVR2, reg, val&0x00FFFFF9 );92.543 - break;92.544 - case VRAM_CFG1:92.545 - MMIO_WRITE( PVR2, reg, val&0x000000FF );92.546 - break;92.547 - case VRAM_CFG2:92.548 - MMIO_WRITE( PVR2, reg, val&0x003FFFFF );92.549 - break;92.550 - case VRAM_CFG3:92.551 - MMIO_WRITE( PVR2, reg, val&0x1FFFFFFF );92.552 - break;92.553 - case RENDER_FOGTBLCOL:92.554 - case RENDER_FOGVRTCOL:92.555 - MMIO_WRITE( PVR2, reg, val&0x00FFFFFF );92.556 - break;92.557 - case RENDER_FOGCOEFF:92.558 - MMIO_WRITE( PVR2, reg, val&0x0000FFFF );92.559 - break;92.560 - case RENDER_CLAMPHI:92.561 - case RENDER_CLAMPLO:92.562 - MMIO_WRITE( PVR2, reg, val );92.563 - break;92.564 - case RENDER_TEXSIZE:92.565 - MMIO_WRITE( PVR2, reg, val&0x00031F1F );92.566 - break;92.567 - case RENDER_PALETTE:92.568 - MMIO_WRITE( PVR2, reg, val&0x00000003 );92.569 - break;92.570 - case RENDER_ALPHA_REF:92.571 - MMIO_WRITE( PVR2, reg, val&0x000000FF );92.572 - break;92.573 - /********** CRTC registers *************/92.574 - case DISP_HBORDER:92.575 - case DISP_VBORDER:92.576 - MMIO_WRITE( PVR2, reg, val&0x03FF03FF );92.577 - break;92.578 - case DISP_TOTAL:92.579 - val = val & 0x03FF03FF;92.580 - MMIO_WRITE( PVR2, reg, val );92.581 - pvr2_update_raster_posn(sh4r.slice_cycle);92.582 - pvr2_state.total_lines = (val >> 16) + 1;92.583 - pvr2_state.line_size = (val & 0x03FF) + 1;92.584 - pvr2_state.line_time_ns = 1000000 * pvr2_state.line_size / pvr2_state.dot_clock;92.585 - pvr2_state.retrace_end_line = 0x2A;92.586 - pvr2_state.retrace_start_line = pvr2_state.total_lines - 6;92.587 - pvr2_schedule_scanline_event( EVENT_SCANLINE1, pvr2_state.irq_vpos1, 0, 0 );92.588 - pvr2_schedule_scanline_event( EVENT_SCANLINE2, pvr2_state.irq_vpos2, 0, 0 );92.589 - pvr2_schedule_scanline_event( EVENT_HPOS, pvr2_state.irq_hpos_line, 0,92.590 - pvr2_state.irq_hpos_time_ns );92.591 - break;92.592 - case DISP_SYNCCFG:92.593 - MMIO_WRITE( PVR2, reg, val&0x000003FF );92.594 - pvr2_state.interlaced = (val & 0x0010) ? TRUE : FALSE;92.595 - break;92.596 - case DISP_SYNCTIME:92.597 - pvr2_state.vsync_lines = (val >> 8) & 0x0F;92.598 - pvr2_state.hsync_width_ns = ((val & 0x7F) + 1) * 2000000 / pvr2_state.dot_clock;92.599 - MMIO_WRITE( PVR2, reg, val&0xFFFFFF7F );92.600 - break;92.601 - case DISP_CFG2:92.602 - MMIO_WRITE( PVR2, reg, val&0x003F01FF );92.603 - break;92.604 - case DISP_HPOS:92.605 - val = val & 0x03FF;92.606 - pvr2_state.front_porch_ns = (val + 1) * 1000000 / pvr2_state.dot_clock;92.607 - MMIO_WRITE( PVR2, reg, val );92.608 - break;92.609 - case DISP_VPOS:92.610 - MMIO_WRITE( PVR2, reg, val&0x03FF03FF );92.611 - break;92.612 + MMIO_WRITE( PVR2, reg, val&0x03FF33FF );92.613 + pvr2_state.irq_hpos_line = val & 0x03FF;92.614 + pvr2_state.irq_hpos_time_ns = 2000000*((val>>16)&0x03FF)/pvr2_state.dot_clock;92.615 + pvr2_state.irq_hpos_mode = (val >> 12) & 0x03;92.616 + switch( pvr2_state.irq_hpos_mode ) {92.617 + case 3: /* Reserved - treat as 0 */92.618 + case 0: /* Once per frame at specified line */92.619 + pvr2_state.irq_hpos_mode = HPOS_PER_FRAME;92.620 + break;92.621 + case 2: /* Once per line - as per-line-count */92.622 + pvr2_state.irq_hpos_line = 1;92.623 + pvr2_state.irq_hpos_mode = 1;92.624 + case 1: /* Once per N lines */92.625 + pvr2_state.irq_hpos_line_count = pvr2_state.irq_hpos_line;92.626 + pvr2_state.irq_hpos_line = (pvr2_state.line_count >> 1) +92.627 + pvr2_state.irq_hpos_line_count;92.628 + while( pvr2_state.irq_hpos_line > (pvr2_state.total_lines>>1) ) {92.629 + pvr2_state.irq_hpos_line -= (pvr2_state.total_lines>>1);92.630 + }92.631 + pvr2_state.irq_hpos_mode = HPOS_PER_LINECOUNT;92.632 + }92.633 + pvr2_schedule_scanline_event( EVENT_HPOS, pvr2_state.irq_hpos_line, 0,92.634 + pvr2_state.irq_hpos_time_ns );92.635 + break;92.636 + case DISP_VPOSIRQ:92.637 + val = val & 0x03FF03FF;92.638 + pvr2_state.irq_vpos1 = (val >> 16);92.639 + pvr2_state.irq_vpos2 = val & 0x03FF;92.640 + pvr2_update_raster_posn(sh4r.slice_cycle);92.641 + pvr2_schedule_scanline_event( EVENT_SCANLINE1, pvr2_state.irq_vpos1, 0, 0 );92.642 + pvr2_schedule_scanline_event( EVENT_SCANLINE2, pvr2_state.irq_vpos2, 0, 0 );92.643 + MMIO_WRITE( PVR2, reg, val );92.644 + break;92.645 + case RENDER_NEARCLIP:92.646 + MMIO_WRITE( PVR2, reg, val & 0x7FFFFFFF );92.647 + break;92.648 + case RENDER_SHADOW:92.649 + MMIO_WRITE( PVR2, reg, val&0x000001FF );92.650 + break;92.651 + case RENDER_OBJCFG:92.652 + MMIO_WRITE( PVR2, reg, val&0x003FFFFF );92.653 + break;92.654 + case RENDER_TSPCLIP:92.655 + MMIO_WRITE( PVR2, reg, val&0x7FFFFFFF );92.656 + break;92.657 + case RENDER_FARCLIP:92.658 + MMIO_WRITE( PVR2, reg, val&0xFFFFFFF0 );92.659 + break;92.660 + case RENDER_BGPLANE:92.661 + MMIO_WRITE( PVR2, reg, val&0x1FFFFFFF );92.662 + break;92.663 + case RENDER_ISPCFG:92.664 + MMIO_WRITE( PVR2, reg, val&0x00FFFFF9 );92.665 + break;92.666 + case VRAM_CFG1:92.667 + MMIO_WRITE( PVR2, reg, val&0x000000FF );92.668 + break;92.669 + case VRAM_CFG2:92.670 + MMIO_WRITE( PVR2, reg, val&0x003FFFFF );92.671 + break;92.672 + case VRAM_CFG3:92.673 + MMIO_WRITE( PVR2, reg, val&0x1FFFFFFF );92.674 + break;92.675 + case RENDER_FOGTBLCOL:92.676 + case RENDER_FOGVRTCOL:92.677 + MMIO_WRITE( PVR2, reg, val&0x00FFFFFF );92.678 + break;92.679 + case RENDER_FOGCOEFF:92.680 + MMIO_WRITE( PVR2, reg, val&0x0000FFFF );92.681 + break;92.682 + case RENDER_CLAMPHI:92.683 + case RENDER_CLAMPLO:92.684 + MMIO_WRITE( PVR2, reg, val );92.685 + break;92.686 + case RENDER_TEXSIZE:92.687 + MMIO_WRITE( PVR2, reg, val&0x00031F1F );92.688 + break;92.689 + case RENDER_PALETTE:92.690 + MMIO_WRITE( PVR2, reg, val&0x00000003 );92.691 + break;92.692 + case RENDER_ALPHA_REF:92.693 + MMIO_WRITE( PVR2, reg, val&0x000000FF );92.694 + break;92.695 + /********** CRTC registers *************/92.696 + case DISP_HBORDER:92.697 + case DISP_VBORDER:92.698 + MMIO_WRITE( PVR2, reg, val&0x03FF03FF );92.699 + break;92.700 + case DISP_TOTAL:92.701 + val = val & 0x03FF03FF;92.702 + MMIO_WRITE( PVR2, reg, val );92.703 + pvr2_update_raster_posn(sh4r.slice_cycle);92.704 + pvr2_state.total_lines = (val >> 16) + 1;92.705 + pvr2_state.line_size = (val & 0x03FF) + 1;92.706 + pvr2_state.line_time_ns = 1000000 * pvr2_state.line_size / pvr2_state.dot_clock;92.707 + pvr2_state.retrace_end_line = 0x2A;92.708 + pvr2_state.retrace_start_line = pvr2_state.total_lines - 6;92.709 + pvr2_schedule_scanline_event( EVENT_SCANLINE1, pvr2_state.irq_vpos1, 0, 0 );92.710 + pvr2_schedule_scanline_event( EVENT_SCANLINE2, pvr2_state.irq_vpos2, 0, 0 );92.711 + pvr2_schedule_scanline_event( EVENT_HPOS, pvr2_state.irq_hpos_line, 0,92.712 + pvr2_state.irq_hpos_time_ns );92.713 + break;92.714 + case DISP_SYNCCFG:92.715 + MMIO_WRITE( PVR2, reg, val&0x000003FF );92.716 + pvr2_state.interlaced = (val & 0x0010) ? TRUE : FALSE;92.717 + break;92.718 + case DISP_SYNCTIME:92.719 + pvr2_state.vsync_lines = (val >> 8) & 0x0F;92.720 + pvr2_state.hsync_width_ns = ((val & 0x7F) + 1) * 2000000 / pvr2_state.dot_clock;92.721 + MMIO_WRITE( PVR2, reg, val&0xFFFFFF7F );92.722 + break;92.723 + case DISP_CFG2:92.724 + MMIO_WRITE( PVR2, reg, val&0x003F01FF );92.725 + break;92.726 + case DISP_HPOS:92.727 + val = val & 0x03FF;92.728 + pvr2_state.front_porch_ns = (val + 1) * 1000000 / pvr2_state.dot_clock;92.729 + MMIO_WRITE( PVR2, reg, val );92.730 + break;92.731 + case DISP_VPOS:92.732 + MMIO_WRITE( PVR2, reg, val&0x03FF03FF );92.733 + break;92.735 - /*********** Tile accelerator registers ***********/92.736 - case TA_POLYPOS:92.737 - case TA_LISTPOS:92.738 - /* Readonly registers */92.739 - break;92.740 - case TA_TILEBASE:92.741 - case TA_LISTEND:92.742 - case TA_LISTBASE:92.743 - MMIO_WRITE( PVR2, reg, val&0x00FFFFE0 );92.744 - break;92.745 - case RENDER_TILEBASE:92.746 - case TA_POLYBASE:92.747 - case TA_POLYEND:92.748 - MMIO_WRITE( PVR2, reg, val&0x00FFFFFC );92.749 - break;92.750 - case TA_TILESIZE:92.751 - MMIO_WRITE( PVR2, reg, val&0x000F003F );92.752 - break;92.753 - case TA_TILECFG:92.754 - MMIO_WRITE( PVR2, reg, val&0x00133333 );92.755 - break;92.756 - case TA_INIT:92.757 - if( val & 0x80000000 )92.758 - pvr2_ta_init();92.759 - break;92.760 - case TA_REINIT:92.761 - break;92.762 - /**************** Scaler registers? ****************/92.763 - case RENDER_SCALER:92.764 - MMIO_WRITE( PVR2, reg, val&0x0007FFFF );92.765 - break;92.766 + /*********** Tile accelerator registers ***********/92.767 + case TA_POLYPOS:92.768 + case TA_LISTPOS:92.769 + /* Readonly registers */92.770 + break;92.771 + case TA_TILEBASE:92.772 + case TA_LISTEND:92.773 + case TA_LISTBASE:92.774 + MMIO_WRITE( PVR2, reg, val&0x00FFFFE0 );92.775 + break;92.776 + case RENDER_TILEBASE:92.777 + case TA_POLYBASE:92.778 + case TA_POLYEND:92.779 + MMIO_WRITE( PVR2, reg, val&0x00FFFFFC );92.780 + break;92.781 + case TA_TILESIZE:92.782 + MMIO_WRITE( PVR2, reg, val&0x000F003F );92.783 + break;92.784 + case TA_TILECFG:92.785 + MMIO_WRITE( PVR2, reg, val&0x00133333 );92.786 + break;92.787 + case TA_INIT:92.788 + if( val & 0x80000000 )92.789 + pvr2_ta_init();92.790 + break;92.791 + case TA_REINIT:92.792 + break;92.793 + /**************** Scaler registers? ****************/92.794 + case RENDER_SCALER:92.795 + MMIO_WRITE( PVR2, reg, val&0x0007FFFF );92.796 + break;92.798 - case YUV_ADDR:92.799 - val = val & 0x00FFFFF8;92.800 - MMIO_WRITE( PVR2, reg, val );92.801 - pvr2_yuv_init( val );92.802 - break;92.803 - case YUV_CFG:92.804 - MMIO_WRITE( PVR2, reg, val&0x01013F3F );92.805 - pvr2_yuv_set_config(val);92.806 - break;92.807 + case YUV_ADDR:92.808 + val = val & 0x00FFFFF8;92.809 + MMIO_WRITE( PVR2, reg, val );92.810 + pvr2_yuv_init( val );92.811 + break;92.812 + case YUV_CFG:92.813 + MMIO_WRITE( PVR2, reg, val&0x01013F3F );92.814 + pvr2_yuv_set_config(val);92.815 + break;92.817 - /**************** Unknowns ***************/92.818 - case PVRUNK1:92.819 - MMIO_WRITE( PVR2, reg, val&0x000007FF );92.820 - break;92.821 - case PVRUNK2:92.822 - MMIO_WRITE( PVR2, reg, val&0x00000007 );92.823 - break;92.824 - case PVRUNK3:92.825 - MMIO_WRITE( PVR2, reg, val&0x000FFF3F );92.826 - break;92.827 - case PVRUNK5:92.828 - MMIO_WRITE( PVR2, reg, val&0x0000FFFF );92.829 - break;92.830 - case PVRUNK7:92.831 - MMIO_WRITE( PVR2, reg, val&0x00000001 );92.832 - break;92.833 - case PVRUNK8:92.834 - MMIO_WRITE( PVR2, reg, val&0x0300FFFF );92.835 - break;92.836 + /**************** Unknowns ***************/92.837 + case PVRUNK1:92.838 + MMIO_WRITE( PVR2, reg, val&0x000007FF );92.839 + break;92.840 + case PVRUNK2:92.841 + MMIO_WRITE( PVR2, reg, val&0x00000007 );92.842 + break;92.843 + case PVRUNK3:92.844 + MMIO_WRITE( PVR2, reg, val&0x000FFF3F );92.845 + break;92.846 + case PVRUNK5:92.847 + MMIO_WRITE( PVR2, reg, val&0x0000FFFF );92.848 + break;92.849 + case PVRUNK7:92.850 + MMIO_WRITE( PVR2, reg, val&0x00000001 );92.851 + break;92.852 + case PVRUNK8:92.853 + MMIO_WRITE( PVR2, reg, val&0x0300FFFF );92.854 + break;92.855 }92.856 }92.858 @@ -718,29 +718,29 @@92.859 uint32_t result = pvr2_state.line_count;92.861 if( pvr2_state.odd_even_field ) {92.862 - result |= 0x0400;92.863 + result |= 0x0400;92.864 }92.865 if( (pvr2_state.line_count & 0x01) == pvr2_state.odd_even_field ) {92.866 - if( pvr2_state.line_remainder > pvr2_state.hsync_width_ns ) {92.867 - result |= 0x1000; /* !HSYNC */92.868 - }92.869 - if( pvr2_state.line_count >= pvr2_state.vsync_lines ) {92.870 - if( pvr2_state.line_remainder > pvr2_state.front_porch_ns ) {92.871 - result |= 0x2800; /* Display active */92.872 - } else {92.873 - result |= 0x2000; /* Front porch */92.874 - }92.875 - }92.876 + if( pvr2_state.line_remainder > pvr2_state.hsync_width_ns ) {92.877 + result |= 0x1000; /* !HSYNC */92.878 + }92.879 + if( pvr2_state.line_count >= pvr2_state.vsync_lines ) {92.880 + if( pvr2_state.line_remainder > pvr2_state.front_porch_ns ) {92.881 + result |= 0x2800; /* Display active */92.882 + } else {92.883 + result |= 0x2000; /* Front porch */92.884 + }92.885 + }92.886 } else {92.887 - if( pvr2_state.line_count >= pvr2_state.vsync_lines ) {92.888 - if( pvr2_state.line_remainder < (pvr2_state.line_time_ns - pvr2_state.back_porch_ns)) {92.889 - result |= 0x3800; /* Display active */92.890 - } else {92.891 - result |= 0x3000;92.892 - }92.893 - } else {92.894 - result |= 0x1000; /* Back porch */92.895 - }92.896 + if( pvr2_state.line_count >= pvr2_state.vsync_lines ) {92.897 + if( pvr2_state.line_remainder < (pvr2_state.line_time_ns - pvr2_state.back_porch_ns)) {92.898 + result |= 0x3800; /* Display active */92.899 + } else {92.900 + result |= 0x3000;92.901 + }92.902 + } else {92.903 + result |= 0x1000; /* Back porch */92.904 + }92.905 }92.906 return result;92.907 }92.908 @@ -760,42 +760,42 @@92.909 {92.910 uint32_t field = pvr2_state.odd_even_field;92.911 if( line <= pvr2_state.line_count && pvr2_state.interlaced ) {92.912 - field = !field;92.913 + field = !field;92.914 }92.915 if( hpos_ns > pvr2_state.line_time_ns ) {92.916 - hpos_ns = pvr2_state.line_time_ns;92.917 + hpos_ns = pvr2_state.line_time_ns;92.918 }92.920 line <<= 1;92.921 if( field ) {92.922 - line += 1;92.923 + line += 1;92.924 }92.925 -92.926 +92.927 if( line < pvr2_state.total_lines ) {92.928 - uint32_t lines;92.929 - uint32_t time;92.930 - if( line <= pvr2_state.line_count ) {92.931 - lines = (pvr2_state.total_lines - pvr2_state.line_count + line);92.932 - } else {92.933 - lines = (line - pvr2_state.line_count);92.934 - }92.935 - if( lines <= minimum_lines ) {92.936 - lines += pvr2_state.total_lines;92.937 - }92.938 - time = (lines * pvr2_state.line_time_ns) - pvr2_state.line_remainder + hpos_ns;92.939 - event_schedule( eventid, time );92.940 + uint32_t lines;92.941 + uint32_t time;92.942 + if( line <= pvr2_state.line_count ) {92.943 + lines = (pvr2_state.total_lines - pvr2_state.line_count + line);92.944 + } else {92.945 + lines = (line - pvr2_state.line_count);92.946 + }92.947 + if( lines <= minimum_lines ) {92.948 + lines += pvr2_state.total_lines;92.949 + }92.950 + time = (lines * pvr2_state.line_time_ns) - pvr2_state.line_remainder + hpos_ns;92.951 + event_schedule( eventid, time );92.952 } else {92.953 - event_cancel( eventid );92.954 + event_cancel( eventid );92.955 }92.956 }92.958 MMIO_REGION_READ_FN( PVR2, reg )92.959 {92.960 switch( reg ) {92.961 - case DISP_SYNCSTAT:92.962 - return pvr2_get_sync_status();92.963 - default:92.964 - return MMIO_READ( PVR2, reg );92.965 + case DISP_SYNCSTAT:92.966 + return pvr2_get_sync_status();92.967 + default:92.968 + return MMIO_READ( PVR2, reg );92.969 }92.970 }92.972 @@ -808,8 +808,8 @@92.973 void pvr2_check_palette_changed()92.974 {92.975 if( pvr2_state.palette_changed ) {92.976 - texcache_invalidate_palette();92.977 - pvr2_state.palette_changed = FALSE;92.978 + texcache_invalidate_palette();92.979 + pvr2_state.palette_changed = FALSE;92.980 }92.981 }92.983 @@ -845,9 +845,9 @@92.984 {92.985 int i;92.986 for( i=0; i<render_buffer_count; i++ ) {92.987 - if( render_buffers[i] != NULL && render_buffers[i]->address == frame->address ) {92.988 - return render_buffers[i];92.989 - }92.990 + if( render_buffers[i] != NULL && render_buffers[i]->address == frame->address ) {92.991 + return render_buffers[i];92.992 + }92.993 }92.994 return NULL;92.995 }92.996 @@ -871,68 +871,68 @@92.998 /* Check existing buffers for an available buffer */92.999 for( i=0; i<render_buffer_count; i++ ) {92.1000 - if( render_buffers[i]->width == width && render_buffers[i]->height == height ) {92.1001 - /* needs to be the right dimensions */92.1002 - if( render_buffers[i]->address == render_addr ) {92.1003 - if( displayed_render_buffer == render_buffers[i] ) {92.1004 - /* Same address, but we can't use it because the92.1005 - * display has it. Mark it as unaddressed for later.92.1006 - */92.1007 - render_buffers[i]->address = -1;92.1008 - } else {92.1009 - /* perfect */92.1010 - result = render_buffers[i];92.1011 - break;92.1012 - }92.1013 - } else if( render_buffers[i]->address == -1 && result == NULL &&92.1014 - displayed_render_buffer != render_buffers[i] ) {92.1015 - result = render_buffers[i];92.1016 - }92.1017 -92.1018 - } else if( render_buffers[i]->address == render_addr ) {92.1019 - /* right address, wrong size - if it's larger, flush it, otherwise92.1020 - * nuke it quietly */92.1021 - if( render_buffers[i]->width * render_buffers[i]->height >92.1022 - width*height ) {92.1023 - pvr2_render_buffer_copy_to_sh4( render_buffers[i] );92.1024 - }92.1025 - render_buffers[i]->address = -1;92.1026 - }92.1027 + if( render_buffers[i]->width == width && render_buffers[i]->height == height ) {92.1028 + /* needs to be the right dimensions */92.1029 + if( render_buffers[i]->address == render_addr ) {92.1030 + if( displayed_render_buffer == render_buffers[i] ) {92.1031 + /* Same address, but we can't use it because the92.1032 + * display has it. Mark it as unaddressed for later.92.1033 + */92.1034 + render_buffers[i]->address = -1;92.1035 + } else {92.1036 + /* perfect */92.1037 + result = render_buffers[i];92.1038 + break;92.1039 + }92.1040 + } else if( render_buffers[i]->address == -1 && result == NULL &&92.1041 + displayed_render_buffer != render_buffers[i] ) {92.1042 + result = render_buffers[i];92.1043 + }92.1044 +92.1045 + } else if( render_buffers[i]->address == render_addr ) {92.1046 + /* right address, wrong size - if it's larger, flush it, otherwise92.1047 + * nuke it quietly */92.1048 + if( render_buffers[i]->width * render_buffers[i]->height >92.1049 + width*height ) {92.1050 + pvr2_render_buffer_copy_to_sh4( render_buffers[i] );92.1051 + }92.1052 + render_buffers[i]->address = -1;92.1053 + }92.1054 }92.1056 /* Nothing available - make one */92.1057 if( result == NULL ) {92.1058 - if( render_buffer_count == MAX_RENDER_BUFFERS ) {92.1059 - /* maximum buffers reached - need to throw one away */92.1060 - uint32_t field1_addr = MMIO_READ( PVR2, DISP_ADDR1 );92.1061 - uint32_t field2_addr = MMIO_READ( PVR2, DISP_ADDR2 );92.1062 - for( i=0; i<render_buffer_count; i++ ) {92.1063 - if( render_buffers[i]->address != field1_addr &&92.1064 - render_buffers[i]->address != field2_addr &&92.1065 - render_buffers[i] != displayed_render_buffer ) {92.1066 - /* Never throw away the current "front buffer(s)" */92.1067 - result = render_buffers[i];92.1068 - if( !result->flushed ) {92.1069 - pvr2_render_buffer_copy_to_sh4( result );92.1070 - }92.1071 - if( result->width != width || result->height != height ) {92.1072 - display_driver->destroy_render_buffer(render_buffers[i]);92.1073 - result = display_driver->create_render_buffer(width,height);92.1074 - render_buffers[i] = result;92.1075 - }92.1076 - break;92.1077 - }92.1078 - }92.1079 - } else {92.1080 - result = display_driver->create_render_buffer(width,height);92.1081 - if( result != NULL ) {92.1082 - render_buffers[render_buffer_count++] = result;92.1083 - }92.1084 - }92.1085 + if( render_buffer_count == MAX_RENDER_BUFFERS ) {92.1086 + /* maximum buffers reached - need to throw one away */92.1087 + uint32_t field1_addr = MMIO_READ( PVR2, DISP_ADDR1 );92.1088 + uint32_t field2_addr = MMIO_READ( PVR2, DISP_ADDR2 );92.1089 + for( i=0; i<render_buffer_count; i++ ) {92.1090 + if( render_buffers[i]->address != field1_addr &&92.1091 + render_buffers[i]->address != field2_addr &&92.1092 + render_buffers[i] != displayed_render_buffer ) {92.1093 + /* Never throw away the current "front buffer(s)" */92.1094 + result = render_buffers[i];92.1095 + if( !result->flushed ) {92.1096 + pvr2_render_buffer_copy_to_sh4( result );92.1097 + }92.1098 + if( result->width != width || result->height != height ) {92.1099 + display_driver->destroy_render_buffer(render_buffers[i]);92.1100 + result = display_driver->create_render_buffer(width,height);92.1101 + render_buffers[i] = result;92.1102 + }92.1103 + break;92.1104 + }92.1105 + }92.1106 + } else {92.1107 + result = display_driver->create_render_buffer(width,height);92.1108 + if( result != NULL ) {92.1109 + render_buffers[render_buffer_count++] = result;92.1110 + }92.1111 + }92.1112 }92.1114 if( result != NULL ) {92.1115 - result->address = render_addr;92.1116 + result->address = render_addr;92.1117 }92.1118 return result;92.1119 }92.1120 @@ -949,9 +949,9 @@92.1121 uint32_t render_stride = MMIO_READ( PVR2, RENDER_SIZE ) << 3;92.1123 if( render_addr & 0x01000000 ) { /* vram64 */92.1124 - render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE_INT;92.1125 + render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE_INT;92.1126 } else { /* vram32 */92.1127 - render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE;92.1128 + render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE;92.1129 }92.1131 int width = pvr2_scene_buffer_width();92.1132 @@ -961,12 +961,12 @@92.1133 result = pvr2_alloc_render_buffer( render_addr, width, height );92.1134 /* Setup the buffer */92.1135 if( result != NULL ) {92.1136 - result->rowstride = render_stride;92.1137 - result->colour_format = colour_format;92.1138 - result->scale = render_scale;92.1139 - result->size = width * height * colour_formats[colour_format].bpp;92.1140 - result->flushed = FALSE;92.1141 - result->inverted = TRUE; // render buffers are inverted normally92.1142 + result->rowstride = render_stride;92.1143 + result->colour_format = colour_format;92.1144 + result->scale = render_scale;92.1145 + result->size = width * height * colour_formats[colour_format].bpp;92.1146 + result->flushed = FALSE;92.1147 + result->inverted = TRUE; // render buffers are inverted normally92.1148 }92.1149 return result;92.1150 }92.1151 @@ -975,18 +975,18 @@92.1152 {92.1153 render_buffer_t result = pvr2_alloc_render_buffer( frame->address, frame->width, frame->height );92.1154 if( result != NULL ) {92.1155 - int bpp = colour_formats[frame->colour_format].bpp;92.1156 - result->rowstride = frame->rowstride;92.1157 - result->colour_format = frame->colour_format;92.1158 - result->scale = 0x400;92.1159 - result->size = frame->width * frame->height * bpp;92.1160 - result->flushed = TRUE;92.1161 - result->inverted = frame->inverted;92.1162 - display_driver->load_frame_buffer( frame, result );92.1163 + int bpp = colour_formats[frame->colour_format].bpp;92.1164 + result->rowstride = frame->rowstride;92.1165 + result->colour_format = frame->colour_format;92.1166 + result->scale = 0x400;92.1167 + result->size = frame->width * frame->height * bpp;92.1168 + result->flushed = TRUE;92.1169 + result->inverted = frame->inverted;92.1170 + display_driver->load_frame_buffer( frame, result );92.1171 }92.1172 return result;92.1173 }92.1174 -92.1175 +92.1177 /**92.1178 * Invalidate any caching on the supplied address. Specifically, if it falls92.1179 @@ -997,18 +997,18 @@92.1180 int i;92.1181 address = address & 0x1FFFFFFF;92.1182 for( i=0; i<render_buffer_count; i++ ) {92.1183 - uint32_t bufaddr = render_buffers[i]->address;92.1184 - if( bufaddr != -1 && bufaddr <= address &&92.1185 - (bufaddr + render_buffers[i]->size) > address ) {92.1186 - if( !render_buffers[i]->flushed ) {92.1187 - pvr2_render_buffer_copy_to_sh4( render_buffers[i] );92.1188 - render_buffers[i]->flushed = TRUE;92.1189 - }92.1190 - if( isWrite ) {92.1191 - render_buffers[i]->address = -1; /* Invalid */92.1192 - }92.1193 - return TRUE; /* should never have overlapping buffers */92.1194 - }92.1195 + uint32_t bufaddr = render_buffers[i]->address;92.1196 + if( bufaddr != -1 && bufaddr <= address &&92.1197 + (bufaddr + render_buffers[i]->size) > address ) {92.1198 + if( !render_buffers[i]->flushed ) {92.1199 + pvr2_render_buffer_copy_to_sh4( render_buffers[i] );92.1200 + render_buffers[i]->flushed = TRUE;92.1201 + }92.1202 + if( isWrite ) {92.1203 + render_buffers[i]->address = -1; /* Invalid */92.1204 + }92.1205 + return TRUE; /* should never have overlapping buffers */92.1206 + }92.1207 }92.1208 return FALSE;92.1209 }
93.1 --- a/src/pvr2/pvr2.h Mon Jul 14 07:42:45 2008 +000093.2 +++ b/src/pvr2/pvr2.h Mon Jul 14 07:44:42 2008 +000093.3 @@ -24,6 +24,10 @@93.4 #include "mem.h"93.5 #include "display.h"93.7 +#ifdef __cplusplus93.8 +extern "C" {93.9 +#endif93.10 +93.11 typedef unsigned int pvraddr_t;93.12 typedef unsigned int pvr64addr_t;93.14 @@ -140,7 +144,7 @@93.15 * using a line length and stride.93.16 */93.17 void pvr2_vram64_write_stride( sh4addr_t dest, unsigned char *src, uint32_t line_bytes,93.18 - uint32_t line_stride_bytes, uint32_t line_count );93.19 + uint32_t line_stride_bytes, uint32_t line_count );93.21 /**93.22 * Read from the interleaved memory address space (aka 64-bit address space)93.23 @@ -178,7 +182,7 @@93.24 * counts must be a multiple of 4, and the src address must be 32-bit aligned.93.25 */93.26 void pvr2_vram64_read_stride( unsigned char *dest, uint32_t dest_line_bytes, sh4addr_t srcaddr,93.27 - uint32_t src_line_bytes, uint32_t line_count );93.28 + uint32_t src_line_bytes, uint32_t line_count );93.29 /**93.30 * Dump a portion of vram to a stream from the interleaved memory address93.31 * space.93.32 @@ -380,4 +384,8 @@93.33 pvraddr_t punchout_ptr;93.34 };93.36 +#ifdef __cplusplus93.37 +}93.38 +#endif93.39 +93.40 #endif /* !lxdream_pvr2_H */
94.1 --- a/src/pvr2/pvr2mem.c Mon Jul 14 07:42:45 2008 +000094.2 +++ b/src/pvr2/pvr2mem.c Mon Jul 14 07:44:42 2008 +000094.3 @@ -31,31 +31,31 @@94.4 switch( destaddr & 0x13800000 ) {94.5 case 0x10000000:94.6 case 0x12000000:94.7 - pvr2_ta_write( src, count );94.8 - break;94.9 + pvr2_ta_write( src, count );94.10 + break;94.11 case 0x11000000:94.12 case 0x11800000:94.13 - region = MMIO_READ( ASIC, PVRDMARGN1 );94.14 - if( region == 0 ) {94.15 - pvr2_vram64_write( destaddr, src, count );94.16 - } else {94.17 - unsigned char *dest = mem_get_region(destaddr);94.18 - memcpy( dest, src, count );94.19 - }94.20 - break;94.21 + region = MMIO_READ( ASIC, PVRDMARGN1 );94.22 + if( region == 0 ) {94.23 + pvr2_vram64_write( destaddr, src, count );94.24 + } else {94.25 + unsigned char *dest = mem_get_region(destaddr);94.26 + memcpy( dest, src, count );94.27 + }94.28 + break;94.29 case 0x10800000:94.30 case 0x12800000:94.31 - pvr2_yuv_write( src, count );94.32 - break;94.33 + pvr2_yuv_write( src, count );94.34 + break;94.35 case 0x13000000:94.36 case 0x13800000:94.37 - region = MMIO_READ( ASIC, PVRDMARGN2 );94.38 - if( region == 0 ) {94.39 - pvr2_vram64_write( destaddr, src, count );94.40 - } else {94.41 - unsigned char *dest = mem_get_region(destaddr);94.42 - memcpy( dest, src, count );94.43 - }94.44 + region = MMIO_READ( ASIC, PVRDMARGN2 );94.45 + if( region == 0 ) {94.46 + pvr2_vram64_write( destaddr, src, count );94.47 + } else {94.48 + unsigned char *dest = mem_get_region(destaddr);94.49 + memcpy( dest, src, count );94.50 + }94.51 }94.52 }94.54 @@ -68,41 +68,41 @@94.56 destaddr = destaddr & 0x7FFFFF;94.57 if( destaddr + length > 0x800000 ) {94.58 - length = 0x800000 - destaddr;94.59 + length = 0x800000 - destaddr;94.60 }94.62 for( i=destaddr & 0xFFFFF000; i < destaddr + length; i+= PAGE_SIZE ) {94.63 - texcache_invalidate_page( i );94.64 + texcache_invalidate_page( i );94.65 }94.67 banks[0] = ((uint32_t *)(video_base + ((destaddr & 0x007FFFF8) >>1)));94.68 banks[1] = banks[0] + 0x100000;94.69 if( bank_flag )94.70 - banks[0]++;94.71 -94.72 + banks[0]++;94.73 +94.74 /* Handle non-aligned start of source */94.75 if( destaddr & 0x03 ) {94.76 - unsigned char *dest = ((unsigned char *)banks[bank_flag]) + (destaddr & 0x03);94.77 - for( i= destaddr & 0x03; i < 4 && length > 0; i++, length-- ) {94.78 - *dest++ = *src++;94.79 - }94.80 - bank_flag = !bank_flag;94.81 + unsigned char *dest = ((unsigned char *)banks[bank_flag]) + (destaddr & 0x03);94.82 + for( i= destaddr & 0x03; i < 4 && length > 0; i++, length-- ) {94.83 + *dest++ = *src++;94.84 + }94.85 + bank_flag = !bank_flag;94.86 }94.88 dwsrc = (uint32_t *)src;94.89 while( length >= 4 ) {94.90 - *banks[bank_flag]++ = *dwsrc++;94.91 - bank_flag = !bank_flag;94.92 - length -= 4;94.93 + *banks[bank_flag]++ = *dwsrc++;94.94 + bank_flag = !bank_flag;94.95 + length -= 4;94.96 }94.97 -94.98 +94.99 /* Handle non-aligned end of source */94.100 if( length ) {94.101 - src = (unsigned char *)dwsrc;94.102 - unsigned char *dest = (unsigned char *)banks[bank_flag];94.103 - while( length-- > 0 ) {94.104 - *dest++ = *src++;94.105 - }94.106 + src = (unsigned char *)dwsrc;94.107 + unsigned char *dest = (unsigned char *)banks[bank_flag];94.108 + while( length-- > 0 ) {94.109 + *dest++ = *src++;94.110 + }94.111 }94.112 }94.114 @@ -112,7 +112,7 @@94.115 * must be multiples of 4.94.116 */94.117 void pvr2_vram64_write_stride( sh4addr_t destaddr, unsigned char *src, uint32_t line_bytes,94.118 - uint32_t line_stride_bytes, uint32_t line_count )94.119 + uint32_t line_stride_bytes, uint32_t line_count )94.120 {94.121 int bank_flag = (destaddr & 0x04) >> 2;94.122 uint32_t *banks[2];94.123 @@ -128,26 +128,26 @@94.124 line_bytes >>= 2;94.126 for( i=destaddr & 0xFFFFF000; i < destaddr + line_stride_bytes*line_count; i+= PAGE_SIZE ) {94.127 - texcache_invalidate_page( i );94.128 + texcache_invalidate_page( i );94.129 }94.131 banks[0] = (uint32_t *)(video_base + (destaddr >>1));94.132 banks[1] = banks[0] + 0x100000;94.133 if( bank_flag )94.134 - banks[0]++;94.135 -94.136 + banks[0]++;94.137 +94.138 dwsrc = (uint32_t *)src;94.139 for( i=0; i<line_count; i++ ) {94.140 - for( j=0; j<line_bytes; j++ ) {94.141 - *banks[bank_flag]++ = *dwsrc++;94.142 - bank_flag = !bank_flag;94.143 - }94.144 - banks[0] += line_gap;94.145 - banks[1] += line_gap;94.146 - if( line_gap_flag ) {94.147 - banks[bank_flag]++;94.148 - bank_flag = !bank_flag;94.149 - }94.150 + for( j=0; j<line_bytes; j++ ) {94.151 + *banks[bank_flag]++ = *dwsrc++;94.152 + bank_flag = !bank_flag;94.153 + }94.154 + banks[0] += line_gap;94.155 + banks[1] += line_gap;94.156 + if( line_gap_flag ) {94.157 + banks[bank_flag]++;94.158 + bank_flag = !bank_flag;94.159 + }94.160 }94.161 }94.163 @@ -158,7 +158,7 @@94.164 * This method is used to extract a "stride" texture from vram.94.165 */94.166 void pvr2_vram64_read_stride( unsigned char *dest, uint32_t dest_line_bytes, sh4addr_t srcaddr,94.167 - uint32_t src_line_bytes, uint32_t line_count )94.168 + uint32_t src_line_bytes, uint32_t line_count )94.169 {94.170 int bank_flag = (srcaddr & 0x04) >> 2;94.171 uint32_t *banks[2];94.172 @@ -171,35 +171,35 @@94.174 srcaddr = srcaddr & 0x7FFFF8;94.175 if( src_line_bytes <= dest_line_bytes ) {94.176 - dest_line_gap = (dest_line_bytes - src_line_bytes) >> 2;94.177 - src_line_gap = 0;94.178 - src_line_gap_flag = 0;94.179 - line_bytes = src_line_bytes >> 2;94.180 + dest_line_gap = (dest_line_bytes - src_line_bytes) >> 2;94.181 + src_line_gap = 0;94.182 + src_line_gap_flag = 0;94.183 + line_bytes = src_line_bytes >> 2;94.184 } else {94.185 - i = (src_line_bytes - dest_line_bytes);94.186 - src_line_gap_flag = i & 0x04;94.187 - src_line_gap = i >> 3;94.188 - line_bytes = dest_line_bytes >> 2;94.189 + i = (src_line_bytes - dest_line_bytes);94.190 + src_line_gap_flag = i & 0x04;94.191 + src_line_gap = i >> 3;94.192 + line_bytes = dest_line_bytes >> 2;94.193 }94.194 -94.195 +94.196 banks[0] = (uint32_t *)(video_base + (srcaddr>>1));94.197 banks[1] = banks[0] + 0x100000;94.198 if( bank_flag )94.199 - banks[0]++;94.200 -94.201 + banks[0]++;94.202 +94.203 dwdest = (uint32_t *)dest;94.204 for( i=0; i<line_count; i++ ) {94.205 - for( j=0; j<line_bytes; j++ ) {94.206 - *dwdest++ = *banks[bank_flag]++;94.207 - bank_flag = !bank_flag;94.208 - }94.209 - dwdest += dest_line_gap;94.210 - banks[0] += src_line_gap;94.211 - banks[1] += src_line_gap;94.212 - if( src_line_gap_flag ) {94.213 - banks[bank_flag]++;94.214 - bank_flag = !bank_flag;94.215 - }94.216 + for( j=0; j<line_bytes; j++ ) {94.217 + *dwdest++ = *banks[bank_flag]++;94.218 + bank_flag = !bank_flag;94.219 + }94.220 + dwdest += dest_line_gap;94.221 + banks[0] += src_line_gap;94.222 + banks[1] += src_line_gap;94.223 + if( src_line_gap_flag ) {94.224 + banks[bank_flag]++;94.225 + bank_flag = !bank_flag;94.226 + }94.227 }94.228 }94.230 @@ -215,26 +215,26 @@94.231 */94.233 static void pvr2_vram64_detwiddle_4( uint8_t *dest, uint8_t *banks[2], int offset,94.234 - int x1, int y1, int width, int stride )94.235 + int x1, int y1, int width, int stride )94.236 {94.237 if( width == 2 ) {94.238 - x1 = x1 >> 1;94.239 - uint8_t t1 = *banks[offset<4?0:1]++;94.240 - uint8_t t2 = *banks[offset<3?0:1]++;94.241 - dest[y1*stride + x1] = (t1 & 0x0F) | (t2<<4);94.242 - dest[(y1+1)*stride + x1] = (t1>>4) | (t2&0xF0);94.243 + x1 = x1 >> 1;94.244 + uint8_t t1 = *banks[offset<4?0:1]++;94.245 + uint8_t t2 = *banks[offset<3?0:1]++;94.246 + dest[y1*stride + x1] = (t1 & 0x0F) | (t2<<4);94.247 + dest[(y1+1)*stride + x1] = (t1>>4) | (t2&0xF0);94.248 } else if( width == 4 ) {94.249 - pvr2_vram64_detwiddle_4( dest, banks, offset, x1, y1, 2, stride );94.250 - pvr2_vram64_detwiddle_4( dest, banks, offset+2, x1, y1+2, 2, stride );94.251 - pvr2_vram64_detwiddle_4( dest, banks, offset+4, x1+2, y1, 2, stride );94.252 - pvr2_vram64_detwiddle_4( dest, banks, offset+6, x1+2, y1+2, 2, stride );94.253 -94.254 + pvr2_vram64_detwiddle_4( dest, banks, offset, x1, y1, 2, stride );94.255 + pvr2_vram64_detwiddle_4( dest, banks, offset+2, x1, y1+2, 2, stride );94.256 + pvr2_vram64_detwiddle_4( dest, banks, offset+4, x1+2, y1, 2, stride );94.257 + pvr2_vram64_detwiddle_4( dest, banks, offset+6, x1+2, y1+2, 2, stride );94.258 +94.259 } else {94.260 - int subdivide = width >> 1;94.261 - pvr2_vram64_detwiddle_4( dest, banks, offset, x1, y1, subdivide, stride );94.262 - pvr2_vram64_detwiddle_4( dest, banks, offset, x1, y1+subdivide, subdivide, stride );94.263 - pvr2_vram64_detwiddle_4( dest, banks, offset, x1+subdivide, y1, subdivide, stride );94.264 - pvr2_vram64_detwiddle_4( dest, banks, offset, x1+subdivide, y1+subdivide, subdivide, stride );94.265 + int subdivide = width >> 1;94.266 + pvr2_vram64_detwiddle_4( dest, banks, offset, x1, y1, subdivide, stride );94.267 + pvr2_vram64_detwiddle_4( dest, banks, offset, x1, y1+subdivide, subdivide, stride );94.268 + pvr2_vram64_detwiddle_4( dest, banks, offset, x1+subdivide, y1, subdivide, stride );94.269 + pvr2_vram64_detwiddle_4( dest, banks, offset, x1+subdivide, y1+subdivide, subdivide, stride );94.270 }94.271 }94.273 @@ -249,22 +249,22 @@94.274 */94.276 static void pvr2_vram64_detwiddle_8( uint8_t *dest, uint8_t *banks[2], int offset,94.277 - int x1, int y1, int width, int stride )94.278 + int x1, int y1, int width, int stride )94.279 {94.280 if( width == 2 ) {94.281 - dest[y1*stride + x1] = *banks[0]++;94.282 - dest[(y1+1)*stride + x1] = *banks[offset<3?0:1]++;94.283 - dest[y1*stride + x1 + 1] = *banks[offset<2?0:1]++;94.284 - dest[(y1+1)*stride + x1 + 1] = *banks[offset==0?0:1]++;94.285 - uint8_t *tmp = banks[0]; /* swap banks */94.286 - banks[0] = banks[1];94.287 - banks[1] = tmp;94.288 + dest[y1*stride + x1] = *banks[0]++;94.289 + dest[(y1+1)*stride + x1] = *banks[offset<3?0:1]++;94.290 + dest[y1*stride + x1 + 1] = *banks[offset<2?0:1]++;94.291 + dest[(y1+1)*stride + x1 + 1] = *banks[offset==0?0:1]++;94.292 + uint8_t *tmp = banks[0]; /* swap banks */94.293 + banks[0] = banks[1];94.294 + banks[1] = tmp;94.295 } else {94.296 - int subdivide = width >> 1;94.297 - pvr2_vram64_detwiddle_8( dest, banks, offset, x1, y1, subdivide, stride );94.298 - pvr2_vram64_detwiddle_8( dest, banks, offset, x1, y1+subdivide, subdivide, stride );94.299 - pvr2_vram64_detwiddle_8( dest, banks, offset, x1+subdivide, y1, subdivide, stride );94.300 - pvr2_vram64_detwiddle_8( dest, banks, offset, x1+subdivide, y1+subdivide, subdivide, stride );94.301 + int subdivide = width >> 1;94.302 + pvr2_vram64_detwiddle_8( dest, banks, offset, x1, y1, subdivide, stride );94.303 + pvr2_vram64_detwiddle_8( dest, banks, offset, x1, y1+subdivide, subdivide, stride );94.304 + pvr2_vram64_detwiddle_8( dest, banks, offset, x1+subdivide, y1, subdivide, stride );94.305 + pvr2_vram64_detwiddle_8( dest, banks, offset, x1+subdivide, y1+subdivide, subdivide, stride );94.306 }94.307 }94.309 @@ -279,19 +279,19 @@94.310 */94.312 static void pvr2_vram64_detwiddle_16( uint16_t *dest, uint16_t *banks[2], int offset,94.313 - int x1, int y1, int width, int stride )94.314 + int x1, int y1, int width, int stride )94.315 {94.316 if( width == 2 ) {94.317 - dest[y1*stride + x1] = *banks[0]++;94.318 - dest[(y1+1)*stride + x1] = *banks[offset]++;94.319 - dest[y1*stride + x1 + 1] = *banks[1]++;94.320 - dest[(y1+1)*stride + x1 + 1] = *banks[offset^1]++;94.321 + dest[y1*stride + x1] = *banks[0]++;94.322 + dest[(y1+1)*stride + x1] = *banks[offset]++;94.323 + dest[y1*stride + x1 + 1] = *banks[1]++;94.324 + dest[(y1+1)*stride + x1 + 1] = *banks[offset^1]++;94.325 } else {94.326 - int subdivide = width >> 1;94.327 - pvr2_vram64_detwiddle_16( dest, banks, offset, x1, y1, subdivide, stride );94.328 - pvr2_vram64_detwiddle_16( dest, banks, offset, x1, y1+subdivide, subdivide, stride );94.329 - pvr2_vram64_detwiddle_16( dest, banks, offset, x1+subdivide, y1, subdivide, stride );94.330 - pvr2_vram64_detwiddle_16( dest, banks, offset, x1+subdivide, y1+subdivide, subdivide, stride );94.331 + int subdivide = width >> 1;94.332 + pvr2_vram64_detwiddle_16( dest, banks, offset, x1, y1, subdivide, stride );94.333 + pvr2_vram64_detwiddle_16( dest, banks, offset, x1, y1+subdivide, subdivide, stride );94.334 + pvr2_vram64_detwiddle_16( dest, banks, offset, x1+subdivide, y1, subdivide, stride );94.335 + pvr2_vram64_detwiddle_16( dest, banks, offset, x1+subdivide, y1+subdivide, subdivide, stride );94.336 }94.337 }94.339 @@ -316,25 +316,25 @@94.340 banks[0] = (uint8_t *)(video_base + (srcaddr>>1));94.341 banks[1] = banks[0] + 0x400000;94.342 if( offset_flag & 0x04 ) { // If source is not 64-bit aligned, swap the banks94.343 - uint8_t *tmp = banks[0];94.344 - banks[0] = banks[1];94.345 - banks[1] = tmp + 4;94.346 - offset_flag &= 0x03;94.347 + uint8_t *tmp = banks[0];94.348 + banks[0] = banks[1];94.349 + banks[1] = tmp + 4;94.350 + offset_flag &= 0x03;94.351 }94.352 banks[0] += offset_flag;94.354 if( width > height ) {94.355 - for( i=0; i<width; i+=height ) {94.356 - pvr2_vram64_detwiddle_4( wdest, banks, offset_flag, i, 0, height, stride );94.357 - }94.358 + for( i=0; i<width; i+=height ) {94.359 + pvr2_vram64_detwiddle_4( wdest, banks, offset_flag, i, 0, height, stride );94.360 + }94.361 } else if( height > width ) {94.362 - for( i=0; i<height; i+=width ) {94.363 - pvr2_vram64_detwiddle_4( wdest, banks, offset_flag, 0, i, width, stride );94.364 - }94.365 + for( i=0; i<height; i+=width ) {94.366 + pvr2_vram64_detwiddle_4( wdest, banks, offset_flag, 0, i, width, stride );94.367 + }94.368 } else if( width == 1 ) {94.369 - *wdest = *banks[0];94.370 + *wdest = *banks[0];94.371 } else {94.372 - pvr2_vram64_detwiddle_4( wdest, banks, offset_flag, 0, 0, width, stride );94.373 + pvr2_vram64_detwiddle_4( wdest, banks, offset_flag, 0, 0, width, stride );94.374 }94.375 }94.377 @@ -358,25 +358,25 @@94.378 banks[0] = (uint8_t *)(video_base + (srcaddr>>1));94.379 banks[1] = banks[0] + 0x400000;94.380 if( offset_flag & 0x04 ) { // If source is not 64-bit aligned, swap the banks94.381 - uint8_t *tmp = banks[0];94.382 - banks[0] = banks[1];94.383 - banks[1] = tmp + 4;94.384 - offset_flag &= 0x03;94.385 + uint8_t *tmp = banks[0];94.386 + banks[0] = banks[1];94.387 + banks[1] = tmp + 4;94.388 + offset_flag &= 0x03;94.389 }94.390 banks[0] += offset_flag;94.392 if( width > height ) {94.393 - for( i=0; i<width; i+=height ) {94.394 - pvr2_vram64_detwiddle_8( wdest, banks, offset_flag, i, 0, height, width );94.395 - }94.396 + for( i=0; i<width; i+=height ) {94.397 + pvr2_vram64_detwiddle_8( wdest, banks, offset_flag, i, 0, height, width );94.398 + }94.399 } else if( height > width ) {94.400 - for( i=0; i<height; i+=width ) {94.401 - pvr2_vram64_detwiddle_8( wdest, banks, offset_flag, 0, i, width, width );94.402 - }94.403 + for( i=0; i<height; i+=width ) {94.404 + pvr2_vram64_detwiddle_8( wdest, banks, offset_flag, 0, i, width, width );94.405 + }94.406 } else if( width == 1 ) {94.407 - *wdest = *banks[0];94.408 + *wdest = *banks[0];94.409 } else {94.410 - pvr2_vram64_detwiddle_8( wdest, banks, offset_flag, 0, 0, width, width );94.411 + pvr2_vram64_detwiddle_8( wdest, banks, offset_flag, 0, 0, width, width );94.412 }94.413 }94.415 @@ -399,38 +399,38 @@94.416 banks[0] = (uint16_t *)(video_base + (srcaddr>>1));94.417 banks[1] = banks[0] + 0x200000;94.418 if( offset_flag & 0x02 ) { // If source is not 64-bit aligned, swap the banks94.419 - uint16_t *tmp = banks[0];94.420 - banks[0] = banks[1];94.421 - banks[1] = tmp + 2;94.422 - offset_flag &= 0x01;94.423 + uint16_t *tmp = banks[0];94.424 + banks[0] = banks[1];94.425 + banks[1] = tmp + 2;94.426 + offset_flag &= 0x01;94.427 }94.428 banks[0] += offset_flag;94.429 -94.430 +94.432 if( width > height ) {94.433 - for( i=0; i<width; i+=height ) {94.434 - pvr2_vram64_detwiddle_16( wdest, banks, offset_flag, i, 0, height, width );94.435 - }94.436 + for( i=0; i<width; i+=height ) {94.437 + pvr2_vram64_detwiddle_16( wdest, banks, offset_flag, i, 0, height, width );94.438 + }94.439 } else if( height > width ) {94.440 - for( i=0; i<height; i+=width ) {94.441 - pvr2_vram64_detwiddle_16( wdest, banks, offset_flag, 0, i, width, width );94.442 - }94.443 + for( i=0; i<height; i+=width ) {94.444 + pvr2_vram64_detwiddle_16( wdest, banks, offset_flag, 0, i, width, width );94.445 + }94.446 } else if( width == 1 ) {94.447 - *wdest = *banks[0];94.448 + *wdest = *banks[0];94.449 } else {94.450 - pvr2_vram64_detwiddle_16( wdest, banks, offset_flag, 0, 0, width, width );94.451 + pvr2_vram64_detwiddle_16( wdest, banks, offset_flag, 0, 0, width, width );94.452 }94.453 }94.455 void pvr2_vram_write_invert( sh4addr_t destaddr, unsigned char *src, uint32_t length, uint32_t line_length,94.456 - uint32_t src_stride )94.457 + uint32_t src_stride )94.458 {94.459 unsigned char *dest = video_base + (destaddr & 0x007FFFFF);94.460 unsigned char *p = src + length - src_stride;94.461 while( p >= src ) {94.462 - memcpy( dest, p, line_length );94.463 - p -= src_stride;94.464 - dest += line_length;94.465 + memcpy( dest, p, line_length );94.466 + p -= src_stride;94.467 + dest += line_length;94.468 }94.469 }94.471 @@ -443,36 +443,36 @@94.473 srcaddr = srcaddr & 0x7FFFFF;94.474 if( srcaddr + length > 0x800000 )94.475 - length = 0x800000 - srcaddr;94.476 + length = 0x800000 - srcaddr;94.478 banks[0] = ((uint32_t *)(video_base + ((srcaddr&0x007FFFF8)>>1)));94.479 banks[1] = banks[0] + 0x100000;94.480 if( bank_flag )94.481 - banks[0]++;94.482 -94.483 + banks[0]++;94.484 +94.485 /* Handle non-aligned start of source */94.486 if( srcaddr & 0x03 ) {94.487 - char *src = ((char *)banks[bank_flag]) + (srcaddr & 0x03);94.488 - for( i= srcaddr & 0x03; i < 4 && length > 0; i++, length-- ) {94.489 - *dest++ = *src++;94.490 - }94.491 - bank_flag = !bank_flag;94.492 + char *src = ((char *)banks[bank_flag]) + (srcaddr & 0x03);94.493 + for( i= srcaddr & 0x03; i < 4 && length > 0; i++, length-- ) {94.494 + *dest++ = *src++;94.495 + }94.496 + bank_flag = !bank_flag;94.497 }94.499 dwdest = (uint32_t *)dest;94.500 while( length >= 4 ) {94.501 - *dwdest++ = *banks[bank_flag]++;94.502 - bank_flag = !bank_flag;94.503 - length -= 4;94.504 + *dwdest++ = *banks[bank_flag]++;94.505 + bank_flag = !bank_flag;94.506 + length -= 4;94.507 }94.508 -94.509 +94.510 /* Handle non-aligned end of source */94.511 if( length ) {94.512 - dest = (unsigned char *)dwdest;94.513 - unsigned char *src = (unsigned char *)banks[bank_flag];94.514 - while( length-- > 0 ) {94.515 - *dest++ = *src++;94.516 - }94.517 + dest = (unsigned char *)dwdest;94.518 + unsigned char *src = (unsigned char *)banks[bank_flag];94.519 + while( length-- > 0 ) {94.520 + *dest++ = *src++;94.521 + }94.522 }94.523 }94.525 @@ -483,19 +483,19 @@94.526 unsigned int i, j;94.528 if( f == NULL ) {94.529 - ERROR( "Unable to write to dump file '%s' (%s)", filename, strerror(errno) );94.530 - return;94.531 + ERROR( "Unable to write to dump file '%s' (%s)", filename, strerror(errno) );94.532 + return;94.533 }94.534 pvr2_vram64_read( (unsigned char *)tmp, addr, length );94.535 fprintf( f, "%08X\n", addr );94.536 for( i =0; i<length>>2; i+=8 ) {94.537 - for( j=i; j<i+8; j++ ) {94.538 - if( j < length )94.539 - fprintf( f, " %08X", tmp[j] );94.540 - else94.541 - fprintf( f, " " );94.542 - }94.543 - fprintf( f, "\n" );94.544 + for( j=i; j<i+8; j++ ) {94.545 + if( j < length )94.546 + fprintf( f, " %08X", tmp[j] );94.547 + else94.548 + fprintf( f, " " );94.549 + }94.550 + fprintf( f, "\n" );94.551 }94.552 fclose(f);94.553 }94.554 @@ -521,15 +521,15 @@94.555 void pvr2_render_buffer_copy_to_sh4( render_buffer_t buffer )94.556 {94.557 if( (buffer->address & 0xFF000000) == 0x04000000 ) {94.558 - /* Interlaced buffer. Go the double copy... :( */94.559 - unsigned char target[buffer->size];94.560 - display_driver->read_render_buffer( target, buffer, buffer->rowstride, buffer->colour_format );94.561 - pvr2_vram64_write( buffer->address, target, buffer->size );94.562 + /* Interlaced buffer. Go the double copy... :( */94.563 + unsigned char target[buffer->size];94.564 + display_driver->read_render_buffer( target, buffer, buffer->rowstride, buffer->colour_format );94.565 + pvr2_vram64_write( buffer->address, target, buffer->size );94.566 } else {94.567 - /* Regular buffer */94.568 + /* Regular buffer */94.569 unsigned char target[buffer->size];94.570 - int line_size = buffer->width * colour_formats[buffer->colour_format].bpp;94.571 - display_driver->read_render_buffer( target, buffer, buffer->rowstride, buffer->colour_format );94.572 + int line_size = buffer->width * colour_formats[buffer->colour_format].bpp;94.573 + display_driver->read_render_buffer( target, buffer, buffer->rowstride, buffer->colour_format );94.574 if( (buffer->scale & 0xFFFF) == 0x0800 ) {94.575 pvr2_vram_write_invert( buffer->address, target, buffer->size, line_size, line_size << 1 );94.576 } else {
95.1 --- a/src/pvr2/rendsave.c Mon Jul 14 07:42:45 2008 +000095.2 +++ b/src/pvr2/rendsave.c Mon Jul 14 07:44:42 2008 +000095.3 @@ -49,20 +49,20 @@95.4 int pvr2_render_save_scene( const gchar *filename )95.5 {95.6 struct header {95.7 - char magic[16];95.8 - uint32_t version;95.9 - uint32_t timestamp;95.10 - uint32_t frame_count;95.11 + char magic[16];95.12 + uint32_t version;95.13 + uint32_t timestamp;95.14 + uint32_t frame_count;95.15 } scene_header;95.17 char page_map[SAVE_PAGE_COUNT];95.18 int i,j;95.19 pvr2_find_referenced_pages(page_map);95.20 -95.21 +95.22 FILE *f = fopen( filename, "wo" );95.23 if( f == NULL ) {95.24 - ERROR( "Unable to open file '%s' to write scene data: %s", filename, strerror(errno) );95.25 - return -1;95.26 + ERROR( "Unable to open file '%s' to write scene data: %s", filename, strerror(errno) );95.27 + return -1;95.28 }95.30 /* Header */95.31 @@ -81,16 +81,16 @@95.33 /* Write out the VRAM pages we care about */95.34 for( i=0; i<SAVE_PAGE_COUNT; i++ ) {95.35 - if( page_map[i] != 0 ) {95.36 - for( j=i+1; j<SAVE_PAGE_COUNT && page_map[j] != 0; j++ );95.37 - /* Write region from i..j-1 */95.38 - uint32_t start = i * SAVE_PAGE_SIZE;95.39 - uint32_t length = (j-i) * SAVE_PAGE_SIZE;95.40 - fwrite( &start, sizeof(uint32_t), 1, f );95.41 - fwrite( &length, sizeof(uint32_t), 1, f );95.42 - fwrite( video_base + start, 1, length, f );95.43 - i = j-1;95.44 - }95.45 + if( page_map[i] != 0 ) {95.46 + for( j=i+1; j<SAVE_PAGE_COUNT && page_map[j] != 0; j++ );95.47 + /* Write region from i..j-1 */95.48 + uint32_t start = i * SAVE_PAGE_SIZE;95.49 + uint32_t length = (j-i) * SAVE_PAGE_SIZE;95.50 + fwrite( &start, sizeof(uint32_t), 1, f );95.51 + fwrite( &length, sizeof(uint32_t), 1, f );95.52 + fwrite( video_base + start, 1, length, f );95.53 + i = j-1;95.54 + }95.55 }95.56 /* Write out the EOF marker */95.57 uint32_t eof = 0xFFFFFFFF;
96.1 --- a/src/pvr2/rendsort.c Mon Jul 14 07:42:45 2008 +000096.2 +++ b/src/pvr2/rendsort.c Mon Jul 14 07:44:42 2008 +000096.3 @@ -41,23 +41,23 @@96.4 uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);96.5 int count = 0;96.6 while(1) {96.7 - uint32_t entry = *tile_list++;96.8 - if( entry >> 28 == 0x0F ) {96.9 - break;96.10 - } else if( entry >> 28 == 0x0E ) {96.11 - tile_list = (uint32_t *)(video_base+(entry&0x007FFFFF));96.12 - } else if( entry >> 29 == 0x04 ) { /* Triangle array */96.13 - count += ((entry >> 25) & 0x0F)+1;96.14 - } else if( entry >> 29 == 0x05 ) { /* Quad array */96.15 - count += ((((entry >> 25) & 0x0F)+1)<<1);96.16 - } else { /* Polygon */96.17 - int i;96.18 - for( i=0; i<6; i++ ) {96.19 - if( entry & (0x40000000>>i) ) {96.20 - count++;96.21 - }96.22 - }96.23 - }96.24 + uint32_t entry = *tile_list++;96.25 + if( entry >> 28 == 0x0F ) {96.26 + break;96.27 + } else if( entry >> 28 == 0x0E ) {96.28 + tile_list = (uint32_t *)(video_base+(entry&0x007FFFFF));96.29 + } else if( entry >> 29 == 0x04 ) { /* Triangle array */96.30 + count += ((entry >> 25) & 0x0F)+1;96.31 + } else if( entry >> 29 == 0x05 ) { /* Quad array */96.32 + count += ((((entry >> 25) & 0x0F)+1)<<1);96.33 + } else { /* Polygon */96.34 + int i;96.35 + for( i=0; i<6; i++ ) {96.36 + if( entry & (0x40000000>>i) ) {96.37 + count++;96.38 + }96.39 + }96.40 + }96.41 }96.42 return count;96.43 }96.44 @@ -71,98 +71,98 @@96.45 uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);96.46 int count = 0;96.47 while(1) {96.48 - uint32_t entry = *tile_list++;96.49 - if( entry >> 28 == 0x0F ) {96.50 - break;96.51 - } else if( entry >> 28 == 0x0E ) {96.52 - tile_list = (uint32_t *)(video_base+(entry&0x007FFFFF));96.53 - } else {96.54 - uint32_t poly_addr = entry & 0x000FFFFF;96.55 - int is_modified = entry & 0x01000000;96.56 - int vertex_length = (entry >> 21) & 0x07;96.57 - int context_length = 3;96.58 - if( is_modified && pvr2_scene.full_shadow ) {96.59 - context_length = 5;96.60 - vertex_length *= 2 ;96.61 - }96.62 - vertex_length += 3;96.63 + uint32_t entry = *tile_list++;96.64 + if( entry >> 28 == 0x0F ) {96.65 + break;96.66 + } else if( entry >> 28 == 0x0E ) {96.67 + tile_list = (uint32_t *)(video_base+(entry&0x007FFFFF));96.68 + } else {96.69 + uint32_t poly_addr = entry & 0x000FFFFF;96.70 + int is_modified = entry & 0x01000000;96.71 + int vertex_length = (entry >> 21) & 0x07;96.72 + int context_length = 3;96.73 + if( is_modified && pvr2_scene.full_shadow ) {96.74 + context_length = 5;96.75 + vertex_length *= 2 ;96.76 + }96.77 + vertex_length += 3;96.79 - if( (entry & 0xE0000000) == 0x80000000 ) {96.80 - /* Triangle(s) */96.81 - int strip_count = ((entry >> 25) & 0x0F)+1;96.82 - int polygon_length = 3 * vertex_length + context_length;96.83 - int i;96.84 - for( i=0; i<strip_count; i++ ) {96.85 - struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];96.86 - triangles[count].poly = poly;96.87 - triangles[count].triangle_num = 0;96.88 - triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,96.89 - pvr2_scene.vertex_array[poly->vertex_index+1].z,96.90 - pvr2_scene.vertex_array[poly->vertex_index+2].z );96.91 - poly_addr += polygon_length;96.92 - count++;96.93 - }96.94 - } else if( (entry & 0xE0000000) == 0xA0000000 ) {96.95 - /* Quad(s) */96.96 - int strip_count = ((entry >> 25) & 0x0F)+1;96.97 - int polygon_length = 4 * vertex_length + context_length;96.98 - int i;96.99 - for( i=0; i<strip_count; i++ ) {96.100 - struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];96.101 - triangles[count].poly = poly;96.102 - triangles[count].triangle_num = 0;96.103 - triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,96.104 - pvr2_scene.vertex_array[poly->vertex_index+1].z,96.105 - pvr2_scene.vertex_array[poly->vertex_index+2].z );96.106 - count++;96.107 - triangles[count].poly = poly;96.108 - triangles[count].triangle_num = 1;96.109 - triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+1].z,96.110 - pvr2_scene.vertex_array[poly->vertex_index+2].z,96.111 - pvr2_scene.vertex_array[poly->vertex_index+3].z );96.112 - count++;96.113 - poly_addr += polygon_length;96.114 - }96.115 - } else {96.116 - /* Polygon */96.117 - int i;96.118 - struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];96.119 - for( i=0; i<6; i++ ) {96.120 - if( entry & (0x40000000>>i) ) {96.121 - triangles[count].poly = poly;96.122 - triangles[count].triangle_num = i;96.123 - triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+i].z,96.124 - pvr2_scene.vertex_array[poly->vertex_index+i+1].z,96.125 - pvr2_scene.vertex_array[poly->vertex_index+i+2].z );96.126 - count++;96.127 - }96.128 - }96.129 - }96.130 - }96.131 + if( (entry & 0xE0000000) == 0x80000000 ) {96.132 + /* Triangle(s) */96.133 + int strip_count = ((entry >> 25) & 0x0F)+1;96.134 + int polygon_length = 3 * vertex_length + context_length;96.135 + int i;96.136 + for( i=0; i<strip_count; i++ ) {96.137 + struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];96.138 + triangles[count].poly = poly;96.139 + triangles[count].triangle_num = 0;96.140 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,96.141 + pvr2_scene.vertex_array[poly->vertex_index+1].z,96.142 + pvr2_scene.vertex_array[poly->vertex_index+2].z );96.143 + poly_addr += polygon_length;96.144 + count++;96.145 + }96.146 + } else if( (entry & 0xE0000000) == 0xA0000000 ) {96.147 + /* Quad(s) */96.148 + int strip_count = ((entry >> 25) & 0x0F)+1;96.149 + int polygon_length = 4 * vertex_length + context_length;96.150 + int i;96.151 + for( i=0; i<strip_count; i++ ) {96.152 + struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];96.153 + triangles[count].poly = poly;96.154 + triangles[count].triangle_num = 0;96.155 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,96.156 + pvr2_scene.vertex_array[poly->vertex_index+1].z,96.157 + pvr2_scene.vertex_array[poly->vertex_index+2].z );96.158 + count++;96.159 + triangles[count].poly = poly;96.160 + triangles[count].triangle_num = 1;96.161 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+1].z,96.162 + pvr2_scene.vertex_array[poly->vertex_index+2].z,96.163 + pvr2_scene.vertex_array[poly->vertex_index+3].z );96.164 + count++;96.165 + poly_addr += polygon_length;96.166 + }96.167 + } else {96.168 + /* Polygon */96.169 + int i;96.170 + struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];96.171 + for( i=0; i<6; i++ ) {96.172 + if( entry & (0x40000000>>i) ) {96.173 + triangles[count].poly = poly;96.174 + triangles[count].triangle_num = i;96.175 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+i].z,96.176 + pvr2_scene.vertex_array[poly->vertex_index+i+1].z,96.177 + pvr2_scene.vertex_array[poly->vertex_index+i+2].z );96.178 + count++;96.179 + }96.180 + }96.181 + }96.182 + }96.183 }96.184 return count;96.185 }96.187 void sort_render_triangles( struct sort_triangle *triangles, int num_triangles,96.188 - int render_mode )96.189 + int render_mode )96.190 {96.191 int i;96.192 for( i=0; i<num_triangles; i++ ) {96.193 - struct polygon_struct *poly = triangles[i].poly;96.194 - if( poly->tex_id != -1 ) {96.195 - glBindTexture(GL_TEXTURE_2D, poly->tex_id);96.196 - }96.197 - render_set_context( poly->context, RENDER_NORMAL );96.198 - glDepthMask(GL_FALSE);96.199 - glDepthFunc(GL_GEQUAL);96.200 - /* Fix cull direction */96.201 - if( triangles[i].triangle_num & 1 ) {96.202 - glCullFace(GL_FRONT);96.203 - } else {96.204 - glCullFace(GL_BACK);96.205 - }96.206 -96.207 - glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index + triangles[i].triangle_num, 3 );96.208 + struct polygon_struct *poly = triangles[i].poly;96.209 + if( poly->tex_id != -1 ) {96.210 + glBindTexture(GL_TEXTURE_2D, poly->tex_id);96.211 + }96.212 + render_set_context( poly->context, RENDER_NORMAL );96.213 + glDepthMask(GL_FALSE);96.214 + glDepthFunc(GL_GEQUAL);96.215 + /* Fix cull direction */96.216 + if( triangles[i].triangle_num & 1 ) {96.217 + glCullFace(GL_FRONT);96.218 + } else {96.219 + glCullFace(GL_BACK);96.220 + }96.221 +96.222 + glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index + triangles[i].triangle_num, 3 );96.223 }96.224 }96.226 @@ -177,24 +177,24 @@96.227 {96.228 qsort( triangles, num_triangles, sizeof(struct sort_triangle), compare_triangles );96.229 }96.230 -96.231 +96.232 void render_autosort_tile( pvraddr_t tile_entry, int render_mode )96.233 {96.234 int num_triangles = sort_count_triangles(tile_entry);96.235 if( num_triangles == 0 ) {96.236 - return; /* nothing to do */96.237 + return; /* nothing to do */96.238 } else if( num_triangles == 1 ) { /* Triangle can hardly overlap with itself */96.239 - gl_render_tilelist(tile_entry);96.240 + gl_render_tilelist(tile_entry);96.241 } else { /* Ooh boy here we go... */96.242 - struct sort_triangle triangles[num_triangles+1];96.243 - // Reserve space for num_triangles / 2 * 4 vertexes (maximum possible number of96.244 - // quad vertices)96.245 - triangles[num_triangles].poly = (void *)SENTINEL;96.246 - int extracted_triangles = sort_extract_triangles(tile_entry, triangles);96.247 - assert( extracted_triangles == num_triangles );96.248 - sort_triangles( triangles, num_triangles );96.249 - sort_render_triangles(triangles, num_triangles, render_mode);96.250 - glCullFace(GL_BACK);96.251 - assert( triangles[num_triangles].poly == (void *)SENTINEL );96.252 + struct sort_triangle triangles[num_triangles+1];96.253 + // Reserve space for num_triangles / 2 * 4 vertexes (maximum possible number of96.254 + // quad vertices)96.255 + triangles[num_triangles].poly = (void *)SENTINEL;96.256 + int extracted_triangles = sort_extract_triangles(tile_entry, triangles);96.257 + assert( extracted_triangles == num_triangles );96.258 + sort_triangles( triangles, num_triangles );96.259 + sort_render_triangles(triangles, num_triangles, render_mode);96.260 + glCullFace(GL_BACK);96.261 + assert( triangles[num_triangles].poly == (void *)SENTINEL );96.262 }96.263 }
97.1 --- a/src/pvr2/scene.c Mon Jul 14 07:42:45 2008 +000097.2 +++ b/src/pvr2/scene.c Mon Jul 14 07:44:42 2008 +000097.3 @@ -76,16 +76,16 @@97.4 {97.5 if( !vbo_init ) {97.6 #ifdef ENABLE_VERTEX_BUFFER97.7 - if( isGLVertexBufferSupported() ) {97.8 - vbo_supported = TRUE;97.9 - pvr2_scene.vbo_id = 1;97.10 - }97.11 + if( isGLVertexBufferSupported() ) {97.12 + vbo_supported = TRUE;97.13 + pvr2_scene.vbo_id = 1;97.14 + }97.15 #endif97.16 - pvr2_scene.vertex_array = NULL;97.17 - pvr2_scene.vertex_array_size = 0;97.18 - pvr2_scene.poly_array = g_malloc( MAX_POLY_BUFFER_SIZE );97.19 - pvr2_scene.buf_to_poly_map = g_malloc0( BUF_POLY_MAP_SIZE );97.20 - vbo_init = TRUE;97.21 + pvr2_scene.vertex_array = NULL;97.22 + pvr2_scene.vertex_array_size = 0;97.23 + pvr2_scene.poly_array = g_malloc( MAX_POLY_BUFFER_SIZE );97.24 + pvr2_scene.buf_to_poly_map = g_malloc0( BUF_POLY_MAP_SIZE );97.25 + vbo_init = TRUE;97.26 }97.27 }97.29 @@ -103,13 +103,13 @@97.30 {97.31 #ifdef ENABLE_VERTEX_BUFFER97.32 if( vbo_supported ) {97.33 - glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );97.34 - glDeleteBuffersARB( 1, &pvr2_scene.vbo_id );97.35 - pvr2_scene.vbo_id = 0;97.36 + glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );97.37 + glDeleteBuffersARB( 1, &pvr2_scene.vbo_id );97.38 + pvr2_scene.vbo_id = 0;97.39 } else {97.40 #endif97.41 - g_free( pvr2_scene.vertex_array );97.42 - pvr2_scene.vertex_array = NULL;97.43 + g_free( pvr2_scene.vertex_array );97.44 + pvr2_scene.vertex_array = NULL;97.45 #ifdef ENABLE_VERTEX_BUFFER97.46 }97.47 #endif97.48 @@ -128,23 +128,23 @@97.49 #ifdef ENABLE_VERTEX_BUFFER97.50 if( vbo_supported ) {97.51 glGetError();97.52 - glBindBufferARB( GL_ARRAY_BUFFER_ARB, pvr2_scene.vbo_id );97.53 - if( size > pvr2_scene.vertex_array_size ) {97.54 - glBufferDataARB( GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB );97.55 - int status = glGetError();97.56 - if( status != 0 ) {97.57 - fprintf( stderr, "Error %08X allocating vertex buffer\n", status );97.58 - abort();97.59 - }97.60 - pvr2_scene.vertex_array_size = size;97.61 - }97.62 - pvr2_scene.vertex_array = glMapBufferARB( GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB );97.63 - assert(pvr2_scene.vertex_array != NULL );97.64 + glBindBufferARB( GL_ARRAY_BUFFER_ARB, pvr2_scene.vbo_id );97.65 + if( size > pvr2_scene.vertex_array_size ) {97.66 + glBufferDataARB( GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB );97.67 + int status = glGetError();97.68 + if( status != 0 ) {97.69 + fprintf( stderr, "Error %08X allocating vertex buffer\n", status );97.70 + abort();97.71 + }97.72 + pvr2_scene.vertex_array_size = size;97.73 + }97.74 + pvr2_scene.vertex_array = glMapBufferARB( GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB );97.75 + assert(pvr2_scene.vertex_array != NULL );97.76 } else {97.77 #endif97.78 - if( size > pvr2_scene.vertex_array_size ) {97.79 - pvr2_scene.vertex_array = g_realloc( pvr2_scene.vertex_array, size );97.80 - }97.81 + if( size > pvr2_scene.vertex_array_size ) {97.82 + pvr2_scene.vertex_array = g_realloc( pvr2_scene.vertex_array, size );97.83 + }97.84 #ifdef ENABLE_VERTEX_BUFFER97.85 }97.86 #endif97.87 @@ -155,10 +155,10 @@97.88 {97.89 #ifdef ENABLE_VERTEX_BUFFER97.90 if( vbo_supported ) {97.91 - pvr2_scene.vertex_array = NULL;97.92 - return glUnmapBufferARB( GL_ARRAY_BUFFER_ARB );97.93 + pvr2_scene.vertex_array = NULL;97.94 + return glUnmapBufferARB( GL_ARRAY_BUFFER_ARB );97.95 } else {97.96 - return TRUE;97.97 + return TRUE;97.98 }97.99 #else97.100 return TRUE;97.101 @@ -200,8 +200,8 @@97.102 * the normal vertex, half the vertex length for the modified vertex.97.103 */97.104 static void pvr2_decode_render_vertex( struct vertex_struct *vert, uint32_t poly1,97.105 - uint32_t poly2, uint32_t *pvr2_data,97.106 - int modify_offset )97.107 + uint32_t poly2, uint32_t *pvr2_data,97.108 + int modify_offset )97.109 {97.110 gboolean force_alpha = !POLY2_ALPHA_ENABLE(poly2);97.111 union pvr2_data_type {97.112 @@ -265,8 +265,8 @@97.113 */97.114 static void scene_compute_vertexes( struct vertex_struct *result,97.115 int result_count,97.116 - struct vertex_struct *input,97.117 - gboolean is_solid_shaded )97.118 + struct vertex_struct *input,97.119 + gboolean is_solid_shaded )97.120 {97.121 int i,j;97.122 float sx = input[2].x - input[1].x;97.123 @@ -330,7 +330,7 @@97.124 }97.126 static void scene_add_vertexes( pvraddr_t poly_idx, int vertex_length,97.127 - gboolean is_modified )97.128 + gboolean is_modified )97.129 {97.130 struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_idx];97.131 uint32_t *ptr = &pvr2_scene.pvr2_pbuf[poly_idx];97.132 @@ -361,7 +361,7 @@97.133 }97.135 static void scene_add_quad_vertexes( pvraddr_t poly_idx, int vertex_length,97.136 - gboolean is_modified )97.137 + gboolean is_modified )97.138 {97.139 struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_idx];97.140 uint32_t *ptr = &pvr2_scene.pvr2_pbuf[poly_idx];97.141 @@ -369,41 +369,41 @@97.142 unsigned int i;97.144 if( poly->vertex_index == -1 ) {97.145 - // Construct it locally and copy to the vertex buffer, as the VBO is97.146 - // allowed to be horribly slow for reads (ie it could be direct-mapped97.147 - // vram).97.148 - struct vertex_struct quad[4];97.149 -97.150 - assert( poly != NULL );97.151 - assert( pvr2_scene.vertex_index + poly->vertex_count <= pvr2_scene.vertex_count );97.152 - ptr += (is_modified ? 5 : 3 );97.153 - poly->vertex_index = pvr2_scene.vertex_index;97.154 - for( i=0; i<4; i++ ) {97.155 - pvr2_decode_render_vertex( &quad[i], context[0], context[1], ptr, 0 );97.156 - ptr += vertex_length;97.157 - }97.158 - scene_compute_vertexes( &quad[3], 1, &quad[0], !POLY1_GOURAUD_SHADED(context[0]) );97.159 - // Swap last two vertexes (quad arrangement => tri strip arrangement)97.160 - memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index], quad, sizeof(struct vertex_struct)*2 );97.161 - memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+2], &quad[3], sizeof(struct vertex_struct) );97.162 - memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+3], &quad[2], sizeof(struct vertex_struct) );97.163 - pvr2_scene.vertex_index += 4;97.164 -97.165 - if( is_modified ) {97.166 - int mod_offset = (vertex_length - 3)>>1;97.167 - assert( pvr2_scene.vertex_index + poly->vertex_count <= pvr2_scene.vertex_count );97.168 - ptr = &pvr2_scene.pvr2_pbuf[poly_idx] + 5;97.169 - poly->mod_vertex_index = pvr2_scene.vertex_index;97.170 - for( i=0; i<4; i++ ) {97.171 - pvr2_decode_render_vertex( &quad[4], context[0], context[3], ptr, mod_offset );97.172 - ptr += vertex_length;97.173 - }97.174 + // Construct it locally and copy to the vertex buffer, as the VBO is97.175 + // allowed to be horribly slow for reads (ie it could be direct-mapped97.176 + // vram).97.177 + struct vertex_struct quad[4];97.178 +97.179 + assert( poly != NULL );97.180 + assert( pvr2_scene.vertex_index + poly->vertex_count <= pvr2_scene.vertex_count );97.181 + ptr += (is_modified ? 5 : 3 );97.182 + poly->vertex_index = pvr2_scene.vertex_index;97.183 + for( i=0; i<4; i++ ) {97.184 + pvr2_decode_render_vertex( &quad[i], context[0], context[1], ptr, 0 );97.185 + ptr += vertex_length;97.186 + }97.187 scene_compute_vertexes( &quad[3], 1, &quad[0], !POLY1_GOURAUD_SHADED(context[0]) );97.188 - memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index], quad, sizeof(struct vertex_struct)*2 );97.189 - memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+2], &quad[3], sizeof(struct vertex_struct) );97.190 - memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+3], &quad[2], sizeof(struct vertex_struct) );97.191 - pvr2_scene.vertex_index += 4;97.192 - }97.193 + // Swap last two vertexes (quad arrangement => tri strip arrangement)97.194 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index], quad, sizeof(struct vertex_struct)*2 );97.195 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+2], &quad[3], sizeof(struct vertex_struct) );97.196 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+3], &quad[2], sizeof(struct vertex_struct) );97.197 + pvr2_scene.vertex_index += 4;97.198 +97.199 + if( is_modified ) {97.200 + int mod_offset = (vertex_length - 3)>>1;97.201 + assert( pvr2_scene.vertex_index + poly->vertex_count <= pvr2_scene.vertex_count );97.202 + ptr = &pvr2_scene.pvr2_pbuf[poly_idx] + 5;97.203 + poly->mod_vertex_index = pvr2_scene.vertex_index;97.204 + for( i=0; i<4; i++ ) {97.205 + pvr2_decode_render_vertex( &quad[4], context[0], context[3], ptr, mod_offset );97.206 + ptr += vertex_length;97.207 + }97.208 + scene_compute_vertexes( &quad[3], 1, &quad[0], !POLY1_GOURAUD_SHADED(context[0]) );97.209 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index], quad, sizeof(struct vertex_struct)*2 );97.210 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+2], &quad[3], sizeof(struct vertex_struct) );97.211 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+3], &quad[2], sizeof(struct vertex_struct) );97.212 + pvr2_scene.vertex_index += 4;97.213 + }97.214 }97.215 }97.217 @@ -476,54 +476,54 @@97.218 {97.219 uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);97.220 do {97.221 - uint32_t entry = *tile_list++;97.222 - if( entry >> 28 == 0x0F ) {97.223 - break;97.224 - } else if( entry >> 28 == 0x0E ) {97.225 - tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));97.226 - } else {97.227 - pvraddr_t polyaddr = entry&0x000FFFFF;97.228 - int is_modified = (entry & 0x01000000) && pvr2_scene.full_shadow;97.229 - int vertex_length = (entry >> 21) & 0x07;97.230 - int context_length = 3;97.231 - if( is_modified ) {97.232 - context_length = 5;97.233 - vertex_length <<=1 ;97.234 - }97.235 - vertex_length += 3;97.236 -97.237 - if( (entry & 0xE0000000) == 0x80000000 ) {97.238 - /* Triangle(s) */97.239 - int strip_count = ((entry >> 25) & 0x0F)+1;97.240 - int polygon_length = 3 * vertex_length + context_length;97.241 - int i;97.242 - for( i=0; i<strip_count; i++ ) {97.243 - scene_add_vertexes( polyaddr, vertex_length, is_modified );97.244 - polyaddr += polygon_length;97.245 - }97.246 - } else if( (entry & 0xE0000000) == 0xA0000000 ) {97.247 - /* Sprite(s) */97.248 - int strip_count = ((entry >> 25) & 0x0F)+1;97.249 - int polygon_length = 4 * vertex_length + context_length;97.250 - int i;97.251 - for( i=0; i<strip_count; i++ ) {97.252 - scene_add_quad_vertexes( polyaddr, vertex_length, is_modified );97.253 - polyaddr += polygon_length;97.254 - }97.255 - } else {97.256 - /* Polygon */97.257 - int i, last = -1;97.258 - for( i=5; i>=0; i-- ) {97.259 - if( entry & (0x40000000>>i) ) {97.260 - last = i;97.261 - break;97.262 - }97.263 - }97.264 - if( last != -1 ) {97.265 - scene_add_vertexes( polyaddr, vertex_length, is_modified );97.266 - }97.267 - }97.268 - }97.269 + uint32_t entry = *tile_list++;97.270 + if( entry >> 28 == 0x0F ) {97.271 + break;97.272 + } else if( entry >> 28 == 0x0E ) {97.273 + tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));97.274 + } else {97.275 + pvraddr_t polyaddr = entry&0x000FFFFF;97.276 + int is_modified = (entry & 0x01000000) && pvr2_scene.full_shadow;97.277 + int vertex_length = (entry >> 21) & 0x07;97.278 + int context_length = 3;97.279 + if( is_modified ) {97.280 + context_length = 5;97.281 + vertex_length <<=1 ;97.282 + }97.283 + vertex_length += 3;97.284 +97.285 + if( (entry & 0xE0000000) == 0x80000000 ) {97.286 + /* Triangle(s) */97.287 + int strip_count = ((entry >> 25) & 0x0F)+1;97.288 + int polygon_length = 3 * vertex_length + context_length;97.289 + int i;97.290 + for( i=0; i<strip_count; i++ ) {97.291 + scene_add_vertexes( polyaddr, vertex_length, is_modified );97.292 + polyaddr += polygon_length;97.293 + }97.294 + } else if( (entry & 0xE0000000) == 0xA0000000 ) {97.295 + /* Sprite(s) */97.296 + int strip_count = ((entry >> 25) & 0x0F)+1;97.297 + int polygon_length = 4 * vertex_length + context_length;97.298 + int i;97.299 + for( i=0; i<strip_count; i++ ) {97.300 + scene_add_quad_vertexes( polyaddr, vertex_length, is_modified );97.301 + polyaddr += polygon_length;97.302 + }97.303 + } else {97.304 + /* Polygon */97.305 + int i, last = -1;97.306 + for( i=5; i>=0; i-- ) {97.307 + if( entry & (0x40000000>>i) ) {97.308 + last = i;97.309 + break;97.310 + }97.311 + }97.312 + if( last != -1 ) {97.313 + scene_add_vertexes( polyaddr, vertex_length, is_modified );97.314 + }97.315 + }97.316 + }97.317 } while( 1 );97.318 }97.320 @@ -553,12 +553,12 @@97.322 poly->next = NULL;97.323 pvr2_scene.bkgnd_poly = poly;97.324 -97.325 +97.326 struct vertex_struct base_vertexes[3];97.327 uint32_t *ptr = context + context_length;97.328 for( i=0; i<3; i++ ) {97.329 pvr2_decode_render_vertex( &base_vertexes[i], context[0], context[1],97.330 - ptr, 0 );97.331 + ptr, 0 );97.332 ptr += vertex_length;97.333 }97.334 struct vertex_struct *result_vertexes = &pvr2_scene.vertex_array[poly->vertex_index];97.335 @@ -573,7 +573,7 @@97.336 ptr = context + context_length;97.337 for( i=0; i<3; i++ ) {97.338 pvr2_decode_render_vertex( &base_vertexes[i], context[0], context[3],97.339 - ptr, mod_offset );97.340 + ptr, mod_offset );97.341 ptr += vertex_length;97.342 }97.343 result_vertexes = &pvr2_scene.vertex_array[poly->mod_vertex_index];97.344 @@ -583,7 +583,7 @@97.345 result_vertexes[2].y = result_vertexes[3].y = pvr2_scene.buffer_height;97.346 scene_compute_vertexes( result_vertexes, 4, base_vertexes, !POLY1_GOURAUD_SHADED(context[0]) );97.347 }97.348 -97.349 +97.350 }97.353 @@ -677,9 +677,9 @@97.354 segment++;97.355 }97.356 } while( (control & SEGMENT_END) == 0 );97.357 -97.358 +97.359 scene_extract_background();97.360 -97.361 +97.362 vertex_buffer_unmap();97.363 }97.365 @@ -692,33 +692,33 @@97.367 fprintf( f, "Polygons: %d\n", pvr2_scene.poly_count );97.368 for( i=0; i<pvr2_scene.poly_count; i++ ) {97.369 - struct polygon_struct *poly = &pvr2_scene.poly_array[i];97.370 - fprintf( f, " %08X ", ((unsigned char *)poly->context) - video_base );97.371 - switch( poly->vertex_count ) {97.372 - case 3: fprintf( f, "Tri " ); break;97.373 - case 4: fprintf( f, "Quad " ); break;97.374 - default: fprintf( f,"%d-Strip ", poly->vertex_count-2 ); break;97.375 - }97.376 - fprintf( f, "%08X %08X %08X ", poly->context[0], poly->context[1], poly->context[2] );97.377 - if( poly->mod_vertex_index != -1 ) {97.378 - fprintf( f, "%08X %08X\n", poly->context[3], poly->context[5] );97.379 - } else {97.380 - fprintf( f, "\n" );97.381 - }97.382 -97.383 - for( j=0; j<poly->vertex_count; j++ ) {97.384 - struct vertex_struct *v = &pvr2_scene.vertex_array[poly->vertex_index+j];97.385 - fprintf( f, " %.5f %.5f %.5f, (%.5f,%.5f) %08X %08X\n", v->x, v->y, v->z, v->u, v->v,97.386 - v->rgba, v->offset_rgba );97.387 - }97.388 - if( poly->mod_vertex_index != -1 ) {97.389 - fprintf( f, " ---\n" );97.390 - for( j=0; j<poly->vertex_count; j++ ) {97.391 - struct vertex_struct *v = &pvr2_scene.vertex_array[poly->mod_vertex_index+j];97.392 - fprintf( f, " %.5f %.5f %.5f, (%.5f,%.5f) %08X %08X\n", v->x, v->y, v->z, v->u, v->v,97.393 - v->rgba, v->offset_rgba );97.394 - }97.395 - }97.396 + struct polygon_struct *poly = &pvr2_scene.poly_array[i];97.397 + fprintf( f, " %08X ", ((unsigned char *)poly->context) - video_base );97.398 + switch( poly->vertex_count ) {97.399 + case 3: fprintf( f, "Tri " ); break;97.400 + case 4: fprintf( f, "Quad " ); break;97.401 + default: fprintf( f,"%d-Strip ", poly->vertex_count-2 ); break;97.402 + }97.403 + fprintf( f, "%08X %08X %08X ", poly->context[0], poly->context[1], poly->context[2] );97.404 + if( poly->mod_vertex_index != -1 ) {97.405 + fprintf( f, "%08X %08X\n", poly->context[3], poly->context[5] );97.406 + } else {97.407 + fprintf( f, "\n" );97.408 + }97.409 +97.410 + for( j=0; j<poly->vertex_count; j++ ) {97.411 + struct vertex_struct *v = &pvr2_scene.vertex_array[poly->vertex_index+j];97.412 + fprintf( f, " %.5f %.5f %.5f, (%.5f,%.5f) %08X %08X\n", v->x, v->y, v->z, v->u, v->v,97.413 + v->rgba, v->offset_rgba );97.414 + }97.415 + if( poly->mod_vertex_index != -1 ) {97.416 + fprintf( f, " ---\n" );97.417 + for( j=0; j<poly->vertex_count; j++ ) {97.418 + struct vertex_struct *v = &pvr2_scene.vertex_array[poly->mod_vertex_index+j];97.419 + fprintf( f, " %.5f %.5f %.5f, (%.5f,%.5f) %08X %08X\n", v->x, v->y, v->z, v->u, v->v,97.420 + v->rgba, v->offset_rgba );97.421 + }97.422 + }97.423 }97.425 }
98.1 --- a/src/pvr2/scene.h Mon Jul 14 07:42:45 2008 +000098.2 +++ b/src/pvr2/scene.h Mon Jul 14 07:44:42 2008 +000098.3 @@ -1,7 +1,7 @@98.4 /**98.5 * $Id$98.6 *98.7 - * PVR2 rendering functions (private)98.8 + * PVR2 scene description structure (pvr2-private)98.9 *98.10 * Copyright (c) 2005 Nathan Keynes.98.11 *98.12 @@ -16,8 +16,12 @@98.13 * GNU General Public License for more details.98.14 */98.16 -#ifndef lxdream_render_H98.17 -#define lxdream_render_H 198.18 +#ifndef lxdream_scene_H98.19 +#define lxdream_scene_H 198.20 +98.21 +#ifdef __cplusplus98.22 +extern "C" {98.23 +#endif98.25 /************************* Intermediate vertex buffer ************************/98.27 @@ -140,5 +144,8 @@98.28 */98.29 extern struct pvr2_scene_struct pvr2_scene;98.31 +#ifdef __cplusplus98.32 +}98.33 +#endif98.35 -#endif /* !lxdream_render_H */98.36 +#endif /* !lxdream_scene_H */
99.1 --- a/src/pvr2/tacore.c Mon Jul 14 07:42:45 2008 +000099.2 +++ b/src/pvr2/tacore.c Mon Jul 14 07:44:42 2008 +000099.3 @@ -141,8 +141,8 @@99.4 int32_t current_vertex_type;99.5 uint32_t accept_vertexes; /* 0 = NO, 1 = YES */99.6 int32_t vertex_count; /* index of last start-vertex seen, or -1 if no vertexes99.7 - * are present99.8 - */99.9 + * are present99.10 + */99.11 uint32_t max_vertex; /* Maximum number of vertexes in the current polygon (3/4/6/8) */99.12 uint32_t current_list_type;99.13 uint32_t current_tile_matrix; /* Memory location of the first tile for the current list. */99.14 @@ -189,7 +189,7 @@99.15 int pvr2_ta_load_state( FILE *f )99.16 {99.17 if( fread( &ta_status, sizeof(ta_status), 1, f ) != 1 )99.18 - return 1;99.19 + return 1;99.20 return 0;99.21 }99.23 @@ -220,7 +220,7 @@99.24 MMIO_WRITE( PVR2, TA_POLYPOS, MMIO_READ( PVR2, TA_POLYBASE ) );99.25 uint32_t plistpos = MMIO_READ( PVR2, TA_LISTBASE ) >> 2;99.26 if( ta_status.tilelist_dir == TA_GROW_DOWN ) {99.27 - plistpos -= ta_status.tilelist_size;99.28 + plistpos -= ta_status.tilelist_size;99.29 }99.30 MMIO_WRITE( PVR2, TA_LISTPOS, plistpos );99.31 ta_status.tilelist_start = plistpos;99.32 @@ -231,28 +231,28 @@99.33 int ai,ri,gi,bi;99.35 if( TA_IS_INF(a) ) {99.36 - ai = 255;99.37 + ai = 255;99.38 } else {99.39 - ai = 256 * CLAMP(a,0.0,1.0) - 1;99.40 - if( ai < 0 ) ai = 0;99.41 + ai = 256 * CLAMP(a,0.0,1.0) - 1;99.42 + if( ai < 0 ) ai = 0;99.43 }99.44 if( TA_IS_INF(r) ) {99.45 - ri = 255;99.46 + ri = 255;99.47 } else {99.48 - ri = 256 * CLAMP(r,0.0,1.0) - 1;99.49 - if( ri < 0 ) ri = 0;99.50 + ri = 256 * CLAMP(r,0.0,1.0) - 1;99.51 + if( ri < 0 ) ri = 0;99.52 }99.53 if( TA_IS_INF(g) ) {99.54 - gi = 255;99.55 + gi = 255;99.56 } else {99.57 - gi = 256 * CLAMP(g,0.0,1.0) - 1;99.58 - if( gi < 0 ) gi = 0;99.59 + gi = 256 * CLAMP(g,0.0,1.0) - 1;99.60 + if( gi < 0 ) gi = 0;99.61 }99.62 if( TA_IS_INF(b) ) {99.63 - bi = 255;99.64 + bi = 255;99.65 } else {99.66 - bi = 256 * CLAMP(b,0.0,1.0) - 1;99.67 - if( bi < 0 ) bi = 0;99.68 + bi = 256 * CLAMP(b,0.0,1.0) - 1;99.69 + if( bi < 0 ) bi = 0;99.70 }99.71 return (ai << 24) | (ri << 16) | (gi << 8) | bi;99.72 }99.73 @@ -260,14 +260,14 @@99.74 static uint32_t parse_intensity_colour( uint32_t base, float intensity )99.75 {99.76 unsigned int i = (unsigned int)(256 * CLAMP(intensity, 0.0,1.0));99.77 -99.78 +99.79 return99.80 - (((((base & 0xFF) * i) & 0xFF00) |99.81 - (((base & 0xFF00) * i) & 0xFF0000) |99.82 - (((base & 0xFF0000) * i) & 0xFF000000)) >> 8) |99.83 - (base & 0xFF000000);99.84 + (((((base & 0xFF) * i) & 0xFF00) |99.85 + (((base & 0xFF00) * i) & 0xFF0000) |99.86 + (((base & 0xFF0000) * i) & 0xFF000000)) >> 8) |99.87 + (base & 0xFF000000);99.88 }99.89 -99.90 +99.91 /**99.92 * Initialize the specified TA list.99.93 */99.94 @@ -283,31 +283,31 @@99.95 * Don't ask me why, it just does...99.96 */99.97 if( ((ta_status.tilelist_dir == TA_GROW_DOWN && list_end <= tile_matrix) ||99.98 - (ta_status.tilelist_dir == TA_GROW_UP && list_end >= tile_matrix )) &&99.99 - listtype <= TA_LIST_PUNCH_OUT ) {99.100 - int i;99.101 - uint32_t *p;99.102 - for( i=0; i < listtype; i++ ) {99.103 - int size = tilematrix_sizes[(config & 0x03)] << 2;99.104 - ta_status.current_tile_matrix += ta_status.width * ta_status.height * size;99.105 - config >>= 4;99.106 - }99.107 - ta_status.current_tile_size = tilematrix_sizes[(config & 0x03)];99.108 + (ta_status.tilelist_dir == TA_GROW_UP && list_end >= tile_matrix )) &&99.109 + listtype <= TA_LIST_PUNCH_OUT ) {99.110 + int i;99.111 + uint32_t *p;99.112 + for( i=0; i < listtype; i++ ) {99.113 + int size = tilematrix_sizes[(config & 0x03)] << 2;99.114 + ta_status.current_tile_matrix += ta_status.width * ta_status.height * size;99.115 + config >>= 4;99.116 + }99.117 + ta_status.current_tile_size = tilematrix_sizes[(config & 0x03)];99.119 - /* Initialize each tile to 0xF0000000 */99.120 - if( ta_status.current_tile_size != 0 ) {99.121 - p = (uint32_t *)(video_base + ta_status.current_tile_matrix);99.122 - for( i=0; i< ta_status.width * ta_status.height; i++ ) {99.123 - *p = 0xF0000000;99.124 - p += ta_status.current_tile_size;99.125 - }99.126 - }99.127 + /* Initialize each tile to 0xF0000000 */99.128 + if( ta_status.current_tile_size != 0 ) {99.129 + p = (uint32_t *)(video_base + ta_status.current_tile_matrix);99.130 + for( i=0; i< ta_status.width * ta_status.height; i++ ) {99.131 + *p = 0xF0000000;99.132 + p += ta_status.current_tile_size;99.133 + }99.134 + }99.135 } else {99.136 - ta_status.current_tile_size = 0;99.137 + ta_status.current_tile_size = 0;99.138 }99.140 if( tile_matrix == list_end ) {99.141 - ta_status.current_tile_size = 0;99.142 + ta_status.current_tile_size = 0;99.143 }99.145 ta_status.state = STATE_IN_LIST;99.146 @@ -316,12 +316,12 @@99.147 }99.149 static int list_events[5] = {EVENT_PVR_OPAQUE_DONE, EVENT_PVR_OPAQUEMOD_DONE,99.150 - EVENT_PVR_TRANS_DONE, EVENT_PVR_TRANSMOD_DONE,99.151 - EVENT_PVR_PUNCHOUT_DONE };99.152 + EVENT_PVR_TRANS_DONE, EVENT_PVR_TRANSMOD_DONE,99.153 + EVENT_PVR_PUNCHOUT_DONE };99.155 static void ta_end_list() {99.156 if( ta_status.current_list_type != TA_LIST_NONE ) {99.157 - asic_event( list_events[ta_status.current_list_type] );99.158 + asic_event( list_events[ta_status.current_list_type] );99.159 }99.160 ta_status.current_list_type = TA_LIST_NONE;99.161 ta_status.current_vertex_type = TA_VERTEX_LISTLESS;99.162 @@ -348,15 +348,15 @@99.163 int end = MMIO_READ( PVR2, TA_POLYEND );99.164 uint32_t *target = (uint32_t *)(video_base + posn);99.165 for( rv=0; rv < length; rv++ ) {99.166 - if( posn == end ) {99.167 - asic_event( EVENT_PVR_PRIM_ALLOC_FAIL );99.168 - // ta_status.state = STATE_ERROR;99.169 - break;99.170 - }99.171 - if( posn < PVR2_RAM_SIZE ) {99.172 - *target++ = *data++;99.173 - }99.174 - posn += 4;99.175 + if( posn == end ) {99.176 + asic_event( EVENT_PVR_PRIM_ALLOC_FAIL );99.177 + // ta_status.state = STATE_ERROR;99.178 + break;99.179 + }99.180 + if( posn < PVR2_RAM_SIZE ) {99.181 + *target++ = *data++;99.182 + }99.183 + posn += 4;99.184 }99.186 MMIO_WRITE( PVR2, TA_POLYPOS, posn );99.187 @@ -374,41 +374,41 @@99.188 uint32_t limit = MMIO_READ( PVR2, TA_LISTEND ) >> 2;99.189 uint32_t newposn;99.190 if( ta_status.tilelist_dir == TA_GROW_DOWN ) {99.191 - newposn = posn - ta_status.tilelist_size;99.192 - if( posn == limit ) {99.193 - PVRRAM(posn<<2) = 0xF0000000;99.194 - PVRRAM(reference) = 0xE0000000 | (posn<<2);99.195 - return TA_NO_ALLOC;99.196 - } else if( posn < limit ) {99.197 - PVRRAM(reference) = 0xE0000000 | (posn<<2);99.198 - return TA_NO_ALLOC;99.199 - } else if( newposn <= limit ) {99.200 - } else if( newposn <= (limit + ta_status.tilelist_size) ) {99.201 - asic_event( EVENT_PVR_MATRIX_ALLOC_FAIL );99.202 - MMIO_WRITE( PVR2, TA_LISTPOS, newposn );99.203 - } else {99.204 - MMIO_WRITE( PVR2, TA_LISTPOS, newposn );99.205 - }99.206 - PVRRAM(reference) = 0xE0000000 | (posn<<2);99.207 - return posn << 2;99.208 + newposn = posn - ta_status.tilelist_size;99.209 + if( posn == limit ) {99.210 + PVRRAM(posn<<2) = 0xF0000000;99.211 + PVRRAM(reference) = 0xE0000000 | (posn<<2);99.212 + return TA_NO_ALLOC;99.213 + } else if( posn < limit ) {99.214 + PVRRAM(reference) = 0xE0000000 | (posn<<2);99.215 + return TA_NO_ALLOC;99.216 + } else if( newposn <= limit ) {99.217 + } else if( newposn <= (limit + ta_status.tilelist_size) ) {99.218 + asic_event( EVENT_PVR_MATRIX_ALLOC_FAIL );99.219 + MMIO_WRITE( PVR2, TA_LISTPOS, newposn );99.220 + } else {99.221 + MMIO_WRITE( PVR2, TA_LISTPOS, newposn );99.222 + }99.223 + PVRRAM(reference) = 0xE0000000 | (posn<<2);99.224 + return posn << 2;99.225 } else {99.226 - newposn = posn + ta_status.tilelist_size;99.227 - if( posn == limit ) {99.228 - PVRRAM(posn<<2) = 0xF0000000;99.229 - PVRRAM(reference) = 0xE0000000 | (posn<<2);99.230 - return TA_NO_ALLOC;99.231 - } else if ( posn > limit ) {99.232 - PVRRAM(reference) = 0xE0000000 | (posn<<2);99.233 - return TA_NO_ALLOC;99.234 - } else if( newposn >= limit ) {99.235 - } else if( newposn >= (limit - ta_status.tilelist_size) ) {99.236 - asic_event( EVENT_PVR_MATRIX_ALLOC_FAIL );99.237 - MMIO_WRITE( PVR2, TA_LISTPOS, newposn );99.238 - } else {99.239 - MMIO_WRITE( PVR2, TA_LISTPOS, newposn );99.240 - }99.241 - PVRRAM(reference) = 0xE0000000 | (posn<<2);99.242 - return posn << 2;99.243 + newposn = posn + ta_status.tilelist_size;99.244 + if( posn == limit ) {99.245 + PVRRAM(posn<<2) = 0xF0000000;99.246 + PVRRAM(reference) = 0xE0000000 | (posn<<2);99.247 + return TA_NO_ALLOC;99.248 + } else if ( posn > limit ) {99.249 + PVRRAM(reference) = 0xE0000000 | (posn<<2);99.250 + return TA_NO_ALLOC;99.251 + } else if( newposn >= limit ) {99.252 + } else if( newposn >= (limit - ta_status.tilelist_size) ) {99.253 + asic_event( EVENT_PVR_MATRIX_ALLOC_FAIL );99.254 + MMIO_WRITE( PVR2, TA_LISTPOS, newposn );99.255 + } else {99.256 + MMIO_WRITE( PVR2, TA_LISTPOS, newposn );99.257 + }99.258 + PVRRAM(reference) = 0xE0000000 | (posn<<2);99.259 + return posn << 2;99.260 }99.261 }99.263 @@ -423,67 +423,67 @@99.264 int i;99.266 if( ta_status.clip_mode == TA_POLYCMD_CLIP_OUTSIDE &&99.267 - x >= ta_status.clip.x1 && x <= ta_status.clip.x2 &&99.268 - y >= ta_status.clip.y1 && y <= ta_status.clip.y2 ) {99.269 - /* Tile clipped out */99.270 - return;99.271 + x >= ta_status.clip.x1 && x <= ta_status.clip.x2 &&99.272 + y >= ta_status.clip.y1 && y <= ta_status.clip.y2 ) {99.273 + /* Tile clipped out */99.274 + return;99.275 }99.277 if( (tile_entry & 0x80000000) &&99.278 - ta_status.last_triangle_bounds.x1 != -1 &&99.279 - ta_status.last_triangle_bounds.x1 <= x &&99.280 - ta_status.last_triangle_bounds.x2 >= x &&99.281 - ta_status.last_triangle_bounds.y1 <= y &&99.282 - ta_status.last_triangle_bounds.y2 >= y ) {99.283 - /* potential for triangle stacking */99.284 - lasttri = tile_entry & 0xE1E00000;99.285 + ta_status.last_triangle_bounds.x1 != -1 &&99.286 + ta_status.last_triangle_bounds.x1 <= x &&99.287 + ta_status.last_triangle_bounds.x2 >= x &&99.288 + ta_status.last_triangle_bounds.y1 <= y &&99.289 + ta_status.last_triangle_bounds.y2 >= y ) {99.290 + /* potential for triangle stacking */99.291 + lasttri = tile_entry & 0xE1E00000;99.292 }99.293 -99.294 -99.295 +99.296 +99.297 if( PVRRAM(tile) == 0xF0000000 ) {99.298 - PVRRAM(tile) = tile_entry;99.299 - PVRRAM(tile+4) = 0xF0000000;99.300 - return;99.301 + PVRRAM(tile) = tile_entry;99.302 + PVRRAM(tile+4) = 0xF0000000;99.303 + return;99.304 }99.306 while(1) {99.307 - value = PVRRAM(tile);99.308 - for( i=1; i<ta_status.current_tile_size; i++ ) {99.309 - tile += 4;99.310 - uint32_t nextval = PVRRAM(tile);99.311 - if( nextval == 0xF0000000 ) {99.312 - if( lasttri != 0 && lasttri == (value&0xE1E00000) ) {99.313 - int count = (value & 0x1E000000) + 0x02000000;99.314 - if( count < 0x20000000 ) {99.315 - PVRRAM(tile-4) = (value & 0xE1FFFFFF) | count;99.316 - return;99.317 - }99.318 - }99.319 - if( i < ta_status.current_tile_size-1 ) {99.320 - PVRRAM(tile) = tile_entry;99.321 - PVRRAM(tile+4) = 0xF0000000;99.322 - return;99.323 - }99.324 - }99.325 - value = nextval;99.326 - }99.327 + value = PVRRAM(tile);99.328 + for( i=1; i<ta_status.current_tile_size; i++ ) {99.329 + tile += 4;99.330 + uint32_t nextval = PVRRAM(tile);99.331 + if( nextval == 0xF0000000 ) {99.332 + if( lasttri != 0 && lasttri == (value&0xE1E00000) ) {99.333 + int count = (value & 0x1E000000) + 0x02000000;99.334 + if( count < 0x20000000 ) {99.335 + PVRRAM(tile-4) = (value & 0xE1FFFFFF) | count;99.336 + return;99.337 + }99.338 + }99.339 + if( i < ta_status.current_tile_size-1 ) {99.340 + PVRRAM(tile) = tile_entry;99.341 + PVRRAM(tile+4) = 0xF0000000;99.342 + return;99.343 + }99.344 + }99.345 + value = nextval;99.346 + }99.348 - if( value == 0xF0000000 ) {99.349 - tile = ta_alloc_tilelist(tile);99.350 - if( tile != TA_NO_ALLOC ) {99.351 - PVRRAM(tile) = tile_entry;99.352 - PVRRAM(tile+4) = 0xF0000000;99.353 - }99.354 - return;99.355 - } else if( (value & 0xFF000000) == 0xE0000000 ) {99.356 - value &= 0x00FFFFFF;99.357 - if( value == tilestart )99.358 - return; /* Loop */99.359 - tilestart = tile = value;99.360 - } else {99.361 - /* This should never happen */99.362 - return;99.363 - }99.364 + if( value == 0xF0000000 ) {99.365 + tile = ta_alloc_tilelist(tile);99.366 + if( tile != TA_NO_ALLOC ) {99.367 + PVRRAM(tile) = tile_entry;99.368 + PVRRAM(tile+4) = 0xF0000000;99.369 + }99.370 + return;99.371 + } else if( (value & 0xFF000000) == 0xE0000000 ) {99.372 + value &= 0x00FFFFFF;99.373 + if( value == tilestart )99.374 + return; /* Loop */99.375 + tilestart = tile = value;99.376 + } else {99.377 + /* This should never happen */99.378 + return;99.379 + }99.380 }99.381 }99.383 @@ -504,21 +504,21 @@99.384 * clamping here)99.385 */99.386 for( i=0; i<ta_status.vertex_count; i++ ) {99.387 - if( ta_status.poly_vertex[i].x < 0.0 || TA_IS_NINF(ta_status.poly_vertex[i].x) ) {99.388 - tx[i] = -1;99.389 - } else if( ta_status.poly_vertex[i].x > (float)INT_MAX || TA_IS_INF(ta_status.poly_vertex[i].x) ) {99.390 - tx[i] = INT_MAX/32;99.391 - } else {99.392 - tx[i] = (int)(ta_status.poly_vertex[i].x / 32.0);99.393 - }99.394 - if( ta_status.poly_vertex[i].y < 0.0 || TA_IS_NINF(ta_status.poly_vertex[i].y)) {99.395 - ty[i] = -1;99.396 - } else if( ta_status.poly_vertex[i].y > (float)INT_MAX || TA_IS_INF(ta_status.poly_vertex[i].y) ) {99.397 - ty[i] = INT_MAX/32;99.398 - } else {99.399 - ty[i] = (int)(ta_status.poly_vertex[i].y / 32.0);99.400 - }99.401 -99.402 + if( ta_status.poly_vertex[i].x < 0.0 || TA_IS_NINF(ta_status.poly_vertex[i].x) ) {99.403 + tx[i] = -1;99.404 + } else if( ta_status.poly_vertex[i].x > (float)INT_MAX || TA_IS_INF(ta_status.poly_vertex[i].x) ) {99.405 + tx[i] = INT_MAX/32;99.406 + } else {99.407 + tx[i] = (int)(ta_status.poly_vertex[i].x / 32.0);99.408 + }99.409 + if( ta_status.poly_vertex[i].y < 0.0 || TA_IS_NINF(ta_status.poly_vertex[i].y)) {99.410 + ty[i] = -1;99.411 + } else if( ta_status.poly_vertex[i].y > (float)INT_MAX || TA_IS_INF(ta_status.poly_vertex[i].y) ) {99.412 + ty[i] = INT_MAX/32;99.413 + } else {99.414 + ty[i] = (int)(ta_status.poly_vertex[i].y / 32.0);99.415 + }99.416 +99.417 }99.419 /* Compute bounding box for each triangle individually, as well99.420 @@ -526,21 +526,21 @@99.421 */99.423 for( i=0; i<ta_status.vertex_count-2; i++ ) {99.424 - triangle_bound[i].x1 = MIN3(tx[i],tx[i+1],tx[i+2]);99.425 - triangle_bound[i].x2 = MAX3(tx[i],tx[i+1],tx[i+2]);99.426 - triangle_bound[i].y1 = MIN3(ty[i],ty[i+1],ty[i+2]);99.427 - triangle_bound[i].y2 = MAX3(ty[i],ty[i+1],ty[i+2]);99.428 - if( i == 0 ) {99.429 - polygon_bound.x1 = triangle_bound[0].x1;99.430 - polygon_bound.y1 = triangle_bound[0].y1;99.431 - polygon_bound.x2 = triangle_bound[0].x2;99.432 - polygon_bound.y2 = triangle_bound[0].y2;99.433 - } else {99.434 - polygon_bound.x1 = MIN(polygon_bound.x1, triangle_bound[i].x1);99.435 - polygon_bound.x2 = MAX(polygon_bound.x2, triangle_bound[i].x2);99.436 - polygon_bound.y1 = MIN(polygon_bound.y1, triangle_bound[i].y1);99.437 - polygon_bound.y2 = MAX(polygon_bound.y2, triangle_bound[i].y2);99.438 - }99.439 + triangle_bound[i].x1 = MIN3(tx[i],tx[i+1],tx[i+2]);99.440 + triangle_bound[i].x2 = MAX3(tx[i],tx[i+1],tx[i+2]);99.441 + triangle_bound[i].y1 = MIN3(ty[i],ty[i+1],ty[i+2]);99.442 + triangle_bound[i].y2 = MAX3(ty[i],ty[i+1],ty[i+2]);99.443 + if( i == 0 ) {99.444 + polygon_bound.x1 = triangle_bound[0].x1;99.445 + polygon_bound.y1 = triangle_bound[0].y1;99.446 + polygon_bound.x2 = triangle_bound[0].x2;99.447 + polygon_bound.y2 = triangle_bound[0].y2;99.448 + } else {99.449 + polygon_bound.x1 = MIN(polygon_bound.x1, triangle_bound[i].x1);99.450 + polygon_bound.x2 = MAX(polygon_bound.x2, triangle_bound[i].x2);99.451 + polygon_bound.y1 = MIN(polygon_bound.y1, triangle_bound[i].y1);99.452 + polygon_bound.y2 = MAX(polygon_bound.y2, triangle_bound[i].y2);99.453 + }99.454 }99.456 /* Clamp the polygon bounds to the frustum */99.457 @@ -551,95 +551,95 @@99.459 /* Set the "single tile" flag if it's entirely contained in 1 tile */99.460 if( polygon_bound.x1 == polygon_bound.x2 &&99.461 - polygon_bound.y1 == polygon_bound.y2 ) {99.462 - poly_context[0] |= 0x00200000;99.463 + polygon_bound.y1 == polygon_bound.y2 ) {99.464 + poly_context[0] |= 0x00200000;99.465 }99.466 -99.467 +99.468 /* If the polygon is entirely clipped, don't even write the polygon data */99.469 switch( ta_status.clip_mode ) {99.470 case TA_POLYCMD_CLIP_NONE:99.471 - if( polygon_bound.x2 < 0 || polygon_bound.x1 >= ta_status.width ||99.472 - polygon_bound.y2 < 0 || polygon_bound.y1 >= ta_status.height ) {99.473 - return;99.474 - }99.475 - break;99.476 + if( polygon_bound.x2 < 0 || polygon_bound.x1 >= ta_status.width ||99.477 + polygon_bound.y2 < 0 || polygon_bound.y1 >= ta_status.height ) {99.478 + return;99.479 + }99.480 + break;99.481 case TA_POLYCMD_CLIP_INSIDE:99.482 - if( polygon_bound.x2 < ta_status.clip.x1 || polygon_bound.x1 > ta_status.clip.x2 ||99.483 - polygon_bound.y2 < ta_status.clip.y1 || polygon_bound.y1 > ta_status.clip.y2 ) {99.484 - return;99.485 - } else {99.486 - /* Clamp to clip bounds */99.487 - if( polygon_bound.x1 < ta_status.clip.x1 ) polygon_bound.x1 = ta_status.clip.x1;99.488 - if( polygon_bound.x2 > ta_status.clip.x2 ) polygon_bound.x2 = ta_status.clip.x2;99.489 - if( polygon_bound.y1 < ta_status.clip.y1 ) polygon_bound.y1 = ta_status.clip.y1;99.490 - if( polygon_bound.y2 > ta_status.clip.y2 ) polygon_bound.y2 = ta_status.clip.y2;99.491 - }99.492 - break;99.493 + if( polygon_bound.x2 < ta_status.clip.x1 || polygon_bound.x1 > ta_status.clip.x2 ||99.494 + polygon_bound.y2 < ta_status.clip.y1 || polygon_bound.y1 > ta_status.clip.y2 ) {99.495 + return;99.496 + } else {99.497 + /* Clamp to clip bounds */99.498 + if( polygon_bound.x1 < ta_status.clip.x1 ) polygon_bound.x1 = ta_status.clip.x1;99.499 + if( polygon_bound.x2 > ta_status.clip.x2 ) polygon_bound.x2 = ta_status.clip.x2;99.500 + if( polygon_bound.y1 < ta_status.clip.y1 ) polygon_bound.y1 = ta_status.clip.y1;99.501 + if( polygon_bound.y2 > ta_status.clip.y2 ) polygon_bound.y2 = ta_status.clip.y2;99.502 + }99.503 + break;99.504 case TA_POLYCMD_CLIP_OUTSIDE:99.505 - if( polygon_bound.x1 >= ta_status.clip.x1 && polygon_bound.x2 <= ta_status.clip.x2 &&99.506 - polygon_bound.y1 >= ta_status.clip.y1 && polygon_bound.y2 <= ta_status.clip.y2 ) {99.507 - return;99.508 - }99.509 - break;99.510 + if( polygon_bound.x1 >= ta_status.clip.x1 && polygon_bound.x2 <= ta_status.clip.x2 &&99.511 + polygon_bound.y1 >= ta_status.clip.y1 && polygon_bound.y2 <= ta_status.clip.y2 ) {99.512 + return;99.513 + }99.514 + break;99.515 }99.517 /* Ok, we're good to go - write out the polygon first */99.518 uint32_t tile_entry = (MMIO_READ( PVR2, TA_POLYPOS ) - ta_status.polybuf_start) >> 2 |99.519 - ta_status.poly_pointer;99.520 -99.521 + ta_status.poly_pointer;99.522 +99.523 int status = ta_write_polygon_buffer( poly_context, ta_status.poly_context_size );99.524 if( status == 0 ) {99.525 - /* No memory available - abort */99.526 - return;99.527 + /* No memory available - abort */99.528 + return;99.529 } else {99.530 - for( i=0; i<ta_status.vertex_count && status != 0; i++ ) {99.531 - status = ta_write_polygon_buffer( (uint32_t *)(&ta_status.poly_vertex[i]), 3 + ta_status.poly_vertex_size );99.532 - }99.533 + for( i=0; i<ta_status.vertex_count && status != 0; i++ ) {99.534 + status = ta_write_polygon_buffer( (uint32_t *)(&ta_status.poly_vertex[i]), 3 + ta_status.poly_vertex_size );99.535 + }99.536 }99.538 if( ta_status.current_tile_size == 0 ) {99.539 - /* No memory for tile entry, so don't write anything */99.540 - return;99.541 + /* No memory for tile entry, so don't write anything */99.542 + return;99.543 }99.545 /* And now the tile entries. Triangles are different from everything else */99.546 if( ta_status.vertex_count == 3 ) {99.547 - tile_entry |= 0x80000000;99.548 - for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {99.549 - for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {99.550 - ta_write_tile_entry( x,y,tile_entry );99.551 - }99.552 - }99.553 - ta_status.last_triangle_bounds.x1 = polygon_bound.x1;99.554 - ta_status.last_triangle_bounds.y1 = polygon_bound.y1;99.555 - ta_status.last_triangle_bounds.x2 = polygon_bound.x2;99.556 - ta_status.last_triangle_bounds.y2 = polygon_bound.y2;99.557 + tile_entry |= 0x80000000;99.558 + for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {99.559 + for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {99.560 + ta_write_tile_entry( x,y,tile_entry );99.561 + }99.562 + }99.563 + ta_status.last_triangle_bounds.x1 = polygon_bound.x1;99.564 + ta_status.last_triangle_bounds.y1 = polygon_bound.y1;99.565 + ta_status.last_triangle_bounds.x2 = polygon_bound.x2;99.566 + ta_status.last_triangle_bounds.y2 = polygon_bound.y2;99.567 } else if( ta_status.current_vertex_type == TA_VERTEX_SPRITE ||99.568 - ta_status.current_vertex_type == TA_VERTEX_TEX_SPRITE ) {99.569 - tile_entry |= 0xA0000000;99.570 - for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {99.571 - for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {99.572 - ta_write_tile_entry( x,y,tile_entry );99.573 - }99.574 - }99.575 - ta_status.last_triangle_bounds.x1 = polygon_bound.x1;99.576 - ta_status.last_triangle_bounds.y1 = polygon_bound.y1;99.577 - ta_status.last_triangle_bounds.x2 = polygon_bound.x2;99.578 - ta_status.last_triangle_bounds.y2 = polygon_bound.y2;99.579 + ta_status.current_vertex_type == TA_VERTEX_TEX_SPRITE ) {99.580 + tile_entry |= 0xA0000000;99.581 + for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {99.582 + for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {99.583 + ta_write_tile_entry( x,y,tile_entry );99.584 + }99.585 + }99.586 + ta_status.last_triangle_bounds.x1 = polygon_bound.x1;99.587 + ta_status.last_triangle_bounds.y1 = polygon_bound.y1;99.588 + ta_status.last_triangle_bounds.x2 = polygon_bound.x2;99.589 + ta_status.last_triangle_bounds.y2 = polygon_bound.y2;99.590 } else {99.591 - for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {99.592 - for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {99.593 - uint32_t entry = tile_entry;99.594 - for( i=0; i<ta_status.vertex_count-2; i++ ) {99.595 - if( triangle_bound[i].x1 <= x && triangle_bound[i].x2 >= x &&99.596 - triangle_bound[i].y1 <= y && triangle_bound[i].y2 >= y ) {99.597 - entry |= (0x40000000>>i);99.598 - }99.599 - }99.600 - ta_write_tile_entry( x, y, entry );99.601 - }99.602 - }99.603 - ta_status.last_triangle_bounds.x1 = -1;99.604 + for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {99.605 + for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {99.606 + uint32_t entry = tile_entry;99.607 + for( i=0; i<ta_status.vertex_count-2; i++ ) {99.608 + if( triangle_bound[i].x1 <= x && triangle_bound[i].x2 >= x &&99.609 + triangle_bound[i].y1 <= y && triangle_bound[i].y2 >= y ) {99.610 + entry |= (0x40000000>>i);99.611 + }99.612 + }99.613 + ta_write_tile_entry( x, y, entry );99.614 + }99.615 + }99.616 + ta_status.last_triangle_bounds.x1 = -1;99.617 }99.618 }99.620 @@ -652,29 +652,29 @@99.621 static void ta_split_polygon() {99.622 ta_commit_polygon();99.623 if( TA_IS_NORMAL_POLY() ) {99.624 - /* This only applies to ordinary polys - Sprites + modifier lists are99.625 - * handled differently99.626 - */99.627 - if( ta_status.vertex_count == 3 ) {99.628 - /* Triangles use an odd/even scheme */99.629 - if( ta_status.poly_parity == 0 ) {99.630 - memcpy( &ta_status.poly_vertex[0], &ta_status.poly_vertex[2],99.631 - sizeof(struct pvr2_ta_vertex) );99.632 - ta_status.poly_parity = 1;99.633 - } else {99.634 - memcpy( &ta_status.poly_vertex[1], &ta_status.poly_vertex[2],99.635 - sizeof(struct pvr2_ta_vertex) );99.636 - ta_status.poly_parity = 0;99.637 - }99.638 - } else {99.639 - /* Everything else just uses the last 2 vertexes in order */99.640 - memcpy( &ta_status.poly_vertex[0], &ta_status.poly_vertex[ta_status.vertex_count-2],99.641 - sizeof(struct pvr2_ta_vertex)*2 );99.642 - ta_status.poly_parity = 0;99.643 - }99.644 - ta_status.vertex_count = 2;99.645 + /* This only applies to ordinary polys - Sprites + modifier lists are99.646 + * handled differently99.647 + */99.648 + if( ta_status.vertex_count == 3 ) {99.649 + /* Triangles use an odd/even scheme */99.650 + if( ta_status.poly_parity == 0 ) {99.651 + memcpy( &ta_status.poly_vertex[0], &ta_status.poly_vertex[2],99.652 + sizeof(struct pvr2_ta_vertex) );99.653 + ta_status.poly_parity = 1;99.654 + } else {99.655 + memcpy( &ta_status.poly_vertex[1], &ta_status.poly_vertex[2],99.656 + sizeof(struct pvr2_ta_vertex) );99.657 + ta_status.poly_parity = 0;99.658 + }99.659 + } else {99.660 + /* Everything else just uses the last 2 vertexes in order */99.661 + memcpy( &ta_status.poly_vertex[0], &ta_status.poly_vertex[ta_status.vertex_count-2],99.662 + sizeof(struct pvr2_ta_vertex)*2 );99.663 + ta_status.poly_parity = 0;99.664 + }99.665 + ta_status.vertex_count = 2;99.666 } else {99.667 - ta_status.vertex_count = 0;99.668 + ta_status.vertex_count = 0;99.669 }99.670 }99.672 @@ -686,63 +686,63 @@99.673 static void ta_parse_polygon_context( union ta_data *data ) {99.674 int colourfmt = TA_POLYCMD_COLOURFMT(data[0].i);99.675 if( TA_POLYCMD_USELENGTH(data[0].i) ) {99.676 - ta_status.max_vertex = TA_POLYCMD_LENGTH(data[0].i);99.677 + ta_status.max_vertex = TA_POLYCMD_LENGTH(data[0].i);99.678 }99.679 ta_status.clip_mode = TA_POLYCMD_CLIP(data[0].i);99.680 if( ta_status.clip_mode == 1 ) { /* Reserved - treat as CLIP_INSIDE */99.681 - ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;99.682 + ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;99.683 }99.684 ta_status.vertex_count = 0;99.685 ta_status.poly_context[0] =99.686 - (data[1].i & 0xFC1FFFFF) | ((data[0].i & 0x0B) << 22);99.687 + (data[1].i & 0xFC1FFFFF) | ((data[0].i & 0x0B) << 22);99.688 ta_status.poly_context[1] = data[2].i;99.689 ta_status.poly_context[3] = data[4].i;99.690 ta_status.poly_parity = 0;99.691 if( data[0].i & TA_POLYCMD_TEXTURED ) {99.692 - ta_status.current_vertex_type = data[0].i & 0x0D;99.693 - ta_status.poly_context[2] = data[3].i;99.694 - ta_status.poly_context[4] = data[5].i;99.695 - if( data[0].i & TA_POLYCMD_SPECULAR ) {99.696 - ta_status.poly_context[0] |= 0x01000000;99.697 - ta_status.poly_vertex_size = 4;99.698 - } else {99.699 - ta_status.poly_vertex_size = 3;99.700 - }99.701 - if( data[0].i & TA_POLYCMD_UV16 ) {99.702 - ta_status.poly_vertex_size--;99.703 - }99.704 + ta_status.current_vertex_type = data[0].i & 0x0D;99.705 + ta_status.poly_context[2] = data[3].i;99.706 + ta_status.poly_context[4] = data[5].i;99.707 + if( data[0].i & TA_POLYCMD_SPECULAR ) {99.708 + ta_status.poly_context[0] |= 0x01000000;99.709 + ta_status.poly_vertex_size = 4;99.710 + } else {99.711 + ta_status.poly_vertex_size = 3;99.712 + }99.713 + if( data[0].i & TA_POLYCMD_UV16 ) {99.714 + ta_status.poly_vertex_size--;99.715 + }99.716 } else {99.717 - ta_status.current_vertex_type = 0;99.718 - ta_status.poly_vertex_size = 1;99.719 - ta_status.poly_context[2] = 0;99.720 - ta_status.poly_context[4] = 0;99.721 + ta_status.current_vertex_type = 0;99.722 + ta_status.poly_vertex_size = 1;99.723 + ta_status.poly_context[2] = 0;99.724 + ta_status.poly_context[4] = 0;99.725 }99.727 ta_status.poly_pointer = (ta_status.poly_vertex_size << 21);99.728 ta_status.poly_context_size = 3;99.729 if( data[0].i & TA_POLYCMD_MODIFIED ) {99.730 - ta_status.poly_pointer |= 0x01000000;99.731 - if( data[0].i & TA_POLYCMD_FULLMOD ) {99.732 - ta_status.poly_context_size = 5;99.733 - ta_status.poly_vertex_size <<= 1;99.734 - ta_status.current_vertex_type |= 0x40;99.735 - /* Modified/float not supported - behaves as per last intensity */99.736 - if( colourfmt == TA_POLYCMD_COLOURFMT_FLOAT ) {99.737 - colourfmt = TA_POLYCMD_COLOURFMT_LASTINT;99.738 - }99.739 - }99.740 + ta_status.poly_pointer |= 0x01000000;99.741 + if( data[0].i & TA_POLYCMD_FULLMOD ) {99.742 + ta_status.poly_context_size = 5;99.743 + ta_status.poly_vertex_size <<= 1;99.744 + ta_status.current_vertex_type |= 0x40;99.745 + /* Modified/float not supported - behaves as per last intensity */99.746 + if( colourfmt == TA_POLYCMD_COLOURFMT_FLOAT ) {99.747 + colourfmt = TA_POLYCMD_COLOURFMT_LASTINT;99.748 + }99.749 + }99.750 }99.751 -99.752 +99.753 if( colourfmt == TA_POLYCMD_COLOURFMT_INTENSITY ) {99.754 - if( TA_POLYCMD_IS_FULLMOD(data[0].i) ||99.755 - TA_POLYCMD_IS_SPECULAR(data[0].i) ) {99.756 - ta_status.state = STATE_EXPECT_POLY_BLOCK2;99.757 - } else {99.758 - ta_status.intensity1 =99.759 - parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );99.760 - }99.761 + if( TA_POLYCMD_IS_FULLMOD(data[0].i) ||99.762 + TA_POLYCMD_IS_SPECULAR(data[0].i) ) {99.763 + ta_status.state = STATE_EXPECT_POLY_BLOCK2;99.764 + } else {99.765 + ta_status.intensity1 =99.766 + parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );99.767 + }99.768 } else if( colourfmt == TA_POLYCMD_COLOURFMT_LASTINT ) {99.769 - colourfmt = TA_POLYCMD_COLOURFMT_INTENSITY;99.770 + colourfmt = TA_POLYCMD_COLOURFMT_INTENSITY;99.771 }99.773 ta_status.current_vertex_type |= colourfmt;99.774 @@ -758,13 +758,13 @@99.775 ta_status.poly_vertex_size = 0;99.776 ta_status.clip_mode = TA_POLYCMD_CLIP(data[0].i);99.777 if( ta_status.clip_mode == 1 ) { /* Reserved - treat as CLIP_INSIDE */99.778 - ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;99.779 + ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;99.780 }99.781 ta_status.poly_context_size = 3;99.782 ta_status.poly_context[0] = (data[1].i & 0xFC1FFFFF) |99.783 - ((data[0].i & 0x0B)<<22);99.784 + ((data[0].i & 0x0B)<<22);99.785 if( TA_POLYCMD_IS_SPECULAR(data[0].i) ) {99.786 - ta_status.poly_context[0] |= 0x01000000;99.787 + ta_status.poly_context[0] |= 0x01000000;99.788 }99.789 ta_status.poly_context[1] = 0;99.790 ta_status.poly_context[2] = 0;99.791 @@ -781,24 +781,24 @@99.792 static void ta_parse_sprite_context( union ta_data *data ) {99.793 ta_status.poly_context_size = 3;99.794 ta_status.poly_context[0] = (data[1].i & 0xFC1FFFFF) |99.795 - ((data[0].i & 0x0B)<<22) | 0x00400000;99.796 + ((data[0].i & 0x0B)<<22) | 0x00400000;99.797 ta_status.clip_mode = TA_POLYCMD_CLIP(data[0].i);99.798 if( ta_status.clip_mode == 1 ) { /* Reserved - treat as CLIP_INSIDE */99.799 - ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;99.800 + ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;99.801 }99.802 if( TA_POLYCMD_IS_SPECULAR(data[0].i) ) {99.803 - ta_status.poly_context[0] |= 0x01000000;99.804 + ta_status.poly_context[0] |= 0x01000000;99.805 }99.806 ta_status.poly_context[1] = data[2].i;99.807 ta_status.poly_context[2] = data[3].i;99.808 if( data[0].i & TA_POLYCMD_TEXTURED ) {99.809 - ta_status.poly_vertex_size = 2;99.810 - ta_status.poly_vertex[2].detail[1] = data[4].i;99.811 - ta_status.current_vertex_type = TA_VERTEX_TEX_SPRITE;99.812 + ta_status.poly_vertex_size = 2;99.813 + ta_status.poly_vertex[2].detail[1] = data[4].i;99.814 + ta_status.current_vertex_type = TA_VERTEX_TEX_SPRITE;99.815 } else {99.816 - ta_status.poly_vertex_size = 1;99.817 - ta_status.poly_vertex[2].detail[0] = data[4].i;99.818 - ta_status.current_vertex_type = TA_VERTEX_SPRITE;99.819 + ta_status.poly_vertex_size = 1;99.820 + ta_status.poly_vertex[2].detail[0] = data[4].i;99.821 + ta_status.current_vertex_type = TA_VERTEX_SPRITE;99.822 }99.823 ta_status.vertex_count = 0;99.824 ta_status.max_vertex = 4;99.825 @@ -812,8 +812,8 @@99.826 static void ta_fill_vertexes( ) {99.827 int i;99.828 for( i=ta_status.vertex_count; i<ta_status.max_vertex; i++ ) {99.829 - memcpy( &ta_status.poly_vertex[i], &ta_status.poly_vertex[ta_status.vertex_count-1],99.830 - sizeof( struct pvr2_ta_vertex ) );99.831 + memcpy( &ta_status.poly_vertex[i], &ta_status.poly_vertex[ta_status.vertex_count-1],99.832 + sizeof( struct pvr2_ta_vertex ) );99.833 }99.834 }99.836 @@ -825,117 +825,117 @@99.838 switch( ta_status.current_vertex_type ) {99.839 case TA_VERTEX_PACKED:99.840 - vertex->detail[0] = data[6].i;99.841 - break;99.842 + vertex->detail[0] = data[6].i;99.843 + break;99.844 case TA_VERTEX_FLOAT:99.845 - vertex->detail[0] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );99.846 - break;99.847 + vertex->detail[0] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );99.848 + break;99.849 case TA_VERTEX_INTENSITY:99.850 - vertex->detail[0] = parse_intensity_colour( ta_status.intensity1, data[6].f );99.851 - break;99.852 + vertex->detail[0] = parse_intensity_colour( ta_status.intensity1, data[6].f );99.853 + break;99.855 case TA_VERTEX_TEX_SPEC_PACKED:99.856 - vertex->detail[3] = data[7].i; /* ARGB */99.857 - /* Fallthrough */99.858 + vertex->detail[3] = data[7].i; /* ARGB */99.859 + /* Fallthrough */99.860 case TA_VERTEX_TEX_PACKED:99.861 - vertex->detail[0] = data[4].i; /* U */99.862 - vertex->detail[1] = data[5].i; /* V */99.863 - vertex->detail[2] = data[6].i; /* ARGB */99.864 - break;99.865 + vertex->detail[0] = data[4].i; /* U */99.866 + vertex->detail[1] = data[5].i; /* V */99.867 + vertex->detail[2] = data[6].i; /* ARGB */99.868 + break;99.869 case TA_VERTEX_TEX_UV16_SPEC_PACKED:99.870 - vertex->detail[2] = data[7].i; /* ARGB */99.871 - /* Fallthrough */99.872 + vertex->detail[2] = data[7].i; /* ARGB */99.873 + /* Fallthrough */99.874 case TA_VERTEX_TEX_UV16_PACKED:99.875 - vertex->detail[0] = data[4].i; /* UV */99.876 - vertex->detail[1] = data[6].i; /* ARGB */99.877 - break;99.878 + vertex->detail[0] = data[4].i; /* UV */99.879 + vertex->detail[1] = data[6].i; /* ARGB */99.880 + break;99.882 case TA_VERTEX_TEX_FLOAT:99.883 case TA_VERTEX_TEX_SPEC_FLOAT:99.884 - vertex->detail[0] = data[4].i; /* U */99.885 - vertex->detail[1] = data[5].i; /* UV */99.886 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.887 - break;99.888 + vertex->detail[0] = data[4].i; /* U */99.889 + vertex->detail[1] = data[5].i; /* UV */99.890 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.891 + break;99.892 case TA_VERTEX_TEX_UV16_FLOAT:99.893 case TA_VERTEX_TEX_UV16_SPEC_FLOAT:99.894 - vertex->detail[0] = data[4].i; /* UV */99.895 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.896 - break;99.897 + vertex->detail[0] = data[4].i; /* UV */99.898 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.899 + break;99.901 case TA_VERTEX_TEX_SPEC_INTENSITY:99.902 - vertex->detail[3] = parse_intensity_colour( ta_status.intensity2, data[7].f );99.903 - /* Fallthrough */99.904 + vertex->detail[3] = parse_intensity_colour( ta_status.intensity2, data[7].f );99.905 + /* Fallthrough */99.906 case TA_VERTEX_TEX_INTENSITY:99.907 - vertex->detail[0] = data[4].i; /* U */99.908 - vertex->detail[1] = data[5].i; /* V */99.909 - vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[6].f );99.910 - break;99.911 + vertex->detail[0] = data[4].i; /* U */99.912 + vertex->detail[1] = data[5].i; /* V */99.913 + vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[6].f );99.914 + break;99.915 case TA_VERTEX_TEX_UV16_SPEC_INTENSITY:99.916 - vertex->detail[2] = parse_intensity_colour( ta_status.intensity2, data[7].f );99.917 - /* Fallthrough */99.918 + vertex->detail[2] = parse_intensity_colour( ta_status.intensity2, data[7].f );99.919 + /* Fallthrough */99.920 case TA_VERTEX_TEX_UV16_INTENSITY:99.921 - vertex->detail[0] = data[4].i; /* UV */99.922 - vertex->detail[1] = parse_intensity_colour( ta_status.intensity1, data[6].f );99.923 - break;99.924 + vertex->detail[0] = data[4].i; /* UV */99.925 + vertex->detail[1] = parse_intensity_colour( ta_status.intensity1, data[6].f );99.926 + break;99.928 case TA_VERTEX_PACKED_MOD:99.929 - vertex->detail[0] = data[4].i; /* ARGB */99.930 - vertex->detail[1] = data[5].i; /* ARGB */99.931 - break;99.932 + vertex->detail[0] = data[4].i; /* ARGB */99.933 + vertex->detail[1] = data[5].i; /* ARGB */99.934 + break;99.935 case TA_VERTEX_INTENSITY_MOD:99.936 - vertex->detail[0] = parse_intensity_colour( ta_status.intensity1, data[4].f );99.937 - vertex->detail[1] = parse_intensity_colour( ta_status.intensity2, data[5].f );99.938 - break;99.939 + vertex->detail[0] = parse_intensity_colour( ta_status.intensity1, data[4].f );99.940 + vertex->detail[1] = parse_intensity_colour( ta_status.intensity2, data[5].f );99.941 + break;99.943 case TA_VERTEX_TEX_SPEC_PACKED_MOD:99.944 - vertex->detail[3] = data[7].i; /* ARGB0 */99.945 - /* Fallthrough */99.946 + vertex->detail[3] = data[7].i; /* ARGB0 */99.947 + /* Fallthrough */99.948 case TA_VERTEX_TEX_PACKED_MOD:99.949 - vertex->detail[0] = data[4].i; /* U0 */99.950 - vertex->detail[1] = data[5].i; /* V0 */99.951 - vertex->detail[2] = data[6].i; /* ARGB0 */99.952 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.953 - break;99.954 + vertex->detail[0] = data[4].i; /* U0 */99.955 + vertex->detail[1] = data[5].i; /* V0 */99.956 + vertex->detail[2] = data[6].i; /* ARGB0 */99.957 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.958 + break;99.959 case TA_VERTEX_TEX_UV16_SPEC_PACKED_MOD:99.960 - vertex->detail[2] = data[7].i; /* ARGB0 */99.961 - /* Fallthrough */99.962 + vertex->detail[2] = data[7].i; /* ARGB0 */99.963 + /* Fallthrough */99.964 case TA_VERTEX_TEX_UV16_PACKED_MOD:99.965 - vertex->detail[0] = data[4].i; /* UV0 */99.966 - vertex->detail[1] = data[6].i; /* ARGB0 */99.967 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.968 - break;99.969 + vertex->detail[0] = data[4].i; /* UV0 */99.970 + vertex->detail[1] = data[6].i; /* ARGB0 */99.971 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.972 + break;99.974 case TA_VERTEX_TEX_SPEC_INTENSITY_MOD:99.975 - vertex->detail[3] = parse_intensity_colour( ta_status.intensity1, data[7].f );99.976 - /* Fallthrough */99.977 + vertex->detail[3] = parse_intensity_colour( ta_status.intensity1, data[7].f );99.978 + /* Fallthrough */99.979 case TA_VERTEX_TEX_INTENSITY_MOD:99.980 - vertex->detail[0] = data[4].i; /* U0 */99.981 - vertex->detail[1] = data[5].i; /* V0 */99.982 - vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[6].f );99.983 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.984 - break;99.985 + vertex->detail[0] = data[4].i; /* U0 */99.986 + vertex->detail[1] = data[5].i; /* V0 */99.987 + vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[6].f );99.988 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.989 + break;99.990 case TA_VERTEX_TEX_UV16_SPEC_INTENSITY_MOD:99.991 - vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[7].f );99.992 - /* Fallthrough */99.993 + vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[7].f );99.994 + /* Fallthrough */99.995 case TA_VERTEX_TEX_UV16_INTENSITY_MOD:99.996 - vertex->detail[0] = data[4].i; /* UV0 */99.997 - vertex->detail[1] = parse_intensity_colour( ta_status.intensity1, data[6].f );99.998 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.999 - break;99.1000 -99.1001 + vertex->detail[0] = data[4].i; /* UV0 */99.1002 + vertex->detail[1] = parse_intensity_colour( ta_status.intensity1, data[6].f );99.1003 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.1004 + break;99.1005 +99.1006 case TA_VERTEX_SPRITE:99.1007 case TA_VERTEX_TEX_SPRITE:99.1008 case TA_VERTEX_MOD_VOLUME:99.1009 case TA_VERTEX_LISTLESS:99.1010 - vertex++;99.1011 - vertex->x = data[4].f;99.1012 - vertex->y = data[5].f;99.1013 - vertex->z = data[6].f;99.1014 - vertex++;99.1015 - vertex->x = data[7].f;99.1016 - ta_status.vertex_count += 2;99.1017 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.1018 - break;99.1019 + vertex++;99.1020 + vertex->x = data[4].f;99.1021 + vertex->y = data[5].f;99.1022 + vertex->z = data[6].f;99.1023 + vertex++;99.1024 + vertex->x = data[7].f;99.1025 + ta_status.vertex_count += 2;99.1026 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;99.1027 + break;99.1028 }99.1029 ta_status.vertex_count++;99.1030 }99.1031 @@ -945,92 +945,92 @@99.1033 switch( ta_status.current_vertex_type ) {99.1034 case TA_VERTEX_TEX_SPEC_FLOAT:99.1035 - vertex->detail[3] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );99.1036 - /* Fallthrough */99.1037 + vertex->detail[3] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );99.1038 + /* Fallthrough */99.1039 case TA_VERTEX_TEX_FLOAT:99.1040 - vertex->detail[2] = parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );99.1041 - break;99.1042 + vertex->detail[2] = parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );99.1043 + break;99.1044 case TA_VERTEX_TEX_UV16_SPEC_FLOAT:99.1045 - vertex->detail[2] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );99.1046 - /* Fallthrough */99.1047 + vertex->detail[2] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );99.1048 + /* Fallthrough */99.1049 case TA_VERTEX_TEX_UV16_FLOAT:99.1050 - vertex->detail[1] = parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );99.1051 - break;99.1052 + vertex->detail[1] = parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );99.1053 + break;99.1054 case TA_VERTEX_TEX_PACKED_MOD:99.1055 - vertex->detail[3] = data[0].i; /* U1 */99.1056 - vertex->detail[4] = data[1].i; /* V1 */99.1057 - vertex->detail[5] = data[2].i; /* ARGB1 */99.1058 - break;99.1059 + vertex->detail[3] = data[0].i; /* U1 */99.1060 + vertex->detail[4] = data[1].i; /* V1 */99.1061 + vertex->detail[5] = data[2].i; /* ARGB1 */99.1062 + break;99.1063 case TA_VERTEX_TEX_SPEC_PACKED_MOD:99.1064 - vertex->detail[4] = data[0].i; /* U1 */99.1065 - vertex->detail[5] = data[1].i; /* V1 */99.1066 - vertex->detail[6] = data[2].i; /* ARGB1 */99.1067 - vertex->detail[7] = data[3].i; /* ARGB1 */99.1068 - break;99.1069 + vertex->detail[4] = data[0].i; /* U1 */99.1070 + vertex->detail[5] = data[1].i; /* V1 */99.1071 + vertex->detail[6] = data[2].i; /* ARGB1 */99.1072 + vertex->detail[7] = data[3].i; /* ARGB1 */99.1073 + break;99.1074 case TA_VERTEX_TEX_UV16_PACKED_MOD:99.1075 - vertex->detail[2] = data[0].i; /* UV1 */99.1076 - vertex->detail[3] = data[2].i; /* ARGB1 */99.1077 - break;99.1078 + vertex->detail[2] = data[0].i; /* UV1 */99.1079 + vertex->detail[3] = data[2].i; /* ARGB1 */99.1080 + break;99.1081 case TA_VERTEX_TEX_UV16_SPEC_PACKED_MOD:99.1082 - vertex->detail[3] = data[0].i; /* UV1 */99.1083 - vertex->detail[4] = data[2].i; /* ARGB1 */99.1084 - vertex->detail[5] = data[3].i; /* ARGB1 */99.1085 - break;99.1086 + vertex->detail[3] = data[0].i; /* UV1 */99.1087 + vertex->detail[4] = data[2].i; /* ARGB1 */99.1088 + vertex->detail[5] = data[3].i; /* ARGB1 */99.1089 + break;99.1091 case TA_VERTEX_TEX_INTENSITY_MOD:99.1092 - vertex->detail[3] = data[0].i; /* U1 */99.1093 - vertex->detail[4] = data[1].i; /* V1 */99.1094 - vertex->detail[5] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */99.1095 - break;99.1096 + vertex->detail[3] = data[0].i; /* U1 */99.1097 + vertex->detail[4] = data[1].i; /* V1 */99.1098 + vertex->detail[5] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */99.1099 + break;99.1100 case TA_VERTEX_TEX_SPEC_INTENSITY_MOD:99.1101 - vertex->detail[4] = data[0].i; /* U1 */99.1102 - vertex->detail[5] = data[1].i; /* V1 */99.1103 - vertex->detail[6] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */99.1104 - vertex->detail[7] = parse_intensity_colour( ta_status.intensity2, data[3].f ); /* ARGB1 */99.1105 - break;99.1106 + vertex->detail[4] = data[0].i; /* U1 */99.1107 + vertex->detail[5] = data[1].i; /* V1 */99.1108 + vertex->detail[6] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */99.1109 + vertex->detail[7] = parse_intensity_colour( ta_status.intensity2, data[3].f ); /* ARGB1 */99.1110 + break;99.1111 case TA_VERTEX_TEX_UV16_INTENSITY_MOD:99.1112 - vertex->detail[2] = data[0].i; /* UV1 */99.1113 - vertex->detail[3] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */99.1114 - break;99.1115 + vertex->detail[2] = data[0].i; /* UV1 */99.1116 + vertex->detail[3] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */99.1117 + break;99.1118 case TA_VERTEX_TEX_UV16_SPEC_INTENSITY_MOD:99.1119 - vertex->detail[3] = data[0].i; /* UV1 */99.1120 - vertex->detail[4] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */99.1121 - vertex->detail[5] = parse_intensity_colour( ta_status.intensity2, data[3].f ); /* ARGB1 */99.1122 - break;99.1123 + vertex->detail[3] = data[0].i; /* UV1 */99.1124 + vertex->detail[4] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */99.1125 + vertex->detail[5] = parse_intensity_colour( ta_status.intensity2, data[3].f ); /* ARGB1 */99.1126 + break;99.1128 case TA_VERTEX_SPRITE:99.1129 - vertex->y = data[0].f;99.1130 - vertex->z = data[1].f;99.1131 - vertex++;99.1132 - ta_status.vertex_count++;99.1133 - vertex->x = data[2].f;99.1134 - vertex->y = data[3].f;99.1135 - vertex->z = 0;99.1136 - vertex->detail[0] = 0;99.1137 - ta_status.poly_vertex[0].detail[0] = 0;99.1138 - ta_status.poly_vertex[1].detail[0] = 0;99.1139 - break;99.1140 + vertex->y = data[0].f;99.1141 + vertex->z = data[1].f;99.1142 + vertex++;99.1143 + ta_status.vertex_count++;99.1144 + vertex->x = data[2].f;99.1145 + vertex->y = data[3].f;99.1146 + vertex->z = 0;99.1147 + vertex->detail[0] = 0;99.1148 + ta_status.poly_vertex[0].detail[0] = 0;99.1149 + ta_status.poly_vertex[1].detail[0] = 0;99.1150 + break;99.1151 case TA_VERTEX_TEX_SPRITE:99.1152 - vertex->y = data[0].f;99.1153 - vertex->z = data[1].f;99.1154 - vertex++;99.1155 - ta_status.vertex_count++;99.1156 - vertex->x = data[2].f;99.1157 - vertex->y = data[3].f;99.1158 - vertex->z = 0;99.1159 - vertex->detail[0] = 0;99.1160 - vertex->detail[1] = 0;99.1161 - ta_status.poly_vertex[0].detail[0] = data[5].i;99.1162 - ta_status.poly_vertex[0].detail[1] = 0;99.1163 - ta_status.poly_vertex[1].detail[0] = data[6].i;99.1164 - ta_status.poly_vertex[1].detail[1] = 0;99.1165 - ta_status.poly_vertex[2].detail[0] = data[7].i;99.1166 - break;99.1167 + vertex->y = data[0].f;99.1168 + vertex->z = data[1].f;99.1169 + vertex++;99.1170 + ta_status.vertex_count++;99.1171 + vertex->x = data[2].f;99.1172 + vertex->y = data[3].f;99.1173 + vertex->z = 0;99.1174 + vertex->detail[0] = 0;99.1175 + vertex->detail[1] = 0;99.1176 + ta_status.poly_vertex[0].detail[0] = data[5].i;99.1177 + ta_status.poly_vertex[0].detail[1] = 0;99.1178 + ta_status.poly_vertex[1].detail[0] = data[6].i;99.1179 + ta_status.poly_vertex[1].detail[1] = 0;99.1180 + ta_status.poly_vertex[2].detail[0] = data[7].i;99.1181 + break;99.1182 case TA_VERTEX_MOD_VOLUME:99.1183 case TA_VERTEX_LISTLESS:99.1184 - vertex->y = data[0].f;99.1185 - vertex->z = data[1].f;99.1186 - break;99.1187 + vertex->y = data[0].f;99.1188 + vertex->z = data[1].f;99.1189 + break;99.1190 }99.1191 ta_status.state = STATE_IN_POLYGON;99.1192 }99.1193 @@ -1043,120 +1043,120 @@99.1195 switch( ta_status.state ) {99.1196 case STATE_ERROR:99.1197 - /* Fatal error raised - stop processing until reset */99.1198 - return;99.1199 + /* Fatal error raised - stop processing until reset */99.1200 + return;99.1202 case STATE_EXPECT_POLY_BLOCK2:99.1203 - /* This is always a pair of floating-point colours */99.1204 - ta_status.intensity1 =99.1205 - parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );99.1206 - ta_status.intensity2 =99.1207 - parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );99.1208 - ta_status.state = STATE_IN_LIST;99.1209 - break;99.1210 + /* This is always a pair of floating-point colours */99.1211 + ta_status.intensity1 =99.1212 + parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );99.1213 + ta_status.intensity2 =99.1214 + parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );99.1215 + ta_status.state = STATE_IN_LIST;99.1216 + break;99.1218 case STATE_EXPECT_VERTEX_BLOCK2:99.1219 - ta_parse_vertex_block2( data );99.1220 - if( ta_status.vertex_count == ta_status.max_vertex ) {99.1221 - ta_split_polygon();99.1222 - }99.1223 - break;99.1224 + ta_parse_vertex_block2( data );99.1225 + if( ta_status.vertex_count == ta_status.max_vertex ) {99.1226 + ta_split_polygon();99.1227 + }99.1228 + break;99.1230 case STATE_EXPECT_END_VERTEX_BLOCK2:99.1231 - ta_parse_vertex_block2( data );99.1232 - if( ta_status.vertex_count < 3 ) {99.1233 - ta_bad_input_error();99.1234 - } else {99.1235 - ta_commit_polygon();99.1236 - }99.1237 - ta_status.vertex_count = 0;99.1238 - ta_status.poly_parity = 0;99.1239 - ta_status.state = STATE_IN_LIST;99.1240 - break;99.1241 + ta_parse_vertex_block2( data );99.1242 + if( ta_status.vertex_count < 3 ) {99.1243 + ta_bad_input_error();99.1244 + } else {99.1245 + ta_commit_polygon();99.1246 + }99.1247 + ta_status.vertex_count = 0;99.1248 + ta_status.poly_parity = 0;99.1249 + ta_status.state = STATE_IN_LIST;99.1250 + break;99.1251 case STATE_IN_LIST:99.1252 case STATE_IN_POLYGON:99.1253 case STATE_IDLE:99.1254 - switch( TA_CMD( data->i ) ) {99.1255 - case TA_CMD_END_LIST:99.1256 - if( ta_status.state == STATE_IN_POLYGON ) {99.1257 - ta_bad_input_error();99.1258 - ta_end_list();99.1259 - ta_status.state = STATE_ERROR; /* Abort further processing */99.1260 - } else {99.1261 - ta_end_list();99.1262 - }99.1263 - break;99.1264 - case TA_CMD_CLIP:99.1265 - if( ta_status.state == STATE_IN_POLYGON ) {99.1266 - ta_bad_input_error();99.1267 - ta_status.accept_vertexes = FALSE;99.1268 - /* Enter stuffed up mode */99.1269 - }99.1270 - ta_status.clip.x1 = data[4].i & 0x3F;99.1271 - ta_status.clip.y1 = data[5].i & 0x0F;99.1272 - ta_status.clip.x2 = data[6].i & 0x3F;99.1273 - ta_status.clip.y2 = data[7].i & 0x0F;99.1274 - if( ta_status.clip.x2 >= ta_status.width )99.1275 - ta_status.clip.x2 = ta_status.width - 1;99.1276 - if( ta_status.clip.y2 >= ta_status.height )99.1277 - ta_status.clip.y2 = ta_status.height - 1;99.1278 - break;99.1279 - case TA_CMD_POLYGON_CONTEXT:99.1280 - if( ta_status.state == STATE_IDLE ) {99.1281 - ta_init_list( TA_POLYCMD_LISTTYPE( data->i ) );99.1282 - }99.1283 -99.1284 - if( ta_status.vertex_count != 0 ) {99.1285 - /* Error, and not a very well handled one either */99.1286 - ta_bad_input_error();99.1287 - ta_status.accept_vertexes = FALSE;99.1288 - } else {99.1289 - if( TA_IS_MODIFIER_LIST( ta_status.current_list_type ) ) {99.1290 - ta_parse_modifier_context(data);99.1291 - } else {99.1292 - ta_parse_polygon_context(data);99.1293 - }99.1294 - }99.1295 - break;99.1296 - case TA_CMD_SPRITE_CONTEXT:99.1297 - if( ta_status.state == STATE_IDLE ) {99.1298 - ta_init_list( TA_POLYCMD_LISTTYPE( data->i ) );99.1299 - }99.1300 + switch( TA_CMD( data->i ) ) {99.1301 + case TA_CMD_END_LIST:99.1302 + if( ta_status.state == STATE_IN_POLYGON ) {99.1303 + ta_bad_input_error();99.1304 + ta_end_list();99.1305 + ta_status.state = STATE_ERROR; /* Abort further processing */99.1306 + } else {99.1307 + ta_end_list();99.1308 + }99.1309 + break;99.1310 + case TA_CMD_CLIP:99.1311 + if( ta_status.state == STATE_IN_POLYGON ) {99.1312 + ta_bad_input_error();99.1313 + ta_status.accept_vertexes = FALSE;99.1314 + /* Enter stuffed up mode */99.1315 + }99.1316 + ta_status.clip.x1 = data[4].i & 0x3F;99.1317 + ta_status.clip.y1 = data[5].i & 0x0F;99.1318 + ta_status.clip.x2 = data[6].i & 0x3F;99.1319 + ta_status.clip.y2 = data[7].i & 0x0F;99.1320 + if( ta_status.clip.x2 >= ta_status.width )99.1321 + ta_status.clip.x2 = ta_status.width - 1;99.1322 + if( ta_status.clip.y2 >= ta_status.height )99.1323 + ta_status.clip.y2 = ta_status.height - 1;99.1324 + break;99.1325 + case TA_CMD_POLYGON_CONTEXT:99.1326 + if( ta_status.state == STATE_IDLE ) {99.1327 + ta_init_list( TA_POLYCMD_LISTTYPE( data->i ) );99.1328 + }99.1330 - if( ta_status.vertex_count != 0 ) {99.1331 - ta_fill_vertexes();99.1332 - ta_commit_polygon();99.1333 - }99.1334 + if( ta_status.vertex_count != 0 ) {99.1335 + /* Error, and not a very well handled one either */99.1336 + ta_bad_input_error();99.1337 + ta_status.accept_vertexes = FALSE;99.1338 + } else {99.1339 + if( TA_IS_MODIFIER_LIST( ta_status.current_list_type ) ) {99.1340 + ta_parse_modifier_context(data);99.1341 + } else {99.1342 + ta_parse_polygon_context(data);99.1343 + }99.1344 + }99.1345 + break;99.1346 + case TA_CMD_SPRITE_CONTEXT:99.1347 + if( ta_status.state == STATE_IDLE ) {99.1348 + ta_init_list( TA_POLYCMD_LISTTYPE( data->i ) );99.1349 + }99.1351 - ta_parse_sprite_context(data);99.1352 - break;99.1353 - case TA_CMD_VERTEX:99.1354 - ta_status.state = STATE_IN_POLYGON;99.1355 - ta_parse_vertex(data);99.1356 -99.1357 - if( ta_status.state == STATE_EXPECT_VERTEX_BLOCK2 ) {99.1358 - if( TA_IS_END_VERTEX(data[0].i) ) {99.1359 - ta_status.state = STATE_EXPECT_END_VERTEX_BLOCK2;99.1360 - }99.1361 - } else if( TA_IS_END_VERTEX(data->i) ) {99.1362 - if( ta_status.vertex_count < 3 ) {99.1363 - ta_bad_input_error();99.1364 - } else {99.1365 - ta_commit_polygon();99.1366 - }99.1367 - ta_status.vertex_count = 0;99.1368 - ta_status.poly_parity = 0;99.1369 - ta_status.state = STATE_IN_LIST;99.1370 - } else if( ta_status.vertex_count == ta_status.max_vertex ) {99.1371 - ta_split_polygon();99.1372 - }99.1373 - break;99.1374 - default:99.1375 - if( ta_status.state == STATE_IN_POLYGON ) {99.1376 - ta_bad_input_error();99.1377 - }99.1378 - }99.1379 - break;99.1380 + if( ta_status.vertex_count != 0 ) {99.1381 + ta_fill_vertexes();99.1382 + ta_commit_polygon();99.1383 + }99.1384 +99.1385 + ta_parse_sprite_context(data);99.1386 + break;99.1387 + case TA_CMD_VERTEX:99.1388 + ta_status.state = STATE_IN_POLYGON;99.1389 + ta_parse_vertex(data);99.1390 +99.1391 + if( ta_status.state == STATE_EXPECT_VERTEX_BLOCK2 ) {99.1392 + if( TA_IS_END_VERTEX(data[0].i) ) {99.1393 + ta_status.state = STATE_EXPECT_END_VERTEX_BLOCK2;99.1394 + }99.1395 + } else if( TA_IS_END_VERTEX(data->i) ) {99.1396 + if( ta_status.vertex_count < 3 ) {99.1397 + ta_bad_input_error();99.1398 + } else {99.1399 + ta_commit_polygon();99.1400 + }99.1401 + ta_status.vertex_count = 0;99.1402 + ta_status.poly_parity = 0;99.1403 + ta_status.state = STATE_IN_LIST;99.1404 + } else if( ta_status.vertex_count == ta_status.max_vertex ) {99.1405 + ta_split_polygon();99.1406 + }99.1407 + break;99.1408 + default:99.1409 + if( ta_status.state == STATE_IN_POLYGON ) {99.1410 + ta_bad_input_error();99.1411 + }99.1412 + }99.1413 + break;99.1414 }99.1416 }99.1417 @@ -1175,11 +1175,11 @@99.1418 void pvr2_ta_write( unsigned char *buf, uint32_t length )99.1419 {99.1420 if( ta_status.debug_output ) {99.1421 - fwrite_dump32( (uint32_t *)buf, length, stderr );99.1422 + fwrite_dump32( (uint32_t *)buf, length, stderr );99.1423 }99.1425 for( ; length >=32; length -= 32 ) {99.1426 - pvr2_ta_process_block( buf );99.1427 - buf += 32;99.1428 + pvr2_ta_process_block( buf );99.1429 + buf += 32;99.1430 }99.1431 }
100.1 --- a/src/pvr2/texcache.c Mon Jul 14 07:42:45 2008 +0000100.2 +++ b/src/pvr2/texcache.c Mon Jul 14 07:44:42 2008 +0000100.3 @@ -64,12 +64,12 @@100.4 {100.5 int i;100.6 for( i=0; i<PVR2_RAM_PAGES; i++ ) {100.7 - texcache_page_lookup[i] = EMPTY_ENTRY;100.8 + texcache_page_lookup[i] = EMPTY_ENTRY;100.9 }100.10 for( i=0; i<MAX_TEXTURES; i++ ) {100.11 - texcache_free_list[i] = i;100.12 - texcache_active_list[i].texture_addr = -1;100.13 - texcache_active_list[i].next = EMPTY_ENTRY;100.14 + texcache_free_list[i] = i;100.15 + texcache_active_list[i].texture_addr = -1;100.16 + texcache_active_list[i].next = EMPTY_ENTRY;100.17 }100.18 texcache_free_ptr = 0;100.19 texcache_ref_counter = 0;100.20 @@ -86,7 +86,7 @@100.22 glGenTextures( MAX_TEXTURES, texids );100.23 for( i=0; i<MAX_TEXTURES; i++ ) {100.24 - texcache_active_list[i].texture_id = texids[i];100.25 + texcache_active_list[i].texture_id = texids[i];100.26 }100.27 }100.29 @@ -98,11 +98,11 @@100.30 int i;100.31 /* clear structures */100.32 for( i=0; i<PVR2_RAM_PAGES; i++ ) {100.33 - texcache_page_lookup[i] = EMPTY_ENTRY;100.34 + texcache_page_lookup[i] = EMPTY_ENTRY;100.35 }100.36 for( i=0; i<MAX_TEXTURES; i++ ) {100.37 - texcache_free_list[i] = i;100.38 - texcache_active_list[i].next = EMPTY_ENTRY;100.39 + texcache_free_list[i] = i;100.40 + texcache_active_list[i].next = EMPTY_ENTRY;100.41 }100.42 texcache_free_ptr = 0;100.43 texcache_ref_counter = 0;100.44 @@ -118,9 +118,9 @@100.45 GLuint texids[MAX_TEXTURES];100.46 int i;100.47 texcache_flush();100.48 -100.49 +100.50 for( i=0; i<MAX_TEXTURES; i++ ) {100.51 - texids[i] = texcache_active_list[i].texture_id;100.52 + texids[i] = texcache_active_list[i].texture_id;100.53 }100.54 glDeleteTextures( MAX_TEXTURES, texids );100.55 }100.56 @@ -134,19 +134,19 @@100.57 texcache_active_list[slot].texture_addr = -1;100.58 texcache_active_list[slot].next = EMPTY_ENTRY; /* Just for safety */100.59 if( texcache_page_lookup[evict_page] == slot ) {100.60 - texcache_page_lookup[evict_page] = replace_next;100.61 + texcache_page_lookup[evict_page] = replace_next;100.62 } else {100.63 - texcache_entry_index idx = texcache_page_lookup[evict_page];100.64 - texcache_entry_index next;100.65 - do {100.66 - next = texcache_active_list[idx].next;100.67 - if( next == slot ) {100.68 - assert( idx != replace_next );100.69 - texcache_active_list[idx].next = replace_next;100.70 - break;100.71 - }100.72 - idx = next;100.73 - } while( next != EMPTY_ENTRY );100.74 + texcache_entry_index idx = texcache_page_lookup[evict_page];100.75 + texcache_entry_index next;100.76 + do {100.77 + next = texcache_active_list[idx].next;100.78 + if( next == slot ) {100.79 + assert( idx != replace_next );100.80 + texcache_active_list[idx].next = replace_next;100.81 + break;100.82 + }100.83 + idx = next;100.84 + } while( next != EMPTY_ENTRY );100.85 }100.86 }100.88 @@ -161,14 +161,14 @@100.89 int lru_value = texcache_active_list[0].lru_count;100.90 int i;100.91 for( i=1; i<MAX_TEXTURES; i++ ) {100.92 - /* FIXME: account for rollover */100.93 - if( texcache_active_list[i].lru_count < lru_value ) {100.94 - slot = i;100.95 - lru_value = texcache_active_list[i].lru_count;100.96 - }100.97 + /* FIXME: account for rollover */100.98 + if( texcache_active_list[i].lru_count < lru_value ) {100.99 + slot = i;100.100 + lru_value = texcache_active_list[i].lru_count;100.101 + }100.102 }100.103 texcache_evict(slot);100.104 -100.105 +100.106 return slot;100.107 }100.109 @@ -179,16 +179,16 @@100.110 uint32_t texture_page = texture_addr >> 12;100.111 texcache_entry_index idx = texcache_page_lookup[texture_page];100.112 if( idx == EMPTY_ENTRY )100.113 - return;100.114 + return;100.115 assert( texcache_free_ptr >= 0 );100.116 do {100.117 - texcache_entry_t entry = &texcache_active_list[idx];100.118 - entry->texture_addr = -1;100.119 - /* release entry */100.120 - texcache_free_ptr--;100.121 - texcache_free_list[texcache_free_ptr] = idx;100.122 - idx = entry->next;100.123 - entry->next = EMPTY_ENTRY;100.124 + texcache_entry_t entry = &texcache_active_list[idx];100.125 + entry->texture_addr = -1;100.126 + /* release entry */100.127 + texcache_free_ptr--;100.128 + texcache_free_list[texcache_free_ptr] = idx;100.129 + idx = entry->next;100.130 + entry->next = EMPTY_ENTRY;100.131 } while( idx != EMPTY_ENTRY );100.132 texcache_page_lookup[texture_page] = EMPTY_ENTRY;100.133 }100.134 @@ -203,12 +203,12 @@100.135 {100.136 int i;100.137 for( i=0; i<MAX_TEXTURES; i++ ) {100.138 - if( texcache_active_list[i].texture_addr != -1 &&100.139 - PVR2_TEX_IS_PALETTE(texcache_active_list[i].mode) ) {100.140 - texcache_evict( i );100.141 - texcache_free_ptr--;100.142 - texcache_free_list[texcache_free_ptr] = i;100.143 - }100.144 + if( texcache_active_list[i].texture_addr != -1 &&100.145 + PVR2_TEX_IS_PALETTE(texcache_active_list[i].mode) ) {100.146 + texcache_evict( i );100.147 + texcache_free_ptr--;100.148 + texcache_free_list[texcache_free_ptr] = i;100.149 + }100.150 }100.151 }100.153 @@ -216,7 +216,7 @@100.154 {100.155 int i;100.156 for( i=0; i<inbytes; i++ ) {100.157 - *out++ = pal[*in++];100.158 + *out++ = pal[*in++];100.159 }100.160 }100.162 @@ -224,7 +224,7 @@100.163 {100.164 int i;100.165 for( i=0; i<inbytes; i++ ) {100.166 - *out++ = (uint16_t)pal[*in++];100.167 + *out++ = (uint16_t)pal[*in++];100.168 }100.169 }100.171 @@ -232,9 +232,9 @@100.172 {100.173 int i;100.174 for( i=0; i<inbytes; i++ ) {100.175 - *out++ = pal[*in & 0x0F];100.176 - *out++ = pal[(*in >> 4)];100.177 - in++;100.178 + *out++ = pal[*in & 0x0F];100.179 + *out++ = pal[(*in >> 4)];100.180 + in++;100.181 }100.182 }100.184 @@ -243,9 +243,9 @@100.185 {100.186 int i;100.187 for( i=0; i<inbytes; i++ ) {100.188 - *out++ = (uint16_t)pal[*in & 0x0F];100.189 - *out++ = (uint16_t)pal[(*in >> 4)];100.190 - in++;100.191 + *out++ = (uint16_t)pal[*in & 0x0F];100.192 + *out++ = (uint16_t)pal[(*in >> 4)];100.193 + in++;100.194 }100.195 }100.197 @@ -256,32 +256,32 @@100.198 };100.200 static void vq_get_codebook( struct vq_codebook *codebook,100.201 - uint16_t *input )100.202 + uint16_t *input )100.203 {100.204 /* Detwiddle the codebook, for the sake of my own sanity if nothing else */100.205 uint16_t *p = (uint16_t *)input;100.206 int i;100.207 for( i=0; i<256; i++ ) {100.208 - codebook->quad[i][0] = *p++;100.209 - codebook->quad[i][2] = *p++;100.210 - codebook->quad[i][1] = *p++;100.211 - codebook->quad[i][3] = *p++;100.212 + codebook->quad[i][0] = *p++;100.213 + codebook->quad[i][2] = *p++;100.214 + codebook->quad[i][1] = *p++;100.215 + codebook->quad[i][3] = *p++;100.216 }100.217 }100.219 static void vq_decode( uint16_t *output, unsigned char *input, int width, int height,100.220 - struct vq_codebook *codebook ) {100.221 + struct vq_codebook *codebook ) {100.222 int i,j;100.223 -100.224 +100.225 uint8_t *c = (uint8_t *)input;100.226 for( j=0; j<height; j+=2 ) {100.227 - for( i=0; i<width; i+=2 ) {100.228 - uint8_t code = *c++;100.229 - output[i + j*width] = codebook->quad[code][0];100.230 - output[i + 1 + j*width] = codebook->quad[code][1];100.231 - output[i + (j+1)*width] = codebook->quad[code][2];100.232 - output[i + 1 + (j+1)*width] = codebook->quad[code][3];100.233 - }100.234 + for( i=0; i<width; i+=2 ) {100.235 + uint8_t code = *c++;100.236 + output[i + j*width] = codebook->quad[code][0];100.237 + output[i + 1 + j*width] = codebook->quad[code][1];100.238 + output[i + (j+1)*width] = codebook->quad[code][2];100.239 + output[i + 1 + (j+1)*width] = codebook->quad[code][3];100.240 + }100.241 }100.242 }100.244 @@ -310,15 +310,15 @@100.245 int x, y;100.246 uint32_t *p = input;100.247 for( y=0; y<height; y++ ) {100.248 - for( x=0; x<width; x+=2 ) {100.249 - float u = (float)(*p & 0xFF);100.250 - float y0 = (float)( (*p>>8)&0xFF );100.251 - float v = (float)( (*p>>16)&0xFF );100.252 - float y1 = (float)( (*p>>24)&0xFF );100.253 - *output++ = yuv_to_rgb32( y0, u, v );100.254 - *output++ = yuv_to_rgb32( y1, u, v );100.255 - p++;100.256 - }100.257 + for( x=0; x<width; x+=2 ) {100.258 + float u = (float)(*p & 0xFF);100.259 + float y0 = (float)( (*p>>8)&0xFF );100.260 + float v = (float)( (*p>>16)&0xFF );100.261 + float y1 = (float)( (*p>>24)&0xFF );100.262 + *output++ = yuv_to_rgb32( y0, u, v );100.263 + *output++ = yuv_to_rgb32( y1, u, v );100.264 + p++;100.265 + }100.266 }100.267 }100.269 @@ -327,7 +327,7 @@100.270 * bound OpenGL texture.100.271 */100.272 static void texcache_load_texture( uint32_t texture_addr, int width, int height,100.273 - int mode ) {100.274 + int mode ) {100.275 int bpp_shift = 1; /* bytes per (output) pixel as a power of 2 */100.276 GLint intFormat = GL_RGBA, format, type;100.277 int tex_format = mode & PVR2_TEX_FORMAT_MASK;100.278 @@ -340,179 +340,179 @@100.279 switch( tex_format ) {100.280 case PVR2_TEX_FORMAT_IDX4:100.281 case PVR2_TEX_FORMAT_IDX8:100.282 - /* For indexed-colour modes, we need to lookup the palette control100.283 - * word to determine the de-indexed texture format.100.284 - */100.285 - switch( MMIO_READ( PVR2, RENDER_PALETTE ) & 0x03 ) {100.286 - case 0: /* ARGB1555 */100.287 - format = GL_BGRA;100.288 - type = GL_UNSIGNED_SHORT_1_5_5_5_REV;100.289 - break;100.290 - case 1: /* RGB565 */100.291 - intFormat = GL_RGB;100.292 - format = GL_RGB;100.293 - type = GL_UNSIGNED_SHORT_5_6_5;100.294 - break;100.295 - case 2: /* ARGB4444 */100.296 - format = GL_BGRA;100.297 - type = GL_UNSIGNED_SHORT_4_4_4_4_REV;100.298 - break;100.299 - case 3: /* ARGB8888 */100.300 - format = GL_BGRA;100.301 - type = GL_UNSIGNED_BYTE;100.302 - bpp_shift = 2;100.303 - break;100.304 - default:100.305 - return; /* Can't happen, but it makes gcc stop complaining */100.306 - }100.307 - break;100.308 -100.309 - case PVR2_TEX_FORMAT_ARGB1555:100.310 - format = GL_BGRA;100.311 - type = GL_UNSIGNED_SHORT_1_5_5_5_REV;100.312 - break;100.313 - case PVR2_TEX_FORMAT_RGB565:100.314 - intFormat = GL_RGB;100.315 - format = GL_RGB;100.316 - type = GL_UNSIGNED_SHORT_5_6_5;100.317 - break;100.318 - case PVR2_TEX_FORMAT_ARGB4444:100.319 - format = GL_BGRA;100.320 - type = GL_UNSIGNED_SHORT_4_4_4_4_REV;100.321 - break;100.322 - case PVR2_TEX_FORMAT_YUV422:100.323 - /* YUV422 isn't directly supported by most implementations, so decode100.324 - * it to a (reasonably) standard ARGB32.100.325 - */100.326 - bpp_shift = 2;100.327 - format = GL_BGRA;100.328 - type = GL_UNSIGNED_BYTE;100.329 - break;100.330 - case PVR2_TEX_FORMAT_BUMPMAP:100.331 - ERROR( "Bumpmap not supported" );100.332 - return;100.333 - default:100.334 - ERROR( "Undefined texture format" );100.335 - return;100.336 + /* For indexed-colour modes, we need to lookup the palette control100.337 + * word to determine the de-indexed texture format.100.338 + */100.339 + switch( MMIO_READ( PVR2, RENDER_PALETTE ) & 0x03 ) {100.340 + case 0: /* ARGB1555 */100.341 + format = GL_BGRA;100.342 + type = GL_UNSIGNED_SHORT_1_5_5_5_REV;100.343 + break;100.344 + case 1: /* RGB565 */100.345 + intFormat = GL_RGB;100.346 + format = GL_RGB;100.347 + type = GL_UNSIGNED_SHORT_5_6_5;100.348 + break;100.349 + case 2: /* ARGB4444 */100.350 + format = GL_BGRA;100.351 + type = GL_UNSIGNED_SHORT_4_4_4_4_REV;100.352 + break;100.353 + case 3: /* ARGB8888 */100.354 + format = GL_BGRA;100.355 + type = GL_UNSIGNED_BYTE;100.356 + bpp_shift = 2;100.357 + break;100.358 + default:100.359 + return; /* Can't happen, but it makes gcc stop complaining */100.360 + }100.361 + break;100.362 +100.363 + case PVR2_TEX_FORMAT_ARGB1555:100.364 + format = GL_BGRA;100.365 + type = GL_UNSIGNED_SHORT_1_5_5_5_REV;100.366 + break;100.367 + case PVR2_TEX_FORMAT_RGB565:100.368 + intFormat = GL_RGB;100.369 + format = GL_RGB;100.370 + type = GL_UNSIGNED_SHORT_5_6_5;100.371 + break;100.372 + case PVR2_TEX_FORMAT_ARGB4444:100.373 + format = GL_BGRA;100.374 + type = GL_UNSIGNED_SHORT_4_4_4_4_REV;100.375 + break;100.376 + case PVR2_TEX_FORMAT_YUV422:100.377 + /* YUV422 isn't directly supported by most implementations, so decode100.378 + * it to a (reasonably) standard ARGB32.100.379 + */100.380 + bpp_shift = 2;100.381 + format = GL_BGRA;100.382 + type = GL_UNSIGNED_BYTE;100.383 + break;100.384 + case PVR2_TEX_FORMAT_BUMPMAP:100.385 + ERROR( "Bumpmap not supported" );100.386 + return;100.387 + default:100.388 + ERROR( "Undefined texture format" );100.389 + return;100.390 }100.391 -100.392 +100.393 if( PVR2_TEX_IS_STRIDE(mode) && tex_format != PVR2_TEX_FORMAT_IDX4 &&100.394 - tex_format != PVR2_TEX_FORMAT_IDX8 ) {100.395 - /* Stride textures cannot be mip-mapped, compressed, indexed or twiddled */100.396 - uint32_t stride = (MMIO_READ( PVR2, RENDER_TEXSIZE ) & 0x003F) << 5;100.397 - unsigned char data[(width*height) << bpp_shift];100.398 - if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {100.399 - unsigned char tmp[(width*height)<<1];100.400 - pvr2_vram64_read_stride( tmp, width<<1, texture_addr, stride<<1, height );100.401 - yuv_decode( (uint32_t *)data, (uint32_t *)tmp, width, height );100.402 - } else {100.403 - pvr2_vram64_read_stride( data, width<<bpp_shift, texture_addr, stride<<bpp_shift, height );100.404 - }100.405 - glTexImage2D( GL_TEXTURE_2D, 0, intFormat, width, height, 0, format, type, data );100.406 - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);100.407 - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);100.408 - return;100.409 + tex_format != PVR2_TEX_FORMAT_IDX8 ) {100.410 + /* Stride textures cannot be mip-mapped, compressed, indexed or twiddled */100.411 + uint32_t stride = (MMIO_READ( PVR2, RENDER_TEXSIZE ) & 0x003F) << 5;100.412 + unsigned char data[(width*height) << bpp_shift];100.413 + if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {100.414 + unsigned char tmp[(width*height)<<1];100.415 + pvr2_vram64_read_stride( tmp, width<<1, texture_addr, stride<<1, height );100.416 + yuv_decode( (uint32_t *)data, (uint32_t *)tmp, width, height );100.417 + } else {100.418 + pvr2_vram64_read_stride( data, width<<bpp_shift, texture_addr, stride<<bpp_shift, height );100.419 + }100.420 + glTexImage2D( GL_TEXTURE_2D, 0, intFormat, width, height, 0, format, type, data );100.421 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);100.422 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);100.423 + return;100.424 }100.426 if( PVR2_TEX_IS_COMPRESSED(mode) ) {100.427 - uint16_t tmp[VQ_CODEBOOK_SIZE];100.428 - pvr2_vram64_read( (unsigned char *)tmp, texture_addr, VQ_CODEBOOK_SIZE );100.429 - texture_addr += VQ_CODEBOOK_SIZE;100.430 - vq_get_codebook( &codebook, tmp );100.431 + uint16_t tmp[VQ_CODEBOOK_SIZE];100.432 + pvr2_vram64_read( (unsigned char *)tmp, texture_addr, VQ_CODEBOOK_SIZE );100.433 + texture_addr += VQ_CODEBOOK_SIZE;100.434 + vq_get_codebook( &codebook, tmp );100.435 }100.437 int level=0, last_level = 0, mip_width = width, mip_height = height, src_bytes, dest_bytes;100.438 if( PVR2_TEX_IS_MIPMAPPED(mode) ) {100.439 - uint32_t src_offset = 0;100.440 - filter = GL_LINEAR_MIPMAP_LINEAR;100.441 - mip_height = height = width;100.442 - while( (1<<last_level) < width ) {100.443 - last_level++;100.444 - src_offset += ((width>>last_level)*(width>>last_level));100.445 - }100.446 - if( width != 1 ) {100.447 - src_offset += 3;100.448 - }100.449 - if( PVR2_TEX_IS_COMPRESSED(mode) ) {100.450 - src_offset >>= 2;100.451 - } else if( tex_format == PVR2_TEX_FORMAT_IDX4 ) {100.452 - src_offset >>= 1;100.453 - } else if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {100.454 - src_offset <<= 1;100.455 - } else if( tex_format != PVR2_TEX_FORMAT_IDX8 ) {100.456 - src_offset <<= bpp_shift;100.457 - }100.458 - texture_addr += src_offset;100.459 + uint32_t src_offset = 0;100.460 + filter = GL_LINEAR_MIPMAP_LINEAR;100.461 + mip_height = height = width;100.462 + while( (1<<last_level) < width ) {100.463 + last_level++;100.464 + src_offset += ((width>>last_level)*(width>>last_level));100.465 + }100.466 + if( width != 1 ) {100.467 + src_offset += 3;100.468 + }100.469 + if( PVR2_TEX_IS_COMPRESSED(mode) ) {100.470 + src_offset >>= 2;100.471 + } else if( tex_format == PVR2_TEX_FORMAT_IDX4 ) {100.472 + src_offset >>= 1;100.473 + } else if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {100.474 + src_offset <<= 1;100.475 + } else if( tex_format != PVR2_TEX_FORMAT_IDX8 ) {100.476 + src_offset <<= bpp_shift;100.477 + }100.478 + texture_addr += src_offset;100.479 }100.480 -100.481 +100.483 dest_bytes = (mip_width * mip_height) << bpp_shift;100.484 src_bytes = dest_bytes; // Modes will change this (below)100.486 for( level=0; level<= last_level; level++ ) {100.487 - unsigned char data[dest_bytes];100.488 - /* load data from image, detwiddling/uncompressing as required */100.489 - if( tex_format == PVR2_TEX_FORMAT_IDX8 ) {100.490 - src_bytes = (mip_width * mip_height);100.491 - int bank = (mode >> 25) &0x03;100.492 - uint32_t *palette = ((uint32_t *)mmio_region_PVR2PAL.mem) + (bank<<8);100.493 - unsigned char tmp[src_bytes];100.494 - pvr2_vram64_read_twiddled_8( tmp, texture_addr, mip_width, mip_height );100.495 - if( bpp_shift == 2 ) {100.496 - decode_pal8_to_32( (uint32_t *)data, tmp, src_bytes, palette );100.497 - } else {100.498 - decode_pal8_to_16( (uint16_t *)data, tmp, src_bytes, palette );100.499 - }100.500 - } else if( tex_format == PVR2_TEX_FORMAT_IDX4 ) {100.501 - src_bytes = (mip_width * mip_height) >> 1;100.502 - int bank = (mode >>21 ) & 0x3F;100.503 - uint32_t *palette = ((uint32_t *)mmio_region_PVR2PAL.mem) + (bank<<4);100.504 - unsigned char tmp[src_bytes];100.505 - pvr2_vram64_read_twiddled_4( tmp, texture_addr, mip_width, mip_height );100.506 - if( bpp_shift == 2 ) {100.507 - decode_pal4_to_32( (uint32_t *)data, tmp, src_bytes, palette );100.508 - } else {100.509 - decode_pal4_to_16( (uint16_t *)data, tmp, src_bytes, palette );100.510 - }100.511 - } else if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {100.512 - src_bytes = ((mip_width*mip_height)<<1);100.513 - unsigned char tmp[src_bytes];100.514 - if( PVR2_TEX_IS_TWIDDLED(mode) ) {100.515 - pvr2_vram64_read_twiddled_16( tmp, texture_addr, mip_width, mip_height );100.516 - } else {100.517 - pvr2_vram64_read( tmp, texture_addr, src_bytes );100.518 - }100.519 - yuv_decode( (uint32_t *)data, (uint32_t *)tmp, mip_width, mip_height );100.520 - } else if( PVR2_TEX_IS_COMPRESSED(mode) ) {100.521 - src_bytes = ((mip_width*mip_height) >> 2);100.522 - unsigned char tmp[src_bytes];100.523 - if( PVR2_TEX_IS_TWIDDLED(mode) ) {100.524 - pvr2_vram64_read_twiddled_8( tmp, texture_addr, mip_width>>1, mip_height>>1 );100.525 - } else {100.526 - pvr2_vram64_read( tmp, texture_addr, src_bytes );100.527 - }100.528 - vq_decode( (uint16_t *)data, tmp, mip_width, mip_height, &codebook );100.529 - } else if( PVR2_TEX_IS_TWIDDLED(mode) ) {100.530 - pvr2_vram64_read_twiddled_16( data, texture_addr, mip_width, mip_height );100.531 - } else {100.532 - pvr2_vram64_read( data, texture_addr, src_bytes );100.533 - }100.534 -100.535 - /* Pass to GL */100.536 - if( level == last_level && level != 0 ) { /* 1x1 stored within a 2x2 */100.537 - glTexImage2D( GL_TEXTURE_2D, level, intFormat, 1, 1, 0, format, type,100.538 - data + (3 << bpp_shift) );100.539 - } else {100.540 - glTexImage2D( GL_TEXTURE_2D, level, intFormat, mip_width, mip_height, 0, format, type,100.541 - data );100.542 - if( mip_width > 2 ) {100.543 - mip_width >>= 1;100.544 - mip_height >>= 1;100.545 - dest_bytes >>= 2;100.546 - src_bytes >>= 2;100.547 - }100.548 - texture_addr -= src_bytes;100.549 - }100.550 + unsigned char data[dest_bytes];100.551 + /* load data from image, detwiddling/uncompressing as required */100.552 + if( tex_format == PVR2_TEX_FORMAT_IDX8 ) {100.553 + src_bytes = (mip_width * mip_height);100.554 + int bank = (mode >> 25) &0x03;100.555 + uint32_t *palette = ((uint32_t *)mmio_region_PVR2PAL.mem) + (bank<<8);100.556 + unsigned char tmp[src_bytes];100.557 + pvr2_vram64_read_twiddled_8( tmp, texture_addr, mip_width, mip_height );100.558 + if( bpp_shift == 2 ) {100.559 + decode_pal8_to_32( (uint32_t *)data, tmp, src_bytes, palette );100.560 + } else {100.561 + decode_pal8_to_16( (uint16_t *)data, tmp, src_bytes, palette );100.562 + }100.563 + } else if( tex_format == PVR2_TEX_FORMAT_IDX4 ) {100.564 + src_bytes = (mip_width * mip_height) >> 1;100.565 + int bank = (mode >>21 ) & 0x3F;100.566 + uint32_t *palette = ((uint32_t *)mmio_region_PVR2PAL.mem) + (bank<<4);100.567 + unsigned char tmp[src_bytes];100.568 + pvr2_vram64_read_twiddled_4( tmp, texture_addr, mip_width, mip_height );100.569 + if( bpp_shift == 2 ) {100.570 + decode_pal4_to_32( (uint32_t *)data, tmp, src_bytes, palette );100.571 + } else {100.572 + decode_pal4_to_16( (uint16_t *)data, tmp, src_bytes, palette );100.573 + }100.574 + } else if( tex_format == PVR2_TEX_FORMAT_YUV422 ) {100.575 + src_bytes = ((mip_width*mip_height)<<1);100.576 + unsigned char tmp[src_bytes];100.577 + if( PVR2_TEX_IS_TWIDDLED(mode) ) {100.578 + pvr2_vram64_read_twiddled_16( tmp, texture_addr, mip_width, mip_height );100.579 + } else {100.580 + pvr2_vram64_read( tmp, texture_addr, src_bytes );100.581 + }100.582 + yuv_decode( (uint32_t *)data, (uint32_t *)tmp, mip_width, mip_height );100.583 + } else if( PVR2_TEX_IS_COMPRESSED(mode) ) {100.584 + src_bytes = ((mip_width*mip_height) >> 2);100.585 + unsigned char tmp[src_bytes];100.586 + if( PVR2_TEX_IS_TWIDDLED(mode) ) {100.587 + pvr2_vram64_read_twiddled_8( tmp, texture_addr, mip_width>>1, mip_height>>1 );100.588 + } else {100.589 + pvr2_vram64_read( tmp, texture_addr, src_bytes );100.590 + }100.591 + vq_decode( (uint16_t *)data, tmp, mip_width, mip_height, &codebook );100.592 + } else if( PVR2_TEX_IS_TWIDDLED(mode) ) {100.593 + pvr2_vram64_read_twiddled_16( data, texture_addr, mip_width, mip_height );100.594 + } else {100.595 + pvr2_vram64_read( data, texture_addr, src_bytes );100.596 + }100.597 +100.598 + /* Pass to GL */100.599 + if( level == last_level && level != 0 ) { /* 1x1 stored within a 2x2 */100.600 + glTexImage2D( GL_TEXTURE_2D, level, intFormat, 1, 1, 0, format, type,100.601 + data + (3 << bpp_shift) );100.602 + } else {100.603 + glTexImage2D( GL_TEXTURE_2D, level, intFormat, mip_width, mip_height, 0, format, type,100.604 + data );100.605 + if( mip_width > 2 ) {100.606 + mip_width >>= 1;100.607 + mip_height >>= 1;100.608 + dest_bytes >>= 2;100.609 + src_bytes >>= 2;100.610 + }100.611 + texture_addr -= src_bytes;100.612 + }100.613 }100.615 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);100.616 @@ -536,25 +536,25 @@100.617 texcache_entry_index next;100.618 texcache_entry_index idx = texcache_page_lookup[texture_page];100.619 while( idx != EMPTY_ENTRY ) {100.620 - texcache_entry_t entry = &texcache_active_list[idx];100.621 - if( entry->texture_addr == texture_addr &&100.622 - entry->mode == texture_word &&100.623 - entry->width == width &&100.624 - entry->height == height ) {100.625 - entry->lru_count = texcache_ref_counter++;100.626 - return entry->texture_id;100.627 - }100.628 + texcache_entry_t entry = &texcache_active_list[idx];100.629 + if( entry->texture_addr == texture_addr &&100.630 + entry->mode == texture_word &&100.631 + entry->width == width &&100.632 + entry->height == height ) {100.633 + entry->lru_count = texcache_ref_counter++;100.634 + return entry->texture_id;100.635 + }100.636 idx = entry->next;100.637 }100.639 -100.640 +100.641 /* Not found - check the free list */100.642 texcache_entry_index slot = 0;100.644 if( texcache_free_ptr < MAX_TEXTURES ) {100.645 - slot = texcache_free_list[texcache_free_ptr++];100.646 + slot = texcache_free_list[texcache_free_ptr++];100.647 } else {100.648 - slot = texcache_evict_lru();100.649 + slot = texcache_evict_lru();100.650 }100.652 /* Construct new entry */100.653 @@ -567,14 +567,14 @@100.654 /* Add entry to the lookup table */100.655 next = texcache_page_lookup[texture_page];100.656 if( next == slot ) {100.657 - int i;100.658 - fprintf( stderr, "Active list: " );100.659 - for( i=0; i<MAX_TEXTURES; i++ ) {100.660 - fprintf( stderr, "%d, ", texcache_active_list[i].next );100.661 - }100.662 - fprintf( stderr, "\n" );100.663 - assert( next != slot );100.664 -100.665 + int i;100.666 + fprintf( stderr, "Active list: " );100.667 + for( i=0; i<MAX_TEXTURES; i++ ) {100.668 + fprintf( stderr, "%d, ", texcache_active_list[i].next );100.669 + }100.670 + fprintf( stderr, "\n" );100.671 + assert( next != slot );100.672 +100.673 }100.674 assert( next != slot );100.675 texcache_active_list[slot].next = next;100.676 @@ -597,30 +597,30 @@100.677 {100.678 int i;100.679 int slot_found[MAX_TEXTURES];100.680 -100.681 +100.682 memset( slot_found, 0, sizeof(slot_found) );100.684 /* Check entries on the free list */100.685 for( i= texcache_free_ptr; i< MAX_TEXTURES; i++ ) {100.686 - int slot = texcache_free_list[i];100.687 - assert( slot_found[slot] == 0 );100.688 - assert( texcache_active_list[slot].next == EMPTY_ENTRY );100.689 - slot_found[slot] = 1;100.690 + int slot = texcache_free_list[i];100.691 + assert( slot_found[slot] == 0 );100.692 + assert( texcache_active_list[slot].next == EMPTY_ENTRY );100.693 + slot_found[slot] = 1;100.694 }100.696 /* Check entries on the active lists */100.697 for( i=0; i< PVR2_RAM_PAGES; i++ ) {100.698 - int slot = texcache_page_lookup[i];100.699 - while( slot != EMPTY_ENTRY ) {100.700 - assert( slot_found[slot] == 0 );100.701 - assert( (texcache_active_list[slot].texture_addr >> 12) == i );100.702 - slot_found[slot] = 2;100.703 - slot = texcache_active_list[slot].next;100.704 - }100.705 + int slot = texcache_page_lookup[i];100.706 + while( slot != EMPTY_ENTRY ) {100.707 + assert( slot_found[slot] == 0 );100.708 + assert( (texcache_active_list[slot].texture_addr >> 12) == i );100.709 + slot_found[slot] = 2;100.710 + slot = texcache_active_list[slot].next;100.711 + }100.712 }100.714 /* Make sure we didn't miss any entries */100.715 for( i=0; i<MAX_TEXTURES; i++ ) {100.716 - assert( slot_found[i] != 0 );100.717 + assert( slot_found[i] != 0 );100.718 }100.719 }
101.1 --- a/src/pvr2/yuv.c Mon Jul 14 07:42:45 2008 +0000101.2 +++ b/src/pvr2/yuv.c Mon Jul 14 07:44:42 2008 +0000101.3 @@ -43,41 +43,41 @@101.4 * Transformation table for yuv420.101.5 */101.6 uint16_t yuv420_lut[512] = { 0, 128, 64, 129, 1, 130, 65, 131, 2, 132, 66, 133, 3, 134, 67, 135, 4, 192, 68, 193, 5, 194, 69, 195, 6, 196, 70, 197, 7, 198, 71, 199,101.7 - 0, 136, 64, 137, 1, 138, 65, 139, 2, 140, 66, 141, 3, 142, 67, 143, 4, 200, 68, 201, 5, 202, 69, 203, 6, 204, 70, 205, 7, 206, 71, 207,101.8 - 8, 144, 72, 145, 9, 146, 73, 147, 10, 148, 74, 149, 11, 150, 75, 151, 12, 208, 76, 209, 13, 210, 77, 211, 14, 212, 78, 213, 15, 214, 79, 215,101.9 - 8, 152, 72, 153, 9, 154, 73, 155, 10, 156, 74, 157, 11, 158, 75, 159, 12, 216, 76, 217, 13, 218, 77, 219, 14, 220, 78, 221, 15, 222, 79, 223,101.10 - 16, 160, 80, 161, 17, 162, 81, 163, 18, 164, 82, 165, 19, 166, 83, 167, 20, 224, 84, 225, 21, 226, 85, 227, 22, 228, 86, 229, 23, 230, 87, 231,101.11 - 16, 168, 80, 169, 17, 170, 81, 171, 18, 172, 82, 173, 19, 174, 83, 175, 20, 232, 84, 233, 21, 234, 85, 235, 22, 236, 86, 237, 23, 238, 87, 239,101.12 - 24, 176, 88, 177, 25, 178, 89, 179, 26, 180, 90, 181, 27, 182, 91, 183, 28, 240, 92, 241, 29, 242, 93, 243, 30, 244, 94, 245, 31, 246, 95, 247,101.13 - 24, 184, 88, 185, 25, 186, 89, 187, 26, 188, 90, 189, 27, 190, 91, 191, 28, 248, 92, 249, 29, 250, 93, 251, 30, 252, 94, 253, 31, 254, 95, 255,101.14 - 32, 256, 96, 257, 33, 258, 97, 259, 34, 260, 98, 261, 35, 262, 99, 263, 36, 320, 100, 321, 37, 322, 101, 323, 38, 324, 102, 325, 39, 326, 103, 327,101.15 - 32, 264, 96, 265, 33, 266, 97, 267, 34, 268, 98, 269, 35, 270, 99, 271, 36, 328, 100, 329, 37, 330, 101, 331, 38, 332, 102, 333, 39, 334, 103, 335,101.16 - 40, 272, 104, 273, 41, 274, 105, 275, 42, 276, 106, 277, 43, 278, 107, 279, 44, 336, 108, 337, 45, 338, 109, 339, 46, 340, 110, 341, 47, 342, 111, 343,101.17 - 40, 280, 104, 281, 41, 282, 105, 283, 42, 284, 106, 285, 43, 286, 107, 287, 44, 344, 108, 345, 45, 346, 109, 347, 46, 348, 110, 349, 47, 350, 111, 351,101.18 - 48, 288, 112, 289, 49, 290, 113, 291, 50, 292, 114, 293, 51, 294, 115, 295, 52, 352, 116, 353, 53, 354, 117, 355, 54, 356, 118, 357, 55, 358, 119, 359,101.19 - 48, 296, 112, 297, 49, 298, 113, 299, 50, 300, 114, 301, 51, 302, 115, 303, 52, 360, 116, 361, 53, 362, 117, 363, 54, 364, 118, 365, 55, 366, 119, 367,101.20 - 56, 304, 120, 305, 57, 306, 121, 307, 58, 308, 122, 309, 59, 310, 123, 311, 60, 368, 124, 369, 61, 370, 125, 371, 62, 372, 126, 373, 63, 374, 127, 375,101.21 - 56, 312, 120, 313, 57, 314, 121, 315, 58, 316, 122, 317, 59, 318, 123, 319, 60, 376, 124, 377, 61, 378, 125, 379, 62, 380, 126, 381, 63, 382, 127, 383 };101.22 + 0, 136, 64, 137, 1, 138, 65, 139, 2, 140, 66, 141, 3, 142, 67, 143, 4, 200, 68, 201, 5, 202, 69, 203, 6, 204, 70, 205, 7, 206, 71, 207,101.23 + 8, 144, 72, 145, 9, 146, 73, 147, 10, 148, 74, 149, 11, 150, 75, 151, 12, 208, 76, 209, 13, 210, 77, 211, 14, 212, 78, 213, 15, 214, 79, 215,101.24 + 8, 152, 72, 153, 9, 154, 73, 155, 10, 156, 74, 157, 11, 158, 75, 159, 12, 216, 76, 217, 13, 218, 77, 219, 14, 220, 78, 221, 15, 222, 79, 223,101.25 + 16, 160, 80, 161, 17, 162, 81, 163, 18, 164, 82, 165, 19, 166, 83, 167, 20, 224, 84, 225, 21, 226, 85, 227, 22, 228, 86, 229, 23, 230, 87, 231,101.26 + 16, 168, 80, 169, 17, 170, 81, 171, 18, 172, 82, 173, 19, 174, 83, 175, 20, 232, 84, 233, 21, 234, 85, 235, 22, 236, 86, 237, 23, 238, 87, 239,101.27 + 24, 176, 88, 177, 25, 178, 89, 179, 26, 180, 90, 181, 27, 182, 91, 183, 28, 240, 92, 241, 29, 242, 93, 243, 30, 244, 94, 245, 31, 246, 95, 247,101.28 + 24, 184, 88, 185, 25, 186, 89, 187, 26, 188, 90, 189, 27, 190, 91, 191, 28, 248, 92, 249, 29, 250, 93, 251, 30, 252, 94, 253, 31, 254, 95, 255,101.29 + 32, 256, 96, 257, 33, 258, 97, 259, 34, 260, 98, 261, 35, 262, 99, 263, 36, 320, 100, 321, 37, 322, 101, 323, 38, 324, 102, 325, 39, 326, 103, 327,101.30 + 32, 264, 96, 265, 33, 266, 97, 267, 34, 268, 98, 269, 35, 270, 99, 271, 36, 328, 100, 329, 37, 330, 101, 331, 38, 332, 102, 333, 39, 334, 103, 335,101.31 + 40, 272, 104, 273, 41, 274, 105, 275, 42, 276, 106, 277, 43, 278, 107, 279, 44, 336, 108, 337, 45, 338, 109, 339, 46, 340, 110, 341, 47, 342, 111, 343,101.32 + 40, 280, 104, 281, 41, 282, 105, 283, 42, 284, 106, 285, 43, 286, 107, 287, 44, 344, 108, 345, 45, 346, 109, 347, 46, 348, 110, 349, 47, 350, 111, 351,101.33 + 48, 288, 112, 289, 49, 290, 113, 291, 50, 292, 114, 293, 51, 294, 115, 295, 52, 352, 116, 353, 53, 354, 117, 355, 54, 356, 118, 357, 55, 358, 119, 359,101.34 + 48, 296, 112, 297, 49, 298, 113, 299, 50, 300, 114, 301, 51, 302, 115, 303, 52, 360, 116, 361, 53, 362, 117, 363, 54, 364, 118, 365, 55, 366, 119, 367,101.35 + 56, 304, 120, 305, 57, 306, 121, 307, 58, 308, 122, 309, 59, 310, 123, 311, 60, 368, 124, 369, 61, 370, 125, 371, 62, 372, 126, 373, 63, 374, 127, 375,101.36 + 56, 312, 120, 313, 57, 314, 121, 315, 58, 316, 122, 317, 59, 318, 123, 319, 60, 376, 124, 377, 61, 378, 125, 379, 62, 380, 126, 381, 63, 382, 127, 383 };101.38 /**101.39 * Transformation table for YUV422 inputs101.40 */101.41 uint16_t yuv422_lut[512] = { 0, 128, 64, 129, 1, 130, 65, 131, 2, 132, 66, 133, 3, 134, 67, 135, 4, 192, 68, 193, 5, 194, 69, 195, 6, 196, 70, 197, 7, 198, 71, 199,101.42 - 8, 136, 72, 137, 9, 138, 73, 139, 10, 140, 74, 141, 11, 142, 75, 143, 12, 200, 76, 201, 13, 202, 77, 203, 14, 204, 78, 205, 15, 206, 79, 207,101.43 - 16, 144, 80, 145, 17, 146, 81, 147, 18, 148, 82, 149, 19, 150, 83, 151, 20, 208, 84, 209, 21, 210, 85, 211, 22, 212, 86, 213, 23, 214, 87, 215,101.44 - 24, 152, 88, 153, 25, 154, 89, 155, 26, 156, 90, 157, 27, 158, 91, 159, 28, 216, 92, 217, 29, 218, 93, 219, 30, 220, 94, 221, 31, 222, 95, 223,101.45 - 32, 160, 96, 161, 33, 162, 97, 163, 34, 164, 98, 165, 35, 166, 99, 167, 36, 224, 100, 225, 37, 226, 101, 227, 38, 228, 102, 229, 39, 230, 103, 231,101.46 - 40, 168, 104, 169, 41, 170, 105, 171, 42, 172, 106, 173, 43, 174, 107, 175, 44, 232, 108, 233, 45, 234, 109, 235, 46, 236, 110, 237, 47, 238, 111, 239,101.47 - 48, 176, 112, 177, 49, 178, 113, 179, 50, 180, 114, 181, 51, 182, 115, 183, 52, 240, 116, 241, 53, 242, 117, 243, 54, 244, 118, 245, 55, 246, 119, 247,101.48 - 56, 184, 120, 185, 57, 186, 121, 187, 58, 188, 122, 189, 59, 190, 123, 191, 60, 248, 124, 249, 61, 250, 125, 251, 62, 252, 126, 253, 63, 254, 127, 255,101.49 - 256, 384, 320, 385, 257, 386, 321, 387, 258, 388, 322, 389, 259, 390, 323, 391, 260, 448, 324, 449, 261, 450, 325, 451, 262, 452, 326, 453, 263, 454, 327, 455,101.50 - 264, 392, 328, 393, 265, 394, 329, 395, 266, 396, 330, 397, 267, 398, 331, 399, 268, 456, 332, 457, 269, 458, 333, 459, 270, 460, 334, 461, 271, 462, 335, 463,101.51 - 272, 400, 336, 401, 273, 402, 337, 403, 274, 404, 338, 405, 275, 406, 339, 407, 276, 464, 340, 465, 277, 466, 341, 467, 278, 468, 342, 469, 279, 470, 343, 471,101.52 - 280, 408, 344, 409, 281, 410, 345, 411, 282, 412, 346, 413, 283, 414, 347, 415, 284, 472, 348, 473, 285, 474, 349, 475, 286, 476, 350, 477, 287, 478, 351, 479,101.53 - 288, 416, 352, 417, 289, 418, 353, 419, 290, 420, 354, 421, 291, 422, 355, 423, 292, 480, 356, 481, 293, 482, 357, 483, 294, 484, 358, 485, 295, 486, 359, 487,101.54 - 296, 424, 360, 425, 297, 426, 361, 427, 298, 428, 362, 429, 299, 430, 363, 431, 300, 488, 364, 489, 301, 490, 365, 491, 302, 492, 366, 493, 303, 494, 367, 495,101.55 - 304, 432, 368, 433, 305, 434, 369, 435, 306, 436, 370, 437, 307, 438, 371, 439, 308, 496, 372, 497, 309, 498, 373, 499, 310, 500, 374, 501, 311, 502, 375, 503,101.56 - 312, 440, 376, 441, 313, 442, 377, 443, 314, 444, 378, 445, 315, 446, 379, 447, 316, 504, 380, 505, 317, 506, 381, 507, 318, 508, 382, 509, 319, 510, 383, 511 };101.57 + 8, 136, 72, 137, 9, 138, 73, 139, 10, 140, 74, 141, 11, 142, 75, 143, 12, 200, 76, 201, 13, 202, 77, 203, 14, 204, 78, 205, 15, 206, 79, 207,101.58 + 16, 144, 80, 145, 17, 146, 81, 147, 18, 148, 82, 149, 19, 150, 83, 151, 20, 208, 84, 209, 21, 210, 85, 211, 22, 212, 86, 213, 23, 214, 87, 215,101.59 + 24, 152, 88, 153, 25, 154, 89, 155, 26, 156, 90, 157, 27, 158, 91, 159, 28, 216, 92, 217, 29, 218, 93, 219, 30, 220, 94, 221, 31, 222, 95, 223,101.60 + 32, 160, 96, 161, 33, 162, 97, 163, 34, 164, 98, 165, 35, 166, 99, 167, 36, 224, 100, 225, 37, 226, 101, 227, 38, 228, 102, 229, 39, 230, 103, 231,101.61 + 40, 168, 104, 169, 41, 170, 105, 171, 42, 172, 106, 173, 43, 174, 107, 175, 44, 232, 108, 233, 45, 234, 109, 235, 46, 236, 110, 237, 47, 238, 111, 239,101.62 + 48, 176, 112, 177, 49, 178, 113, 179, 50, 180, 114, 181, 51, 182, 115, 183, 52, 240, 116, 241, 53, 242, 117, 243, 54, 244, 118, 245, 55, 246, 119, 247,101.63 + 56, 184, 120, 185, 57, 186, 121, 187, 58, 188, 122, 189, 59, 190, 123, 191, 60, 248, 124, 249, 61, 250, 125, 251, 62, 252, 126, 253, 63, 254, 127, 255,101.64 + 256, 384, 320, 385, 257, 386, 321, 387, 258, 388, 322, 389, 259, 390, 323, 391, 260, 448, 324, 449, 261, 450, 325, 451, 262, 452, 326, 453, 263, 454, 327, 455,101.65 + 264, 392, 328, 393, 265, 394, 329, 395, 266, 396, 330, 397, 267, 398, 331, 399, 268, 456, 332, 457, 269, 458, 333, 459, 270, 460, 334, 461, 271, 462, 335, 463,101.66 + 272, 400, 336, 401, 273, 402, 337, 403, 274, 404, 338, 405, 275, 406, 339, 407, 276, 464, 340, 465, 277, 466, 341, 467, 278, 468, 342, 469, 279, 470, 343, 471,101.67 + 280, 408, 344, 409, 281, 410, 345, 411, 282, 412, 346, 413, 283, 414, 347, 415, 284, 472, 348, 473, 285, 474, 349, 475, 286, 476, 350, 477, 287, 478, 351, 479,101.68 + 288, 416, 352, 417, 289, 418, 353, 419, 290, 420, 354, 421, 291, 422, 355, 423, 292, 480, 356, 481, 293, 482, 357, 483, 294, 484, 358, 485, 295, 486, 359, 487,101.69 + 296, 424, 360, 425, 297, 426, 361, 427, 298, 428, 362, 429, 299, 430, 363, 431, 300, 488, 364, 489, 301, 490, 365, 491, 302, 492, 366, 493, 303, 494, 367, 495,101.70 + 304, 432, 368, 433, 305, 434, 369, 435, 306, 436, 370, 437, 307, 438, 371, 439, 308, 496, 372, 497, 309, 498, 373, 499, 310, 500, 374, 501, 311, 502, 375, 503,101.71 + 312, 440, 376, 441, 313, 442, 377, 443, 314, 444, 378, 445, 315, 446, 379, 447, 316, 504, 380, 505, 317, 506, 381, 507, 318, 508, 382, 509, 319, 510, 383, 511 };101.73 /**101.74 * Input is 8x8 U, 8x8 V, 8x8 Y00, 8x8 Y01, 8x8 Y10, 8x8 Y11, 8 bits each,101.75 @@ -88,7 +88,7 @@101.76 {101.77 int i;101.78 for( i=0; i<512; i++ ) {101.79 - dest[i] = src[yuv420_lut[i]];101.80 + dest[i] = src[yuv420_lut[i]];101.81 }101.82 }101.84 @@ -96,7 +96,7 @@101.85 {101.86 int i;101.87 for( i=0; i<512; i++ ) {101.88 - dest[i] = src[yuv422_lut[i]];101.89 + dest[i] = src[yuv422_lut[i]];101.90 }101.91 }101.93 @@ -109,25 +109,25 @@101.94 unsigned char output[512];101.96 if( pvr2_yuv_state.input_format == FORMAT_YUV420 ) {101.97 - pvr2_decode_yuv420( output, data );101.98 + pvr2_decode_yuv420( output, data );101.99 } else {101.100 - pvr2_decode_yuv422( output, data );101.101 + pvr2_decode_yuv422( output, data );101.102 }101.103 -101.104 +101.105 uint32_t target = pvr2_yuv_state.target +101.106 - (pvr2_yuv_state.y * pvr2_yuv_state.width * 512) +101.107 - (pvr2_yuv_state.x * 32);101.108 + (pvr2_yuv_state.y * pvr2_yuv_state.width * 512) +101.109 + (pvr2_yuv_state.x * 32);101.111 pvr2_vram64_write_stride( target, output, 32, pvr2_yuv_state.width*32, 16 );101.112 if( ++pvr2_yuv_state.x >= pvr2_yuv_state.width ) {101.113 - pvr2_yuv_state.x = 0;101.114 - pvr2_yuv_state.y++;101.115 - if( pvr2_yuv_state.y >= pvr2_yuv_state.height ) {101.116 - asic_event( EVENT_PVR_YUV_DONE );101.117 - pvr2_yuv_state.y = 0;101.118 - }101.119 + pvr2_yuv_state.x = 0;101.120 + pvr2_yuv_state.y++;101.121 + if( pvr2_yuv_state.y >= pvr2_yuv_state.height ) {101.122 + asic_event( EVENT_PVR_YUV_DONE );101.123 + pvr2_yuv_state.y = 0;101.124 + }101.125 }101.126 -101.127 +101.128 MMIO_WRITE( PVR2, YUV_COUNT, MMIO_READ( PVR2, YUV_COUNT ) + 1 );101.129 }101.131 @@ -141,26 +141,26 @@101.132 int block_size = yuv_block_size[pvr2_yuv_state.input_format];101.134 if( pvr2_yuv_state.data_length != 0 ) { /* Append to existing data */101.135 - int tmp = MIN( length, block_size - pvr2_yuv_state.data_length );101.136 - memcpy( pvr2_yuv_state.data + pvr2_yuv_state.data_length,101.137 - data, tmp );101.138 - pvr2_yuv_state.data_length += tmp;101.139 - data += tmp;101.140 - length -= tmp;101.141 - if( pvr2_yuv_state.data_length == block_size ) {101.142 - pvr2_yuv_process_block( pvr2_yuv_state.data );101.143 - }101.144 + int tmp = MIN( length, block_size - pvr2_yuv_state.data_length );101.145 + memcpy( pvr2_yuv_state.data + pvr2_yuv_state.data_length,101.146 + data, tmp );101.147 + pvr2_yuv_state.data_length += tmp;101.148 + data += tmp;101.149 + length -= tmp;101.150 + if( pvr2_yuv_state.data_length == block_size ) {101.151 + pvr2_yuv_process_block( pvr2_yuv_state.data );101.152 + }101.153 }101.155 while( length >= block_size ) {101.156 - pvr2_yuv_process_block( data );101.157 - data += block_size;101.158 - length -= block_size;101.159 + pvr2_yuv_process_block( data );101.160 + data += block_size;101.161 + length -= block_size;101.162 }101.163 -101.164 +101.165 if( length != 0 ) { /* Save the left over data */101.166 - memcpy( pvr2_yuv_state.data, data, length );101.167 - pvr2_yuv_state.data_length = length;101.168 + memcpy( pvr2_yuv_state.data, data, length );101.169 + pvr2_yuv_state.data_length = length;101.170 }101.171 }101.173 @@ -179,8 +179,8 @@101.174 pvr2_yuv_state.height = ((config>>8) & 0x3f) +1;101.175 pvr2_yuv_state.input_format = (config & 0x01000000) ? FORMAT_YUV422 : FORMAT_YUV420;101.176 if( config & 0x00010000 ) {101.177 - pvr2_yuv_state.height *= pvr2_yuv_state.width;101.178 - pvr2_yuv_state.width = 1;101.179 + pvr2_yuv_state.height *= pvr2_yuv_state.width;101.180 + pvr2_yuv_state.width = 1;101.181 }101.182 }101.184 @@ -192,8 +192,8 @@101.185 int pvr2_yuv_load_state( FILE *f )101.186 {101.187 if( fread( &pvr2_yuv_state, sizeof(pvr2_yuv_state), 1, f ) != 1 ) {101.188 - return 1;101.189 + return 1;101.190 } else {101.191 - return 0;101.192 + return 0;101.193 }101.194 }
102.1 --- a/src/serial.h Mon Jul 14 07:42:45 2008 +0000102.2 +++ b/src/serial.h Mon Jul 14 07:44:42 2008 +0000102.3 @@ -15,8 +15,8 @@102.4 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the102.5 * GNU General Public License for more details.102.6 */102.7 -#ifndef dream_serial_H102.8 -#define dream_serial_H 1102.9 +#ifndef lxdream_serial_H102.10 +#define lxdream_serial_H 1102.12 #include <stdint.h>102.14 @@ -48,4 +48,4 @@102.15 }102.16 #endif102.18 -#endif102.19 +#endif /* !lxdream_serial_H */
103.1 --- a/src/sh4/dmac.c Mon Jul 14 07:42:45 2008 +0000103.2 +++ b/src/sh4/dmac.c Mon Jul 14 07:44:42 2008 +0000103.3 @@ -63,18 +63,18 @@103.4 uint32_t oldval = DMA_CONTROL(channel);103.5 int resource;103.6 MMIO_WRITE( DMAC, CHCR0 + (channel<<4), val );103.7 -103.8 +103.9 /* If TE or IE are cleared, clear the interrupt request */103.10 if( IS_CHANNEL_IRQ_ACTIVE(oldval) &&103.11 - !IS_CHANNEL_IRQ_ACTIVE(val) )103.12 - intc_clear_interrupt( INT_DMA_DMTE0+channel );103.13 -103.14 + !IS_CHANNEL_IRQ_ACTIVE(val) )103.15 + intc_clear_interrupt( INT_DMA_DMTE0+channel );103.16 +103.17 resource = CHANNEL_RESOURCE(val);103.18 if( IS_CHANNEL_ENABLED(val) ) {103.19 - if( resource >= DMARES_MEMORY_TO_MEMORY_AUTO &&103.20 - resource < DMARES_SCI_TRANSMIT_EMPTY ) {103.21 - /* Autorun */103.22 - }103.23 + if( resource >= DMARES_MEMORY_TO_MEMORY_AUTO &&103.24 + resource < DMARES_SCI_TRANSMIT_EMPTY ) {103.25 + /* Autorun */103.26 + }103.27 }103.29 /* Everything else we don't need to care about until we actually try to103.30 @@ -91,14 +91,14 @@103.31 {103.32 switch( reg ) {103.33 case DMAOR:103.34 - MMIO_WRITE( DMAC, reg, val );103.35 - break;103.36 + MMIO_WRITE( DMAC, reg, val );103.37 + break;103.38 case CHCR0: DMAC_set_control( 0, val ); break;103.39 case CHCR1: DMAC_set_control( 1, val ); break;103.40 case CHCR2: DMAC_set_control( 2, val ); break;103.41 case CHCR3: DMAC_set_control( 3, val ); break;103.42 default:103.43 - MMIO_WRITE( DMAC, reg, val );103.44 + MMIO_WRITE( DMAC, reg, val );103.45 }103.46 }103.48 @@ -118,46 +118,46 @@103.49 uint32_t control = DMA_CONTROL(channel);103.51 if( IS_CHANNEL_ENABLED(control) ) {103.52 - uint32_t source = DMA_SOURCE(channel);103.53 - uint32_t dest = DMA_DEST(channel);103.54 - uint32_t count = DMA_COUNT( channel );103.55 - if( count == 0 )103.56 - count = 0x01000000;103.57 - if( run_count == 0 || run_count > count )103.58 - run_count = count;103.59 - uint32_t xfersize = DMAC_xfer_size[ (control >> 4)&0x07 ];103.60 - int source_step, dest_step;103.61 - int resource = (control >> 8) & 0x0F;103.62 - switch( (control >> 14) & 0x03 ) {103.63 - case 0: dest_step = 0; break;103.64 - case 1: dest_step = xfersize; break;103.65 - case 2: dest_step = -xfersize; break;103.66 - case 3: dest_step = 0; break; /* Illegal */103.67 - }103.68 - switch( (control >> 12) & 0x03 ) {103.69 - case 0: source_step = 0; break;103.70 - case 1: source_step = xfersize; break;103.71 - case 2: source_step = -xfersize; break;103.72 - case 3: source_step = 0; break; /* Illegal */103.73 - }103.74 -103.75 - while( run_count > 0 ) {103.76 - /* Origin */103.77 - if( (resource & 0x02) == 0 ) {103.78 - /* Source is a normal memory address */103.79 -103.80 - } else {103.81 - /* Device */103.82 - }103.83 -103.84 - /* Destination */103.85 - if( (resource & 0x01) == 0 ) {103.86 - /* Destination is a normal memory address */103.87 - } else {103.88 - }103.89 - run_count--;103.90 - count--;103.91 - }103.92 + uint32_t source = DMA_SOURCE(channel);103.93 + uint32_t dest = DMA_DEST(channel);103.94 + uint32_t count = DMA_COUNT( channel );103.95 + if( count == 0 )103.96 + count = 0x01000000;103.97 + if( run_count == 0 || run_count > count )103.98 + run_count = count;103.99 + uint32_t xfersize = DMAC_xfer_size[ (control >> 4)&0x07 ];103.100 + int source_step, dest_step;103.101 + int resource = (control >> 8) & 0x0F;103.102 + switch( (control >> 14) & 0x03 ) {103.103 + case 0: dest_step = 0; break;103.104 + case 1: dest_step = xfersize; break;103.105 + case 2: dest_step = -xfersize; break;103.106 + case 3: dest_step = 0; break; /* Illegal */103.107 + }103.108 + switch( (control >> 12) & 0x03 ) {103.109 + case 0: source_step = 0; break;103.110 + case 1: source_step = xfersize; break;103.111 + case 2: source_step = -xfersize; break;103.112 + case 3: source_step = 0; break; /* Illegal */103.113 + }103.114 +103.115 + while( run_count > 0 ) {103.116 + /* Origin */103.117 + if( (resource & 0x02) == 0 ) {103.118 + /* Source is a normal memory address */103.119 +103.120 + } else {103.121 + /* Device */103.122 + }103.123 +103.124 + /* Destination */103.125 + if( (resource & 0x01) == 0 ) {103.126 + /* Destination is a normal memory address */103.127 + } else {103.128 + }103.129 + run_count--;103.130 + count--;103.131 + }103.132 }103.133 #endif103.134 }103.135 @@ -177,14 +177,14 @@103.136 char tmp[32];103.138 if( !IS_CHANNEL_ENABLED(control) || !IS_DMAC_ENABLED() )103.139 - return 0;103.140 -103.141 + return 0;103.142 +103.143 if( ((control >> 8) & 0x0F) != DMARES_MEMORY_TO_DEVICE ) {103.144 - /* Error? */103.145 -103.146 - return 0;103.147 + /* Error? */103.148 +103.149 + return 0;103.150 }103.151 -103.152 +103.153 source = DMA_SOURCE(channel);103.154 count = DMA_COUNT(channel);103.155 if( count == 0 ) count = 0x01000000;103.156 @@ -192,33 +192,33 @@103.157 size = DMAC_xfer_size[ (control >> 4)&0x07 ];103.158 run_count = numBytes / size;103.159 if( run_count > count || run_count == 0 )103.160 - run_count = count;103.161 + run_count = count;103.163 /* Do copy - FIXME: doesn't work when crossing regions */103.164 sh4ptr_t region = mem_get_region( source );103.165 switch( (control >> 12) & 0x03 ) {103.166 case 0:103.167 - memcpy( tmp, region, size );103.168 - for( i=0; i<run_count; i++ ) {103.169 - memcpy( buf, tmp, size );103.170 - buf += size;103.171 - }103.172 - break;103.173 + memcpy( tmp, region, size );103.174 + for( i=0; i<run_count; i++ ) {103.175 + memcpy( buf, tmp, size );103.176 + buf += size;103.177 + }103.178 + break;103.179 case 1:103.180 - i = run_count * size;103.181 - memcpy( buf, region, i );103.182 - source += i;103.183 - break;103.184 + i = run_count * size;103.185 + memcpy( buf, region, i );103.186 + source += i;103.187 + break;103.188 case 2:103.189 - for( i=0; i<run_count; i++ ) {103.190 - memcpy( buf, region, size );103.191 - buf += size;103.192 - region -= size;103.193 - }103.194 - source -= (run_count * size);103.195 - break;103.196 + for( i=0; i<run_count; i++ ) {103.197 + memcpy( buf, region, size );103.198 + buf += size;103.199 + region -= size;103.200 + }103.201 + source -= (run_count * size);103.202 + break;103.203 default:103.204 - return 0; /* Illegal */103.205 + return 0; /* Illegal */103.206 }103.208 /* Update the channel registers */103.209 @@ -226,10 +226,10 @@103.210 MMIO_WRITE( DMAC, SAR0 + (channel<<4), source );103.211 MMIO_WRITE( DMAC, DMATCR0 + (channel<<4), count );103.212 if( count == 0 ) {103.213 - control |= CHCR_TE;103.214 - if( IS_CHANNEL_IRQ_ENABLED(control) )103.215 - intc_raise_interrupt( INT_DMA_DMTE0 + channel );103.216 - MMIO_WRITE( DMAC, CHCR0 + (channel<<4), control );103.217 + control |= CHCR_TE;103.218 + if( IS_CHANNEL_IRQ_ENABLED(control) )103.219 + intc_raise_interrupt( INT_DMA_DMTE0 + channel );103.220 + MMIO_WRITE( DMAC, CHCR0 + (channel<<4), control );103.221 }103.223 return run_count * size;103.224 @@ -241,13 +241,13 @@103.225 uint32_t dest, count, run_count, size, i;103.227 if( !IS_CHANNEL_ENABLED(control) || !IS_DMAC_ENABLED() )103.228 - return 0;103.229 -103.230 + return 0;103.231 +103.232 if( ((control >> 8) & 0x0F) != DMARES_DEVICE_TO_MEMORY ) {103.233 - /* Error? */103.234 - return 0;103.235 + /* Error? */103.236 + return 0;103.237 }103.238 -103.239 +103.240 dest = DMA_DEST(channel);103.241 count = DMA_COUNT(channel);103.242 if( count == 0 ) count = 0x01000000;103.243 @@ -255,33 +255,33 @@103.244 size = DMAC_xfer_size[ (control >> 4)&0x07 ];103.245 run_count = numBytes / size;103.246 if( run_count > count || run_count == 0 )103.247 - run_count = count;103.248 + run_count = count;103.250 /* Do copy - FIXME: doesn't work when crossing regions */103.251 sh4ptr_t region = mem_get_region( dest );103.252 switch( (control >> 12) & 0x03 ) {103.253 case 0:103.254 - for( i=0; i<run_count; i++ ) {103.255 - /* Doesn't make a whole lot of sense, but hey... */103.256 - memcpy( region, buf, size );103.257 - buf += size;103.258 - }103.259 - break;103.260 + for( i=0; i<run_count; i++ ) {103.261 + /* Doesn't make a whole lot of sense, but hey... */103.262 + memcpy( region, buf, size );103.263 + buf += size;103.264 + }103.265 + break;103.266 case 1:103.267 - i = run_count * size;103.268 - memcpy( region, buf, i );103.269 - dest += i;103.270 - break;103.271 + i = run_count * size;103.272 + memcpy( region, buf, i );103.273 + dest += i;103.274 + break;103.275 case 2:103.276 - for( i=0; i<run_count; i++ ) {103.277 - memcpy( region, buf, size );103.278 - buf += size;103.279 - region -= size;103.280 - }103.281 - dest -= (run_count * size);103.282 - break;103.283 + for( i=0; i<run_count; i++ ) {103.284 + memcpy( region, buf, size );103.285 + buf += size;103.286 + region -= size;103.287 + }103.288 + dest -= (run_count * size);103.289 + break;103.290 default:103.291 - return 0; /* Illegal */103.292 + return 0; /* Illegal */103.293 }103.295 /* Update the channel registers */103.296 @@ -289,10 +289,10 @@103.297 MMIO_WRITE( DMAC, DAR0 + (channel<<4), dest );103.298 MMIO_WRITE( DMAC, DMATCR0 + (channel<<4), count );103.299 if( count == 0 ) {103.300 - control |= CHCR_TE;103.301 - if( IS_CHANNEL_IRQ_ENABLED(control) )103.302 - intc_raise_interrupt( INT_DMA_DMTE0 + channel );103.303 - MMIO_WRITE( DMAC, CHCR0 + (channel<<4), control );103.304 + control |= CHCR_TE;103.305 + if( IS_CHANNEL_IRQ_ENABLED(control) )103.306 + intc_raise_interrupt( INT_DMA_DMTE0 + channel );103.307 + MMIO_WRITE( DMAC, CHCR0 + (channel<<4), control );103.308 }103.309 return run_count * size;103.310 }103.311 @@ -316,37 +316,37 @@103.312 {103.313 int i;103.314 if( !IS_DMAC_ENABLED() )103.315 - return;103.316 + return;103.317 for( i=0; i<4; i++ ) {103.318 - uint32_t control = DMA_CONTROL(i);103.319 - if( IS_CHANNEL_ENABLED(control) ) {103.320 - uint32_t channel_res = CHANNEL_RESOURCE(control);103.321 - switch( resource ) {103.322 - case DMAC_EXTERNAL:103.323 - if( channel_res == DMARES_MEMORY_TO_MEMORY )103.324 - DMAC_run_channel(i,1);103.325 - break;103.326 - case DMAC_SCI_TDE:103.327 - if( channel_res == DMARES_SCI_TRANSMIT_EMPTY )103.328 - DMAC_run_channel(i,1);103.329 - break;103.330 - case DMAC_SCI_RDF:103.331 - if( channel_res == DMARES_SCI_RECEIVE_FULL )103.332 - DMAC_run_channel(i,1);103.333 - break;103.334 - case DMAC_SCIF_TDE:103.335 - if( channel_res == DMARES_SCIF_TRANSMIT_EMPTY )103.336 - DMAC_run_channel(i,1);103.337 - break;103.338 - case DMAC_SCIF_RDF:103.339 - if( channel_res == DMARES_SCIF_RECEIVE_FULL )103.340 - DMAC_run_channel(i,1);103.341 - break;103.342 - case DMAC_TMU_ICI:103.343 - if( channel_res >= DMARES_MEMORY_TO_MEMORY_TMU )103.344 - DMAC_run_channel(i,1);103.345 - break;103.346 - }103.347 - }103.348 + uint32_t control = DMA_CONTROL(i);103.349 + if( IS_CHANNEL_ENABLED(control) ) {103.350 + uint32_t channel_res = CHANNEL_RESOURCE(control);103.351 + switch( resource ) {103.352 + case DMAC_EXTERNAL:103.353 + if( channel_res == DMARES_MEMORY_TO_MEMORY )103.354 + DMAC_run_channel(i,1);103.355 + break;103.356 + case DMAC_SCI_TDE:103.357 + if( channel_res == DMARES_SCI_TRANSMIT_EMPTY )103.358 + DMAC_run_channel(i,1);103.359 + break;103.360 + case DMAC_SCI_RDF:103.361 + if( channel_res == DMARES_SCI_RECEIVE_FULL )103.362 + DMAC_run_channel(i,1);103.363 + break;103.364 + case DMAC_SCIF_TDE:103.365 + if( channel_res == DMARES_SCIF_TRANSMIT_EMPTY )103.366 + DMAC_run_channel(i,1);103.367 + break;103.368 + case DMAC_SCIF_RDF:103.369 + if( channel_res == DMARES_SCIF_RECEIVE_FULL )103.370 + DMAC_run_channel(i,1);103.371 + break;103.372 + case DMAC_TMU_ICI:103.373 + if( channel_res >= DMARES_MEMORY_TO_MEMORY_TMU )103.374 + DMAC_run_channel(i,1);103.375 + break;103.376 + }103.377 + }103.378 }103.379 }
104.1 --- a/src/sh4/dmac.h Mon Jul 14 07:42:45 2008 +0000104.2 +++ b/src/sh4/dmac.h Mon Jul 14 07:44:42 2008 +0000104.3 @@ -16,8 +16,8 @@104.4 * GNU General Public License for more details.104.5 */104.7 -#ifndef dream_sh4dmac_H104.8 -#define dream_sh4dmac_H 1104.9 +#ifndef lxdream_dmac_H104.10 +#define lxdream_dmac_H 1104.12 #include <stdint.h>104.14 @@ -59,4 +59,5 @@104.15 #ifdef __cplusplus104.16 }104.17 #endif104.18 -#endif104.19 +104.20 +#endif /* !lxdream_dmac_H */
105.1 --- a/src/sh4/ia32abi.h Mon Jul 14 07:42:45 2008 +0000105.2 +++ b/src/sh4/ia32abi.h Mon Jul 14 07:44:42 2008 +0000105.3 @@ -17,8 +17,8 @@105.4 * GNU General Public License for more details.105.5 */105.7 -#ifndef __lxdream_ia32abi_H105.8 -#define __lxdream_ia32abi_H 1105.9 +#ifndef lxdream_ia32abi_H105.10 +#define lxdream_ia32abi_H 1105.12 #define load_ptr( reg, ptr ) load_imm32( reg, (uint32_t)ptr );105.14 @@ -99,7 +99,7 @@105.15 PUSH_r32(R_EBP);105.16 /* mov &sh4r, ebp */105.17 load_ptr( R_EBP, ((uint8_t *)&sh4r) + 128 );105.18 -105.19 +105.20 sh4_x86.in_delay_slot = FALSE;105.21 sh4_x86.priv_checked = FALSE;105.22 sh4_x86.fpuen_checked = FALSE;105.23 @@ -109,7 +109,7 @@105.24 sh4_x86.tlb_on = IS_MMU_ENABLED();105.25 sh4_x86.tstate = TSTATE_NONE;105.26 #ifdef STACK_ALIGN105.27 - sh4_x86.stack_posn = 8;105.28 + sh4_x86.stack_posn = 8;105.29 #endif105.30 }105.32 @@ -122,9 +122,9 @@105.33 ADD_r32_sh4r( R_ECX, REG_OFFSET(slice_cycle) ); // 6105.34 load_spreg( R_EAX, R_PC );105.35 if( sh4_x86.tlb_on ) {105.36 - call_func1(xlat_get_code_by_vma,R_EAX);105.37 + call_func1(xlat_get_code_by_vma,R_EAX);105.38 } else {105.39 - call_func1(xlat_get_code,R_EAX);105.40 + call_func1(xlat_get_code,R_EAX);105.41 }105.42 POP_r32(R_EBP);105.43 RET();105.44 @@ -140,9 +140,9 @@105.45 load_spreg( R_EAX, R_NEW_PC );105.46 store_spreg( R_EAX, R_PC );105.47 if( sh4_x86.tlb_on ) {105.48 - call_func1(xlat_get_code_by_vma,R_EAX);105.49 + call_func1(xlat_get_code_by_vma,R_EAX);105.50 } else {105.51 - call_func1(xlat_get_code,R_EAX);105.52 + call_func1(xlat_get_code,R_EAX);105.53 }105.54 POP_r32(R_EBP);105.55 RET();105.56 @@ -159,11 +159,11 @@105.57 load_imm32( R_ECX, pc ); // 5105.58 store_spreg( R_ECX, REG_OFFSET(pc) ); // 3105.59 if( IS_IN_ICACHE(pc) ) {105.60 - MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5105.61 + MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5105.62 } else if( sh4_x86.tlb_on ) {105.63 - call_func1(xlat_get_code_by_vma,R_ECX);105.64 + call_func1(xlat_get_code_by_vma,R_ECX);105.65 } else {105.66 - call_func1(xlat_get_code,R_ECX);105.67 + call_func1(xlat_get_code,R_ECX);105.68 }105.69 AND_imm8s_r32( 0xFC, R_EAX ); // 3105.70 load_imm32( R_ECX, ((endpc - sh4_x86.block_start_pc)>>1)*sh4_cpu_period ); // 5105.71 @@ -183,11 +183,11 @@105.72 ADD_sh4r_r32( R_PC, R_ECX );105.73 store_spreg( R_ECX, REG_OFFSET(pc) ); // 3105.74 if( IS_IN_ICACHE(pc) ) {105.75 - MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5105.76 + MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5105.77 } else if( sh4_x86.tlb_on ) {105.78 - call_func1(xlat_get_code_by_vma,R_ECX);105.79 + call_func1(xlat_get_code_by_vma,R_ECX);105.80 } else {105.81 - call_func1(xlat_get_code,R_ECX);105.82 + call_func1(xlat_get_code,R_ECX);105.83 }105.84 AND_imm8s_r32( 0xFC, R_EAX ); // 3105.85 load_imm32( R_ECX, ((endpc - sh4_x86.block_start_pc)>>1)*sh4_cpu_period ); // 5105.86 @@ -201,66 +201,66 @@105.87 */105.88 void sh4_translate_end_block( sh4addr_t pc ) {105.89 if( sh4_x86.branch_taken == FALSE ) {105.90 - // Didn't exit unconditionally already, so write the termination here105.91 - exit_block_rel( pc, pc );105.92 + // Didn't exit unconditionally already, so write the termination here105.93 + exit_block_rel( pc, pc );105.94 }105.95 if( sh4_x86.backpatch_posn != 0 ) {105.96 - unsigned int i;105.97 - // Raise exception105.98 - uint8_t *end_ptr = xlat_output;105.99 - MOV_r32_r32( R_EDX, R_ECX );105.100 - ADD_r32_r32( R_EDX, R_ECX );105.101 - ADD_r32_sh4r( R_ECX, R_PC );105.102 - MOV_moff32_EAX( &sh4_cpu_period );105.103 - MUL_r32( R_EDX );105.104 - ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );105.105 + unsigned int i;105.106 + // Raise exception105.107 + uint8_t *end_ptr = xlat_output;105.108 + MOV_r32_r32( R_EDX, R_ECX );105.109 + ADD_r32_r32( R_EDX, R_ECX );105.110 + ADD_r32_sh4r( R_ECX, R_PC );105.111 + MOV_moff32_EAX( &sh4_cpu_period );105.112 + MUL_r32( R_EDX );105.113 + ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );105.115 - call_func0( sh4_raise_exception );105.116 - ADD_imm8s_r32( 4, R_ESP );105.117 - load_spreg( R_EAX, R_PC );105.118 - if( sh4_x86.tlb_on ) {105.119 - call_func1(xlat_get_code_by_vma,R_EAX);105.120 - } else {105.121 - call_func1(xlat_get_code,R_EAX);105.122 - }105.123 - POP_r32(R_EBP);105.124 - RET();105.125 + call_func0( sh4_raise_exception );105.126 + ADD_imm8s_r32( 4, R_ESP );105.127 + load_spreg( R_EAX, R_PC );105.128 + if( sh4_x86.tlb_on ) {105.129 + call_func1(xlat_get_code_by_vma,R_EAX);105.130 + } else {105.131 + call_func1(xlat_get_code,R_EAX);105.132 + }105.133 + POP_r32(R_EBP);105.134 + RET();105.136 - // Exception already raised - just cleanup105.137 - uint8_t *preexc_ptr = xlat_output;105.138 - MOV_r32_r32( R_EDX, R_ECX );105.139 - ADD_r32_r32( R_EDX, R_ECX );105.140 - ADD_r32_sh4r( R_ECX, R_SPC );105.141 - MOV_moff32_EAX( &sh4_cpu_period );105.142 - MUL_r32( R_EDX );105.143 - ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );105.144 - load_spreg( R_EAX, R_PC );105.145 - if( sh4_x86.tlb_on ) {105.146 - call_func1(xlat_get_code_by_vma,R_EAX);105.147 - } else {105.148 - call_func1(xlat_get_code,R_EAX);105.149 - }105.150 - POP_r32(R_EBP);105.151 - RET();105.152 + // Exception already raised - just cleanup105.153 + uint8_t *preexc_ptr = xlat_output;105.154 + MOV_r32_r32( R_EDX, R_ECX );105.155 + ADD_r32_r32( R_EDX, R_ECX );105.156 + ADD_r32_sh4r( R_ECX, R_SPC );105.157 + MOV_moff32_EAX( &sh4_cpu_period );105.158 + MUL_r32( R_EDX );105.159 + ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );105.160 + load_spreg( R_EAX, R_PC );105.161 + if( sh4_x86.tlb_on ) {105.162 + call_func1(xlat_get_code_by_vma,R_EAX);105.163 + } else {105.164 + call_func1(xlat_get_code,R_EAX);105.165 + }105.166 + POP_r32(R_EBP);105.167 + RET();105.169 - for( i=0; i< sh4_x86.backpatch_posn; i++ ) {105.170 - uint32_t *fixup_addr = (uint32_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset];105.171 - *fixup_addr = xlat_output - (uint8_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset] - 4;105.172 - if( sh4_x86.backpatch_list[i].exc_code < 0 ) {105.173 - load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );105.174 - int stack_adj = -1 - sh4_x86.backpatch_list[i].exc_code;105.175 - if( stack_adj > 0 ) {105.176 - ADD_imm8s_r32( stack_adj, R_ESP );105.177 - }105.178 - int rel = preexc_ptr - xlat_output;105.179 - JMP_rel(rel);105.180 - } else {105.181 - PUSH_imm32( sh4_x86.backpatch_list[i].exc_code );105.182 - load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );105.183 - int rel = end_ptr - xlat_output;105.184 - JMP_rel(rel);105.185 - }105.186 - }105.187 + for( i=0; i< sh4_x86.backpatch_posn; i++ ) {105.188 + uint32_t *fixup_addr = (uint32_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset];105.189 + *fixup_addr = xlat_output - (uint8_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset] - 4;105.190 + if( sh4_x86.backpatch_list[i].exc_code < 0 ) {105.191 + load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );105.192 + int stack_adj = -1 - sh4_x86.backpatch_list[i].exc_code;105.193 + if( stack_adj > 0 ) {105.194 + ADD_imm8s_r32( stack_adj, R_ESP );105.195 + }105.196 + int rel = preexc_ptr - xlat_output;105.197 + JMP_rel(rel);105.198 + } else {105.199 + PUSH_imm32( sh4_x86.backpatch_list[i].exc_code );105.200 + load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );105.201 + int rel = end_ptr - xlat_output;105.202 + JMP_rel(rel);105.203 + }105.204 + }105.205 }105.206 }105.208 @@ -268,25 +268,25 @@105.209 {105.210 void *result = NULL;105.211 asm(105.212 - "mov %%ebp, %%eax\n\t"105.213 - "mov $0x8, %%ecx\n\t"105.214 - "mov %1, %%edx\n"105.215 -"frame_loop: test %%eax, %%eax\n\t"105.216 - "je frame_not_found\n\t"105.217 - "cmp (%%eax), %%edx\n\t"105.218 - "je frame_found\n\t"105.219 - "sub $0x1, %%ecx\n\t"105.220 - "je frame_not_found\n\t"105.221 - "movl (%%eax), %%eax\n\t"105.222 - "jmp frame_loop\n"105.223 -"frame_found: movl 0x4(%%eax), %0\n"105.224 -"frame_not_found:"105.225 - : "=r" (result)105.226 - : "r" (((uint8_t *)&sh4r) + 128 )105.227 - : "eax", "ecx", "edx" );105.228 + "mov %%ebp, %%eax\n\t"105.229 + "mov $0x8, %%ecx\n\t"105.230 + "mov %1, %%edx\n"105.231 + "frame_loop: test %%eax, %%eax\n\t"105.232 + "je frame_not_found\n\t"105.233 + "cmp (%%eax), %%edx\n\t"105.234 + "je frame_found\n\t"105.235 + "sub $0x1, %%ecx\n\t"105.236 + "je frame_not_found\n\t"105.237 + "movl (%%eax), %%eax\n\t"105.238 + "jmp frame_loop\n"105.239 + "frame_found: movl 0x4(%%eax), %0\n"105.240 + "frame_not_found:"105.241 + : "=r" (result)105.242 + : "r" (((uint8_t *)&sh4r) + 128 )105.243 + : "eax", "ecx", "edx" );105.244 return result;105.245 }105.247 -#endif105.248 +#endif /* !lxdream_ia32abi_H */
106.1 --- a/src/sh4/ia32mac.h Mon Jul 14 07:42:45 2008 +0000106.2 +++ b/src/sh4/ia32mac.h Mon Jul 14 07:44:42 2008 +0000106.3 @@ -1,8 +1,9 @@106.4 /**106.5 * $Id$106.6 *106.7 - * Provides the implementation for the ia32 ABI (eg prologue, epilogue, and106.8 - * calling conventions)106.9 + * Provides the implementation for the ia32 Mac OS X ABI variant106.10 + * (eg prologue, epilogue, and calling conventions). Main difference106.11 + * from ia32abi is that stack frames are aligned on 16-byte boundaries.106.12 *106.13 * Copyright (c) 2007 Nathan Keynes.106.14 *106.15 @@ -17,8 +18,8 @@106.16 * GNU General Public License for more details.106.17 */106.19 -#ifndef __lxdream_ia32abi_H106.20 -#define __lxdream_ia32abi_H 1106.21 +#ifndef lxdream_ia32mac_H106.22 +#define lxdream_ia32mac_H 1106.24 #define load_ptr( reg, ptr ) load_imm32( reg, (uint32_t)ptr );106.26 @@ -124,7 +125,7 @@106.27 PUSH_r32(R_EBP);106.28 /* mov &sh4r, ebp */106.29 load_ptr( R_EBP, ((uint8_t *)&sh4r) + 128 );106.30 -106.31 +106.32 sh4_x86.in_delay_slot = FALSE;106.33 sh4_x86.priv_checked = FALSE;106.34 sh4_x86.fpuen_checked = FALSE;106.35 @@ -145,9 +146,9 @@106.36 ADD_r32_sh4r( R_ECX, REG_OFFSET(slice_cycle) ); // 6106.37 load_spreg( R_EAX, R_PC );106.38 if( sh4_x86.tlb_on ) {106.39 - call_func1(xlat_get_code_by_vma,R_EAX);106.40 + call_func1(xlat_get_code_by_vma,R_EAX);106.41 } else {106.42 - call_func1(xlat_get_code,R_EAX);106.43 + call_func1(xlat_get_code,R_EAX);106.44 }106.45 POP_r32(R_EBP);106.46 RET();106.47 @@ -163,9 +164,9 @@106.48 load_spreg( R_EAX, R_NEW_PC );106.49 store_spreg( R_EAX, R_PC );106.50 if( sh4_x86.tlb_on ) {106.51 - call_func1(xlat_get_code_by_vma,R_EAX);106.52 + call_func1(xlat_get_code_by_vma,R_EAX);106.53 } else {106.54 - call_func1(xlat_get_code,R_EAX);106.55 + call_func1(xlat_get_code,R_EAX);106.56 }106.57 POP_r32(R_EBP);106.58 RET();106.59 @@ -183,11 +184,11 @@106.60 load_imm32( R_ECX, pc ); // 5106.61 store_spreg( R_ECX, REG_OFFSET(pc) ); // 3106.62 if( IS_IN_ICACHE(pc) ) {106.63 - MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5106.64 + MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5106.65 } else if( sh4_x86.tlb_on ) {106.66 - call_func1(xlat_get_code_by_vma,R_ECX);106.67 + call_func1(xlat_get_code_by_vma,R_ECX);106.68 } else {106.69 - call_func1(xlat_get_code,R_ECX);106.70 + call_func1(xlat_get_code,R_ECX);106.71 }106.72 AND_imm8s_r32( 0xFC, R_EAX ); // 3106.73 load_imm32( R_ECX, ((endpc - sh4_x86.block_start_pc)>>1)*sh4_cpu_period ); // 5106.74 @@ -207,11 +208,11 @@106.75 ADD_sh4r_r32( R_PC, R_ECX );106.76 store_spreg( R_ECX, REG_OFFSET(pc) ); // 3106.77 if( IS_IN_ICACHE(pc) ) {106.78 - MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5106.79 + MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5106.80 } else if( sh4_x86.tlb_on ) {106.81 - call_func1(xlat_get_code_by_vma,R_ECX);106.82 + call_func1(xlat_get_code_by_vma,R_ECX);106.83 } else {106.84 - call_func1(xlat_get_code,R_ECX);106.85 + call_func1(xlat_get_code,R_ECX);106.86 }106.87 AND_imm8s_r32( 0xFC, R_EAX ); // 3106.88 load_imm32( R_ECX, ((endpc - sh4_x86.block_start_pc)>>1)*sh4_cpu_period ); // 5106.89 @@ -225,66 +226,66 @@106.90 */106.91 void sh4_translate_end_block( sh4addr_t pc ) {106.92 if( sh4_x86.branch_taken == FALSE ) {106.93 - // Didn't exit unconditionally already, so write the termination here106.94 - exit_block_rel( pc, pc );106.95 + // Didn't exit unconditionally already, so write the termination here106.96 + exit_block_rel( pc, pc );106.97 }106.98 if( sh4_x86.backpatch_posn != 0 ) {106.99 - unsigned int i;106.100 - // Raise exception106.101 - uint8_t *end_ptr = xlat_output;106.102 - MOV_r32_r32( R_EDX, R_ECX );106.103 - ADD_r32_r32( R_EDX, R_ECX );106.104 - ADD_r32_sh4r( R_ECX, R_PC );106.105 - MOV_moff32_EAX( &sh4_cpu_period );106.106 - MUL_r32( R_EDX );106.107 - ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );106.108 + unsigned int i;106.109 + // Raise exception106.110 + uint8_t *end_ptr = xlat_output;106.111 + MOV_r32_r32( R_EDX, R_ECX );106.112 + ADD_r32_r32( R_EDX, R_ECX );106.113 + ADD_r32_sh4r( R_ECX, R_PC );106.114 + MOV_moff32_EAX( &sh4_cpu_period );106.115 + MUL_r32( R_EDX );106.116 + ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );106.118 POP_r32(R_EDX);106.119 call_func1( sh4_raise_exception, R_EDX );106.120 - load_spreg( R_EAX, R_PC );106.121 - if( sh4_x86.tlb_on ) {106.122 - call_func1(xlat_get_code_by_vma,R_EAX);106.123 - } else {106.124 - call_func1(xlat_get_code,R_EAX);106.125 - }106.126 - POP_r32(R_EBP);106.127 - RET();106.128 + load_spreg( R_EAX, R_PC );106.129 + if( sh4_x86.tlb_on ) {106.130 + call_func1(xlat_get_code_by_vma,R_EAX);106.131 + } else {106.132 + call_func1(xlat_get_code,R_EAX);106.133 + }106.134 + POP_r32(R_EBP);106.135 + RET();106.137 - // Exception already raised - just cleanup106.138 - uint8_t *preexc_ptr = xlat_output;106.139 - MOV_r32_r32( R_EDX, R_ECX );106.140 - ADD_r32_r32( R_EDX, R_ECX );106.141 - ADD_r32_sh4r( R_ECX, R_SPC );106.142 - MOV_moff32_EAX( &sh4_cpu_period );106.143 - MUL_r32( R_EDX );106.144 - ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );106.145 - load_spreg( R_EAX, R_PC );106.146 - if( sh4_x86.tlb_on ) {106.147 - call_func1(xlat_get_code_by_vma,R_EAX);106.148 - } else {106.149 - call_func1(xlat_get_code,R_EAX);106.150 - }106.151 - POP_r32(R_EBP);106.152 - RET();106.153 + // Exception already raised - just cleanup106.154 + uint8_t *preexc_ptr = xlat_output;106.155 + MOV_r32_r32( R_EDX, R_ECX );106.156 + ADD_r32_r32( R_EDX, R_ECX );106.157 + ADD_r32_sh4r( R_ECX, R_SPC );106.158 + MOV_moff32_EAX( &sh4_cpu_period );106.159 + MUL_r32( R_EDX );106.160 + ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );106.161 + load_spreg( R_EAX, R_PC );106.162 + if( sh4_x86.tlb_on ) {106.163 + call_func1(xlat_get_code_by_vma,R_EAX);106.164 + } else {106.165 + call_func1(xlat_get_code,R_EAX);106.166 + }106.167 + POP_r32(R_EBP);106.168 + RET();106.170 - for( i=0; i< sh4_x86.backpatch_posn; i++ ) {106.171 - uint32_t *fixup_addr = (uint32_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset];106.172 - *fixup_addr = xlat_output - (uint8_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset] - 4;106.173 - if( sh4_x86.backpatch_list[i].exc_code < 0 ) {106.174 - load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );106.175 - int stack_adj = -1 - sh4_x86.backpatch_list[i].exc_code;106.176 - if( stack_adj > 0 ) {106.177 - ADD_imm8s_r32( stack_adj, R_ESP );106.178 - }106.179 - int rel = preexc_ptr - xlat_output;106.180 - JMP_rel(rel);106.181 - } else {106.182 - PUSH_imm32( sh4_x86.backpatch_list[i].exc_code );106.183 - load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );106.184 - int rel = end_ptr - xlat_output;106.185 - JMP_rel(rel);106.186 - }106.187 - }106.188 + for( i=0; i< sh4_x86.backpatch_posn; i++ ) {106.189 + uint32_t *fixup_addr = (uint32_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset];106.190 + *fixup_addr = xlat_output - (uint8_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset] - 4;106.191 + if( sh4_x86.backpatch_list[i].exc_code < 0 ) {106.192 + load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );106.193 + int stack_adj = -1 - sh4_x86.backpatch_list[i].exc_code;106.194 + if( stack_adj > 0 ) {106.195 + ADD_imm8s_r32( stack_adj, R_ESP );106.196 + }106.197 + int rel = preexc_ptr - xlat_output;106.198 + JMP_rel(rel);106.199 + } else {106.200 + PUSH_imm32( sh4_x86.backpatch_list[i].exc_code );106.201 + load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );106.202 + int rel = end_ptr - xlat_output;106.203 + JMP_rel(rel);106.204 + }106.205 + }106.206 }106.207 }106.209 @@ -292,26 +293,26 @@106.210 {106.211 void *result = NULL;106.212 asm(106.213 - "mov %%ebp, %%eax\n\t"106.214 - "mov $0x8, %%ecx\n\t"106.215 - "mov %1, %%edx\n"106.216 -"frame_loop: test %%eax, %%eax\n\t"106.217 - "je frame_not_found\n\t"106.218 - "cmp (%%eax), %%edx\n\t"106.219 - "je frame_found\n\t"106.220 - "sub $0x1, %%ecx\n\t"106.221 - "je frame_not_found\n\t"106.222 - "movl (%%eax), %%eax\n\t"106.223 - "jmp frame_loop\n"106.224 -"frame_found: movl 0x4(%%eax), %0\n"106.225 -"frame_not_found:"106.226 - : "=r" (result)106.227 - : "r" (((uint8_t *)&sh4r) + 128 )106.228 - : "eax", "ecx", "edx" );106.229 + "mov %%ebp, %%eax\n\t"106.230 + "mov $0x8, %%ecx\n\t"106.231 + "mov %1, %%edx\n"106.232 + "frame_loop: test %%eax, %%eax\n\t"106.233 + "je frame_not_found\n\t"106.234 + "cmp (%%eax), %%edx\n\t"106.235 + "je frame_found\n\t"106.236 + "sub $0x1, %%ecx\n\t"106.237 + "je frame_not_found\n\t"106.238 + "movl (%%eax), %%eax\n\t"106.239 + "jmp frame_loop\n"106.240 + "frame_found: movl 0x4(%%eax), %0\n"106.241 + "frame_not_found:"106.242 + : "=r" (result)106.243 + : "r" (((uint8_t *)&sh4r) + 128 )106.244 + : "eax", "ecx", "edx" );106.245 return result;106.246 }106.249 -#endif106.250 +#endif /* !lxdream_ia32mac.h */
107.1 --- a/src/sh4/ia64abi.h Mon Jul 14 07:42:45 2008 +0000107.2 +++ b/src/sh4/ia64abi.h Mon Jul 14 07:44:42 2008 +0000107.3 @@ -1,7 +1,7 @@107.4 /**107.5 * $Id$107.6 *107.7 - * Provides the implementation for the ia32 ABI (eg prologue, epilogue, and107.8 + * Provides the implementation for the AMD64 ABI (eg prologue, epilogue, and107.9 * calling conventions)107.10 *107.11 * Copyright (c) 2007 Nathan Keynes.107.12 @@ -17,13 +17,13 @@107.13 * GNU General Public License for more details.107.14 */107.16 -#ifndef __lxdream_x86_64abi_H107.17 -#define __lxdream_x86_64abi_H 1107.18 +#ifndef lxdream_ia64abi_H107.19 +#define lxdream_ia64abi_H 1107.21 #include <unwind.h>107.23 #define load_ptr( reg, ptr ) load_imm64( reg, (uint64_t)ptr );107.24 -107.25 +107.26 /**107.27 * Note: clobbers EAX to make the indirect call - this isn't usually107.28 * a problem since the callee will usually clobber it anyway.107.29 @@ -96,7 +96,7 @@107.30 PUSH_r32(R_EBP);107.31 /* mov &sh4r, ebp */107.32 load_ptr( R_EBP, ((uint8_t *)&sh4r) + 128 );107.33 -107.34 +107.35 sh4_x86.in_delay_slot = FALSE;107.36 sh4_x86.priv_checked = FALSE;107.37 sh4_x86.fpuen_checked = FALSE;107.38 @@ -116,9 +116,9 @@107.39 ADD_r32_sh4r( R_ECX, REG_OFFSET(slice_cycle) ); // 6107.40 load_spreg( R_EAX, R_PC );107.41 if( sh4_x86.tlb_on ) {107.42 - call_func1(xlat_get_code_by_vma,R_EAX);107.43 + call_func1(xlat_get_code_by_vma,R_EAX);107.44 } else {107.45 - call_func1(xlat_get_code,R_EAX);107.46 + call_func1(xlat_get_code,R_EAX);107.47 }107.48 POP_r32(R_EBP);107.49 RET();107.50 @@ -134,9 +134,9 @@107.51 load_spreg( R_EAX, R_NEW_PC );107.52 store_spreg( R_EAX, R_PC );107.53 if( sh4_x86.tlb_on ) {107.54 - call_func1(xlat_get_code_by_vma,R_EAX);107.55 + call_func1(xlat_get_code_by_vma,R_EAX);107.56 } else {107.57 - call_func1(xlat_get_code,R_EAX);107.58 + call_func1(xlat_get_code,R_EAX);107.59 }107.60 POP_r32(R_EBP);107.61 RET();107.62 @@ -151,11 +151,11 @@107.63 load_imm32( R_ECX, pc ); // 5107.64 store_spreg( R_ECX, REG_OFFSET(pc) ); // 3107.65 if( IS_IN_ICACHE(pc) ) {107.66 - REXW(); MOV_moff32_EAX( xlat_get_lut_entry(pc) );107.67 + REXW(); MOV_moff32_EAX( xlat_get_lut_entry(pc) );107.68 } else if( sh4_x86.tlb_on ) {107.69 - call_func1(xlat_get_code_by_vma, R_ECX);107.70 + call_func1(xlat_get_code_by_vma, R_ECX);107.71 } else {107.72 - call_func1(xlat_get_code,R_ECX);107.73 + call_func1(xlat_get_code,R_ECX);107.74 }107.75 REXW(); AND_imm8s_r32( 0xFC, R_EAX ); // 4107.76 load_imm32( R_ECX, ((endpc - sh4_x86.block_start_pc)>>1)*sh4_cpu_period ); // 5107.77 @@ -176,11 +176,11 @@107.78 ADD_sh4r_r32( R_PC, R_ECX );107.79 store_spreg( R_ECX, REG_OFFSET(pc) ); // 3107.80 if( IS_IN_ICACHE(pc) ) {107.81 - REXW(); MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5107.82 + REXW(); MOV_moff32_EAX( xlat_get_lut_entry(GET_ICACHE_PHYS(pc)) ); // 5107.83 } else if( sh4_x86.tlb_on ) {107.84 - call_func1(xlat_get_code_by_vma,R_ECX);107.85 + call_func1(xlat_get_code_by_vma,R_ECX);107.86 } else {107.87 - call_func1(xlat_get_code,R_ECX);107.88 + call_func1(xlat_get_code,R_ECX);107.89 }107.90 REXW(); AND_imm8s_r32( 0xFC, R_EAX ); // 4107.91 load_imm32( R_ECX, ((endpc - sh4_x86.block_start_pc)>>1)*sh4_cpu_period ); // 5107.92 @@ -194,65 +194,65 @@107.93 */107.94 void sh4_translate_end_block( sh4addr_t pc ) {107.95 if( sh4_x86.branch_taken == FALSE ) {107.96 - // Didn't exit unconditionally already, so write the termination here107.97 - exit_block_rel( pc, pc );107.98 + // Didn't exit unconditionally already, so write the termination here107.99 + exit_block_rel( pc, pc );107.100 }107.101 if( sh4_x86.backpatch_posn != 0 ) {107.102 - unsigned int i;107.103 - // Raise exception107.104 - uint8_t *end_ptr = xlat_output;107.105 - MOV_r32_r32( R_EDX, R_ECX );107.106 - ADD_r32_r32( R_EDX, R_ECX );107.107 - ADD_r32_sh4r( R_ECX, R_PC );107.108 - MOV_moff32_EAX( &sh4_cpu_period );107.109 - MUL_r32( R_EDX );107.110 - ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );107.111 + unsigned int i;107.112 + // Raise exception107.113 + uint8_t *end_ptr = xlat_output;107.114 + MOV_r32_r32( R_EDX, R_ECX );107.115 + ADD_r32_r32( R_EDX, R_ECX );107.116 + ADD_r32_sh4r( R_ECX, R_PC );107.117 + MOV_moff32_EAX( &sh4_cpu_period );107.118 + MUL_r32( R_EDX );107.119 + ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );107.121 - call_func0( sh4_raise_exception );107.122 - load_spreg( R_EAX, R_PC );107.123 - if( sh4_x86.tlb_on ) {107.124 - call_func1(xlat_get_code_by_vma,R_EAX);107.125 - } else {107.126 - call_func1(xlat_get_code,R_EAX);107.127 - }107.128 - POP_r32(R_EBP);107.129 - RET();107.130 + call_func0( sh4_raise_exception );107.131 + load_spreg( R_EAX, R_PC );107.132 + if( sh4_x86.tlb_on ) {107.133 + call_func1(xlat_get_code_by_vma,R_EAX);107.134 + } else {107.135 + call_func1(xlat_get_code,R_EAX);107.136 + }107.137 + POP_r32(R_EBP);107.138 + RET();107.140 - // Exception already raised - just cleanup107.141 - uint8_t *preexc_ptr = xlat_output;107.142 - MOV_r32_r32( R_EDX, R_ECX );107.143 - ADD_r32_r32( R_EDX, R_ECX );107.144 - ADD_r32_sh4r( R_ECX, R_SPC );107.145 - MOV_moff32_EAX( &sh4_cpu_period );107.146 - MUL_r32( R_EDX );107.147 - ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );107.148 - load_spreg( R_EDI, R_PC );107.149 - if( sh4_x86.tlb_on ) {107.150 - call_func0(xlat_get_code_by_vma);107.151 - } else {107.152 - call_func0(xlat_get_code);107.153 - }107.154 - POP_r32(R_EBP);107.155 - RET();107.156 + // Exception already raised - just cleanup107.157 + uint8_t *preexc_ptr = xlat_output;107.158 + MOV_r32_r32( R_EDX, R_ECX );107.159 + ADD_r32_r32( R_EDX, R_ECX );107.160 + ADD_r32_sh4r( R_ECX, R_SPC );107.161 + MOV_moff32_EAX( &sh4_cpu_period );107.162 + MUL_r32( R_EDX );107.163 + ADD_r32_sh4r( R_EAX, REG_OFFSET(slice_cycle) );107.164 + load_spreg( R_EDI, R_PC );107.165 + if( sh4_x86.tlb_on ) {107.166 + call_func0(xlat_get_code_by_vma);107.167 + } else {107.168 + call_func0(xlat_get_code);107.169 + }107.170 + POP_r32(R_EBP);107.171 + RET();107.173 - for( i=0; i< sh4_x86.backpatch_posn; i++ ) {107.174 - uint32_t *fixup_addr = (uint32_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset];107.175 - *fixup_addr = xlat_output - (uint8_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset] - 4;107.176 - if( sh4_x86.backpatch_list[i].exc_code < 0 ) {107.177 - load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );107.178 - int stack_adj = -1 - sh4_x86.backpatch_list[i].exc_code;107.179 - if( stack_adj > 0 ) {107.180 - ADD_imm8s_r32( stack_adj*4, R_ESP );107.181 - }107.182 - int rel = preexc_ptr - xlat_output;107.183 - JMP_rel(rel);107.184 - } else {107.185 - load_imm32( R_EDI, sh4_x86.backpatch_list[i].exc_code );107.186 - load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );107.187 - int rel = end_ptr - xlat_output;107.188 - JMP_rel(rel);107.189 - }107.190 - }107.191 + for( i=0; i< sh4_x86.backpatch_posn; i++ ) {107.192 + uint32_t *fixup_addr = (uint32_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset];107.193 + *fixup_addr = xlat_output - (uint8_t *)&xlat_current_block->code[sh4_x86.backpatch_list[i].fixup_offset] - 4;107.194 + if( sh4_x86.backpatch_list[i].exc_code < 0 ) {107.195 + load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );107.196 + int stack_adj = -1 - sh4_x86.backpatch_list[i].exc_code;107.197 + if( stack_adj > 0 ) {107.198 + ADD_imm8s_r32( stack_adj*4, R_ESP );107.199 + }107.200 + int rel = preexc_ptr - xlat_output;107.201 + JMP_rel(rel);107.202 + } else {107.203 + load_imm32( R_EDI, sh4_x86.backpatch_list[i].exc_code );107.204 + load_imm32( R_EDX, sh4_x86.backpatch_list[i].fixup_icount );107.205 + int rel = end_ptr - xlat_output;107.206 + JMP_rel(rel);107.207 + }107.208 + }107.209 }107.210 }107.212 @@ -265,17 +265,17 @@107.213 *result = (void *)_Unwind_GetIP(context);107.214 return _URC_NORMAL_STOP;107.215 }107.216 -107.217 +107.218 return _URC_NO_REASON;107.219 }107.221 void *xlat_get_native_pc()107.222 {107.223 struct _Unwind_Exception exc;107.224 -107.225 +107.226 void *result = NULL;107.227 _Unwind_Backtrace( xlat_check_frame, &result );107.228 return result;107.229 }107.231 -#endif107.232 +#endif /* !lxdream_ia64abi_H */
108.1 --- a/src/sh4/intc.c Mon Jul 14 07:42:45 2008 +0000108.2 +++ b/src/sh4/intc.c Mon Jul 14 07:44:42 2008 +0000108.3 @@ -26,21 +26,21 @@108.4 char *name;108.5 uint32_t code;108.6 } intc_sources[INT_NUM_SOURCES] = {108.7 - { "IRQ0", 0x200 }, { "IRQ1", 0x220 }, { "IRQ2", 0x240 },108.8 - { "IRQ3", 0x260 }, { "IRQ4", 0x280 }, { "IRQ5", 0x2A0 },108.9 - { "IRQ6", 0x2C0 }, { "IRQ7", 0x2E0 }, { "IRQ8", 0x300 },108.10 - { "IRQ9", 0x320 }, { "IRQ10",0x340 }, { "IRQ11",0x360 },108.11 - { "IRQ12",0x380 }, { "IRQ13",0x3A0 }, { "IRQ14",0x3C0 },108.12 - { "NMI", 0x1C0 }, { "H-UDI",0x600 }, { "GPIOI",0x620 },108.13 - { "DMTE0",0x640 }, { "DMTE1",0x660 }, { "DMTE2",0x680 },108.14 - { "DMTE3",0x6A0 }, { "DMTAE",0x6C0 }, { "TUNI0",0x400 },108.15 - { "TUNI1",0x420 }, { "TUNI2",0x440 }, { "TICPI2",0x460 },108.16 - { "RTC_ATI",0x480 },{ "RTC_PRI",0x4A0 },{ "RTC_CUI",0x4C0 },108.17 - { "SCI_ERI",0x4E0 },{ "SCI_RXI",0x500 },{ "SCI_TXI",0x520 },108.18 - { "SCI_TEI",0x540 },108.19 - { "SCIF_ERI",0x700 },{ "SCIF_RXI",0x720 },{ "SCIF_BRI",0x740 },108.20 - { "SCIF_TXI",0x760 },108.21 - { "WDT_ITI",0x560 },{ "RCMI",0x580 }, { "ROVI",0x5A0 } };108.22 + { "IRQ0", 0x200 }, { "IRQ1", 0x220 }, { "IRQ2", 0x240 },108.23 + { "IRQ3", 0x260 }, { "IRQ4", 0x280 }, { "IRQ5", 0x2A0 },108.24 + { "IRQ6", 0x2C0 }, { "IRQ7", 0x2E0 }, { "IRQ8", 0x300 },108.25 + { "IRQ9", 0x320 }, { "IRQ10",0x340 }, { "IRQ11",0x360 },108.26 + { "IRQ12",0x380 }, { "IRQ13",0x3A0 }, { "IRQ14",0x3C0 },108.27 + { "NMI", 0x1C0 }, { "H-UDI",0x600 }, { "GPIOI",0x620 },108.28 + { "DMTE0",0x640 }, { "DMTE1",0x660 }, { "DMTE2",0x680 },108.29 + { "DMTE3",0x6A0 }, { "DMTAE",0x6C0 }, { "TUNI0",0x400 },108.30 + { "TUNI1",0x420 }, { "TUNI2",0x440 }, { "TICPI2",0x460 },108.31 + { "RTC_ATI",0x480 },{ "RTC_PRI",0x4A0 },{ "RTC_CUI",0x4C0 },108.32 + { "SCI_ERI",0x4E0 },{ "SCI_RXI",0x500 },{ "SCI_TXI",0x520 },108.33 + { "SCI_TEI",0x540 },108.34 + { "SCIF_ERI",0x700 },{ "SCIF_RXI",0x720 },{ "SCIF_BRI",0x740 },108.35 + { "SCIF_TXI",0x760 },108.36 + { "WDT_ITI",0x560 },{ "RCMI",0x580 }, { "ROVI",0x5A0 } };108.38 static int intc_default_priority[INT_NUM_SOURCES] = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 16 };108.40 @@ -57,40 +57,40 @@108.41 {108.42 /* Well it saves having to use an intermediate table... */108.43 switch( reg ) {108.44 - case ICR: /* care about this later */108.45 - break;108.46 - case IPRA:108.47 - PRIORITY(INT_TMU_TUNI0) = (val>>12)&0x000F;108.48 - PRIORITY(INT_TMU_TUNI1) = (val>>8)&0x000F;108.49 - PRIORITY(INT_TMU_TUNI2) =108.50 - PRIORITY(INT_TMU_TICPI2) = (val>>4)&0x000F;108.51 - PRIORITY(INT_RTC_ATI) =108.52 - PRIORITY(INT_RTC_PRI) =108.53 + case ICR: /* care about this later */108.54 + break;108.55 + case IPRA:108.56 + PRIORITY(INT_TMU_TUNI0) = (val>>12)&0x000F;108.57 + PRIORITY(INT_TMU_TUNI1) = (val>>8)&0x000F;108.58 + PRIORITY(INT_TMU_TUNI2) =108.59 + PRIORITY(INT_TMU_TICPI2) = (val>>4)&0x000F;108.60 + PRIORITY(INT_RTC_ATI) =108.61 + PRIORITY(INT_RTC_PRI) =108.62 PRIORITY(INT_RTC_CUI) = val&0x000F;108.63 - break;108.64 - case IPRB:108.65 - PRIORITY(INT_WDT_ITI) = (val>>12)&0x000F;108.66 - PRIORITY(INT_REF_RCMI) =108.67 - PRIORITY(INT_REF_ROVI) = (val>>8)&0x000F;108.68 - PRIORITY(INT_SCI_ERI) =108.69 - PRIORITY(INT_SCI_RXI) =108.70 + break;108.71 + case IPRB:108.72 + PRIORITY(INT_WDT_ITI) = (val>>12)&0x000F;108.73 + PRIORITY(INT_REF_RCMI) =108.74 + PRIORITY(INT_REF_ROVI) = (val>>8)&0x000F;108.75 + PRIORITY(INT_SCI_ERI) =108.76 + PRIORITY(INT_SCI_RXI) =108.77 PRIORITY(INT_SCI_TXI) =108.78 - PRIORITY(INT_SCI_TEI) = (val>>4)&0x000F;108.79 - /* Bits 0-3 reserved */108.80 - break;108.81 - case IPRC:108.82 - PRIORITY(INT_GPIO) = (val>>12)&0x000F;108.83 - PRIORITY(INT_DMA_DMTE0) =108.84 - PRIORITY(INT_DMA_DMTE1) =108.85 + PRIORITY(INT_SCI_TEI) = (val>>4)&0x000F;108.86 + /* Bits 0-3 reserved */108.87 + break;108.88 + case IPRC:108.89 + PRIORITY(INT_GPIO) = (val>>12)&0x000F;108.90 + PRIORITY(INT_DMA_DMTE0) =108.91 + PRIORITY(INT_DMA_DMTE1) =108.92 PRIORITY(INT_DMA_DMTE2) =108.93 - PRIORITY(INT_DMA_DMTE3) =108.94 - PRIORITY(INT_DMA_DMAE) = (val>>8)&0x000F;108.95 - PRIORITY(INT_SCIF_ERI) =108.96 - PRIORITY(INT_SCIF_RXI) =108.97 + PRIORITY(INT_DMA_DMTE3) =108.98 + PRIORITY(INT_DMA_DMAE) = (val>>8)&0x000F;108.99 + PRIORITY(INT_SCIF_ERI) =108.100 + PRIORITY(INT_SCIF_RXI) =108.101 PRIORITY(INT_SCIF_BRI) =108.102 - PRIORITY(INT_SCIF_TXI) = (val>>4)&0x000F;108.103 - PRIORITY(INT_HUDI) = val&0x000F;108.104 - break;108.105 + PRIORITY(INT_SCIF_TXI) = (val>>4)&0x000F;108.106 + PRIORITY(INT_HUDI) = val&0x000F;108.107 + break;108.108 }108.109 MMIO_WRITE( INTC, reg, val );108.110 }108.111 @@ -106,7 +106,7 @@108.113 intc_state.num_pending = 0;108.114 for( i=0; i<INT_NUM_SOURCES; i++ )108.115 - intc_state.priority[i] = intc_default_priority[i];108.116 + intc_state.priority[i] = intc_default_priority[i];108.117 sh4r.event_pending = event_get_next_time();108.118 sh4r.event_types &= (~PENDING_IRQ);108.119 }108.120 @@ -120,7 +120,7 @@108.121 int INTC_load_state( FILE *f )108.122 {108.123 if( fread(&intc_state, sizeof(intc_state), 1, f) != 1 )108.124 - return -1;108.125 + return -1;108.126 return 0;108.127 }108.129 @@ -134,15 +134,15 @@108.130 void intc_raise_interrupt( int which )108.131 {108.132 int i, j, pri;108.133 -108.134 +108.135 pri = PRIORITY(which);108.136 if( pri == 0 ) return; /* masked off */108.137 -108.138 +108.139 for( i=0; i<intc_state.num_pending; i++ ) {108.140 if( intc_state.pending[i] == which ) return; /* Don't queue more than once */108.141 if( PRIORITY(intc_state.pending[i]) > pri ||108.142 - (PRIORITY(intc_state.pending[i]) == pri &&108.143 - intc_state.pending[i] < which))108.144 + (PRIORITY(intc_state.pending[i]) == pri &&108.145 + intc_state.pending[i] < which))108.146 break;108.147 }108.148 /* i == insertion point */108.149 @@ -152,7 +152,7 @@108.151 if( i == intc_state.num_pending && (sh4r.sr&SR_BL)==0 && SH4_INTMASK() < pri ) {108.152 sh4r.event_pending = 0;108.153 - sh4r.event_types |= PENDING_IRQ;108.154 + sh4r.event_types |= PENDING_IRQ;108.155 }108.157 intc_state.num_pending++;108.158 @@ -162,18 +162,18 @@108.159 {108.160 int i;108.161 for( i=intc_state.num_pending-1; i>=0; i-- ) {108.162 - if( intc_state.pending[i] == which ) {108.163 - /* Shift array contents down */108.164 - while( i < intc_state.num_pending-1 ) {108.165 - intc_state.pending[i] = intc_state.pending[i+1];108.166 - i++;108.167 - }108.168 - intc_state.num_pending--;108.169 - intc_mask_changed();108.170 - break;108.171 - }108.172 + if( intc_state.pending[i] == which ) {108.173 + /* Shift array contents down */108.174 + while( i < intc_state.num_pending-1 ) {108.175 + intc_state.pending[i] = intc_state.pending[i+1];108.176 + i++;108.177 + }108.178 + intc_state.num_pending--;108.179 + intc_mask_changed();108.180 + break;108.181 + }108.182 }108.183 -108.184 +108.185 }108.187 uint32_t intc_accept_interrupt( void )108.188 @@ -185,16 +185,16 @@108.189 void intc_mask_changed( void )108.190 {108.191 if( intc_state.num_pending > 0 && (sh4r.sr&SR_BL)==0 &&108.192 - SH4_INTMASK() < PRIORITY(intc_state.pending[intc_state.num_pending-1]) ) {108.193 + SH4_INTMASK() < PRIORITY(intc_state.pending[intc_state.num_pending-1]) ) {108.194 sh4r.event_pending = 0;108.195 - sh4r.event_types |= PENDING_IRQ ;108.196 + sh4r.event_types |= PENDING_IRQ ;108.197 }108.198 else {108.199 - sh4r.event_pending = event_get_next_time();108.200 - sh4r.event_types &= (~PENDING_IRQ);108.201 + sh4r.event_pending = event_get_next_time();108.202 + sh4r.event_types &= (~PENDING_IRQ);108.203 }108.204 }108.205 -108.206 +108.208 char *intc_get_interrupt_name( int code )108.209 {
109.1 --- a/src/sh4/intc.h Mon Jul 14 07:42:45 2008 +0000109.2 +++ b/src/sh4/intc.h Mon Jul 14 07:44:42 2008 +0000109.3 @@ -16,16 +16,13 @@109.4 * GNU General Public License for more details.109.5 */109.7 -#ifndef sh4intc_H109.8 -#define sh4intc_H 1109.9 +#ifndef lxdream_intc_H109.10 +#define lxdream_intc_H 1109.12 #include "sh4core.h"109.14 #ifdef __cplusplus109.15 extern "C" {109.16 -#if 0109.17 -}109.18 -#endif109.19 #endif109.21 #define INT_IRQ0 0 /* External Interrupt request 0 */109.22 @@ -83,4 +80,4 @@109.23 }109.24 #endif109.26 -#endif /* !sh4intc_H */109.27 +#endif /* !lxdream_intc_H */
110.1 --- a/src/sh4/mmu.c Mon Jul 14 07:42:45 2008 +0000110.2 +++ b/src/sh4/mmu.c Mon Jul 14 07:44:42 2008 +0000110.3 @@ -128,9 +128,9 @@110.4 {110.5 switch( reg ) {110.6 case MMUCR:110.7 - return MMIO_READ( MMU, MMUCR) | (mmu_urc<<10) | (mmu_urb<<18) | (mmu_lrui<<26);110.8 + return MMIO_READ( MMU, MMUCR) | (mmu_urc<<10) | (mmu_urb<<18) | (mmu_lrui<<26);110.9 default:110.10 - return MMIO_READ( MMU, reg );110.11 + return MMIO_READ( MMU, reg );110.12 }110.13 }110.15 @@ -139,40 +139,40 @@110.16 uint32_t tmp;110.17 switch(reg) {110.18 case PTEH:110.19 - val &= 0xFFFFFCFF;110.20 - if( (val & 0xFF) != mmu_asid ) {110.21 - mmu_asid = val&0xFF;110.22 - sh4_icache.page_vma = -1; // invalidate icache as asid has changed110.23 - }110.24 - break;110.25 + val &= 0xFFFFFCFF;110.26 + if( (val & 0xFF) != mmu_asid ) {110.27 + mmu_asid = val&0xFF;110.28 + sh4_icache.page_vma = -1; // invalidate icache as asid has changed110.29 + }110.30 + break;110.31 case PTEL:110.32 - val &= 0x1FFFFDFF;110.33 - break;110.34 + val &= 0x1FFFFDFF;110.35 + break;110.36 case PTEA:110.37 - val &= 0x0000000F;110.38 - break;110.39 + val &= 0x0000000F;110.40 + break;110.41 case MMUCR:110.42 - if( val & MMUCR_TI ) {110.43 - mmu_invalidate_tlb();110.44 - }110.45 - mmu_urc = (val >> 10) & 0x3F;110.46 - mmu_urb = (val >> 18) & 0x3F;110.47 - mmu_lrui = (val >> 26) & 0x3F;110.48 - val &= 0x00000301;110.49 - tmp = MMIO_READ( MMU, MMUCR );110.50 - if( ((val ^ tmp) & MMUCR_AT) && sh4_is_using_xlat() ) {110.51 - // AT flag has changed state - flush the xlt cache as all bets110.52 - // are off now. We also need to force an immediate exit from the110.53 - // current block110.54 - MMIO_WRITE( MMU, MMUCR, val );110.55 - sh4_translate_flush_cache();110.56 - }110.57 - break;110.58 + if( val & MMUCR_TI ) {110.59 + mmu_invalidate_tlb();110.60 + }110.61 + mmu_urc = (val >> 10) & 0x3F;110.62 + mmu_urb = (val >> 18) & 0x3F;110.63 + mmu_lrui = (val >> 26) & 0x3F;110.64 + val &= 0x00000301;110.65 + tmp = MMIO_READ( MMU, MMUCR );110.66 + if( ((val ^ tmp) & MMUCR_AT) && sh4_is_using_xlat() ) {110.67 + // AT flag has changed state - flush the xlt cache as all bets110.68 + // are off now. We also need to force an immediate exit from the110.69 + // current block110.70 + MMIO_WRITE( MMU, MMUCR, val );110.71 + sh4_translate_flush_cache();110.72 + }110.73 + break;110.74 case CCR:110.75 - mmu_set_cache_mode( val & (CCR_OIX|CCR_ORA) );110.76 - break;110.77 + mmu_set_cache_mode( val & (CCR_OIX|CCR_ORA) );110.78 + break;110.79 default:110.80 - break;110.81 + break;110.82 }110.83 MMIO_WRITE( MMU, reg, val );110.84 }110.85 @@ -207,25 +207,25 @@110.86 */110.87 mmio_region_MMU_write( CCR, MMIO_READ(MMU, CCR) );110.88 if( fread( cache, 4096, 2, f ) != 2 ) {110.89 - return 1;110.90 + return 1;110.91 }110.92 if( fread( &mmu_itlb, sizeof(mmu_itlb), 1, f ) != 1 ) {110.93 - return 1;110.94 + return 1;110.95 }110.96 if( fread( &mmu_utlb, sizeof(mmu_utlb), 1, f ) != 1 ) {110.97 - return 1;110.98 + return 1;110.99 }110.100 if( fread( &mmu_urc, sizeof(mmu_urc), 1, f ) != 1 ) {110.101 - return 1;110.102 + return 1;110.103 }110.104 if( fread( &mmu_urc, sizeof(mmu_urb), 1, f ) != 1 ) {110.105 - return 1;110.106 + return 1;110.107 }110.108 if( fread( &mmu_lrui, sizeof(mmu_lrui), 1, f ) != 1 ) {110.109 - return 1;110.110 + return 1;110.111 }110.112 if( fread( &mmu_asid, sizeof(mmu_asid), 1, f ) != 1 ) {110.113 - return 1;110.114 + return 1;110.115 }110.116 return 0;110.117 }110.118 @@ -234,18 +234,18 @@110.119 {110.120 uint32_t i;110.121 switch( mode ) {110.122 - case MEM_OC_INDEX0: /* OIX=0 */110.123 - for( i=OCRAM_START; i<OCRAM_END; i++ )110.124 - page_map[i] = cache + ((i&0x02)<<(PAGE_BITS-1));110.125 - break;110.126 - case MEM_OC_INDEX1: /* OIX=1 */110.127 - for( i=OCRAM_START; i<OCRAM_END; i++ )110.128 - page_map[i] = cache + ((i&0x02000000)>>(25-PAGE_BITS));110.129 - break;110.130 - default: /* disabled */110.131 - for( i=OCRAM_START; i<OCRAM_END; i++ )110.132 - page_map[i] = NULL;110.133 - break;110.134 + case MEM_OC_INDEX0: /* OIX=0 */110.135 + for( i=OCRAM_START; i<OCRAM_END; i++ )110.136 + page_map[i] = cache + ((i&0x02)<<(PAGE_BITS-1));110.137 + break;110.138 + case MEM_OC_INDEX1: /* OIX=1 */110.139 + for( i=OCRAM_START; i<OCRAM_END; i++ )110.140 + page_map[i] = cache + ((i&0x02000000)>>(25-PAGE_BITS));110.141 + break;110.142 + default: /* disabled */110.143 + for( i=OCRAM_START; i<OCRAM_END; i++ )110.144 + page_map[i] = NULL;110.145 + break;110.146 }110.147 }110.149 @@ -269,10 +269,10 @@110.150 {110.151 int i;110.152 for( i=0; i<ITLB_ENTRY_COUNT; i++ ) {110.153 - mmu_itlb[i].flags &= (~TLB_VALID);110.154 + mmu_itlb[i].flags &= (~TLB_VALID);110.155 }110.156 for( i=0; i<UTLB_ENTRY_COUNT; i++ ) {110.157 - mmu_utlb[i].flags &= (~TLB_VALID);110.158 + mmu_utlb[i].flags &= (~TLB_VALID);110.159 }110.160 }110.162 @@ -313,15 +313,15 @@110.163 {110.164 struct utlb_entry *ent = &mmu_utlb[UTLB_ENTRY(addr)];110.165 return ent->vpn | ent->asid | (ent->flags & TLB_VALID) |110.166 - ((ent->flags & TLB_DIRTY)<<7);110.167 + ((ent->flags & TLB_DIRTY)<<7);110.168 }110.169 int32_t mmu_utlb_data_read( sh4addr_t addr )110.170 {110.171 struct utlb_entry *ent = &mmu_utlb[UTLB_ENTRY(addr)];110.172 if( UTLB_DATA2(addr) ) {110.173 - return ent->pcmcia;110.174 + return ent->pcmcia;110.175 } else {110.176 - return ent->ppn | ent->flags;110.177 + return ent->ppn | ent->flags;110.178 }110.179 }110.181 @@ -334,15 +334,15 @@110.182 int result = -1;110.183 unsigned int i;110.184 for( i = 0; i < UTLB_ENTRY_COUNT; i++ ) {110.185 - if( (mmu_utlb[i].flags & TLB_VALID) &&110.186 - ((mmu_utlb[i].flags & TLB_SHARE) || asid == mmu_utlb[i].asid) &&110.187 - ((mmu_utlb[i].vpn ^ vpn) & mmu_utlb[i].mask) == 0 ) {110.188 - if( result != -1 ) {110.189 - fprintf( stderr, "TLB Multi hit: %d %d\n", result, i );110.190 - return -2;110.191 - }110.192 - result = i;110.193 - }110.194 + if( (mmu_utlb[i].flags & TLB_VALID) &&110.195 + ((mmu_utlb[i].flags & TLB_SHARE) || asid == mmu_utlb[i].asid) &&110.196 + ((mmu_utlb[i].vpn ^ vpn) & mmu_utlb[i].mask) == 0 ) {110.197 + if( result != -1 ) {110.198 + fprintf( stderr, "TLB Multi hit: %d %d\n", result, i );110.199 + return -2;110.200 + }110.201 + result = i;110.202 + }110.203 }110.204 return result;110.205 }110.206 @@ -356,14 +356,14 @@110.207 int result = -1;110.208 unsigned int i;110.209 for( i = 0; i < ITLB_ENTRY_COUNT; i++ ) {110.210 - if( (mmu_itlb[i].flags & TLB_VALID) &&110.211 - ((mmu_itlb[i].flags & TLB_SHARE) || asid == mmu_itlb[i].asid) &&110.212 - ((mmu_itlb[i].vpn ^ vpn) & mmu_itlb[i].mask) == 0 ) {110.213 - if( result != -1 ) {110.214 - return -2;110.215 - }110.216 - result = i;110.217 - }110.218 + if( (mmu_itlb[i].flags & TLB_VALID) &&110.219 + ((mmu_itlb[i].flags & TLB_SHARE) || asid == mmu_itlb[i].asid) &&110.220 + ((mmu_itlb[i].vpn ^ vpn) & mmu_itlb[i].mask) == 0 ) {110.221 + if( result != -1 ) {110.222 + return -2;110.223 + }110.224 + result = i;110.225 + }110.226 }110.227 return result;110.228 }110.229 @@ -371,31 +371,31 @@110.230 void mmu_utlb_addr_write( sh4addr_t addr, uint32_t val )110.231 {110.232 if( UTLB_ASSOC(addr) ) {110.233 - int utlb = mmu_utlb_lookup_assoc( val, mmu_asid );110.234 - if( utlb >= 0 ) {110.235 - struct utlb_entry *ent = &mmu_utlb[utlb];110.236 - ent->flags = ent->flags & ~(TLB_DIRTY|TLB_VALID);110.237 - ent->flags |= (val & TLB_VALID);110.238 - ent->flags |= ((val & 0x200)>>7);110.239 - }110.240 + int utlb = mmu_utlb_lookup_assoc( val, mmu_asid );110.241 + if( utlb >= 0 ) {110.242 + struct utlb_entry *ent = &mmu_utlb[utlb];110.243 + ent->flags = ent->flags & ~(TLB_DIRTY|TLB_VALID);110.244 + ent->flags |= (val & TLB_VALID);110.245 + ent->flags |= ((val & 0x200)>>7);110.246 + }110.248 - int itlb = mmu_itlb_lookup_assoc( val, mmu_asid );110.249 - if( itlb >= 0 ) {110.250 - struct itlb_entry *ent = &mmu_itlb[itlb];110.251 - ent->flags = (ent->flags & (~TLB_VALID)) | (val & TLB_VALID);110.252 - }110.253 + int itlb = mmu_itlb_lookup_assoc( val, mmu_asid );110.254 + if( itlb >= 0 ) {110.255 + struct itlb_entry *ent = &mmu_itlb[itlb];110.256 + ent->flags = (ent->flags & (~TLB_VALID)) | (val & TLB_VALID);110.257 + }110.259 - if( itlb == -2 || utlb == -2 ) {110.260 - MMU_TLB_MULTI_HIT_ERROR(addr);110.261 - return;110.262 - }110.263 + if( itlb == -2 || utlb == -2 ) {110.264 + MMU_TLB_MULTI_HIT_ERROR(addr);110.265 + return;110.266 + }110.267 } else {110.268 - struct utlb_entry *ent = &mmu_utlb[UTLB_ENTRY(addr)];110.269 - ent->vpn = (val & 0xFFFFFC00);110.270 - ent->asid = (val & 0xFF);110.271 - ent->flags = (ent->flags & ~(TLB_DIRTY|TLB_VALID));110.272 - ent->flags |= (val & TLB_VALID);110.273 - ent->flags |= ((val & 0x200)>>7);110.274 + struct utlb_entry *ent = &mmu_utlb[UTLB_ENTRY(addr)];110.275 + ent->vpn = (val & 0xFFFFFC00);110.276 + ent->asid = (val & 0xFF);110.277 + ent->flags = (ent->flags & ~(TLB_DIRTY|TLB_VALID));110.278 + ent->flags |= (val & TLB_VALID);110.279 + ent->flags |= ((val & 0x200)>>7);110.280 }110.281 }110.283 @@ -403,11 +403,11 @@110.284 {110.285 struct utlb_entry *ent = &mmu_utlb[UTLB_ENTRY(addr)];110.286 if( UTLB_DATA2(addr) ) {110.287 - ent->pcmcia = val & 0x0000000F;110.288 + ent->pcmcia = val & 0x0000000F;110.289 } else {110.290 - ent->ppn = (val & 0x1FFFFC00);110.291 - ent->flags = (val & 0x000001FF);110.292 - ent->mask = get_mask_for_flags(val);110.293 + ent->ppn = (val & 0x1FFFFC00);110.294 + ent->flags = (val & 0x000001FF);110.295 + ent->mask = get_mask_for_flags(val);110.296 }110.297 }110.299 @@ -471,18 +471,18 @@110.301 mmu_urc++;110.302 if( mmu_urc == mmu_urb || mmu_urc == 0x40 ) {110.303 - mmu_urc = 0;110.304 + mmu_urc = 0;110.305 }110.307 for( i = 0; i < UTLB_ENTRY_COUNT; i++ ) {110.308 - if( (mmu_utlb[i].flags & TLB_VALID) &&110.309 - ((mmu_utlb[i].flags & TLB_SHARE) || mmu_asid == mmu_utlb[i].asid) &&110.310 - ((mmu_utlb[i].vpn ^ vpn) & mmu_utlb[i].mask) == 0 ) {110.311 - if( result != -1 ) {110.312 - return -2;110.313 - }110.314 - result = i;110.315 - }110.316 + if( (mmu_utlb[i].flags & TLB_VALID) &&110.317 + ((mmu_utlb[i].flags & TLB_SHARE) || mmu_asid == mmu_utlb[i].asid) &&110.318 + ((mmu_utlb[i].vpn ^ vpn) & mmu_utlb[i].mask) == 0 ) {110.319 + if( result != -1 ) {110.320 + return -2;110.321 + }110.322 + result = i;110.323 + }110.324 }110.325 return result;110.326 }110.327 @@ -503,17 +503,17 @@110.329 mmu_urc++;110.330 if( mmu_urc == mmu_urb || mmu_urc == 0x40 ) {110.331 - mmu_urc = 0;110.332 + mmu_urc = 0;110.333 }110.335 for( i = 0; i < UTLB_ENTRY_COUNT; i++ ) {110.336 - if( (mmu_utlb[i].flags & TLB_VALID) &&110.337 - ((mmu_utlb[i].vpn ^ vpn) & mmu_utlb[i].mask) == 0 ) {110.338 - if( result != -1 ) {110.339 - return -2;110.340 - }110.341 - result = i;110.342 - }110.343 + if( (mmu_utlb[i].flags & TLB_VALID) &&110.344 + ((mmu_utlb[i].vpn ^ vpn) & mmu_utlb[i].mask) == 0 ) {110.345 + if( result != -1 ) {110.346 + return -2;110.347 + }110.348 + result = i;110.349 + }110.350 }110.352 return result;110.353 @@ -528,17 +528,17 @@110.354 int replace;110.355 /* Determine entry to replace based on lrui */110.356 if( (mmu_lrui & 0x38) == 0x38 ) {110.357 - replace = 0;110.358 - mmu_lrui = mmu_lrui & 0x07;110.359 + replace = 0;110.360 + mmu_lrui = mmu_lrui & 0x07;110.361 } else if( (mmu_lrui & 0x26) == 0x06 ) {110.362 - replace = 1;110.363 - mmu_lrui = (mmu_lrui & 0x19) | 0x20;110.364 + replace = 1;110.365 + mmu_lrui = (mmu_lrui & 0x19) | 0x20;110.366 } else if( (mmu_lrui & 0x15) == 0x01 ) {110.367 - replace = 2;110.368 - mmu_lrui = (mmu_lrui & 0x3E) | 0x14;110.369 + replace = 2;110.370 + mmu_lrui = (mmu_lrui & 0x3E) | 0x14;110.371 } else { // Note - gets invalid entries too110.372 - replace = 3;110.373 - mmu_lrui = (mmu_lrui | 0x0B);110.374 + replace = 3;110.375 + mmu_lrui = (mmu_lrui | 0x0B);110.376 }110.378 mmu_itlb[replace].vpn = mmu_utlb[entryNo].vpn;110.379 @@ -564,23 +564,23 @@110.380 unsigned int i;110.382 for( i = 0; i < ITLB_ENTRY_COUNT; i++ ) {110.383 - if( (mmu_itlb[i].flags & TLB_VALID) &&110.384 - ((mmu_itlb[i].flags & TLB_SHARE) || mmu_asid == mmu_itlb[i].asid) &&110.385 - ((mmu_itlb[i].vpn ^ vpn) & mmu_itlb[i].mask) == 0 ) {110.386 - if( result != -1 ) {110.387 - return -2;110.388 - }110.389 - result = i;110.390 - }110.391 + if( (mmu_itlb[i].flags & TLB_VALID) &&110.392 + ((mmu_itlb[i].flags & TLB_SHARE) || mmu_asid == mmu_itlb[i].asid) &&110.393 + ((mmu_itlb[i].vpn ^ vpn) & mmu_itlb[i].mask) == 0 ) {110.394 + if( result != -1 ) {110.395 + return -2;110.396 + }110.397 + result = i;110.398 + }110.399 }110.401 if( result == -1 ) {110.402 - int utlbEntry = mmu_utlb_lookup_vpn_asid( vpn );110.403 - if( utlbEntry < 0 ) {110.404 - return utlbEntry;110.405 - } else {110.406 - return mmu_itlb_update_from_utlb( utlbEntry );110.407 - }110.408 + int utlbEntry = mmu_utlb_lookup_vpn_asid( vpn );110.409 + if( utlbEntry < 0 ) {110.410 + return utlbEntry;110.411 + } else {110.412 + return mmu_itlb_update_from_utlb( utlbEntry );110.413 + }110.414 }110.416 switch( result ) {110.417 @@ -589,7 +589,7 @@110.418 case 2: mmu_lrui = (mmu_lrui & 0x3E) | 0x14; break;110.419 case 3: mmu_lrui = (mmu_lrui | 0x0B); break;110.420 }110.421 -110.422 +110.423 return result;110.424 }110.426 @@ -608,22 +608,22 @@110.427 unsigned int i;110.429 for( i = 0; i < ITLB_ENTRY_COUNT; i++ ) {110.430 - if( (mmu_itlb[i].flags & TLB_VALID) &&110.431 - ((mmu_itlb[i].vpn ^ vpn) & mmu_itlb[i].mask) == 0 ) {110.432 - if( result != -1 ) {110.433 - return -2;110.434 - }110.435 - result = i;110.436 - }110.437 + if( (mmu_itlb[i].flags & TLB_VALID) &&110.438 + ((mmu_itlb[i].vpn ^ vpn) & mmu_itlb[i].mask) == 0 ) {110.439 + if( result != -1 ) {110.440 + return -2;110.441 + }110.442 + result = i;110.443 + }110.444 }110.446 if( result == -1 ) {110.447 - int utlbEntry = mmu_utlb_lookup_vpn( vpn );110.448 - if( utlbEntry < 0 ) {110.449 - return utlbEntry;110.450 - } else {110.451 - return mmu_itlb_update_from_utlb( utlbEntry );110.452 - }110.453 + int utlbEntry = mmu_utlb_lookup_vpn( vpn );110.454 + if( utlbEntry < 0 ) {110.455 + return utlbEntry;110.456 + } else {110.457 + return mmu_itlb_update_from_utlb( utlbEntry );110.458 + }110.459 }110.461 switch( result ) {110.462 @@ -632,7 +632,7 @@110.463 case 2: mmu_lrui = (mmu_lrui & 0x3E) | 0x14; break;110.464 case 3: mmu_lrui = (mmu_lrui | 0x0B); break;110.465 }110.466 -110.467 +110.468 return result;110.469 }110.471 @@ -640,54 +640,54 @@110.472 {110.473 uint32_t mmucr = MMIO_READ(MMU,MMUCR);110.474 if( addr & 0x80000000 ) {110.475 - if( IS_SH4_PRIVMODE() ) {110.476 - if( addr >= 0xE0000000 ) {110.477 - return addr; /* P4 - passthrough */110.478 - } else if( addr < 0xC0000000 ) {110.479 - /* P1, P2 regions are pass-through (no translation) */110.480 - return VMA_TO_EXT_ADDR(addr);110.481 - }110.482 - } else {110.483 - if( addr >= 0xE0000000 && addr < 0xE4000000 &&110.484 - ((mmucr&MMUCR_SQMD) == 0) ) {110.485 - /* Conditional user-mode access to the store-queue (no translation) */110.486 - return addr;110.487 - }110.488 - MMU_READ_ADDR_ERROR();110.489 - return MMU_VMA_ERROR;110.490 - }110.491 + if( IS_SH4_PRIVMODE() ) {110.492 + if( addr >= 0xE0000000 ) {110.493 + return addr; /* P4 - passthrough */110.494 + } else if( addr < 0xC0000000 ) {110.495 + /* P1, P2 regions are pass-through (no translation) */110.496 + return VMA_TO_EXT_ADDR(addr);110.497 + }110.498 + } else {110.499 + if( addr >= 0xE0000000 && addr < 0xE4000000 &&110.500 + ((mmucr&MMUCR_SQMD) == 0) ) {110.501 + /* Conditional user-mode access to the store-queue (no translation) */110.502 + return addr;110.503 + }110.504 + MMU_READ_ADDR_ERROR();110.505 + return MMU_VMA_ERROR;110.506 + }110.507 }110.508 -110.509 +110.510 if( (mmucr & MMUCR_AT) == 0 ) {110.511 - return VMA_TO_EXT_ADDR(addr);110.512 + return VMA_TO_EXT_ADDR(addr);110.513 }110.515 /* If we get this far, translation is required */110.516 int entryNo;110.517 if( ((mmucr & MMUCR_SV) == 0) || !IS_SH4_PRIVMODE() ) {110.518 - entryNo = mmu_utlb_lookup_vpn_asid( addr );110.519 + entryNo = mmu_utlb_lookup_vpn_asid( addr );110.520 } else {110.521 - entryNo = mmu_utlb_lookup_vpn( addr );110.522 + entryNo = mmu_utlb_lookup_vpn( addr );110.523 }110.525 switch(entryNo) {110.526 case -1:110.527 - MMU_TLB_READ_MISS_ERROR(addr);110.528 - return MMU_VMA_ERROR;110.529 + MMU_TLB_READ_MISS_ERROR(addr);110.530 + return MMU_VMA_ERROR;110.531 case -2:110.532 - MMU_TLB_MULTI_HIT_ERROR(addr);110.533 - return MMU_VMA_ERROR;110.534 + MMU_TLB_MULTI_HIT_ERROR(addr);110.535 + return MMU_VMA_ERROR;110.536 default:110.537 - if( (mmu_utlb[entryNo].flags & TLB_USERMODE) == 0 &&110.538 - !IS_SH4_PRIVMODE() ) {110.539 - /* protection violation */110.540 - MMU_TLB_READ_PROT_ERROR(addr);110.541 - return MMU_VMA_ERROR;110.542 - }110.543 + if( (mmu_utlb[entryNo].flags & TLB_USERMODE) == 0 &&110.544 + !IS_SH4_PRIVMODE() ) {110.545 + /* protection violation */110.546 + MMU_TLB_READ_PROT_ERROR(addr);110.547 + return MMU_VMA_ERROR;110.548 + }110.550 - /* finally generate the target address */110.551 - return (mmu_utlb[entryNo].ppn & mmu_utlb[entryNo].mask) |110.552 - (addr & (~mmu_utlb[entryNo].mask));110.553 + /* finally generate the target address */110.554 + return (mmu_utlb[entryNo].ppn & mmu_utlb[entryNo].mask) |110.555 + (addr & (~mmu_utlb[entryNo].mask));110.556 }110.557 }110.559 @@ -695,59 +695,59 @@110.560 {110.561 uint32_t mmucr = MMIO_READ(MMU,MMUCR);110.562 if( addr & 0x80000000 ) {110.563 - if( IS_SH4_PRIVMODE() ) {110.564 - if( addr >= 0xE0000000 ) {110.565 - return addr; /* P4 - passthrough */110.566 - } else if( addr < 0xC0000000 ) {110.567 - /* P1, P2 regions are pass-through (no translation) */110.568 - return VMA_TO_EXT_ADDR(addr);110.569 - }110.570 - } else {110.571 - if( addr >= 0xE0000000 && addr < 0xE4000000 &&110.572 - ((mmucr&MMUCR_SQMD) == 0) ) {110.573 - /* Conditional user-mode access to the store-queue (no translation) */110.574 - return addr;110.575 - }110.576 - MMU_WRITE_ADDR_ERROR();110.577 - return MMU_VMA_ERROR;110.578 - }110.579 + if( IS_SH4_PRIVMODE() ) {110.580 + if( addr >= 0xE0000000 ) {110.581 + return addr; /* P4 - passthrough */110.582 + } else if( addr < 0xC0000000 ) {110.583 + /* P1, P2 regions are pass-through (no translation) */110.584 + return VMA_TO_EXT_ADDR(addr);110.585 + }110.586 + } else {110.587 + if( addr >= 0xE0000000 && addr < 0xE4000000 &&110.588 + ((mmucr&MMUCR_SQMD) == 0) ) {110.589 + /* Conditional user-mode access to the store-queue (no translation) */110.590 + return addr;110.591 + }110.592 + MMU_WRITE_ADDR_ERROR();110.593 + return MMU_VMA_ERROR;110.594 + }110.595 }110.596 -110.597 +110.598 if( (mmucr & MMUCR_AT) == 0 ) {110.599 - return VMA_TO_EXT_ADDR(addr);110.600 + return VMA_TO_EXT_ADDR(addr);110.601 }110.603 /* If we get this far, translation is required */110.604 int entryNo;110.605 if( ((mmucr & MMUCR_SV) == 0) || !IS_SH4_PRIVMODE() ) {110.606 - entryNo = mmu_utlb_lookup_vpn_asid( addr );110.607 + entryNo = mmu_utlb_lookup_vpn_asid( addr );110.608 } else {110.609 - entryNo = mmu_utlb_lookup_vpn( addr );110.610 + entryNo = mmu_utlb_lookup_vpn( addr );110.611 }110.613 switch(entryNo) {110.614 case -1:110.615 - MMU_TLB_WRITE_MISS_ERROR(addr);110.616 - return MMU_VMA_ERROR;110.617 + MMU_TLB_WRITE_MISS_ERROR(addr);110.618 + return MMU_VMA_ERROR;110.619 case -2:110.620 - MMU_TLB_MULTI_HIT_ERROR(addr);110.621 - return MMU_VMA_ERROR;110.622 + MMU_TLB_MULTI_HIT_ERROR(addr);110.623 + return MMU_VMA_ERROR;110.624 default:110.625 - if( IS_SH4_PRIVMODE() ? ((mmu_utlb[entryNo].flags & TLB_WRITABLE) == 0)110.626 - : ((mmu_utlb[entryNo].flags & TLB_USERWRITABLE) != TLB_USERWRITABLE) ) {110.627 - /* protection violation */110.628 - MMU_TLB_WRITE_PROT_ERROR(addr);110.629 - return MMU_VMA_ERROR;110.630 - }110.631 + if( IS_SH4_PRIVMODE() ? ((mmu_utlb[entryNo].flags & TLB_WRITABLE) == 0)110.632 + : ((mmu_utlb[entryNo].flags & TLB_USERWRITABLE) != TLB_USERWRITABLE) ) {110.633 + /* protection violation */110.634 + MMU_TLB_WRITE_PROT_ERROR(addr);110.635 + return MMU_VMA_ERROR;110.636 + }110.638 - if( (mmu_utlb[entryNo].flags & TLB_DIRTY) == 0 ) {110.639 - MMU_TLB_INITIAL_WRITE_ERROR(addr);110.640 - return MMU_VMA_ERROR;110.641 - }110.642 + if( (mmu_utlb[entryNo].flags & TLB_DIRTY) == 0 ) {110.643 + MMU_TLB_INITIAL_WRITE_ERROR(addr);110.644 + return MMU_VMA_ERROR;110.645 + }110.647 - /* finally generate the target address */110.648 - return (mmu_utlb[entryNo].ppn & mmu_utlb[entryNo].mask) |110.649 - (addr & (~mmu_utlb[entryNo].mask));110.650 + /* finally generate the target address */110.651 + return (mmu_utlb[entryNo].ppn & mmu_utlb[entryNo].mask) |110.652 + (addr & (~mmu_utlb[entryNo].mask));110.653 }110.654 }110.656 @@ -757,20 +757,20 @@110.657 void mmu_update_icache_phys( sh4addr_t addr )110.658 {110.659 if( (addr & 0x1C000000) == 0x0C000000 ) {110.660 - /* Main ram */110.661 - sh4_icache.page_vma = addr & 0xFF000000;110.662 - sh4_icache.page_ppa = 0x0C000000;110.663 - sh4_icache.mask = 0xFF000000;110.664 - sh4_icache.page = sh4_main_ram;110.665 + /* Main ram */110.666 + sh4_icache.page_vma = addr & 0xFF000000;110.667 + sh4_icache.page_ppa = 0x0C000000;110.668 + sh4_icache.mask = 0xFF000000;110.669 + sh4_icache.page = sh4_main_ram;110.670 } else if( (addr & 0x1FE00000) == 0 ) {110.671 - /* BIOS ROM */110.672 - sh4_icache.page_vma = addr & 0xFFE00000;110.673 - sh4_icache.page_ppa = 0;110.674 - sh4_icache.mask = 0xFFE00000;110.675 - sh4_icache.page = mem_get_region(0);110.676 + /* BIOS ROM */110.677 + sh4_icache.page_vma = addr & 0xFFE00000;110.678 + sh4_icache.page_ppa = 0;110.679 + sh4_icache.mask = 0xFFE00000;110.680 + sh4_icache.page = mem_get_region(0);110.681 } else {110.682 - /* not supported */110.683 - sh4_icache.page_vma = -1;110.684 + /* not supported */110.685 + sh4_icache.page_vma = -1;110.686 }110.687 }110.689 @@ -790,64 +790,64 @@110.690 {110.691 int entryNo;110.692 if( IS_SH4_PRIVMODE() ) {110.693 - if( addr & 0x80000000 ) {110.694 - if( addr < 0xC0000000 ) {110.695 - /* P1, P2 and P4 regions are pass-through (no translation) */110.696 - mmu_update_icache_phys(addr);110.697 - return TRUE;110.698 - } else if( addr >= 0xE0000000 && addr < 0xFFFFFF00 ) {110.699 - MMU_READ_ADDR_ERROR();110.700 - return FALSE;110.701 - }110.702 - }110.703 -110.704 - uint32_t mmucr = MMIO_READ(MMU,MMUCR);110.705 - if( (mmucr & MMUCR_AT) == 0 ) {110.706 - mmu_update_icache_phys(addr);110.707 - return TRUE;110.708 - }110.709 + if( addr & 0x80000000 ) {110.710 + if( addr < 0xC0000000 ) {110.711 + /* P1, P2 and P4 regions are pass-through (no translation) */110.712 + mmu_update_icache_phys(addr);110.713 + return TRUE;110.714 + } else if( addr >= 0xE0000000 && addr < 0xFFFFFF00 ) {110.715 + MMU_READ_ADDR_ERROR();110.716 + return FALSE;110.717 + }110.718 + }110.720 - entryNo = mmu_itlb_lookup_vpn( addr );110.721 + uint32_t mmucr = MMIO_READ(MMU,MMUCR);110.722 + if( (mmucr & MMUCR_AT) == 0 ) {110.723 + mmu_update_icache_phys(addr);110.724 + return TRUE;110.725 + }110.726 +110.727 + entryNo = mmu_itlb_lookup_vpn( addr );110.728 } else {110.729 - if( addr & 0x80000000 ) {110.730 - MMU_READ_ADDR_ERROR();110.731 - return FALSE;110.732 - }110.733 + if( addr & 0x80000000 ) {110.734 + MMU_READ_ADDR_ERROR();110.735 + return FALSE;110.736 + }110.738 - uint32_t mmucr = MMIO_READ(MMU,MMUCR);110.739 - if( (mmucr & MMUCR_AT) == 0 ) {110.740 - mmu_update_icache_phys(addr);110.741 - return TRUE;110.742 - }110.743 -110.744 - if( mmucr & MMUCR_SV ) {110.745 - entryNo = mmu_itlb_lookup_vpn( addr );110.746 - } else {110.747 - entryNo = mmu_itlb_lookup_vpn_asid( addr );110.748 - }110.749 - if( entryNo != -1 && (mmu_itlb[entryNo].flags & TLB_USERMODE) == 0 ) {110.750 - MMU_TLB_READ_PROT_ERROR(addr);110.751 - return FALSE;110.752 - }110.753 + uint32_t mmucr = MMIO_READ(MMU,MMUCR);110.754 + if( (mmucr & MMUCR_AT) == 0 ) {110.755 + mmu_update_icache_phys(addr);110.756 + return TRUE;110.757 + }110.758 +110.759 + if( mmucr & MMUCR_SV ) {110.760 + entryNo = mmu_itlb_lookup_vpn( addr );110.761 + } else {110.762 + entryNo = mmu_itlb_lookup_vpn_asid( addr );110.763 + }110.764 + if( entryNo != -1 && (mmu_itlb[entryNo].flags & TLB_USERMODE) == 0 ) {110.765 + MMU_TLB_READ_PROT_ERROR(addr);110.766 + return FALSE;110.767 + }110.768 }110.770 switch(entryNo) {110.771 case -1:110.772 - MMU_TLB_READ_MISS_ERROR(addr);110.773 - return FALSE;110.774 + MMU_TLB_READ_MISS_ERROR(addr);110.775 + return FALSE;110.776 case -2:110.777 - MMU_TLB_MULTI_HIT_ERROR(addr);110.778 - return FALSE;110.779 + MMU_TLB_MULTI_HIT_ERROR(addr);110.780 + return FALSE;110.781 default:110.782 - sh4_icache.page_ppa = mmu_itlb[entryNo].ppn & mmu_itlb[entryNo].mask;110.783 - sh4_icache.page = mem_get_region( sh4_icache.page_ppa );110.784 - if( sh4_icache.page == NULL ) {110.785 - sh4_icache.page_vma = -1;110.786 - } else {110.787 - sh4_icache.page_vma = mmu_itlb[entryNo].vpn & mmu_itlb[entryNo].mask;110.788 - sh4_icache.mask = mmu_itlb[entryNo].mask;110.789 - }110.790 - return TRUE;110.791 + sh4_icache.page_ppa = mmu_itlb[entryNo].ppn & mmu_itlb[entryNo].mask;110.792 + sh4_icache.page = mem_get_region( sh4_icache.page_ppa );110.793 + if( sh4_icache.page == NULL ) {110.794 + sh4_icache.page_vma = -1;110.795 + } else {110.796 + sh4_icache.page_vma = mmu_itlb[entryNo].vpn & mmu_itlb[entryNo].mask;110.797 + sh4_icache.mask = mmu_itlb[entryNo].mask;110.798 + }110.799 + return TRUE;110.800 }110.801 }110.803 @@ -860,29 +860,29 @@110.804 sh4addr_t mmu_vma_to_phys_disasm( sh4vma_t vma )110.805 {110.806 if( vma & 0x80000000 ) {110.807 - if( vma < 0xC0000000 ) {110.808 - /* P1, P2 and P4 regions are pass-through (no translation) */110.809 - return VMA_TO_EXT_ADDR(vma);110.810 - } else if( vma >= 0xE0000000 && vma < 0xFFFFFF00 ) {110.811 - /* Not translatable */110.812 - return MMU_VMA_ERROR;110.813 - }110.814 + if( vma < 0xC0000000 ) {110.815 + /* P1, P2 and P4 regions are pass-through (no translation) */110.816 + return VMA_TO_EXT_ADDR(vma);110.817 + } else if( vma >= 0xE0000000 && vma < 0xFFFFFF00 ) {110.818 + /* Not translatable */110.819 + return MMU_VMA_ERROR;110.820 + }110.821 }110.823 uint32_t mmucr = MMIO_READ(MMU,MMUCR);110.824 if( (mmucr & MMUCR_AT) == 0 ) {110.825 - return VMA_TO_EXT_ADDR(vma);110.826 + return VMA_TO_EXT_ADDR(vma);110.827 }110.828 -110.829 +110.830 int entryNo = mmu_itlb_lookup_vpn( vma );110.831 if( entryNo == -2 ) {110.832 - entryNo = mmu_itlb_lookup_vpn_asid( vma );110.833 + entryNo = mmu_itlb_lookup_vpn_asid( vma );110.834 }110.835 if( entryNo < 0 ) {110.836 - return MMU_VMA_ERROR;110.837 + return MMU_VMA_ERROR;110.838 } else {110.839 - return (mmu_itlb[entryNo].ppn & mmu_itlb[entryNo].mask) |110.840 - (vma & (~mmu_itlb[entryNo].mask));110.841 + return (mmu_itlb[entryNo].ppn & mmu_itlb[entryNo].mask) |110.842 + (vma & (~mmu_itlb[entryNo].mask));110.843 }110.844 }110.846 @@ -894,39 +894,39 @@110.847 sh4addr_t target;110.848 /* Store queue operation */110.849 if( mmucr & MMUCR_AT ) {110.850 - int entryNo;110.851 - if( ((mmucr & MMUCR_SV) == 0) || !IS_SH4_PRIVMODE() ) {110.852 - entryNo = mmu_utlb_lookup_vpn_asid( addr );110.853 - } else {110.854 - entryNo = mmu_utlb_lookup_vpn( addr );110.855 - }110.856 - switch(entryNo) {110.857 - case -1:110.858 - MMU_TLB_WRITE_MISS_ERROR(addr);110.859 - return FALSE;110.860 - case -2:110.861 - MMU_TLB_MULTI_HIT_ERROR(addr);110.862 - return FALSE;110.863 - default:110.864 - if( IS_SH4_PRIVMODE() ? ((mmu_utlb[entryNo].flags & TLB_WRITABLE) == 0)110.865 - : ((mmu_utlb[entryNo].flags & TLB_USERWRITABLE) != TLB_USERWRITABLE) ) {110.866 - /* protection violation */110.867 - MMU_TLB_WRITE_PROT_ERROR(addr);110.868 - return FALSE;110.869 - }110.870 -110.871 - if( (mmu_utlb[entryNo].flags & TLB_DIRTY) == 0 ) {110.872 - MMU_TLB_INITIAL_WRITE_ERROR(addr);110.873 - return FALSE;110.874 - }110.875 -110.876 - /* finally generate the target address */110.877 - target = ((mmu_utlb[entryNo].ppn & mmu_utlb[entryNo].mask) |110.878 - (addr & (~mmu_utlb[entryNo].mask))) & 0xFFFFFFE0;110.879 - }110.880 + int entryNo;110.881 + if( ((mmucr & MMUCR_SV) == 0) || !IS_SH4_PRIVMODE() ) {110.882 + entryNo = mmu_utlb_lookup_vpn_asid( addr );110.883 + } else {110.884 + entryNo = mmu_utlb_lookup_vpn( addr );110.885 + }110.886 + switch(entryNo) {110.887 + case -1:110.888 + MMU_TLB_WRITE_MISS_ERROR(addr);110.889 + return FALSE;110.890 + case -2:110.891 + MMU_TLB_MULTI_HIT_ERROR(addr);110.892 + return FALSE;110.893 + default:110.894 + if( IS_SH4_PRIVMODE() ? ((mmu_utlb[entryNo].flags & TLB_WRITABLE) == 0)110.895 + : ((mmu_utlb[entryNo].flags & TLB_USERWRITABLE) != TLB_USERWRITABLE) ) {110.896 + /* protection violation */110.897 + MMU_TLB_WRITE_PROT_ERROR(addr);110.898 + return FALSE;110.899 + }110.900 +110.901 + if( (mmu_utlb[entryNo].flags & TLB_DIRTY) == 0 ) {110.902 + MMU_TLB_INITIAL_WRITE_ERROR(addr);110.903 + return FALSE;110.904 + }110.905 +110.906 + /* finally generate the target address */110.907 + target = ((mmu_utlb[entryNo].ppn & mmu_utlb[entryNo].mask) |110.908 + (addr & (~mmu_utlb[entryNo].mask))) & 0xFFFFFFE0;110.909 + }110.910 } else {110.911 - uint32_t hi = (MMIO_READ( MMU, (queue == 0 ? QACR0 : QACR1) ) & 0x1C) << 24;110.912 - target = (addr&0x03FFFFE0) | hi;110.913 + uint32_t hi = (MMIO_READ( MMU, (queue == 0 ? QACR0 : QACR1) ) & 0x1C) << 24;110.914 + target = (addr&0x03FFFFE0) | hi;110.915 }110.916 mem_copy_to_sh4( target, src, 32 );110.917 return TRUE;
111.1 --- a/src/sh4/scif.c Mon Jul 14 07:42:45 2008 +0000111.2 +++ b/src/sh4/scif.c Mon Jul 14 07:44:42 2008 +0000111.3 @@ -58,7 +58,7 @@111.4 void serial_attach_device( serial_device_t dev )111.5 {111.6 if( serial_device != NULL )111.7 - serial_detach_device();111.8 + serial_detach_device();111.9 serial_device = dev;111.10 }111.12 @@ -74,19 +74,19 @@111.13 */111.14 void serial_transmit_data( char *data, int length ) {111.15 if( length == 0 )111.16 - return;111.17 + return;111.18 serial_data_block_t block =111.19 - g_malloc( sizeof( struct serial_data_block ) + length );111.20 + g_malloc( sizeof( struct serial_data_block ) + length );111.21 block->length = length;111.22 block->offset = 0;111.23 block->next = NULL;111.24 memcpy( block->data, data, length );111.25 -111.26 +111.27 if( serial_recvq_head == NULL ) {111.28 - serial_recvq_head = serial_recvq_tail = block;111.29 + serial_recvq_head = serial_recvq_tail = block;111.30 } else {111.31 - serial_recvq_tail->next = block;111.32 - serial_recvq_tail = block;111.33 + serial_recvq_tail->next = block;111.34 + serial_recvq_tail = block;111.35 }111.36 }111.38 @@ -95,15 +95,15 @@111.39 */111.40 static int serial_transmit_dequeue( ) {111.41 if( serial_recvq_head != NULL ) {111.42 - uint8_t val = serial_recvq_head->data[serial_recvq_head->offset++];111.43 - if( serial_recvq_head->offset >= serial_recvq_head->length ) {111.44 - serial_data_block_t next = serial_recvq_head->next;111.45 - g_free( serial_recvq_head );111.46 - serial_recvq_head = next;111.47 - if( next == NULL )111.48 - serial_recvq_tail = NULL;111.49 - }111.50 - return (int)(unsigned int)val;111.51 + uint8_t val = serial_recvq_head->data[serial_recvq_head->offset++];111.52 + if( serial_recvq_head->offset >= serial_recvq_head->length ) {111.53 + serial_data_block_t next = serial_recvq_head->next;111.54 + g_free( serial_recvq_head );111.55 + serial_recvq_head = next;111.56 + if( next == NULL )111.57 + serial_recvq_tail = NULL;111.58 + }111.59 + return (int)(unsigned int)val;111.60 }111.61 return -1;111.63 @@ -195,7 +195,7 @@111.64 {111.65 int val = SCIF_recvq.tail - SCIF_recvq.head;111.66 if( val < 0 ) {111.67 - val = FIFO_ARR_LENGTH - SCIF_recvq.head + SCIF_recvq.tail;111.68 + val = FIFO_ARR_LENGTH - SCIF_recvq.head + SCIF_recvq.tail;111.69 }111.70 return val;111.71 }111.72 @@ -205,10 +205,10 @@111.73 uint8_t result;111.74 uint32_t tmp, length;111.75 if( SCIF_recvq.head == SCIF_recvq.tail )111.76 - return -1; /* No data */111.77 + return -1; /* No data */111.78 result = SCIF_recvq.data[SCIF_recvq.head++];111.79 if( SCIF_recvq.head > FIFO_LENGTH )111.80 - SCIF_recvq.head = 0;111.81 + SCIF_recvq.head = 0;111.83 /* Update data count register */111.84 tmp = MMIO_READ( SCIF, SCFDR2 ) & 0xF0;111.85 @@ -217,16 +217,16 @@111.87 /* Clear flags (if requested ) */111.88 if( clearFlags && length < SCIF_recvq.trigger ) {111.89 - tmp = SCFSR2_RDF;111.90 - if( length == 0 )111.91 - tmp |= SCFSR2_DR;111.92 - tmp = MMIO_READ( SCIF, SCFSR2 ) & (~tmp);111.93 - MMIO_WRITE( SCIF, SCFSR2, tmp );111.94 - /* If both flags are cleared, clear the interrupt as well */111.95 - if( (tmp & (SCFSR2_DR|SCFSR2_RDF)) == 0 && IS_RECEIVE_IRQ_ENABLED() )111.96 - intc_clear_interrupt( INT_SCIF_RXI );111.97 + tmp = SCFSR2_RDF;111.98 + if( length == 0 )111.99 + tmp |= SCFSR2_DR;111.100 + tmp = MMIO_READ( SCIF, SCFSR2 ) & (~tmp);111.101 + MMIO_WRITE( SCIF, SCFSR2, tmp );111.102 + /* If both flags are cleared, clear the interrupt as well */111.103 + if( (tmp & (SCFSR2_DR|SCFSR2_RDF)) == 0 && IS_RECEIVE_IRQ_ENABLED() )111.104 + intc_clear_interrupt( INT_SCIF_RXI );111.105 }111.106 -111.107 +111.108 return (int)(unsigned int)result;111.109 }111.111 @@ -235,13 +235,13 @@111.112 uint32_t tmp, length;111.113 int newpos = SCIF_recvq.tail + 1;111.114 if( newpos > FIFO_LENGTH )111.115 - newpos = 0;111.116 + newpos = 0;111.117 if( newpos == SCIF_recvq.head ) {111.118 - /* FIFO full - set ORER and discard the value */111.119 - MMIO_WRITE( SCIF, SCLSR2, SCLSR2_ORER );111.120 - if( IS_RECEIVE_ERROR_IRQ_ENABLED() )111.121 - intc_raise_interrupt( INT_SCIF_ERI );111.122 - return FALSE;111.123 + /* FIFO full - set ORER and discard the value */111.124 + MMIO_WRITE( SCIF, SCLSR2, SCLSR2_ORER );111.125 + if( IS_RECEIVE_ERROR_IRQ_ENABLED() )111.126 + intc_raise_interrupt( INT_SCIF_ERI );111.127 + return FALSE;111.128 }111.129 SCIF_recvq.data[SCIF_recvq.tail] = value;111.131 @@ -253,9 +253,9 @@111.132 /* Update status register */111.133 tmp = MMIO_READ( SCIF, SCFSR2 );111.134 if( length >= SCIF_recvq.trigger ) {111.135 - tmp |= SCFSR2_RDF;111.136 - if( IS_RECEIVE_IRQ_ENABLED() )111.137 - intc_raise_interrupt( INT_SCIF_RXI );111.138 + tmp |= SCFSR2_RDF;111.139 + if( IS_RECEIVE_IRQ_ENABLED() )111.140 + intc_raise_interrupt( INT_SCIF_RXI );111.141 DMAC_trigger( DMAC_SCIF_RDF );111.142 }111.143 MMIO_WRITE( SCIF, SCFSR2, tmp );111.144 @@ -274,14 +274,14 @@111.145 MMIO_WRITE( SCIF, SCFDR2, MMIO_READ( SCIF, SCFDR2 ) & 0xF0 );111.146 MMIO_WRITE( SCIF, SCFSR2, MMIO_READ( SCIF, SCFSR2 ) & ~(SCFSR2_DR|SCFSR2_RDF) );111.147 if( IS_RECEIVE_IRQ_ENABLED() )111.148 - intc_clear_interrupt( INT_SCIF_RXI );111.149 + intc_clear_interrupt( INT_SCIF_RXI );111.150 }111.152 static inline uint8_t SCIF_sendq_size( )111.153 {111.154 int val = SCIF_sendq.tail - SCIF_sendq.head;111.155 if( val < 0 ) {111.156 - val = FIFO_ARR_LENGTH - SCIF_sendq.head + SCIF_sendq.tail;111.157 + val = FIFO_ARR_LENGTH - SCIF_sendq.head + SCIF_sendq.tail;111.158 }111.159 return val;111.160 }111.161 @@ -296,27 +296,27 @@111.162 uint8_t result;111.163 uint32_t tmp, length;111.164 if( SCIF_sendq.head == SCIF_sendq.tail )111.165 - return -1; /* No data */111.166 + return -1; /* No data */111.168 /* Update queue head pointer */111.169 result = SCIF_sendq.data[SCIF_sendq.head++];111.170 if( SCIF_sendq.head > FIFO_LENGTH )111.171 - SCIF_sendq.head = 0;111.172 + SCIF_sendq.head = 0;111.174 /* Update data count register */111.175 tmp = MMIO_READ( SCIF, SCFDR2 ) & 0x0F;111.176 length = SCIF_sendq_size();111.177 MMIO_WRITE( SCIF, SCFDR2, tmp | (length << 8) );111.178 -111.179 +111.180 /* Update status register */111.181 if( length <= SCIF_sendq.trigger ) {111.182 - tmp = MMIO_READ( SCIF, SCFSR2 ) | SCFSR2_TDFE;111.183 - if( length == 0 )111.184 - tmp |= SCFSR2_TEND; /* Transmission ended - no data waiting */111.185 - if( IS_TRANSMIT_IRQ_ENABLED() )111.186 - intc_raise_interrupt( INT_SCIF_TXI );111.187 + tmp = MMIO_READ( SCIF, SCFSR2 ) | SCFSR2_TDFE;111.188 + if( length == 0 )111.189 + tmp |= SCFSR2_TEND; /* Transmission ended - no data waiting */111.190 + if( IS_TRANSMIT_IRQ_ENABLED() )111.191 + intc_raise_interrupt( INT_SCIF_TXI );111.192 DMAC_trigger( DMAC_SCIF_TDE );111.193 - MMIO_WRITE( SCIF, SCFSR2, tmp );111.194 + MMIO_WRITE( SCIF, SCFSR2, tmp );111.195 }111.196 return (int)(unsigned int)result;111.197 }111.198 @@ -337,10 +337,10 @@111.199 uint32_t tmp, length;111.200 int newpos = SCIF_sendq.tail + 1;111.201 if( newpos > FIFO_LENGTH )111.202 - newpos = 0;111.203 + newpos = 0;111.204 if( newpos == SCIF_sendq.head ) {111.205 - /* FIFO full - discard */111.206 - return FALSE;111.207 + /* FIFO full - discard */111.208 + return FALSE;111.209 }111.210 SCIF_sendq.data[SCIF_sendq.tail] = value;111.211 SCIF_sendq.tail = newpos;111.212 @@ -349,17 +349,17 @@111.213 tmp = MMIO_READ( SCIF, SCFDR2 ) & 0x0F;111.214 length = SCIF_sendq_size();111.215 MMIO_WRITE( SCIF, SCFDR2, tmp | (length << 8) );111.216 -111.217 +111.218 /* Update flags if requested */111.219 if( clearFlags ) {111.220 - tmp = SCFSR2_TEND;111.221 - if( length > SCIF_sendq.trigger ) {111.222 - tmp |= SCFSR2_TDFE;111.223 - if( IS_TRANSMIT_IRQ_ENABLED() )111.224 - intc_clear_interrupt( INT_SCIF_TXI );111.225 - }111.226 - tmp = MMIO_READ( SCIF, SCFSR2 ) & (~tmp);111.227 - MMIO_WRITE( SCIF, SCFSR2, tmp );111.228 + tmp = SCFSR2_TEND;111.229 + if( length > SCIF_sendq.trigger ) {111.230 + tmp |= SCFSR2_TDFE;111.231 + if( IS_TRANSMIT_IRQ_ENABLED() )111.232 + intc_clear_interrupt( INT_SCIF_TXI );111.233 + }111.234 + tmp = MMIO_READ( SCIF, SCFSR2 ) & (~tmp);111.235 + MMIO_WRITE( SCIF, SCFSR2, tmp );111.236 }111.237 return TRUE;111.238 }111.239 @@ -370,7 +370,7 @@111.240 MMIO_WRITE( SCIF, SCFDR2, MMIO_READ( SCIF, SCFDR2 ) & 0x0F );111.241 MMIO_WRITE( SCIF, SCFSR2, MMIO_READ( SCIF, SCFSR2 ) | SCFSR2_TEND | SCFSR2_TDFE );111.242 if( IS_TRANSMIT_IRQ_ENABLED() ) {111.243 - intc_raise_interrupt( INT_SCIF_TXI );111.244 + intc_raise_interrupt( INT_SCIF_TXI );111.245 DMAC_trigger( DMAC_SCIF_TDE );111.246 }111.247 }111.248 @@ -389,27 +389,27 @@111.249 uint32_t recvq_size = SCIF_recvq_size();111.251 if( sendq_size != 0 )111.252 - result |= SCFSR2_TEND;111.253 + result |= SCFSR2_TEND;111.255 if( sendq_size <= SCIF_sendq.trigger )111.256 - result |= SCFSR2_TDFE;111.257 + result |= SCFSR2_TDFE;111.258 else if( (result & SCFSR2_TDFE) == 0 && IS_TRANSMIT_IRQ_ENABLED() )111.259 - intc_clear_interrupt( INT_SCIF_TXI );111.260 + intc_clear_interrupt( INT_SCIF_TXI );111.262 if( recvq_size >= SCIF_recvq.trigger )111.263 - result |= SCFSR2_RDF;111.264 + result |= SCFSR2_RDF;111.265 if( (value & SCFSR2_DR) != 0 && (result & SCFSR2_DR) == 0 &&111.266 - recvq_size != 0 )111.267 - result |= SCFSR2_DR;111.268 + recvq_size != 0 )111.269 + result |= SCFSR2_DR;111.270 if( (result & (SCFSR2_DR|SCFSR2_RDF)) == 0 && IS_RECEIVE_IRQ_ENABLED() )111.271 - intc_clear_interrupt( INT_SCIF_RXI );111.272 + intc_clear_interrupt( INT_SCIF_RXI );111.274 if( IS_RECEIVE_ERROR_IRQ_ENABLED() ) {111.275 - if( (result & SCFSR2_BRK) == 0 )111.276 - intc_clear_interrupt( INT_SCIF_BRI );111.277 - if( (result & SCFSR2_ER) == 0 &&111.278 - (MMIO_READ( SCIF, SCLSR2 ) & SCLSR2_ORER) == 0 )111.279 - intc_clear_interrupt( INT_SCIF_ERI );111.280 + if( (result & SCFSR2_BRK) == 0 )111.281 + intc_clear_interrupt( INT_SCIF_BRI );111.282 + if( (result & SCFSR2_ER) == 0 &&111.283 + (MMIO_READ( SCIF, SCLSR2 ) & SCLSR2_ORER) == 0 )111.284 + intc_clear_interrupt( INT_SCIF_ERI );111.285 }111.286 }111.288 @@ -420,7 +420,7 @@111.289 {111.290 MMIO_WRITE( SCIF, SCFSR2, MMIO_READ( SCIF, SCFSR2 ) | SCFSR2_BRK );111.291 if( IS_RECEIVE_ERROR_IRQ_ENABLED() )111.292 - intc_raise_interrupt( INT_SCIF_BRI );111.293 + intc_raise_interrupt( INT_SCIF_BRI );111.294 }111.296 const static int SCIF_CLOCK_MULTIPLIER[4] = {1, 4, 16, 64};111.297 @@ -436,22 +436,22 @@111.299 } else {111.301 - /* Otherwise, SH4 peripheral clock divided by n */111.302 - int mult = SCIF_CLOCK_MULTIPLIER[MMIO_READ( SCIF, SCSMR2 ) & 0x03];111.303 -111.304 - /* Then process the bitrate register */111.305 - int bbr = MMIO_READ( SCIF, SCBRR2 ) & 0xFF;111.306 + /* Otherwise, SH4 peripheral clock divided by n */111.307 + int mult = SCIF_CLOCK_MULTIPLIER[MMIO_READ( SCIF, SCSMR2 ) & 0x03];111.309 - int baudrate = sh4_peripheral_freq / (32 * mult * (bbr+1) );111.310 -111.311 - if( serial_device != NULL && serial_device->set_line_speed != NULL )111.312 - serial_device->set_line_speed( baudrate );111.313 + /* Then process the bitrate register */111.314 + int bbr = MMIO_READ( SCIF, SCBRR2 ) & 0xFF;111.316 - SCIF_tick_period = sh4_peripheral_period * (32 * mult * (bbr+1));111.317 + int baudrate = sh4_peripheral_freq / (32 * mult * (bbr+1) );111.319 - /*111.320 + if( serial_device != NULL && serial_device->set_line_speed != NULL )111.321 + serial_device->set_line_speed( baudrate );111.322 +111.323 + SCIF_tick_period = sh4_peripheral_period * (32 * mult * (bbr+1));111.324 +111.325 + /*111.326 clock_set_tick_rate( CLOCK_SCIF, baudrate / 10 );111.327 - */111.328 + */111.329 }111.330 }111.332 @@ -459,9 +459,9 @@111.333 {111.334 switch( reg ) {111.335 case SCFRDR2: /* Receive data */111.336 - return SCIF_recvq_dequeue(FALSE);111.337 + return SCIF_recvq_dequeue(FALSE);111.338 default:111.339 - return MMIO_READ( SCIF, reg );111.340 + return MMIO_READ( SCIF, reg );111.341 }111.342 }111.344 @@ -470,95 +470,95 @@111.345 uint32_t tmp;111.346 switch( reg ) {111.347 case SCSMR2: /* Serial mode register */111.348 - /* Bit 6 => 0 = 8-bit, 1 = 7-bit111.349 - * Bit 5 => 0 = Parity disabled, 1 = parity enabled111.350 - * Bit 4 => 0 = Even parity, 1 = Odd parity111.351 - * Bit 3 => 0 = 1 stop bit, 1 = 2 stop bits111.352 - * Bits 0-1 => Clock select 00 = P, 01 = P/4, 10 = P/16, 11 = P/64111.353 - */111.354 - val &= 0x007B;111.355 - if( serial_device != NULL ) {111.356 - serial_device->set_line_params( val );111.357 - }111.358 - tmp = MMIO_READ( SCIF, SCSMR2 );111.359 - if( (tmp & 0x03) != (val & 0x03) ) {111.360 - /* Clock change */111.361 - SCIF_update_line_speed( );111.362 - }111.363 - /* Save for later read-back */111.364 - MMIO_WRITE( SCIF, SCSMR2, val );111.365 - break;111.366 + /* Bit 6 => 0 = 8-bit, 1 = 7-bit111.367 + * Bit 5 => 0 = Parity disabled, 1 = parity enabled111.368 + * Bit 4 => 0 = Even parity, 1 = Odd parity111.369 + * Bit 3 => 0 = 1 stop bit, 1 = 2 stop bits111.370 + * Bits 0-1 => Clock select 00 = P, 01 = P/4, 10 = P/16, 11 = P/64111.371 + */111.372 + val &= 0x007B;111.373 + if( serial_device != NULL ) {111.374 + serial_device->set_line_params( val );111.375 + }111.376 + tmp = MMIO_READ( SCIF, SCSMR2 );111.377 + if( (tmp & 0x03) != (val & 0x03) ) {111.378 + /* Clock change */111.379 + SCIF_update_line_speed( );111.380 + }111.381 + /* Save for later read-back */111.382 + MMIO_WRITE( SCIF, SCSMR2, val );111.383 + break;111.384 case SCBRR2: /* Bit rate register */111.385 - MMIO_WRITE( SCIF, SCBRR2, val );111.386 - SCIF_update_line_speed( );111.387 - break;111.388 + MMIO_WRITE( SCIF, SCBRR2, val );111.389 + SCIF_update_line_speed( );111.390 + break;111.391 case SCSCR2: /* Serial control register */111.392 - /* Bit 7 => Transmit-FIFO-data-empty interrupt enabled111.393 - * Bit 6 => Receive-data-full interrupt enabled111.394 - * Bit 5 => Transmit enable111.395 - * Bit 4 => Receive enable111.396 - * Bit 3 => Receive-error/break interrupt enabled111.397 - * Bit 1 => Clock enable111.398 - */111.399 - val &= 0x00FA;111.400 - /* Clear any interrupts that just became disabled */111.401 - if( (val & SCSCR2_TIE) == 0 )111.402 - intc_clear_interrupt( INT_SCIF_TXI );111.403 - if( (val & SCSCR2_RIE) == 0 )111.404 - intc_clear_interrupt( INT_SCIF_RXI );111.405 - if( (val & (SCSCR2_RIE|SCSCR2_REIE)) == 0 ) {111.406 - intc_clear_interrupt( INT_SCIF_ERI );111.407 - intc_clear_interrupt( INT_SCIF_BRI );111.408 - }111.409 -111.410 - MMIO_WRITE( SCIF, reg, val );111.411 - break;111.412 + /* Bit 7 => Transmit-FIFO-data-empty interrupt enabled111.413 + * Bit 6 => Receive-data-full interrupt enabled111.414 + * Bit 5 => Transmit enable111.415 + * Bit 4 => Receive enable111.416 + * Bit 3 => Receive-error/break interrupt enabled111.417 + * Bit 1 => Clock enable111.418 + */111.419 + val &= 0x00FA;111.420 + /* Clear any interrupts that just became disabled */111.421 + if( (val & SCSCR2_TIE) == 0 )111.422 + intc_clear_interrupt( INT_SCIF_TXI );111.423 + if( (val & SCSCR2_RIE) == 0 )111.424 + intc_clear_interrupt( INT_SCIF_RXI );111.425 + if( (val & (SCSCR2_RIE|SCSCR2_REIE)) == 0 ) {111.426 + intc_clear_interrupt( INT_SCIF_ERI );111.427 + intc_clear_interrupt( INT_SCIF_BRI );111.428 + }111.429 +111.430 + MMIO_WRITE( SCIF, reg, val );111.431 + break;111.432 case SCFTDR2: /* Transmit FIFO data register */111.433 - SCIF_sendq_enqueue( val, FALSE );111.434 - break;111.435 + SCIF_sendq_enqueue( val, FALSE );111.436 + break;111.437 case SCFSR2: /* Serial status register */111.438 - /* Bits 12-15 Parity error count111.439 - * Bits 8-11 Framing erro count111.440 - * Bit 7 - Receive error111.441 - * Bit 6 - Transmit end111.442 - * Bit 5 - Transmit FIFO data empty111.443 - * Bit 4 - Break detect111.444 - * Bit 3 - Framing error111.445 - * Bit 2 - Parity error111.446 - * Bit 1 - Receive FIFO data full111.447 - * Bit 0 - Receive data ready111.448 - */111.449 - /* Clear off any flags/interrupts that are being set to 0 */111.450 - SCIF_update_status( val );111.451 - break;111.452 + /* Bits 12-15 Parity error count111.453 + * Bits 8-11 Framing erro count111.454 + * Bit 7 - Receive error111.455 + * Bit 6 - Transmit end111.456 + * Bit 5 - Transmit FIFO data empty111.457 + * Bit 4 - Break detect111.458 + * Bit 3 - Framing error111.459 + * Bit 2 - Parity error111.460 + * Bit 1 - Receive FIFO data full111.461 + * Bit 0 - Receive data ready111.462 + */111.463 + /* Clear off any flags/interrupts that are being set to 0 */111.464 + SCIF_update_status( val );111.465 + break;111.466 case SCFCR2: /* FIFO control register */111.467 - val &= 0x0F;111.468 - SCIF_recvq.trigger = SCIF_recvq_triggers[val >> 6];111.469 - SCIF_sendq.trigger = SCIF_sendq_triggers[(val >> 4) & 0x03];111.470 - if( val & SCFCR2_TFRST ) {111.471 - SCIF_sendq_clear();111.472 - }111.473 - if( val & SCFCR2_RFRST ) {111.474 - SCIF_recvq_clear();111.475 - }111.476 + val &= 0x0F;111.477 + SCIF_recvq.trigger = SCIF_recvq_triggers[val >> 6];111.478 + SCIF_sendq.trigger = SCIF_sendq_triggers[(val >> 4) & 0x03];111.479 + if( val & SCFCR2_TFRST ) {111.480 + SCIF_sendq_clear();111.481 + }111.482 + if( val & SCFCR2_RFRST ) {111.483 + SCIF_recvq_clear();111.484 + }111.486 - MMIO_WRITE( SCIF, reg, val );111.487 - break;111.488 + MMIO_WRITE( SCIF, reg, val );111.489 + break;111.490 case SCSPTR2: /* Serial Port Register */111.491 - MMIO_WRITE( SCIF, reg, val );111.492 - /* NOT IMPLEMENTED */111.493 - WARN( "SCSPTR2 not implemented: Write %08X", val );111.494 - break;111.495 + MMIO_WRITE( SCIF, reg, val );111.496 + /* NOT IMPLEMENTED */111.497 + WARN( "SCSPTR2 not implemented: Write %08X", val );111.498 + break;111.499 case SCLSR2:111.500 - val = val & SCLSR2_ORER;111.501 - if( val == 0 ) {111.502 - MMIO_WRITE( SCIF, SCLSR2, val );111.503 - if( (MMIO_READ( SCIF, SCFSR2 ) & SCFSR2_ER) == 0 &&111.504 - IS_RECEIVE_ERROR_IRQ_ENABLED() )111.505 - intc_clear_interrupt( INT_SCIF_ERI );111.506 - }111.507 -111.508 - break;111.509 + val = val & SCLSR2_ORER;111.510 + if( val == 0 ) {111.511 + MMIO_WRITE( SCIF, SCLSR2, val );111.512 + if( (MMIO_READ( SCIF, SCFSR2 ) & SCFSR2_ER) == 0 &&111.513 + IS_RECEIVE_ERROR_IRQ_ENABLED() )111.514 + intc_clear_interrupt( INT_SCIF_ERI );111.515 + }111.516 +111.517 + break;111.518 }111.519 }111.521 @@ -579,42 +579,42 @@111.522 gboolean rcvd = FALSE;111.524 if( IS_LOOPBACK_ENABLED() ) {111.525 - if( IS_TRANSMIT_ENABLED() ) {111.526 - int val = SCIF_sendq_dequeue();111.527 - if( val != -1 && IS_RECEIVE_ENABLED() ) {111.528 - SCIF_recvq_enqueue( val );111.529 - rcvd = TRUE;111.530 - }111.531 - }111.532 + if( IS_TRANSMIT_ENABLED() ) {111.533 + int val = SCIF_sendq_dequeue();111.534 + if( val != -1 && IS_RECEIVE_ENABLED() ) {111.535 + SCIF_recvq_enqueue( val );111.536 + rcvd = TRUE;111.537 + }111.538 + }111.539 } else {111.540 - if( IS_TRANSMIT_ENABLED() ) {111.541 - int val = SCIF_sendq_dequeue();111.542 - if( val != -1 && serial_device != NULL &&111.543 - serial_device->receive_data != NULL ) {111.544 - serial_device->receive_data( val );111.545 - }111.546 - }111.547 -111.548 - if( IS_RECEIVE_ENABLED() ) {111.549 - int val = serial_transmit_dequeue();111.550 - if( val != -1 ) {111.551 - SCIF_recvq_enqueue( val );111.552 - rcvd = TRUE;111.553 - }111.554 - }111.555 + if( IS_TRANSMIT_ENABLED() ) {111.556 + int val = SCIF_sendq_dequeue();111.557 + if( val != -1 && serial_device != NULL &&111.558 + serial_device->receive_data != NULL ) {111.559 + serial_device->receive_data( val );111.560 + }111.561 + }111.562 +111.563 + if( IS_RECEIVE_ENABLED() ) {111.564 + int val = serial_transmit_dequeue();111.565 + if( val != -1 ) {111.566 + SCIF_recvq_enqueue( val );111.567 + rcvd = TRUE;111.568 + }111.569 + }111.570 }111.572 /* Check if we need to set the DR flag */111.573 if( !rcvd && !SCIF_rcvd_last_tick &&111.574 - SCIF_recvq.head != SCIF_recvq.tail &&111.575 - SCIF_recvq_size() < SCIF_recvq.trigger ) {111.576 - uint32_t tmp = MMIO_READ( SCIF, SCFSR2 );111.577 - if( (tmp & SCFSR2_DR) == 0 ) {111.578 - MMIO_WRITE( SCIF, SCFSR2, tmp | SCFSR2_DR );111.579 - if( IS_RECEIVE_IRQ_ENABLED() )111.580 - intc_raise_interrupt( INT_SCIF_RXI );111.581 - DMAC_trigger( DMAC_SCIF_RDF );111.582 - }111.583 + SCIF_recvq.head != SCIF_recvq.tail &&111.584 + SCIF_recvq_size() < SCIF_recvq.trigger ) {111.585 + uint32_t tmp = MMIO_READ( SCIF, SCFSR2 );111.586 + if( (tmp & SCFSR2_DR) == 0 ) {111.587 + MMIO_WRITE( SCIF, SCFSR2, tmp | SCFSR2_DR );111.588 + if( IS_RECEIVE_IRQ_ENABLED() )111.589 + intc_raise_interrupt( INT_SCIF_RXI );111.590 + DMAC_trigger( DMAC_SCIF_RDF );111.591 + }111.592 }111.593 SCIF_rcvd_last_tick = rcvd;111.594 }111.595 @@ -630,7 +630,7 @@111.596 {111.597 SCIF_tick_remainder += nanosecs;111.598 while( SCIF_tick_remainder >= SCIF_tick_period ) {111.599 - SCIF_tick_remainder -= SCIF_tick_period;111.600 - SCIF_clock_tick();111.601 + SCIF_tick_remainder -= SCIF_tick_period;111.602 + SCIF_clock_tick();111.603 }111.604 }
112.1 --- a/src/sh4/sh4.c Mon Jul 14 07:42:45 2008 +0000112.2 +++ b/src/sh4/sh4.c Mon Jul 14 07:44:42 2008 +0000112.3 @@ -45,8 +45,8 @@112.4 uint32_t sh4_xlat_run_slice( uint32_t );112.6 struct dreamcast_module sh4_module = { "SH4", sh4_init, sh4_reset,112.7 - sh4_start, sh4_run_slice, sh4_stop,112.8 - sh4_save_state, sh4_load_state };112.9 + sh4_start, sh4_run_slice, sh4_stop,112.10 + sh4_save_state, sh4_load_state };112.12 struct sh4_registers sh4r;112.13 struct breakpoint_struct sh4_breakpoints[MAX_BREAKPOINTS];112.14 @@ -58,14 +58,14 @@112.16 void sh4_set_use_xlat( gboolean use )112.17 {112.18 -// No-op if the translator was not built112.19 + // No-op if the translator was not built112.20 #ifdef SH4_TRANSLATOR112.21 if( use ) {112.22 - xlat_cache_init();112.23 - sh4_translate_init();112.24 - sh4_module.run_time_slice = sh4_xlat_run_slice;112.25 + xlat_cache_init();112.26 + sh4_translate_init();112.27 + sh4_module.run_time_slice = sh4_xlat_run_slice;112.28 } else {112.29 - sh4_module.run_time_slice = sh4_run_slice;112.30 + sh4_module.run_time_slice = sh4_run_slice;112.31 }112.32 sh4_use_translator = use;112.33 #endif112.34 @@ -96,7 +96,7 @@112.35 void sh4_reset(void)112.36 {112.37 if( sh4_use_translator ) {112.38 - xlat_flush_cache();112.39 + xlat_flush_cache();112.40 }112.42 /* zero everything out, for the sake of having a consistent state. */112.43 @@ -129,9 +129,9 @@112.44 void sh4_stop(void)112.45 {112.46 if( sh4_use_translator ) {112.47 - /* If we were running with the translator, update new_pc and in_delay_slot */112.48 - sh4r.new_pc = sh4r.pc+2;112.49 - sh4r.in_delay_slot = FALSE;112.50 + /* If we were running with the translator, update new_pc and in_delay_slot */112.51 + sh4r.new_pc = sh4r.pc+2;112.52 + sh4r.in_delay_slot = FALSE;112.53 }112.55 }112.56 @@ -139,9 +139,9 @@112.57 void sh4_save_state( FILE *f )112.58 {112.59 if( sh4_use_translator ) {112.60 - /* If we were running with the translator, update new_pc and in_delay_slot */112.61 - sh4r.new_pc = sh4r.pc+2;112.62 - sh4r.in_delay_slot = FALSE;112.63 + /* If we were running with the translator, update new_pc and in_delay_slot */112.64 + sh4r.new_pc = sh4r.pc+2;112.65 + sh4r.in_delay_slot = FALSE;112.66 }112.68 fwrite( &sh4r, sizeof(sh4r), 1, f );112.69 @@ -154,7 +154,7 @@112.70 int sh4_load_state( FILE * f )112.71 {112.72 if( sh4_use_translator ) {112.73 - xlat_flush_cache();112.74 + xlat_flush_cache();112.75 }112.76 fread( &sh4r, sizeof(sh4r), 1, f );112.77 MMU_load_state( f );112.78 @@ -169,7 +169,7 @@112.79 sh4_breakpoints[sh4_breakpoint_count].address = pc;112.80 sh4_breakpoints[sh4_breakpoint_count].type = type;112.81 if( sh4_use_translator ) {112.82 - xlat_invalidate_word( pc );112.83 + xlat_invalidate_word( pc );112.84 }112.85 sh4_breakpoint_count++;112.86 }112.87 @@ -179,18 +179,18 @@112.88 int i;112.90 for( i=0; i<sh4_breakpoint_count; i++ ) {112.91 - if( sh4_breakpoints[i].address == pc &&112.92 - sh4_breakpoints[i].type == type ) {112.93 - while( ++i < sh4_breakpoint_count ) {112.94 - sh4_breakpoints[i-1].address = sh4_breakpoints[i].address;112.95 - sh4_breakpoints[i-1].type = sh4_breakpoints[i].type;112.96 - }112.97 - if( sh4_use_translator ) {112.98 - xlat_invalidate_word( pc );112.99 - }112.100 - sh4_breakpoint_count--;112.101 - return TRUE;112.102 - }112.103 + if( sh4_breakpoints[i].address == pc &&112.104 + sh4_breakpoints[i].type == type ) {112.105 + while( ++i < sh4_breakpoint_count ) {112.106 + sh4_breakpoints[i-1].address = sh4_breakpoints[i].address;112.107 + sh4_breakpoints[i-1].type = sh4_breakpoints[i].type;112.108 + }112.109 + if( sh4_use_translator ) {112.110 + xlat_invalidate_word( pc );112.111 + }112.112 + sh4_breakpoint_count--;112.113 + return TRUE;112.114 + }112.115 }112.116 return FALSE;112.117 }112.118 @@ -199,8 +199,8 @@112.119 {112.120 int i;112.121 for( i=0; i<sh4_breakpoint_count; i++ ) {112.122 - if( sh4_breakpoints[i].address == pc )112.123 - return sh4_breakpoints[i].type;112.124 + if( sh4_breakpoints[i].address == pc )112.125 + return sh4_breakpoints[i].type;112.126 }112.127 return 0;112.128 }112.129 @@ -227,9 +227,9 @@112.130 {112.131 int i;112.132 for( i=0; i<16; i++ ) {112.133 - float tmp = sh4r.fr[0][i];112.134 - sh4r.fr[0][i] = sh4r.fr[1][i];112.135 - sh4r.fr[1][i] = tmp;112.136 + float tmp = sh4r.fr[0][i];112.137 + sh4r.fr[0][i] = sh4r.fr[1][i];112.138 + sh4r.fr[1][i] = tmp;112.139 }112.140 }112.142 @@ -250,7 +250,7 @@112.143 void sh4_write_fpscr( uint32_t newval )112.144 {112.145 if( (sh4r.fpscr ^ newval) & FPSCR_FR ) {112.146 - sh4_switch_fr_banks();112.147 + sh4_switch_fr_banks();112.148 }112.149 sh4r.fpscr = newval;112.150 }112.151 @@ -280,10 +280,10 @@112.152 sh4r.pc = sh4r.vbr + v; \112.153 sh4r.new_pc = sh4r.pc + 2; \112.154 sh4_write_sr( sh4r.ssr |SR_MD|SR_BL|SR_RB ); \112.155 - if( sh4r.in_delay_slot ) { \112.156 - sh4r.in_delay_slot = 0; \112.157 - sh4r.spc -= 2; \112.158 - } \112.159 + if( sh4r.in_delay_slot ) { \112.160 + sh4r.in_delay_slot = 0; \112.161 + sh4r.spc -= 2; \112.162 + } \112.163 } \112.164 return TRUE; } while(0)112.166 @@ -308,7 +308,7 @@112.167 sh4r.pc = 0xA0000000;112.168 sh4r.new_pc = sh4r.pc + 2;112.169 sh4_write_sr( (sh4r.sr|SR_MD|SR_BL|SR_RB|SR_IMASK)112.170 - &(~SR_FD) );112.171 + &(~SR_FD) );112.172 return TRUE;112.173 }112.175 @@ -320,9 +320,9 @@112.177 gboolean sh4_raise_slot_exception( int normal_code, int slot_code ) {112.178 if( sh4r.in_delay_slot ) {112.179 - return sh4_raise_exception(slot_code);112.180 + return sh4_raise_exception(slot_code);112.181 } else {112.182 - return sh4_raise_exception(normal_code);112.183 + return sh4_raise_exception(normal_code);112.184 }112.185 }112.187 @@ -347,9 +347,9 @@112.188 void signsat48( void )112.189 {112.190 if( ((int64_t)sh4r.mac) < (int64_t)0xFFFF800000000000LL )112.191 - sh4r.mac = 0xFFFF800000000000LL;112.192 + sh4r.mac = 0xFFFF800000000000LL;112.193 else if( ((int64_t)sh4r.mac) > (int64_t)0x00007FFFFFFFFFFFLL )112.194 - sh4r.mac = 0x00007FFFFFFFFFFFLL;112.195 + sh4r.mac = 0x00007FFFFFFFFFFFLL;112.196 }112.198 void sh4_fsca( uint32_t anglei, float *fr )112.199 @@ -367,21 +367,21 @@112.200 void sh4_sleep(void)112.201 {112.202 if( MMIO_READ( CPG, STBCR ) & 0x80 ) {112.203 - sh4r.sh4_state = SH4_STATE_STANDBY;112.204 - /* Bring all running peripheral modules up to date, and then halt them. */112.205 - TMU_run_slice( sh4r.slice_cycle );112.206 - SCIF_run_slice( sh4r.slice_cycle );112.207 + sh4r.sh4_state = SH4_STATE_STANDBY;112.208 + /* Bring all running peripheral modules up to date, and then halt them. */112.209 + TMU_run_slice( sh4r.slice_cycle );112.210 + SCIF_run_slice( sh4r.slice_cycle );112.211 } else {112.212 - if( MMIO_READ( CPG, STBCR2 ) & 0x80 ) {112.213 - sh4r.sh4_state = SH4_STATE_DEEP_SLEEP;112.214 - /* Halt DMAC but other peripherals still running */112.215 -112.216 - } else {112.217 - sh4r.sh4_state = SH4_STATE_SLEEP;112.218 - }112.219 + if( MMIO_READ( CPG, STBCR2 ) & 0x80 ) {112.220 + sh4r.sh4_state = SH4_STATE_DEEP_SLEEP;112.221 + /* Halt DMAC but other peripherals still running */112.222 +112.223 + } else {112.224 + sh4r.sh4_state = SH4_STATE_SLEEP;112.225 + }112.226 }112.227 if( sh4_xlat_is_running() ) {112.228 - sh4_translate_exit( XLAT_EXIT_SLEEP );112.229 + sh4_translate_exit( XLAT_EXIT_SLEEP );112.230 }112.231 }112.233 @@ -393,11 +393,11 @@112.234 {112.235 switch( sh4r.sh4_state ) {112.236 case SH4_STATE_STANDBY:112.237 - break;112.238 + break;112.239 case SH4_STATE_DEEP_SLEEP:112.240 - break;112.241 + break;112.242 case SH4_STATE_SLEEP:112.243 - break;112.244 + break;112.245 }112.246 sh4r.sh4_state = SH4_STATE_RUNNING;112.247 }112.248 @@ -412,16 +412,16 @@112.249 {112.250 int sleep_state = sh4r.sh4_state;112.251 assert( sleep_state != SH4_STATE_RUNNING );112.252 -112.253 +112.254 while( sh4r.event_pending < nanosecs ) {112.255 - sh4r.slice_cycle = sh4r.event_pending;112.256 - if( sh4r.event_types & PENDING_EVENT ) {112.257 - event_execute();112.258 - }112.259 - if( sh4r.event_types & PENDING_IRQ ) {112.260 - sh4_wakeup();112.261 - return sh4r.slice_cycle;112.262 - }112.263 + sh4r.slice_cycle = sh4r.event_pending;112.264 + if( sh4r.event_types & PENDING_EVENT ) {112.265 + event_execute();112.266 + }112.267 + if( sh4r.event_types & PENDING_IRQ ) {112.268 + sh4_wakeup();112.269 + return sh4r.slice_cycle;112.270 + }112.271 }112.272 sh4r.slice_cycle = nanosecs;112.273 return sh4r.slice_cycle;112.274 @@ -436,13 +436,13 @@112.275 {112.276 float fv[4] = { target[1], target[0], target[3], target[2] };112.277 target[1] = sh4r.fr[1][1] * fv[0] + sh4r.fr[1][5]*fv[1] +112.278 - sh4r.fr[1][9]*fv[2] + sh4r.fr[1][13]*fv[3];112.279 + sh4r.fr[1][9]*fv[2] + sh4r.fr[1][13]*fv[3];112.280 target[0] = sh4r.fr[1][0] * fv[0] + sh4r.fr[1][4]*fv[1] +112.281 - sh4r.fr[1][8]*fv[2] + sh4r.fr[1][12]*fv[3];112.282 + sh4r.fr[1][8]*fv[2] + sh4r.fr[1][12]*fv[3];112.283 target[3] = sh4r.fr[1][3] * fv[0] + sh4r.fr[1][7]*fv[1] +112.284 - sh4r.fr[1][11]*fv[2] + sh4r.fr[1][15]*fv[3];112.285 + sh4r.fr[1][11]*fv[2] + sh4r.fr[1][15]*fv[3];112.286 target[2] = sh4r.fr[1][2] * fv[0] + sh4r.fr[1][6]*fv[1] +112.287 - sh4r.fr[1][10]*fv[2] + sh4r.fr[1][14]*fv[3];112.288 + sh4r.fr[1][10]*fv[2] + sh4r.fr[1][14]*fv[3];112.289 }112.291 gboolean sh4_has_page( sh4vma_t vma )
113.1 --- a/src/sh4/sh4.h Mon Jul 14 07:42:45 2008 +0000113.2 +++ b/src/sh4/sh4.h Mon Jul 14 07:44:42 2008 +0000113.3 @@ -67,8 +67,8 @@113.4 uint32_t sr, pr, pc, fpscr;113.5 uint32_t t, m, q, s; /* really boolean - 0 or 1 */113.6 union {113.7 - int32_t i;113.8 - float f;113.9 + int32_t i;113.10 + float f;113.11 } fpul;113.12 uint32_t pad; // FIXME: remove in next DST version113.13 float fr[2][16];113.14 @@ -77,13 +77,13 @@113.16 uint32_t r_bank[8]; /* hidden banked registers */113.17 int32_t store_queue[16]; /* technically 2 banks of 32 bytes */113.18 -113.19 +113.20 uint32_t new_pc; /* Not a real register, but used to handle delay slots */113.21 uint32_t event_pending; /* slice cycle time of the next pending event, or FFFFFFFF113.22 when no events are pending */113.23 uint32_t event_types; /* bit 0 = IRQ pending, bit 1 = general event pending */113.24 int in_delay_slot; /* flag to indicate the current instruction is in113.25 - * a delay slot (certain rules apply) */113.26 + * a delay slot (certain rules apply) */113.27 uint32_t slice_cycle; /* Current nanosecond within the timeslice */113.28 int sh4_state; /* Current power-on state (one of the SH4_STATE_* values ) */113.29 };
114.1 --- a/src/sh4/sh4core.c Mon Jul 14 07:42:45 2008 +0000114.2 +++ b/src/sh4/sh4core.c Mon Jul 14 07:44:42 2008 +0000114.3 @@ -216,7 +216,7 @@114.4 sh4_write_long( memtmp, *((uint32_t *)&XF((reg)&0x0E)) ); \114.5 sh4_write_long( memtmp+4, *((uint32_t *)&XF(reg)) ); \114.6 } else { \114.7 - sh4_write_long( memtmp, *((uint32_t *)&FR(reg)) ); \114.8 + sh4_write_long( memtmp, *((uint32_t *)&FR(reg)) ); \114.9 sh4_write_long( memtmp+4, *((uint32_t *)&FR((reg)|0x01)) ); \114.10 } \114.11 } \
115.1 --- a/src/sh4/sh4core.h Mon Jul 14 07:42:45 2008 +0000115.2 +++ b/src/sh4/sh4core.h Mon Jul 14 07:44:42 2008 +0000115.3 @@ -17,8 +17,8 @@115.4 * GNU General Public License for more details.115.5 */115.7 -#ifndef sh4core_H115.8 -#define sh4core_H 1115.9 +#ifndef lxdream_sh4core_H115.10 +#define lxdream_sh4core_H 1115.12 #include <glib/gtypes.h>115.13 #include <stdint.h>115.14 @@ -233,5 +233,6 @@115.15 #ifdef __cplusplus115.16 }115.17 #endif115.18 -#endif115.20 +#endif /* !lxdream_sh4core_H */115.21 +
116.1 --- a/src/sh4/sh4core.in Mon Jul 14 07:42:45 2008 +0000116.2 +++ b/src/sh4/sh4core.in Mon Jul 14 07:44:42 2008 +0000116.3 @@ -216,7 +216,7 @@116.4 sh4_write_long( memtmp, *((uint32_t *)&XF((reg)&0x0E)) ); \116.5 sh4_write_long( memtmp+4, *((uint32_t *)&XF(reg)) ); \116.6 } else { \116.7 - sh4_write_long( memtmp, *((uint32_t *)&FR(reg)) ); \116.8 + sh4_write_long( memtmp, *((uint32_t *)&FR(reg)) ); \116.9 sh4_write_long( memtmp+4, *((uint32_t *)&FR((reg)|0x01)) ); \116.10 } \116.11 } \
117.1 --- a/src/sh4/sh4dasm.h Mon Jul 14 07:42:45 2008 +0000117.2 +++ b/src/sh4/sh4dasm.h Mon Jul 14 07:44:42 2008 +0000117.3 @@ -16,8 +16,8 @@117.4 * GNU General Public License for more details.117.5 */117.7 -#ifndef sh4dasm_H117.8 -#define sh4dasm_H 1117.9 +#ifndef lxdream_sh4dasm_H117.10 +#define lxdream_sh4dasm_H 1117.12 #include "cpu.h"117.14 @@ -36,4 +36,4 @@117.15 }117.16 #endif117.18 -#endif117.19 +#endif /* !lxdream_sh4dasm_H */
118.1 --- a/src/sh4/sh4mem.c Mon Jul 14 07:42:45 2008 +0000118.2 +++ b/src/sh4/sh4mem.c Mon Jul 14 07:44:42 2008 +0000118.3 @@ -54,12 +54,12 @@118.4 #ifdef ENABLE_TRACE_IO118.5 #define TRACE_IO( str, p, r, ... ) if(io_rgn[(uint32_t)p]->trace_flag && !MMIO_NOTRACE_BYNUM((uint32_t)p,r)) \118.6 TRACE( str " [%s.%s: %s]", __VA_ARGS__, \118.7 - MMIO_NAME_BYNUM((uint32_t)p), MMIO_REGID_BYNUM((uint32_t)p, r), \118.8 - MMIO_REGDESC_BYNUM((uint32_t)p, r) )118.9 + MMIO_NAME_BYNUM((uint32_t)p), MMIO_REGID_BYNUM((uint32_t)p, r), \118.10 + MMIO_REGDESC_BYNUM((uint32_t)p, r) )118.11 #define TRACE_P4IO( str, io, r, ... ) if(io->trace_flag && !MMIO_NOTRACE_IOBYNUM(io,r)) \118.12 -TRACE( str " [%s.%s: %s]", __VA_ARGS__, \118.13 - io->id, MMIO_REGID_IOBYNUM(io, r), \118.14 - MMIO_REGDESC_IOBYNUM(io, r) )118.15 + TRACE( str " [%s.%s: %s]", __VA_ARGS__, \118.16 + io->id, MMIO_REGID_IOBYNUM(io, r), \118.17 + MMIO_REGDESC_IOBYNUM(io, r) )118.18 #else118.19 #define TRACE_IO( str, p, r, ... )118.20 #define TRACE_P4IO( str, io, r, ... )118.21 @@ -72,26 +72,26 @@118.22 {118.23 struct mmio_region *io = P4_io[(addr&0x1FFFFFFF)>>19];118.24 if( !io ) {118.25 - switch( addr & 0x1F000000 ) {118.26 - case 0x00000000: case 0x01000000: case 0x02000000: case 0x03000000:118.27 - /* Store queue - readable? */118.28 - return 0;118.29 - break;118.30 - case 0x10000000: return mmu_icache_addr_read( addr );118.31 - case 0x11000000: return mmu_icache_data_read( addr );118.32 - case 0x12000000: return mmu_itlb_addr_read( addr );118.33 - case 0x13000000: return mmu_itlb_data_read( addr );118.34 - case 0x14000000: return mmu_ocache_addr_read( addr );118.35 - case 0x15000000: return mmu_ocache_data_read( addr );118.36 - case 0x16000000: return mmu_utlb_addr_read( addr );118.37 - case 0x17000000: return mmu_utlb_data_read( addr );118.38 - default:118.39 + switch( addr & 0x1F000000 ) {118.40 + case 0x00000000: case 0x01000000: case 0x02000000: case 0x03000000:118.41 + /* Store queue - readable? */118.42 + return 0;118.43 + break;118.44 + case 0x10000000: return mmu_icache_addr_read( addr );118.45 + case 0x11000000: return mmu_icache_data_read( addr );118.46 + case 0x12000000: return mmu_itlb_addr_read( addr );118.47 + case 0x13000000: return mmu_itlb_data_read( addr );118.48 + case 0x14000000: return mmu_ocache_addr_read( addr );118.49 + case 0x15000000: return mmu_ocache_data_read( addr );118.50 + case 0x16000000: return mmu_utlb_addr_read( addr );118.51 + case 0x17000000: return mmu_utlb_data_read( addr );118.52 + default:118.53 WARN( "Attempted read from unknown or invalid P4 region: %08X", addr );118.54 - return 0;118.55 + return 0;118.56 }118.57 } else {118.58 - int32_t val = io->io_read( addr&0xFFF );118.59 - TRACE_P4IO( "Long read %08X <= %08X", io, (addr&0xFFF), val, addr );118.60 + int32_t val = io->io_read( addr&0xFFF );118.61 + TRACE_P4IO( "Long read %08X <= %08X", io, (addr&0xFFF), val, addr );118.62 return val;118.63 }118.64 }118.65 @@ -100,24 +100,24 @@118.66 {118.67 struct mmio_region *io = P4_io[(addr&0x1FFFFFFF)>>19];118.68 if( !io ) {118.69 - switch( addr & 0x1F000000 ) {118.70 - case 0x00000000: case 0x01000000: case 0x02000000: case 0x03000000:118.71 + switch( addr & 0x1F000000 ) {118.72 + case 0x00000000: case 0x01000000: case 0x02000000: case 0x03000000:118.73 /* Store queue */118.74 SH4_WRITE_STORE_QUEUE( addr, val );118.75 - break;118.76 - case 0x10000000: mmu_icache_addr_write( addr, val ); break;118.77 - case 0x11000000: mmu_icache_data_write( addr, val ); break;118.78 - case 0x12000000: mmu_itlb_addr_write( addr, val ); break;118.79 - case 0x13000000: mmu_itlb_data_write( addr, val ); break;118.80 - case 0x14000000: mmu_ocache_addr_write( addr, val ); break;118.81 - case 0x15000000: mmu_ocache_data_write( addr, val ); break;118.82 - case 0x16000000: mmu_utlb_addr_write( addr, val ); break;118.83 - case 0x17000000: mmu_utlb_data_write( addr, val ); break;118.84 - default:118.85 + break;118.86 + case 0x10000000: mmu_icache_addr_write( addr, val ); break;118.87 + case 0x11000000: mmu_icache_data_write( addr, val ); break;118.88 + case 0x12000000: mmu_itlb_addr_write( addr, val ); break;118.89 + case 0x13000000: mmu_itlb_data_write( addr, val ); break;118.90 + case 0x14000000: mmu_ocache_addr_write( addr, val ); break;118.91 + case 0x15000000: mmu_ocache_data_write( addr, val ); break;118.92 + case 0x16000000: mmu_utlb_addr_write( addr, val ); break;118.93 + case 0x17000000: mmu_utlb_data_write( addr, val ); break;118.94 + default:118.95 WARN( "Attempted write to unknown P4 region: %08X", addr );118.96 }118.97 } else {118.98 - TRACE_P4IO( "Long write %08X => %08X", io, (addr&0xFFF), val, addr );118.99 + TRACE_P4IO( "Long write %08X => %08X", io, (addr&0xFFF), val, addr );118.100 io->io_write( addr&0xFFF, val );118.101 }118.102 }118.103 @@ -127,7 +127,7 @@118.104 sh4ptr_t page;118.105 if( addr >= 0xE0000000 ) /* P4 Area, handled specially */118.106 return SIGNEXT16(sh4_read_p4( addr ));118.107 -118.108 +118.109 if( (addr&0x1F800000) == 0x04000000 ) {118.110 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);118.111 }118.112 @@ -136,7 +136,7 @@118.113 if( ((uintptr_t)page) < MAX_IO_REGIONS ) { /* IO Region */118.114 if( page == NULL ) {118.115 WARN( "Attempted word read to missing page: %08X",118.116 - addr );118.117 + addr );118.118 return 0;118.119 }118.120 return SIGNEXT16(io_rgn[(uintptr_t)page]->io_read(addr&0xFFF));118.121 @@ -151,24 +151,24 @@118.122 int64_t sh4_read_quad( sh4addr_t addr )118.123 {118.124 return ((int64_t)((uint32_t)sh4_read_long(addr))) |118.125 - (((int64_t)((uint32_t)sh4_read_long(addr+4))) << 32);118.126 + (((int64_t)((uint32_t)sh4_read_long(addr+4))) << 32);118.127 }118.129 int32_t sh4_read_long( sh4addr_t addr )118.130 {118.131 sh4ptr_t page;118.132 -118.133 +118.134 CHECK_READ_WATCH(addr,4);118.136 if( addr >= 0xE0000000 ) { /* P4 Area, handled specially */118.137 return ZEROEXT32(sh4_read_p4( addr ));118.138 } else if( (addr&0x1C000000) == 0x0C000000 ) {118.139 - return ZEROEXT32(*(int32_t *)(sh4_main_ram + (addr&0x00FFFFFF)));118.140 + return ZEROEXT32(*(int32_t *)(sh4_main_ram + (addr&0x00FFFFFF)));118.141 } else if( (addr&0x1F800000) == 0x04000000 ) {118.142 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);118.143 - pvr2_render_buffer_invalidate(addr, FALSE);118.144 + pvr2_render_buffer_invalidate(addr, FALSE);118.145 } else if( (addr&0x1F800000) == 0x05000000 ) {118.146 - pvr2_render_buffer_invalidate(addr, FALSE);118.147 + pvr2_render_buffer_invalidate(addr, FALSE);118.148 }118.150 page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];118.151 @@ -195,19 +195,19 @@118.152 if( addr >= 0xE0000000 ) { /* P4 Area, handled specially */118.153 return ZEROEXT32(SIGNEXT16(sh4_read_p4( addr )));118.154 } else if( (addr&0x1C000000) == 0x0C000000 ) {118.155 - return ZEROEXT32(SIGNEXT16(*(int16_t *)(sh4_main_ram + (addr&0x00FFFFFF))));118.156 + return ZEROEXT32(SIGNEXT16(*(int16_t *)(sh4_main_ram + (addr&0x00FFFFFF))));118.157 } else if( (addr&0x1F800000) == 0x04000000 ) {118.158 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);118.159 - pvr2_render_buffer_invalidate(addr, FALSE);118.160 + pvr2_render_buffer_invalidate(addr, FALSE);118.161 } else if( (addr&0x1F800000) == 0x05000000 ) {118.162 - pvr2_render_buffer_invalidate(addr, FALSE);118.163 + pvr2_render_buffer_invalidate(addr, FALSE);118.164 }118.165 -118.166 +118.167 page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];118.168 if( ((uintptr_t)page) < MAX_IO_REGIONS ) { /* IO Region */118.169 int32_t val;118.170 if( page == NULL ) {118.171 - WARN( "Attempted word read to missing page: %08X", addr );118.172 + WARN( "Attempted word read to missing page: %08X", addr );118.173 return 0;118.174 }118.175 val = SIGNEXT16(io_rgn[(uintptr_t)page]->io_read(addr&0xFFF));118.176 @@ -227,15 +227,15 @@118.177 if( addr >= 0xE0000000 ) { /* P4 Area, handled specially */118.178 return ZEROEXT32(SIGNEXT8(sh4_read_p4( addr )));118.179 } else if( (addr&0x1C000000) == 0x0C000000 ) {118.180 - return ZEROEXT32(SIGNEXT8(*(int8_t *)(sh4_main_ram + (addr&0x00FFFFFF))));118.181 + return ZEROEXT32(SIGNEXT8(*(int8_t *)(sh4_main_ram + (addr&0x00FFFFFF))));118.182 } else if( (addr&0x1F800000) == 0x04000000 ) {118.183 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);118.184 - pvr2_render_buffer_invalidate(addr, FALSE);118.185 + pvr2_render_buffer_invalidate(addr, FALSE);118.186 } else if( (addr&0x1F800000) == 0x05000000 ) {118.187 - pvr2_render_buffer_invalidate(addr, FALSE);118.188 + pvr2_render_buffer_invalidate(addr, FALSE);118.189 }118.191 -118.192 +118.193 page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];118.194 if( ((uintptr_t)page) < MAX_IO_REGIONS ) { /* IO Region */118.195 int32_t val;118.196 @@ -270,16 +270,16 @@118.197 sh4_write_p4( addr, val );118.198 return;118.199 } else if( (addr&0x1C000000) == 0x0C000000 ) {118.200 - *(uint32_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;118.201 - xlat_invalidate_long(addr);118.202 - return;118.203 + *(uint32_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;118.204 + xlat_invalidate_long(addr);118.205 + return;118.206 } else if( (addr&0x1F800000) == 0x04000000 ||118.207 - (addr&0x1F800000) == 0x11000000 ) {118.208 - texcache_invalidate_page(addr& 0x7FFFFF);118.209 + (addr&0x1F800000) == 0x11000000 ) {118.210 + texcache_invalidate_page(addr& 0x7FFFFF);118.211 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);118.212 - pvr2_render_buffer_invalidate(addr, TRUE);118.213 + pvr2_render_buffer_invalidate(addr, TRUE);118.214 } else if( (addr&0x1F800000) == 0x05000000 ) {118.215 - pvr2_render_buffer_invalidate(addr, TRUE);118.216 + pvr2_render_buffer_invalidate(addr, TRUE);118.217 }118.219 if( (addr&0x1FFFFFFF) < 0x200000 ) {118.220 @@ -288,14 +288,14 @@118.221 return;118.222 }118.223 if( (addr&0x1F800000) == 0x00800000 )118.224 - asic_g2_write_word();118.225 + asic_g2_write_word();118.227 page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];118.228 if( ((uintptr_t)page) < MAX_IO_REGIONS ) { /* IO Region */118.229 if( page == NULL ) {118.230 - if( (addr & 0x1F000000) >= 0x04000000 &&118.231 - (addr & 0x1F000000) < 0x07000000 )118.232 - return;118.233 + if( (addr & 0x1F000000) >= 0x04000000 &&118.234 + (addr & 0x1F000000) < 0x07000000 )118.235 + return;118.236 WARN( "Long write to missing page: %08X => %08X", val, addr );118.237 return;118.238 }118.239 @@ -316,16 +316,16 @@118.240 sh4_write_p4( addr, (int16_t)val );118.241 return;118.242 } else if( (addr&0x1C000000) == 0x0C000000 ) {118.243 - *(uint16_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;118.244 - xlat_invalidate_word(addr);118.245 - return;118.246 + *(uint16_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;118.247 + xlat_invalidate_word(addr);118.248 + return;118.249 } else if( (addr&0x1F800000) == 0x04000000 ||118.250 - (addr&0x1F800000) == 0x11000000 ) {118.251 - texcache_invalidate_page(addr& 0x7FFFFF);118.252 + (addr&0x1F800000) == 0x11000000 ) {118.253 + texcache_invalidate_page(addr& 0x7FFFFF);118.254 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);118.255 - pvr2_render_buffer_invalidate(addr, TRUE);118.256 + pvr2_render_buffer_invalidate(addr, TRUE);118.257 } else if( (addr&0x1F800000) == 0x05000000 ) {118.258 - pvr2_render_buffer_invalidate(addr, TRUE);118.259 + pvr2_render_buffer_invalidate(addr, TRUE);118.260 }118.262 if( (addr&0x1FFFFFFF) < 0x200000 ) {118.263 @@ -356,18 +356,18 @@118.264 sh4_write_p4( addr, (int8_t)val );118.265 return;118.266 } else if( (addr&0x1C000000) == 0x0C000000 ) {118.267 - *(uint8_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;118.268 - xlat_invalidate_word(addr);118.269 - return;118.270 + *(uint8_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;118.271 + xlat_invalidate_word(addr);118.272 + return;118.273 } else if( (addr&0x1F800000) == 0x04000000 ||118.274 - (addr&0x1F800000) == 0x11000000 ) {118.275 - texcache_invalidate_page(addr& 0x7FFFFF);118.276 + (addr&0x1F800000) == 0x11000000 ) {118.277 + texcache_invalidate_page(addr& 0x7FFFFF);118.278 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);118.279 - pvr2_render_buffer_invalidate(addr, TRUE);118.280 + pvr2_render_buffer_invalidate(addr, TRUE);118.281 } else if( (addr&0x1F800000) == 0x05000000 ) {118.282 - pvr2_render_buffer_invalidate(addr, TRUE);118.283 + pvr2_render_buffer_invalidate(addr, TRUE);118.284 }118.285 -118.286 +118.287 if( (addr&0x1FFFFFFF) < 0x200000 ) {118.288 WARN( "Attempted write to read-only memory: %08X => %08X", val, addr);118.289 sh4_stop();118.290 @@ -393,33 +393,33 @@118.291 */118.292 void mem_copy_from_sh4( sh4ptr_t dest, sh4addr_t srcaddr, size_t count ) {118.293 if( srcaddr >= 0x04000000 && srcaddr < 0x05000000 ) {118.294 - pvr2_vram64_read( dest, srcaddr, count );118.295 + pvr2_vram64_read( dest, srcaddr, count );118.296 } else {118.297 - sh4ptr_t src = mem_get_region(srcaddr);118.298 - if( src == NULL ) {118.299 - WARN( "Attempted block read from unknown address %08X", srcaddr );118.300 - } else {118.301 - memcpy( dest, src, count );118.302 - }118.303 + sh4ptr_t src = mem_get_region(srcaddr);118.304 + if( src == NULL ) {118.305 + WARN( "Attempted block read from unknown address %08X", srcaddr );118.306 + } else {118.307 + memcpy( dest, src, count );118.308 + }118.309 }118.310 }118.312 void mem_copy_to_sh4( sh4addr_t destaddr, sh4ptr_t src, size_t count ) {118.313 if( destaddr >= 0x10000000 && destaddr < 0x14000000 ) {118.314 - pvr2_dma_write( destaddr, src, count );118.315 - return;118.316 + pvr2_dma_write( destaddr, src, count );118.317 + return;118.318 } else if( (destaddr & 0x1F800000) == 0x05000000 ) {118.319 - pvr2_render_buffer_invalidate( destaddr, TRUE );118.320 + pvr2_render_buffer_invalidate( destaddr, TRUE );118.321 } else if( (destaddr & 0x1F800000) == 0x04000000 ) {118.322 - pvr2_vram64_write( destaddr, src, count );118.323 - return;118.324 + pvr2_vram64_write( destaddr, src, count );118.325 + return;118.326 }118.327 sh4ptr_t dest = mem_get_region(destaddr);118.328 if( dest == NULL )118.329 - WARN( "Attempted block write to unknown address %08X", destaddr );118.330 + WARN( "Attempted block write to unknown address %08X", destaddr );118.331 else {118.332 - xlat_invalidate_block( destaddr, count );118.333 - memcpy( dest, src, count );118.334 + xlat_invalidate_block( destaddr, count );118.335 + memcpy( dest, src, count );118.336 }118.337 }118.339 @@ -427,7 +427,7 @@118.340 {118.341 sh4addr_t addr = mmu_vma_to_phys_read(vma);118.342 if( addr == MMU_VMA_ERROR ) {118.343 - return NULL;118.344 + return NULL;118.345 }118.347 sh4ptr_t page = page_map[ (addr & 0x1FFFFFFF) >> 12 ];
119.1 --- a/src/sh4/sh4mmio.c Mon Jul 14 07:42:45 2008 +0000119.2 +++ b/src/sh4/sh4mmio.c Mon Jul 14 07:44:42 2008 +0000119.3 @@ -39,9 +39,9 @@119.4 uint16_t output = MMIO_READ( BSC, PDTRA );119.5 uint16_t input_mask = 0, output_mask = 0;119.6 for( i=0; i<16; i++ ) {119.7 - int bits = (pctra >> (i<<1)) & 0x03;119.8 - if( bits == 2 ) input_mask |= (1<<i);119.9 - else if( bits != 0 ) output_mask |= (1<<i);119.10 + int bits = (pctra >> (i<<1)) & 0x03;119.11 + if( bits == 2 ) input_mask |= (1<<i);119.12 + else if( bits != 0 ) output_mask |= (1<<i);119.13 }119.15 /* ??? */119.16 @@ -61,9 +61,9 @@119.17 uint16_t output = MMIO_READ( BSC, PDTRB );119.18 uint16_t input_mask = 0, output_mask = 0;119.19 for( i=0; i<4; i++ ) {119.20 - int bits = (pctrb >> (i<<1)) & 0x03;119.21 - if( bits == 2 ) input_mask |= (1<<i);119.22 - else if( bits != 0 ) output_mask |= (1<<i);119.23 + int bits = (pctrb >> (i<<1)) & 0x03;119.24 + if( bits == 2 ) input_mask |= (1<<i);119.25 + else if( bits != 0 ) output_mask |= (1<<i);119.26 }119.28 return ((bsc_input>>16) & input_mask) | output;119.29 @@ -76,14 +76,14 @@119.30 {119.31 int32_t val;119.32 switch( reg ) {119.33 - case PDTRA:119.34 - val = bsc_read_pdtra();119.35 - break;119.36 - case PDTRB:119.37 - val = bsc_read_pdtrb();119.38 - break;119.39 - default:119.40 - val = MMIO_READ( BSC, reg );119.41 + case PDTRA:119.42 + val = bsc_read_pdtra();119.43 + break;119.44 + case PDTRB:119.45 + val = bsc_read_pdtrb();119.46 + break;119.47 + default:119.48 + val = MMIO_READ( BSC, reg );119.49 }119.50 return val;119.51 }
120.1 --- a/src/sh4/sh4mmio.h Mon Jul 14 07:42:45 2008 +0000120.2 +++ b/src/sh4/sh4mmio.h Mon Jul 14 07:44:42 2008 +0000120.3 @@ -23,6 +23,10 @@120.4 #if (defined(MMIO_IMPL) && !defined(SH4MMIO_IMPL)) || \120.5 (!defined(MMIO_IMPL) && !defined(SH4MMIO_IFACE))120.7 +#ifdef __cplusplus120.8 +extern "C" {120.9 +#endif120.10 +120.11 #ifdef MMIO_IMPL120.12 #define SH4MMIO_IMPL120.13 #else120.14 @@ -230,4 +234,10 @@120.15 void mmu_ocache_data_write( sh4addr_t addr, uint32_t val );120.16 void mmu_utlb_addr_write( sh4addr_t addr, uint32_t val );120.17 void mmu_utlb_data_write( sh4addr_t addr, uint32_t val );120.18 +120.19 +120.20 +#ifdef __cplusplus120.21 +}120.22 #endif120.23 +120.24 +#endif
121.1 --- a/src/sh4/sh4stat.h Mon Jul 14 07:42:45 2008 +0000121.2 +++ b/src/sh4/sh4stat.h Mon Jul 14 07:44:42 2008 +0000121.3 @@ -17,11 +17,15 @@121.4 */121.6 #ifndef lxdream_sh4stat_H121.7 -#define lxdream_sh4stat_H121.8 +#define lxdream_sh4stat_H 1121.10 #include <stdio.h>121.11 #include <stdint.h>121.13 +#ifdef __cplusplus121.14 +extern "C" {121.15 +#endif121.16 +121.17 typedef enum {121.18 I_UNKNOWN,121.19 I_ADD, I_ADDI, I_ADDC, I_ADDV,121.20 @@ -61,10 +65,13 @@121.22 #define SH4_INSTRUCTION_COUNT I_UNDEF121.24 -void sh4_stats_reset( void );121.25 -void sh4_stats_print( FILE *out );121.26 -void sh4_stats_add( sh4_inst_id id );121.27 -void sh4_stats_add_by_pc( uint32_t pc );121.28 + void sh4_stats_reset( void );121.29 + void sh4_stats_print( FILE *out );121.30 + void sh4_stats_add( sh4_inst_id id );121.31 + void sh4_stats_add_by_pc( uint32_t pc );121.33 +#ifdef __cplusplus121.34 +}121.35 +#endif121.37 #endif /* !lxdream_sh4stat_H */
122.1 --- a/src/sh4/sh4trans.c Mon Jul 14 07:42:45 2008 +0000122.2 +++ b/src/sh4/sh4trans.c Mon Jul 14 07:44:42 2008 +0000122.3 @@ -43,63 +43,63 @@122.4 sh4r.slice_cycle = 0;122.6 if( sh4r.sh4_state != SH4_STATE_RUNNING ) {122.7 - sh4_sleep_run_slice(nanosecs);122.8 + sh4_sleep_run_slice(nanosecs);122.9 }122.11 switch( setjmp(xlat_jmp_buf) ) {122.12 case XLAT_EXIT_BREAKPOINT:122.13 - sh4_clear_breakpoint( sh4r.pc, BREAK_ONESHOT );122.14 - /* fallthrough */122.15 + sh4_clear_breakpoint( sh4r.pc, BREAK_ONESHOT );122.16 + /* fallthrough */122.17 case XLAT_EXIT_HALT:122.18 - if( sh4r.sh4_state != SH4_STATE_STANDBY ) {122.19 - TMU_run_slice( sh4r.slice_cycle );122.20 - SCIF_run_slice( sh4r.slice_cycle );122.21 - dreamcast_stop();122.22 - return sh4r.slice_cycle;122.23 - }122.24 + if( sh4r.sh4_state != SH4_STATE_STANDBY ) {122.25 + TMU_run_slice( sh4r.slice_cycle );122.26 + SCIF_run_slice( sh4r.slice_cycle );122.27 + dreamcast_stop();122.28 + return sh4r.slice_cycle;122.29 + }122.30 case XLAT_EXIT_SYSRESET:122.31 - dreamcast_reset();122.32 - break;122.33 + dreamcast_reset();122.34 + break;122.35 case XLAT_EXIT_SLEEP:122.36 - sh4_sleep_run_slice(nanosecs);122.37 + sh4_sleep_run_slice(nanosecs);122.38 break;122.39 }122.40 -122.41 +122.42 xlat_running = TRUE;122.43 void * (*code)() = NULL;122.44 while( sh4r.slice_cycle < nanosecs ) {122.45 - if( sh4r.event_pending <= sh4r.slice_cycle ) {122.46 - if( sh4r.event_types & PENDING_EVENT ) {122.47 - event_execute();122.48 - }122.49 - /* Eventq execute may (quite likely) deliver an immediate IRQ */122.50 - if( sh4r.event_types & PENDING_IRQ ) {122.51 - sh4_accept_interrupt();122.52 - code = NULL;122.53 - }122.54 - }122.55 -122.56 - if( code == NULL ) {122.57 - if( sh4r.pc > 0xFFFFFF00 ) {122.58 - syscall_invoke( sh4r.pc );122.59 - sh4r.in_delay_slot = 0;122.60 - sh4r.pc = sh4r.pr;122.61 - }122.62 + if( sh4r.event_pending <= sh4r.slice_cycle ) {122.63 + if( sh4r.event_types & PENDING_EVENT ) {122.64 + event_execute();122.65 + }122.66 + /* Eventq execute may (quite likely) deliver an immediate IRQ */122.67 + if( sh4r.event_types & PENDING_IRQ ) {122.68 + sh4_accept_interrupt();122.69 + code = NULL;122.70 + }122.71 + }122.73 - code = xlat_get_code_by_vma( sh4r.pc );122.74 - if( code == NULL ) {122.75 - code = sh4_translate_basic_block( sh4r.pc );122.76 - }122.77 - }122.78 - code = code();122.79 + if( code == NULL ) {122.80 + if( sh4r.pc > 0xFFFFFF00 ) {122.81 + syscall_invoke( sh4r.pc );122.82 + sh4r.in_delay_slot = 0;122.83 + sh4r.pc = sh4r.pr;122.84 + }122.85 +122.86 + code = xlat_get_code_by_vma( sh4r.pc );122.87 + if( code == NULL ) {122.88 + code = sh4_translate_basic_block( sh4r.pc );122.89 + }122.90 + }122.91 + code = code();122.92 }122.94 xlat_running = FALSE;122.95 sh4_starting = FALSE;122.96 sh4r.slice_cycle = nanosecs;122.97 if( sh4r.sh4_state != SH4_STATE_STANDBY ) {122.98 - TMU_run_slice( nanosecs );122.99 - SCIF_run_slice( nanosecs );122.100 + TMU_run_slice( nanosecs );122.101 + SCIF_run_slice( nanosecs );122.102 }122.103 return nanosecs;122.104 }122.105 @@ -112,7 +112,7 @@122.106 void sh4_translate_add_recovery( uint32_t icount )122.107 {122.108 xlat_recovery[xlat_recovery_posn].xlat_offset =122.109 - ((uintptr_t)xlat_output) - ((uintptr_t)xlat_current_block->code);122.110 + ((uintptr_t)xlat_output) - ((uintptr_t)xlat_current_block->code);122.111 xlat_recovery[xlat_recovery_posn].sh4_icount = icount;122.112 xlat_recovery_posn++;122.113 }122.114 @@ -176,7 +176,7 @@122.115 }122.116 sh4_translate_end_block(pc);122.117 assert( xlat_output <= (xlat_current_block->code + xlat_current_block->size - recovery_size) );122.118 -122.119 +122.120 /* Write the recovery records onto the end of the code block */122.121 memcpy( xlat_output, xlat_recovery, recovery_size);122.122 xlat_current_block->recover_table_offset = xlat_output - (uint8_t *)xlat_current_block->code;122.123 @@ -205,11 +205,11 @@122.124 void *code = xlat_get_code( sh4r.pc );122.125 xlat_recovery_record_t recover = xlat_get_recovery(code, pc, TRUE);122.126 if( recover != NULL ) {122.127 - // Can be null if there is no recovery necessary122.128 - sh4_translate_run_recovery(recover);122.129 + // Can be null if there is no recovery necessary122.130 + sh4_translate_run_recovery(recover);122.131 }122.132 if( thunk != NULL ) {122.133 - thunk();122.134 + thunk();122.135 }122.136 // finally longjmp back into sh4_xlat_run_slice122.137 xlat_running = FALSE;122.138 @@ -220,13 +220,13 @@122.139 {122.140 void *pc = xlat_get_native_pc();122.141 if( pc != NULL ) {122.142 - // could be null if we're not actually running inside the translator122.143 - void *code = xlat_get_code( sh4r.pc );122.144 - xlat_recovery_record_t recover = xlat_get_recovery(code, pc, TRUE);122.145 - if( recover != NULL ) {122.146 - // Can be null if there is no recovery necessary122.147 - sh4_translate_run_recovery(recover);122.148 - }122.149 + // could be null if we're not actually running inside the translator122.150 + void *code = xlat_get_code( sh4r.pc );122.151 + xlat_recovery_record_t recover = xlat_get_recovery(code, pc, TRUE);122.152 + if( recover != NULL ) {122.153 + // Can be null if there is no recovery necessary122.154 + sh4_translate_run_recovery(recover);122.155 + }122.156 }122.157 // finally longjmp back into sh4_xlat_run_slice122.158 xlat_running = FALSE;122.159 @@ -236,7 +236,7 @@122.160 void sh4_translate_breakpoint_hit(uint32_t pc)122.161 {122.162 if( sh4_starting && sh4r.slice_cycle == 0 && pc == sh4r.pc ) {122.163 - return;122.164 + return;122.165 }122.166 sh4_translate_exit( XLAT_EXIT_BREAKPOINT );122.167 }122.168 @@ -260,14 +260,14 @@122.169 void *code = xlat_get_code( sh4r.pc );122.170 xlat_recovery_record_t recover = xlat_get_recovery(code, pc, TRUE);122.171 if( recover != NULL ) {122.172 - // Can be null if there is no recovery necessary122.173 - sh4_translate_run_recovery(recover);122.174 - xlat_flush_cache();122.175 - xlat_running = FALSE;122.176 - longjmp(xlat_jmp_buf, XLAT_EXIT_CONTINUE);122.177 + // Can be null if there is no recovery necessary122.178 + sh4_translate_run_recovery(recover);122.179 + xlat_flush_cache();122.180 + xlat_running = FALSE;122.181 + longjmp(xlat_jmp_buf, XLAT_EXIT_CONTINUE);122.182 } else {122.183 - xlat_flush_cache();122.184 - return;122.185 + xlat_flush_cache();122.186 + return;122.187 }122.188 }122.190 @@ -276,22 +276,22 @@122.191 void *result = NULL;122.193 if( IS_IN_ICACHE(vma) ) {122.194 - return xlat_get_code( GET_ICACHE_PHYS(vma) );122.195 + return xlat_get_code( GET_ICACHE_PHYS(vma) );122.196 }122.198 if( vma > 0xFFFFFF00 ) {122.199 - // lxdream hook122.200 - return NULL;122.201 + // lxdream hook122.202 + return NULL;122.203 }122.205 if( !mmu_update_icache(vma) ) {122.206 - // fault - off to the fault handler122.207 - if( !mmu_update_icache(sh4r.pc) ) {122.208 - // double fault - halt122.209 - ERROR( "Double fault - halting" );122.210 - dreamcast_stop();122.211 - return NULL;122.212 - }122.213 + // fault - off to the fault handler122.214 + if( !mmu_update_icache(sh4r.pc) ) {122.215 + // double fault - halt122.216 + ERROR( "Double fault - halting" );122.217 + dreamcast_stop();122.218 + return NULL;122.219 + }122.220 }122.222 assert( IS_IN_ICACHE(sh4r.pc) );
123.1 --- a/src/sh4/sh4trans.h Mon Jul 14 07:42:45 2008 +0000123.2 +++ b/src/sh4/sh4trans.h Mon Jul 14 07:44:42 2008 +0000123.3 @@ -16,10 +16,17 @@123.4 * GNU General Public License for more details.123.5 */123.7 +#ifndef lxdream_sh4trans_H123.8 +#define lxdream_sh4trans_H 1123.9 +123.10 #include "sh4/xltcache.h"123.11 #include "dream.h"123.12 #include "mem.h"123.14 +#ifdef __cplusplus123.15 +extern "C" {123.16 +#endif123.17 +123.18 /** Maximum size of a translated instruction, in bytes. Current worst case seems123.19 * to be a BF/S followed by one of the long FMOVs.123.20 */123.21 @@ -145,3 +152,9 @@123.22 * cycle and never returns.123.23 */123.24 void sh4_translate_breakpoint_hit( sh4vma_t pc );123.25 +123.26 +#ifdef __cplusplus123.27 +}123.28 +#endif123.29 +123.30 +#endif /* !lxdream_sh4trans_H */123.31 \ No newline at end of file
124.1 --- a/src/sh4/timer.c Mon Jul 14 07:42:45 2008 +0000124.2 +++ b/src/sh4/timer.c Mon Jul 14 07:44:42 2008 +0000124.3 @@ -55,23 +55,23 @@124.4 uint32_t div;124.5 switch( reg ) {124.6 case FRQCR: /* Frequency control */124.7 - div = ifc_divider[(val >> 6) & 0x07];124.8 - sh4_cpu_freq = sh4_input_freq / div;124.9 - sh4_cpu_period = sh4_cpu_multiplier * div / sh4_input_freq;124.10 - div = ifc_divider[(val >> 3) & 0x07];124.11 - sh4_bus_freq = sh4_input_freq / div;124.12 - sh4_bus_period = 1000 * div / sh4_input_freq;124.13 - div = pfc_divider[val & 0x07];124.14 - sh4_peripheral_freq = sh4_input_freq / div;124.15 - sh4_peripheral_period = 1000 * div / sh4_input_freq;124.16 + div = ifc_divider[(val >> 6) & 0x07];124.17 + sh4_cpu_freq = sh4_input_freq / div;124.18 + sh4_cpu_period = sh4_cpu_multiplier * div / sh4_input_freq;124.19 + div = ifc_divider[(val >> 3) & 0x07];124.20 + sh4_bus_freq = sh4_input_freq / div;124.21 + sh4_bus_period = 1000 * div / sh4_input_freq;124.22 + div = pfc_divider[val & 0x07];124.23 + sh4_peripheral_freq = sh4_input_freq / div;124.24 + sh4_peripheral_period = 1000 * div / sh4_input_freq;124.26 - /* Update everything that depends on the peripheral frequency */124.27 - SCIF_update_line_speed();124.28 - break;124.29 + /* Update everything that depends on the peripheral frequency */124.30 + SCIF_update_line_speed();124.31 + break;124.32 case WTCSR: /* Watchdog timer */124.33 - break;124.34 + break;124.35 }124.36 -124.37 +124.38 MMIO_WRITE( CPG, reg, val );124.39 }124.41 @@ -136,14 +136,14 @@124.42 {124.43 switch( reg ) {124.44 case TCNT0:124.45 - TMU_count( 0, sh4r.slice_cycle );124.46 - break;124.47 + TMU_count( 0, sh4r.slice_cycle );124.48 + break;124.49 case TCNT1:124.50 - TMU_count( 1, sh4r.slice_cycle );124.51 - break;124.52 + TMU_count( 1, sh4r.slice_cycle );124.53 + break;124.54 case TCNT2:124.55 - TMU_count( 2, sh4r.slice_cycle );124.56 - break;124.57 + TMU_count( 2, sh4r.slice_cycle );124.58 + break;124.59 }124.60 return MMIO_READ( TMU, reg );124.61 }124.62 @@ -154,45 +154,45 @@124.63 uint32_t oldtcr = MMIO_READ( TMU, TCR0 + (12*timer) );124.65 if( (oldtcr & TCR_UNF) == 0 ) {124.66 - tcr = tcr & (~TCR_UNF);124.67 + tcr = tcr & (~TCR_UNF);124.68 } else {124.69 - if( ((oldtcr & TCR_UNIE) == 0) &&124.70 - (tcr & TCR_IRQ_ACTIVE) == TCR_IRQ_ACTIVE ) {124.71 - intc_raise_interrupt( INT_TMU_TUNI0 + timer );124.72 - } else if( (oldtcr & TCR_UNIE) != 0 &&124.73 - (tcr & TCR_IRQ_ACTIVE) != TCR_IRQ_ACTIVE ) {124.74 - intc_clear_interrupt( INT_TMU_TUNI0 + timer );124.75 - }124.76 + if( ((oldtcr & TCR_UNIE) == 0) &&124.77 + (tcr & TCR_IRQ_ACTIVE) == TCR_IRQ_ACTIVE ) {124.78 + intc_raise_interrupt( INT_TMU_TUNI0 + timer );124.79 + } else if( (oldtcr & TCR_UNIE) != 0 &&124.80 + (tcr & TCR_IRQ_ACTIVE) != TCR_IRQ_ACTIVE ) {124.81 + intc_clear_interrupt( INT_TMU_TUNI0 + timer );124.82 + }124.83 }124.85 switch( tcr & 0x07 ) {124.86 case 0:124.87 - period = sh4_peripheral_period << 2 ;124.88 - break;124.89 + period = sh4_peripheral_period << 2 ;124.90 + break;124.91 case 1:124.92 - period = sh4_peripheral_period << 4;124.93 - break;124.94 + period = sh4_peripheral_period << 4;124.95 + break;124.96 case 2:124.97 - period = sh4_peripheral_period << 6;124.98 - break;124.99 + period = sh4_peripheral_period << 6;124.100 + break;124.101 case 3:124.102 - period = sh4_peripheral_period << 8;124.103 - break;124.104 + period = sh4_peripheral_period << 8;124.105 + break;124.106 case 4:124.107 - period = sh4_peripheral_period << 10;124.108 - break;124.109 + period = sh4_peripheral_period << 10;124.110 + break;124.111 case 5:124.112 - /* Illegal value. */124.113 - ERROR( "TMU %d period set to illegal value (5)", timer );124.114 - period = sh4_peripheral_period << 12; /* for something to do */124.115 - break;124.116 + /* Illegal value. */124.117 + ERROR( "TMU %d period set to illegal value (5)", timer );124.118 + period = sh4_peripheral_period << 12; /* for something to do */124.119 + break;124.120 case 6:124.121 - period = rtc_output_period;124.122 - break;124.123 + period = rtc_output_period;124.124 + break;124.125 case 7:124.126 - /* External clock... Hrm? */124.127 - period = sh4_peripheral_period; /* I dunno... */124.128 - break;124.129 + /* External clock... Hrm? */124.130 + period = sh4_peripheral_period; /* I dunno... */124.131 + break;124.132 }124.133 TMU_timers[timer].timer_period = period;124.135 @@ -202,9 +202,9 @@124.136 void TMU_schedule_timer( int timer )124.137 {124.138 uint64_t duration = (uint64_t)((uint32_t)(MMIO_READ( TMU, TCNT0 + 12*timer )+1)) *124.139 - (uint64_t)TMU_timers[timer].timer_period - TMU_timers[timer].timer_remainder;124.140 + (uint64_t)TMU_timers[timer].timer_period - TMU_timers[timer].timer_remainder;124.141 event_schedule_long( EVENT_TMU0+timer, (uint32_t)(duration / 1000000000),124.142 - (uint32_t)(duration % 1000000000) );124.143 + (uint32_t)(duration % 1000000000) );124.144 }124.146 void TMU_start( int timer )124.147 @@ -229,26 +229,26 @@124.148 uint32_t TMU_count( int timer, uint32_t nanosecs )124.149 {124.150 uint32_t run_ns = nanosecs + TMU_timers[timer].timer_remainder -124.151 - TMU_timers[timer].timer_run;124.152 + TMU_timers[timer].timer_run;124.153 TMU_timers[timer].timer_remainder =124.154 - run_ns % TMU_timers[timer].timer_period;124.155 + run_ns % TMU_timers[timer].timer_period;124.156 TMU_timers[timer].timer_run = nanosecs;124.157 uint32_t count = run_ns / TMU_timers[timer].timer_period;124.158 uint32_t value = MMIO_READ( TMU, TCNT0 + 12*timer );124.159 uint32_t reset = MMIO_READ( TMU, TCOR0 + 12*timer );124.160 if( count > value ) {124.161 - uint32_t tcr = MMIO_READ( TMU, TCR0 + 12*timer );124.162 - tcr |= TCR_UNF;124.163 - count -= value;124.164 + uint32_t tcr = MMIO_READ( TMU, TCR0 + 12*timer );124.165 + tcr |= TCR_UNF;124.166 + count -= value;124.167 value = reset - (count % reset) + 1;124.168 - MMIO_WRITE( TMU, TCR0 + 12*timer, tcr );124.169 - if( tcr & TCR_UNIE )124.170 - intc_raise_interrupt( INT_TMU_TUNI0 + timer );124.171 - MMIO_WRITE( TMU, TCNT0 + 12*timer, value );124.172 - TMU_schedule_timer(timer);124.173 + MMIO_WRITE( TMU, TCR0 + 12*timer, tcr );124.174 + if( tcr & TCR_UNIE )124.175 + intc_raise_interrupt( INT_TMU_TUNI0 + timer );124.176 + MMIO_WRITE( TMU, TCNT0 + 12*timer, value );124.177 + TMU_schedule_timer(timer);124.178 } else {124.179 - value -= count;124.180 - MMIO_WRITE( TMU, TCNT0 + 12*timer, value );124.181 + value -= count;124.182 + MMIO_WRITE( TMU, TCNT0 + 12*timer, value );124.183 }124.184 return value;124.185 }124.186 @@ -259,45 +259,45 @@124.187 int i;124.188 switch( reg ) {124.189 case TSTR:124.190 - oldval = MMIO_READ( TMU, TSTR );124.191 - for( i=0; i<3; i++ ) {124.192 - uint32_t tmp = 1<<i;124.193 - if( (oldval & tmp) != 0 && (val&tmp) == 0 )124.194 - TMU_stop(i);124.195 - else if( (oldval&tmp) == 0 && (val&tmp) != 0 )124.196 - TMU_start(i);124.197 - }124.198 - break;124.199 + oldval = MMIO_READ( TMU, TSTR );124.200 + for( i=0; i<3; i++ ) {124.201 + uint32_t tmp = 1<<i;124.202 + if( (oldval & tmp) != 0 && (val&tmp) == 0 )124.203 + TMU_stop(i);124.204 + else if( (oldval&tmp) == 0 && (val&tmp) != 0 )124.205 + TMU_start(i);124.206 + }124.207 + break;124.208 case TCR0:124.209 - TMU_set_timer_control( 0, val );124.210 - return;124.211 + TMU_set_timer_control( 0, val );124.212 + return;124.213 case TCR1:124.214 - TMU_set_timer_control( 1, val );124.215 - return;124.216 + TMU_set_timer_control( 1, val );124.217 + return;124.218 case TCR2:124.219 - TMU_set_timer_control( 2, val );124.220 - return;124.221 + TMU_set_timer_control( 2, val );124.222 + return;124.223 case TCNT0:124.224 - MMIO_WRITE( TMU, reg, val );124.225 - if( TMU_IS_RUNNING(0) ) { // reschedule124.226 - TMU_timers[0].timer_run = sh4r.slice_cycle;124.227 - TMU_schedule_timer( 0 );124.228 - }124.229 - return;124.230 + MMIO_WRITE( TMU, reg, val );124.231 + if( TMU_IS_RUNNING(0) ) { // reschedule124.232 + TMU_timers[0].timer_run = sh4r.slice_cycle;124.233 + TMU_schedule_timer( 0 );124.234 + }124.235 + return;124.236 case TCNT1:124.237 - MMIO_WRITE( TMU, reg, val );124.238 - if( TMU_IS_RUNNING(1) ) { // reschedule124.239 - TMU_timers[1].timer_run = sh4r.slice_cycle;124.240 - TMU_schedule_timer( 1 );124.241 - }124.242 - return;124.243 + MMIO_WRITE( TMU, reg, val );124.244 + if( TMU_IS_RUNNING(1) ) { // reschedule124.245 + TMU_timers[1].timer_run = sh4r.slice_cycle;124.246 + TMU_schedule_timer( 1 );124.247 + }124.248 + return;124.249 case TCNT2:124.250 - MMIO_WRITE( TMU, reg, val );124.251 - if( TMU_IS_RUNNING(2) ) { // reschedule124.252 - TMU_timers[2].timer_run = sh4r.slice_cycle;124.253 - TMU_schedule_timer( 2 );124.254 - }124.255 - return;124.256 + MMIO_WRITE( TMU, reg, val );124.257 + if( TMU_IS_RUNNING(2) ) { // reschedule124.258 + TMU_timers[2].timer_run = sh4r.slice_cycle;124.259 + TMU_schedule_timer( 2 );124.260 + }124.261 + return;124.262 }124.263 MMIO_WRITE( TMU, reg, val );124.264 }124.265 @@ -306,13 +306,13 @@124.266 {124.267 int tcr = MMIO_READ( TMU, TSTR );124.268 if( tcr & 0x01 ) {124.269 - TMU_count( 0, nanosecs );124.270 + TMU_count( 0, nanosecs );124.271 }124.272 if( tcr & 0x02 ) {124.273 - TMU_count( 1, nanosecs );124.274 + TMU_count( 1, nanosecs );124.275 }124.276 if( tcr & 0x04 ) {124.277 - TMU_count( 2, nanosecs );124.278 + TMU_count( 2, nanosecs );124.279 }124.280 }
125.1 --- a/src/sh4/x86op.h Mon Jul 14 07:42:45 2008 +0000125.2 +++ b/src/sh4/x86op.h Mon Jul 14 07:44:42 2008 +0000125.3 @@ -16,8 +16,12 @@125.4 * GNU General Public License for more details.125.5 */125.7 -#ifndef __lxdream_x86op_H125.8 -#define __lxdream_x86op_H125.9 +#ifndef lxdream_x86op_H125.10 +#define lxdream_x86op_H 1125.11 +125.12 +#ifdef __cplusplus125.13 +extern "C" {125.14 +#endif125.16 #define R_NONE -1125.17 #define R_EAX 0125.18 @@ -305,4 +309,8 @@125.19 /* Pseudo-op Load carry from T: CMP [EBP+t], #01 ; CMC */125.20 #define LDC_t() OP(0x83); MODRM_r32_sh4r(7,R_T); OP(0x01); CMC()125.22 -#endif /* !__lxdream_x86op_H */125.23 +#ifdef __cplusplus125.24 +}125.25 +#endif125.26 +125.27 +#endif /* !lxdream_x86op_H */
126.1 --- a/src/sh4/xltcache.c Mon Jul 14 07:42:45 2008 +0000126.2 +++ b/src/sh4/xltcache.c Mon Jul 14 07:44:42 2008 +0000126.3 @@ -15,7 +15,7 @@126.4 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the126.5 * GNU General Public License for more details.126.6 */126.7 -126.8 +126.9 #include <sys/types.h>126.10 #include <sys/mman.h>126.11 #include <assert.h>126.12 @@ -62,21 +62,21 @@126.13 void xlat_cache_init(void)126.14 {126.15 if( !xlat_initialized ) {126.16 - xlat_initialized = TRUE;126.17 - xlat_new_cache = mmap( NULL, XLAT_NEW_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,126.18 - MAP_PRIVATE|MAP_ANON, -1, 0 );126.19 - xlat_temp_cache = mmap( NULL, XLAT_TEMP_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,126.20 - MAP_PRIVATE|MAP_ANON, -1, 0 );126.21 - xlat_old_cache = mmap( NULL, XLAT_OLD_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,126.22 - MAP_PRIVATE|MAP_ANON, -1, 0 );126.23 - xlat_new_cache_ptr = xlat_new_cache;126.24 - xlat_temp_cache_ptr = xlat_temp_cache;126.25 - xlat_old_cache_ptr = xlat_old_cache;126.26 - xlat_new_create_ptr = xlat_new_cache;126.27 -126.28 - xlat_lut = mmap( NULL, XLAT_LUT_PAGES*sizeof(void *), PROT_READ|PROT_WRITE,126.29 - MAP_PRIVATE|MAP_ANON, -1, 0);126.30 - memset( xlat_lut, 0, XLAT_LUT_PAGES*sizeof(void *) );126.31 + xlat_initialized = TRUE;126.32 + xlat_new_cache = mmap( NULL, XLAT_NEW_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,126.33 + MAP_PRIVATE|MAP_ANON, -1, 0 );126.34 + xlat_temp_cache = mmap( NULL, XLAT_TEMP_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,126.35 + MAP_PRIVATE|MAP_ANON, -1, 0 );126.36 + xlat_old_cache = mmap( NULL, XLAT_OLD_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,126.37 + MAP_PRIVATE|MAP_ANON, -1, 0 );126.38 + xlat_new_cache_ptr = xlat_new_cache;126.39 + xlat_temp_cache_ptr = xlat_temp_cache;126.40 + xlat_old_cache_ptr = xlat_old_cache;126.41 + xlat_new_create_ptr = xlat_new_cache;126.42 +126.43 + xlat_lut = mmap( NULL, XLAT_LUT_PAGES*sizeof(void *), PROT_READ|PROT_WRITE,126.44 + MAP_PRIVATE|MAP_ANON, -1, 0);126.45 + memset( xlat_lut, 0, XLAT_LUT_PAGES*sizeof(void *) );126.46 }126.47 xlat_flush_cache();126.48 }126.49 @@ -84,7 +84,7 @@126.50 void xlat_print_free( FILE *out )126.51 {126.52 fprintf( out, "New space: %d\nTemp space: %d\nOld space: %d\n",126.53 - xlat_new_cache_ptr->size, xlat_temp_cache_ptr->size, xlat_old_cache_ptr->size );126.54 + xlat_new_cache_ptr->size, xlat_temp_cache_ptr->size, xlat_old_cache_ptr->size );126.55 }126.57 /**126.58 @@ -113,9 +113,9 @@126.59 tmp->active = 1;126.60 tmp->size = 0;126.61 for( i=0; i<XLAT_LUT_PAGES; i++ ) {126.62 - if( xlat_lut[i] != NULL ) {126.63 - memset( xlat_lut[i], 0, XLAT_LUT_PAGE_SIZE );126.64 - }126.65 + if( xlat_lut[i] != NULL ) {126.66 + memset( xlat_lut[i], 0, XLAT_LUT_PAGE_SIZE );126.67 + }126.68 }126.69 }126.71 @@ -123,36 +123,36 @@126.72 {126.73 int i;126.74 for( i=0; i<XLAT_LUT_PAGE_ENTRIES; i++ ) {126.75 - if( IS_ENTRY_POINT(page[i]) ) {126.76 - BLOCK_FOR_CODE(page[i])->active = 0;126.77 - }126.78 - page[i] = NULL;126.79 + if( IS_ENTRY_POINT(page[i]) ) {126.80 + BLOCK_FOR_CODE(page[i])->active = 0;126.81 + }126.82 + page[i] = NULL;126.83 }126.84 }126.86 void xlat_invalidate_word( sh4addr_t addr )126.87 {126.88 if( xlat_lut ) {126.89 - void **page = xlat_lut[XLAT_LUT_PAGE(addr)];126.90 - if( page != NULL ) {126.91 - int entry = XLAT_LUT_ENTRY(addr);126.92 - if( page[entry] != NULL ) {126.93 - xlat_flush_page_by_lut(page);126.94 - }126.95 - }126.96 + void **page = xlat_lut[XLAT_LUT_PAGE(addr)];126.97 + if( page != NULL ) {126.98 + int entry = XLAT_LUT_ENTRY(addr);126.99 + if( page[entry] != NULL ) {126.100 + xlat_flush_page_by_lut(page);126.101 + }126.102 + }126.103 }126.104 }126.106 void xlat_invalidate_long( sh4addr_t addr )126.107 {126.108 if( xlat_lut ) {126.109 - void **page = xlat_lut[XLAT_LUT_PAGE(addr)];126.110 - if( page != NULL ) {126.111 - int entry = XLAT_LUT_ENTRY(addr);126.112 - if( page[entry] != NULL || page[entry+1] != NULL ) {126.113 - xlat_flush_page_by_lut(page);126.114 - }126.115 - }126.116 + void **page = xlat_lut[XLAT_LUT_PAGE(addr)];126.117 + if( page != NULL ) {126.118 + int entry = XLAT_LUT_ENTRY(addr);126.119 + if( page[entry] != NULL || page[entry+1] != NULL ) {126.120 + xlat_flush_page_by_lut(page);126.121 + }126.122 + }126.123 }126.124 }126.126 @@ -163,30 +163,30 @@126.127 uint32_t page_no = XLAT_LUT_PAGE(address);126.128 int entry = XLAT_LUT_ENTRY(address);126.129 if( xlat_lut ) {126.130 - do {126.131 - void **page = xlat_lut[page_no];126.132 - int page_entries = XLAT_LUT_PAGE_ENTRIES - entry;126.133 - if( entry_count < page_entries ) {126.134 - page_entries = entry_count;126.135 - }126.136 - if( page != NULL ) {126.137 - if( page_entries == XLAT_LUT_PAGE_ENTRIES ) {126.138 - /* Overwriting the entire page anyway */126.139 - xlat_flush_page_by_lut(page);126.140 - } else {126.141 - for( i=entry; i<entry+page_entries; i++ ) {126.142 - if( page[i] != NULL ) {126.143 - xlat_flush_page_by_lut(page);126.144 - break;126.145 - }126.146 - }126.147 - }126.148 - entry_count -= page_entries;126.149 - }126.150 - page_no ++;126.151 - entry_count -= page_entries;126.152 - entry = 0;126.153 - } while( entry_count > 0 );126.154 + do {126.155 + void **page = xlat_lut[page_no];126.156 + int page_entries = XLAT_LUT_PAGE_ENTRIES - entry;126.157 + if( entry_count < page_entries ) {126.158 + page_entries = entry_count;126.159 + }126.160 + if( page != NULL ) {126.161 + if( page_entries == XLAT_LUT_PAGE_ENTRIES ) {126.162 + /* Overwriting the entire page anyway */126.163 + xlat_flush_page_by_lut(page);126.164 + } else {126.165 + for( i=entry; i<entry+page_entries; i++ ) {126.166 + if( page[i] != NULL ) {126.167 + xlat_flush_page_by_lut(page);126.168 + break;126.169 + }126.170 + }126.171 + }126.172 + entry_count -= page_entries;126.173 + }126.174 + page_no ++;126.175 + entry_count -= page_entries;126.176 + entry = 0;126.177 + } while( entry_count > 0 );126.178 }126.179 }126.181 @@ -194,7 +194,7 @@126.182 {126.183 void **page = xlat_lut[XLAT_LUT_PAGE(address)];126.184 if( page != NULL ) {126.185 - xlat_flush_page_by_lut(page);126.186 + xlat_flush_page_by_lut(page);126.187 }126.188 }126.190 @@ -203,7 +203,7 @@126.191 void *result = NULL;126.192 void **page = xlat_lut[XLAT_LUT_PAGE(address)];126.193 if( page != NULL ) {126.194 - result = (void *)(((uintptr_t)(page[XLAT_LUT_ENTRY(address)])) & (~((uintptr_t)0x03)));126.195 + result = (void *)(((uintptr_t)(page[XLAT_LUT_ENTRY(address)])) & (~((uintptr_t)0x03)));126.196 }126.197 return result;126.198 }126.199 @@ -211,29 +211,29 @@126.200 xlat_recovery_record_t xlat_get_recovery( void *code, void *native_pc, gboolean recover_after )126.201 {126.202 if( code != NULL ) {126.203 - uintptr_t pc_offset = ((uint8_t *)native_pc) - ((uint8_t *)code);126.204 - xlat_cache_block_t block = BLOCK_FOR_CODE(code);126.205 - uint32_t count = block->recover_table_size;126.206 - xlat_recovery_record_t records = (xlat_recovery_record_t)(&block->code[block->recover_table_offset]);126.207 - uint32_t posn;126.208 - if( recover_after ) {126.209 - if( records[count-1].xlat_offset < pc_offset ) {126.210 - return NULL;126.211 - }126.212 - for( posn=count-1; posn > 0; posn-- ) {126.213 - if( records[posn-1].xlat_offset < pc_offset ) {126.214 - return &records[posn];126.215 - }126.216 - }126.217 - return &records[0]; // shouldn't happen126.218 - } else {126.219 - for( posn = 1; posn < count; posn++ ) {126.220 - if( records[posn].xlat_offset >= pc_offset ) {126.221 - return &records[posn-1];126.222 - }126.223 - }126.224 - return &records[count-1];126.225 - }126.226 + uintptr_t pc_offset = ((uint8_t *)native_pc) - ((uint8_t *)code);126.227 + xlat_cache_block_t block = BLOCK_FOR_CODE(code);126.228 + uint32_t count = block->recover_table_size;126.229 + xlat_recovery_record_t records = (xlat_recovery_record_t)(&block->code[block->recover_table_offset]);126.230 + uint32_t posn;126.231 + if( recover_after ) {126.232 + if( records[count-1].xlat_offset < pc_offset ) {126.233 + return NULL;126.234 + }126.235 + for( posn=count-1; posn > 0; posn-- ) {126.236 + if( records[posn-1].xlat_offset < pc_offset ) {126.237 + return &records[posn];126.238 + }126.239 + }126.240 + return &records[0]; // shouldn't happen126.241 + } else {126.242 + for( posn = 1; posn < count; posn++ ) {126.243 + if( records[posn].xlat_offset >= pc_offset ) {126.244 + return &records[posn-1];126.245 + }126.246 + }126.247 + return &records[count-1];126.248 + }126.249 }126.250 return NULL;126.251 }126.252 @@ -244,12 +244,12 @@126.254 /* Add the LUT entry for the block */126.255 if( page == NULL ) {126.256 - xlat_lut[XLAT_LUT_PAGE(address)] = page =126.257 - mmap( NULL, XLAT_LUT_PAGE_SIZE, PROT_READ|PROT_WRITE,126.258 - MAP_PRIVATE|MAP_ANON, -1, 0 );126.259 - memset( page, 0, XLAT_LUT_PAGE_SIZE );126.260 + xlat_lut[XLAT_LUT_PAGE(address)] = page =126.261 + mmap( NULL, XLAT_LUT_PAGE_SIZE, PROT_READ|PROT_WRITE,126.262 + MAP_PRIVATE|MAP_ANON, -1, 0 );126.263 + memset( page, 0, XLAT_LUT_PAGE_SIZE );126.264 }126.265 -126.266 +126.267 return &page[XLAT_LUT_ENTRY(address)];126.268 }126.270 @@ -265,9 +265,9 @@126.271 {126.272 xlat_cache_block_t xlt = (xlat_cache_block_t)(((char *)block)-sizeof(struct xlat_cache_block));126.273 if( xlt->recover_table_offset == 0 ) {126.274 - return xlt->size;126.275 + return xlt->size;126.276 } else {126.277 - return xlt->recover_table_offset;126.278 + return xlt->recover_table_offset;126.279 }126.280 }126.282 @@ -282,14 +282,14 @@126.283 cutsize = (cutsize + 3) & 0xFFFFFFFC; // force word alignment126.284 assert( cutsize <= block->size );126.285 if( block->size > cutsize + MIN_TOTAL_SIZE ) {126.286 - int oldsize = block->size;126.287 - block->size = cutsize;126.288 - xlat_cache_block_t next = NEXT(block);126.289 - next->active = 0;126.290 - next->size = oldsize - cutsize - sizeof(struct xlat_cache_block);126.291 - return next;126.292 + int oldsize = block->size;126.293 + block->size = cutsize;126.294 + xlat_cache_block_t next = NEXT(block);126.295 + next->active = 0;126.296 + next->size = oldsize - cutsize - sizeof(struct xlat_cache_block);126.297 + return next;126.298 } else {126.299 - return NEXT(block);126.300 + return NEXT(block);126.301 }126.302 }126.304 @@ -305,20 +305,20 @@126.305 xlat_cache_block_t curr = xlat_old_cache_ptr;126.306 xlat_cache_block_t start_block = curr;126.307 do {126.308 - allocation += curr->size + sizeof(struct xlat_cache_block);126.309 - curr = NEXT(curr);126.310 - if( allocation > size ) {126.311 - break; /* done */126.312 - }126.313 - if( curr->size == 0 ) { /* End-of-cache Sentinel */126.314 - /* Leave what we just released as free space and start again from the126.315 - * top of the cache126.316 - */126.317 - start_block->active = 0;126.318 - start_block->size = allocation;126.319 - allocation = -sizeof(struct xlat_cache_block);126.320 - start_block = curr = xlat_old_cache;126.321 - }126.322 + allocation += curr->size + sizeof(struct xlat_cache_block);126.323 + curr = NEXT(curr);126.324 + if( allocation > size ) {126.325 + break; /* done */126.326 + }126.327 + if( curr->size == 0 ) { /* End-of-cache Sentinel */126.328 + /* Leave what we just released as free space and start again from the126.329 + * top of the cache126.330 + */126.331 + start_block->active = 0;126.332 + start_block->size = allocation;126.333 + allocation = -sizeof(struct xlat_cache_block);126.334 + start_block = curr = xlat_old_cache;126.335 + }126.336 } while(1);126.337 start_block->active = 1;126.338 start_block->size = allocation;126.339 @@ -329,7 +329,7 @@126.340 memcpy( start_block->code, block->code, block->size );126.341 xlat_old_cache_ptr = xlat_cut_block(start_block, size );126.342 if( xlat_old_cache_ptr->size == 0 ) {126.343 - xlat_old_cache_ptr = xlat_old_cache;126.344 + xlat_old_cache_ptr = xlat_old_cache;126.345 }126.346 }126.348 @@ -344,26 +344,26 @@126.349 xlat_cache_block_t curr = xlat_temp_cache_ptr;126.350 xlat_cache_block_t start_block = curr;126.351 do {126.352 - if( curr->active == BLOCK_USED ) {126.353 - xlat_promote_to_old_space( curr );126.354 - } else if( curr->active == BLOCK_ACTIVE ) {126.355 - // Active but not used, release block126.356 - *((uintptr_t *)curr->lut_entry) &= ((uintptr_t)0x03);126.357 - }126.358 - allocation += curr->size + sizeof(struct xlat_cache_block);126.359 - curr = NEXT(curr);126.360 - if( allocation > size ) {126.361 - break; /* done */126.362 - }126.363 - if( curr->size == 0 ) { /* End-of-cache Sentinel */126.364 - /* Leave what we just released as free space and start again from the126.365 - * top of the cache126.366 - */126.367 - start_block->active = 0;126.368 - start_block->size = allocation;126.369 - allocation = -sizeof(struct xlat_cache_block);126.370 - start_block = curr = xlat_temp_cache;126.371 - }126.372 + if( curr->active == BLOCK_USED ) {126.373 + xlat_promote_to_old_space( curr );126.374 + } else if( curr->active == BLOCK_ACTIVE ) {126.375 + // Active but not used, release block126.376 + *((uintptr_t *)curr->lut_entry) &= ((uintptr_t)0x03);126.377 + }126.378 + allocation += curr->size + sizeof(struct xlat_cache_block);126.379 + curr = NEXT(curr);126.380 + if( allocation > size ) {126.381 + break; /* done */126.382 + }126.383 + if( curr->size == 0 ) { /* End-of-cache Sentinel */126.384 + /* Leave what we just released as free space and start again from the126.385 + * top of the cache126.386 + */126.387 + start_block->active = 0;126.388 + start_block->size = allocation;126.389 + allocation = -sizeof(struct xlat_cache_block);126.390 + start_block = curr = xlat_temp_cache;126.391 + }126.392 } while(1);126.393 start_block->active = 1;126.394 start_block->size = allocation;126.395 @@ -374,9 +374,9 @@126.396 memcpy( start_block->code, block->code, block->size );126.397 xlat_temp_cache_ptr = xlat_cut_block(start_block, size );126.398 if( xlat_temp_cache_ptr->size == 0 ) {126.399 - xlat_temp_cache_ptr = xlat_temp_cache;126.400 + xlat_temp_cache_ptr = xlat_temp_cache;126.401 }126.402 -126.403 +126.404 }126.406 /**126.407 @@ -386,11 +386,11 @@126.408 xlat_cache_block_t xlat_start_block( sh4addr_t address )126.409 {126.410 if( xlat_new_cache_ptr->size == 0 ) {126.411 - xlat_new_cache_ptr = xlat_new_cache;126.412 + xlat_new_cache_ptr = xlat_new_cache;126.413 }126.415 if( xlat_new_cache_ptr->active ) {126.416 - xlat_promote_to_temp_space( xlat_new_cache_ptr );126.417 + xlat_promote_to_temp_space( xlat_new_cache_ptr );126.418 }126.419 xlat_new_create_ptr = xlat_new_cache_ptr;126.420 xlat_new_create_ptr->active = 1;126.421 @@ -398,56 +398,56 @@126.423 /* Add the LUT entry for the block */126.424 if( xlat_lut[XLAT_LUT_PAGE(address)] == NULL ) {126.425 - xlat_lut[XLAT_LUT_PAGE(address)] =126.426 - mmap( NULL, XLAT_LUT_PAGE_SIZE, PROT_READ|PROT_WRITE,126.427 - MAP_PRIVATE|MAP_ANON, -1, 0 );126.428 - memset( xlat_lut[XLAT_LUT_PAGE(address)], 0, XLAT_LUT_PAGE_SIZE );126.429 + xlat_lut[XLAT_LUT_PAGE(address)] =126.430 + mmap( NULL, XLAT_LUT_PAGE_SIZE, PROT_READ|PROT_WRITE,126.431 + MAP_PRIVATE|MAP_ANON, -1, 0 );126.432 + memset( xlat_lut[XLAT_LUT_PAGE(address)], 0, XLAT_LUT_PAGE_SIZE );126.433 }126.435 if( IS_ENTRY_POINT(xlat_lut[XLAT_LUT_PAGE(address)][XLAT_LUT_ENTRY(address)]) ) {126.436 - xlat_cache_block_t oldblock = BLOCK_FOR_CODE(xlat_lut[XLAT_LUT_PAGE(address)][XLAT_LUT_ENTRY(address)]);126.437 - oldblock->active = 0;126.438 + xlat_cache_block_t oldblock = BLOCK_FOR_CODE(xlat_lut[XLAT_LUT_PAGE(address)][XLAT_LUT_ENTRY(address)]);126.439 + oldblock->active = 0;126.440 }126.442 xlat_lut[XLAT_LUT_PAGE(address)][XLAT_LUT_ENTRY(address)] =126.443 - &xlat_new_create_ptr->code;126.444 + &xlat_new_create_ptr->code;126.445 xlat_new_create_ptr->lut_entry = xlat_lut[XLAT_LUT_PAGE(address)] + XLAT_LUT_ENTRY(address);126.446 -126.447 +126.448 return xlat_new_create_ptr;126.449 }126.451 xlat_cache_block_t xlat_extend_block( uint32_t newSize )126.452 {126.453 while( xlat_new_create_ptr->size < newSize ) {126.454 - if( xlat_new_cache_ptr->size == 0 ) {126.455 - /* Migrate to the front of the cache to keep it contiguous */126.456 - xlat_new_create_ptr->active = 0;126.457 - sh4ptr_t olddata = xlat_new_create_ptr->code;126.458 - int oldsize = xlat_new_create_ptr->size;126.459 - int size = oldsize + MIN_BLOCK_SIZE; /* minimum expansion */126.460 - void **lut_entry = xlat_new_create_ptr->lut_entry;126.461 - int allocation = -sizeof(struct xlat_cache_block);126.462 - xlat_new_cache_ptr = xlat_new_cache;126.463 - do {126.464 - if( xlat_new_cache_ptr->active ) {126.465 - xlat_promote_to_temp_space( xlat_new_cache_ptr );126.466 - }126.467 - allocation += xlat_new_cache_ptr->size + sizeof(struct xlat_cache_block);126.468 - xlat_new_cache_ptr = NEXT(xlat_new_cache_ptr);126.469 - } while( allocation < size );126.470 - xlat_new_create_ptr = xlat_new_cache;126.471 - xlat_new_create_ptr->active = 1;126.472 - xlat_new_create_ptr->size = allocation;126.473 - xlat_new_create_ptr->lut_entry = lut_entry;126.474 - *lut_entry = &xlat_new_create_ptr->code;126.475 - memmove( xlat_new_create_ptr->code, olddata, oldsize );126.476 - } else {126.477 - if( xlat_new_cache_ptr->active ) {126.478 - xlat_promote_to_temp_space( xlat_new_cache_ptr );126.479 - }126.480 - xlat_new_create_ptr->size += xlat_new_cache_ptr->size + sizeof(struct xlat_cache_block);126.481 - xlat_new_cache_ptr = NEXT(xlat_new_cache_ptr);126.482 - }126.483 + if( xlat_new_cache_ptr->size == 0 ) {126.484 + /* Migrate to the front of the cache to keep it contiguous */126.485 + xlat_new_create_ptr->active = 0;126.486 + sh4ptr_t olddata = xlat_new_create_ptr->code;126.487 + int oldsize = xlat_new_create_ptr->size;126.488 + int size = oldsize + MIN_BLOCK_SIZE; /* minimum expansion */126.489 + void **lut_entry = xlat_new_create_ptr->lut_entry;126.490 + int allocation = -sizeof(struct xlat_cache_block);126.491 + xlat_new_cache_ptr = xlat_new_cache;126.492 + do {126.493 + if( xlat_new_cache_ptr->active ) {126.494 + xlat_promote_to_temp_space( xlat_new_cache_ptr );126.495 + }126.496 + allocation += xlat_new_cache_ptr->size + sizeof(struct xlat_cache_block);126.497 + xlat_new_cache_ptr = NEXT(xlat_new_cache_ptr);126.498 + } while( allocation < size );126.499 + xlat_new_create_ptr = xlat_new_cache;126.500 + xlat_new_create_ptr->active = 1;126.501 + xlat_new_create_ptr->size = allocation;126.502 + xlat_new_create_ptr->lut_entry = lut_entry;126.503 + *lut_entry = &xlat_new_create_ptr->code;126.504 + memmove( xlat_new_create_ptr->code, olddata, oldsize );126.505 + } else {126.506 + if( xlat_new_cache_ptr->active ) {126.507 + xlat_promote_to_temp_space( xlat_new_cache_ptr );126.508 + }126.509 + xlat_new_create_ptr->size += xlat_new_cache_ptr->size + sizeof(struct xlat_cache_block);126.510 + xlat_new_cache_ptr = NEXT(xlat_new_cache_ptr);126.511 + }126.512 }126.513 return xlat_new_create_ptr;126.515 @@ -458,10 +458,10 @@126.516 void **ptr = xlat_new_create_ptr->lut_entry;126.517 void **endptr = ptr + (srcsize>>2);126.518 while( ptr < endptr ) {126.519 - if( *ptr == NULL ) {126.520 - *ptr = XLAT_LUT_ENTRY_USED;126.521 - }126.522 - ptr++;126.523 + if( *ptr == NULL ) {126.524 + *ptr = XLAT_LUT_ENTRY_USED;126.525 + }126.526 + ptr++;126.527 }126.529 xlat_new_cache_ptr = xlat_cut_block( xlat_new_create_ptr, destsize );126.530 @@ -477,17 +477,17 @@126.531 {126.532 int foundptr = 0;126.533 xlat_cache_block_t tail =126.534 - (xlat_cache_block_t)(((char *)cache) + size - sizeof(struct xlat_cache_block));126.535 + (xlat_cache_block_t)(((char *)cache) + size - sizeof(struct xlat_cache_block));126.537 assert( tail->active == 1 );126.538 assert( tail->size == 0 );126.539 while( cache < tail ) {126.540 - assert( cache->active >= 0 && cache->active <= 2 );126.541 - assert( cache->size >= 0 && cache->size < size );126.542 - if( cache == ptr ) {126.543 - foundptr = 1;126.544 - }126.545 - cache = NEXT(cache);126.546 + assert( cache->active >= 0 && cache->active <= 2 );126.547 + assert( cache->size >= 0 && cache->size < size );126.548 + if( cache == ptr ) {126.549 + foundptr = 1;126.550 + }126.551 + cache = NEXT(cache);126.552 }126.553 assert( cache == tail );126.554 assert( foundptr == 1 || tail == ptr );
127.1 --- a/src/sh4/xltcache.h Mon Jul 14 07:42:45 2008 +0000127.2 +++ b/src/sh4/xltcache.h Mon Jul 14 07:44:42 2008 +0000127.3 @@ -20,7 +20,7 @@127.4 #include "mem.h"127.6 #ifndef lxdream_xltcache_H127.7 -#define lxdream_xltcache_H127.8 +#define lxdream_xltcache_H 1127.10 /**127.11 * For now, recovery is purely a matter of mapping native pc => sh4 pc,127.12 @@ -33,8 +33,8 @@127.13 */127.14 typedef struct xlat_recovery_record {127.15 uint32_t xlat_offset; // native (translated) pc127.16 - uint32_t sh4_icount; // instruction number of the corresponding SH4 instruction127.17 - // (0 = first instruction, 1 = second instruction, ... )127.18 + uint32_t sh4_icount; // instruction number of the corresponding SH4 instruction127.19 + // (0 = first instruction, 1 = second instruction, ... )127.20 } *xlat_recovery_record_t;127.22 struct xlat_cache_block {
128.1 --- a/src/syscall.c Mon Jul 14 07:42:45 2008 +0000128.2 +++ b/src/syscall.c Mon Jul 14 07:44:42 2008 +0000128.3 @@ -31,13 +31,13 @@128.4 {128.5 hook_id &= 0xFF;128.6 if( syscall_hooks[hook_id].hook != NULL )128.7 - WARN( "Overwriting existing hook %02X", hook_id );128.8 + WARN( "Overwriting existing hook %02X", hook_id );128.9 syscall_hooks[hook_id].hook = hook;128.10 syscall_hooks[hook_id].vector = 0;128.11 }128.13 void syscall_add_hook_vector( uint32_t hook_id, uint32_t vector_addr,128.14 - syscall_hook_func_t hook )128.15 + syscall_hook_func_t hook )128.16 {128.17 hook_id &= 0xFF;128.18 syscall_add_hook( hook_id, hook );128.19 @@ -50,9 +50,9 @@128.20 hook_id &= 0xFF;128.21 syscall_hook_func_t hook = syscall_hooks[hook_id].hook;128.22 if( hook == NULL ) {128.23 - WARN( "Invoked non-existent hook %02X", hook_id );128.24 + WARN( "Invoked non-existent hook %02X", hook_id );128.25 } else {128.26 - hook(hook_id);128.27 + hook(hook_id);128.28 }128.29 }128.31 @@ -60,9 +60,9 @@128.32 {128.33 int i;128.34 for( i=0; i<256; i++ ) {128.35 - if( syscall_hooks[i].hook != NULL &&128.36 - syscall_hooks[i].vector != 0 ) {128.37 - mem_write_long( syscall_hooks[i].vector, 0xFFFFFF00 + i );128.38 - }128.39 + if( syscall_hooks[i].hook != NULL &&128.40 + syscall_hooks[i].vector != 0 ) {128.41 + mem_write_long( syscall_hooks[i].vector, 0xFFFFFF00 + i );128.42 + }128.43 }128.44 }
129.1 --- a/src/syscall.h Mon Jul 14 07:42:45 2008 +0000129.2 +++ b/src/syscall.h Mon Jul 14 07:44:42 2008 +0000129.3 @@ -16,8 +16,8 @@129.4 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the129.5 * GNU General Public License for more details.129.6 */129.7 -#ifndef dream_syscall_H129.8 -#define dream_syscall_H 1129.9 +#ifndef lxdream_syscall_H129.10 +#define lxdream_syscall_H 1129.12 #include <stdint.h>129.13 #include <glib/gtypes.h>129.14 @@ -74,4 +74,5 @@129.15 #ifdef __cplusplus129.16 }129.17 #endif129.18 -#endif129.19 +129.20 +#endif /* !lxdream_syscall_H */
130.1 --- a/src/tools/actparse.c Mon Jul 14 07:42:45 2008 +0000130.2 +++ b/src/tools/actparse.c Mon Jul 14 07:44:42 2008 +0000130.3 @@ -42,41 +42,41 @@130.5 // Strip c-style comments130.6 while( *p ) {130.7 - if( *p == '/' && *(p+1) == '*' ) {130.8 - p+=2;130.9 - while( *p ) {130.10 - if( *p == '*' && *(p+1) == '/' ) {130.11 - p+=2;130.12 - break;130.13 - }130.14 - p++;130.15 - }130.16 - } else if( *p == '/' && *(p+1) == '/' ) {130.17 - p+=2;130.18 - while( *p && *p != '\n' ) {130.19 - p++;130.20 - }130.21 - } else {130.22 - *q++ = *p++;130.23 - }130.24 + if( *p == '/' && *(p+1) == '*' ) {130.25 + p+=2;130.26 + while( *p ) {130.27 + if( *p == '*' && *(p+1) == '/' ) {130.28 + p+=2;130.29 + break;130.30 + }130.31 + p++;130.32 + }130.33 + } else if( *p == '/' && *(p+1) == '/' ) {130.34 + p+=2;130.35 + while( *p && *p != '\n' ) {130.36 + p++;130.37 + }130.38 + } else {130.39 + *q++ = *p++;130.40 + }130.41 }130.42 *q = '\0';130.43 strcpy( operation, g_strstrip(opclean) );130.45 for( i=0; i<rules->rule_count; i++ ) {130.46 - if( strcasecmp(rules->rules[i]->format, operation) == 0 ) {130.47 - if( actions->actions[i] != NULL ) {130.48 - fprintf( stderr, "Duplicate actions for operation '%s'\n", operation );130.49 - return -1;130.50 - }130.51 - actions->actions[i] = act;130.52 - return 0;130.53 - }130.54 + if( strcasecmp(rules->rules[i]->format, operation) == 0 ) {130.55 + if( actions->actions[i] != NULL ) {130.56 + fprintf( stderr, "Duplicate actions for operation '%s'\n", operation );130.57 + return -1;130.58 + }130.59 + actions->actions[i] = act;130.60 + return 0;130.61 + }130.62 }130.63 fprintf(stderr, "No operation found matching '%s'\n", operation );130.64 return -1;130.65 }130.66 -130.67 +130.69 struct actionset *parse_action_file( struct ruleset *rules, FILE *f )130.70 {130.71 @@ -84,7 +84,7 @@130.72 struct stat st;130.73 char *text;130.74 int i, length;130.75 -130.76 +130.77 memset( actions, 0, sizeof( struct actionset ) );130.78 /* Read whole file in (for convenience) */130.79 fstat( fileno(f), &st );130.80 @@ -95,47 +95,47 @@130.81 yyline = 0;130.82 actions->pretext = text;130.83 for( i=0; i<length; i++ ) {130.84 - if( text[i] == '\n' ) {130.85 - yyline++;130.86 - if( i+3 < length && text[i+1] == '%' && text[i+2] == '%' ) {130.87 - text[i+1] = '\0';130.88 - i+=3;130.89 - break;130.90 - }130.91 - }130.92 + if( text[i] == '\n' ) {130.93 + yyline++;130.94 + if( i+3 < length && text[i+1] == '%' && text[i+2] == '%' ) {130.95 + text[i+1] = '\0';130.96 + i+=3;130.97 + break;130.98 + }130.99 + }130.100 }130.102 char *operation = &text[i];130.103 for( ; i<length; i++ ) {130.104 - if( text[i] == '\n' ) {130.105 - yyline++;130.106 - if( i+3 < length && text[i+1] == '%' && text[i+2] == '%' ) {130.107 - i+=3;130.108 - break;130.109 - }130.110 - }130.111 -130.112 - if( text[i] == '{' && text[i+1] == ':' ) {130.113 - text[i] = '\0';130.114 - i+=2;130.115 - char *action = &text[i];130.116 - for( ;i<length; i++ ) {130.117 - if( text[i] == ':' && text[i+1] == '}' ) {130.118 - text[i] = '\0';130.119 - i++;130.120 - if( add_action( actions, rules, operation, action ) != 0 ) {130.121 - free(actions);130.122 - free(text);130.123 - return NULL;130.124 - }130.125 - operation = &text[i+1];130.126 - break;130.127 - }130.128 - }130.129 - }130.130 + if( text[i] == '\n' ) {130.131 + yyline++;130.132 + if( i+3 < length && text[i+1] == '%' && text[i+2] == '%' ) {130.133 + i+=3;130.134 + break;130.135 + }130.136 + }130.137 +130.138 + if( text[i] == '{' && text[i+1] == ':' ) {130.139 + text[i] = '\0';130.140 + i+=2;130.141 + char *action = &text[i];130.142 + for( ;i<length; i++ ) {130.143 + if( text[i] == ':' && text[i+1] == '}' ) {130.144 + text[i] = '\0';130.145 + i++;130.146 + if( add_action( actions, rules, operation, action ) != 0 ) {130.147 + free(actions);130.148 + free(text);130.149 + return NULL;130.150 + }130.151 + operation = &text[i+1];130.152 + break;130.153 + }130.154 + }130.155 + }130.156 }130.158 actions->posttext = &text[i];130.159 -130.160 +130.161 return actions;130.162 }
131.1 --- a/src/tools/gendec.c Mon Jul 14 07:42:45 2008 +0000131.2 +++ b/src/tools/gendec.c Mon Jul 14 07:44:42 2008 +0000131.3 @@ -50,13 +50,13 @@131.4 * Find a mask that can be used to split up the given rules131.5 */131.6 uint32_t find_mask( struct ruleset *rules, int ruleidx[], int rule_count,131.7 - uint32_t input_mask )131.8 + uint32_t input_mask )131.9 {131.10 int i;131.11 uint32_t mask = rules->rules[ruleidx[0]]->mask;131.13 for( i=1; i<rule_count; i++ ) {131.14 - mask = mask & rules->rules[ruleidx[i]]->mask;131.15 + mask = mask & rules->rules[ruleidx[i]]->mask;131.16 }131.18 assert( (mask & input_mask) == input_mask ); /* input_mask should always be included in the mask */131.19 @@ -68,9 +68,9 @@131.20 int count = 0;131.22 while( mask ) {131.23 - if( mask&1 )131.24 - count++;131.25 - mask >>= 1;131.26 + if( mask&1 )131.27 + count++;131.28 + mask >>= 1;131.29 }131.30 return 1<<count;131.31 }131.32 @@ -78,23 +78,23 @@131.33 int get_bitshift_for_mask( uint32_t mask ) {131.34 int shift = 0;131.35 while( mask && !(mask&1) ) {131.36 - shift++;131.37 - mask >>= 1;131.38 + shift++;131.39 + mask >>= 1;131.40 }131.41 return shift;131.42 }131.44 void get_option_values_for_mask( uint32_t *options,131.45 - uint32_t mask )131.46 + uint32_t mask )131.47 {131.48 /* This could be a lot smarter. But it's not */131.49 int i;131.50 *options = 0;131.51 for( i=1; i<=mask; i++ ) {131.52 - if( (i & mask) > *options ) {131.53 - options++;131.54 - *options = (i&mask);131.55 - }131.56 + if( (i & mask) > *options ) {131.57 + options++;131.58 + *options = (i&mask);131.59 + }131.60 }131.61 }131.63 @@ -105,24 +105,24 @@131.65 /* Determine number of spaces in first line of input */131.66 for( i=0; isspace(action[i]); i++ ) {131.67 - if( action[i] == '\n' ) {131.68 - spaces = 0;131.69 - text = &action[i+1];131.70 - } else {131.71 - spaces++;131.72 - }131.73 + if( action[i] == '\n' ) {131.74 + spaces = 0;131.75 + text = &action[i+1];131.76 + } else {131.77 + spaces++;131.78 + }131.79 }131.81 needed -= spaces;131.82 fprintf( f, "%*c", needed, ' ' );131.83 for( i=0; text[i] != '\0'; i++ ) {131.84 - fputc( text[i], f );131.85 - if( text[i] == '\n' && text[i+1] != '\0' ) {131.86 - fprintf( f, "%*c", needed, ' ' );131.87 - }131.88 + fputc( text[i], f );131.89 + if( text[i] == '\n' && text[i+1] != '\0' ) {131.90 + fprintf( f, "%*c", needed, ' ' );131.91 + }131.92 }131.93 if( text[i-1] != '\n' ) {131.94 - fprintf( f, "\n" );131.95 + fprintf( f, "\n" );131.96 }131.97 }131.99 @@ -130,96 +130,96 @@131.100 {131.101 int i;131.102 if( action == NULL ) {131.103 - fprintf( f, "%*cUNIMP(ir); /* %s */\n", depth*8, ' ', rule->format );131.104 + fprintf( f, "%*cUNIMP(ir); /* %s */\n", depth*8, ' ', rule->format );131.105 } else {131.106 - fprintf( f, "%*c{ /* %s */", depth*8, ' ', rule->format );131.107 - if( rule->operand_count != 0 ) {131.108 - fprintf( f, "\n%*c", depth*8, ' ' );131.109 - for( i=0; i<rule->operand_count; i++ ) {131.110 - if( rule->operands[i].is_signed ) {131.111 - fprintf( f, "int32_t %s = SIGNEXT%d", rule->operands[i].name, rule->operands[i].bit_count );131.112 - } else {131.113 - fprintf( f, "uint32_t %s = ", rule->operands[i].name );131.114 - }131.115 - if( rule->operands[i].bit_shift == 0 ) {131.116 - fprintf( f, "(ir&0x%X)", (1<<(rule->operands[i].bit_count))-1 );131.117 - } else {131.118 - fprintf( f, "((ir>>%d)&0x%X)", rule->operands[i].bit_shift,131.119 - (1<<(rule->operands[i].bit_count))-1 );131.120 - }131.121 - if( rule->operands[i].left_shift != 0 ) {131.122 - fprintf( f, "<<%d", rule->operands[i].left_shift );131.123 - }131.124 - fprintf( f, "; " );131.125 - }131.126 - }131.127 - fputs( "\n", f );131.128 - if( action[0] != '\0' ) {131.129 - fprint_indent( action, depth, f );131.130 - }131.131 - fprintf( f, "%*c}\n", depth*8, ' ' );131.132 + fprintf( f, "%*c{ /* %s */", depth*8, ' ', rule->format );131.133 + if( rule->operand_count != 0 ) {131.134 + fprintf( f, "\n%*c", depth*8, ' ' );131.135 + for( i=0; i<rule->operand_count; i++ ) {131.136 + if( rule->operands[i].is_signed ) {131.137 + fprintf( f, "int32_t %s = SIGNEXT%d", rule->operands[i].name, rule->operands[i].bit_count );131.138 + } else {131.139 + fprintf( f, "uint32_t %s = ", rule->operands[i].name );131.140 + }131.141 + if( rule->operands[i].bit_shift == 0 ) {131.142 + fprintf( f, "(ir&0x%X)", (1<<(rule->operands[i].bit_count))-1 );131.143 + } else {131.144 + fprintf( f, "((ir>>%d)&0x%X)", rule->operands[i].bit_shift,131.145 + (1<<(rule->operands[i].bit_count))-1 );131.146 + }131.147 + if( rule->operands[i].left_shift != 0 ) {131.148 + fprintf( f, "<<%d", rule->operands[i].left_shift );131.149 + }131.150 + fprintf( f, "; " );131.151 + }131.152 + }131.153 + fputs( "\n", f );131.154 + if( action[0] != '\0' ) {131.155 + fprint_indent( action, depth, f );131.156 + }131.157 + fprintf( f, "%*c}\n", depth*8, ' ' );131.158 }131.159 }131.161 void split_and_generate( struct ruleset *rules, struct actionset *actions,131.162 - int ruleidx[], int rule_count, int input_mask,131.163 - int depth, FILE *f ) {131.164 + int ruleidx[], int rule_count, int input_mask,131.165 + int depth, FILE *f ) {131.166 uint32_t mask;131.167 int i,j;131.169 if( rule_count == 0 ) {131.170 - fprintf( f, "%*cUNDEF(ir);\n", depth*8, ' ' );131.171 + fprintf( f, "%*cUNDEF(ir);\n", depth*8, ' ' );131.172 } else if( rule_count == 1 ) {131.173 - fprint_action( rules->rules[ruleidx[0]], actions->actions[ruleidx[0]], depth, f );131.174 + fprint_action( rules->rules[ruleidx[0]], actions->actions[ruleidx[0]], depth, f );131.175 } else {131.177 - mask = find_mask(rules, ruleidx, rule_count, input_mask);131.178 - if( mask == 0 ) { /* No matching mask? */131.179 - fprintf( stderr, "Error: unable to find a valid bitmask (%d rules, %08X input mask)\n", rule_count, input_mask );131.180 - dump_rulesubset( rules, ruleidx, rule_count, stderr );131.181 - return;131.182 - }131.183 -131.184 - /* break up the rules into sub-sets, and process each sub-set.131.185 - * NB: We could do this in one pass at the cost of more complex131.186 - * data structures. For now though, this keeps it simple131.187 - */131.188 - int option_count = get_option_count_for_mask( mask );131.189 - uint32_t options[option_count];131.190 - int subruleidx[rule_count];131.191 - int subrule_count;131.192 - int mask_shift = get_bitshift_for_mask( mask );131.193 - int has_empty_options = 0;131.194 - get_option_values_for_mask( options, mask );131.195 -131.196 - if( mask_shift == 0 ) {131.197 - fprintf( f, "%*cswitch( ir&0x%X ) {\n", depth*8, ' ', mask );131.198 - } else {131.199 - fprintf( f, "%*cswitch( (ir&0x%X) >> %d ) {\n", depth*8, ' ',131.200 - mask, mask_shift);131.201 - }131.202 - for( i=0; i<option_count; i++ ) {131.203 - subrule_count = 0;131.204 - for( j=0; j<rule_count; j++ ) {131.205 - int match = rules->rules[ruleidx[j]]->bits & mask;131.206 - if( match == options[i] ) {131.207 - subruleidx[subrule_count++] = ruleidx[j];131.208 - }131.209 - }131.210 - if( subrule_count == 0 ) {131.211 - has_empty_options = 1;131.212 - } else {131.213 - fprintf( f, "%*ccase 0x%X:\n", depth*8+4, ' ', options[i]>>mask_shift );131.214 - split_and_generate( rules, actions, subruleidx, subrule_count,131.215 - mask|input_mask, depth+1, f );131.216 - fprintf( f, "%*cbreak;\n", depth*8+8, ' ' );131.217 - }131.218 - }131.219 - if( has_empty_options ) {131.220 - fprintf( f, "%*cdefault:\n%*cUNDEF();\n%*cbreak;\n",131.221 - depth*8+4, ' ', depth*8+8, ' ', depth*8 + 8, ' ' );131.222 - }131.223 - fprintf( f, "%*c}\n", depth*8, ' ' );131.224 + mask = find_mask(rules, ruleidx, rule_count, input_mask);131.225 + if( mask == 0 ) { /* No matching mask? */131.226 + fprintf( stderr, "Error: unable to find a valid bitmask (%d rules, %08X input mask)\n", rule_count, input_mask );131.227 + dump_rulesubset( rules, ruleidx, rule_count, stderr );131.228 + return;131.229 + }131.230 +131.231 + /* break up the rules into sub-sets, and process each sub-set.131.232 + * NB: We could do this in one pass at the cost of more complex131.233 + * data structures. For now though, this keeps it simple131.234 + */131.235 + int option_count = get_option_count_for_mask( mask );131.236 + uint32_t options[option_count];131.237 + int subruleidx[rule_count];131.238 + int subrule_count;131.239 + int mask_shift = get_bitshift_for_mask( mask );131.240 + int has_empty_options = 0;131.241 + get_option_values_for_mask( options, mask );131.242 +131.243 + if( mask_shift == 0 ) {131.244 + fprintf( f, "%*cswitch( ir&0x%X ) {\n", depth*8, ' ', mask );131.245 + } else {131.246 + fprintf( f, "%*cswitch( (ir&0x%X) >> %d ) {\n", depth*8, ' ',131.247 + mask, mask_shift);131.248 + }131.249 + for( i=0; i<option_count; i++ ) {131.250 + subrule_count = 0;131.251 + for( j=0; j<rule_count; j++ ) {131.252 + int match = rules->rules[ruleidx[j]]->bits & mask;131.253 + if( match == options[i] ) {131.254 + subruleidx[subrule_count++] = ruleidx[j];131.255 + }131.256 + }131.257 + if( subrule_count == 0 ) {131.258 + has_empty_options = 1;131.259 + } else {131.260 + fprintf( f, "%*ccase 0x%X:\n", depth*8+4, ' ', options[i]>>mask_shift );131.261 + split_and_generate( rules, actions, subruleidx, subrule_count,131.262 + mask|input_mask, depth+1, f );131.263 + fprintf( f, "%*cbreak;\n", depth*8+8, ' ' );131.264 + }131.265 + }131.266 + if( has_empty_options ) {131.267 + fprintf( f, "%*cdefault:\n%*cUNDEF();\n%*cbreak;\n",131.268 + depth*8+4, ' ', depth*8+8, ' ', depth*8 + 8, ' ' );131.269 + }131.270 + fprintf( f, "%*c}\n", depth*8, ' ' );131.271 }131.272 }131.274 @@ -229,15 +229,15 @@131.275 int i;131.277 for( i=0; i<rules->rule_count; i++ ) {131.278 - ruleidx[i] = i;131.279 + ruleidx[i] = i;131.280 }131.282 fputs( actions->pretext, f );131.283 -131.284 +131.285 split_and_generate( rules, actions, ruleidx, rules->rule_count, 0, 1, f );131.287 fputs( actions->posttext, f );131.288 -131.289 +131.290 return 0;131.291 }131.293 @@ -248,12 +248,12 @@131.294 fputs( "%%\n", f );131.296 for( i=0; i<rules->rule_count; i++ ) {131.297 - fprintf( f, "%s {: %s :}\n", rules->rules[i]->format,131.298 - actions->actions[i] == NULL ? "" : actions->actions[i] );131.299 + fprintf( f, "%s {: %s :}\n", rules->rules[i]->format,131.300 + actions->actions[i] == NULL ? "" : actions->actions[i] );131.301 }131.302 fputs( "%%\n", f );131.303 fputs( actions->posttext, f );131.304 -131.305 +131.306 return 0;131.307 }131.309 @@ -265,87 +265,87 @@131.310 /* Parse the command line */131.311 while( (opt = getopt_long( argc, argv, option_list, longopts, NULL )) != -1 ) {131.312 switch( opt ) {131.313 - case 't':131.314 - gen_mode = GEN_TEMPLATE;131.315 - break;131.316 - case 'o':131.317 - out_filename = optarg;131.318 - break;131.319 - case 'h':131.320 - usage();131.321 - exit(0);131.322 - }131.323 + case 't':131.324 + gen_mode = GEN_TEMPLATE;131.325 + break;131.326 + case 'o':131.327 + out_filename = optarg;131.328 + break;131.329 + case 'h':131.330 + usage();131.331 + exit(0);131.332 + }131.333 }131.334 if( optind < argc ) {131.335 - ins_filename = argv[optind++];131.336 + ins_filename = argv[optind++];131.337 }131.338 if( optind < argc ) {131.339 - act_filename = argv[optind++];131.340 + act_filename = argv[optind++];131.341 }131.343 if( optind < argc || ins_filename == NULL || act_filename == NULL ) {131.344 - usage();131.345 - exit(1);131.346 + usage();131.347 + exit(1);131.348 }131.349 -131.350 +131.351 if( out_filename == NULL ) {131.352 - if( gen_mode == GEN_TEMPLATE ) {131.353 - out_filename = act_filename;131.354 - } else {131.355 - char tmp[strlen(act_filename)+1];131.356 - strcpy( tmp, act_filename);131.357 - char *c = strrchr( tmp, '.' );131.358 - if( c != NULL ) {131.359 - *c = '\0';131.360 - }131.361 - out_filename = g_strconcat( tmp, DEFAULT_OUT_EXT, NULL );131.362 - }131.363 + if( gen_mode == GEN_TEMPLATE ) {131.364 + out_filename = act_filename;131.365 + } else {131.366 + char tmp[strlen(act_filename)+1];131.367 + strcpy( tmp, act_filename);131.368 + char *c = strrchr( tmp, '.' );131.369 + if( c != NULL ) {131.370 + *c = '\0';131.371 + }131.372 + out_filename = g_strconcat( tmp, DEFAULT_OUT_EXT, NULL );131.373 + }131.374 }131.376 /* Open the files */131.377 ins_file = fopen( ins_filename, "ro" );131.378 if( ins_file == NULL ) {131.379 fprintf( stderr, "Unable to open '%s' for reading (%s)\n", ins_filename, strerror(errno) );131.380 - exit(2);131.381 + exit(2);131.382 }131.384 act_file = fopen( act_filename, "ro" );131.385 if( act_file == NULL ) {131.386 fprintf( stderr, "Unable to open '%s' for reading (%s)\n", act_filename, strerror(errno) );131.387 - exit(3);131.388 + exit(3);131.389 }131.390 -131.391 +131.392 /* Parse the input */131.393 struct ruleset *rules = parse_ruleset_file( ins_file );131.394 fclose( ins_file );131.395 if( rules == NULL ) {131.396 - exit(5);131.397 + exit(5);131.398 }131.400 struct actionset *actions = parse_action_file( rules, act_file );131.401 fclose( act_file );131.402 if( actions == NULL ) {131.403 - exit(6);131.404 + exit(6);131.405 }131.407 /* Finally write out the results */131.408 out_file = fopen( out_filename, "wo" );131.409 if( out_file == NULL ) {131.410 fprintf( stderr, "Unable to open '%s' for writing (%s)\n", out_filename, strerror(errno) );131.411 - exit(4);131.412 + exit(4);131.413 }131.414 -131.415 +131.416 switch( gen_mode ) {131.417 case GEN_SOURCE:131.418 - if( generate_decoder( rules, actions, out_file ) != 0 ) {131.419 - exit(7);131.420 - }131.421 - break;131.422 + if( generate_decoder( rules, actions, out_file ) != 0 ) {131.423 + exit(7);131.424 + }131.425 + break;131.426 case GEN_TEMPLATE:131.427 - if( generate_template( rules, actions, out_file ) != 0 ) {131.428 - exit(7);131.429 - }131.430 - break;131.431 + if( generate_template( rules, actions, out_file ) != 0 ) {131.432 + exit(7);131.433 + }131.434 + break;131.435 }131.436 fclose( out_file );131.437 return 0;
132.1 --- a/src/tools/gendec.h Mon Jul 14 07:42:45 2008 +0000132.2 +++ b/src/tools/gendec.h Mon Jul 14 07:44:42 2008 +0000132.3 @@ -17,8 +17,8 @@132.4 * GNU General Public License for more details.132.5 */132.7 -#ifndef gendec_H132.8 -#define gendec_H132.9 +#ifndef lxdream_gendec_H132.10 +#define lxdream_gendec_H 1132.12 #include <stdint.h>132.14 @@ -82,4 +82,5 @@132.15 #ifdef __cplusplus132.16 }132.17 #endif132.18 -#endif132.19 +132.20 +#endif /* !lxdream_gendec_H */
133.1 --- a/src/tools/genglsl.c Mon Jul 14 07:42:45 2008 +0000133.2 +++ b/src/tools/genglsl.c Mon Jul 14 07:44:42 2008 +0000133.3 @@ -28,38 +28,38 @@133.4 int ch;133.6 while( (ch = fgetc(in)) != EOF ) {133.7 - if( ch == '\"' ) {133.8 - fputc( '\\', out );133.9 - } else if( ch == '\n') {133.10 - fputs( "\\n\\", out );133.11 - }133.12 - fputc( ch, out );133.13 + if( ch == '\"' ) {133.14 + fputc( '\\', out );133.15 + } else if( ch == '\n') {133.16 + fputs( "\\n\\", out );133.17 + }133.18 + fputc( ch, out );133.19 }133.20 }133.22 int main( int argc, char *argv[] )133.23 {133.24 if( argc != 4 ) {133.25 - fprintf( stderr, "Usage: genglsl <vertex-shader-file> <fragment-shader-file> <output-file>\n");133.26 - exit(1);133.27 + fprintf( stderr, "Usage: genglsl <vertex-shader-file> <fragment-shader-file> <output-file>\n");133.28 + exit(1);133.29 }133.31 FILE *vsin = fopen( argv[1], "ro" );133.32 if( vsin == NULL ) {133.33 - perror( "Unable to open vertex shader source" );133.34 - exit(2);133.35 + perror( "Unable to open vertex shader source" );133.36 + exit(2);133.37 }133.39 FILE *fsin = fopen( argv[2], "ro" );133.40 if( fsin == NULL ) {133.41 - perror( "Unable to open fragment shader source" );133.42 - exit(2);133.43 + perror( "Unable to open fragment shader source" );133.44 + exit(2);133.45 }133.47 FILE *out = fopen( argv[3], "wo" );133.48 if( out == NULL ) {133.49 - perror( "Unable to open output file" );133.50 - exit(2);133.51 + perror( "Unable to open output file" );133.52 + exit(2);133.53 }133.55 fprintf( out, "/**\n * This file is automatically generated - do not edit\n */\n\n" );
134.1 --- a/src/tools/insparse.c Mon Jul 14 07:42:45 2008 +0000134.2 +++ b/src/tools/insparse.c Mon Jul 14 07:44:42 2008 +0000134.3 @@ -49,28 +49,28 @@134.4 rules->rule_count = 0;134.5 yyline = 0;134.6 while( fgets( buf, sizeof(buf), f ) != NULL ) {134.7 - yyline++;134.8 - if( strncasecmp(buf, "registers", 9) == 0 ) {134.9 - parse_registers_block(buf, sizeof(buf), f);134.10 - } else if( buf[0] != '\0' && buf[0] != '#' && buf[0] != '\n' ) {134.11 - struct rule *rule;134.12 - char *p = buf;134.13 - rule = new_rule();134.14 - if( parse_rule( &p, rule ) != 0 ) {134.15 - free( rule );134.16 - } else {134.17 - rules->rules[rules->rule_count++] = rule;134.18 - }134.19 - }134.20 + yyline++;134.21 + if( strncasecmp(buf, "registers", 9) == 0 ) {134.22 + parse_registers_block(buf, sizeof(buf), f);134.23 + } else if( buf[0] != '\0' && buf[0] != '#' && buf[0] != '\n' ) {134.24 + struct rule *rule;134.25 + char *p = buf;134.26 + rule = new_rule();134.27 + if( parse_rule( &p, rule ) != 0 ) {134.28 + free( rule );134.29 + } else {134.30 + rules->rules[rules->rule_count++] = rule;134.31 + }134.32 + }134.33 }134.34 return rules;134.35 }134.37 int parse_registers_block( char *buf, int buflen, FILE *f ) {134.38 do {134.39 - if( strchr(buf, '}') != NULL ) {134.40 - break;134.41 - }134.42 + if( strchr(buf, '}') != NULL ) {134.43 + break;134.44 + }134.45 } while( fgets( buf, buflen, f ) != NULL );134.46 return 0;134.47 }134.48 @@ -82,28 +82,28 @@134.49 int parse_rule( char **str, struct rule *rule )134.50 {134.51 if( parse_bitstring( str, rule ) != 0 ) {134.52 - return -1;134.53 + return -1;134.54 }134.56 /* consume whitespace in between */134.57 while( isspace(**str) ) (*str)++;134.58 if( **str == '\0' ) {134.59 - fprintf( stderr, "Unexpected end of file in rule on line %d\n", yyline );134.60 - return -1;134.61 + fprintf( stderr, "Unexpected end of file in rule on line %d\n", yyline );134.62 + return -1;134.63 }134.64 -134.65 +134.66 int result = parse_rule_format( str, rule );134.67 if( result == 0 ) {134.68 - /* Reverse operand bit shifts */134.69 - int j;134.70 - for( j=0; j<rule->operand_count; j++ ) {134.71 - rule->operands[j].bit_shift =134.72 - rule->bit_count - rule->operands[j].bit_shift - rule->operands[j].bit_count;134.73 - }134.74 - if( **str == '!' ) {134.75 - (*str)++;134.76 - result = parse_operand_uses( str, rule );134.77 - }134.78 + /* Reverse operand bit shifts */134.79 + int j;134.80 + for( j=0; j<rule->operand_count; j++ ) {134.81 + rule->operands[j].bit_shift =134.82 + rule->bit_count - rule->operands[j].bit_shift - rule->operands[j].bit_count;134.83 + }134.84 + if( **str == '!' ) {134.85 + (*str)++;134.86 + result = parse_operand_uses( str, rule );134.87 + }134.88 }134.90 return 0;134.91 @@ -112,29 +112,29 @@134.92 int parse_bitstring( char **str, struct rule *rule )134.93 {134.94 while( !isspace(**str) ) {134.95 - int ch = **str;134.96 - (*str)++;134.97 - switch( ch ) {134.98 - case '0':134.99 - rule->bits = rule->bits << 1;134.100 - rule->mask = (rule->mask << 1) | 1;134.101 - rule->bit_count++;134.102 - break;134.103 - case '1':134.104 - rule->bits = (rule->bits << 1) | 1;134.105 - rule->mask = (rule->mask << 1) | 1;134.106 - rule->bit_count++;134.107 - break;134.108 - case '(':134.109 - if( parse_bitoperand( str, rule ) != 0 ) {134.110 - return -1 ;134.111 - }134.112 - break;134.113 - default:134.114 - (*str)--;134.115 - fprintf( stderr, "Unexpected character '%c' in bitstring at line %d\n", ch, yyline );134.116 - return -1;134.117 - }134.118 + int ch = **str;134.119 + (*str)++;134.120 + switch( ch ) {134.121 + case '0':134.122 + rule->bits = rule->bits << 1;134.123 + rule->mask = (rule->mask << 1) | 1;134.124 + rule->bit_count++;134.125 + break;134.126 + case '1':134.127 + rule->bits = (rule->bits << 1) | 1;134.128 + rule->mask = (rule->mask << 1) | 1;134.129 + rule->bit_count++;134.130 + break;134.131 + case '(':134.132 + if( parse_bitoperand( str, rule ) != 0 ) {134.133 + return -1 ;134.134 + }134.135 + break;134.136 + default:134.137 + (*str)--;134.138 + fprintf( stderr, "Unexpected character '%c' in bitstring at line %d\n", ch, yyline );134.139 + return -1;134.140 + }134.141 }134.142 return 0;134.143 }134.144 @@ -144,36 +144,36 @@134.145 char *p = rule->operands[rule->operand_count].name;134.147 if( rule->operand_count == MAX_OPERANDS ) {134.148 - fprintf( stderr, "Maximum operands/rule exceeded (%d) at line %d\n", MAX_OPERANDS, yyline );134.149 - return -1;134.150 + fprintf( stderr, "Maximum operands/rule exceeded (%d) at line %d\n", MAX_OPERANDS, yyline );134.151 + return -1;134.152 }134.154 while( isalnum(**str) || **str == '_' ) {134.155 - *p++ = *(*str)++;134.156 + *p++ = *(*str)++;134.157 }134.158 *p = '\0';134.159 CONSUME_CHAR(':');134.160 -134.161 +134.162 int size = parse_integer( str );134.163 if( size == -1 ) {134.164 - return -1;134.165 + return -1;134.166 }134.167 rule->operands[rule->operand_count].bit_count = size;134.168 if( **str == 's' || **str == 'S' ) {134.169 - (*str)++;134.170 - rule->operands[rule->operand_count].is_signed = 1;134.171 + (*str)++;134.172 + rule->operands[rule->operand_count].is_signed = 1;134.173 } else if( **str == 'u' || **str == 'U' ) {134.174 - (*str)++;134.175 - rule->operands[rule->operand_count].is_signed = 0;134.176 + (*str)++;134.177 + rule->operands[rule->operand_count].is_signed = 0;134.178 }134.179 if( **str == '<' ) {134.180 - (*str)++;134.181 - CONSUME_CHAR('<');134.182 - int lsl = parse_integer(str);134.183 - if( lsl == -1 ) {134.184 - return -1;134.185 - }134.186 - rule->operands[rule->operand_count].left_shift = lsl;134.187 + (*str)++;134.188 + CONSUME_CHAR('<');134.189 + int lsl = parse_integer(str);134.190 + if( lsl == -1 ) {134.191 + return -1;134.192 + }134.193 + rule->operands[rule->operand_count].left_shift = lsl;134.194 }134.195 CONSUME_CHAR(')');134.197 @@ -189,12 +189,12 @@134.198 {134.199 uint32_t val = 0;134.200 if( !isdigit(**str) ) {134.201 - fprintf(stderr, "Expected digit (0-9) but was '%c' at line %d\n", **str, yyline );134.202 - return -1;134.203 + fprintf(stderr, "Expected digit (0-9) but was '%c' at line %d\n", **str, yyline );134.204 + return -1;134.205 }134.206 do {134.207 - val = val * 10 + (**str - '0');134.208 - (*str)++;134.209 + val = val * 10 + (**str - '0');134.210 + (*str)++;134.211 } while( isdigit(**str) );134.212 return val;134.213 }134.214 @@ -205,7 +205,7 @@134.215 char tmp[64];134.216 char *p = tmp;134.217 while( **str != '\n' && **str != '\0' && **str != '!' ) {134.218 - *p++ = *(*str)++;134.219 + *p++ = *(*str)++;134.220 }134.221 *p = '\0';134.222 strcpy( rule->format, tmp );134.223 @@ -223,15 +223,15 @@134.224 int i, j;134.225 fprintf( f, "Rulset: %d rules\n", rules->rule_count );134.226 for( i=0; i<rules->rule_count; i++ ) {134.227 - struct rule *rule = rules->rules[i];134.228 - fprintf( f, "Match: %08X/%08X %s: ", rule->bits, rule->mask, rule->format );134.229 - for( j=0; j<rule->operand_count; j++ ) {134.230 - fprintf( f, "%s = (%s)(ir>>%d)&0x%X ", rule->operands[j].name,134.231 - rule->operands[j].is_signed ? "signed" : "unsigned",134.232 - rule->operands[j].bit_shift,134.233 - (1<<rule->operands[j].bit_count)-1 );134.234 - }134.235 - fprintf( f, "\n" );134.236 + struct rule *rule = rules->rules[i];134.237 + fprintf( f, "Match: %08X/%08X %s: ", rule->bits, rule->mask, rule->format );134.238 + for( j=0; j<rule->operand_count; j++ ) {134.239 + fprintf( f, "%s = (%s)(ir>>%d)&0x%X ", rule->operands[j].name,134.240 + rule->operands[j].is_signed ? "signed" : "unsigned",134.241 + rule->operands[j].bit_shift,134.242 + (1<<rule->operands[j].bit_count)-1 );134.243 + }134.244 + fprintf( f, "\n" );134.245 }134.246 }134.248 @@ -239,14 +239,14 @@134.249 {134.250 int i,j;134.251 for( i=0; i<rule_count; i++ ) {134.252 - struct rule *rule = rules->rules[ruleidx[i]];134.253 - fprintf( f, "Match: %08X/%08X %s: ", rule->bits, rule->mask, rule->format );134.254 - for( j=0; j<rule->operand_count; j++ ) {134.255 - fprintf( f, "%s = (%s)(ir>>%d)&0x%X ", rule->operands[j].name,134.256 - rule->operands[j].is_signed ? "signed" : "unsigned",134.257 - rule->operands[j].bit_shift,134.258 - (1<<rule->operands[j].bit_count)-1 );134.259 - }134.260 - fprintf( f, "\n" );134.261 + struct rule *rule = rules->rules[ruleidx[i]];134.262 + fprintf( f, "Match: %08X/%08X %s: ", rule->bits, rule->mask, rule->format );134.263 + for( j=0; j<rule->operand_count; j++ ) {134.264 + fprintf( f, "%s = (%s)(ir>>%d)&0x%X ", rule->operands[j].name,134.265 + rule->operands[j].is_signed ? "signed" : "unsigned",134.266 + rule->operands[j].bit_shift,134.267 + (1<<rule->operands[j].bit_count)-1 );134.268 + }134.269 + fprintf( f, "\n" );134.270 }134.271 }
135.1 --- a/src/util.c Mon Jul 14 07:42:45 2008 +0000135.2 +++ b/src/util.c Mon Jul 14 07:44:42 2008 +0000135.3 @@ -63,11 +63,11 @@135.4 {135.5 uint32_t len = 0;135.6 if( s == NULL ) {135.7 - fwrite( &len, sizeof(len), 1, f );135.8 + fwrite( &len, sizeof(len), 1, f );135.9 } else {135.10 - len = strlen(s)+1;135.11 - fwrite( &len, sizeof(len), 1, f );135.12 - fwrite( s, len, 1, f );135.13 + len = strlen(s)+1;135.14 + fwrite( &len, sizeof(len), 1, f );135.15 + fwrite( s, len, 1, f );135.16 }135.17 }135.19 @@ -76,7 +76,7 @@135.20 uint32_t len;135.21 fread( &len, sizeof(len), 1, f );135.22 if( len != 0 ) {135.23 - fread( s, len > maxlen ? maxlen : len, 1, f );135.24 + fread( s, len > maxlen ? maxlen : len, 1, f );135.25 }135.26 return len;135.27 }135.28 @@ -107,10 +107,10 @@135.29 int status = uncompress( p, &size, tmp, csize );135.30 g_free(tmp);135.31 if( status == Z_OK ) {135.32 - return count;135.33 + return count;135.34 } else {135.35 - fprintf( stderr, "Error reading compressed data\n" );135.36 - return 0;135.37 + fprintf( stderr, "Error reading compressed data\n" );135.38 + return 0;135.39 }135.40 }135.42 @@ -118,20 +118,20 @@135.43 {135.44 unsigned int i, j;135.45 for( i =0; i<length; i+=16 ) {135.46 - fprintf( f, "%08X:", i);135.47 - for( j=i; j<i+16; j++ ) {135.48 - if( (j % 4) == 0 )135.49 - fprintf( f, " " );135.50 - if( j < length )135.51 - fprintf( f, " %02X", (unsigned int)(data[j]) );135.52 - else135.53 - fprintf( f, " " );135.54 - }135.55 - fprintf( f, " " );135.56 - for( j=i; j<i+16 && j<length; j++ ) {135.57 - fprintf( f, "%c", isprint(data[j]) ? data[j] : '.' );135.58 - }135.59 - fprintf( f, "\n" );135.60 + fprintf( f, "%08X:", i);135.61 + for( j=i; j<i+16; j++ ) {135.62 + if( (j % 4) == 0 )135.63 + fprintf( f, " " );135.64 + if( j < length )135.65 + fprintf( f, " %02X", (unsigned int)(data[j]) );135.66 + else135.67 + fprintf( f, " " );135.68 + }135.69 + fprintf( f, " " );135.70 + for( j=i; j<i+16 && j<length; j++ ) {135.71 + fprintf( f, "%c", isprint(data[j]) ? data[j] : '.' );135.72 + }135.73 + fprintf( f, "\n" );135.74 }135.75 }135.77 @@ -144,14 +144,14 @@135.78 {135.79 unsigned int i, j;135.80 for( i =0; i<length>>2; i+=wordsPerLine ) {135.81 - fprintf( f, "%08X:", i);135.82 - for( j=i; j<i+wordsPerLine; j++ ) {135.83 - if( j < length )135.84 - fprintf( f, " %08X", (unsigned int)(data[j]) );135.85 - else135.86 - fprintf( f, " " );135.87 - }135.88 - fprintf( f, "\n" );135.89 + fprintf( f, "%08X:", i);135.90 + for( j=i; j<i+wordsPerLine; j++ ) {135.91 + if( j < length )135.92 + fprintf( f, " %08X", (unsigned int)(data[j]) );135.93 + else135.94 + fprintf( f, " " );135.95 + }135.96 + fprintf( f, "\n" );135.97 }135.98 }135.100 @@ -161,54 +161,54 @@135.101 png_bytep p;135.102 png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);135.103 if (!png_ptr) {135.104 - return FALSE;135.105 + return FALSE;135.106 }135.108 png_infop info_ptr = png_create_info_struct(png_ptr);135.109 if (!info_ptr) {135.110 - png_destroy_write_struct(&png_ptr, NULL);135.111 - return FALSE;135.112 + png_destroy_write_struct(&png_ptr, NULL);135.113 + return FALSE;135.114 }135.115 -135.116 +135.117 if( setjmp(png_jmpbuf(png_ptr)) ) {135.118 - png_destroy_write_struct(&png_ptr, &info_ptr);135.119 - return FALSE;135.120 + png_destroy_write_struct(&png_ptr, &info_ptr);135.121 + return FALSE;135.122 }135.123 png_init_io( png_ptr, f );135.124 switch( buffer->colour_format ) {135.125 case COLFMT_BGR888:135.126 - coltype = PNG_COLOR_TYPE_RGB;135.127 - break;135.128 + coltype = PNG_COLOR_TYPE_RGB;135.129 + break;135.130 case COLFMT_BGRA8888:135.131 - coltype = PNG_COLOR_TYPE_RGB_ALPHA;135.132 - break;135.133 + coltype = PNG_COLOR_TYPE_RGB_ALPHA;135.134 + break;135.135 case COLFMT_BGR0888:135.136 - coltype = PNG_COLOR_TYPE_RGB;135.137 - break;135.138 + coltype = PNG_COLOR_TYPE_RGB;135.139 + break;135.140 default:135.141 - coltype = PNG_COLOR_TYPE_RGB;135.142 + coltype = PNG_COLOR_TYPE_RGB;135.143 }135.144 png_set_IHDR(png_ptr, info_ptr, buffer->width, buffer->height,135.145 - 8, coltype, PNG_INTERLACE_NONE,135.146 - PNG_COMPRESSION_TYPE_DEFAULT,135.147 - PNG_FILTER_TYPE_DEFAULT );135.148 + 8, coltype, PNG_INTERLACE_NONE,135.149 + PNG_COMPRESSION_TYPE_DEFAULT,135.150 + PNG_FILTER_TYPE_DEFAULT );135.151 png_write_info(png_ptr, info_ptr);135.152 if( buffer->colour_format == COLFMT_BGR0888 ) {135.153 - png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);135.154 + png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);135.155 }135.156 png_set_bgr(png_ptr);135.157 if( buffer->inverted ) {135.158 - p = (png_bytep)(buffer->data + (buffer->height*buffer->rowstride) - buffer->rowstride);135.159 - for(i=0; i<buffer->height; i++ ) {135.160 - png_write_row(png_ptr, p);135.161 - p-=buffer->rowstride;135.162 - }135.163 + p = (png_bytep)(buffer->data + (buffer->height*buffer->rowstride) - buffer->rowstride);135.164 + for(i=0; i<buffer->height; i++ ) {135.165 + png_write_row(png_ptr, p);135.166 + p-=buffer->rowstride;135.167 + }135.168 } else {135.169 - p = (png_bytep)buffer->data;135.170 - for(i=0; i<buffer->height; i++ ) {135.171 - png_write_row(png_ptr, p);135.172 - p+=buffer->rowstride;135.173 - }135.174 + p = (png_bytep)buffer->data;135.175 + for(i=0; i<buffer->height; i++ ) {135.176 + png_write_row(png_ptr, p);135.177 + p+=buffer->rowstride;135.178 + }135.179 }135.180 png_write_end(png_ptr, info_ptr);135.181 png_destroy_write_struct(&png_ptr, &info_ptr);135.182 @@ -220,37 +220,37 @@135.183 png_bytep p;135.184 int i;135.185 png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,135.186 - NULL, NULL, NULL);135.187 + NULL, NULL, NULL);135.188 if (!png_ptr) {135.189 - return NULL;135.190 + return NULL;135.191 }135.193 png_infop info_ptr = png_create_info_struct(png_ptr);135.194 if (!info_ptr) {135.195 - png_destroy_read_struct(&png_ptr, NULL, NULL);135.196 - return NULL;135.197 + png_destroy_read_struct(&png_ptr, NULL, NULL);135.198 + return NULL;135.199 }135.200 -135.201 +135.202 png_infop end_info = png_create_info_struct(png_ptr);135.203 if (!end_info) {135.204 - png_destroy_read_struct(&png_ptr, &info_ptr, NULL );135.205 - return NULL;135.206 + png_destroy_read_struct(&png_ptr, &info_ptr, NULL );135.207 + return NULL;135.208 }135.210 if( setjmp(png_jmpbuf(png_ptr)) ) {135.211 - png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);135.212 - return NULL;135.213 + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);135.214 + return NULL;135.215 }135.217 png_init_io(png_ptr, f);135.218 png_read_info(png_ptr, info_ptr);135.219 -135.220 +135.221 png_uint_32 width, height;135.222 int bit_depth, color_type, interlace_type,135.223 - compression_type, filter_method;135.224 + compression_type, filter_method;135.225 png_get_IHDR(png_ptr, info_ptr, &width, &height,135.226 - &bit_depth, &color_type, &interlace_type,135.227 - &compression_type, &filter_method);135.228 + &bit_depth, &color_type, &interlace_type,135.229 + &compression_type, &filter_method);135.230 assert( interlace_type == PNG_INTERLACE_NONE );135.231 int rowbytes = png_get_rowbytes(png_ptr, info_ptr);135.232 int channels = png_get_channels(png_ptr, info_ptr);135.233 @@ -263,15 +263,15 @@135.234 buffer->size = rowbytes*height;135.235 buffer->inverted = FALSE;135.236 if( channels == 4 ) {135.237 - buffer->colour_format = COLFMT_BGRA8888;135.238 + buffer->colour_format = COLFMT_BGRA8888;135.239 } else if( channels == 3 ) {135.240 - buffer->colour_format = COLFMT_RGB888;135.241 + buffer->colour_format = COLFMT_RGB888;135.242 }135.243 -135.244 +135.245 p = (png_bytep)buffer->data;135.246 for( i=0; i<height; i++ ) {135.247 - png_read_row(png_ptr, p, NULL );135.248 - p += rowbytes;135.249 + png_read_row(png_ptr, p, NULL );135.250 + p += rowbytes;135.251 }135.253 png_read_end(png_ptr, end_info);135.254 @@ -296,10 +296,10 @@135.255 {135.256 int l = get_log_level_from_string(str);135.257 if( l == -1 ) {135.258 - return FALSE;135.259 + return FALSE;135.260 } else {135.261 - global_msg_level = l;135.262 - return TRUE;135.263 + global_msg_level = l;135.264 + return TRUE;135.265 }135.266 }135.268 @@ -310,18 +310,18 @@135.269 va_list ap;135.271 if( level > global_msg_level ) {135.272 - return; // ignored135.273 + return; // ignored135.274 }135.276 va_start(ap, msg);135.277 gchar *text = g_strdup_vprintf( msg, ap );135.278 va_end(ap);135.279 -135.280 +135.281 if( level <= EMIT_ERR ) {135.282 - if( gui_error_dialog( text ) ) {135.283 - g_free(text);135.284 - return;135.285 - }135.286 + if( gui_error_dialog( text ) ) {135.287 + g_free(text);135.288 + return;135.289 + }135.290 }
136.1 --- a/src/watch.c Mon Jul 14 07:42:45 2008 +0000136.2 +++ b/src/watch.c Mon Jul 14 07:44:42 2008 +0000136.3 @@ -80,8 +80,8 @@136.4 continue;136.5 count++;136.6 if( watch_arr[i].flags & op &&136.7 - watch_arr[i].start < addr+size &&136.8 - watch_arr[i].end >= addr ) {136.9 + watch_arr[i].start < addr+size &&136.10 + watch_arr[i].end >= addr ) {136.11 return &watch_arr[i];136.12 }136.13 }
.