Search
lxdream.org :: lxdream :: r736:a02d1475ccfd
lxdream 0.9.1
released Jun 29
Download Now
changeset736:a02d1475ccfd
parent735:c3aac20f118e
child737:7477adafe909
authornkeynes
dateMon Jul 14 07:44:42 2008 +0000 (11 years ago)
Re-indent everything consistently
Fix include guards for consistency as well
src/aica/aica.c
src/aica/armcore.c
src/aica/armcore.h
src/aica/armdasm.c
src/aica/armdasm.h
src/aica/armmem.c
src/aica/audio.c
src/aica/audio.h
src/asic.c
src/bios.c
src/bootstrap.c
src/bootstrap.h
src/clock.h
src/cocoaui/cocoa_gd.c
src/cocoaui/cocoa_prefs.c
src/cocoaui/cocoa_win.c
src/cocoaui/cocoaui.c
src/cocoaui/cocoaui.h
src/config.c
src/config.h
src/cpu.h
src/dcload.c
src/display.c
src/display.h
src/dream.h
src/dreamcast.c
src/dreamcast.h
src/drivers/audio_alsa.c
src/drivers/audio_esd.c
src/drivers/audio_null.c
src/drivers/audio_osx.c
src/drivers/audio_pulse.c
src/drivers/cd_linux.c
src/drivers/cd_none.c
src/drivers/cd_osx.c
src/drivers/gl_fbo.c
src/drivers/joy_linux.c
src/drivers/joy_linux.h
src/drivers/osx_iokit.c
src/drivers/osx_iokit.h
src/drivers/video_gdk.c
src/drivers/video_gl.c
src/drivers/video_gl.h
src/drivers/video_glx.c
src/drivers/video_glx.h
src/drivers/video_gtk.c
src/drivers/video_nsgl.c
src/drivers/video_nsgl.h
src/drivers/video_null.c
src/drivers/video_osx.c
src/eventq.c
src/eventq.h
src/gdlist.c
src/gdlist.h
src/gdrom/cdi.c
src/gdrom/gddriver.h
src/gdrom/gdi.c
src/gdrom/gdimage.c
src/gdrom/gdrom.c
src/gdrom/gdrom.h
src/gdrom/ide.c
src/gdrom/ide.h
src/gdrom/nrg.c
src/gdrom/packet.h
src/gtkui/ctrl_dlg.c
src/gtkui/debug_win.c
src/gtkui/dump_win.c
src/gtkui/gdrom_menu.c
src/gtkui/gtkcb.c
src/gtkui/gtkui.c
src/gtkui/gtkui.h
src/gtkui/main_win.c
src/gtkui/mmio_win.c
src/gtkui/path_dlg.c
src/gui.h
src/loader.c
src/loader.h
src/lxdream.h
src/main.c
src/maple/controller.c
src/maple/controller.h
src/maple/kbd.c
src/maple/maple.c
src/maple/maple.h
src/maple/mouse.c
src/mem.c
src/mem.h
src/pvr2/gl_sl.c
src/pvr2/glrender.c
src/pvr2/glutil.c
src/pvr2/glutil.h
src/pvr2/pvr2.c
src/pvr2/pvr2.h
src/pvr2/pvr2mem.c
src/pvr2/rendsave.c
src/pvr2/rendsort.c
src/pvr2/scene.c
src/pvr2/scene.h
src/pvr2/tacore.c
src/pvr2/texcache.c
src/pvr2/yuv.c
src/serial.h
src/sh4/dmac.c
src/sh4/dmac.h
src/sh4/ia32abi.h
src/sh4/ia32mac.h
src/sh4/ia64abi.h
src/sh4/intc.c
src/sh4/intc.h
src/sh4/mmu.c
src/sh4/scif.c
src/sh4/sh4.c
src/sh4/sh4.h
src/sh4/sh4core.c
src/sh4/sh4core.h
src/sh4/sh4core.in
src/sh4/sh4dasm.h
src/sh4/sh4mem.c
src/sh4/sh4mmio.c
src/sh4/sh4mmio.h
src/sh4/sh4stat.h
src/sh4/sh4trans.c
src/sh4/sh4trans.h
src/sh4/timer.c
src/sh4/x86op.h
src/sh4/xltcache.c
src/sh4/xltcache.h
src/syscall.c
src/syscall.h
src/tools/actparse.c
src/tools/gendec.c
src/tools/gendec.h
src/tools/genglsl.c
src/tools/insparse.c
src/util.c
src/watch.c
1.1 --- a/src/aica/aica.c Mon Jul 14 07:42:45 2008 +0000
1.2 +++ b/src/aica/aica.c Mon Jul 14 07:44:42 2008 +0000
1.3 @@ -41,8 +41,8 @@
1.4 uint32_t aica_run_slice( uint32_t );
1.5
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.11
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.21
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.33
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.63
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.72
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.103
1.104 @@ -218,24 +218,24 @@
1.105
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.144
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.179
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 a
1.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.267
1.268 @@ -343,22 +343,22 @@
1.269 * Derived directly from Dan Potter's log table
1.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.304
1.305
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 - else
1.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 have
1.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 + else
1.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 have
1.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.416
1.417 }
2.1 --- a/src/aica/armcore.c Mon Jul 14 07:42:45 2008 +0000
2.2 +++ b/src/aica/armcore.c Mon Jul 14 07:44:42 2008 +0000
2.3 @@ -30,12 +30,12 @@
2.4 void arm_set_mode( int mode );
2.5
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.19
2.20 #define EXC_RESET 0
2.21 #define EXC_UNDEFINED 1
2.22 @@ -65,15 +65,15 @@
2.23 int i;
2.24
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.60
2.61 if( !armr.running )
2.62 - return num_samples;
2.63 + return num_samples;
2.64
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_MODE
2.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 #endif
2.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.117
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.154
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 writing
2.160 - * back to CPSR
2.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 writing
2.167 + * back to CPSR
2.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.175
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.186
2.187 - /* Middle 16 bits not currently defined */
2.188 + /* Middle 16 bits not currently defined */
2.189
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.198
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.207
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.214
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.368
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 - else
2.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 + else
2.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.470
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.695
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 - else
2.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 + else
2.746 + operand = ROTATE_RIGHT_LONG(operand,tmp);
2.747 + break;
2.748 + default: UNIMP(ir);
2.749 + }
2.750 + return operand;
2.751 }
2.752
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.867
2.868 gboolean arm_execute_instruction( void )
2.869 @@ -696,11 +696,11 @@
2.870
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.884
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.972
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 though
2.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 though
2.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.1211
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.2190
2.2191 }
2.2192
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 +0000
3.2 +++ b/src/aica/armcore.h Mon Jul 14 07:44:42 2008 +0000
3.3 @@ -16,14 +16,18 @@
3.4 * GNU General Public License for more details.
3.5 */
3.6
3.7 -#ifndef dream_armcore_H
3.8 -#define dream_armcore_H 1
3.9 +#ifndef lxdream_armcore_H
3.10 +#define lxdream_armcore_H 1
3.11
3.12 #include "lxdream.h"
3.13 #include "mem.h"
3.14 #include <stdint.h>
3.15 #include <stdio.h>
3.16
3.17 +#ifdef __cplusplus
3.18 +extern "C" {
3.19 +#endif
3.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 __cplusplus
3.31 +}
3.32 +#endif
3.33 +
3.34 +#endif /* !lxdream_armcore_H */
4.1 --- a/src/aica/armdasm.c Mon Jul 14 07:42:45 2008 +0000
4.2 +++ b/src/aica/armdasm.c Mon Jul 14 07:44:42 2008 +0000
4.3 @@ -48,142 +48,142 @@
4.4
4.5
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.27
4.28
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.47
4.48
4.49
4.50
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.62
4.63 #define UNIMP(ir) snprintf( buf, len, "??? " )
4.64
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 - else
4.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 + else
4.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.140
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 - else
4.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 + else
4.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.190
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.194
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.254
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.265
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.273
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.402
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.475
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 }
4.881
4.882
5.1 --- a/src/aica/armdasm.h Mon Jul 14 07:42:45 2008 +0000
5.2 +++ b/src/aica/armdasm.h Mon Jul 14 07:44:42 2008 +0000
5.3 @@ -16,8 +16,8 @@
5.4 * GNU General Public License for more details.
5.5 */
5.6
5.7 -#ifndef armdasm_H
5.8 -#define armdasm_H 1
5.9 +#ifndef lxdream_armdasm_H
5.10 +#define lxdream_armdasm_H 1
5.11
5.12 #include "cpu.h"
5.13
5.14 @@ -36,4 +36,4 @@
5.15 }
5.16 #endif
5.17
5.18 -#endif
5.19 +#endif /* !lxdream_armdasm_H */
6.1 --- a/src/aica/armmem.c Mon Jul 14 07:42:45 2008 +0000
6.2 +++ b/src/aica/armmem.c Mon Jul 14 07:44:42 2008 +0000
6.3 @@ -31,35 +31,35 @@
6.4
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.10
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 happy
6.134 + return val; // Can't happen, but make gcc happy
6.135 }
6.136 }
6.137
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 +0000
7.2 +++ b/src/aica/audio.c Mon Jul 14 07:44:42 2008 +0000
7.3 @@ -33,19 +33,19 @@
7.4
7.5 audio_driver_t audio_driver_list[] = {
7.6 #ifdef HAVE_CORE_AUDIO
7.7 - &audio_osx_driver,
7.8 + &audio_osx_driver,
7.9 #endif
7.10 #ifdef HAVE_PULSE
7.11 - &audio_pulse_driver,
7.12 + &audio_pulse_driver,
7.13 #endif
7.14 #ifdef HAVE_ESOUND
7.15 - &audio_esd_driver,
7.16 + &audio_esd_driver,
7.17 #endif
7.18 #ifdef HAVE_ALSA
7.19 - &audio_alsa_driver,
7.20 + &audio_alsa_driver,
7.21 #endif
7.22 - &audio_null_driver,
7.23 - NULL };
7.24 + &audio_null_driver,
7.25 + NULL };
7.26
7.27 #define NUM_BUFFERS 3
7.28 #define MS_PER_BUFFER 100
7.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.37
7.38 @@ -239,23 +239,23 @@
7.39 */
7.40
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.48
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, 614
7.52 + 230, 230, 230, 230, 307, 409, 512, 614,
7.53 + 230, 230, 230, 230, 307, 409, 512, 614
7.54 };
7.55
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, -15
7.59 + 1, 3, 5, 7, 9, 11, 13, 15,
7.60 + -1, -3, -5, -7, -9, -11, -13, -15
7.61 };
7.62
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.102
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 +0000
8.2 +++ b/src/aica/audio.h Mon Jul 14 07:44:42 2008 +0000
8.3 @@ -15,15 +15,14 @@
8.4 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.5 * GNU General Public License for more details.
8.6 */
8.7 -#ifndef dream_audio_H
8.8 -#define dream_audio_H 1
8.9 +#ifndef lxdream_audio_H
8.10 +#define lxdream_audio_H 1
8.11
8.12 #include <stdint.h>
8.13 #include <stdio.h>
8.14 #include <glib/gtypes.h>
8.15 #include <glib/gi18n.h>
8.16
8.17 -
8.18 #ifdef __cplusplus
8.19 extern "C" {
8.20 #endif
8.21 @@ -135,4 +134,5 @@
8.22 #ifdef __cplusplus
8.23 }
8.24 #endif
8.25 -#endif
8.26 \ No newline at end of file
8.27 +
8.28 +#endif /* !lxdream_audio_H */
9.1 --- a/src/asic.c Mon Jul 14 07:42:45 2008 +0000
9.2 +++ b/src/asic.c Mon Jul 14 07:44:42 2008 +0000
9.3 @@ -52,7 +52,7 @@
9.4 static uint32_t g2_update_fifo_status( uint32_t slice_cycle );
9.5
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.9
9.10 #define G2_BIT5_TICKS 60
9.11 #define G2_BIT4_TICKS 160
9.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.22
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.57
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 else
9.65 - return 0;
9.66 + return 0;
9.67 }
9.68
9.69
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.80
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.85
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.93
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.98
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.106
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.129
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.142
9.143 MMIO_WRITE( ASIC, G2STATUS, val );
9.144 @@ -221,9 +221,9 @@
9.145 intc_raise_interrupt( INT_IRQ9 );
9.146
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.155
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.177
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.201
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 else
9.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 else
9.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 else
9.232 - intc_raise_interrupt( INT_IRQ9 );
9.233 + intc_raise_interrupt( INT_IRQ9 );
9.234 }
9.235
9.236 void g2_dma_transfer( int channel )
9.237 @@ -290,44 +290,44 @@
9.238 uint32_t offset = channel << 5;
9.239
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.281
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.313
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.341
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.454
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.475
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.482
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 not
9.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 not
9.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.626
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.673
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.681
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 }
9.706
10.1 --- a/src/bios.c Mon Jul 14 07:42:45 2008 +0000
10.2 +++ b/src/bios.c Mon Jul 14 07:44:42 2008 +0000
10.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.22
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.54
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.64
10.65 @@ -128,78 +128,78 @@
10.66
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 - else
10.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 + else
10.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 }
10.212
11.1 --- a/src/bootstrap.c Mon Jul 14 07:42:45 2008 +0000
11.2 +++ b/src/bootstrap.c Mon Jul 14 07:44:42 2008 +0000
11.3 @@ -58,20 +58,20 @@
11.4
11.5
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.35
11.36
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 +0000
12.2 +++ b/src/bootstrap.h Mon Jul 14 07:44:42 2008 +0000
12.3 @@ -19,15 +19,15 @@
12.4 /*
12.5 * IP.BIN related code. Ref: http://mc.pp.se/dc/ip0000.bin.html
12.6 */
12.7 -#ifndef dream_bootstrap_H
12.8 -#define dream_bootstrap_H 1
12.9 +#ifndef lxdream_bootstrap_H
12.10 +#define lxdream_bootstrap_H 1
12.11 +
12.12 +#include "lxdream.h"
12.13
12.14 #ifdef __cplusplus
12.15 extern "C" {
12.16 #endif
12.17
12.18 -#include "dream.h"
12.19 -
12.20 /**
12.21 * Dump the bootstrap info to the output log for infomational/debugging
12.22 * purposes.
12.23 @@ -37,4 +37,5 @@
12.24 #ifdef __cplusplus
12.25 }
12.26 #endif
12.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 +0000
13.2 +++ b/src/clock.h Mon Jul 14 07:44:42 2008 +0000
13.3 @@ -1,5 +1,6 @@
13.4 /**
13.5 * $Id$
13.6 + *
13.7 * External interface to the dreamcast serial port, implemented by
13.8 * sh4/scif.c
13.9 *
13.10 @@ -15,8 +16,9 @@
13.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13.12 * GNU General Public License for more details.
13.13 */
13.14 -#ifndef dream_clock_H
13.15 -#define dream_clock_H 1
13.16 +
13.17 +#ifndef lxdream_clock_H
13.18 +#define lxdream_clock_H 1
13.19
13.20 #include <stdint.h>
13.21
14.1 --- a/src/cocoaui/cocoa_gd.c Mon Jul 14 07:42:45 2008 +0000
14.2 +++ b/src/cocoaui/cocoa_gd.c Mon Jul 14 07:44:42 2008 +0000
14.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.29
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 +0000
15.2 +++ b/src/cocoaui/cocoa_prefs.c Mon Jul 14 07:44:42 2008 +0000
15.3 @@ -26,7 +26,8 @@
15.4 NSDictionary *items;
15.5 }
15.6 - (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label
15.7 - tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action;
15.8 + tooltip: (NSString *)tooltip icon: (NSString *)icon
15.9 + action: (SEL) action;
15.10 @end
15.11
15.12 @implementation LxdreamPrefsToolbarDelegate
15.13 @@ -46,7 +47,7 @@
15.14 }
15.15
15.16 - (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label
15.17 - tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action
15.18 +tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action
15.19 {
15.20 NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier: id];
15.21 [item setLabel: label];
15.22 @@ -75,9 +76,9 @@
15.23 }
15.24
15.25 - (NSToolbarItem *) toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier
15.26 - willBeInsertedIntoToolbar:(BOOL)flag
15.27 +willBeInsertedIntoToolbar:(BOOL)flag
15.28 {
15.29 - return [items objectForKey: itemIdentifier];
15.30 + return [items objectForKey: itemIdentifier];
15.31 }
15.32 - (void)paths_action: (id)sender
15.33 {
15.34 @@ -102,10 +103,10 @@
15.35 - (id)initWithContentRect:(NSRect)contentRect
15.36 {
15.37 if( [super initWithContentRect: contentRect
15.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 +0000
16.2 +++ b/src/cocoaui/cocoa_win.c Mon Jul 14 07:44:42 2008 +0000
16.3 @@ -29,7 +29,8 @@
16.4 NSDictionary *items;
16.5 }
16.6 - (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label
16.7 - tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action;
16.8 + tooltip: (NSString *)tooltip
16.9 + icon: (NSString *)icon action: (SEL) action;
16.10 @end
16.11
16.12 @implementation LxdreamToolbarDelegate
16.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.42
16.43 - (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label
16.44 - tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action
16.45 +tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action
16.46 {
16.47 NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier: id];
16.48 [item setLabel: label];
16.49 @@ -94,9 +95,9 @@
16.50 }
16.51
16.52 - (NSToolbarItem *) toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier
16.53 - willBeInsertedIntoToolbar:(BOOL)flag
16.54 +willBeInsertedIntoToolbar:(BOOL)flag
16.55 {
16.56 - return [items objectForKey: itemIdentifier];
16.57 + return [items objectForKey: itemIdentifier];
16.58 }
16.59 @end
16.60
16.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: contentRect
16.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.84
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 +0000
17.2 +++ b/src/cocoaui/cocoaui.c Mon Jul 14 07:44:42 2008 +0000
17.3 @@ -36,11 +36,11 @@
17.4 uint32_t cocoa_gui_run_slice( uint32_t nanosecs );
17.5
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.17
17.18 /**
17.19 * Count of running nanoseconds - used to cut back on the GUI runtime
17.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.28
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 Menu
17.41 [appleMenu addItem:[NSMenuItem separatorItem]];
17.42 services = [[[NSMenu alloc] init] autorelease];
17.43 @@ -84,8 +84,8 @@
17.44
17.45 // Hide Others
17.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.52
17.53 // Show All
17.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 like
17.84 - * -psn_0_... - we want to remove this so that lxdream doesn't try to process it
17.85 - * normally
17.86 - */
17.87 + * -psn_0_... - we want to remove this so that lxdream doesn't try to process it
17.88 + * normally
17.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.114
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.124
17.125 void gui_update_state(void)
17.126 @@ -352,7 +352,7 @@
17.127
17.128 void cocoa_gui_update( void )
17.129 {
17.130 -
17.131 +
17.132 }
17.133
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: 1
17.140 - modes: [NSArray arrayWithObject: NSDefaultRunLoopMode] ];
17.141 + target: [NSApp delegate] argument: nil order: 1
17.142 + modes: [NSArray arrayWithObject: NSDefaultRunLoopMode] ];
17.143 }
17.144
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->data
17.149 pixelsWide: buffer->width pixelsHigh: buffer->height
17.150 - bitsPerSample: 8 samplesPerPixel: 3
17.151 - hasAlpha: NO isPlanar: NO
17.152 - colorSpaceName: NSDeviceRGBColorSpace bitmapFormat: 0
17.153 - bytesPerRow: buffer->rowstride bitsPerPixel: 24];
17.154 -
17.155 + bitsPerSample: 8 samplesPerPixel: 3
17.156 + hasAlpha: NO isPlanar: NO
17.157 + colorSpaceName: NSDeviceRGBColorSpace bitmapFormat: 0
17.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 +0000
18.2 +++ b/src/cocoaui/cocoaui.h Mon Jul 14 07:44:42 2008 +0000
18.3 @@ -16,12 +16,16 @@
18.4 * GNU General Public License for more details.
18.5 */
18.6
18.7 +#ifndef lxdream_cocoaui_H
18.8 +#define lxdream_cocoaui_H
18.9 +
18.10 #import <AppKit/AppKit.h>
18.11 #include <glib/gi18n.h>
18.12
18.13 -#ifndef lxdream_cocoaui_H
18.14 -#define lxdream_cocoaui_H
18.15 -
18.16 +#ifdef __cplusplus
18.17 +extern "C" {
18.18 +#endif
18.19 +
18.20 #define NS_(x) [NSString stringWithUTF8String: _(x)]
18.21
18.22 NSWindow *cocoa_gui_create_main_window();
18.23 @@ -47,4 +51,8 @@
18.24 - (id)initWithContentRect:(NSRect)contentRect;
18.25 @end
18.26
18.27 +#ifdef __cplusplus
18.28 +}
18.29 +#endif
18.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 +0000
19.2 +++ b/src/config.c Mon Jul 14 07:44:42 2008 +0000
19.3 @@ -36,27 +36,27 @@
19.4 gboolean lxdream_save_config_stream( FILE *f );
19.5
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.23
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.29
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_ALSA
19.38 - { "alsa", alsa_config },
19.39 + { "alsa", alsa_config },
19.40 #endif
19.41 - { NULL, CONFIG_TYPE_NONE }};
19.42 + { NULL, CONFIG_TYPE_NONE }};
19.43
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.136
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.160
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.180
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.189
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.199
19.200 result = lxdream_load_config_stream( f );
19.201 @@ -210,77 +210,77 @@
19.202 lxdream_set_default_config();
19.203
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 - else
19.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 + else
19.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 +0000
20.2 +++ b/src/config.h Mon Jul 14 07:44:42 2008 +0000
20.3 @@ -22,6 +22,10 @@
20.4 #include <glib/gtypes.h>
20.5 #include <glib/gi18n.h>
20.6
20.7 +#ifdef __cplusplus
20.8 +extern "C" {
20.9 +#endif
20.10 +
20.11 #define CONFIG_TYPE_NONE 0
20.12 #define CONFIG_TYPE_FILE 1
20.13 #define CONFIG_TYPE_PATH 2
20.14 @@ -88,5 +92,8 @@
20.15 */
20.16 gboolean lxdream_save_config( );
20.17
20.18 +#ifdef __cplusplus
20.19 +}
20.20 +#endif
20.21
20.22 #endif /* !lxdream_config_H */
21.1 --- a/src/cpu.h Mon Jul 14 07:42:45 2008 +0000
21.2 +++ b/src/cpu.h Mon Jul 14 07:44:42 2008 +0000
21.3 @@ -16,8 +16,8 @@
21.4 * GNU General Public License for more details.
21.5 */
21.6
21.7 -#ifndef dream_cpu_H
21.8 -#define dream_cpu_H 1
21.9 +#ifndef lxdream_cpu_H
21.10 +#define lxdream_cpu_H 1
21.11
21.12 #include "lxdream.h"
21.13 #include "mem.h"
21.14 @@ -71,4 +71,4 @@
21.15 }
21.16 #endif
21.17
21.18 -#endif /* !dream_cpu_H */
21.19 +#endif /* !lxdream_cpu_H */
22.1 --- a/src/dcload.c Mon Jul 14 07:42:45 2008 +0000
22.2 +++ b/src/dcload.c Mon Jul 14 07:44:42 2008 +0000
22.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.72
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.154
22.155 }
23.1 --- a/src/display.c Mon Jul 14 07:42:45 2008 +0000
23.2 +++ b/src/display.c Mon Jul 14 07:44:42 2008 +0000
23.3 @@ -26,14 +26,14 @@
23.4
23.5 display_driver_t display_driver_list[] = {
23.6 #ifdef HAVE_GTK
23.7 - &display_gtk_driver,
23.8 + &display_gtk_driver,
23.9 #else
23.10 #ifdef HAVE_COCOA
23.11 - &display_osx_driver,
23.12 + &display_osx_driver,
23.13 #endif
23.14 #endif
23.15 - &display_null_driver,
23.16 - NULL };
23.17 + &display_null_driver,
23.18 + NULL };
23.19
23.20 /* Some explanation:
23.21 * The system has at least one "root" device representing the main display
23.22 @@ -76,17 +76,17 @@
23.23 * Colour format information
23.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.49
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.64
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.105
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 handling
23.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 handling
23.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 found
23.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 found
23.180 }
23.181 }
23.182
23.183 @@ -198,22 +198,22 @@
23.184 GList *ptr;
23.185
23.186 if( keycode == 0 ) {
23.187 - return NULL;
23.188 + return NULL;
23.189 }
23.190
23.191 if( driver == NULL ) {
23.192 - return &root_keymap[keycode-1];
23.193 + return &root_keymap[keycode-1];
23.194 }
23.195
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.246
23.247
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.282
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.291
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.312
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.321
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.357
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.397
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.408
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.445
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.457
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.470
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.479
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.495
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.503
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 +0000
24.2 +++ b/src/display.h Mon Jul 14 07:44:42 2008 +0000
24.3 @@ -17,8 +17,8 @@
24.4 * GNU General Public License for more details.
24.5 */
24.6
24.7 -#ifndef dream_video_H
24.8 -#define dream_video_H
24.9 +#ifndef lxdream_display_H
24.10 +#define lxdream_display_H 1
24.11
24.12 #define GL_GLEXT_PROTOTYPES 1
24.13
24.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.20
24.21 } *display_driver_t;
24.22
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.25
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.29
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.33
24.34 /**
24.35 * Register a hook to receive all input events
24.36 @@ -328,4 +328,4 @@
24.37 #ifdef __cplusplus
24.38 }
24.39 #endif
24.40 -#endif
24.41 +#endif /* !lxdream_display_H */
25.1 --- a/src/dream.h Mon Jul 14 07:42:45 2008 +0000
25.2 +++ b/src/dream.h Mon Jul 14 07:44:42 2008 +0000
25.3 @@ -16,8 +16,8 @@
25.4 * GNU General Public License for more details.
25.5 */
25.6
25.7 -#ifndef dream_H
25.8 -#define dream_H 1
25.9 +#ifndef lxdream_dream_H
25.10 +#define lxdream_dream_H 1
25.11
25.12 #include <stdio.h>
25.13 #include <stdlib.h>
25.14 @@ -103,4 +103,4 @@
25.15 #ifdef __cplusplus
25.16 }
25.17 #endif
25.18 -#endif
25.19 +#endif /* !lxdream_dream_H */
26.1 --- a/src/dreamcast.c Mon Jul 14 07:42:45 2008 +0000
26.2 +++ b/src/dreamcast.c Mon Jul 14 07:44:42 2008 +0000
26.3 @@ -35,8 +35,8 @@
26.4 * Current state of the DC virtual machine
26.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 * declaration
26.16 */
26.17 struct dreamcast_module unknown_module = { "****", NULL, NULL, NULL, NULL,
26.18 - NULL, NULL, NULL };
26.19 + NULL, NULL, NULL };
26.20
26.21 /**
26.22 * This function is responsible for defining how all the pieces of the
26.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.35
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.50
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.59
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.75
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.129
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.138
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.199
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.232
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.240
26.241 for( i=0; i<MAX_MODULES; i++ ) {
26.242 - have_read[i] = 0;
26.243 + have_read[i] = 0;
26.244 }
26.245
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 actually
26.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.335
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 +0000
27.2 +++ b/src/dreamcast.h Mon Jul 14 07:44:42 2008 +0000
27.3 @@ -19,8 +19,8 @@
27.4 * GNU General Public License for more details.
27.5 */
27.6
27.7 -#ifndef dreamcast_H
27.8 -#define dreamcast_H 1
27.9 +#ifndef lxdream_dreamcast_H
27.10 +#define lxdream_dreamcast_H 1
27.11
27.12 #include <stdio.h>
27.13 #include "lxdream.h"
27.14 @@ -82,4 +82,4 @@
27.15 }
27.16 #endif
27.17
27.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 +0000
28.2 +++ b/src/drivers/audio_alsa.c Mon Jul 14 07:44:42 2008 +0000
28.3 @@ -32,8 +32,8 @@
28.4
28.5
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.12
28.13
28.14 @@ -51,12 +51,12 @@
28.15
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.20
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.37
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.53
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.80
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.90
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.99
28.100 return TRUE;
28.101 @@ -183,13 +183,13 @@
28.102
28.103
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_shutdown
28.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_shutdown
28.123 };
29.1 --- a/src/drivers/audio_esd.c Mon Jul 14 07:42:45 2008 +0000
29.2 +++ b/src/drivers/audio_esd.c Mon Jul 14 07:44:42 2008 +0000
29.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 +0000
30.2 +++ b/src/drivers/audio_null.c Mon Jul 14 07:44:42 2008 +0000
30.3 @@ -20,7 +20,7 @@
30.4
30.5 gboolean audio_null_init()
30.6 {
30.7 - return TRUE;
30.8 + return TRUE;
30.9 }
30.10
30.11 gboolean audio_null_process_buffer( audio_buffer_t buffer )
30.12 @@ -30,7 +30,7 @@
30.13
30.14 gboolean audio_null_shutdown()
30.15 {
30.16 - return TRUE;
30.17 + return TRUE;
30.18 }
30.19
30.20 struct audio_driver audio_null_driver = {
31.1 --- a/src/drivers/audio_osx.c Mon Jul 14 07:42:45 2008 +0000
31.2 +++ b/src/drivers/audio_osx.c Mon Jul 14 07:44:42 2008 +0000
31.3 @@ -28,12 +28,12 @@
31.4 static uint32_t buffer_size;
31.5
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 +0000
32.2 +++ b/src/drivers/audio_pulse.c Mon Jul 14 07:44:42 2008 +0000
32.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.15
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.40
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.50
32.51 struct audio_driver audio_pulse_driver = {
33.1 --- a/src/drivers/cd_linux.c Mon Jul 14 07:42:45 2008 +0000
33.2 +++ b/src/drivers/cd_linux.c Mon Jul 14 07:44:42 2008 +0000
33.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.13
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.55
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.64
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.71
33.72 return TRUE;
33.73 @@ -113,20 +113,20 @@
33.74
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.82
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.136
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.150
33.151 @@ -196,16 +196,16 @@
33.152 }
33.153
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, &sector_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 +0000
34.2 +++ b/src/drivers/cd_none.c Mon Jul 14 07:44:42 2008 +0000
34.3 @@ -22,7 +22,7 @@
34.4 static gdrom_disc_t cdnone_open_device( const gchar *filename, FILE *f );
34.5
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.9
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 +0000
35.2 +++ b/src/drivers/cd_osx.c Mon Jul 14 07:44:42 2008 +0000
35.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.9
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.13
35.14 #define OSX_DRIVE(disc) ( (osx_cdrom_drive_t)(((gdrom_image_t)disc)->private) )
35.15
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.63
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 +0000
36.2 +++ b/src/drivers/gl_fbo.c Mon Jul 14 07:44:42 2008 +0000
36.3 @@ -58,8 +58,8 @@
36.4
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.12
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.41
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.52
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 attached
36.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 attached
36.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 unbound
36.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.141
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.154
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.190
36.191 @@ -278,7 +278,7 @@
36.192 }
36.193
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 +0000
37.2 +++ b/src/drivers/joy_linux.c Mon Jul 14 07:44:42 2008 +0000
37.3 @@ -51,7 +51,7 @@
37.4 } *linux_joystick_t;
37.5
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.54
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.90
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.150
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.159
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.172
37.173 joy->channel = g_io_channel_unix_new(fd);
37.174 @@ -208,24 +208,24 @@
37.175 DIR *dir = opendir(INPUT_PATH);
37.176
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.213
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 +0000
38.2 +++ b/src/drivers/joy_linux.h Mon Jul 14 07:44:42 2008 +0000
38.3 @@ -19,6 +19,10 @@
38.4 #ifndef lxdream_joy_linux_H
38.5 #define lxdream_joy_linux_H
38.6
38.7 +#ifdef __cplusplus
38.8 +extern "C" {
38.9 +#endif
38.10 +
38.11 /**
38.12 * Initialize the linux joystick code, and scan for devices
38.13 */
38.14 @@ -29,6 +33,8 @@
38.15 */
38.16 void linux_joystick_shutdown();
38.17
38.18 -
38.19 +#ifdef __cplusplus
38.20 +}
38.21 +#endif
38.22
38.23 #endif /* !lxdream_joy_linux_H */
39.1 --- a/src/drivers/osx_iokit.c Mon Jul 14 07:42:45 2008 +0000
39.2 +++ b/src/drivers/osx_iokit.c Mon Jul 14 07:44:42 2008 +0000
39.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 interest
39.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.38
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 ) {