From: Toni Wilen Date: Sat, 16 Jul 2005 15:53:44 +0000 (+0300) Subject: imported winuaesrc1100b2.zip X-Git-Tag: 2100~306 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=96a26a30fe707e369c16cfeb7619dc38916b99f0;p=francis%2Fwinuae.git imported winuaesrc1100b2.zip --- diff --git a/akiko.c b/akiko.c index 00f85fe6..c6b50d83 100755 --- a/akiko.c +++ b/akiko.c @@ -124,7 +124,7 @@ static void i2c_do (void) } return; } - } + } if (bitcounter >= 0) { if (direction) { /* Amiga -> NVRAM */ @@ -543,7 +543,7 @@ static int sys_cddev_open (void) } } else { write_log ("read error\n"); - } + } } else { write_log ("Audio CD\n"); if (audiounit < 0) @@ -917,7 +917,7 @@ static void akiko_handler (void) return; } } - + static void akiko_internal (void) { cdrom_run_command (); @@ -1381,7 +1381,7 @@ uae_u8 *save_akiko(int *len) save_u32 (akiko_buffer[i]); save_u8 ((uae_u8)akiko_read_offset); save_u8 ((uae_u8)akiko_write_offset); - + save_u32 ((cdrom_playing ? 1 : 0) | (cdrom_paused ? 2 : 0)); if (cdrom_playing) cd_qcode (0); diff --git a/akiko2.c b/akiko2.c index 8891692a..b2251d9c 100755 --- a/akiko2.c +++ b/akiko2.c @@ -67,10 +67,10 @@ static void nvram_write (int offset, int len) { struct zfile *f = zfile_fopen (currprefs.flashfile, "rb+"); if (!f) { - f = zfile_fopen (currprefs.flashfile, "wb"); - if (!f) return; - zfile_fwrite (cd32_nvram, NVRAM_SIZE, 1, f); - zfile_fclose (f); + f = zfile_fopen (currprefs.flashfile, "wb"); + if (!f) return; + zfile_fwrite (cd32_nvram, NVRAM_SIZE, 1, f); + zfile_fclose (f); } zfile_fseek (f, offset, SEEK_SET); zfile_fwrite (cd32_nvram + offset, len, 1, f); @@ -136,7 +136,7 @@ static void i2c_do (void) if (direction > 0) { nvram_writetmp[nvram_writeaddr++] = nvram_byte; nvram_writeaddr &= 15; - bitcounter = 0; + bitcounter = 0; } else { bitcounter = -1; } @@ -278,8 +278,8 @@ static void akiko_c2p_do (void) for (i = 0; i < 8; i++) akiko_result[i] = 0; /* FIXME: better c2p algoritm than this piece of crap.... */ for (i = 0; i < 8 * 32; i++) { - if (akiko_buffer[7 - (i >> 5)] & (1 << (i & 31))) - akiko_result[i & 7] |= 1 << (i >> 3); + if (akiko_buffer[7 - (i >> 5)] & (1 << (i & 31))) + akiko_result[i & 7] |= 1 << (i >> 3); } } @@ -412,7 +412,7 @@ static int cd_qcode (uae_u8 *d) uae_u8 *buf, *s, as; if (d) - memset (d, 0, 11); + memset (d, 0, 11); last_play_pos = 0; buf = sys_command_qcode (DF_IOCTL, unitnum); if (!buf) @@ -445,7 +445,7 @@ static int cd_qcode (uae_u8 *d) /* Make sure end of disc position is passed. */ int lsn = msf2lsn ((s[5] << 16) | (s[6] << 8) | (s[7] << 0)); - int msf = lsn2msf (cdrom_leadout); + int msf = lsn2msf (cdrom_leadout); if (lsn >= cdrom_leadout || cdrom_leadout - lsn < 10) { d[8] = tobcd ((uae_u8)(msf >> 16)); d[9] = tobcd ((uae_u8)(msf >> 8)); @@ -524,7 +524,7 @@ static int sys_cddev_open (void) if (!found) { if (first >= 0) { unitnum = first; - sys_command_open (DF_IOCTL, unitnum); + sys_command_open (DF_IOCTL, unitnum); } else { unitnum = -1; return 1; @@ -764,33 +764,33 @@ static void cdrom_run_command_run (void) memset (cdrom_result_buffer, 0, sizeof(cdrom_result_buffer)); switch (cdrom_command & 0x0f) { - case 2: - len = cdrom_command_pause (); - break; - case 3: - len = cdrom_command_unpause (); - break; - case 4: - len = cdrom_command_multi (); - break; + case 2: + len = cdrom_command_pause (); + break; + case 3: + len = cdrom_command_unpause (); + break; + case 4: + len = cdrom_command_multi (); + break; case 5: cdrom_dosomething = 1; len = cdrom_command_something (); break; - case 6: - len = cdrom_command_subq (); - break; - case 7: - len = cdrom_command_door_status (); - break; - default: - len = 0; - break; + case 6: + len = cdrom_command_subq (); + break; + case 7: + len = cdrom_command_door_status (); + break; + default: + len = 0; + break; } if (len == 0) - return; + return; if (cdrom_checksum_error) - cdrom_result_buffer[1] |= 0x80; + cdrom_result_buffer[1] |= 0x80; cdrom_return_data (len); } @@ -814,29 +814,29 @@ static void cdrom_run_read (void) for (j = 0; j < 16; j++) { if (cdrom_readmask_w & (1 << j)) break; } - sector = cdrom_current_sector = cdrom_data_offset + cdrom_sector_counter; - sec = sector - sector_buffer_sector_1; - if (sector_buffer_sector_1 >= 0 && sec >= 0 && sec < SECTOR_BUFFER_SIZE) { + sector = cdrom_current_sector = cdrom_data_offset + cdrom_sector_counter; + sec = sector - sector_buffer_sector_1; + if (sector_buffer_sector_1 >= 0 && sec >= 0 && sec < SECTOR_BUFFER_SIZE) { if (sector_buffer_info_1[sec] != 0xff && sector_buffer_info_1[sec] != 0) { - memcpy (buf + 16, sector_buffer_1 + sec * 2048, 2048); - encode_l2 (buf, sector + 150); - buf[0] = 0; - buf[1] = 0; - buf[2] = 0; - buf[3] = cdrom_sector_counter; - for (i = 0; i < 2352; i++) - put_byte (cdrom_address1 + j * 4096 + i, buf[i]); - cdrom_readmask_r |= 1 << j; + memcpy (buf + 16, sector_buffer_1 + sec * 2048, 2048); + encode_l2 (buf, sector + 150); + buf[0] = 0; + buf[1] = 0; + buf[2] = 0; + buf[3] = cdrom_sector_counter; + for (i = 0; i < 2352; i++) + put_byte (cdrom_address1 + j * 4096 + i, buf[i]); + cdrom_readmask_r |= 1 << j; } if (sector_buffer_info_1[sec] != 0xff) sector_buffer_info_1[sec]--; } else return; #if AKIKO_DEBUG_IO_CMD - write_log("read sector=%d, scnt=%d -> %d\n", cdrom_data_offset, cdrom_sector_counter, sector); + write_log("read sector=%d, scnt=%d -> %d\n", cdrom_data_offset, cdrom_sector_counter, sector); #endif cdrom_readmask_w &= ~(1 << j); - cdrom_status1 |= CDSTATUS_DATASECTOR; + cdrom_status1 |= CDSTATUS_DATASECTOR; } cdrom_sector_counter++; } @@ -849,7 +849,7 @@ static void akiko_handler (void) struct device_info di; if (cdrom_result_complete > cdrom_result_last_pos && cdrom_result_complete - cdrom_result_last_pos < 100) { - cdrom_status1 |= CDSTATUS_DATA_AVAILABLE; + cdrom_status1 |= CDSTATUS_DATA_AVAILABLE; return; } if (cdrom_result_last_pos < cdrom_result_complete) @@ -878,8 +878,8 @@ static void akiko_internal (void) { cdrom_run_command (); if (cdrom_command_active > 0) { - cdrom_command_active--; - if (!cdrom_command_active) + cdrom_command_active--; + if (!cdrom_command_active) cdrom_run_command_run (); } } @@ -896,7 +896,7 @@ void AKIKO_hsync_handler (void) if (framecounter <= 0) { cdrom_run_read (); framecounter = 1000000 / (74 * 75 * cdrom_speed); - cdrom_status1 |= CDSTATUS_FRAME; + cdrom_status1 |= CDSTATUS_FRAME; } akiko_internal (); akiko_handler (); @@ -917,7 +917,7 @@ static void *akiko_thread (void *null) int sector; while(akiko_thread_running) { - uae_sem_wait (&akiko_sem); + uae_sem_wait (&akiko_sem); sector = cdrom_current_sector; for (i = 0; i < SECTOR_BUFFER_SIZE; i++) { if (sector_buffer_info_1[i] == 0xff) break; @@ -949,7 +949,7 @@ static void *akiko_thread (void *null) sector_buffer_sector_1 = sector_buffer_sector_2; sector_buffer_sector_2 = tmp3; } - uae_sem_post (&akiko_sem); + uae_sem_post (&akiko_sem); Sleep (10); } akiko_thread_running = -1; @@ -1042,7 +1042,7 @@ uae_u32 akiko_bget2 (uaecptr addr, int msg) /* C2P */ case 0x38: case 0x39: - case 0x3a: + case 0x3a: case 0x3b: v = akiko_c2p_read (addr - 0x38); break; @@ -1085,7 +1085,7 @@ uae_u32 akiko_lget (uaecptr addr) v |= akiko_bget2 (addr + 1, 0) << 16; v |= akiko_bget2 (addr + 0, 0) << 24; if (addr < 0x30 && (addr != 4 && addr != 8) && AKIKO_DEBUG_IO) - write_log ("akiko_lget %08.8X: %08.8X %08.8X\n", m68k_getpc(), addr, v); + write_log ("akiko_lget %08.8X: %08.8X %08.8X\n", m68k_getpc(), addr, v); return v; } @@ -1096,7 +1096,7 @@ void akiko_bput2 (uaecptr addr, uae_u32 v, int msg) addr &= 0xffff; v &= 0xff; if(msg && addr < 0x30 && AKIKO_DEBUG_IO) - write_log ("akiko_bput %08.8X: %08.8X=%02.2X\n", m68k_getpc(), addr, v & 0xff); + write_log ("akiko_bput %08.8X: %08.8X=%02.2X\n", m68k_getpc(), addr, v & 0xff); uae_sem_wait (&akiko_sem); switch (addr) { @@ -1199,7 +1199,7 @@ void akiko_lput (uaecptr addr, uae_u32 v) { addr &= 0xffff; if(addr < 0x30 && AKIKO_DEBUG_IO) - write_log("akiko_lput %08.8X: %08.8X=%08.8X\n", m68k_getpc(), addr, v); + write_log("akiko_lput %08.8X: %08.8X=%08.8X\n", m68k_getpc(), addr, v); akiko_bput2 (addr + 3, (v >> 0) & 0xff, 0); akiko_bput2 (addr + 2, (v >> 8) & 0xff, 0); akiko_bput2 (addr + 1, (v >> 16) & 0xff, 0); @@ -1282,7 +1282,7 @@ void akiko_init (void) } } if (!savestate_state) { - cdrom_playing = cdrom_paused = 0; + cdrom_playing = cdrom_paused = 0; cdrom_data_offset = -1; uae_sem_init (&akiko_sem, 0, 1); } @@ -1390,4 +1390,4 @@ uae_u8 *restore_akiko(uae_u8 *src) sys_command_play (DF_IOCTL, unitnum, last_play_pos, last_play_end, 0); return src; -} \ No newline at end of file +} diff --git a/ar.c b/ar.c index 60283e5e..759e5e8e 100755 --- a/ar.c +++ b/ar.c @@ -1,4 +1,4 @@ -/* +/* * UAE Action Replay 1/2/3 and HRTMon support * * (c) 2000-2002 Toni Wilen @@ -12,7 +12,7 @@ * HRTMon support is tested with version 2.25 + patch. * More information about HRTMon can be found from * http://dumbo.cryogen.ch/hrtmon/ - * + * * Action Replay 2/3: * * Tested with AR3 ROM version 3.09 (10/13/91) and AR2 2.12 (12/24/90) @@ -25,8 +25,8 @@ * 3.17 12/17/91 mm/dd/yy * * This patch also makes AR3 compatible with KickStart's other than 1.3 - * (ROM checksum error is normal with KS != 1.3) - * NOTE: AR has problems with 68020+ processors. + * (ROM checksum error is normal with KS != 1.3) + * NOTE: AR has problems with 68020+ processors * For maximum compatibility select 68000/68010 and A500 speed from UAE * options. * @@ -70,7 +70,7 @@ * 5. Copy the rom into the address the monitor allocated. * 6. Exit the action replay. * 7. Save the ram from the monitor to disk. - * + * * I DO NOT REPLY MAILS ASKING FOR ACTION REPLAY ROMS! * * AR2/3 hardware notes (not 100% correct..) @@ -93,7 +93,7 @@ * * cartridge hardware also snoops CPU accesses to custom chip * registers (DFF000-DFF1FE). All CPU custom chip accesses are - * saved to RAM at 0x44f000-0x44f1ff. Note that emulated AR3 also + * saved to RAM at 0x44f000-0x44f1ff. Note that emulated AR3 also * saves copper's custom chip accesses. This fix stops programs * that try to trick AR by using copper to update write-only * custom registers. @@ -111,7 +111,7 @@ * This command will not work using the current infrastructure, * so don't use it 8). */ - + /* AR1 Breakpoint info. * 1.15 If a breakpoint occurred. Its address is stored at 9fe048. * The 5 breakpoint entries each consisting of 6 bytes are stored at 9fe23e. @@ -123,26 +123,26 @@ /* How AR1 is entered on reset: * In the kickstart (1.3) there is the following code: * I have marked the important lines: - * - * fc00e6 lea f00000,a1 ; address where AR1 rom is located. + * + * fc00e6 lea f00000,a1 ; address where AR1 rom is located. * fc00ec cmpa.l a1,a0 * fc00ee beq fc00fe.s * fc00f0 lea C(pc), a5 - * fc00f4 cmpi.w #1111,(a1) ; The first word of the AR1 rom is set to 1111. + * fc00f4 cmpi.w #1111,(a1) ; The first word of the AR1 rom is set to 1111. * fc00f8 bne fc00fe.s - * fc00fa jmp 2(a1) ; This is the entry point of the rom. + * fc00fa jmp 2(a1) ; This is the entry point of the rom. */ - + /* Flag info: - * AR3:'ARON'. This is unset initially. It is set the first time you enter the AR via a freeze. - * It enables you to keep the keyboard buffer and such. - * If this flag is unset, the keyboard buffer is cleared, the breakpoints are deleted and ... */ - + * AR3:'ARON'. This is unset initially. It is set the first time you enter the AR via a freeze. + * It enables you to keep the keyboard buffer and such. + * If this flag is unset, the keyboard buffer is cleared, the breakpoints are deleted and ... */ + /* AR3:'PRIN'. This flag is unset initially. It is set at some point and when you switch to the 2nd screen - * for the first time it displays all the familiar text. Then unsets 'PRIN'. - */ - - + * for the first time it displays all the familiar text. Then unsets 'PRIN'. + */ + + #include "sysconfig.h" #include "sysdeps.h" @@ -156,33 +156,33 @@ #include "ar.h" #include "savestate.h" -#define DEBUG +#define DEBUG #ifdef DEBUG -#define write_log_debug write_log +#define write_log_debug write_log #else -#define write_log_debug +#define write_log_debug #endif - -#define ARMODE_FREEZE 0 /* AR2/3 The action replay 'freeze' button has been pressed. */ -#define ARMODE_BREAKPOINT_AR2 2 /* AR2: The action replay is activated via a breakpoint. */ -#define ARMODE_BREAKPOINT_ACTIVATED 1 -#define ARMODE_BREAKPOINT_AR3_RESET_AR2 3 /* AR2: The action replay is activated after a reset. */ + +#define ARMODE_FREEZE 0 /* AR2/3 The action replay 'freeze' button has been pressed. */ +#define ARMODE_BREAKPOINT_AR2 2 /* AR2: The action replay is activated via a breakpoint. */ +#define ARMODE_BREAKPOINT_ACTIVATED 1 +#define ARMODE_BREAKPOINT_AR3_RESET_AR2 3 /* AR2: The action replay is activated after a reset. */ /* AR3: The action replay is activated by a breakpoint. */ /* HRTMon baseaddress, can be freely changed */ -#define HRTMON_BASE 0x980000 +#define HRTMON_BASE 0x980000 uae_u8 ar_custom[2*256]; -int hrtmon_flag = ACTION_REPLAY_INACTIVE; +int hrtmon_flag = ACTION_REPLAY_INACTIVE; static uae_u8 *hrtmemory = 0; static uae_u8 *armemory_rom = 0, *armemory_ram = 0; static uae_u32 hrtmem_mask; static uae_u8 *hrtmon_custom; -uae_u32 hrtmem_start, hrtmem_size; +uae_u32 hrtmem_start, hrtmem_size; static uae_u32 hrtmem_lget (uaecptr) REGPARAM; static uae_u32 hrtmem_wget (uaecptr) REGPARAM; @@ -190,7 +190,7 @@ static uae_u32 hrtmem_bget (uaecptr) REGPARAM; static void hrtmem_lput (uaecptr, uae_u32) REGPARAM; static void hrtmem_wput (uaecptr, uae_u32) REGPARAM; static void hrtmem_bput (uaecptr, uae_u32) REGPARAM; -static int hrtmem_check (uaecptr addr, uae_u32 size) REGPARAM; +static int hrtmem_check (uaecptr addr, uae_u32 size) REGPARAM; static uae_u8 *hrtmem_xlate (uaecptr addr) REGPARAM; static void hrtmon_unmap_banks(void); @@ -254,7 +254,7 @@ static int REGPARAM2 hrtmem_check (uaecptr addr, uae_u32 size) return (addr + size) <= hrtmem_size; } -static uae_u8 REGPARAM2 *hrtmem_xlate (uaecptr addr) +static uae_u8 REGPARAM2 *hrtmem_xlate (uaecptr addr) { addr -= hrtmem_start & hrtmem_mask; addr &= hrtmem_mask; @@ -274,7 +274,7 @@ while(len--) { src++; } } -static void copytoamiga(uaecptr dst,uae_u8 *src,int len) +static void copytoamiga(uaecptr dst,uae_u8 *src,int len) { while(len--) { put_byte (dst, *src++); @@ -285,26 +285,26 @@ while(len--) { int action_replay_flag = ACTION_REPLAY_INACTIVE; static int ar_rom_file_size; -/* Use this for relocating AR? */ +/* Use this for relocating AR? */ static int ar_rom_location; /*static*/ int armodel; -static uae_u8 artemp[4]; /* Space to store the 'real' level 7 interrupt */ +static uae_u8 artemp[4]; /* Space to store the 'real' level 7 interrupt */ static uae_u8 armode; -static uae_u32 arrom_start, arrom_size, arrom_mask; -static uae_u32 arram_start, arram_size, arram_mask; +static uae_u32 arrom_start, arrom_size, arrom_mask; +static uae_u32 arram_start, arram_size, arram_mask; -static int ar_wait_pop = 0; /* bool used by AR1 when waiting for the program counter to exit it's ram. */ -uaecptr wait_for_pc = 0; /* The program counter that we wait for. */ +static int ar_wait_pop = 0; /* bool used by AR1 when waiting for the program counter to exit it's ram. */ +uaecptr wait_for_pc = 0; /* The program counter that we wait for. */ -/* returns true if the Program counter is currently in the AR rom. */ +/* returns true if the Program counter is currently in the AR rom. */ int is_ar_pc_in_rom() { uaecptr pc = m68k_getpc() & 0xFFFFFF; return pc >= arrom_start && pc < arrom_start+arrom_size; } -/* returns true if the Program counter is currently in the AR RAM. */ +/* returns true if the Program counter is currently in the AR RAM. */ int is_ar_pc_in_ram() { uaecptr pc = m68k_getpc() & 0xFFFFFF; @@ -312,37 +312,37 @@ int is_ar_pc_in_ram() } -/* flag writing == 1 for writing memory, 0 for reading from memory. */ -STATIC_INLINE int ar3a (uaecptr addr, uae_u8 b, int writing) +/* flag writing == 1 for writing memory, 0 for reading from memory. */ +STATIC_INLINE int ar3a (uaecptr addr, uae_u8 b, int writing) { uaecptr pc; -/* if ( addr < 8 ) //|| writing ) */ +/* if ( addr < 8 ) //|| writing ) */ /* { */ /* if ( writing ) */ -/* write_log_debug("ARSTATUS armode:%d, Writing %d to address %p, PC=%p\n", armode, b, addr, m68k_getpc()); */ +/* write_log_debug("ARSTATUS armode:%d, Writing %d to address %p, PC=%p\n", armode, b, addr, m68k_getpc()); */ /* else */ -/* write_log_debug("ARSTATUS armode:%d, Reading %d from address %p, PC=%p\n", armode, armemory_rom[addr], addr, m68k_getpc()); */ +/* write_log_debug("ARSTATUS armode:%d, Reading %d from address %p, PC=%p\n", armode, armemory_rom[addr], addr, m68k_getpc()); */ /* } */ if (armodel == 1 ) /* With AR1. It is always a read. Actually, it is a strobe on exit of the AR. - * but, it is also read during the checksum routine. */ + * but, it is also read during the checksum routine. */ { - if ( addr < 2) + if ( addr < 2) { if ( is_ar_pc_in_rom() ) { if ( ar_wait_pop ) { action_replay_flag = ACTION_REPLAY_WAIT_PC; -/* write_log_debug("SP %p\n", m68k_areg(regs,7)); */ -/* write_log_debug("SP+2 %p\n", m68k_areg(regs,7)+2 ); */ +/* write_log_debug("SP %p\n", m68k_areg(regs,7)); */ +/* write_log_debug("SP+2 %p\n", m68k_areg(regs,7)+2 ); */ /* write_log_debug("(SP+2) %p\n", longget(m68k_areg(regs,7)+2)); */ - ar_wait_pop = 0; + ar_wait_pop = 0; /* We get (SP+2) here, as the first word on the stack is the status register. */ /* We want the following long, which is the return program counter. */ wait_for_pc = longget(m68k_areg(regs,7)+2); /* Get (SP+2) */ set_special (SPCFLAG_ACTION_REPLAY); - + pc = m68k_getpc(); /* write_log_debug("Action Replay marked as ACTION_REPLAY_WAIT_PC, PC=%p\n",pc);*/ } @@ -365,7 +365,7 @@ STATIC_INLINE int ar3a (uaecptr addr, uae_u8 b, int writing) if (action_replay_flag != ACTION_REPLAY_ACTIVE) return 0; #endif - + if (!writing) /* reading */ { if (addr == 1 || addr == 3) /* This is necessary because we don't update rom location 0 every time we change armode */ @@ -376,9 +376,9 @@ STATIC_INLINE int ar3a (uaecptr addr, uae_u8 b, int writing) return armemory_rom[addr]; } /* else, we are writing */ - else if (addr == 1) { + else if (addr == 1) { armode = b; - if(armode >= 2) + if(armode >= 2) { if ( armode == ARMODE_BREAKPOINT_AR2 ) { @@ -388,10 +388,10 @@ STATIC_INLINE int ar3a (uaecptr addr, uae_u8 b, int writing) { write_log("AR3: exit waiting for breakpoint.\n"); /* Correct for AR3 (waiting for breakpoint)*/ } - else + else { write_log("AR2/3: mode(%d) > 3 this shouldn't happen.\n", armode); - } + } } else { write_log("AR: exit with armode(%d)\n", armode); } @@ -459,19 +459,19 @@ void REGPARAM2 chipmem_wput_actionreplay23 (uaecptr addr, uae_u32 w) static uae_u32 arram_lget (uaecptr) REGPARAM; static uae_u32 arram_wget (uaecptr) REGPARAM; static uae_u32 arram_bget (uaecptr) REGPARAM; -static void arram_lput (uaecptr, uae_u32) REGPARAM; -static void arram_wput (uaecptr, uae_u32) REGPARAM; -static void arram_bput (uaecptr, uae_u32) REGPARAM; -static int arram_check (uaecptr addr, uae_u32 size) REGPARAM; +static void arram_lput (uaecptr, uae_u32) REGPARAM; +static void arram_wput (uaecptr, uae_u32) REGPARAM; +static void arram_bput (uaecptr, uae_u32) REGPARAM; +static int arram_check (uaecptr addr, uae_u32 size) REGPARAM; static uae_u8 *arram_xlate (uaecptr addr) REGPARAM; static uae_u32 arrom_lget (uaecptr) REGPARAM; static uae_u32 arrom_wget (uaecptr) REGPARAM; static uae_u32 arrom_bget (uaecptr) REGPARAM; -static void arrom_lput (uaecptr, uae_u32) REGPARAM; -static void arrom_wput (uaecptr, uae_u32) REGPARAM; -static void arrom_bput (uaecptr, uae_u32) REGPARAM; -static int arrom_check (uaecptr addr, uae_u32 size) REGPARAM; +static void arrom_lput (uaecptr, uae_u32) REGPARAM; +static void arrom_wput (uaecptr, uae_u32) REGPARAM; +static void arrom_bput (uaecptr, uae_u32) REGPARAM; +static int arrom_check (uaecptr addr, uae_u32 size) REGPARAM; static uae_u8 *arrom_xlate (uaecptr addr) REGPARAM; static void action_replay_unmap_banks(void); @@ -571,14 +571,14 @@ void REGPARAM2 arram_bput (uaecptr addr, uae_u32 b) armemory_ram[addr] = b; } -static int REGPARAM2 arram_check (uaecptr addr, uae_u32 size) +static int REGPARAM2 arram_check (uaecptr addr, uae_u32 size) { addr -= arram_start; addr &= arram_mask; return (addr + size) <= arram_size; } -static uae_u8 REGPARAM2 *arram_xlate (uaecptr addr) +static uae_u8 REGPARAM2 *arram_xlate (uaecptr addr) { addr -= arram_start; addr &= arram_mask; @@ -615,7 +615,7 @@ static uae_u32 REGPARAM2 arrom_bget (uaecptr addr) return ar3a (addr, 0, 0); } -static void REGPARAM2 arrom_lput (uaecptr addr, uae_u32 l) +static void REGPARAM2 arrom_lput (uaecptr addr, uae_u32 l) { #ifdef JIT special_mem |= S_WRITE; @@ -628,7 +628,7 @@ static void REGPARAM2 arrom_lput (uaecptr addr, uae_u32 l) ar3a (addr + 3,(uae_u8)(l >> 0), 1); } -static void REGPARAM2 arrom_wput (uaecptr addr, uae_u32 w) +static void REGPARAM2 arrom_wput (uaecptr addr, uae_u32 w) { #ifdef JIT special_mem |= S_WRITE; @@ -639,7 +639,7 @@ static void REGPARAM2 arrom_wput (uaecptr addr, uae_u32 w) ar3a (addr + 1,(uae_u8)(w >> 0), 1); } -static void REGPARAM2 arrom_bput (uaecptr addr, uae_u32 b) +static void REGPARAM2 arrom_bput (uaecptr addr, uae_u32 b) { #ifdef JIT special_mem |= S_WRITE; @@ -649,26 +649,26 @@ static void REGPARAM2 arrom_bput (uaecptr addr, uae_u32 b) ar3a (addr, b, 1); } -static int REGPARAM2 arrom_check (uaecptr addr, uae_u32 size) +static int REGPARAM2 arrom_check (uaecptr addr, uae_u32 size) { addr -= arrom_start; addr &= arrom_mask; return (addr + size) <= arrom_size; } -static uae_u8 REGPARAM2 *arrom_xlate (uaecptr addr) +static uae_u8 REGPARAM2 *arrom_xlate (uaecptr addr) { addr -= arrom_start; addr &= arrom_mask; return armemory_rom + addr; } -static addrbank arrom_bank = { +static addrbank arrom_bank = { arrom_lget, arrom_wget, arrom_bget, arrom_lput, arrom_wput, arrom_bput, arrom_xlate, arrom_check, NULL }; -static addrbank arram_bank = { +static addrbank arram_bank = { arram_lget, arram_wget, arram_bget, arram_lput, arram_wput, arram_bput, arram_xlate, arram_check, NULL @@ -678,7 +678,7 @@ static void action_replay_unmap_banks() { if(!armemory_rom) return; - + map_banks (&dummy_bank, arrom_start >> 16 , arrom_size >> 16, 0); map_banks (&dummy_bank, arram_start >> 16 , arram_size >> 16, 0); } @@ -703,9 +703,9 @@ static void hide_cart(int hide) #endif } -/*extern void Interrupt (int nr);*/ +/*extern void Interrupt (int nr);*/ -/* Cartridge activates itself by overlaying its rom +/* Cartridge activates itself by overlaying its rom * over chip-ram and then issuing IRQ 7 * * I just copy IRQ vector 7 from ROM to chip RAM @@ -727,7 +727,7 @@ static void action_replay_go1 (int irq) { hide_cart (0); action_replay_flag = ACTION_REPLAY_ACTIVE; - + memcpy (armemory_ram + 0xf000, ar_custom, 2 * 256); Interrupt (7); } @@ -763,8 +763,8 @@ void action_replay_enter(void) } else if (armode == ARMODE_FREEZE) { write_log("AR2/3: activated (freeze)\n"); - } - else if (armode >= 2) + } + else if (armode >= 2) { if ( armode == ARMODE_BREAKPOINT_AR2 ) { @@ -774,10 +774,10 @@ void action_replay_enter(void) { write_log("AR3: activated (breakpoint)\n"); } - else + else { write_log("AR2/3: mode(%d) > 3 this shouldn't happen.\n", armode); - } + } armode = ARMODE_BREAKPOINT_ACTIVATED; } action_replay_go(); @@ -785,23 +785,23 @@ void action_replay_enter(void) void check_prefs_changed_carts(int in_memory_reset) { - if (strcmp (currprefs.cartfile, changed_prefs.cartfile) != 0) + if (strcmp (currprefs.cartfile, changed_prefs.cartfile) != 0) { write_log("Cartridge ROM Prefs changed.\n"); if (action_replay_unload(in_memory_reset)) { - memcpy (currprefs.cartfile, changed_prefs.cartfile, sizeof currprefs.cartfile); + memcpy (currprefs.cartfile, changed_prefs.cartfile, sizeof currprefs.cartfile); #ifdef ACTION_REPLAY action_replay_load(); - action_replay_init(1); + action_replay_init(1); #endif #ifdef ACTION_REPLAY_HRTMON hrtmon_load(1); #endif } } -} - +} + void action_replay_reset(void) { if (action_replay_flag == ACTION_REPLAY_INACTIVE) @@ -846,7 +846,7 @@ void action_replay_ciaread(void) int action_replay_freeze(void) { - if(action_replay_flag == ACTION_REPLAY_IDLE) + if(action_replay_flag == ACTION_REPLAY_IDLE) { if (armodel == 1) { @@ -869,7 +869,7 @@ int action_replay_freeze(void) void action_replay_chipwrite(void) { - if (armodel > 1) + if (armodel > 1) { action_replay_flag = ACTION_REPLAY_DORESET; set_special (SPCFLAG_ACTION_REPLAY); @@ -881,7 +881,7 @@ void action_replay_chipwrite(void) copyfromamiga (artemp, regs.vbr + 0x60, 4); copytoamiga (regs.vbr + 0x7c, artemp, 4); ar_wait_pop = 1; /* Wait for stack to pop. */ - + action_replay_flag = ACTION_REPLAY_ACTIVATE; set_special (SPCFLAG_ACTION_REPLAY); } @@ -907,13 +907,13 @@ void hrtmon_breakenter(void) } -/* Disabling copperlist processing: +/* Disabling copperlist processing: * On: ar317 an rts at 41084c does it. * On: ar214: an rts at 41068e does it. */ -/* Original AR3 only works with KS 1.3 +/* Original AR3 only works with KS 1.3 * this patch fixes that problem. */ @@ -928,7 +928,7 @@ static void action_replay_patch(void) if (armodel != 3 || !kickmem) return; if (!memcmp (kickmem, kickmem + 262144, 262144)) off1 = 262144; else off1 = 0; - for (;;) { + for (;;) { if (!memcmp (kickmem + off1, ar3patch1, sizeof (ar3patch1)) || off1 == 524288 - sizeof (ar3patch1)) break; off1++; } @@ -946,9 +946,9 @@ static void action_replay_patch(void) write_log ("AR ROM patched for KS2.0+\n"); } -/* Returns 0 if the checksum is OK. +/* Returns 0 if the checksum is OK. * Else, it returns the calculated checksum. - * Note: Will be wrong if the checksum is zero, but i'll take my chances on that not happenning ;) + * Note: Will be wrong if the checksum is zero, but i'll take my chances on that not happenning ;) */ static uae_u32 action_replay_calculate_checksum() { @@ -963,18 +963,18 @@ static uae_u32 action_replay_calculate_checksum() * AR1: The checksum is the last non-zero long in the rom. * AR2: The checksum starts at offset 4. * AR2: The checksum is the last Long in the rom. - * AR3: The checksum starts at offset 0x7c. + * AR3: The checksum starts at offset 0x7c. * AR3: The checksum is the last Long in the rom. * * Checksums: (This is a good way to compare roms. I have two with different md5sums, * but the same checksum, so the difference must be in the first four bytes.) - * 3.17 0xf009bfc9 + * 3.17 0xf009bfc9 * 3.09 0xd34d04a7 * 2.14 0xad839d36 * 2.14 0xad839d36 * 1.15 0xee12116 */ - + if (!armemory_rom) return 0; /* If there is no rom then i guess the checksum is ok */ @@ -983,61 +983,61 @@ static uae_u32 action_replay_calculate_checksum() /* Search for first non-zero Long starting from the end of the rom. */ /* Assume long alignment, (will always be true for AR2 and AR3 and the AR1 rom i've got). */ - /* If anyone finds an AR1 rom with a word-aligned checksum, then this code will have to be modified. */ + /* If anyone finds an AR1 rom with a word-aligned checksum, then this code will have to be modified. */ while (! *(--checksum_end) ); - + if ( armodel == 1) { - uae_u16* rom_ptr_word; - uae_s16 sign_extended_word; - + uae_u16* rom_ptr_word; + uae_s16 sign_extended_word; + rom_ptr_word = (uae_u16*)checksum_start; while ( rom_ptr_word != (uae_u16*)checksum_end ) { sign_extended_word = (uae_s16)do_get_mem_word (rom_ptr_word); /* When the word is cast on the following line, it will get sign-extended. */ - checksum += (uae_u32)sign_extended_word; + checksum += (uae_u32)sign_extended_word; rom_ptr_word++; } } else - { - uae_u32* rom_ptr_long; + { + uae_u32* rom_ptr_long; rom_ptr_long = checksum_start; while ( rom_ptr_long != checksum_end ) { - checksum += do_get_mem_long (rom_ptr_long); - rom_ptr_long++; + checksum += do_get_mem_long (rom_ptr_long); + rom_ptr_long++; } } - + stored_checksum = do_get_mem_long(checksum_end); return checksum == stored_checksum ? 0 : checksum; } -/* Returns 0 on error. */ +/* Returns 0 on error. */ static uae_u8* get_checksum_location() { uae_u32* checksum_end; /* See action_replay_calculate_checksum() for checksum info. */ - + if (!armemory_rom) return 0; checksum_end = (uae_u32*)&armemory_rom[ar_rom_file_size]; - /* Search for first non-zero Long starting from the end of the rom. */ + /* Search for first non-zero Long starting from the end of the rom. */ while (! *(--checksum_end) ); return (uae_u8*)checksum_end; } -/* Replaces the existing cart checksum with a correct one. */ -/* Useful if you want to patch the rom. */ +/* Replaces the existing cart checksum with a correct one. */ +/* Useful if you want to patch the rom.*/ static void action_replay_fixup_checksum(uae_u32 new_checksum) { uae_u32* checksum = (uae_u32*)get_checksum_location(); @@ -1053,13 +1053,13 @@ static void action_replay_fixup_checksum(uae_u32 new_checksum) } /* Longword search on word boundary - * the search_value is assumed to already be in the local endian format + * the search_value is assumed to already be in the local endian format * return 0 on failure */ -static uae_u8* find_absolute_long(uae_u8* start_addr, uae_u8* end_addr, uae_u32 search_value) +static uae_u8* find_absolute_long(uae_u8* start_addr, uae_u8* end_addr, uae_u32 search_value) { uae_u8* addr; - + for ( addr = start_addr; addr < end_addr; ) { if ( do_get_mem_long((uae_u32*)addr) == search_value ) @@ -1070,23 +1070,23 @@ static uae_u8* find_absolute_long(uae_u8* start_addr, uae_u8* end_addr, uae_u32 addr+=2; } return 0; -} +} -/* word search on word boundary - * the search_addr is assumed to already be in the local endian format +/* word search on word boundary + * the search_addr is assumed to already be in the local endian format * return 0 on failure * Currently only tested where the address we are looking for is AFTER the instruction. - * Not sure it works with negative offsets. + * Not sure it works with negative offsets. */ -static uae_u8* find_relative_word(uae_u8* start_addr, uae_u8* end_addr, uae_u16 search_addr) +static uae_u8* find_relative_word(uae_u8* start_addr, uae_u8* end_addr, uae_u16 search_addr) { uae_u8* addr; - + for ( addr = start_addr; addr < end_addr; ) { if ( do_get_mem_word((uae_u16*)addr) == (uae_u16)(search_addr - (uae_u16)(addr-start_addr)) ) { -/* write_log_debug("Found %p at offset %p.\n", search_addr, addr - start_addr);*/ +/* write_log_debug("Found %p at offset %p.\n", search_addr, addr - start_addr);*/ return addr; } addr+=2; @@ -1094,16 +1094,16 @@ static uae_u8* find_relative_word(uae_u8* start_addr, uae_u8* end_addr, uae_u16 return 0; } -/* Disable rom test */ -/* This routine replaces the rom-test routine with a 'rts'. - * It does this in a 'safe' way, by searching for a reference to the checksum - * and only disables it if the surounding bytes are what it expects. +/* Disable rom test */ +/* This routine replaces the rom-test routine with a 'rts'. + * It does this in a 'safe' way, by searching for a reference to the checksum + * and only disables it if the surounding bytes are what it expects. */ static void disable_rom_test() { uae_u8* addr; - + uae_u8* start_addr = armemory_rom; uae_u8* end_addr = get_checksum_location(); @@ -1112,7 +1112,7 @@ static void disable_rom_test() * checksum test. * AR1: * F0D4D0 6100 ???? bsr.w calc_checksum ; calculate the checksum - * F0D4D4 41FA 147A lea (0xf0e950,PC),a0 ; load the existing checksum. + * F0D4D4 41FA 147A lea (0xf0e950,PC),a0 ; load the existing checksum. * ; do a comparison. * AR2: * 40EC92 6100 ???? bsr.w calc_checksum @@ -1123,11 +1123,11 @@ static void disable_rom_test() { uae_u16 search_value_rel = end_addr - start_addr; addr = find_relative_word(start_addr, end_addr, search_value_rel); - + if ( addr ) { if ( do_get_mem_word((uae_u16*)(addr-6)) == 0x6100 && /* bsr.w */ - do_get_mem_word((uae_u16*)(addr-2)) == 0x41fa ) /* lea relative */ + do_get_mem_word((uae_u16*)(addr-2)) == 0x41fa ) /* lea relative */ { write_log("Patching to disable ROM TEST.\n"); do_put_mem_word((uae_u16*)(addr-6), 0x4e75); /* rts */ @@ -1142,16 +1142,16 @@ static void disable_rom_test() if ( addr ) { if ( do_get_mem_word((uae_u16*)(addr-6)) == 0x6100 && /* bsr.w */ - do_get_mem_word((uae_u16*)(addr-2)) == 0x41f9 ) /* lea absolute */ + do_get_mem_word((uae_u16*)(addr-2)) == 0x41f9 ) /* lea absolute */ { write_log("Patching to disable ROM TEST.\n"); do_put_mem_word((uae_u16*)(addr-6), 0x4e75); /* rts */ } } } -} - -/* After we have calculated the checksum, and verified the rom is ok, +} + +/* After we have calculated the checksum, and verified the rom is ok, * we can do two things. * 1. (optionally)Patch it and then update the checksum. * 2. Remove the checksum check and (optionally) patch it. @@ -1201,11 +1201,11 @@ static void action_replay_unsetbanks (void) chipmem_bank.lput = chipmem_lput; } -/* param to allow us to unload the cart. Currently we know it is safe if we are doing a reset to unload it.*/ +/* param to allow us to unload the cart. Currently we know it is safe if we are doing a reset to unload it.*/ int action_replay_unload(int in_memory_reset) -{ - char* state[] = - { +{ + char* state[] = + { "ACTION_REPLAY_WAIT_PC", "ACTION_REPLAY_INACTIVE", "ACTION_REPLAY_WAITRESET", @@ -1216,7 +1216,7 @@ int action_replay_unload(int in_memory_reset) "ACTION_REPLAY_DORESET", "ACTION_REPLAY_HIDE", }; - + write_log_debug("Action Replay State:(%s) Hrtmon State:(%s)\n", state[action_replay_flag+3],state[hrtmon_flag+3] ); if ( armemory_rom && armodel == 1 ) @@ -1251,7 +1251,7 @@ int action_replay_unload(int in_memory_reset) action_replay_cleanup(); return 1; } - + int action_replay_load(void) { @@ -1322,7 +1322,7 @@ void action_replay_init (int activate) } } -/* This only deallocates memory, it is not suitable for unloading roms and continuing */ +/* This only deallocates memory, it is not suitable for unloading roms and continuing */ void action_replay_cleanup() { if (armemory_rom) @@ -1337,14 +1337,14 @@ void action_replay_cleanup() hrtmemory = 0; } -#ifndef FALSE -#define FALSE 0 +#ifndef FALSE +#define FALSE 0 #endif -#ifndef TRUE -#define TRUE 1 +#ifndef TRUE +#define TRUE 1 #endif -typedef struct { +typedef struct { char jmps[20]; unsigned int mon_size; unsigned short col0, col1; @@ -1366,13 +1366,13 @@ typedef struct { unsigned int error_pc; unsigned short error_status; char newid[6]; - unsigned short mon_version; - unsigned short mon_revision; - unsigned int whd_base; - unsigned short whd_version; - unsigned short whd_revision; - unsigned int max_chip; - unsigned int custom; + unsigned short mon_version; + unsigned short mon_revision; + unsigned int whd_base; + unsigned short whd_version; + unsigned short whd_revision; + unsigned int max_chip; + unsigned int custom; } HRTCFG; static void hrtmon_configure(HRTCFG *cfg) @@ -1383,18 +1383,18 @@ cfg->right = 0; cfg->key = FALSE; cfg->ide = 0; cfg->a1200 = 0; -cfg->aga = (currprefs.chipset_mask & 4) ? 1 : 0; +cfg->aga = (currprefs.chipset_mask & 4) ? 1 : 0; cfg->insert = TRUE; cfg->delay = 15; cfg->lview = FALSE; cfg->cd32 = 0; -cfg->screenmode = 0; +cfg->screenmode = 0; cfg->vbr = TRUE; cfg->hexmode = FALSE; cfg->mon_size=0; cfg->hexmode = TRUE; do_put_mem_long(&cfg->max_chip,currprefs.chipmem_size); -hrtmon_custom = do_get_mem_long ((uae_u32*)&cfg->custom)+hrtmemory; +hrtmon_custom = do_get_mem_long ((uae_u32*)&cfg->custom)+hrtmemory; } static void hrtmon_reloc(uae_u32 *mem,uae_u32 *header) @@ -1413,13 +1413,13 @@ static void hrtmon_reloc(uae_u32 *mem,uae_u32 *header) } } -static uae_u8 hrt_header[] = { +static uae_u8 hrt_header[] = { 0x0, 0x0, 0x3, 0xf3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0 + 0x0 }; int hrtmon_load(int activate) @@ -1428,13 +1428,13 @@ int hrtmon_load(int activate) int size; uae_u32 header[8]; uae_u32 id_string[2]; - + /* Don't load a rom if one is already loaded. Use action_replay_unload() first. */ if (armemory_rom) return 0; if (hrtmemory) return 0; - + armodel = 0; if (strlen(currprefs.cartfile) == 0) return 0; @@ -1452,15 +1452,15 @@ int hrtmon_load(int activate) zfile_fclose (f); return 0; } - zfile_fread(header,sizeof(header),1,f); + zfile_fread(header,sizeof(header),1,f); /* Check the header */ -/* uae_u8* ptr = (uae_u8*)&header; */ -/* for ( ; ptr < sizeof(header); ptr++) */ +/* uae_u8* ptr = (uae_u8*)&header; */ +/* for ( ; ptr < sizeof(header); ptr++) */ /* { */ -/* if ( *ptr != *header */ - - zfile_fread(id_string,sizeof(id_string),1,f); +/* if ( *ptr != *header */ + + zfile_fread(id_string,sizeof(id_string),1,f); if (strncmp((char*)&id_string[1], "HRT!",4) != 0 ) { write_log("Not a Hrtmon Rom\n"); @@ -1468,7 +1468,7 @@ int hrtmon_load(int activate) return 0; } zfile_fseek(f,sizeof(header),SEEK_SET); - + hrtmem_size = size; hrtmem_size += 65535; hrtmem_size &= ~65535; @@ -1504,12 +1504,12 @@ static void hrtmon_unmap_banks() -#define AR_VER_STR_OFFSET 0x4 /* offset in the rom where the version string begins. */ -#define AR_VER_STR_END 0x7c /* offset in the rom where the version string ends. */ -#define AR_VER_STR_LEN (AR_VER_STR_END - AR_VER_STR_OFFSET) +#define AR_VER_STR_OFFSET 0x4 /* offset in the rom where the version string begins. */ +#define AR_VER_STR_END 0x7c /* offset in the rom where the version string ends. */ +#define AR_VER_STR_LEN (AR_VER_STR_END - AR_VER_STR_OFFSET) char arVersionString[AR_VER_STR_LEN+1]; -/* This function extracts the version info for AR2 and AR3. */ +/* This function extracts the version info for AR2 and AR3. */ void action_replay_version() { @@ -1522,10 +1522,10 @@ void action_replay_version() if (!armemory_rom) return; - + if ( armodel == 1 ) return; /* no support yet. */ - + /* Extract Version string */ memcpy(arVersionString, armemory_rom+AR_VER_STR_OFFSET, AR_VER_STR_LEN); arVersionString[AR_VER_STR_LEN]= '\0'; @@ -1535,7 +1535,7 @@ void action_replay_version() *tmp = '\0'; } /* write_log_debug("Version string is : '%s'\n", arVersionString); */ - + tmp = strchr(arVersionString,')'); if ( tmp ) { @@ -1571,8 +1571,8 @@ void action_replay_version() write_log("Version of cart is '%d.%.02d', date is '%s'\n", iArVersionMajor, iArVersionMinor, sArDate); } } - -/* This function doesn't reset the Cart memory, it is just called during a memory reset */ + +/* This function doesn't reset the Cart memory, it is just called during a memory reset */ void action_replay_memory_reset(void) { #ifdef ACTION_REPLAY @@ -1582,7 +1582,7 @@ void action_replay_memory_reset(void) } #endif #ifdef ACTION_REPLAY_HRTMON - if ( hrtmemory ) + if ( hrtmemory ) { hrtmon_hide(); /* It is never really idle */ } @@ -1594,7 +1594,7 @@ void action_replay_memory_reset(void) action_replay_checksum_info(); } -uae_u8 *save_action_replay (int *len, uae_u8 *dstptr) +uae_u8 *save_action_replay (int *len, uae_u8 *dstptr) { uae_u8 *dstbak,*dst; diff --git a/audio.c b/audio.c index 4dc8e0fb..ce2411c2 100755 --- a/audio.c +++ b/audio.c @@ -48,7 +48,7 @@ struct audio_channel_data { uaecptr lc, pt; int current_sample, last_sample; int *voltbl; - int state; + int state; int per; int vol; int len, wlen; @@ -110,7 +110,7 @@ static void convertsample(uae_u8 *sample, int len) static void namesplit (char *s) { int l; - + l = strlen (s) - 1; while (l >= 0) { if (s[l] == '.') @@ -421,7 +421,7 @@ void sample16i_crux_handler (void) data3 &= audio_channel[3].adk_mask; data3p &= audio_channel[3].adk_mask; - { + { struct audio_channel_data *cdp; unsigned long ratio, ratio1; #define INTERVAL (scaled_sample_evtime * 3) @@ -480,12 +480,12 @@ void sample16ss_handler (void) data1 &= audio_channel[1].adk_mask; data2 &= audio_channel[2].adk_mask; data3 &= audio_channel[3].adk_mask; - + PUT_SOUND_WORD (data0 << 2); PUT_SOUND_WORD (data1 << 2); PUT_SOUND_WORD (data3 << 2); PUT_SOUND_WORD (data2 << 2); - + check_sound_buffers (); } @@ -504,7 +504,7 @@ void sample16s_handler (void) data1 &= audio_channel[1].adk_mask; data2 &= audio_channel[2].adk_mask; data3 &= audio_channel[3].adk_mask; - + data0 += data3; { uae_u32 data = SBASEVAL16(1) + data0; @@ -551,7 +551,7 @@ void sample16si_crux_handler (void) data3 &= audio_channel[3].adk_mask; data3p &= audio_channel[3].adk_mask; - { + { struct audio_channel_data *cdp; unsigned long ratio, ratio1; #define INTERVAL (scaled_sample_evtime * 3) @@ -595,7 +595,7 @@ void sample16si_crux_handler (void) uae_u32 data = SBASEVAL16(1) + data1; FINISH_DATA (data, 16, 1); put_sound_word_right (data); - } + } check_sound_buffers (); } @@ -653,7 +653,7 @@ void sample16si_rh_handler (void) uae_u32 data = SBASEVAL16(1) + data1; FINISH_DATA (data, 16, 1); put_sound_word_right (data); - } + } check_sound_buffers (); } @@ -686,7 +686,7 @@ void schedule_audio (void) best = cdp->evtime; eventtab[ev_audio].active = 1; } - } + } } eventtab[ev_audio].evtime = get_cycles () + best; } @@ -840,7 +840,7 @@ static void audio_handler (int nr, int timed) } } return; - + case 3: if (currprefs.produce_sound == 0) cdp->per = PERIOD_MAX; @@ -1011,7 +1011,7 @@ void update_audio (void) best_evtime = audio_channel[2].evtime; if (audio_channel[3].evtime != MAX_EV && best_evtime > audio_channel[3].evtime) best_evtime = audio_channel[3].evtime; - + if (currprefs.produce_sound > 1 && best_evtime > next_sample_evtime) best_evtime = next_sample_evtime; @@ -1061,7 +1061,7 @@ uae_u16 dmacon; void audio_hsync (int dmaaction) { int nr, handle; - + if (currprefs.produce_sound == 0) return; diff --git a/autoconf.c b/autoconf.c index a9082c9a..4a3989dc 100755 --- a/autoconf.c +++ b/autoconf.c @@ -21,7 +21,7 @@ #include "osdep/exectasks.h" /* We'll need a lot of these. */ -#define MAX_TRAPS 4096 +#define MAX_TRAPS 4096 static TrapFunction traps[MAX_TRAPS]; static int trapmode[MAX_TRAPS]; static const char *trapstr[MAX_TRAPS]; @@ -37,7 +37,7 @@ int lasttrap; /* Stack management */ -/* The mechanism for doing m68k calls from native code is as follows: +/* The mechanism for doing m68k calls from native code is as follows: * * m68k code executes, stack is main * calltrap to execute_fn_on_extra_stack. new stack is allocated diff --git a/blitter.c b/blitter.c index d6c61b2a..3bf706de 100755 --- a/blitter.c +++ b/blitter.c @@ -583,7 +583,7 @@ void blitter_handler(void) return; } #ifdef BLITTER_DEBUG - if (!blitter_dontdo) + if (!blitter_dontdo) actually_do_blit(); else bltstate = BLT_done; @@ -623,7 +623,7 @@ STATIC_INLINE uae_u16 blitter_doblit (void) + (blit_filltable[d >> 8][ifemode + fc1][0] << 8)); blitfc = blit_filltable[d >> 8][ifemode + fc1][1]; } - + if (ddat) blt_info.blitzero = 0; @@ -822,7 +822,7 @@ static void blit_bltset (int con) { int i; - blitline = bltcon1 & 1; + blitline = bltcon1 & 1; blitfill = bltcon1 & 0x18; blitdesc = bltcon1 & 2; blit_ch = (bltcon0 & 0x0f00) >> 8; @@ -915,7 +915,7 @@ void do_blitter (int hpos) blit_last_hpos = hpos; blit_cyclecounter = 0; - reset_blit (1|2); + reset_blit (1|2); if (blitline) { blitsing = bltcon1 & 0x2; @@ -1035,7 +1035,7 @@ void blitter_slowdown (int ddfstrt, int ddfstop, int totalcycles, int freecycles { static int oddfstrt, oddfstop, ototal, ofree; static int slow; - + if (!totalcycles || ddfstrt < 0 || ddfstop < 0) return; if (ddfstrt != oddfstrt || ddfstop != oddfstop || totalcycles != ototal || ofree != freecycles) { diff --git a/bsdsocket.c b/bsdsocket.c index 62022feb..85740237 100755 --- a/bsdsocket.c +++ b/bsdsocket.c @@ -234,7 +234,7 @@ SOCKET_TYPE getsock (SB, int sd) { // Task with same name already exists -> use same dtable if (sb1->dtable[sd-1] != INVALID_SOCKET) return sb1->dtable[sd-1]; - } + } nsb = sb1->next; } @@ -340,7 +340,7 @@ static struct socketbase *alloc_socketbase (void) sb->ownertask = gettask (); m68k_dreg (regs, 0) = -1; - sb->signal = CallLib (get_long (4), -0x14A); + sb->signal = CallLib (get_long (4), -0x14A); /* AllocSignal */ if (sb->signal == -1) { write_log ("bsdsocket: ERROR: Couldn't allocate signal for task 0x%lx.\n", sb->ownertask); @@ -374,8 +374,12 @@ static struct socketbase *alloc_socketbase (void) struct socketbase *get_socketbase (void) { - /* @@@ make portable for sizeof(void *) != sizeof(uae_u32) */ - return (struct socketbase *) get_long (m68k_areg (regs, 6) + offsetof (struct UAEBSDBase, sb)); + int i; + uae_u32 p[sizeof(void*) / 4]; + + for (i = 0; i < (sizeof p) / 4; i++) + p[i] = get_long (m68k_areg (regs, 6) + offsetof (struct UAEBSDBase, sb) + i * 4); + return *((struct socketbase**)p); } static void free_socketbase (void) @@ -452,8 +456,9 @@ static uae_u32 functable, datatable, inittable; static uae_u32 bsdsocklib_Open (void) { uae_u32 result = 0; - int opencount; + int opencount, i; SB; + uae_u32 p[sizeof (void*) / 4]; locksigqueue (); @@ -467,10 +472,11 @@ static uae_u32 bsdsocklib_Open (void) m68k_areg (regs, 2) = 0; m68k_dreg (regs, 0) = sizeof (struct UAEBSDBase); m68k_dreg (regs, 1) = 0; - result = CallLib (get_long (4), -0x54); + result = CallLib (get_long (4), -0x54); /* MakeLibrary */ - /* @@@ make portable for sizeof(void *) != sizeof(uae_u32) */ - put_long (result + offsetof (struct UAEBSDBase, sb), (uae_u32) sb); + *((struct socketbase**)p) = sb; + for (i = 0; i < (sizeof p) / 4; i++) + put_long(result + offsetof (struct UAEBSDBase, sb) + i * 4, p[i]); TRACE (("%0lx [%d]\n", result, opencount)); } else @@ -564,7 +570,7 @@ static uae_u32 bsdsocklib_recvfrom (void) return sb->resultval; } -/* recv(s, buf, len, flags)(d0/a0/d1/d2) */ +/* recv(s, buf, len, flags)(d0/a0/d1/d2) */ static uae_u32 bsdsocklib_recv (void) { SB = get_socketbase (); @@ -970,10 +976,10 @@ static const char * const strErr = "Errlist lookup error"; uae_u32 strErrptr; -#define TAG_DONE (0L) /* terminates array of TagItems. ti_Data unused */ -#define TAG_IGNORE (1L) /* ignore this item, not end of array */ +#define TAG_DONE (0L) /* terminates array of TagItems. ti_Data unused */ +#define TAG_IGNORE (1L) /* ignore this item, not end of array */ #define TAG_MORE (2L) /* ti_Data is pointer to another array of TagItems */ -#define TAG_SKIP (3L) /* skip this and the next ti_Data items */ +#define TAG_SKIP (3L) /* skip this and the next ti_Data items */ #define TAG_USER ((uae_u32)(1L<<31)) #define SBTF_VAL 0x0000 @@ -1231,26 +1237,20 @@ static uae_u32 bsdsocklib_init (void) m68k_areg (regs, 0) = functable; m68k_areg (regs, 1) = datatable; m68k_areg (regs, 2) = 0; - m68k_dreg (regs, 0) = LIBRARY_SIZEOF; + m68k_dreg (regs, 0) = sizeof (struct UAEBSDBase); m68k_dreg (regs, 1) = 0; - tmp1 = CallLib (m68k_areg (regs, 6), -0x54); + tmp1 = CallLib (m68k_areg (regs, 6), -0x54); /* MakeLibrary */ if (!tmp1) { write_log ("bsdoscket: FATAL: Cannot create bsdsocket.library!\n"); return 0; } m68k_areg (regs, 1) = tmp1; - CallLib (m68k_areg (regs, 6), -0x18c); + CallLib (m68k_areg (regs, 6), -0x18c); /* AddLibrary */ SockLibBase = tmp1; -#if 0 - m68k_areg (regs, 1) = ds ("dos.library"); - m68k_dreg (regs, 0) = 0; - dosbase = CallLib (m68k_areg (regs, 6), -552); - printf ("%08lx\n", dosbase); -#endif /* Install error strings in Amiga memory */ - tmp1 = 0; + tmp1 = 0; for (i = number_sys_error; i--;) tmp1 += strlen (errortexts[i])+1; @@ -1261,7 +1261,7 @@ static uae_u32 bsdsocklib_init (void) m68k_dreg (regs, 0) = tmp1; m68k_dreg (regs, 1) = 0; - tmp1 = CallLib (get_long (4), -0xC6); + tmp1 = CallLib (get_long (4), -0xC6); /* AllocMem */ if (!tmp1) { write_log ("bsdsocket: FATAL: Ran out of memory while creating bsdsocket.library!\n"); diff --git a/cdtv.c b/cdtv.c index dcecbe63..07f569e0 100755 --- a/cdtv.c +++ b/cdtv.c @@ -78,7 +78,7 @@ static uae_u32 dmac_bget2 (uaecptr addr) { case 0x17: /* SCSI STATUS */ return 0x22; - + default: return dmacmemory[0x93]; } diff --git a/cfgfile.c b/cfgfile.c index b12ac21c..d9eb96b3 100755 --- a/cfgfile.c +++ b/cfgfile.c @@ -194,6 +194,19 @@ void cfgfile_write (struct zfile *f, char *format,...) va_end (parms); } +void cfgfile_target_write (struct zfile *f, char *format,...) +{ + va_list parms; + char tmp[CONFIG_BLEN]; + + va_start (parms, format); + vsprintf (tmp + strlen (TARGET_NAME) + 1, format, parms); + memcpy (tmp, TARGET_NAME, strlen (TARGET_NAME)); + tmp[strlen (TARGET_NAME)] = '.'; + zfile_fwrite (tmp, 1, strlen (tmp), f); + va_end (parms); +} + static void save_options (struct zfile *f, struct uae_prefs *p, int type) { struct strlist *sl; @@ -208,7 +221,7 @@ static void save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write (f, "config_version=%d.%d.%d\n", UAEMAJOR, UAEMINOR, UAESUBREV); cfgfile_write (f, "config_hardware_path=%s\n", p->config_hardware_path); cfgfile_write (f, "config_host_path=%s\n", p->config_host_path); - + for (sl = p->all_lines; sl; sl = sl->next) { if (sl->unknown) cfgfile_write (f, "%s=%s\n", sl->option, sl->value); @@ -267,7 +280,7 @@ static void save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write (f, "sound_channels=%s\n", stereomode[p->sound_stereo]); cfgfile_write (f, "sound_stereo_separation=%d\n", p->sound_stereo_separation); cfgfile_write (f, "sound_stereo_mixing_delay=%d\n", p->sound_mixed_stereo >= 0 ? p->sound_mixed_stereo : 0); - + cfgfile_write (f, "sound_max_buff=%d\n", p->sound_maxbsiz); cfgfile_write (f, "sound_frequency=%d\n", p->sound_freq); cfgfile_write (f, "sound_interpol=%s\n", interpolmode[p->sound_interpol]); @@ -282,7 +295,7 @@ static void save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write (f, "comp_nf=%s\n", p->compnf ? "true" : "false"); cfgfile_write (f, "comp_constjump=%s\n", p->comp_constjump ? "true" : "false"); cfgfile_write (f, "comp_oldsegv=%s\n", p->comp_oldsegv ? "true" : "false"); - + cfgfile_write (f, "comp_flushmode=%s\n", flushmode[p->comp_hardflush]); cfgfile_write (f, "compforcesettings=%s\n", p->compforcesettings ? "true" : "false"); cfgfile_write (f, "compfpu=%s\n", p->compfpu ? "true" : "false"); @@ -376,7 +389,6 @@ static void save_options (struct zfile *f, struct uae_prefs *p, int type) #endif cfgfile_write (f, "immediate_blits=%s\n", p->immediate_blits ? "true" : "false"); - cfgfile_write (f, "fast_copper=%s\n", p->fast_copper ? "true" : "false"); cfgfile_write (f, "ntsc=%s\n", p->ntscmode ? "true" : "false"); cfgfile_write (f, "genlock=%s\n", p->genlock ? "true" : "false"); cfgfile_write (f, "show_leds=%s\n", p->leds_on_screen ? "true" : "false"); @@ -451,8 +463,10 @@ int cfgfile_yesno (char *option, char *value, char *name, int *location) else if (strcasecmp (value, "no") == 0 || strcasecmp (value, "n") == 0 || strcasecmp (value, "false") == 0 || strcasecmp (value, "f") == 0) *location = 0; - else + else { write_log ("Option `%s' requires a value of either `yes' or `no'.\n", option); + return -1; + } return 1; } @@ -467,8 +481,10 @@ int cfgfile_intval (char *option, char *value, char *name, int *location, int sc value += 2, base = 16; *location = strtol (value, &endptr, base) * scale; - if (*endptr != '\0' || *value == '\0') + if (*endptr != '\0' || *value == '\0') { write_log ("Option `%s' requires a numeric argument.\n", option); + return -1; + } return 1; } @@ -483,7 +499,7 @@ int cfgfile_strval (char *option, char *value, char *name, int *location, const return 0; write_log ("Unknown value for option `%s'.\n", option); - return 1; + return -1; } *location = val; return 1; @@ -679,7 +695,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value) || cfgfile_strval (option, value, "gfx_color_mode", &p->color_mode, colormode1, 1) || cfgfile_strval (option, value, "gfx_color_mode", &p->color_mode, colormode2, 0)) return 1; - + #ifdef GFXFILTER if (strcmp (option,"gfx_filter") == 0) { @@ -851,7 +867,6 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu char tmpbuf[CONFIG_BLEN]; if (cfgfile_yesno (option, value, "immediate_blits", &p->immediate_blits) - || cfgfile_yesno (option, value, "fast_copper", &p->fast_copper) || cfgfile_yesno (option, value, "kickshifter", &p->kickshifter) || cfgfile_yesno (option, value, "ntsc", &p->ntscmode) || cfgfile_yesno (option, value, "genlock", &p->genlock) @@ -1023,7 +1038,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu char *dname, *aname, *root, *fs; char *tmpp = strchr (value, ','); char *str; - + config_newfilesystem = 1; if (tmpp == 0) goto invalid_fs; @@ -1454,7 +1469,7 @@ static void parse_gfx_specs (struct uae_prefs *p, char *spec) if (p->gfx_linedbl == 3) { write_log ("You can't use both 'd' and 'D' modifiers in the display mode specification.\n"); } - + free (x0); return; @@ -1559,7 +1574,7 @@ static void parse_filesys_spec (int readonly, char *spec) #ifdef __DOS__ { char *tmp; - + while ((tmp = strchr (s2, '\\'))) *tmp = '/'; } @@ -1574,7 +1589,7 @@ static void parse_filesys_spec (int readonly, char *spec) write_log ("Usage: [-m | -M] VOLNAME:mount_point\n"); } } - + static void parse_hardfile_spec (char *spec) { char *x0 = my_strdup (spec); @@ -1618,7 +1633,7 @@ static void parse_cpu_specs (struct uae_prefs *p, char *spec) write_log ("CPU parameter string must begin with '0', '1', '2', '3' or '4'.\n"); return; } - + p->cpu_level = *spec++ - '0'; p->address_space_24 = p->cpu_level < 2; p->cpu_compatible = 0; @@ -1860,9 +1875,9 @@ int cfgfile_handle_custom_event (char *custom, int mode) cnt_ok++; break; } - } + } } - } + } p = nextp; } xfree (tmp); @@ -1935,7 +1950,7 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u static struct zfile *configstore; static char *configsearch; static int configsearchfound; - + err = 0; argv = 0; p = 0; @@ -2022,7 +2037,7 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u } goto end; } - + if (size > 10000) return 10; p = xmalloc (size + 1); @@ -2114,7 +2129,7 @@ static int configure_rom (struct uae_prefs *p, int *rom, int msg) char tmp1[MAX_DPATH], tmp2[MAX_DPATH]; char *path = 0; int i; - + tmp2[0] = 0; i = 0; while (rom[i] >= 0) { @@ -2234,9 +2249,9 @@ void default_prefs (struct uae_prefs *p, int type) for (i = 0;i < 10; i++) p->optcount[i] = -1; p->optcount[0] = 4; /* How often a block has to be executed before it - is translated */ - p->optcount[1] = 0; /* How often to use the naive translation */ - p->optcount[2] = 0; + * is translated */ + p->optcount[1] = 0; /* How often to use the naive translation */ + p->optcount[2] = 0; p->optcount[3] = 0; p->optcount[4] = 0; p->optcount[5] = 0; @@ -2270,7 +2285,6 @@ void default_prefs (struct uae_prefs *p, int type) p->leds_on_screen = 0; p->keyboard_leds_in_use = 0; p->keyboard_leds[0] = p->keyboard_leds[1] = p->keyboard_leds[2] = 0; - p->fast_copper = 1; p->scsi = 0; p->cpu_idle = 0; p->catweasel = 0; @@ -2379,7 +2393,6 @@ static void buildin_default_prefs (struct uae_prefs *p) p->chipset_mask = CSMASK_ECS_AGNUS; p->immediate_blits = 0; p->collision_level = 2; - p->fast_copper = 1; p->produce_sound = 3; p->scsi = 0; p->cpu_idle = 0; @@ -2431,10 +2444,8 @@ static void set_68000_compa (struct uae_prefs *p, int compa) { case 0: p->cpu_cycle_exact = p->blitter_cycle_exact = 1; - p->fast_copper = 0; break; case 1: - p->fast_copper = 0; break; case 2: p->cpu_compatible = 0; @@ -2462,12 +2473,12 @@ static int bip_a1000 (struct uae_prefs *p, int config, int compa, int romcheck) set_68000_compa (p, compa); p->dfxtype[1] = -1; return configure_rom (p, roms, romcheck); -} +} static int bip_cdtv (struct uae_prefs *p, int config, int compa, int romcheck) { int roms[4]; - + roms[0] = 6; roms[1] = 32; roms[2] = -1; @@ -2490,7 +2501,7 @@ static int bip_cdtv (struct uae_prefs *p, int config, int compa, int romcheck) static int bip_cd32 (struct uae_prefs *p, int config, int compa, int romcheck) { int roms[2]; - + buildin_default_prefs_68020 (p); roms[0] = 18; roms[1] = -1; diff --git a/cia.c b/cia.c index 55316dc2..d18a23e8 100755 --- a/cia.c +++ b/cia.c @@ -698,7 +698,7 @@ static void WriteCIAA (uae_u16 addr,uae_u8 val) #endif ciaadra = val; bfe001_change (); break; case 3: - ciaadrb = val; + ciaadrb = val; #ifdef DONGLE_DEBUG if (notinrom ()) write_log ("BFE301 W %02.2X %s\n", val, debuginfo(0)); @@ -975,7 +975,7 @@ void CIA_reset (void) if (! ersatzkickfile) map_overlay (0); #ifdef SERIAL_PORT - if (currprefs.use_serial && !savestate_state) + if (currprefs.use_serial && !savestate_state) serial_dtr_off (); /* Drop DTR at reset */ #endif if (savestate_state) { @@ -1234,8 +1234,10 @@ static void cdtv_battram_write (int addr, int v) { struct zfile *f; int offset = addr & CDTV_NVRAM_MASK; - if (offset >= CDTV_NVRAM_SIZE) return; - if (cdtv_battram[offset] == v) return; + if (offset >= CDTV_NVRAM_SIZE) + return; + if (cdtv_battram[offset] == v) + return; cdtv_battram[offset] = v; f = zfile_fopen (currprefs.flashfile,"rb+"); if (!f) @@ -1250,8 +1252,9 @@ static uae_u8 cdtv_battram_read (int addr) uae_u8 v; int offset; offset = addr & CDTV_NVRAM_MASK; - if (offset >= CDTV_NVRAM_SIZE) return 0; - v = cdtv_battram[offset]; + if (offset >= CDTV_NVRAM_SIZE) + return 0; + v = cdtv_battram[offset]; return v; } #endif @@ -1380,7 +1383,7 @@ uae_u8 *restore_cia (int num, uae_u8 *src) b = restore_u8 (); /* F CRB */ if (num) ciabcrb = b; else ciaacrb = b; -/* CIA internal data */ + /* CIA internal data */ b = restore_u8 (); /* ICR MASK */ if (num) ciabimask = b; else ciaaimask = b; @@ -1428,7 +1431,7 @@ uae_u8 *save_cia (int num, int *len, uae_u8 *dstptr) b = num ? ciabprb : ciaaprb; /* 1 PRB */ save_u8 (b); b = num ? ciabdra : ciaadra; /* 2 DDRA */ - save_u8 (b); + save_u8 (b); b = num ? ciabdrb : ciaadrb; /* 3 DDRB */ save_u8 (b); t = (num ? ciabta - ciabta_passed : ciaata - ciaata_passed);/* 4 TA */ diff --git a/compemu_raw_x86.c b/compemu_raw_x86.c index 429ebd5a..158db86c 100755 --- a/compemu_raw_x86.c +++ b/compemu_raw_x86.c @@ -66,8 +66,8 @@ uae_u8 need_to_preserve[]={1,1,1,1,0,1,1,1}; #define CLOBBER_SHRL clobber_flags() #define CLOBBER_SHRA clobber_flags() #define CLOBBER_TEST clobber_flags() -#define CLOBBER_CL16 -#define CLOBBER_CL8 +#define CLOBBER_CL16 +#define CLOBBER_CL8 #define CLOBBER_SE16 #define CLOBBER_SE8 #define CLOBBER_ZE16 @@ -83,9 +83,6 @@ uae_u8 need_to_preserve[]={1,1,1,1,0,1,1,1}; * Actual encoding of the instructions on the target CPU * *************************************************************************/ -static int have_cmov=0; /* We need to generate different code if - we don't have cmov */ - #include "compemu_optimizer_x86.c" static uae_u16 swap16(uae_u16 x) @@ -518,7 +515,7 @@ LOWFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc)) } else { /* replacement using branch and mov */ int uncc=(cc^1); - emit_byte(0x70+uncc); + emit_byte(0x70+uncc); emit_byte(2); /* skip next 2 bytes if not cc=true */ emit_byte(0x89); emit_byte(0xc0+8*s+d); @@ -622,7 +619,7 @@ LOWFUNC(NONE,READ,4,raw_mov_l_rrm_indexed,(W4 d,R4 baser, R4 index, IMM factor)) { int isebp=(baser==5)?0x40:0; int fi; - + switch(factor) { case 1: fi=0; break; case 2: fi=1; break; @@ -644,7 +641,7 @@ LOWFUNC(NONE,READ,4,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index, IMM factor) { int fi; int isebp; - + switch(factor) { case 1: fi=0; break; case 2: fi=1; break; @@ -653,7 +650,7 @@ LOWFUNC(NONE,READ,4,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index, IMM factor) default: abort(); } isebp=(baser==5)?0x40:0; - + emit_byte(0x66); emit_byte(0x8b); emit_byte(0x04+8*d+isebp); @@ -698,7 +695,7 @@ LOWFUNC(NONE,WRITE,4,raw_mov_l_mrr_indexed,(R4 baser, R4 index, IMM factor, R4 s default: abort(); } - + isebp=(baser==5)?0x40:0; emit_byte(0x89); @@ -878,7 +875,7 @@ LOWFUNC(NONE,READ,4,raw_mov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor)) case 2: fi=1; break; case 4: fi=2; break; case 8: fi=3; break; - default: + default: fprintf(stderr,"Bad factor %d in mov_l_rm_indexed!\n",factor); abort(); } @@ -897,7 +894,7 @@ LOWFUNC(NONE,READ,5,raw_cmov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor, case 2: fi=1; break; case 4: fi=2; break; case 8: fi=3; break; - default: + default: fprintf(stderr,"Bad factor %d in mov_l_rm_indexed!\n",factor); abort(); } @@ -910,7 +907,7 @@ LOWFUNC(NONE,READ,5,raw_cmov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor, } else { /* replacement using branch and mov */ int uncc=(cond^1); - emit_byte(0x70+uncc); + emit_byte(0x70+uncc); emit_byte(7); /* skip next 7 bytes if not cc=true */ emit_byte(0x8b); emit_byte(0x04+8*d); @@ -930,7 +927,7 @@ LOWFUNC(NONE,READ,3,raw_cmov_l_rm,(W4 d, IMM mem, IMM cond)) } else { /* replacement using branch and mov */ int uncc=(cond^1); - emit_byte(0x70+uncc); + emit_byte(0x70+uncc); emit_byte(6); /* skip next 6 bytes if not cc=true */ emit_byte(0x8b); emit_byte(0x05+8*d); @@ -1053,7 +1050,7 @@ LENDFUNC(NONE,NONE,3,raw_lea_l_brr,(W4 d, R4 s, IMM offset)) LOWFUNC(NONE,NONE,5,raw_lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset)) { int fi; - + switch(factor) { case 1: fi=0; break; case 2: fi=1; break; @@ -1073,7 +1070,7 @@ LOWFUNC(NONE,NONE,4,raw_lea_l_rr_indexed,(W4 d, R4 s, R4 index, IMM factor)) { int isebp=(s==5)?0x40:0; int fi; - + switch(factor) { case 1: fi=0; break; case 2: fi=1; break; @@ -1219,16 +1216,16 @@ LOWFUNC(RMW,RMW,2,raw_adc_l_mi,(MEMRW d, IMM s)) } LENDFUNC(RMW,RMW,2,raw_adc_l_mi,(MEMRW d, IMM s)) -LOWFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s)) +LOWFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s)) { emit_byte(0x81); emit_byte(0x05); emit_long(d); emit_long(s); } -LENDFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s)) +LENDFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s)) -LOWFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s)) +LOWFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s)) { emit_byte(0x66); emit_byte(0x81); @@ -1236,16 +1233,16 @@ LOWFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s)) emit_long(d); emit_word(s); } -LENDFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s)) +LENDFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s)) -LOWFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s)) +LOWFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s)) { emit_byte(0x80); emit_byte(0x05); emit_long(d); emit_byte(s); } -LENDFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s)) +LENDFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s)) LOWFUNC(WRITE,NONE,2,raw_test_l_ri,(R4 d, IMM i)) { @@ -1538,7 +1535,7 @@ LENDFUNC(WRITE,NONE,2,raw_cmp_b,(R1 d, R1 s)) LOWFUNC(WRITE,READ,4,raw_cmp_l_rm_indexed,(R4 d, IMM offset, R4 index, IMM factor)) { int fi; - + switch(factor) { case 1: fi=0; break; case 2: fi=1; break; @@ -1697,45 +1694,45 @@ static __inline__ void raw_jnz(uae_u32 t) static __inline__ void raw_jnz_l_oponly(void) { lopt_emit_all(); - emit_byte(0x0f); - emit_byte(0x85); + emit_byte(0x0f); + emit_byte(0x85); } static __inline__ void raw_jcc_l_oponly(int cc) { lopt_emit_all(); - emit_byte(0x0f); - emit_byte(0x80+cc); + emit_byte(0x0f); + emit_byte(0x80+cc); } static __inline__ void raw_jnz_b_oponly(void) { lopt_emit_all(); - emit_byte(0x75); + emit_byte(0x75); } static __inline__ void raw_jz_b_oponly(void) { lopt_emit_all(); - emit_byte(0x74); + emit_byte(0x74); } static __inline__ void raw_jmp_l_oponly(void) { lopt_emit_all(); - emit_byte(0xe9); + emit_byte(0xe9); } static __inline__ void raw_jmp_b_oponly(void) { lopt_emit_all(); - emit_byte(0xeb); + emit_byte(0xeb); } static __inline__ void raw_ret(void) { lopt_emit_all(); - emit_byte(0xc3); + emit_byte(0xc3); } static __inline__ void raw_nop(void) @@ -1756,8 +1753,8 @@ static __inline__ void raw_flags_to_reg(int r) { raw_lahf(0); /* Most flags in AH */ //raw_setcc(r,0); /* V flag in AL */ - raw_setcc_m((uae_u32)live.state[FLAGTMP].mem,0); - + raw_setcc_m((uae_u32)live.state[FLAGTMP].mem,0); + #if 1 /* Let's avoid those nasty partial register stalls */ //raw_mov_b_mr((uae_u32)live.state[FLAGTMP].mem,r); raw_mov_b_mr(((uae_u32)live.state[FLAGTMP].mem)+1,r+4); @@ -1845,6 +1842,13 @@ static int in_handler=0; static uae_u8 *veccode; #ifdef _WIN32 + +#if defined(CPU_64_BIT) +#define ctxPC (pContext->Rip) +#else +#define ctxPC (pContext->Eip) +#endif + int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) { PEXCEPTION_RECORD pExceptRecord = NULL; @@ -1859,14 +1863,14 @@ int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) int j; if( n_except != STATUS_ACCESS_VIOLATION || !canbang) - return EXCEPTION_CONTINUE_SEARCH; + return EXCEPTION_CONTINUE_SEARCH; pExceptRecord = blah->ExceptionRecord; pContext = blah->ContextRecord; if( pContext ) { - i = (uae_u8 *)(pContext->Eip); + i = (uae_u8 *)ctxPC; } if( pExceptRecord ) { @@ -1875,7 +1879,7 @@ int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) #ifdef JIT_DEBUG write_log("JIT: fault address is 0x%x at 0x%x\n",addr,i); #endif - if (!canbang || !currprefs.cachesize) + if (!canbang || !currprefs.cachesize) { #ifdef JIT_DEBUG write_log("JIT: Not happy! Canbang or cachesize is 0 in SIGSEGV handler!\n"); @@ -1883,16 +1887,16 @@ int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) return EXCEPTION_CONTINUE_SEARCH; } - if (in_handler) + if (in_handler) write_log("JIT: Argh --- Am already in a handler. Shouldn't happen!\n"); - + if (canbang && i>=compiled_code && i<=current_compile_p) { if (*i==0x66) { i++; size=2; len++; } - + switch(i[0]) { case 0x8a: if ((i[1]&0xc0)==0x80) { @@ -1929,7 +1933,7 @@ int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) dir=SIG_READ; len+=2; break; - default: + default: break; } break; @@ -1952,16 +1956,32 @@ int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) break; } break; - } + } } - - if (r!=-1) { + + if (r!=-1) { void* pr=NULL; #ifdef JIT_DEBUG write_log("register was %d, direction was %d, size was %d\n",r,dir,size); #endif switch(r) { +#if defined(CPU_64_BIT) + case 0: pr=&(pContext->Rax); break; + case 1: pr=&(pContext->Rcx); break; + case 2: pr=&(pContext->Rdx); break; + case 3: pr=&(pContext->Rbx); break; + case 4: pr=(size>1)?NULL:(((uae_u8*)&(pContext->Rax))+1); break; + case 5: pr=(size>1)? + (void*)(&(pContext->Rbp)): + (void*)(((uae_u8*)&(pContext->Rcx))+1); break; + case 6: pr=(size>1)? + (void*)(&(pContext->Rsi)): + (void*)(((uae_u8*)&(pContext->Rdx))+1); break; + case 7: pr=(size>1)? + (void*)(&(pContext->Rdi)): + (void*)(((uae_u8*)&(pContext->Rbx))+1); break; +#else case 0: pr=&(pContext->Eax); break; case 1: pr=&(pContext->Ecx); break; case 2: pr=&(pContext->Edx); break; @@ -1976,19 +1996,20 @@ int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) case 7: pr=(size>1)? (void*)(&(pContext->Edi)): (void*)(((uae_u8*)&(pContext->Ebx))+1); break; +#endif default: abort(); } if (pr) { blockinfo* bi; - + if (currprefs.comp_oldsegv) { addr-=(uae_u32)NATMEM_OFFSET; - + #ifdef JIT_DEBUG if ((addr>=0x10000000 && addr<0x40000000) || (addr>=0x50000000)) { write_log("Suspicious address 0x%x in SEGV handler.\n",addr); - } + } #endif if (dir==SIG_READ) { switch(size) { @@ -2011,23 +2032,23 @@ int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) #endif fflush(stdout); segvcount++; - pContext->Eip+=len; + ctxPC+=len; } else { void* tmp=target; int i; uae_u8 vecbuf[5]; - + addr-=(uae_u32)NATMEM_OFFSET; - + #ifdef JIT_DEBUG if ((addr>=0x10000000 && addr<0x40000000) || (addr>=0x50000000)) { write_log("Suspicious address 0x%x in SEGV handler.\n",addr); - } + } #endif - - target=(uae_u8*)pContext->Eip; + + target=(uae_u8*)ctxPC; for (i=0;i<5;i++) vecbuf[i]=target[i]; emit_byte(0xe9); @@ -2038,9 +2059,9 @@ int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) write_log("Handled one access!\n"); #endif segvcount++; - + target=veccode; - + if (dir==SIG_READ) { switch(size) { case 1: raw_mov_b_ri(r,get_byte(addr)); break; @@ -2058,16 +2079,16 @@ int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) } } for (i=0;i<5;i++) - raw_mov_b_mi(pContext->Eip+i,vecbuf[i]); + raw_mov_b_mi(ctxPC+i,vecbuf[i]); raw_mov_l_mi((uae_u32)&in_handler,0); emit_byte(0xe9); - emit_long(pContext->Eip+len-(uae_u32)target-4); + emit_long(ctxPC+len-(uae_u32)target-4); in_handler=1; target=tmp; } bi=active; while (bi) { - if (bi->handler && + if (bi->handler && (uae_u8*)bi->direct_handler<=i && (uae_u8*)bi->nexthandler>i) { #ifdef JIT_DEBUG @@ -2088,7 +2109,7 @@ int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ) is in the dormant list */ bi=dormant; while (bi) { - if (bi->handler && + if (bi->handler && (uae_u8*)bi->direct_handler<=i && (uae_u8*)bi->nexthandler>i) { #ifdef JIT_DEBUG @@ -2135,11 +2156,11 @@ static void vec(int x, struct sigcontext sc) int dir=-1; int len=0; int j; - + write_log("fault address is %08x at %08x\n",sc.cr2,sc.eip); - if (!canbang) + if (!canbang) write_log("Not happy! Canbang is 0 in SIGSEGV handler!\n"); - if (in_handler) + if (in_handler) write_log("Argh --- Am already in a handler. Shouldn't happen!\n"); if (canbang && i>=compiled_code && i<=current_compile_p) { @@ -2148,7 +2169,7 @@ static void vec(int x, struct sigcontext sc) size=2; len++; } - + switch(i[0]) { case 0x8a: if ((i[1]&0xc0)==0x80) { @@ -2186,11 +2207,11 @@ static void vec(int x, struct sigcontext sc) dir=SIG_READ; len+=2; break; - default: + default: break; } break; - + case 0x89: switch(i[1]&0xc0) { case 0x80: @@ -2210,13 +2231,13 @@ static void vec(int x, struct sigcontext sc) break; } break; - } + } } - if (r!=-1) { + if (r!=-1) { void* pr=NULL; write_log("register was %d, direction was %d, size was %d\n",r,dir,size); - + switch(r) { case 0: pr=&(sc.eax); break; case 1: pr=&(sc.ecx); break; @@ -2239,7 +2260,7 @@ static void vec(int x, struct sigcontext sc) if (currprefs.comp_oldsegv) { addr-=NATMEM_OFFSET; - + if ((addr>=0x10000000 && addr<0x40000000) || (addr>=0x50000000)) { write_log("Suspicious address in %x SEGV handler.\n",addr); @@ -2269,14 +2290,14 @@ static void vec(int x, struct sigcontext sc) void* tmp=target; int i; uae_u8 vecbuf[5]; - + addr-=NATMEM_OFFSET; - + if ((addr>=0x10000000 && addr<0x40000000) || (addr>=0x50000000)) { write_log("Suspicious address 0x%x in SEGV handler.\n",addr); } - + target=(uae_u8*)sc.eip; for (i=0;i<5;i++) vecbuf[i]=target[i]; @@ -2287,7 +2308,7 @@ static void vec(int x, struct sigcontext sc) write_log("Handled one access!\n"); fflush(stdout); segvcount++; - + target=veccode; if (dir==SIG_READ) { @@ -2316,7 +2337,7 @@ static void vec(int x, struct sigcontext sc) } bi=active; while (bi) { - if (bi->handler && + if (bi->handler && (uae_u8*)bi->direct_handler<=i && (uae_u8*)bi->nexthandler>i) { write_log("deleted trigger (%p<%p<%p) %p\n", @@ -2335,7 +2356,7 @@ static void vec(int x, struct sigcontext sc) is in the dormant list */ bi=dormant; while (bi) { - if (bi->handler && + if (bi->handler && (uae_u8*)bi->direct_handler<=i && (uae_u8*)bi->nexthandler>i) { write_log("deleted trigger (%p<%p<%p) %p\n", @@ -2369,6 +2390,294 @@ static void vec(int x, struct sigcontext sc) #endif #endif +/************************************************************************* + * Checking for CPU features * + *************************************************************************/ + +struct cpuinfo_x86 { + uae_u8 x86; // CPU family + uae_u8 x86_vendor; // CPU vendor + uae_u8 x86_processor; // CPU canonical processor type + uae_u8 x86_brand_id; // CPU BrandID if supported, yield 0 otherwise + uae_u32 x86_hwcap; + uae_u8 x86_model; + uae_u8 x86_mask; + int cpuid_level; // Maximum supported CPUID level, -1=no CPUID + char x86_vendor_id[16]; +}; +struct cpuinfo_x86 cpuinfo; + +enum { + X86_VENDOR_INTEL = 0, + X86_VENDOR_CYRIX = 1, + X86_VENDOR_AMD = 2, + X86_VENDOR_UMC = 3, + X86_VENDOR_NEXGEN = 4, + X86_VENDOR_CENTAUR = 5, + X86_VENDOR_RISE = 6, + X86_VENDOR_TRANSMETA = 7, + X86_VENDOR_NSC = 8, + X86_VENDOR_UNKNOWN = 0xff +}; + +enum { + X86_PROCESSOR_I386, /* 80386 */ + X86_PROCESSOR_I486, /* 80486DX, 80486SX, 80486DX[24] */ + X86_PROCESSOR_PENTIUM, + X86_PROCESSOR_PENTIUMPRO, + X86_PROCESSOR_K6, + X86_PROCESSOR_ATHLON, + X86_PROCESSOR_PENTIUM4, + X86_PROCESSOR_K8, + X86_PROCESSOR_max +}; + +static const char * x86_processor_string_table[X86_PROCESSOR_max] = { + "80386", + "80486", + "Pentium", + "PentiumPro", + "K6", + "Athlon", + "Pentium4", + "K8" +}; + +static struct ptt { + const int align_loop; + const int align_loop_max_skip; + const int align_jump; + const int align_jump_max_skip; + const int align_func; +} +x86_alignments[X86_PROCESSOR_max] = { + { 4, 3, 4, 3, 4 }, + { 16, 15, 16, 15, 16 }, + { 16, 7, 16, 7, 16 }, + { 16, 15, 16, 7, 16 }, + { 32, 7, 32, 7, 32 }, + { 16, 7, 16, 7, 16 }, + { 0, 0, 0, 0, 0 }, + { 16, 7, 16, 7, 16 } +}; + +static void +x86_get_cpu_vendor(struct cpuinfo_x86 *c) +{ + char *v = c->x86_vendor_id; + + if (!strcmp(v, "GenuineIntel")) + c->x86_vendor = X86_VENDOR_INTEL; + else if (!strcmp(v, "AuthenticAMD")) + c->x86_vendor = X86_VENDOR_AMD; + else if (!strcmp(v, "CyrixInstead")) + c->x86_vendor = X86_VENDOR_CYRIX; + else if (!strcmp(v, "Geode by NSC")) + c->x86_vendor = X86_VENDOR_NSC; + else if (!strcmp(v, "UMC UMC UMC ")) + c->x86_vendor = X86_VENDOR_UMC; + else if (!strcmp(v, "CentaurHauls")) + c->x86_vendor = X86_VENDOR_CENTAUR; + else if (!strcmp(v, "NexGenDriven")) + c->x86_vendor = X86_VENDOR_NEXGEN; + else if (!strcmp(v, "RiseRiseRise")) + c->x86_vendor = X86_VENDOR_RISE; + else if (!strcmp(v, "GenuineTMx86") || + !strcmp(v, "TransmetaCPU")) + c->x86_vendor = X86_VENDOR_TRANSMETA; + else + c->x86_vendor = X86_VENDOR_UNKNOWN; +} + +static void cpuid(uae_u32 op, uae_u32 *eax, uae_u32 *ebx, uae_u32 *ecx, uae_u32 *edx) +{ + const int CPUID_SPACE = 4096; + uae_u8* cpuid_space = cache_alloc(CPUID_SPACE); + static uae_u32 s_op, s_eax, s_ebx, s_ecx, s_edx; + uae_u8* tmp=get_target(); + + s_op = op; + set_target(cpuid_space); + raw_push_l_r(0); /* eax */ + raw_push_l_r(1); /* ecx */ + raw_push_l_r(2); /* edx */ + raw_push_l_r(3); /* ebx */ + raw_mov_l_rm(0,(uintptr)&s_op); + raw_cpuid(0); + raw_mov_l_mr((uintptr)&s_eax,0); + raw_mov_l_mr((uintptr)&s_ebx,3); + raw_mov_l_mr((uintptr)&s_ecx,1); + raw_mov_l_mr((uintptr)&s_edx,2); + raw_pop_l_r(3); + raw_pop_l_r(2); + raw_pop_l_r(1); + raw_pop_l_r(0); + raw_ret(); + set_target(tmp); + + ((cpuop_func*)cpuid_space)(0); + if (eax != NULL) *eax = s_eax; + if (ebx != NULL) *ebx = s_ebx; + if (ecx != NULL) *ecx = s_ecx; + if (edx != NULL) *edx = s_edx; + + cache_free (cpuid_space); +} + +static void raw_init_cpu(void) +{ + struct cpuinfo_x86 *c = &cpuinfo; + uae_u32 xlvl; + + /* Defaults */ + c->x86_processor = X86_PROCESSOR_max; + c->x86_vendor = X86_VENDOR_UNKNOWN; + c->cpuid_level = -1; /* CPUID not detected */ + c->x86_model = c->x86_mask = 0; /* So far unknown... */ + c->x86_vendor_id[0] = '\0'; /* Unset */ + c->x86_hwcap = 0; + + /* Get vendor name */ + c->x86_vendor_id[12] = '\0'; + cpuid(0x00000000, + (uae_u32 *)&c->cpuid_level, + (uae_u32 *)&c->x86_vendor_id[0], + (uae_u32 *)&c->x86_vendor_id[8], + (uae_u32 *)&c->x86_vendor_id[4]); + x86_get_cpu_vendor(c); + + /* Intel-defined flags: level 0x00000001 */ + c->x86_brand_id = 0; + if ( c->cpuid_level >= 0x00000001 ) { + uae_u32 tfms, brand_id; + cpuid(0x00000001, &tfms, &brand_id, NULL, &c->x86_hwcap); + c->x86 = (tfms >> 8) & 15; + c->x86_model = (tfms >> 4) & 15; + c->x86_brand_id = brand_id & 0xff; + if ( (c->x86_vendor == X86_VENDOR_AMD) && + (c->x86 == 0xf)) { + /* AMD Extended Family and Model Values */ + c->x86 += (tfms >> 20) & 0xff; + c->x86_model += (tfms >> 12) & 0xf0; + } + c->x86_mask = tfms & 15; + } else { + /* Have CPUID level 0 only - unheard of */ + c->x86 = 4; + } + + /* AMD-defined flags: level 0x80000001 */ + cpuid(0x80000000, &xlvl, NULL, NULL, NULL); + if ( (xlvl & 0xffff0000) == 0x80000000 ) { + if ( xlvl >= 0x80000001 ) { + uae_u32 features; + cpuid(0x80000001, NULL, NULL, NULL, &features); + if (features & (1 << 29)) { + /* Assume x86-64 if long mode is supported */ + c->x86_processor = X86_PROCESSOR_K8; + } + } + } + + /* Canonicalize processor ID */ + switch (c->x86) { + case 3: + c->x86_processor = X86_PROCESSOR_I386; + break; + case 4: + c->x86_processor = X86_PROCESSOR_I486; + break; + case 5: + if (c->x86_vendor == X86_VENDOR_AMD) + c->x86_processor = X86_PROCESSOR_K6; + else + c->x86_processor = X86_PROCESSOR_PENTIUM; + break; + case 6: + if (c->x86_vendor == X86_VENDOR_AMD) + c->x86_processor = X86_PROCESSOR_ATHLON; + else + c->x86_processor = X86_PROCESSOR_PENTIUMPRO; + break; + case 15: + if (c->x86_vendor == X86_VENDOR_INTEL) { + /* Assume any BrandID >= 8 and family == 15 yields a Pentium 4 */ + if (c->x86_brand_id >= 8) + c->x86_processor = X86_PROCESSOR_PENTIUM4; + } + if (c->x86_vendor == X86_VENDOR_AMD) { + /* Assume an Athlon processor if family == 15 and it was not + detected as an x86-64 so far */ + if (c->x86_processor == X86_PROCESSOR_max) + c->x86_processor = X86_PROCESSOR_ATHLON; + } + break; + } + if (c->x86_processor == X86_PROCESSOR_max) { + write_log ("Error: unknown processor type\n"); + write_log ("..Family : %d\n", c->x86); + write_log ("..Model : %d\n", c->x86_model); + write_log ("..Mask : %d\n", c->x86_mask); + write_log (" Vendor : %s [%d]\n", c->x86_vendor_id, c->x86_vendor); + if (c->x86_brand_id) + write_log(" BrandID : %02x\n", c->x86_brand_id); + abort(); + } + + /* Have CMOV support? */ + have_cmov = c->x86_hwcap & (1 << 15); + + /* Can the host CPU suffer from partial register stalls? */ + have_rat_stall = (c->x86_vendor == X86_VENDOR_INTEL); +#if 1 + /* It appears that partial register writes are a bad idea even on + AMD K7 cores, even though they are not supposed to have the + dreaded rat stall. Why? Anyway, that's why we lie about it ;-) */ + if (c->x86_processor == X86_PROCESSOR_ATHLON) + have_rat_stall = 1; +#endif + + /* Alignments */ + if (tune_alignment) { + align_loops = x86_alignments[c->x86_processor].align_loop; + align_jumps = x86_alignments[c->x86_processor].align_jump; + } + + write_log("Max CPUID level=%d Processor is %s [%s]\n", + c->cpuid_level, c->x86_vendor_id, + x86_processor_string_table[c->x86_processor]); +} + +#if 0 +static int target_check_bsf(void) +{ + int mismatch = 0; + for (int g_ZF = 0; g_ZF <= 1; g_ZF++) { + for (int g_CF = 0; g_CF <= 1; g_CF++) { + for (int g_OF = 0; g_OF <= 1; g_OF++) { + for (int g_SF = 0; g_SF <= 1; g_SF++) { + for (int value = -1; value <= 1; value++) { + unsigned long flags = (g_SF << 7) | (g_OF << 11) | (g_ZF << 6) | g_CF; + unsigned long tmp = value; + __asm__ __volatile__ ("push %0; popf; bsf %1,%1; pushf; pop %0" + : "+r" (flags), "+r" (tmp) : : "cc"); + int OF = (flags >> 11) & 1; + int SF = (flags >> 7) & 1; + int ZF = (flags >> 6) & 1; + int CF = flags & 1; + tmp = (value == 0); + if (ZF != tmp || SF != g_SF || OF != g_OF || CF != g_CF) + mismatch = true; + } + }}}} + if (mismatch) + write_log("Target CPU defines all flags on BSF instruction\n"); + return !mismatch; +} +#endif + +#if 0 + /************************************************************************* * Checking for CPU features * *************************************************************************/ @@ -2427,7 +2736,7 @@ static void raw_init_cpu(void) { x86_regs x; uae_u32 maxlev; - + x=cpuid(0); maxlev=x.eax; write_log("Max CPUID level=%d Processor is %c%c%c%c%c%c%c%c%c%c%c%c\n", @@ -2449,7 +2758,7 @@ static void raw_init_cpu(void) if (maxlev>=1) { x=cpuid(1); - if (x.edx&(1<<15)) + if (x.edx&(1<<15)) have_cmov=1; } have_rat_stall=1; @@ -2479,6 +2788,7 @@ static void raw_init_cpu(void) have_rat_stall=1; #endif } +#endif /************************************************************************* * FPU stuff * @@ -2488,7 +2798,7 @@ static void raw_init_cpu(void) static __inline__ void raw_fp_init(void) { int i; - + for (i=0;i=0) { - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap with temp-reg */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0xf4); /* add -12 to esp */ - emit_byte(0xdb); - emit_byte(0x3c); - emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap with temp-reg */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0xf4); /* add -12 to esp */ + emit_byte(0xdb); + emit_byte(0x3c); + emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ } emit_byte(0xd9); emit_byte(0xe0); /* fchs -x*log2(e) */ @@ -3348,20 +3658,20 @@ LOWFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s)) emit_byte(0xdd); emit_byte(0xd9); /* fstp copy e^x & pop */ if (tr>=0) { - emit_byte(0xdb); - emit_byte(0x2c); - emit_byte(0x24); /* fld load temp-reg from [esp] */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0x0c); /* add +12 to esp */ - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ - emit_byte(0xde); - emit_byte(0xe9); /* fsubp (e^x)-(e^-x) */ + emit_byte(0xdb); + emit_byte(0x2c); + emit_byte(0x24); /* fld load temp-reg from [esp] */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0x0c); /* add +12 to esp */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ + emit_byte(0xde); + emit_byte(0xe9); /* fsubp (e^x)-(e^-x) */ } else { - emit_byte(0xde); - emit_byte(0xe1); /* fsubrp (e^x)-(e^-x) */ + emit_byte(0xde); + emit_byte(0xe1); /* fsubrp (e^x)-(e^-x) */ } emit_byte(0xd9); emit_byte(0xe8); /* fld 1.0 */ @@ -3376,7 +3686,7 @@ LOWFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s)) tos_make(d); /* store y=sinh(x) */ } LENDFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s)) - + LOWFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) { int ds,tr; @@ -3392,14 +3702,14 @@ LOWFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) emit_byte(0xdd); emit_byte(0xd1); /* fst copy x*log2(e) */ if (tr>=0) { - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap with temp-reg */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0xf4); /* add -12 to esp */ - emit_byte(0xdb); - emit_byte(0x3c); - emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap with temp-reg */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0xf4); /* add -12 to esp */ + emit_byte(0xdb); + emit_byte(0x3c); + emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ } emit_byte(0xd9); emit_byte(0xe0); /* fchs -x*log2(e) */ @@ -3438,14 +3748,14 @@ LOWFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) emit_byte(0xdd); emit_byte(0xd9); /* fstp copy e^x & pop */ if (tr>=0) { - emit_byte(0xdb); - emit_byte(0x2c); - emit_byte(0x24); /* fld load temp-reg from [esp] */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0x0c); /* add +12 to esp */ - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ + emit_byte(0xdb); + emit_byte(0x2c); + emit_byte(0x24); /* fld load temp-reg from [esp] */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0x0c); /* add +12 to esp */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ } emit_byte(0xde); emit_byte(0xc1); /* faddp (e^x)+(e^-x) */ @@ -3462,7 +3772,7 @@ LOWFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) tos_make(d); /* store y=cosh(x) */ } LENDFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) - + LOWFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s)) { int ds,tr; @@ -3478,14 +3788,14 @@ LOWFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s)) emit_byte(0xdd); emit_byte(0xd1); /* fst copy x*log2(e) */ if (tr>=0) { - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap with temp-reg */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0xf4); /* add -12 to esp */ - emit_byte(0xdb); - emit_byte(0x3c); - emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap with temp-reg */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0xf4); /* add -12 to esp */ + emit_byte(0xdb); + emit_byte(0x3c); + emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ } emit_byte(0xd9); emit_byte(0xe0); /* fchs -x*log2(e) */ @@ -3530,20 +3840,20 @@ LOWFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s)) emit_byte(0xde); emit_byte(0xe9); /* fsubp (e^x)-(e^-x) */ if (tr>=0) { - emit_byte(0xdb); - emit_byte(0x2c); - emit_byte(0x24); /* fld load temp-reg from [esp] */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0x0c); /* add +12 to esp */ - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ - emit_byte(0xde); - emit_byte(0xf9); /* fdivp ((e^x)-(e^-x))/((e^x)+(e^-x)) */ + emit_byte(0xdb); + emit_byte(0x2c); + emit_byte(0x24); /* fld load temp-reg from [esp] */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0x0c); /* add +12 to esp */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ + emit_byte(0xde); + emit_byte(0xf9); /* fdivp ((e^x)-(e^-x))/((e^x)+(e^-x)) */ } else { - emit_byte(0xde); - emit_byte(0xf1); /* fdivrp ((e^x)-(e^-x))/((e^x)+(e^-x)) */ + emit_byte(0xde); + emit_byte(0xf1); /* fdivrp ((e^x)-(e^-x))/((e^x)+(e^-x)) */ } tos_make(d); /* store y=tanh(x) */ } @@ -3565,7 +3875,7 @@ LOWFUNC(NONE,NONE,2,raw_fneg_rr,(FW d, FR s)) make_tos(d); emit_byte(0xd9); emit_byte(0xe0); /* take fchs */ - } + } } LENDFUNC(NONE,NONE,2,raw_fneg_rr,(FW d, FR s)) @@ -3582,7 +3892,7 @@ LOWFUNC(NONE,NONE,2,raw_fadd_rr,(FRW d, FR s)) else { make_tos(d); ds=stackpos(s); - + emit_byte(0xd8); emit_byte(0xc0+ds); /* add source to dest*/ } @@ -3592,7 +3902,7 @@ LENDFUNC(NONE,NONE,2,raw_fadd_rr,(FRW d, FR s)) LOWFUNC(NONE,NONE,2,raw_fsub_rr,(FRW d, FR s)) { int ds; - + if (live.spos[s]==live.tos) { /* Source is on top of stack */ ds=stackpos(d); @@ -3602,7 +3912,7 @@ LOWFUNC(NONE,NONE,2,raw_fsub_rr,(FRW d, FR s)) else { make_tos(d); ds=stackpos(s); - + emit_byte(0xd8); emit_byte(0xe0+ds); /* sub src from dest */ } @@ -3612,7 +3922,7 @@ LENDFUNC(NONE,NONE,2,raw_fsub_rr,(FRW d, FR s)) LOWFUNC(NONE,NONE,2,raw_fcmp_rr,(FR d, FR s)) { int ds; - + make_tos(d); ds=stackpos(s); @@ -3624,7 +3934,7 @@ LENDFUNC(NONE,NONE,2,raw_fcmp_rr,(FR d, FR s)) LOWFUNC(NONE,NONE,2,raw_fmul_rr,(FRW d, FR s)) { int ds; - + if (live.spos[s]==live.tos) { /* Source is on top of stack */ ds=stackpos(d); @@ -3634,7 +3944,7 @@ LOWFUNC(NONE,NONE,2,raw_fmul_rr,(FRW d, FR s)) else { make_tos(d); ds=stackpos(s); - + emit_byte(0xd8); emit_byte(0xc8+ds); /* mul dest by source*/ } @@ -3644,7 +3954,7 @@ LENDFUNC(NONE,NONE,2,raw_fmul_rr,(FRW d, FR s)) LOWFUNC(NONE,NONE,2,raw_fdiv_rr,(FRW d, FR s)) { int ds; - + if (live.spos[s]==live.tos) { /* Source is on top of stack */ ds=stackpos(d); @@ -3654,7 +3964,7 @@ LOWFUNC(NONE,NONE,2,raw_fdiv_rr,(FRW d, FR s)) else { make_tos(d); ds=stackpos(s); - + emit_byte(0xd8); emit_byte(0xf0+ds); /* div dest by source*/ } @@ -3666,18 +3976,18 @@ LOWFUNC(NONE,NONE,2,raw_frem_rr,(FRW d, FR s)) int ds; if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) { - //write_log ("frem found x in TOS-1 and y in TOS\n"); - emit_byte(0xd9); - emit_byte(0xf8); /* fprem rem(y/x) */ + //write_log ("frem found x in TOS-1 and y in TOS\n"); + emit_byte(0xd9); + emit_byte(0xf8); /* fprem rem(y/x) */ } else { - make_tos(s); /* tos=x */ - ds=stackpos(d); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld y */ - emit_byte(0xd9); - emit_byte(0xf8); /* fprem rem(y/x) */ - tos_make(d); /* store y=rem(y/x) */ + make_tos(s); /* tos=x */ + ds=stackpos(d); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld y */ + emit_byte(0xd9); + emit_byte(0xf8); /* fprem rem(y/x) */ + tos_make(d); /* store y=rem(y/x) */ } } LENDFUNC(NONE,NONE,2,raw_frem_rr,(FRW d, FR s)) @@ -3687,18 +3997,18 @@ LOWFUNC(NONE,NONE,2,raw_frem1_rr,(FRW d, FR s)) int ds; if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) { - //write_log ("frem1 found x in TOS-1 and y in TOS\n"); - emit_byte(0xd9); - emit_byte(0xf5); /* fprem1 rem1(y/x) */ + //write_log ("frem1 found x in TOS-1 and y in TOS\n"); + emit_byte(0xd9); + emit_byte(0xf5); /* fprem1 rem1(y/x) */ } else { - make_tos(s); /* tos=x */ - ds=stackpos(d); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld y */ - emit_byte(0xd9); - emit_byte(0xf5); /* fprem1 rem1(y/x) */ - tos_make(d); /* store y=rem(y/x) */ + make_tos(s); /* tos=x */ + ds=stackpos(d); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld y */ + emit_byte(0xd9); + emit_byte(0xf5); /* fprem1 rem1(y/x) */ + tos_make(d); /* store y=rem(y/x) */ } } LENDFUNC(NONE,NONE,2,raw_frem1_rr,(FRW d, FR s)) @@ -3724,17 +4034,17 @@ static __inline__ void raw_fflags_into_flags(int r) emit_byte(0xd9); emit_byte(0xc9+p); /* swap top two around */ if (have_cmov) { - // gb-- fucomi is for P6 cores only, not K6-2 then... + // gb-- fucomi is for P6 cores only, not K6-2 then... emit_byte(0xdb); emit_byte(0xe9+p); /* fucomi them */ } else { - emit_byte(0xdd); - emit_byte(0xe1+p); /* fucom them */ - emit_byte(0x9b); - emit_byte(0xdf); - emit_byte(0xe0); /* fstsw ax */ - raw_sahf(0); /* sahf */ + emit_byte(0xdd); + emit_byte(0xe1+p); /* fucom them */ + emit_byte(0x9b); + emit_byte(0xdf); + emit_byte(0xe0); /* fstsw ax */ + raw_sahf(0); /* sahf */ } emit_byte(0xdd); emit_byte(0xd9+p); /* store value back, and get rid of 0 */ diff --git a/compemu_support.c b/compemu_support.c index a79fdef9..88af2db4 100755 --- a/compemu_support.c +++ b/compemu_support.c @@ -3,7 +3,6 @@ #define readmem_special readmem #define USE_MATCHSTATE 0 -#define setzflg_uses_bsf 0 #include "sysconfig.h" #include "sysdeps.h" #include "config.h" @@ -48,7 +47,17 @@ static uae_u8* current_compile_p=NULL; static uae_u8* max_compile_start; uae_u8* compiled_code=NULL; static uae_s32 reg_alloc_run; -static int have_rat_stall=0; + +static int lazy_flush = 1; // Flag: lazy translation cache invalidation +static int avoid_fpu = 1; // Flag: compile FPU instructions ? +static int have_cmov = 0; // target has CMOV instructions ? +static int have_rat_stall = 1; // target has partial register stalls ? +const int tune_alignment = 1; // Tune code alignments for running CPU ? +const int tune_nop_fillers = 1; // Tune no-op fillers for architecture + +static int setzflg_uses_bsf = 0; // setzflg virtual instruction can use native BSF instruction correctly? +static int align_loops = 32; // Align the start of loops +static int align_jumps = 32; // Align the start of jumps void* pushall_call_handler=NULL; static void* popall_do_nothing=NULL; @@ -120,7 +129,7 @@ uae_u32 m68k_pc_offset; /* Some arithmetic ooperations can be optimized away if the operands are known to be constant. But that's only a good idea when the side effects they would have on the flags are not important. This - variable indicates whether we need the side effects or not + variable indicates whether we need the side effects or not */ uae_u32 needflags=0; @@ -131,7 +140,7 @@ uae_u32 needflags=0; Then again, sometimes we do x86 instructions that clobber the x86 flags, but don't represent a corresponding m68k instruction. In that - case, we have to save them. + case, we have to save them. We used to save them to the stack, but now store them back directly into the regflags.cznv of the traditional emulation. Thus some odd @@ -144,7 +153,7 @@ uae_u32 needflags=0; track of the respective states. To make things worse, we might or might not be interested in the flags. - by default, we are, but a call to dont_care_flags can change that + by default, we are, but a call to dont_care_flags can change that until the next call to live_flags. If we are not, pretty much whatever is in the register and/or the native flags is seen as valid. */ @@ -167,7 +176,7 @@ static __inline__ blockinfo* get_blockinfo_addr(void* addr) return NULL; } - + /******************************************************************* * All sorts of list related functions for all of the lists * *******************************************************************/ @@ -176,19 +185,19 @@ static __inline__ void remove_from_cl_list(blockinfo* bi) { uae_u32 cl=cacheline(bi->pc_p); - if (bi->prev_same_cl_p) + if (bi->prev_same_cl_p) *(bi->prev_same_cl_p)=bi->next_same_cl; if (bi->next_same_cl) bi->next_same_cl->prev_same_cl_p=bi->prev_same_cl_p; - if (cache_tags[cl+1].bi) + if (cache_tags[cl+1].bi) cache_tags[cl].handler=cache_tags[cl+1].bi->handler_to_use; - else + else cache_tags[cl].handler=popall_execute_normal; } static __inline__ void remove_from_list(blockinfo* bi) { - if (bi->prev_p) + if (bi->prev_p) *(bi->prev_p)=bi->next; if (bi->next) bi->next->prev_p=bi->prev_p; @@ -203,7 +212,7 @@ static __inline__ void remove_from_lists(blockinfo* bi) static __inline__ void add_to_cl_list(blockinfo* bi) { uae_u32 cl=cacheline(bi->pc_p); - + if (cache_tags[cl+1].bi) cache_tags[cl+1].bi->prev_same_cl_p=&(bi->next_same_cl); bi->next_same_cl=cache_tags[cl+1].bi; @@ -222,7 +231,7 @@ static __inline__ void raise_in_cl_list(blockinfo* bi) static __inline__ void add_to_active(blockinfo* bi) { - if (active) + if (active) active->prev_p=&(bi->next); bi->next=active; @@ -232,7 +241,7 @@ static __inline__ void add_to_active(blockinfo* bi) static __inline__ void add_to_dormant(blockinfo* bi) { - if (dormant) + if (dormant) dormant->prev_p=&(bi->next); bi->next=dormant; @@ -242,7 +251,7 @@ static __inline__ void add_to_dormant(blockinfo* bi) static __inline__ void remove_dep(dependency* d) { - if (d->prev_p) + if (d->prev_p) *(d->prev_p)=d->next; if (d->next) d->next->prev_p=d->prev_p; @@ -277,7 +286,7 @@ static __inline__ void set_dhtu(blockinfo* bi, void* dh) //printf("x is %p\n",x); //printf("x->next is %p\n",x->next); //printf("x->prev_p is %p\n",x->prev_p); - + if (x->jmp_off) { adjust_jmpdep(x,dh); } @@ -309,7 +318,7 @@ static __inline__ void invalidate_block(blockinfo* bi) static __inline__ void create_jmpdep(blockinfo* bi, int i, uae_u32* jmpaddr, uae_u32 target) { blockinfo* tbi=get_blockinfo_addr((void*)target); - + Dif(!tbi) { printf("Could not create jmpdep!\n"); abort(); @@ -317,7 +326,7 @@ static __inline__ void create_jmpdep(blockinfo* bi, int i, uae_u32* jmpaddr, uae bi->dep[i].jmp_off=jmpaddr; bi->dep[i].target=tbi; bi->dep[i].next=tbi->deplist; - if (bi->dep[i].next) + if (bi->dep[i].next) bi->dep[i].next->prev_p=&(bi->dep[i].next); bi->dep[i].prev_p=&(tbi->deplist); tbi->deplist=&(bi->dep[i]); @@ -341,9 +350,9 @@ static __inline__ void big_to_small_state(bigstate* b, smallstate* s) } } printf("count=%d\n",count); - for (i=0;inat[i].dirtysize=0; - } + } } static __inline__ void attached_state(blockinfo* bi) @@ -361,21 +370,21 @@ static __inline__ blockinfo* get_blockinfo_addr_new(void* addr, int setstate) int i; #if USE_OPTIMIZER - if (reg_alloc_run) + if (reg_alloc_run) return NULL; #endif if (!bi) { for (i=0;ipc_p=addr; invalidate_block(bi); add_to_active(bi); add_to_cl_list(bi); - + } } } @@ -396,7 +405,7 @@ static __inline__ blockinfo* get_blockinfo_addr_new(void* addr, int setstate) static void prepare_block(blockinfo* bi); -static __inline__ void alloc_blockinfos(void) +static __inline__ void alloc_blockinfos(void) { int i; blockinfo* bi; @@ -406,7 +415,7 @@ static __inline__ void alloc_blockinfos(void) return; bi=hold_bi[i]=(blockinfo*)current_compile_p; current_compile_p+=sizeof(blockinfo); - + prepare_block(bi); } } @@ -440,7 +449,7 @@ void check_prefs_changed_comp (void) currprefs.comp_midopt=changed_prefs.comp_midopt; currprefs.comp_lowopt=changed_prefs.comp_lowopt; - if ( ( !canbang || !currprefs.cachesize ) && + if ( ( !canbang || !currprefs.cachesize ) && currprefs.comptrustbyte != 1 ) { // Set all of these to indirect when canbang == 0 @@ -465,21 +474,21 @@ void check_prefs_changed_comp (void) if (!currprefs.compforcesettings && !have_done_picasso) { int stop=0; - if (currprefs.comptrustbyte!=0 && currprefs.comptrustbyte!=3) + if (currprefs.comptrustbyte!=0 && currprefs.comptrustbyte!=3) stop = 1, write_log(" : comptrustbyte is not 'direct' or 'afterpic'\n"); - if (currprefs.comptrustword!=0 && currprefs.comptrustword!=3) + if (currprefs.comptrustword!=0 && currprefs.comptrustword!=3) stop = 1, write_log(" : comptrustword is not 'direct' or 'afterpic'\n"); - if (currprefs.comptrustlong!=0 && currprefs.comptrustlong!=3) + if (currprefs.comptrustlong!=0 && currprefs.comptrustlong!=3) stop = 1, write_log(" : comptrustlong is not 'direct' or 'afterpic'\n"); - if (currprefs.comptrustnaddr!=0 && currprefs.comptrustnaddr!=3) + if (currprefs.comptrustnaddr!=0 && currprefs.comptrustnaddr!=3) stop = 1, write_log(" : comptrustnaddr is not 'direct' or 'afterpic'\n"); - if (currprefs.compnf!=1) + if (currprefs.compnf!=1) stop = 1, write_log(" : compnf is not 'yes'\n"); - if (currprefs.cachesize<1024) + if (currprefs.cachesize<1024) stop = 1, write_log(" : cachesize is less than 1024\n"); - if (currprefs.comp_hardflush) + if (currprefs.comp_hardflush) stop = 1, write_log(" : comp_flushmode is 'hard'\n"); - if (!canbang) + if (!canbang) stop = 1, write_log(" : Cannot use most direct memory access,\n" " and unable to recover from failed guess!\n"); #if 0 @@ -536,7 +545,7 @@ static __inline__ uae_u32 reverse32(uae_u32 oldv) ((oldv<<8)&0xff0000) | ((oldv<<24)&0xff000000); } - + void set_target(uae_u8* t) { lopt_emit_all(); @@ -682,7 +691,7 @@ static __inline__ void log_flush(void) static __inline__ void log_dump(void) { int i; - + return; write_log("----------------------\n"); @@ -732,7 +741,7 @@ static void tomem(int r) live.nat[rr].nholds==1 && !live.nat[rr].locked) { // printf("RemovingA offset %x from reg %d (%d) at %p\n", - // live.state[r].val,r,rr,target); + // live.state[r].val,r,rr,target); adjust_nreg(rr,live.state[r].val); live.state[r].val=0; live.state[r].dirtysize=4; @@ -870,7 +879,7 @@ static int alloc_reg_hinted(int r, int size, int willclobber, int hint) badness=live.nat[i].touched; if (live.nat[i].nholds==0) badness=0; - if (i==hint) + if (i==hint) badness-=200000000; if (!live.nat[i].locked && badness0) + if (nd>0) free_nreg(d); raw_mov_l_rr(d,s); @@ -1040,11 +1049,11 @@ static __inline__ void make_exclusive(int r, int size, int spec) return; for (i=0;i=size) { n=live.state[r].realreg; switch(size) { - case 1: - if (live.nat[n].canbyte || spec>=0) { - answer=n; + case 1: + if (live.nat[n].canbyte || spec>=0) { + answer=n; } break; - case 2: - if (live.nat[n].canword || spec>=0) { - answer=n; + case 2: + if (live.nat[n].canword || spec>=0) { + answer=n; } break; - case 4: - answer=n; + case 4: + answer=n; break; default: abort(); } if (answer<0) evict(r); } - /* either the value was in memory to start with, or it was evicted and + /* either the value was in memory to start with, or it was evicted and is in memory now */ if (answer<0) { answer=alloc_reg_hinted(r,spec>=0?4:size,0,spec); @@ -1232,21 +1241,21 @@ static __inline__ int writereg_general(int r, int size, int spec) Dif (live.nat[n].nholds!=1) abort(); switch(size) { - case 1: - if (live.nat[n].canbyte || spec>=0) { + case 1: + if (live.nat[n].canbyte || spec>=0) { live.state[r].dirtysize=ndsize; live.state[r].validsize=nvsize; answer=n; } break; - case 2: - if (live.nat[n].canword || spec>=0) { + case 2: + if (live.nat[n].canword || spec>=0) { live.state[r].dirtysize=ndsize; live.state[r].validsize=nvsize; answer=n; } break; - case 4: + case 4: live.state[r].dirtysize=ndsize; live.state[r].validsize=nvsize; answer=n; @@ -1256,7 +1265,7 @@ static __inline__ int writereg_general(int r, int size, int spec) if (answer<0) evict(r); } - /* either the value was in memory to start with, or it was evicted and + /* either the value was in memory to start with, or it was evicted and is in memory now */ if (answer<0) { answer=alloc_reg_hinted(r,size,1,spec); @@ -1269,7 +1278,7 @@ static __inline__ int writereg_general(int r, int size, int spec) live.state[r].validsize=4; live.state[r].dirtysize=size>live.state[r].dirtysize?size:live.state[r].dirtysize; live.state[r].validsize=size>live.state[r].validsize?size:live.state[r].validsize; - + live.nat[answer].locked++; live.nat[answer].touched=touchcnt++; if (size==4) { @@ -1299,7 +1308,7 @@ static __inline__ int rmw_general(int r, int wsize, int rsize, int spec) { int n; int answer=-1; - + if (live.state[r].status==UNDEF) { printf("WARNING: Unexpected read of undefined register %d\n",r); } @@ -1316,25 +1325,25 @@ static __inline__ int rmw_general(int r, int wsize, int rsize, int spec) abort(); switch(rsize) { - case 1: - if (live.nat[n].canbyte || spec>=0) { - answer=n; + case 1: + if (live.nat[n].canbyte || spec>=0) { + answer=n; } break; - case 2: - if (live.nat[n].canword || spec>=0) { - answer=n; + case 2: + if (live.nat[n].canword || spec>=0) { + answer=n; } break; - case 4: - answer=n; + case 4: + answer=n; break; default: abort(); } if (answer<0) evict(r); } - /* either the value was in memory to start with, or it was evicted and + /* either the value was in memory to start with, or it was evicted and is in memory now */ if (answer<0) { answer=alloc_reg_hinted(r,spec>=0?4:rsize,0,spec); @@ -1361,12 +1370,12 @@ static __inline__ int rmw_general(int r, int wsize, int rsize, int spec) return answer; } -static int rmw(int r, int wsize, int rsize) +static int rmw(int r, int wsize, int rsize) { return rmw_general(r,wsize,rsize,-1); } -static int rmw_specific(int r, int wsize, int rsize, int spec) +static int rmw_specific(int r, int wsize, int rsize, int spec) { return rmw_general(r,wsize,rsize,spec); } @@ -1391,9 +1400,9 @@ static void f_tomem(int r) { if (live.fate[r].status==DIRTY) { #if USE_LONG_DOUBLE - raw_fmov_ext_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg); + raw_fmov_ext_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg); #else - raw_fmov_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg); + raw_fmov_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg); #endif live.fate[r].status=CLEAN; } @@ -1403,9 +1412,9 @@ static void f_tomem_drop(int r) { if (live.fate[r].status==DIRTY) { #if USE_LONG_DOUBLE - raw_fmov_ext_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg); + raw_fmov_ext_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg); #else - raw_fmov_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg); + raw_fmov_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg); #endif live.fate[r].status=INMEM; } @@ -1520,7 +1529,7 @@ static int f_alloc_reg(int r, int willclobber) } live.fate[r].status=CLEAN; } - else { + else { live.fate[r].status=DIRTY; } live.fate[r].realreg=bestreg; @@ -1551,11 +1560,11 @@ static __inline__ int f_readreg(int r) if (f_isinreg(r)) { n=live.fate[r].realreg; - answer=n; + answer=n; } - /* either the value was in memory to start with, or it was evicted and + /* either the value was in memory to start with, or it was evicted and is in memory now */ - if (answer<0) + if (answer<0) answer=f_alloc_reg(r,0); live.fat[answer].locked++; @@ -1581,7 +1590,7 @@ static __inline__ void f_make_exclusive(int r, int clobber) if (vr!=r && live.fate[vr].status==DIRTY) ndirt++; } - if (!ndirt && !live.fat[rr].locked) { + if (!ndirt && !live.fat[rr].locked) { /* Everything else is clean, so let's keep this register */ for (i=0;i1) + Dif (live.nat[n].nholds>1) abort(); if (live.nat[n].nholds && depthnat[i].validsize) + for (i=0;inat[i].validsize) vton[s->nat[i].holds]=i; flush_flags(); /* low level */ sync_m68k_pc(); /* mid level */ - + /* We don't do FREGS yet, so this is raw flush() code */ for (i=0;i0) free_nreg(i); - for (i=0;i0) f_free_nreg(i); @@ -5061,7 +5070,7 @@ static void writemem_real(int address, int source, int offset, int size, int tmp if (clobber) f=source; switch(size) { - case 1: mov_b_bRr(address,source,NATMEM_OFFSETX); break; + case 1: mov_b_bRr(address,source,NATMEM_OFFSETX); break; case 2: mov_w_rr(f,source); bswap_16(f); mov_w_bRr(address,f,NATMEM_OFFSETX); break; case 4: mov_l_rr(f,source); bswap_32(f); mov_l_bRr(address,f,NATMEM_OFFSETX); break; } @@ -5154,7 +5163,7 @@ void writeword(int address, int source, int tmp) writeword_general(address,source,tmp,0); } -static __inline__ void writelong_general(int address, int source, int tmp, +static __inline__ void writelong_general(int address, int source, int tmp, int clobber) { int distrust; @@ -5190,7 +5199,7 @@ void writelong(int address, int source, int tmp) static void readmem_real(int address, int dest, int offset, int size, int tmp) { - int f=tmp; + int f=tmp; if (size==4 && address!=dest) f=dest; @@ -5198,7 +5207,7 @@ static void readmem_real(int address, int dest, int offset, int size, int tmp) #ifdef NATMEM_OFFSET if (canbang) { /* Woohoo! go directly at the memory! */ switch(size) { - case 1: mov_b_brR(dest,address,NATMEM_OFFSETX); break; + case 1: mov_b_brR(dest,address,NATMEM_OFFSETX); break; case 2: mov_w_brR(dest,address,NATMEM_OFFSETX); bswap_16(dest); break; case 4: mov_l_brR(dest,address,NATMEM_OFFSETX); bswap_32(dest); break; } @@ -5211,7 +5220,7 @@ static void readmem_real(int address, int dest, int offset, int size, int tmp) shrl_l_ri(f,16); /* The index into the baseaddr table */ mov_l_rm_indexed(f,(uae_u32)baseaddr,f,4); /* f now holds the offset */ - + switch(size) { case 1: mov_b_rrm_indexed(dest,address,f,1); break; case 2: mov_w_rrm_indexed(dest,address,f,1); bswap_16(dest); break; @@ -5352,7 +5361,7 @@ void get_n_addr_jmp(int address, int dest, int tmp) } -/* base is a register, but dp is an actual value. +/* base is a register, but dp is an actual value. target is a register, as is tmp */ void calc_disp_ea_020(int base, uae_u32 dp, int target, int tmp) { @@ -5364,7 +5373,7 @@ void calc_disp_ea_020(int base, uae_u32 dp, int target, int tmp) int ignorereg=(dp&0x40); int addbase=0; int outer=0; - + if ((dp & 0x30) == 0x20) addbase = (uae_s32)(uae_s16)comp_get_iword((m68k_pc_offset+=2)-2); if ((dp & 0x30) == 0x30) addbase = comp_get_ilong((m68k_pc_offset+=4)-4); @@ -5373,7 +5382,7 @@ void calc_disp_ea_020(int base, uae_u32 dp, int target, int tmp) if ((dp & 0x4) == 0) { /* add regd *before* the get_long */ if (!ignorereg) { - if ((dp & 0x800) == 0) + if ((dp & 0x800) == 0) sign_extend_16_rr(target,reg); else mov_l_rr(target,reg); @@ -5397,7 +5406,7 @@ void calc_disp_ea_020(int base, uae_u32 dp, int target, int tmp) if (dp&0x03) readlong(target,target,tmp); if (!ignorereg) { - if ((dp & 0x800) == 0) + if ((dp & 0x800) == 0) sign_extend_16_rr(tmp,reg); else mov_l_rr(tmp,reg); @@ -5483,7 +5492,7 @@ static void calc_checksum(blockinfo* bi, uae_u32* c1, uae_u32* c2) tmp&=(~3); pos=(uae_u32*)tmp; - if (len<0 || len>MAX_CHECKSUM_LEN) { + if (len<0 || len>MAX_CHECKSUM_LEN) { *c1=0; *c2=0; } @@ -5528,7 +5537,7 @@ static void show_checksum(blockinfo* bi) int check_for_cache_miss(void) { blockinfo* bi=get_blockinfo_addr(regs.pc_p); - + if (bi) { int cl=cacheline(regs.pc_p); if (bi!=cache_tags[cl+1].bi) { @@ -5539,7 +5548,7 @@ int check_for_cache_miss(void) return 0; } - + static void recompile_block(void) { /* An existing block's countdown code has expired. We need to make @@ -5547,7 +5556,7 @@ static void recompile_block(void) perceived cache miss... */ blockinfo* bi=get_blockinfo_addr(regs.pc_p); - Dif (!bi) + Dif (!bi) abort(); raise_in_cl_list(bi); execute_normal(); @@ -5572,14 +5581,14 @@ static void cache_miss(void) return; } -static void check_checksum(void) +static void check_checksum(void) { blockinfo* bi=get_blockinfo_addr(regs.pc_p); uae_u32 cl=cacheline(regs.pc_p); blockinfo* bi2=get_blockinfo(cl); uae_u32 c1,c2; - + checksum_count++; /* These are not the droids you are looking for... */ if (!bi) { @@ -5600,7 +5609,7 @@ static void check_checksum(void) else { c1=c2=1; /* Make sure it doesn't match */ } - if (c1==bi->c1 && c2==bi->c2) { + if (c1==bi->c1 && c2==bi->c2) { /* This block is still OK. So we reactivate. Of course, that means we have to move it into the needs-to-be-flushed list */ bi->handler_to_use=bi->handler; @@ -5642,7 +5651,7 @@ static __inline__ void create_popalls(void) } raw_jmp((uae_u32)do_nothing); align_target(32); - + popall_execute_normal=get_target(); for (i=0;ipc_p); - if (!bi->handler) { + if (!bi->handler) { /* invalidated block */ - if (bi==cache_tags[cl+1].bi) + if (bi==cache_tags[cl+1].bi) cache_tags[cl].handler=popall_execute_normal; bi->handler_to_use=popall_execute_normal; set_dhtu(bi,bi->direct_pen); } else { - if (bi==cache_tags[cl+1].bi) + if (bi==cache_tags[cl+1].bi) cache_tags[cl].handler=popall_check_checksum; bi->handler_to_use=popall_check_checksum; set_dhtu(bi,bi->direct_pcc); @@ -5964,7 +5973,7 @@ void flush_icache(int n) bi2->next=dormant; if (dormant) dormant->prev_p=&(bi2->next); - + dormant=active; active->prev_p=&dormant; active=NULL; @@ -6007,8 +6016,8 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) optlev=bi->optlevel; if (bi->handler) { - Dif (bi!=bi2) { - /* I don't think it can happen anymore. Shouldn't, in + Dif (bi!=bi2) { + /* I don't think it can happen anymore. Shouldn't, in any case. So let's make sure... */ printf("WOOOWOO count=%d, ol=%d %p %p\n", bi->count,bi->optlevel,bi->handler_to_use, @@ -6020,7 +6029,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) /* What the heck? We are not supposed to be here! */ abort(); } - } + } if (bi->count==-1) { optlev++; while (!currprefs.optcount[optlev]) @@ -6028,11 +6037,11 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) bi->count=currprefs.optcount[optlev]-1; } current_block_pc_p=(uae_u32)pc_hist[0].location; - + remove_deps(bi); /* We are about to create new code */ bi->optlevel=optlev; bi->pc_p=(uae_u8*)pc_hist[0].location; - + liveflags[blocklen]=0x1f; /* All flags needed afterwards */ i=blocklen; while (i--) { @@ -6091,7 +6100,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) if (optlev==0) { /* No need to actually translate */ /* Execute normally without keeping stats */ raw_mov_l_mi((uae_u32)®s.pc_p,(uae_u32)pc_hist[0].location); - raw_jmp((uae_u32)popall_exec_nostats); + raw_jmp((uae_u32)popall_exec_nostats); } else { reg_alloc_run=0; @@ -6105,7 +6114,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) cpuop_func **cputbl; cpuop_func **comptbl; uae_u16 opcode; - + opcode=cft_map((uae_u16)*pc_hist[i].location); special_mem=pc_hist[i].specmem; needed_flags=(liveflags[i+1] & prop[opcode].set_flags); @@ -6121,8 +6130,8 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) cputbl=cpufunctbl; comptbl=compfunctbl; } - - if (comptbl[opcode] && optlev>1) { + + if (comptbl[opcode] && optlev>1) { failure=0; if (!was_comp) { comp_pc_p=(uae_u8*)pc_hist[i].location; @@ -6132,18 +6141,18 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) comptbl[opcode](opcode); freescratch(); - if (!(liveflags[i+1] & FLAG_CZNV)) { + if (!(liveflags[i+1] & FLAG_CZNV)) { /* We can forget about flags */ dont_care_flags(); } -#if INDIVIDUAL_INST +#if INDIVIDUAL_INST flush(1); nop(); flush(1); was_comp=0; #endif } - else + else failure=1; if (failure) { if (was_comp) { @@ -6167,10 +6176,10 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) else { //raw_mov_l_mi((uae_u32)&foink3,(uae_u32)opcode); } - + if (ineeded_flags; - + if (x==0xff || 1) { /* To be on the safe side */ uae_u16* next=(uae_u16*)next_pc_p; uae_u16 op=cft_map(*next); @@ -6198,15 +6207,15 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) x&=(~prop[op].set_flags); x|=prop[op].use_flags; } - + x|=bi2->needed_flags; - if (!(x & FLAG_CZNV)) { + if (!(x & FLAG_CZNV)) { /* We can forget about flags */ dont_care_flags(); extra_len+=2; /* The next instruction now is part of this block */ } - + } #endif @@ -6214,7 +6223,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) uae_u32 t1=next_pc_p; uae_u32 t2=taken_pc_p; int cc=branch_cc; - + uae_u32* branchadd; uae_u32* tba; bigstate tmp; @@ -6263,24 +6272,24 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) raw_mov_l_mi((uae_u32)®s.pc_p,t2); raw_jmp((uae_u32)popall_do_nothing); create_jmpdep(bi,1,tba,t2); - } - else + } + else { if (was_comp) { flush(1); } - + /* Let's find out where next_handler is... */ - if (was_comp && isinreg(PC_P)) { + if (was_comp && isinreg(PC_P)) { int r2; r=live.state[PC_P].realreg; - + if (r==0) r2=1; - else + else r2=0; - + raw_and_l_ri(r,TAGMASK); raw_mov_l_ri(r2,(uae_u32)popall_do_nothing); raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles)); @@ -6302,7 +6311,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) raw_mov_l_mi((uae_u32)®s.pc_p,v); raw_jmp((uae_u32)popall_do_nothing); create_jmpdep(bi,0,tba,v); - } + } else { int r2; @@ -6310,9 +6319,9 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) raw_mov_l_rm(r,(uae_u32)®s.pc_p); if (r==0) r2=1; - else + else r2=0; - + raw_and_l_ri(r,TAGMASK); raw_mov_l_ri(r2,(uae_u32)popall_do_nothing); raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles)); @@ -6322,16 +6331,16 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) } } - if (next_pc_p+extra_len>=max_pcp && - next_pc_p+extra_len=max_pcp && + next_pc_p+extra_lenlen=max_pcp-min_pcp; bi->min_pcp=min_pcp; - + remove_from_list(bi); - if (isinrom(min_pcp) && isinrom(max_pcp)) + if (isinrom(min_pcp) && isinrom(max_pcp)) add_to_dormant(bi); /* No need to checksum it on cache flush. Please don't start changing ROMs in flight! */ @@ -6344,14 +6353,14 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles) align_target(32); current_compile_p=get_target(); - raise_in_cl_list(bi); - bi->nexthandler=current_compile_p; + raise_in_cl_list(bi); + bi->nexthandler=current_compile_p; - /* We will flush soon, anyway, so let's do it now */ - if (current_compile_p>=max_compile_start) - flush_icache_hard(7); + /* We will flush soon, anyway, so let's do it now */ + if (current_compile_p>=max_compile_start) + flush_icache_hard(7); - do_extra_cycles(totcycles); /* for the compilation time */ + do_extra_cycles(totcycles); /* for the compilation time */ } } diff --git a/custom.c b/custom.c index 1d6f6f5a..3ba76e49 100755 --- a/custom.c +++ b/custom.c @@ -101,7 +101,7 @@ static unsigned int total_skipped = 0; STATIC_INLINE void sync_copper (int hpos); /* Events */ - + unsigned long int event_cycles, nextevent, is_lastline, currcycle; long cycles_to_next_event; long max_cycles_to_next_event; @@ -147,7 +147,7 @@ uae_u16 dmacon; uae_u16 adkcon; /* used by audio code */ static uae_u32 cop1lc,cop2lc,copcon; - + int maxhpos = MAXHPOS_PAL; int maxvpos = MAXVPOS_PAL; int minfirstline = VBLANK_ENDLINE_PAL; @@ -299,9 +299,9 @@ static int current_change_set; #ifdef OS_WITHOUT_MEMORY_MANAGEMENT /* sam: Those arrays uses around 7Mb of BSS... That seems */ /* too much for AmigaDOS (uae crashes as soon as one loads */ -/* it. So I use a different strategy here (realloc the */ +/* it. So I use a different strategy here (realloc the */ /* arrays when needed. That strategy might be usefull for */ -/* computer with low memory. */ +/* computer with low memory. */ struct sprite_entry *sprite_entries[2]; struct color_change *color_changes[2]; static int max_sprite_entry = 400; @@ -551,7 +551,7 @@ static int get_maxplanes (int res) return planes[fetchmode * 4 + res]; } -/* Disable bitplane DMA if planes > maxplanes. This is needed e.g. by the +/* Disable bitplane DMA if planes > maxplanes. This is needed e.g. by the Sanity WOC demo (at the "Party Effect"). */ STATIC_INLINE int GET_PLANES_LIMIT (uae_u16 v) { @@ -561,8 +561,8 @@ STATIC_INLINE int GET_PLANES_LIMIT (uae_u16 v) } /* The HRM says 0xD8, but that can't work... */ -#define HARD_DDF_STOP 0xd4 -#define HARD_DDF_START 0x18 +#define HARD_DDF_STOP 0xd4 +#define HARD_DDF_START 0x18 static void add_modulos (void) { @@ -641,7 +641,7 @@ static int fm_maxplane, fm_maxplane_shift; /* The corresponding values, by fetchmode and display resolution. */ static int fetchunits[] = { 8,8,8,0, 16,8,8,0, 32,16,8,0 }; static int fetchstarts[] = { 3,2,1,0, 4,3,2,0, 5,4,3,0 }; -static int fm_maxplanes[] = { 3,2,1,0, 3,3,2,0, 3,3,3,0 }; +static int fm_maxplanes[] = { 3,2,1,0, 3,3,2,0, 3,3,3,0 }; static uae_u8 cycle_diagram_table[3][3][9][32]; static uae_u8 cycle_diagram_free_cycles[3][3][9]; @@ -664,7 +664,7 @@ static void debug_cycle_diagram(void) if (v==0) aa='-'; else if(v>0) aa='1'; else aa='X'; write_log("%c",aa); } - write_log(" %d:%d\n", + write_log(" %d:%d\n", cycle_diagram_free_cycles[fm][res][planes], cycle_diagram_total_cycles[fm][res][planes]); } write_log("\n"); @@ -711,7 +711,7 @@ static void create_cycle_diagram_table(void) } -/* Used by the copper. */ +/* Used by the copper. */ static int estimated_last_fetch_cycle; static int cycle_diagram_shift; @@ -745,13 +745,13 @@ static uae_u32 fetched_aga1[MAX_PLANES]; #endif /* Expansions from bplcon0/bplcon1. */ -static int toscr_res, toscr_res_first, toscr_nr_planes, fetchwidth; +static int toscr_res, toscr_res_first, toscr_nr_planes, fetchwidth; static int toscr_delay1x, toscr_delay2x, toscr_delay1, toscr_delay2; -/* The number of bits left from the last fetched words. +/* The number of bits left from the last fetched words. This is an optimization - conceptually, we have to make sure the result is the same as if toscr is called in each clock cycle. However, to speed this - up, we accumulate display data; this variable keeps track of how much. + up, we accumulate display data; this variable keeps track of how much. Thus, once we do call toscr_nbits (which happens at least every 16 bits), we can do more work at once. */ static int toscr_nbits; @@ -1633,7 +1633,7 @@ static void record_color_change (int hpos, int regno, unsigned long value) curr_color_changes[next_color_change++].value = value; } -typedef int sprbuf_res_t, cclockres_t, hwres_t, bplres_t; +typedef int sprbuf_res_t, cclockres_t, hwres_t, bplres_t; /* handle very rarely needed playfield collision (CLXDAT bit 0) */ static void do_playfield_collisions (void) @@ -1823,7 +1823,7 @@ static void expand_sprres (void) } STATIC_INLINE void record_sprite_1 (uae_u16 *buf, uae_u32 datab, int num, int dbl, - unsigned int mask, int do_collisions, uae_u32 collision_mask) + unsigned int mask, int do_collisions, uae_u32 collision_mask) { int j = 0; while (datab) { @@ -1942,7 +1942,7 @@ static void decide_sprites (int hpos) { int nrs[MAX_SPRITES], posns[MAX_SPRITES]; int count, i; - /* apparantly writes to custom registers happen in the 3/4th of cycle + /* apparantly writes to custom registers happen in the 3/4th of cycle * and sprite xpos comparator sees it immediately */ int point = hpos * 2 - 4; int width = sprite_width; @@ -2004,7 +2004,7 @@ STATIC_INLINE int sprites_differ (struct draw_info *dip, struct draw_info *dip_o if (dip->nr_sprites != dip_old->nr_sprites) return 1; - + if (dip->nr_sprites == 0) return 0; @@ -2027,7 +2027,7 @@ STATIC_INLINE int color_changes_differ (struct draw_info *dip, struct draw_info { if (dip->nr_color_changes != dip_old->nr_color_changes) return 1; - + if (dip->nr_color_changes == 0) return 0; if (memcmp (curr_color_changes + dip->first_color_change, @@ -2454,6 +2454,7 @@ static void COPJMP (int num) if (was_active) events_schedule (); + unset_special (SPCFLAG_COPPER); cop_state.ignore_next = 0; cop_state.state = COP_read1; cop_state.vpos = vpos; @@ -2467,8 +2468,6 @@ static void COPJMP (int num) } else if (oldstrobe != num) { /* dma disabled and accessing both COPxJMPs -> copper stops! */ cop_state.state = COP_stop; - copper_enabled_thisline = 0; - unset_special (SPCFLAG_COPPER); } } @@ -2528,7 +2527,7 @@ static void DMACON (int hpos, uae_u16 v) if (dmaen (DMA_BITPLANE)) maybe_start_bpl_dma (hpos); } - + events_schedule(); } @@ -3391,7 +3390,7 @@ static int isagnus[]= { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 27 0x40 - 0x74 */ 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0, /* 21 */ - 1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0, /* 32 0xa0 - 0xde + 1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0, /* 32 0xa0 - 0xde */ /* BPLxPTH/BPLxPTL */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 16 */ /* BPLCON0-3,BPLMOD1-2 */ @@ -3408,6 +3407,11 @@ static int isagnus[]= { static void dump_copper (char *error, int until_hpos) { + static int warned = 10; + + if (warned < 0) + return; + warned--; write_log("%s: vpos=%d until_hpos=%d\n", error, vpos, until_hpos); write_log("cvcmp=%d chcmp=%d chpos=%d cvpos=%d ci1=%04.4X ci2=%04.4X\n", @@ -3418,31 +3422,22 @@ static void dump_copper (char *error, int until_hpos) static void update_copper (int until_hpos) { - int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); + int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); int c_hpos = cop_state.hpos; if (eventtab[ev_copper].active) { - static int warned; - if (!warned) { - dump_copper ("error1",until_hpos); - warned = 1; - } + dump_copper ("error1",until_hpos); eventtab[ev_copper].active = 0; return; - uae_abort ("update_copper1"); } if (cop_state.state == COP_wait && vp < cop_state.vcmp) { - static int warned; - if (!warned) { - dump_copper ("error2",until_hpos); - warned = 1; - } + dump_copper ("error2",until_hpos); + eventtab[ev_copper].active = 0; copper_enabled_thisline = 0; return; - uae_abort ("update_copper2"); } - + until_hpos &= ~1; if (until_hpos > (maxhpos & ~1)) @@ -3458,7 +3453,7 @@ static void update_copper (int until_hpos) /* So we know about the fetch state. */ decide_line (c_hpos); - + switch (cop_state.state) { case COP_read1_in2: cop_state.state = COP_read1; @@ -3586,7 +3581,7 @@ static void update_copper (int until_hpos) cop_state.hcmp = (cop_state.saved_i1 & cop_state.saved_i2 & 0xFE); vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80); - + if (cop_state.saved_i1 == 0xFFFF && cop_state.saved_i2 == 0xFFFE) { cop_state.state = COP_stop; copper_enabled_thisline = 0; @@ -3817,7 +3812,7 @@ STATIC_INLINE void do_sprites_1 (int num, int cycle, int hpos) } if (s->dmastate && !posctl) { uae_u16 data; - + data = sprite_fetch (s, dma, hpos, cycle, 1); #if SPRITE_DEBUG > 1 if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) { @@ -3853,7 +3848,7 @@ STATIC_INLINE void do_sprites_1 (int num, int cycle, int hpos) } break; case 32: - { + { uae_u16 data32 = sprite_fetch (s, dma, hpos, cycle, 1); if (dma) { if (cycle == 0) @@ -4024,7 +4019,7 @@ static int rpt_vsync (void) } return v; } - + static void framewait (void) { frame_time_t curr_time; @@ -4060,7 +4055,7 @@ void fpscounter_reset (void) static void fpscounter (void) { int now, last; - + now = read_processor_time (); last = now - lastframetime; lastframetime = now; @@ -4140,7 +4135,7 @@ static void vsync_handler (void) if (picasso_on) picasso_handle_vsync (); #endif - + vsync_handle_redraw (lof, lof_changed); if (quit_program > 0) { @@ -4539,6 +4534,10 @@ void customreset (void) dumpcustom (); for (i = 0; i < 8; i++) nr_armed += spr[i].armed != 0; + if (! currprefs.produce_sound) { + eventtab[ev_audio].active = 0; + events_schedule (); + } } expand_sprres (); @@ -4554,14 +4553,14 @@ void customreset (void) void dumpcustom (void) { write_log ("DMACON: %x INTENA: %x INTREQ: %x VPOS: %x HPOS: %x\n", DMACONR(), - (unsigned int)intena, (unsigned int)intreq, (unsigned int)vpos, (unsigned int)current_hpos()); + (unsigned int)intena, (unsigned int)intreq, (unsigned int)vpos, (unsigned int)current_hpos()); write_log ("COP1LC: %08lx, COP2LC: %08lx COPPTR: %08lx\n", (unsigned long)cop1lc, (unsigned long)cop2lc, cop_state.ip); write_log ("DIWSTRT: %04x DIWSTOP: %04x DDFSTRT: %04x DDFSTOP: %04x\n", - (unsigned int)diwstrt, (unsigned int)diwstop, (unsigned int)ddfstrt, (unsigned int)ddfstop); + (unsigned int)diwstrt, (unsigned int)diwstop, (unsigned int)ddfstrt, (unsigned int)ddfstop); write_log ("BPLCON 0: %04x 1: %04x 2: %04x 3: %04x 4: %04x\n", bplcon0, bplcon1, bplcon2, bplcon3, bplcon4); if (timeframes) { write_log ("Average frame time: %f ms [frames: %d time: %d]\n", - (double)frametime / timeframes, timeframes, frametime); + (double)frametime / timeframes, timeframes, frametime); if (total_skipped) write_log ("Skipped frames: %d\n", total_skipped); } @@ -4605,8 +4604,8 @@ void custom_init (void) int num; for (num = 0; num < 2; num++) { - sprite_entries[num] = xmalloc (max_sprite_entry * sizeof (struct sprite_entry)); - color_changes[num] = xmalloc (max_color_change * sizeof (struct color_change)); + sprite_entries[num] = xmalloc (max_sprite_entry * sizeof (struct sprite_entry)); + color_changes[num] = xmalloc (max_color_change * sizeof (struct color_change)); } #endif @@ -4745,7 +4744,7 @@ uae_u32 REGPARAM2 custom_wget (uaecptr addr) } return custom_wget2 (addr); } - + uae_u32 REGPARAM2 custom_bget (uaecptr addr) { #ifdef JIT diff --git a/debug.c b/debug.c index de67bd23..898d97b0 100755 --- a/debug.c +++ b/debug.c @@ -647,7 +647,7 @@ static void memwatch_func (uaecptr addr, int rw, int size, uae_u32 val) } } -static uae_u32 debug_lget (uaecptr addr) +static uae_u32 REGPARAM debug_lget (uaecptr addr) { int off = debug_mem_off (addr); uae_u32 v; @@ -655,7 +655,7 @@ static uae_u32 debug_lget (uaecptr addr) memwatch_func (addr, 0, 4, v); return v; } -static uae_u32 debug_wget (uaecptr addr) +static uae_u32 REGPARAM2 debug_wget (uaecptr addr) { int off = debug_mem_off (addr); uae_u32 v; @@ -663,7 +663,7 @@ static uae_u32 debug_wget (uaecptr addr) memwatch_func (addr, 0, 2, v); return v; } -static uae_u32 debug_bget (uaecptr addr) +static uae_u32 REGPARAM2 debug_bget (uaecptr addr) { int off = debug_mem_off (addr); uae_u32 v; @@ -671,29 +671,29 @@ static uae_u32 debug_bget (uaecptr addr) memwatch_func (addr, 0, 1, v); return v; } -static void debug_lput (uaecptr addr, uae_u32 v) +static void REGPARAM2 debug_lput (uaecptr addr, uae_u32 v) { int off = debug_mem_off (addr); memwatch_func (addr, 1, 4, v); debug_mem_banks[off]->lput(addr, v); } -static void debug_wput (uaecptr addr, uae_u32 v) +static void REGPARAM2 debug_wput (uaecptr addr, uae_u32 v) { int off = debug_mem_off (addr); memwatch_func (addr, 1, 2, v); debug_mem_banks[off]->wput(addr, v); } -static void debug_bput (uaecptr addr, uae_u32 v) +static void REGPARAM2 debug_bput (uaecptr addr, uae_u32 v) { int off = debug_mem_off (addr); memwatch_func (addr, 1, 1, v); debug_mem_banks[off]->bput(addr, v); } -static int debug_check (uaecptr addr, uae_u32 size) +static int REGPARAM2 debug_check (uaecptr addr, uae_u32 size) { return debug_mem_banks[munge24 (addr) >> 16]->check (addr, size); } -static uae_u8 *debug_xlate (uaecptr addr) +static uae_u8 *REGPARAM2 debug_xlate (uaecptr addr) { return debug_mem_banks[munge24 (addr) >> 16]->xlateaddr (addr); } diff --git a/disk.c b/disk.c index 929b299b..dceb7da5 100755 --- a/disk.c +++ b/disk.c @@ -256,7 +256,7 @@ static void disk_date (uae_u8 *p) } p[0] = days >> 24; p[1] = days >> 16; p[2] = days >> 8; p[3] = days >> 0; p[4] = minutes >> 24; p[5] = minutes >> 16; p[6] = minutes >> 8; p[7] = minutes >> 0; - p[8] = ticks >> 24; p[9] = ticks >> 16; p[10] = ticks >> 8; p[11] = ticks >> 0; + p[8] = ticks >> 24; p[9] = ticks >> 16; p[10] = ticks >> 8; p[11] = ticks >> 0; } static void createbootblock (uae_u8 *sector, int bootable) @@ -456,7 +456,7 @@ static int createimagefromexe (struct zfile *src, struct zfile *dst) pl (sector1, 24 + dirhash (dirname1) * 4, dblock1); disk_checksum(sector1, sector1 + 20); writeimageblock (dst, sector1, 880 * FS_FLOPPY_BLOCKSIZE); - + createbitmapblock (sector1, bitmap); writeimageblock (dst, sector1, 881 * FS_FLOPPY_BLOCKSIZE); @@ -482,10 +482,10 @@ static char *drive_id_name(drive *drv) case DRIVE_ID_525SD: return "5.25SD"; case DRIVE_ID_35DD : return "3.5DD"; } - return "UNKNOWN"; + return "UNKNOWN"; } -/* Simulate exact behaviour of an A3000T 3.5 HD disk drive. +/* Simulate exact behaviour of an A3000T 3.5 HD disk drive. * The drive reports to be a 3.5 DD drive whenever there is no * disk or a 3.5 DD disk is inserted. Only 3.5 HD drive id is reported * when a real 3.5 HD disk is inserted. -Adil @@ -692,7 +692,7 @@ char *DISK_get_saveimagepath (const char *name) char name2[MAX_DPATH]; char path[MAX_DPATH]; int i; - + strcpy (name2, name); i = strlen (name2) - 1; while (i > 0) { @@ -768,7 +768,7 @@ static int diskfile_iswriteprotect (const char *fname, int *needwritefile, drive struct zfile *zf1, *zf2; int wrprot1 = 0, wrprot2 = 1; unsigned char buffer[25]; - + *needwritefile = 0; *drvtype = DRV_35_DD; zf1 = DISK_validate_filename (fname, 1, &wrprot1, NULL); @@ -918,7 +918,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char tid->offs = i * 512 * drv->num_secs; } drv->useturbo = 1; - + } else { int i; @@ -950,7 +950,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char drive_fill_bigbuf (drv, 1); drv->mfmpos = (rand () | (rand () << 16)) % drv->tracklen; drv->prevtracklen = 0; -#ifdef DRIVESOUND +#ifdef DRIVESOUND driveclick_insert (drv - floppy, 0); #endif return 1; @@ -1012,7 +1012,7 @@ static void drive_step (drive * drv) if (direction) { if (drv->cyl) { drv->cyl--; -#ifdef DRIVESOUND +#ifdef DRIVESOUND driveclick_click (drv - floppy, drv->cyl); #endif } @@ -1031,7 +1031,7 @@ static void drive_step (drive * drv) } if (drv->cyl >= maxtrack) write_dlog ("program tried to step over track %d\n", maxtrack); -#ifdef DRIVESOUND +#ifdef DRIVESOUND driveclick_click (drv - floppy, drv->cyl); #endif } @@ -1069,7 +1069,7 @@ static void drive_motor (drive * drv, int off) if (drv->motoroff && !off) { drv->dskready_time = DSKREADY_TIME; rand_shifter (drv); -#ifdef DRIVESOUND +#ifdef DRIVESOUND driveclick_motor (drv - floppy, drv->dskready_down_time == 0 ? 2 : 1); #endif #ifdef DISK_DEBUG2 @@ -1081,7 +1081,7 @@ static void drive_motor (drive * drv, int off) if (!drv->motoroff && off) { drv->drive_id_scnt = 0; /* Reset id shift reg counter */ drv->dskready_down_time = DSKREADY_DOWN_TIME; -#ifdef DRIVESOUND +#ifdef DRIVESOUND driveclick_motor (drv - floppy, 0); #endif #ifdef DEBUG_DRIVE_ID @@ -1172,7 +1172,7 @@ static void drive_fill_bigbuf (drive * drv, int force) track_reset (drv); return; } -#endif +#endif } else if (drv->filetype == ADF_IPF) { #ifdef CAPS @@ -1270,7 +1270,7 @@ static void drive_fill_bigbuf (drive * drv, int force) dstmfmbuf[dstmfmoffset % len] = mfmbuf[i]; dstmfmoffset++; } - + } #ifdef DISK_DEBUG @@ -1522,7 +1522,7 @@ static void drive_write_data (drive * drv) static void drive_eject (drive * drv) { -#ifdef DRIVESOUND +#ifdef DRIVESOUND driveclick_insert (drv - floppy, 1); #endif drive_image_free (drv); @@ -1636,7 +1636,7 @@ static void diskfile_readonly (const char *name, int readonly) { struct stat st; int mode, oldmode; - + if (stat (name, &st)) return; oldmode = mode = st.st_mode; @@ -1676,7 +1676,7 @@ int disk_setwriteprotect (int num, const char *name, int protect) int wrprot1, wrprot2, i; char *name2; drive_type drvtype; - + oldprotect = diskfile_iswriteprotect (name, &needwritefile, &drvtype); zf1 = DISK_validate_filename (name, 1, &wrprot1, NULL); if (!zf1) return 0; @@ -1890,7 +1890,7 @@ void DISK_select (uae_u8 data) for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = floppy + dr; /* motor on/off workings tested with small assembler code on real Amiga 1200. */ - /* motor/id flipflop is set only when drive select goes from high to low */ + /* motor/id flipflop is set only when drive select goes from high to low */ if (!(selected & (1 << dr)) && (lastselected & (1 << dr)) ) { drv->drive_id_scnt++; drv->drive_id_scnt &= 31; @@ -1966,7 +1966,7 @@ uae_u8 DISK_status (void) } else if (drv->dskchange && currprefs.dfxtype[dr] != DRV_525_SD) { st &= ~4; } - } + } } return st; } @@ -2028,7 +2028,7 @@ static void disk_dmafinished (void) write_log ("\n"); } #endif -} +} static void fetchnextrevolution (drive *drv) { @@ -2092,7 +2092,7 @@ static void disk_doupdate_write (drive * drv, int floppybits) { int dr; int drives[4]; - + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv2 = &floppy[dr]; drives[dr] = 0; @@ -2298,7 +2298,7 @@ static void disk_doupdate_read (drive * drv, int floppybits) static void disk_dma_debugmsg(void) { - write_dlog ("LEN=%04.4X (%d) SYNC=%04.4X PT=%08.8X ADKCON=%04.4X PC=%08.8X\n", + write_dlog ("LEN=%04.4X (%d) SYNC=%04.4X PT=%08.8X ADKCON=%04.4X PC=%08.8X\n", dsklength, dsklength, (adkcon & 0x400) ? dsksync : 0xffff, dskpt, adkcon, m68k_getpc()); } @@ -2426,7 +2426,7 @@ void DISK_update (int tohpos) for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; - + if (drv->motoroff) continue; drv->floppybitcounter += cycles; @@ -2599,7 +2599,7 @@ void DSKLEN (uae_u16 v, int hpos) linecounter = 2; dskdmaen = 0; return; - } + } } } @@ -2723,7 +2723,7 @@ end: drive_image_free (drv); return ret; } - + /* Disk save/restore code */ diff --git a/drawing.c b/drawing.c index 9348bc33..7d0ba1df 100755 --- a/drawing.c +++ b/drawing.c @@ -113,7 +113,7 @@ union { } pixdata; uae_u16 spixels[2 * MAX_SPR_PIXELS]; -/* Eight bits for every pixel. */ +/* Eight bits for every pixel. */ union sps_union spixstate; static uae_u32 ham_linebuf[MAX_PIXELS_PER_LINE * 2]; @@ -293,7 +293,7 @@ static void pfield_init_linetoscr (void) playfield_start = linetoscr_diw_start; playfield_end = linetoscr_diw_end; - + if (playfield_start < visible_left_border) playfield_start = visible_left_border; if (playfield_start > visible_right_border) @@ -325,7 +325,7 @@ static void pfield_init_linetoscr (void) playfield_end = max; if (playfield_end > visible_right_border) playfield_end = visible_right_border; - } + } #endif /* Now, compute some offsets. */ @@ -837,7 +837,7 @@ STATIC_INLINE void draw_sprites_1 (struct sprite_entry *e, int ham, int dualpf, #if SPRITE_DEBUG > 0 v |= 1 | 4; #endif - + if (has_attach && (stbuf[pos] & (3 << offs))) { col = v; if (aga) @@ -906,8 +906,8 @@ STATIC_INLINE void draw_sprites_1 (struct sprite_entry *e, int ham, int dualpf, window_pos += 1 << doubling; } } - -/* See comments above. Do not touch if you don't know what's going on. + +/* See comments above. Do not touch if you don't know what's going on. * (We do _not_ want the following to be inlined themselves). */ /* lores bitplane, lores sprites */ static void NOINLINE draw_sprites_normal_sp_lo_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 0, 0, 0, 0); } @@ -999,7 +999,7 @@ static void clear_bitplane_border_aga (void) static void weird_bitplane_fix (void) { int i, shift = lores_shift - bplres; - + if (shift < 0) { shift = -shift; for (i = playfield_start << lores_shift; i < playfield_end << lores_shift; i++) { @@ -1080,7 +1080,7 @@ STATIC_INLINE void pfield_doline_1 (uae_u32 *pixels, int wordcount, int planes) } } -/* See above for comments on inlining. These functions should _not_ +/* See above for comments on inlining. These functions should _not_ be inlined themselves. */ static void NOINLINE pfield_doline_n1 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 1); } static void NOINLINE pfield_doline_n2 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 2); } @@ -1156,9 +1156,9 @@ static void init_aspect_maps (void) if (currprefs.gfx_correct_aspect) native_lines_per_amiga_line = ((double)gfxvidinfo.height - * (currprefs.gfx_lores ? 320 : 640) - / (currprefs.gfx_linedbl ? 512 : 256) - / gfxvidinfo.width); + * (currprefs.gfx_lores ? 320 : 640) + / (currprefs.gfx_linedbl ? 512 : 256) + / gfxvidinfo.width); else native_lines_per_amiga_line = 1; @@ -1707,7 +1707,9 @@ static int td_pos = (TD_RIGHT|TD_BOTTOM); #define NUMBERS_NUM 14 -static char *numbers = { /* ugly */ +#define TD_BORDER 0x333 + +static char *numbers = { /* ugly 0123456789CHD% */ "+++++++--++++-+++++++++++++++++-++++++++++++++++++++++++++++++++++++++++++++-++++++-++++----++---+" "+xxxxx+--+xx+-+xxxxx++xxxxx++x+-+x++xxxxx++xxxxx++xxxxx++xxxxx++xxxxx++xxxx+-+x++x+-+xxx++-+xx+-+x" "+x+++x+--++x+-+++++x++++++x++x+++x++x++++++x++++++++++x++x+++x++x+++x++x++++-+x++x+-+x++x+--+x++x+" @@ -1746,7 +1748,7 @@ static void write_tdnumber (int x, int y, int num) { int j; uae_u8 *numptr; - + numptr = numbers + num * TD_NUM_WIDTH + NUMBERS_NUM * TD_NUM_WIDTH * y; for (j = 0; j < TD_NUM_WIDTH; j++) { if (*numptr == 'x') @@ -1760,7 +1762,7 @@ static void write_tdnumber (int x, int y, int num) static void draw_status_line (int line) { int x_start, y, j, led; - + if (td_pos & TD_RIGHT) x_start = gfxvidinfo.width - TD_PADX - NUM_LEDS * TD_WIDTH; else @@ -1771,10 +1773,9 @@ static void draw_status_line (int line) if (xlinebuffer == 0) xlinebuffer = row_map[line]; - memset (xlinebuffer, 0, gfxvidinfo.width * gfxvidinfo.pixbytes); - for (led = 0; led < NUM_LEDS; led++) { - int side, pos, num1 = -1, num2 = -1, num3 = -1, num4 = -1, x, off_rgb, on_rgb, c, on = 0; + int side, pos, num1 = -1, num2 = -1, num3 = -1, num4 = -1; + int x, off_rgb, on_rgb, c, on = 0, am = 2; if (led >= 1 && led <= 4) { int pled = led - 1; int track = gui_data.drive_track[pled]; @@ -1819,6 +1820,9 @@ static void draw_status_line (int line) num1 = fps / 100; num2 = (fps - num1 * 100) / 10; num3 = fps % 10; + am = 3; + if (num1 == 0) + am = 2; } else if (led == 8) { int idle = (gui_data.idle + 5) / 10; pos = 0; @@ -1828,26 +1832,34 @@ static void draw_status_line (int line) num2 = (idle - num1 * 100) / 10; num3 = idle % 10; num4 = 13; + am = 4; + if (num1 == 0) + am = 3; } c = xcolors[on ? on_rgb : off_rgb]; + if (y == 0 || y == TD_TOTAL_HEIGHT - 1) + c = xcolors[TD_BORDER]; x = x_start + pos * TD_WIDTH; - for (j = 0; j < TD_LED_WIDTH; j++) + putpixel (x - 1, xcolors[TD_BORDER]); + for (j = 0; j < TD_LED_WIDTH; j++) putpixel (x + j, c); + putpixel (x + j, xcolors[TD_BORDER]); if (y >= TD_PADY && y - TD_PADY < TD_NUM_HEIGHT) { if (num3 >= 0) { - int tn = num1 > 0 ? 3 : 2; - int offs = (TD_LED_WIDTH - tn * TD_NUM_WIDTH) / 2; + x += (TD_LED_WIDTH - am * TD_NUM_WIDTH) / 2; if (num1 > 0) { - write_tdnumber (x + offs, y - TD_PADY, num1); - offs += TD_NUM_WIDTH; + write_tdnumber (x, y - TD_PADY, num1); + x += TD_NUM_WIDTH; } - write_tdnumber (x + offs, y - TD_PADY, num2); - write_tdnumber (x + offs + TD_NUM_WIDTH, y - TD_PADY, num3); + write_tdnumber (x, y - TD_PADY, num2); + x += TD_NUM_WIDTH; + write_tdnumber (x, y - TD_PADY, num3); + x += TD_NUM_WIDTH; if (num4 > 0) - write_tdnumber (x + offs + 2 * TD_NUM_WIDTH, y - TD_PADY, num4); + write_tdnumber (x, y - TD_PADY, num4); } } } @@ -1879,7 +1891,7 @@ void finish_drawing_frame (void) break; where = amiga2aspect_line_map[i1]; - if (where >= gfxvidinfo.height - (currprefs.leds_on_screen ? TD_TOTAL_HEIGHT : 0)) + if (where >= gfxvidinfo.height) break; if (where == -1) continue; diff --git a/driveclick.c b/driveclick.c index 8dee75a2..5907403e 100755 --- a/driveclick.c +++ b/driveclick.c @@ -127,7 +127,7 @@ static void processclicks(struct drvsample *ds) } else { for(n = nClick; n < CLICK_TRACKS; n++) { ds->indexes[n] = ds->indexes[nClick-1]; - ds->lengths[n] = ds->lengths[nClick-1]; + ds->lengths[n] = ds->lengths[nClick-1]; } } } @@ -266,7 +266,7 @@ static int clickcnt; static void mix (void) { int total = ((uae_u8*)sndbufpt - (uae_u8*)sndbuffer) / (currprefs.sound_stereo ? 4 : 2); - + if (currprefs.dfxclickvolume > 0) { while (clickcnt < total) { clickbuffer[clickcnt++] = getsample() * (100 - currprefs.dfxclickvolume) / 100; diff --git a/enforcer.c b/enforcer.c index f3d2e6f2..918b311b 100755 --- a/enforcer.c +++ b/enforcer.c @@ -381,14 +381,14 @@ uae_u32 REGPARAM2 chipmem_lget2 (uaecptr addr) addr -= chipmem_start & chipmem_mask; addr &= chipmem_mask; m = (uae_u32 *)(chipmemory + addr); - + if (ISILLEGAL(addr)) { enforcer_display_hit("LONG READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr); if (enforcermode==1) { set_special (SPCFLAG_TRAP); - } + } } return do_get_mem_long (m); } @@ -402,12 +402,12 @@ uae_u32 REGPARAM2 chipmem_wget2(uaecptr addr) m = (uae_u16 *)(chipmemory + addr); if (ISILLEGAL(addr)) - { + { enforcer_display_hit("WORD READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr); if (enforcermode==1) { set_special (SPCFLAG_TRAP); - } + } } return do_get_mem_word (m); } diff --git a/ersatz.c b/ersatz.c index 31fc1a15..f68a44c2 100755 --- a/ersatz.c +++ b/ersatz.c @@ -22,7 +22,7 @@ #include "ersatz.h" #include "gui.h" -#define EOP_INIT 0 +#define EOP_INIT 0 #define EOP_NIMP 1 #define EOP_SERVEINT 2 #define EOP_DOIO 3 diff --git a/expansion.c b/expansion.c index d73dda46..a541f589 100755 --- a/expansion.c +++ b/expansion.c @@ -1,4 +1,4 @@ - /* + /* * UAE - The Un*x Amiga Emulator * * AutoConfig (tm) Expansions (ZorroII/III) @@ -140,7 +140,7 @@ static int ecard; /* Please note: ZorroIII implementation seems to work different * than described in the HRM. This claims that ZorroIII config * address is 0xff000000 while the ZorroII config space starts - * at 0x00e80000. In reality, both, Z2 and Z3 cards are + * at 0x00e80000. In reality, both, Z2 and Z3 cards are * configured in the ZorroII config space. Kickstart 3.1 doesn't * even do a single read or write access to the ZorroIII space. * The original Amiga include files tell the same as the HRM. @@ -149,7 +149,7 @@ static int ecard; * to a ZorroIII card on a real Amiga. This is not implemented * yet. * -- Stefan - * + * * Surprising that 0xFF000000 isn't used. Maybe it depends on the * ROM. Anyway, the HRM says that Z3 cards may appear in Z2 config * space, so what we are doing here is correct. @@ -261,7 +261,7 @@ static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value) case 0x44: if (expamem_type() == zorroIII) { // +Bernd Roesch - value = value - 0x3000; // maps to 0x10000000 + value = value - 0x3000; // maps to 0x10000000 chipmem_wput (regs.regs[11] + 0x20, value); chipmem_wput (regs.regs[11] + 0x28, value); // -Bernd Roesch @@ -506,7 +506,7 @@ static addrbank catweasel_bank = { static void expamem_map_catweasel (void) { catweasel_start = ((expamem_hi | (expamem_lo >> 4)) << 16); - map_banks (&catweasel_bank, catweasel_start >> 16, 1, 0); + map_banks (&catweasel_bank, catweasel_start >> 16, 1, 0); write_log ("Catweasel MK%d: mapped @$%lx\n", cwc.type, catweasel_start); } @@ -875,7 +875,7 @@ static void expamem_init_arcadia (void) #endif -/* +/* * Filesystem device */ @@ -1163,7 +1163,7 @@ void expamem_reset (void) #ifdef ARCADIA if (arcadia_rom) { arcadiaboot = mapped_malloc (0x10000, "arcadia"); - arcadia_bank.baseaddr = arcadiaboot; + arcadia_bank.baseaddr = arcadiaboot; card_init[cardno] = expamem_init_arcadia; card_map[cardno++] = expamem_map_arcadia; } diff --git a/fdi2raw.c b/fdi2raw.c index 09fd2ba6..20c314e2 100755 --- a/fdi2raw.c +++ b/fdi2raw.c @@ -19,9 +19,9 @@ any later version. This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. + more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., @@ -385,7 +385,7 @@ static void bit_add (FDI *fdi, int bit) return; } fdi->track_dst[BIT_BYTEOFFSET] &= ~(1 << BIT_BITOFFSET); - if (bit) + if (bit) fdi->track_dst[BIT_BYTEOFFSET] |= (1 << BIT_BITOFFSET); fdi->out++; if (fdi->out >= MAX_DST_BUFFER * 8) { @@ -877,7 +877,7 @@ static void amiga_sector_header (FDI *fdi, uae_u8 *header, uae_u8 *data, int sec static void s20(FDI *fdi) { bit_drop_next (fdi); - debuglog ("s20:header=%s,data=%s", datalog(fdi->track_src, 4), datalog(fdi->track_src + 4, 16)); + debuglog ("s20:header=%s,data=%s", datalog(fdi->track_src, 4), datalog(fdi->track_src + 4, 16)); amiga_sector_header (fdi, fdi->track_src, fdi->track_src + 4, 0, 0); fdi->track_src += 4 + 16; } @@ -1281,7 +1281,7 @@ static void track_pc_36 (struct fdi *fdi) typedef void (*decode_normal_track_func)(FDI*); static decode_normal_track_func decode_normal_track[] = -{ +{ track_empty, /* 0 */ track_amiga_dd, track_amiga_hd, /* 1-2 */ track_atari_st_9, track_atari_st_10, /* 3-4 */ @@ -1378,7 +1378,7 @@ static void dumpstream(int track, uae_u8 *stream, int len) fwrite (stream, 1, len * 4, f); fclose (f); #endif -} +} static int bitoffset; @@ -1407,7 +1407,7 @@ static int totaldiv; static void init_array(unsigned long standard_MFM_2_bit_cell_size, int nb_of_bits) { int i; - + for (i = 0; i < FDI_MAX_ARRAY; i++) { psarray[i].size = standard_MFM_2_bit_cell_size; // That is (total track length / 50000) for Amiga double density total += psarray[i].size; @@ -1527,7 +1527,7 @@ static void fdi2_decode (FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u3 for (j = 0; j < real_size; j++) *pt++ = (uae_u16)(pulse / real_size); } - + /* prepares for the next pulse */ adjust = ((real_size * avg_size)/8) - pulse; total -= psarray[array_index].size; @@ -1684,7 +1684,7 @@ static void fdi2_decode (FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u3 } if (outstep == 1 && indexoffset == i) *indexoffsetp = bitoffset; - } + } /* gets the size in bits from the pulse width, considering the current average bitrate */ adjusted_pulse = pulse; @@ -1771,7 +1771,7 @@ static void fdi2_decode (FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u3 for (j = 0; j < real_size; j++) *pt++ = (uae_u16)(pulse / real_size); } - + /* prepares for the next pulse */ adjust = ((real_size * avg_size) / (4 << mfm)) - pulse; total -= psarray[array_index].size; @@ -1897,7 +1897,7 @@ static int decode_lowlevel_track (FDI *fdi, int track, struct fdi_cache *cache) { while ((i != j) && (p1[idx_off1] > p1[idx_off2])) { /* falling edge, replace with "<" for rising edge */ i++; - p1 += idx_off3; + p1 += idx_off3; if (i >= pulses) { i = 0; p1 = idxp; @@ -2033,7 +2033,7 @@ FDI *fdi2raw_header(struct zfile *f) fdi->track_src_buffer = fdi_malloc (MAX_SRC_BUFFER); fdi->track_dst_buffer = fdi_malloc (MAX_DST_BUFFER); fdi->track_dst_buffer_timing = fdi_malloc (MAX_TIMING_BUFFER); - + fdi->last_track = ((fdi->header[142] << 8) + fdi->header[143]) + 1; fdi->last_track *= fdi->header[144] + 1; if (fdi->last_track > MAX_TRACKS) @@ -2155,7 +2155,7 @@ int fdi2raw_loadtrack (FDI *fdi, uae_u16 *mfmbuf, uae_u16 *tracktiming, int trac zxx (fdi); outlen = -1; - + } else if (fdi->track_type < 0x10) { decode_normal_track[fdi->track_type](fdi); diff --git a/filesys.c b/filesys.c index 6c2475f8..aa2c036c 100755 --- a/filesys.c +++ b/filesys.c @@ -103,7 +103,7 @@ typedef struct { int bootpri; /* boot priority */ int devno; int automounted; /* don't save to config if set */ - + struct hardfiledata hf; /* Threading stuff */ @@ -183,7 +183,7 @@ char *get_filesys_unit (struct uaedev_mount_info *mountinfo, int nr, if (nr >= mountinfo->num_units) return "No slot allocated for this unit"; - + *volname = uip->volname ? my_strdup (uip->volname) : 0; if (uip->devname == 0 || strlen(uip->devname) == 0) { *devname = xmalloc (10); @@ -592,7 +592,7 @@ typedef struct _unit { unsigned long nr_cache_lookups; struct notify *notifyhash[NOTIFY_HASH_SIZE]; - + int volflags; } Unit; @@ -674,7 +674,7 @@ find_unit (uaecptr port) return u; } - + static void prepare_for_open (char *name) { #if 0 @@ -800,7 +800,7 @@ static void update_child_names (Unit *unit, a_inode *a, a_inode *parent) char *name_start; char *new_name; char dirsep[2] = { FSDB_DIR_SEPARATOR, '\0' }; - + a->parent = parent; name_start = strrchr (a->nname, FSDB_DIR_SEPARATOR); if (name_start == 0) { @@ -949,7 +949,7 @@ static char *get_nname (Unit *unit, a_inode *base, char *rel, aino_test (base); *modified_rel = 0; - + /* If we have a mapping of some other aname to "rel", we must pretend * it does not exist. * This can happen for example if an Amiga program creates a @@ -983,7 +983,7 @@ static char *create_nname (Unit *unit, a_inode *base, char *rel) aino_test (base); /* We are trying to create a file called REL. */ - + /* If the name is used otherwise in the directory (or globally), we * need a new unique nname. */ if (fsdb_name_invalid (rel) || fsdb_used_as_nname (base, rel)) { @@ -1404,7 +1404,7 @@ static void do_info (Unit *unit, dpacket packet, uaecptr info) { struct fs_usage fsu; - + if (get_fs_usage (unit->ui.rootdir, 0, &fsu) != 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, dos_errno ()); @@ -2083,7 +2083,7 @@ static void do_examine (Unit *unit, dpacket packet, ExamineKey *ek, uaecptr info get_fileinfo (unit, packet, info, ek->curr_file); ek->curr_file = ek->curr_file->sibling; TRACE (("curr_file set to %p %s\n", ek->curr_file, - ek->curr_file ? ek->curr_file->aname : "NULL")); + ek->curr_file ? ek->curr_file->aname : "NULL")); return; no_more_entries: @@ -2663,7 +2663,7 @@ action_change_mode (Unit *unit, dpacket packet) /* will be CHANGE_FH or CHANGE_LOCK value */ long type = GET_PCK_ARG1 (packet); /* either a file-handle or lock */ - uaecptr object = GET_PCK_ARG2 (packet) << 2; + uaecptr object = GET_PCK_ARG2 (packet) << 2; /* will be EXCLUSIVE_LOCK/SHARED_LOCK if CHANGE_LOCK, * or MODE_OLDFILE/MODE_NEWFILE/MODE_READWRITE if CHANGE_FH */ long mode = GET_PCK_ARG3 (packet); @@ -2849,7 +2849,7 @@ action_examine_fh (Unit *unit, dpacket packet) put_long (info, 0); } -/* For a nice example of just how contradictory documentation can be, see the +/* For a nice example of just how contradictory documentation can be, see the * Autodoc for DOS:SetFileSize and the Packets.txt description of this packet... * This implementation tries to mimic the behaviour of the Kick 3.1 ramdisk * (which seems to match the Autodoc description). */ @@ -2966,7 +2966,7 @@ action_delete_object (Unit *unit, dpacket packet) } static void -action_set_date (Unit *unit, dpacket packet) +action_set_date (Unit *unit, dpacket packet) { uaecptr lock = GET_PCK_ARG2 (packet) << 2; uaecptr name = GET_PCK_ARG3 (packet) << 2; @@ -2984,7 +2984,7 @@ action_set_date (Unit *unit, dpacket packet) } ut.actime = ut.modtime = put_time(get_long (date), get_long (date + 4), - get_long (date + 8)); + get_long (date + 8)); a = find_aino (unit, lock, bstr (unit, name), &err); if (err == 0 && utime (a->nname, &ut) == -1) err = dos_errno (); @@ -3634,7 +3634,7 @@ static uae_u32 filesys_diagentry (void) } resaddr += 0x1A; tmp = resaddr; - + /* The good thing about this function is that it always gets called * when we boot. So we could put all sorts of stuff that wants to be done * here. @@ -3927,7 +3927,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke err = -1; goto error; } - + if (hfd->cylinders * hfd->sectors * hfd->heads * blocksize > hfd->size) write_log("WARNING: end of partition > size of disk!\n"); @@ -4437,7 +4437,7 @@ static uae_u8 *restore_filesys_virtual (UnitInfo *ui, uae_u8 *src) { Unit *u = startup_create_unit (ui); int cnt; - + u->a_uniq = restore_u64 (); u->key_uniq = restore_u64 (); u->dosbase = restore_u32 (); diff --git a/fpp.c b/fpp.c index 4e2b1f67..31c0560a 100755 --- a/fpp.c +++ b/fpp.c @@ -33,7 +33,7 @@ STATIC_INLINE int isinrom (void) #define FFLAG_Z 0x4000 #define FFLAG_N 0x0100 -#define FFLAG_NAN 0x0400 +#define FFLAG_NAN 0x0400 #define MAKE_FPSR(r) regs.fp_result=(r) @@ -60,7 +60,7 @@ static __inline__ void native_set_fpucw (uae_u32 m68k_cw) case 2: /* down */ iround=1; break; case 3: /* up */ iround=2; break; } - + x=0x107f + (iprec<<8) + (iround<<10); #if defined(X86_MSVC_ASSEMBLY) __asm { @@ -383,7 +383,7 @@ STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra) reg = opcode & 7; size = (extra >> 10) & 7; ad = -1; - + switch (mode) { case 0: switch (size) { @@ -625,7 +625,7 @@ STATIC_INLINE int fpp_cond (uae_u32 opcode, int contition) #if 0 return NotANumber || (Z && N); /* This is wrong, compare 0x0c */ #else - return NotANumber || (N && !Z); + return NotANumber || (N && !Z); #endif case 0x1d: return NotANumber || Z || N; @@ -1180,7 +1180,7 @@ void fpp_opp (uae_u32 opcode, uae_u16 extra) case 0x00: /* FMOVE */ case 0x40: /* Explicit rounding. This is just a quick fix. Same * for all other cases that have three choices */ - case 0x44: + case 0x44: regs.fp[reg] = src; /* Brian King was here. to register needs FPSR updated. * See page 3-73 in Motorola 68K programmers reference manual. @@ -1230,7 +1230,7 @@ void fpp_opp (uae_u32 opcode, uae_u16 extra) MAKE_FPSR (regs.fp[reg]); break; case 0x0d: /* FATANH */ -#if 1 /* The BeBox doesn't have atanh, and it isn't in the HPUX libm either */ +#if 1 /* The BeBox doesn't have atanh, and it isn't in the HPUX libm either */ regs.fp[reg] = log ((1 + src) / (1 - src)) / 2; #else regs.fp[reg] = atanh (src); diff --git a/gencpu.c b/gencpu.c index 7af4d960..3181df4c 100755 --- a/gencpu.c +++ b/gencpu.c @@ -190,7 +190,7 @@ static void gen_nextilong (char *type, char *name, int norefill) m68k_pc_offset += 4; if (using_ce) { - printf ("\t%s %s;\n", type, name); + printf ("\t%s %s;\n", type, name); /* we must do this because execution order of (something | something2) is not defined */ if (norefill) { printf ("\t%s = get_word_ce_prefetch (%d) << 16;\n", name, r + 2); @@ -200,9 +200,9 @@ static void gen_nextilong (char *type, char *name, int norefill) printf ("\t%s |= get_word_ce_prefetch (%d);\n", name, r + 4); } } else { - if (using_prefetch) { + if (using_prefetch) { if (norefill) { - printf ("\t%s %s;\n", type, name); + printf ("\t%s %s;\n", type, name); printf ("\t%s = get_word_prefetch (%d) << 16;\n", name, r + 2); printf ("\t%s |= regs.irc;\n", name); insn_n_cycles += 4; @@ -237,7 +237,7 @@ static const char *gen_nextiword (int norefill) } } else { sprintf (buffer, "get_iword (%d)", r); - insn_n_cycles += 4; + insn_n_cycles += 4; } } return buffer; @@ -255,17 +255,17 @@ static const char *gen_nextibyte (int norefill) else sprintf (buffer, "(uae_u8)get_word_ce_prefetch (%d)", r + 2); } else { - insn_n_cycles += 4; + insn_n_cycles += 4; if (using_prefetch) { if (norefill) { sprintf (buffer, "(uae_u8)regs.irc", r); } else { sprintf (buffer, "(uae_u8)get_word_prefetch (%d)", r + 2); - insn_n_cycles += 4; + insn_n_cycles += 4; } } else { sprintf (buffer, "get_ibyte (%d)", r); - insn_n_cycles += 4; + insn_n_cycles += 4; } } return buffer; @@ -297,7 +297,7 @@ static void fill_prefetch_1 (int o) if (!using_prefetch) return; if (using_ce) { - printf ("\tget_word_ce_prefetch (%d);\n", o); + printf ("\tget_word_ce_prefetch (%d);\n", o); } else { printf ("\tget_word_prefetch (%d);\n", o); } @@ -322,13 +322,13 @@ static void fill_prefetch_0 (void) printf ("\tget_word_prefetch (0);\n"); did_prefetch = 1; insn_n_cycles += 4; -} +} static void fill_prefetch_next_1 (void) { irc2ir (); fill_prefetch_1 (m68k_pc_offset + 2); -} +} static void fill_prefetch_next (void) { @@ -376,7 +376,7 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g { char namea[100]; int m68k_pc_offset_last = m68k_pc_offset; - + sprintf (namea, "%sa", name); start_brace (); @@ -549,10 +549,10 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g /* We get here for all non-reg non-immediate addressing modes to * actually fetch the value. */ - if ((using_prefetch || using_ce) && using_exception_3 && getv != 0 && size != sz_byte) { + if ((using_prefetch || using_ce) && using_exception_3 && getv != 0 && size != sz_byte) { printf ("\tif (%sa & 1) {\n", name); - printf ("\t\texception3 (opcode, m68k_getpc() + %d, %sa);\n", - m68k_pc_offset_last + e3fudge, name); + printf ("\t\texception3 (opcode, m68k_getpc() + %d, %sa);\n", + m68k_pc_offset_last + e3fudge, name); printf ("\t\tgoto %s;\n", endlabelstr); printf ("\t}\n"); need_endlabel = 1; @@ -757,7 +757,7 @@ static void genmovemel_ce (uae_u16 opcode) printf ("\tuae_u32 v;\n"); genamode (table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1, GF_AA); if (table68k[opcode].dmode == Ad8r || table68k[opcode].dmode == PC8r) - addcycles (2); + addcycles (2); start_brace (); if (table68k[opcode].size == sz_long) { printf ("\twhile (dmask) { v = get_word_ce(srca) << 16; v |= get_word_ce(srca + 2); m68k_dreg(regs, movem_index1[dmask]) = v; srca += %d; dmask = movem_next[dmask]; }\n", @@ -814,7 +814,7 @@ static void genmovemle_ce (uae_u16 opcode) genamode (table68k[opcode].dmode, "dstreg", table68k[opcode].size, "src", 2, 1, GF_AA); if (table68k[opcode].dmode == Ad8r || table68k[opcode].dmode == PC8r) - addcycles (2); + addcycles (2); start_brace (); if (table68k[opcode].size == sz_long) { if (table68k[opcode].dmode == Apdi) { @@ -1073,7 +1073,7 @@ static void genflags (flagtypes type, wordsizes size, char *value, char *src, ch case sz_long: printf ("\toptflag_cmpl ((uae_s32)(%s), (uae_s32)(%s));\n", src, dst); break; } return; - + default: break; } @@ -1119,11 +1119,11 @@ static int source_is_imm1_8 (struct instr *i) static void shift_ce (amodes dmode, int size) { if (using_ce && isreg (dmode)) { - printf ("\t{\n"); + printf ("\t{\n"); printf ("\t\tint cycles = %d * %d;\n", size == sz_long ? 8 : 6, CYCLE_UNIT / 2); printf ("\t\tcycles += 2 * %d * ccnt;\n", CYCLE_UNIT / 2); - addcycles3 ("\t\t"); - printf ("\t}\n"); + addcycles3 ("\t\t"); + printf ("\t}\n"); } } @@ -1178,7 +1178,7 @@ static void gen_opcode (unsigned long int opcode) if (curi->size == sz_byte) { printf ("\tsrc &= 0xFF;\n"); } - fill_prefetch_next_delay (4); + fill_prefetch_next_delay (4); printf ("\tregs.sr %c= src;\n", curi->mnemo == i_EORSR ? '^' : '|'); printf ("\tMakeFromSR();\n"); break; @@ -1188,7 +1188,7 @@ static void gen_opcode (unsigned long int opcode) if (curi->size == sz_byte) { printf ("\tsrc |= 0xFF00;\n"); } - fill_prefetch_next_delay (4); + fill_prefetch_next_delay (4); printf ("\tregs.sr &= src;\n"); printf ("\tMakeFromSR();\n"); break; @@ -1199,7 +1199,7 @@ static void gen_opcode (unsigned long int opcode) if (curi->dmode == Dreg && curi->size == sz_long) tmpc += (curi->smode == imm || curi->smode == immi) ? 4 : 2; } - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); genflags (flag_sub, curi->size, "newv", "src", "dst"); genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); @@ -1222,7 +1222,7 @@ static void gen_opcode (unsigned long int opcode) genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA); if ((isreg (curi->smode) && curi->size == sz_long) || !isreg (curi->smode)) tmpc += 2; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); printf ("\tuae_u32 newv = dst - src - (GET_XFLG ? 1 : 0);\n"); genflags (flag_subx, curi->size, "newv", "src", "dst"); @@ -1232,7 +1232,7 @@ static void gen_opcode (unsigned long int opcode) case i_SBCD: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); printf ("\tuae_u16 newv_lo = (dst & 0xF) - (src & 0xF) - (GET_XFLG ? 1 : 0);\n"); printf ("\tuae_u16 newv_hi = (dst & 0xF0) - (src & 0xF0);\n"); @@ -1253,9 +1253,9 @@ static void gen_opcode (unsigned long int opcode) genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); if (isreg (curi->dmode)) { if (curi->dmode == Dreg && curi->size == sz_long) - tmpc += (curi->smode == imm || curi->smode == immi) ? 4 : 2; + tmpc += (curi->smode == imm || curi->smode == immi) ? 4 : 2; } - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); genflags (flag_add, curi->size, "newv", "src", "dst"); genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); @@ -1268,7 +1268,7 @@ static void gen_opcode (unsigned long int opcode) if (curi->size == sz_long) tmpc += (isreg (curi->smode) || curi->smode == imm) ? 2 : 0; } - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); printf ("\tuae_u32 newv = dst + src;\n"); genastore ("newv", curi->dmode, "dstreg", sz_long, "dst"); @@ -1278,7 +1278,7 @@ static void gen_opcode (unsigned long int opcode) genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA); if ((isreg (curi->smode) && curi->size == sz_long) || !isreg (curi->smode)) tmpc += 2; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); printf ("\tuae_u32 newv = dst + src + (GET_XFLG ? 1 : 0);\n"); genflags (flag_addx, curi->size, "newv", "src", "dst"); @@ -1288,7 +1288,7 @@ static void gen_opcode (unsigned long int opcode) case i_ABCD: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); printf ("\tuae_u16 newv_lo = (src & 0xF) + (dst & 0xF) + (GET_XFLG ? 1 : 0);\n"); printf ("\tuae_u16 newv_hi = (src & 0xF0) + (dst & 0xF0);\n"); @@ -1308,7 +1308,7 @@ static void gen_opcode (unsigned long int opcode) case i_NEG: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); if (isreg (curi->smode) && curi->size == sz_long) tmpc += 2; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); genflags (flag_sub, curi->size, "dst", "src", "0"); genastore_rev ("dst", curi->smode, "srcreg", curi->size, "src"); @@ -1316,7 +1316,7 @@ static void gen_opcode (unsigned long int opcode) case i_NEGX: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); if (isreg (curi->smode) && curi->size == sz_long) tmpc += 2; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); printf ("\tuae_u32 newv = 0 - src - (GET_XFLG ? 1 : 0);\n"); genflags (flag_subx, curi->size, "newv", "src", "0"); @@ -1326,7 +1326,7 @@ static void gen_opcode (unsigned long int opcode) case i_NBCD: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); if (isreg (curi->smode)) tmpc += 2; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); printf ("\tuae_u16 newv_lo = - (src & 0xF) - (GET_XFLG ? 1 : 0);\n"); printf ("\tuae_u16 newv_hi = - (src & 0xF0);\n"); @@ -1344,14 +1344,14 @@ static void gen_opcode (unsigned long int opcode) case i_CLR: genamode (curi->smode, "srcreg", curi->size, "src", cpu_level == 0 ? 1 : 2, 0, 0); if (isreg (curi->smode) && curi->size == sz_long) tmpc += 2; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); genflags (flag_logical, curi->size, "0", "", ""); genastore_rev ("0", curi->smode, "srcreg", curi->size, "src"); break; case i_NOT: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); if (isreg (curi->smode) && curi->size == sz_long) tmpc += 2; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); printf ("\tuae_u32 dst = ~src;\n"); genflags (flag_logical, curi->size, "dst", "", ""); @@ -1359,14 +1359,14 @@ static void gen_opcode (unsigned long int opcode) break; case i_TST: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); genflags (flag_logical, curi->size, "src", "", ""); break; case i_BTST: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); if (isreg (curi->dmode)) tmpc += 2; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); if (curi->size == sz_byte) printf ("\tsrc &= 7;\n"); else @@ -1377,7 +1377,7 @@ static void gen_opcode (unsigned long int opcode) genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); if (isreg (curi->dmode)) tmpc += 4; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); if (curi->size == sz_byte) printf ("\tsrc &= 7;\n"); else @@ -1390,7 +1390,7 @@ static void gen_opcode (unsigned long int opcode) genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); if (isreg (curi->dmode)) tmpc += 4; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); if (curi->size == sz_byte) printf ("\tsrc &= 7;\n"); else @@ -1403,7 +1403,7 @@ static void gen_opcode (unsigned long int opcode) genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); if (isreg (curi->dmode)) tmpc += 4; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); if (curi->size == sz_byte) printf ("\tsrc &= 7;\n"); else @@ -1415,7 +1415,7 @@ static void gen_opcode (unsigned long int opcode) case i_CMPM: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); genflags (flag_cmp, curi->size, "newv", "src", "dst"); break; @@ -1426,7 +1426,7 @@ static void gen_opcode (unsigned long int opcode) if (curi->dmode == Areg || (curi->dmode == Dreg && curi->size == sz_long)) tmpc += 2; } - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); genflags (flag_cmp, curi->size, "newv", "src", "dst"); break; @@ -1437,7 +1437,7 @@ static void gen_opcode (unsigned long int opcode) if (curi->dmode == Areg || (curi->dmode == Dreg && curi->size == sz_long)) tmpc += 2; } - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); start_brace (); genflags (flag_cmp, sz_long, "newv", "src", "dst"); break; @@ -1446,7 +1446,7 @@ static void gen_opcode (unsigned long int opcode) case i_MVPRM: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); printf ("\tuaecptr memp = m68k_areg(regs, dstreg) + (uae_s32)(uae_s16)%s;\n", gen_nextiword (0)); - fill_prefetch_next (); + fill_prefetch_next (); if (using_ce) { if (curi->size == sz_word) { printf ("\tput_byte_ce (memp, src >> 8); put_byte_ce (memp + 2, src);\n"); @@ -1481,7 +1481,7 @@ static void gen_opcode (unsigned long int opcode) printf (" + (get_byte (memp + 4) << 8) + get_byte (memp + 6);\n"); } } - fill_prefetch_next (); + fill_prefetch_next (); genastore ("val", curi->dmode, "dstreg", curi->size, "dst"); break; case i_MOVE: @@ -1500,13 +1500,13 @@ static void gen_opcode (unsigned long int opcode) } else { printf ("\tuae_u32 val = src;\n"); } - fill_prefetch_next (); + fill_prefetch_next (); genastore ("val", curi->dmode, "dstreg", sz_long, "dst"); break; case i_MVSR2: genamode (curi->smode, "srcreg", sz_word, "src", 2, 0, 0); if (isreg (curi->smode)) tmpc += 2; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); printf ("\tMakeSR();\n"); if (curi->size == sz_byte) genastore ("regs.sr & 0xff", curi->smode, "srcreg", sz_word, "src"); @@ -1522,12 +1522,12 @@ static void gen_opcode (unsigned long int opcode) tmpc += 4; printf ("\tregs.sr = src;\n"); } - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); printf ("\tMakeFromSR();\n"); break; case i_SWAP: genamode (curi->smode, "srcreg", sz_long, "src", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); printf ("\tuae_u32 dst = ((src >> 16)&0xFFFF) | ((src&0xFFFF)<<16);\n"); genflags (flag_logical, sz_long, "dst", "", ""); @@ -1536,13 +1536,13 @@ static void gen_opcode (unsigned long int opcode) case i_EXG: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); - fill_prefetch_next_delay (2); + fill_prefetch_next_delay (2); genastore ("dst", curi->smode, "srcreg", curi->size, "src"); genastore ("src", curi->dmode, "dstreg", curi->size, "dst"); break; case i_EXT: genamode (curi->smode, "srcreg", sz_long, "src", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); switch (curi->size) { case sz_byte: printf ("\tuae_u32 dst = (uae_s32)(uae_s8)src;\n"); break; @@ -1560,14 +1560,14 @@ static void gen_opcode (unsigned long int opcode) genmovemel_ce (opcode); else genmovemel (opcode); - fill_prefetch_next (); + fill_prefetch_next (); break; case i_MVMLE: if (using_ce) genmovemle_ce (opcode); else genmovemle (opcode); - fill_prefetch_next (); + fill_prefetch_next (); break; case i_TRAP: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); @@ -1591,7 +1591,7 @@ static void gen_opcode (unsigned long int opcode) printf ("\tcpureset();\n"); break; case i_NOP: - fill_prefetch_next (); + fill_prefetch_next (); break; case i_STOP: /* real stop do not prefetch anything, later... */ @@ -1642,9 +1642,9 @@ static void gen_opcode (unsigned long int opcode) genamode (Aipi, "7", sz_long, "pc", 1, 0, 0); genamode (curi->smode, "srcreg", curi->size, "offs", 1, 0, 0); printf ("\tm68k_areg(regs, 7) += offs;\n"); - printf ("\tif (pc & 1)\n"); - printf ("\t\texception3 (0x%04.4X, m68k_getpc(), pc);\n", opcode); - printf ("\telse\n"); + printf ("\tif (pc & 1)\n"); + printf ("\t\texception3 (0x%04.4X, m68k_getpc(), pc);\n", opcode); + printf ("\telse\n"); printf ("\t\tm68k_setpc_rte(pc);\n"); /* PC is set and prefetch filled. */ m68k_pc_offset = 0; @@ -1657,13 +1657,13 @@ static void gen_opcode (unsigned long int opcode) genastore ("m68k_areg(regs, 7)", curi->smode, "srcreg", sz_long, "src"); genamode (curi->dmode, "dstreg", curi->size, "offs", 1, 0, 0); printf ("\tm68k_areg(regs, 7) += offs;\n"); - fill_prefetch_next (); + fill_prefetch_next (); break; case i_UNLK: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); printf ("\tm68k_areg(regs, 7) = src;\n"); genamode (Aipi, "7", sz_long, "old", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); genastore ("old", curi->smode, "srcreg", curi->size, "src"); break; case i_RTS: @@ -1672,7 +1672,7 @@ static void gen_opcode (unsigned long int opcode) else printf ("\tm68k_do_rts();\n"); m68k_pc_offset = 0; - fill_prefetch_full (); + fill_prefetch_full (); break; case i_TRAPV: sync_m68k_pc (); @@ -1680,7 +1680,7 @@ static void gen_opcode (unsigned long int opcode) printf ("\t\tException (7, m68k_getpc ());\n"); printf ("\t\tgoto %s;\n", endlabelstr); printf ("\t}\n"); - fill_prefetch_next (); + fill_prefetch_next (); need_endlabel = 1; break; case i_RTR: @@ -1691,7 +1691,7 @@ static void gen_opcode (unsigned long int opcode) printf ("\tregs.sr |= sr; m68k_setpc(pc);\n"); printf ("\tMakeFromSR();\n"); m68k_pc_offset = 0; - fill_prefetch_full (); + fill_prefetch_full (); break; case i_JSR: genamode (curi->smode, "srcreg", curi->size, "src", 0, 0, GF_AA|GF_NOREFILL); @@ -1704,17 +1704,17 @@ static void gen_opcode (unsigned long int opcode) printf ("\t}\n"); need_endlabel = 1; } - printf ("\tm68k_setpc (srca);\n"); + printf ("\tm68k_setpc (srca);\n"); m68k_pc_offset = 0; fill_prefetch_1 (0); - printf("\tm68k_areg (regs, 7) -= 4;\n"); + printf("\tm68k_areg (regs, 7) -= 4;\n"); if (using_ce) { printf("\tput_word_ce (m68k_areg (regs, 7), oldpc >> 16);\n"); printf("\tput_word_ce (m68k_areg (regs, 7) + 2, oldpc);\n"); } else { printf("\tput_long (m68k_areg (regs, 7), oldpc);\n"); } - fill_prefetch_next (); + fill_prefetch_next (); break; case i_JMP: genamode (curi->smode, "srcreg", curi->size, "src", 0, 0, GF_AA|GF_NOREFILL); @@ -1729,7 +1729,7 @@ static void gen_opcode (unsigned long int opcode) addcycles (2); printf ("\tm68k_setpc(srca);\n"); m68k_pc_offset = 0; - fill_prefetch_full (); + fill_prefetch_full (); break; case i_BSR: printf ("\tuae_s32 s;\n"); @@ -1748,7 +1748,7 @@ static void gen_opcode (unsigned long int opcode) else printf ("\tm68k_do_bsr (m68k_getpc() + %d, s);\n", m68k_pc_offset); m68k_pc_offset = 0; - fill_prefetch_full (); + fill_prefetch_full (); break; case i_Bcc: if (curi->size == sz_long) { @@ -1759,7 +1759,7 @@ static void gen_opcode (unsigned long int opcode) printf ("\t\tgoto %s;\n", endlabelstr); printf ("\t}\n"); sync_m68k_pc (); - irc2ir (); + irc2ir (); fill_prefetch_2 (); printf ("\tgoto %s;\n", endlabelstr); need_endlabel = 1; @@ -1768,7 +1768,7 @@ static void gen_opcode (unsigned long int opcode) next_cpu_level = 1; } } - genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA | GF_NOREFILL); + genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA | GF_NOREFILL); addcycles (2); printf ("\tif (!cctrue(%d)) goto didnt_jump;\n", curi->cc); if (using_exception_3) { @@ -1802,14 +1802,14 @@ static void gen_opcode (unsigned long int opcode) fill_prefetch_2 (); } else fill_prefetch_full (); - insn_n_cycles = curi->size == sz_byte ? 8 : 12; + insn_n_cycles = curi->size == sz_byte ? 8 : 12; break; case i_LEA: genamode (curi->smode, "srcreg", curi->size, "src", 0, 0, GF_AA); genamode (curi->dmode, "dstreg", curi->size, "dst", 2, 0, GF_AA); if (curi->smode == Ad8r || curi->smode == PC8r) tmpc += 4; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); genastore ("srca", curi->dmode, "dstreg", curi->size, "dst"); break; case i_PEA: @@ -1817,7 +1817,7 @@ static void gen_opcode (unsigned long int opcode) genamode (Apdi, "7", sz_long, "dst", 2, 0, GF_AA); if (curi->smode == Ad8r || curi->smode == PC8r) tmpc += 4; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); genastore ("srca", Apdi, "7", sz_long, "dst"); break; case i_DBcc: @@ -1851,13 +1851,13 @@ static void gen_opcode (unsigned long int opcode) printf ("\tm68k_setpc (oldpc + %d);\n", m68k_pc_offset); m68k_pc_offset = 0; fill_prefetch_full (); - insn_n_cycles = 12; + insn_n_cycles = 12; need_endlabel = 1; break; case i_Scc: genamode (curi->smode, "srcreg", curi->size, "src", cpu_level == 0 ? 1 : 2, 0, 0); start_brace (); - fill_prefetch_next(); + fill_prefetch_next(); start_brace (); printf ("\tint val = cctrue(%d) ? 0xff : 0;\n", curi->cc); if (using_ce) { @@ -1880,7 +1880,7 @@ static void gen_opcode (unsigned long int opcode) */ printf("\t\tSET_VFLG (1);\n"); printf("\t\tif (dst < 0) SET_NFLG (1);\n"); - } + } printf ("\t\tException (5, oldpc);\n"); printf ("\t\tgoto %s;\n", endlabelstr); printf ("\t} else {\n"); @@ -1905,7 +1905,7 @@ static void gen_opcode (unsigned long int opcode) printf ("\t\t\tnewv = (newv & 0xffff) | ((uae_u32)rem << 16);\n"); printf ("\t\t"); genastore ("newv", curi->dmode, "dstreg", sz_long, "dst"); printf ("\t\t}\n"); - fill_prefetch_next (); + fill_prefetch_next (); sync_m68k_pc (); printf ("\t}\n"); insn_n_cycles += 136 - (136 - 76) / 2; /* average */ @@ -1947,7 +1947,7 @@ static void gen_opcode (unsigned long int opcode) printf ("\t\t\tnewv = (newv & 0xffff) | ((uae_u32)rem << 16);\n"); printf ("\t\t"); genastore ("newv", curi->dmode, "dstreg", sz_long, "dst"); printf ("\t\t}\n"); - fill_prefetch_next (); + fill_prefetch_next (); sync_m68k_pc (); printf ("\t}\n"); insn_n_cycles += 156 - (156 - 120) / 2; /* average */ @@ -1956,7 +1956,7 @@ static void gen_opcode (unsigned long int opcode) case i_MULU: genamode (curi->smode, "srcreg", sz_word, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", sz_word, "dst", 1, 0, 0); - fill_prefetch_next(); + fill_prefetch_next(); start_brace (); printf ("\tuae_u32 newv = (uae_u32)(uae_u16)dst * (uae_u32)(uae_u16)src;\n"); if (using_ce) @@ -1969,12 +1969,12 @@ static void gen_opcode (unsigned long int opcode) } genastore ("newv", curi->dmode, "dstreg", sz_long, "dst"); sync_m68k_pc (); - insn_n_cycles += (70 - 38) / 2 + 38; /* average */ + insn_n_cycles += (70 - 38) / 2 + 38; /* average */ break; case i_MULS: genamode (curi->smode, "srcreg", sz_word, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", sz_word, "dst", 1, 0, 0); - fill_prefetch_next(); + fill_prefetch_next(); start_brace (); printf ("\tuae_u32 newv = (uae_s32)(uae_s16)dst * (uae_s32)(uae_s16)src;\n"); if (using_ce) @@ -1994,7 +1994,7 @@ static void gen_opcode (unsigned long int opcode) genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); sync_m68k_pc (); - fill_prefetch_next_delay (6); + fill_prefetch_next_delay (6); printf ("\tif ((uae_s32)dst < 0) {\n"); printf ("\t\tSET_NFLG (1);\n"); printf ("\t\tException (6, oldpc);\n"); @@ -2010,7 +2010,7 @@ static void gen_opcode (unsigned long int opcode) printf ("\tuaecptr oldpc = m68k_getpc();\n"); genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 2, 0, 0); - fill_prefetch_0 (); + fill_prefetch_0 (); printf ("\t{uae_s32 upper,lower,reg = regs.regs[(extra >> 12) & 15];\n"); switch (curi->size) { case sz_byte: @@ -2045,7 +2045,7 @@ static void gen_opcode (unsigned long int opcode) default: abort (); } printf ("\tuae_u32 sign = (%s & val) >> %d;\n", cmask (curi->size), bit_size (curi->size) - 1); - printf ("\tint ccnt = cnt & 63;\n"); + printf ("\tint ccnt = cnt & 63;\n"); printf ("\tcnt &= 63;\n"); printf ("\tCLEAR_CZNV;\n"); printf ("\tif (cnt >= %d) {\n", bit_size (curi->size)); @@ -2080,7 +2080,7 @@ static void gen_opcode (unsigned long int opcode) case sz_long: printf ("\tuae_u32 val = data;\n"); break; default: abort (); } - printf ("\tint ccnt = cnt & 63;\n"); + printf ("\tint ccnt = cnt & 63;\n"); printf ("\tcnt &= 63;\n"); printf ("\tCLEAR_CZNV;\n"); printf ("\tif (cnt >= %d) {\n", bit_size (curi->size)); @@ -2119,7 +2119,7 @@ static void gen_opcode (unsigned long int opcode) case sz_long: printf ("\tuae_u32 val = data;\n"); break; default: abort (); } - printf ("\tint ccnt = cnt & 63;\n"); + printf ("\tint ccnt = cnt & 63;\n"); printf ("\tcnt &= 63;\n"); printf ("\tCLEAR_CZNV;\n"); printf ("\tif (cnt >= %d) {\n", bit_size (curi->size)); @@ -2151,7 +2151,7 @@ static void gen_opcode (unsigned long int opcode) case sz_long: printf ("\tuae_u32 val = data;\n"); break; default: abort (); } - printf ("\tint ccnt = cnt & 63;\n"); + printf ("\tint ccnt = cnt & 63;\n"); printf ("\tcnt &= 63;\n"); printf ("\tCLEAR_CZNV;\n"); printf ("\tif (cnt >= %d) {\n", bit_size (curi->size)); @@ -2184,7 +2184,7 @@ static void gen_opcode (unsigned long int opcode) case sz_long: printf ("\tuae_u32 val = data;\n"); break; default: abort (); } - printf ("\tint ccnt = cnt & 63;\n"); + printf ("\tint ccnt = cnt & 63;\n"); printf ("\tcnt &= 63;\n"); printf ("\tCLEAR_CZNV;\n"); if (source_is_imm1_8 (curi)) @@ -2214,7 +2214,7 @@ static void gen_opcode (unsigned long int opcode) case sz_long: printf ("\tuae_u32 val = data;\n"); break; default: abort (); } - printf ("\tint ccnt = cnt & 63;\n"); + printf ("\tint ccnt = cnt & 63;\n"); printf ("\tcnt &= 63;\n"); printf ("\tCLEAR_CZNV;\n"); if (source_is_imm1_8 (curi)) @@ -2244,7 +2244,7 @@ static void gen_opcode (unsigned long int opcode) case sz_long: printf ("\tuae_u32 val = data;\n"); break; default: abort (); } - printf ("\tint ccnt = cnt & 63;\n"); + printf ("\tint ccnt = cnt & 63;\n"); printf ("\tcnt &= 63;\n"); printf ("\tCLEAR_CZNV;\n"); if (source_is_imm1_8 (curi)) @@ -2304,7 +2304,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_ASRW: genamode (curi->smode, "srcreg", curi->size, "data", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); switch (curi->size) { case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; @@ -2322,7 +2322,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_ASLW: genamode (curi->smode, "srcreg", curi->size, "data", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); switch (curi->size) { case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; @@ -2343,7 +2343,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_LSRW: genamode (curi->smode, "srcreg", curi->size, "data", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); switch (curi->size) { case sz_byte: printf ("\tuae_u32 val = (uae_u8)data;\n"); break; @@ -2360,7 +2360,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_LSLW: genamode (curi->smode, "srcreg", curi->size, "data", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); switch (curi->size) { case sz_byte: printf ("\tuae_u8 val = data;\n"); break; @@ -2377,7 +2377,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_ROLW: genamode (curi->smode, "srcreg", curi->size, "data", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); switch (curi->size) { case sz_byte: printf ("\tuae_u8 val = data;\n"); break; @@ -2394,7 +2394,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_RORW: genamode (curi->smode, "srcreg", curi->size, "data", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); switch (curi->size) { case sz_byte: printf ("\tuae_u8 val = data;\n"); break; @@ -2411,7 +2411,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_ROXLW: genamode (curi->smode, "srcreg", curi->size, "data", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); switch (curi->size) { case sz_byte: printf ("\tuae_u8 val = data;\n"); break; @@ -2429,7 +2429,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_ROXRW: genamode (curi->smode, "srcreg", curi->size, "data", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); switch (curi->size) { case sz_byte: printf ("\tuae_u8 val = data;\n"); break; @@ -2447,7 +2447,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_MOVEC2: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); printf ("\tint regno = (src >> 12) & 15;\n"); printf ("\tuae_u32 *regp = regs.regs + regno;\n"); @@ -2455,7 +2455,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_MOVE2C: genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); - fill_prefetch_next (); + fill_prefetch_next (); start_brace (); printf ("\tint regno = (src >> 12) & 15;\n"); printf ("\tuae_u32 *regp = regs.regs + regno;\n"); @@ -2466,7 +2466,7 @@ static void gen_opcode (unsigned long int opcode) int old_brace_level; genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); - fill_prefetch_0 (); + fill_prefetch_0 (); start_brace (); printf ("\tint ru = (src >> 6) & 7;\n"); printf ("\tint rc = src & 7;\n"); @@ -2560,7 +2560,7 @@ static void gen_opcode (unsigned long int opcode) case i_TRAPcc: if (curi->smode != am_unknown && curi->smode != am_illg) genamode (curi->smode, "srcreg", curi->size, "dummy", 1, 0, 0); - fill_prefetch_0 (); + fill_prefetch_0 (); printf ("\tif (cctrue(%d)) { Exception(7,m68k_getpc()); goto %s; }\n", curi->cc, endlabelstr); need_endlabel = 1; break; @@ -2696,7 +2696,7 @@ static void gen_opcode (unsigned long int opcode) genflags (flag_logical, curi->size, "src", "", ""); if (!isreg (curi->smode)) tmpc += 2; - fill_prefetch_next_delay (tmpc); + fill_prefetch_next_delay (tmpc); printf ("\tsrc |= 0x80;\n"); genastore ("src", curi->smode, "srcreg", curi->size, "src"); break; @@ -2750,27 +2750,27 @@ static void gen_opcode (unsigned long int opcode) case i_CINVL: printf ("\tif (opcode&0x80)\n" - "\t\tflush_icache(31);\n"); + "\t\tflush_icache(31);\n"); break; case i_CINVP: printf ("\tif (opcode&0x80)\n" - "\t\tflush_icache(32);\n"); + "\t\tflush_icache(32);\n"); break; case i_CINVA: printf ("\tif (opcode&0x80)\n" - "\t\tflush_icache(33);\n"); + "\t\tflush_icache(33);\n"); break; case i_CPUSHL: printf ("\tif (opcode&0x80)\n" - "\t\tflush_icache(41);\n"); + "\t\tflush_icache(41);\n"); break; case i_CPUSHP: printf ("\tif (opcode&0x80)\n" - "\t\tflush_icache(42);\n"); + "\t\tflush_icache(42);\n"); break; case i_CPUSHA: printf ("\tif (opcode&0x80)\n" - "\t\tflush_icache(43);\n"); + "\t\tflush_icache(43);\n"); break; case i_MOVE16: if ((opcode & 0xfff8) == 0xf620) { @@ -2796,7 +2796,7 @@ static void gen_opcode (unsigned long int opcode) printf ("\tput_long(memda+8, get_long(memsa+8));\n"); printf ("\tput_long(memda+12, get_long(memsa+12));\n"); if ((opcode & 0xfff8) == 0xf600) - printf ("\tm68k_areg(regs, srcreg) += 16;\n"); + printf ("\tm68k_areg(regs, srcreg) += 16;\n"); else if ((opcode & 0xfff8) == 0xf608) printf ("\tm68k_areg(regs, dstreg) += 16;\n"); } @@ -2835,7 +2835,7 @@ static void generate_includes (FILE * f) fprintf (f, "#include \"newcpu.h\"\n"); fprintf (f, "#include \"cpu_prefetch.h\"\n"); fprintf (f, "#include \"cputbl.h\"\n"); - + fprintf (f, "#define CPUFUNC(x) x##_ff\n" "#define SET_CFLG_ALWAYS(x) SET_CFLG(x)\n" "#define SET_NFLG_ALWAYS(x) SET_NFLG(x)\n" @@ -2902,17 +2902,17 @@ static char *decodeEA (amodes mode, wordsizes size) } break; case imm0: - strcpy (buffer,"#.B"); - break; + strcpy (buffer,"#.B"); + break; case imm1: - strcpy (buffer,"#.W"); - break; + strcpy (buffer,"#.W"); + break; case imm2: - strcpy (buffer,"#.L"); - break; + strcpy (buffer,"#.L"); + break; case immi: - strcpy (buffer,"#"); - break; + strcpy (buffer,"#"); + break; default: break; @@ -3068,21 +3068,21 @@ static void generate_func (void) /* sam: this is for people with low memory (eg. me :)) */ printf ("\n" - "#if !defined(PART_1) && !defined(PART_2) && " - "!defined(PART_3) && !defined(PART_4) && " + "#if !defined(PART_1) && !defined(PART_2) && " + "!defined(PART_3) && !defined(PART_4) && " "!defined(PART_5) && !defined(PART_6) && " "!defined(PART_7) && !defined(PART_8)" "\n" - "#define PART_1 1\n" - "#define PART_2 1\n" - "#define PART_3 1\n" - "#define PART_4 1\n" - "#define PART_5 1\n" - "#define PART_6 1\n" - "#define PART_7 1\n" - "#define PART_8 1\n" - "#endif\n\n"); - + "#define PART_1 1\n" + "#define PART_2 1\n" + "#define PART_3 1\n" + "#define PART_4 1\n" + "#define PART_5 1\n" + "#define PART_6 1\n" + "#define PART_7 1\n" + "#define PART_8 1\n" + "#endif\n\n"); + rp = 0; for(j = 1; j <= 8; ++j) { int k = (j * nr_cpuop_funcs) / 8; @@ -3129,7 +3129,7 @@ int main (int argc, char **argv) fprintf (stblfile, "#ifdef CPUEMU_%d\n", postfix); postfix2 = postfix; sprintf (fname, "cpuemu_%d.c", postfix); - freopen (fname, "wb", stdout); + freopen (fname, "wb", stdout); generate_includes (stdout); } cpu_level = 4 - i; @@ -3143,7 +3143,7 @@ int main (int argc, char **argv) } if (i > 0 && i < 4) fprintf (stblfile, "#ifndef CPUEMU_68000_ONLY\n"); - fprintf (stblfile, "struct cputbl CPUFUNC(op_smalltbl_%d)[] = {\n", postfix); + fprintf (stblfile, "struct cputbl CPUFUNC(op_smalltbl_%d)[] = {\n", postfix); generate_func (); if (i > 0 && i < 4) fprintf (stblfile, "#endif /* CPUEMU_68000_ONLY */\n"); diff --git a/gtkui.c b/gtkui.c index a536030c..7490774f 100755 --- a/gtkui.c +++ b/gtkui.c @@ -5,7 +5,7 @@ * * Copyright 1997, 1998 Bernd Schmidt * Copyright 1998 Michael Krause - * + * * The Tk GUI doesn't work. * The X Forms Library isn't available as source, and there aren't any * binaries compiled against glibc @@ -293,7 +293,7 @@ static void set_hd_state (void) &volname, &rootdir, &readonly, &secspertrack, &surfaces, &reserved, &cylinders, &size, &blocksize); - + if (is_hardfile (currprefs.mountinfo, i)) { sprintf (texts[0], "DH%d", i ); sprintf (texts[3], "%d", surfaces); @@ -539,7 +539,7 @@ static void did_reset (void) { if (quit_gui) return; - + write_comm_pipe_int (&from_gui_pipe, 2, 1); } @@ -547,7 +547,7 @@ static void did_debug (void) { if (quit_gui) return; - + write_comm_pipe_int (&from_gui_pipe, 3, 1); } @@ -555,7 +555,7 @@ static void did_quit (void) { if (quit_gui) return; - + write_comm_pipe_int (&from_gui_pipe, 4, 1); } @@ -563,7 +563,7 @@ static void did_eject (GtkWidget *w, gpointer data) { if (quit_gui) return; - + write_comm_pipe_int (&from_gui_pipe, 0, 0); write_comm_pipe_int (&from_gui_pipe, (int)data, 1); } @@ -573,14 +573,14 @@ static void pause_uae (GtkWidget *widget, gpointer data) if (quit_gui) return; - write_comm_pipe_int (&from_gui_pipe, GTK_TOGGLE_BUTTON (widget)->active ? 5 : 6, 1); + write_comm_pipe_int (&from_gui_pipe, GTK_TOGGLE_BUTTON (widget)->active ? 5 : 6, 1); } static void end_pause_uae (void) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pause_uae_widget), FALSE); } - + static int filesel_active = -1; static GtkWidget *disk_selector; @@ -936,7 +936,7 @@ static GtkWidget *make_led (int nr) thing = gtk_preview_new (GTK_PREVIEW_COLOR); gtk_box_pack_start (GTK_BOX (the_led), thing, TRUE, TRUE, 0); gtk_widget_show (thing); - + return the_led; } @@ -984,7 +984,7 @@ static void make_floppy_disks (GtkWidget *vbox) /* Frame with an hbox and the "DFx:" title */ sprintf (buf, "DF%d:", i); buttonbox = make_file_container (buf, vbox); - + /* LED */ subthing = make_led (i + 1); gtk_box_pack_start (GTK_BOX (buttonbox), subthing, FALSE, TRUE, 0); @@ -1063,7 +1063,7 @@ static void make_cpu_widgets (GtkWidget *vbox) gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, FALSE, 0); add_empty_vbox (hbox); - gtk_widget_show (hbox); + gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); frame = gtk_frame_new ("CPU flags"); @@ -1086,7 +1086,7 @@ static void make_cpu_widgets (GtkWidget *vbox) gtk_signal_connect (GTK_OBJECT (ccpu_widget), "clicked", (GtkSignalFunc) cputype_changed, NULL); gtk_signal_connect (GTK_OBJECT (a24m_widget), "clicked", - (GtkSignalFunc) cputype_changed, NULL); + (GtkSignalFunc) cputype_changed, NULL); } static void make_gfx_widgets (GtkWidget *vbox) @@ -1311,13 +1311,13 @@ static void make_comp_widgets (GtkWidget *vbox) "Direct", "Indirect", "Indirect for KS", "Direct after Picasso", NULL },*complabels2[] = { - "Direct", "Indirect", "Indirect for KS", "Direct after Picasso", + "Direct", "Indirect", "Indirect for KS", "Direct after Picasso", NULL },*complabels3[] = { - "Direct", "Indirect", "Indirect for KS", "Direct after Picasso", + "Direct", "Indirect", "Indirect for KS", "Direct after Picasso", NULL },*complabels3a[] = { - "Direct", "Indirect", "Indirect for KS", "Direct after Picasso", + "Direct", "Indirect", "Indirect for KS", "Direct after Picasso", NULL }, *complabels4[] = { "Always generate", "Only generate when needed", @@ -1335,7 +1335,7 @@ static void make_comp_widgets (GtkWidget *vbox) "Soft", "Hard", NULL }, *complabels9[] = { - "Disable", "Enable", + "Disable", "Enable", NULL }; GtkWidget *thing; @@ -1473,7 +1473,7 @@ static GtkWidget *create_dirdlg (const char *title) gtk_box_pack_start (GTK_BOX (hbox), label1, FALSE, TRUE, 10); gtk_widget_show (label1); thing = gtk_entry_new_with_max_length (255); - gtk_box_pack_start (GTK_BOX (hbox), thing, TRUE, TRUE, 10); + gtk_box_pack_start (GTK_BOX (hbox), thing, TRUE, TRUE, 10); gtk_widget_show (thing); path_entry = thing; @@ -1484,7 +1484,7 @@ static GtkWidget *create_dirdlg (const char *title) gtk_box_pack_start (GTK_BOX (hbox), thing, FALSE, TRUE, 10); gtk_widget_show (thing); thing = gtk_entry_new_with_max_length (255); - gtk_box_pack_start (GTK_BOX (hbox), thing, TRUE, TRUE, 10); + gtk_box_pack_start (GTK_BOX (hbox), thing, TRUE, TRUE, 10); gtk_widget_show (thing); gtk_widget_set_usize (thing, 200, -1); volname_entry = thing; @@ -1531,7 +1531,7 @@ static void did_hdchange (void) hd_change_mode = 1; if (is_hardfile (currprefs.mountinfo, selected_hd_row)) { } else { - create_dirdlg ("Change a mounted directory"); + create_dirdlg ("Change a mounted directory"); gtk_entry_set_text (GTK_ENTRY (volname_entry), volname); gtk_entry_set_text (GTK_ENTRY (path_entry), rootdir); } @@ -1657,7 +1657,7 @@ static void create_guidlg (void) { "Graphics", make_gfx_widgets }, { "Chipset", make_chipset_widgets }, { "Sound", make_sound_widgets }, - { "JIT", make_comp_widgets }, + { "JIT", make_comp_widgets }, { "Game ports", make_joy_widgets }, { "Harddisks", make_hd_widgets }, { "About", make_about_widgets } @@ -1743,7 +1743,7 @@ static void *gtk_gui_thread (void *dummy) void gui_changesettings(void) { - + } void gui_fps (int x) @@ -1778,15 +1778,15 @@ void gui_filename (int num, const char *name) void gui_handle_events (void) { int pause_uae = FALSE; - + if (no_gui) return; do { - while (pause_uae || comm_pipe_has_data (&from_gui_pipe)) { - int cmd = read_comm_pipe_int_blocking (&from_gui_pipe); - int n; - switch (cmd) { + while (pause_uae || comm_pipe_has_data (&from_gui_pipe)) { + int cmd = read_comm_pipe_int_blocking (&from_gui_pipe); + int n; + switch (cmd) { case 0: n = read_comm_pipe_int_blocking (&from_gui_pipe); changed_prefs.df[n][0] = '\0'; @@ -1839,8 +1839,8 @@ void gui_handle_events (void) free (gui_keyname); uae_sem_post (&gui_sem); break; - } - } + } + } } while (pause_uae); } @@ -1856,7 +1856,7 @@ int gui_init (void) uae_thread_id tid; gui_active = 0; - + init_comm_pipe (&to_gui_pipe, 20, 1); init_comm_pipe (&from_gui_pipe, 20, 1); uae_sem_init (&gui_sem, 0, 1); diff --git a/hardfile.c b/hardfile.c index 8026f0f0..d4e209f7 100755 --- a/hardfile.c +++ b/hardfile.c @@ -687,7 +687,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata case CMD_REMCHANGEINT: release_async_request (hfpd, request); break; - + case HD_SCSICMD: /* SCSI */ if (hfd->nrcyls == 0) error = handle_scsi (request, hfd); @@ -705,7 +705,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata hf_log2 ("hf: unit=%d, request=%p, cmd=%d offset=%u len=%d, actual=%d error%=%d\n", unit, request, get_word(request + 28), get_long (request + 44), get_long (request + 36), actual, error); - + return async; } @@ -818,7 +818,7 @@ void hardfile_reset (void) if (hfpd->opencount > 0) { for (j = 0; j < MAX_ASYNC_REQUESTS; j++) { uaecptr request; - if (request = hfpd->d_request[i]) + if (request = hfpd->d_request[i]) abort_async (hfpd, request, 0, 0); } } diff --git a/include/blkdev.h b/include/blkdev.h index 51d613d2..16beb20f 100755 --- a/include/blkdev.h +++ b/include/blkdev.h @@ -39,7 +39,7 @@ struct device_info { int bytespersector; int bus, target, lun; int id; - char label[60]; + char *label; }; typedef int (*open_bus_func)(int flags); diff --git a/include/bsdsocket.h b/include/bsdsocket.h index 33ca35b4..ea4ff77d 100755 --- a/include/bsdsocket.h +++ b/include/bsdsocket.h @@ -76,7 +76,7 @@ struct socketbase { struct UAEBSDBase { char dummy[LIBRARY_SIZEOF]; - struct socketbase *sb; + uae_u32 sb[sizeof (void*) / 4]; char scratchbuf[SCRATCHBUFSIZE]; }; diff --git a/include/catweasel.h b/include/catweasel.h index 5fb6b281..129ff1d4 100755 --- a/include/catweasel.h +++ b/include/catweasel.h @@ -90,4 +90,4 @@ int catweasel_diskready(catweasel_drive *d); int catweasel_track0(catweasel_drive *d); -#endif \ No newline at end of file +#endif diff --git a/include/compemu.h b/include/compemu.h index 8f4ede07..ada579b4 100755 --- a/include/compemu.h +++ b/include/compemu.h @@ -1,3 +1,9 @@ +#ifdef CPU_64_BIT +typedef uae_u64 uintptr; +#else +typedef uae_u32 uintptr; +#endif + #define USE_OPTIMIZER 0 #define USE_LOW_OPTIMIZER 0 #define USE_ALIAS 1 diff --git a/include/keyboard.h b/include/keyboard.h index c09676c3..017c2ff1 100755 --- a/include/keyboard.h +++ b/include/keyboard.h @@ -149,5 +149,6 @@ enum aks { AKS_ENTERGUI = 0x200, AKS_SCREENSHOT, AKS_FREEZEBUTTON, AKS_STATESAVEDIALOG, AKS_STATERESTOREDIALOG, AKS_DECREASEREFRESHRATE, AKS_INCREASEREFRESHRATE, - AKS_ARCADIADIAGNOSTICS, AKS_ARCADIAPLY1, AKS_ARCADIAPLY2, AKS_ARCADIACOIN1, AKS_ARCADIACOIN2 + AKS_ARCADIADIAGNOSTICS, AKS_ARCADIAPLY1, AKS_ARCADIAPLY2, AKS_ARCADIACOIN1, AKS_ARCADIACOIN2, + AKS_TOGGLEMOUSEGRAB, AKS_SWITCHINTERPOL }; diff --git a/include/options.h b/include/options.h index 46f5f9a1..ebd972da 100755 --- a/include/options.h +++ b/include/options.h @@ -219,11 +219,14 @@ struct uae_prefs { int win32_no_overlay; /* If this is set, we won't try and use any RGB overlays */ int win32_ctrl_F11_is_quit; int win32_automount_drives; + int win32_automount_netdrives; int win32_midioutdev; int win32_midiindev; int win32_aspi; int win32_soundcard; int win32_norecyclebin; + int win32_specialkey; + int win32_kbledmode; int curses_reverse_video; @@ -250,6 +253,7 @@ struct uae_prefs { extern char optionsfile[]; extern void save_options (struct zfile *, struct uae_prefs *, int); extern void cfgfile_write (struct zfile *, char *format,...); +extern void cfgfile_target_write (struct zfile *, char *format,...); extern void cfgfile_backup (const char *path); extern void default_prefs (struct uae_prefs *, int); diff --git a/include/parallel.h b/include/parallel.h index f5bd4004..043d2e9b 100755 --- a/include/parallel.h +++ b/include/parallel.h @@ -5,5 +5,3 @@ extern void flushprinter (void); extern void closeprinter (void); extern void openprinter (void); extern int isprinteropen (void); - - diff --git a/include/sysdeps.h b/include/sysdeps.h index 5ae50cb7..de324ab2 100755 --- a/include/sysdeps.h +++ b/include/sysdeps.h @@ -468,7 +468,7 @@ extern void logging_init(void); #elif _MSC_VER #define STATIC_INLINE static __forceinline #define NOINLINE __declspec(noinline) -#define NORETURN __declspec(noreturn) +#define NORETURN __declspec(noreturn) #else #define STATIC_INLINE static __inline__ #define NOINLINE diff --git a/include/unzip.h b/include/unzip.h index 4b290eca..ecd2b82c 100755 --- a/include/unzip.h +++ b/include/unzip.h @@ -58,12 +58,6 @@ typedef int (ZEXPORT *DEFLATEEND)(z_streamp strm); typedef int (ZEXPORT *DEFLATE)(z_streamp strm, int flush); typedef uLong (ZEXPORT *CRC32)(uLong crc, const Bytef *buf, uInt len); -extern INFLATEINIT2 pinflateInit2; -extern INFLATEINIT pinflateInit; -extern INFLATEEND pinflateEnd; -extern INFLATE pinflate; -extern CRC32 pcrc32; - #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ diff --git a/include/xwin.h b/include/xwin.h index 74e51dbe..0e9f9d26 100755 --- a/include/xwin.h +++ b/include/xwin.h @@ -18,6 +18,8 @@ extern void graphics_leave (void); extern void handle_events (void); extern void setup_brkhandler (void); extern int isfullscreen (void); +extern void toggle_fullscreen (void); +extern void toggle_mousegrab (void); extern void flush_line (int); extern void flush_block (int, int); diff --git a/include/zfile.h b/include/zfile.h index 583ff0e0..3c096aa1 100755 --- a/include/zfile.h +++ b/include/zfile.h @@ -7,7 +7,6 @@ */ struct zfile; -extern int is_zlib; typedef int (*zfile_callback)(struct zfile*, void*); diff --git a/inputdevice.c b/inputdevice.c index a25a1274..8dd7d989 100755 --- a/inputdevice.c +++ b/inputdevice.c @@ -123,7 +123,7 @@ static int isdevice (struct uae_input_device *id) int inputdevice_uaelib (char *s, char *parm) { int i; - + for (i = 1; events[i].name; i++) { if (!strcmp (s, events[i].confname)) { handle_input_event (i, atol (parm), 1, 0); @@ -370,19 +370,19 @@ void read_inputdevice_config (struct uae_prefs *pr, char *option, char *value) option += 6; /* "input." */ p = getstring (&option); - if (!strcasecmp (p, "config")) + if (!strcasecmp (p, "config")) pr->input_selected_setting = atol (value); - if (!strcasecmp (p, "joymouse_speed_analog")) + if (!strcasecmp (p, "joymouse_speed_analog")) pr->input_joymouse_multiplier = atol (value); - if (!strcasecmp (p, "joymouse_speed_digital")) + if (!strcasecmp (p, "joymouse_speed_digital")) pr->input_joymouse_speed = atol (value); - if (!strcasecmp (p, "joystick_deadzone")) + if (!strcasecmp (p, "joystick_deadzone")) pr->input_joystick_deadzone = atol (value); - if (!strcasecmp (p, "joymouse_deadzone")) + if (!strcasecmp (p, "joymouse_deadzone")) pr->input_joymouse_deadzone = atol (value); - if (!strcasecmp (p, "mouse_speed")) + if (!strcasecmp (p, "mouse_speed")) pr->input_mouse_speed = atol (value); - if (!strcasecmp (p, "autofire")) + if (!strcasecmp (p, "autofire")) pr->input_autofire_framecnt = atol (value); idnum = atol (p); if (idnum <= 0 || idnum > MAX_INPUT_SETTINGS) @@ -449,7 +449,7 @@ void read_inputdevice_config (struct uae_prefs *pr, char *option, char *value) num = getnum (&p); } p = value; - + custom = NULL; for (subnum = 0; subnum < MAX_INPUT_SUB_EVENT; subnum++) { xfree (custom); @@ -608,7 +608,7 @@ static void mouseupdate (int pct) mouse_frame_x[i] = mouse_x[i]; mouse_frame_y[i] = mouse_y[i]; } - + } } @@ -729,7 +729,7 @@ uae_u8 handle_joystick_buttons (uae_u8 dra) { uae_u8 but = 0; int i; - + for (i = 0; i < 2; i++) { if (cd32_pad_enabled[i]) { uae_u16 p5dir = 0x0200 << (i * 4); @@ -751,8 +751,8 @@ uae_u8 handle_joystick_buttons (uae_u8 dra) void handle_cd32_joystick_cia (uae_u8 pra, uae_u8 dra) { static int oldstate[2]; - int i; - + int i; + for (i = 0; i < 2; i++) { uae_u8 but = 0x40 << i; uae_u16 p5dir = 0x0200 << (i * 4); /* output enable P5 */ @@ -978,6 +978,19 @@ static void queue_input_event (int event, int state, int max, int framecnt, int static uae_u8 keybuf[256]; static int inputcode_pending, inputcode_pending_state; + void inputdevice_release_all_keys (void) + { + int i; + + for (i = 0; i < 0x80; i++) { + if (keybuf[i] != 0) { + keybuf[i] = 0; + record_key (i << 1|1); + } + } + } + + void inputdevice_add_inputcode (int code, int state) { inputcode_pending = code; @@ -1014,23 +1027,23 @@ void inputdevice_handle_inputcode (void) #ifdef ARCADIA switch (code) { - case AKS_ARCADIADIAGNOSTICS: + case AKS_ARCADIADIAGNOSTICS: arcadia_flag &= ~1; arcadia_flag |= state ? 1 : 0; break; - case AKS_ARCADIAPLY1: + case AKS_ARCADIAPLY1: arcadia_flag &= ~4; arcadia_flag |= state ? 4 : 0; break; - case AKS_ARCADIAPLY2: + case AKS_ARCADIAPLY2: arcadia_flag &= ~2; arcadia_flag |= state ? 2 : 0; break; - case AKS_ARCADIACOIN1: + case AKS_ARCADIACOIN1: if (state) arcadia_coin[0]++; break; - case AKS_ARCADIACOIN2: + case AKS_ARCADIACOIN2: if (state) arcadia_coin[1]++; break; @@ -1041,123 +1054,126 @@ void inputdevice_handle_inputcode (void) return; switch (code) { - case AKS_ENTERGUI: + case AKS_ENTERGUI: gui_display (-1); break; - case AKS_SCREENSHOT: + case AKS_SCREENSHOT: screenshot(1, 1); break; #ifdef ACTION_REPLAY - case AKS_FREEZEBUTTON: + case AKS_FREEZEBUTTON: action_replay_freeze (); break; #endif - case AKS_FLOPPY0: + case AKS_FLOPPY0: gui_display (0); break; - case AKS_FLOPPY1: + case AKS_FLOPPY1: gui_display (1); break; - case AKS_FLOPPY2: + case AKS_FLOPPY2: gui_display (2); break; - case AKS_FLOPPY3: + case AKS_FLOPPY3: gui_display (3); break; - case AKS_EFLOPPY0: + case AKS_EFLOPPY0: disk_eject (0); break; - case AKS_EFLOPPY1: + case AKS_EFLOPPY1: disk_eject (1); break; - case AKS_EFLOPPY2: + case AKS_EFLOPPY2: disk_eject (2); break; - case AKS_EFLOPPY3: + case AKS_EFLOPPY3: disk_eject (3); break; - case AKS_IRQ7: + case AKS_IRQ7: Interrupt (7); break; - case AKS_PAUSE: + case AKS_PAUSE: pausemode (-1); break; - case AKS_WARP: + case AKS_WARP: warpmode (-1); break; - case AKS_INHIBITSCREEN: + case AKS_INHIBITSCREEN: toggle_inhibit_frame (IHF_SCROLLLOCK); break; - case AKS_STATEREWIND: + case AKS_STATEREWIND: savestate_dorewind(1); break; - case AKS_VOLDOWN: + case AKS_VOLDOWN: sound_volume (-1); break; - case AKS_VOLUP: + case AKS_VOLUP: sound_volume (1); break; - case AKS_VOLMUTE: + case AKS_VOLMUTE: sound_volume (0); break; - case AKS_QUIT: + case AKS_QUIT: uae_quit (); break; - case AKS_SOFTRESET: + case AKS_SOFTRESET: uae_reset (0); break; - case AKS_HARDRESET: + case AKS_HARDRESET: uae_reset (1); break; - case AKS_STATESAVEQUICK: - case AKS_STATESAVEQUICK1: - case AKS_STATESAVEQUICK2: - case AKS_STATESAVEQUICK3: - case AKS_STATESAVEQUICK4: - case AKS_STATESAVEQUICK5: - case AKS_STATESAVEQUICK6: - case AKS_STATESAVEQUICK7: - case AKS_STATESAVEQUICK8: - case AKS_STATESAVEQUICK9: + case AKS_STATESAVEQUICK: + case AKS_STATESAVEQUICK1: + case AKS_STATESAVEQUICK2: + case AKS_STATESAVEQUICK3: + case AKS_STATESAVEQUICK4: + case AKS_STATESAVEQUICK5: + case AKS_STATESAVEQUICK6: + case AKS_STATESAVEQUICK7: + case AKS_STATESAVEQUICK8: + case AKS_STATESAVEQUICK9: savestate_quick ((code - AKS_STATESAVEQUICK) / 2, 1); break; - case AKS_STATERESTOREQUICK: - case AKS_STATERESTOREQUICK1: - case AKS_STATERESTOREQUICK2: - case AKS_STATERESTOREQUICK3: - case AKS_STATERESTOREQUICK4: - case AKS_STATERESTOREQUICK5: - case AKS_STATERESTOREQUICK6: - case AKS_STATERESTOREQUICK7: - case AKS_STATERESTOREQUICK8: - case AKS_STATERESTOREQUICK9: + case AKS_STATERESTOREQUICK: + case AKS_STATERESTOREQUICK1: + case AKS_STATERESTOREQUICK2: + case AKS_STATERESTOREQUICK3: + case AKS_STATERESTOREQUICK4: + case AKS_STATERESTOREQUICK5: + case AKS_STATERESTOREQUICK6: + case AKS_STATERESTOREQUICK7: + case AKS_STATERESTOREQUICK8: + case AKS_STATERESTOREQUICK9: savestate_quick ((code - AKS_STATERESTOREQUICK) / 2, 0); break; - case AKS_TOGGLEFULLSCREEN: - fullscreentoggle (); + case AKS_TOGGLEFULLSCREEN: + toggle_fullscreen (); break; - case AKS_ENTERDEBUGGER: + case AKS_TOGGLEMOUSEGRAB: + toggle_mousegrab (); + break; + case AKS_ENTERDEBUGGER: activate_debugger (); break; - case AKS_STATESAVEDIALOG: + case AKS_STATESAVEDIALOG: gui_display (5); - break; + break; case AKS_STATERESTOREDIALOG: gui_display (4); break; - case AKS_DECREASEREFRESHRATE: - case AKS_INCREASEREFRESHRATE: - { - int dir = code == AKS_INCREASEREFRESHRATE ? 5 : -5; - if (currprefs.chipset_refreshrate == 0) - currprefs.chipset_refreshrate = currprefs.ntscmode ? 60 : 50; - changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate + dir; - if (changed_prefs.chipset_refreshrate < 10) - changed_prefs.chipset_refreshrate = 10; - if (changed_prefs.chipset_refreshrate > 900) - changed_prefs.chipset_refreshrate = 900; - } - break; + case AKS_DECREASEREFRESHRATE: + case AKS_INCREASEREFRESHRATE: + { + int dir = code == AKS_INCREASEREFRESHRATE ? 5 : -5; + if (currprefs.chipset_refreshrate == 0) + currprefs.chipset_refreshrate = currprefs.ntscmode ? 60 : 50; + changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate + dir; + if (changed_prefs.chipset_refreshrate < 10) + changed_prefs.chipset_refreshrate = 10; + if (changed_prefs.chipset_refreshrate > 900) + changed_prefs.chipset_refreshrate = 900; + } + break; } } @@ -1165,7 +1181,7 @@ int handle_input_event (int nr, int state, int max, int autofire) { struct inputevent *ie; int joy; - + if (nr <= 0) return 0; ie = &events[nr]; @@ -1319,7 +1335,7 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev uae_u32 omask = id2->buttonmask & mask; uae_u32 nmask = (state ? 1 : 0) << button; char *custom; - + if (button >= ID_BUTTON_TOTAL) return; for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) { @@ -1341,7 +1357,7 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev id2->buttonmask |= mask; else id2->buttonmask &= ~mask; - } + } } @@ -1597,7 +1613,7 @@ void inputdevice_updateconfig (struct uae_prefs *prefs) mouse_delta[i][2] = 0; } memset (keybuf, 0, sizeof (keybuf)); - + for (i = 0; i < INPUT_QUEUE_SIZE; i++) input_queue[i].framecnt = input_queue[i].nextframecnt = -1; @@ -1690,7 +1706,7 @@ void inputdevice_setkeytranslation (struct uae_input_device_kbr_default *trans) keyboard_default = trans; } -int inputdevice_translatekeycode (int keyboard, int scancode, int state) +static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int state) { struct uae_input_device *na = &keyboards[keyboard]; int j, k; @@ -1715,6 +1731,42 @@ int inputdevice_translatekeycode (int keyboard, int scancode, int state) return handled; } +#define IECODE_UP_PREFIX 0x80 +#define RAW_STEALTH 0x68 +#define STEALTHF_E0KEY 0x08 +#define STEALTHF_UPSTROKE 0x04 +#define STEALTHF_SPECIAL 0x02 +#define STEALTHF_E1KEY 0x01 + +static void sendmmcodes(int code, int newstate) +{ + uae_u8 b; + + b = RAW_STEALTH | IECODE_UP_PREFIX; + record_key(((b << 1) | (b >> 7)) & 0xff); + b = IECODE_UP_PREFIX; + if ((code >> 8) == 0x01) + b |= STEALTHF_E0KEY; + if ((code >> 8) == 0x02) + b |= STEALTHF_E1KEY; + if (!newstate) + b |= STEALTHF_UPSTROKE; + record_key(((b << 1) | (b >> 7)) & 0xff); + b = ((code >> 4) & 0x0f) | IECODE_UP_PREFIX; + record_key(((b << 1) | (b >> 7)) & 0xff); + b = (code & 0x0f) | IECODE_UP_PREFIX; + record_key(((b << 1) | (b >> 7)) & 0xff); +} + +int inputdevice_translatekeycode (int keyboard, int scancode, int state) +{ + if (inputdevice_translatekeycode_2 (keyboard, scancode, state)) + return 1; + if (currprefs.mmkeyboard) + sendmmcodes(scancode, state); + return 0; +} + static struct inputdevice_functions idev[3]; void inputdevice_init (void) @@ -2060,7 +2112,7 @@ void inputdevice_copyconfig (struct uae_prefs *src, struct uae_prefs *dst) memcpy (&dst->keyboard_settings[i][j], &src->keyboard_settings[i][j], sizeof (struct uae_input_device)); } } - + inputdevice_updateconfig (dst); } @@ -2090,7 +2142,7 @@ void inputdevice_swap_ports (struct uae_prefs *p, int devnum) k++; } } - } + } } void inputdevice_copy_single_config (struct uae_prefs *p, int src, int dst, int devnum) @@ -2248,7 +2300,7 @@ void setmousestate (int mouse, int axis, int data, int isabs) fract2[mouse][axis] += v; diff = fract2[mouse][axis] - fract1[mouse][axis]; if (diff > 1 || diff < -1) { - v -= (int)diff; + v -= (int)diff; fract2[mouse][axis] -= diff; } for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) diff --git a/inputevents.def b/inputevents.def index ac6d3e47..f6df1d64 100755 --- a/inputevents.def +++ b/inputevents.def @@ -299,13 +299,16 @@ DEFEVENT(SPC_VOLUME_MUTE,"Mute/unmute volume",AM_K,0,0,AKS_VOLMUTE) DEFEVENT(SPC_QUIT,"Quit emulator",AM_K,0,0,AKS_QUIT) DEFEVENT(SPC_SOFTRESET,"Reset emulation",AM_K,0,0,AKS_SOFTRESET) DEFEVENT(SPC_HARDRESET,"Hard reset emulation",AM_K,0,0,AKS_HARDRESET) +DEFEVENT(SPC_ENTERDEBUGGER,"Activate the built-in debugger",AM_K,0,0,AKS_ENTERDEBUGGER) DEFEVENT(SPC_STATESAVE,"Quick save state",AM_K,0,0,AKS_STATESAVEQUICK) DEFEVENT(SPC_STATERESTORE,"Quick restore state",AM_K,0,0,AKS_STATERESTOREQUICK) DEFEVENT(SPC_STATESAVEDIALOG,"Save state",AM_K,0,0,AKS_STATESAVEDIALOG) DEFEVENT(SPC_STATERESTOREDIALOG,"Restore state",AM_K,0,0,AKS_STATERESTOREDIALOG) DEFEVENT(SPC_TOGGLEFULLSCREEN,"Toggle windowed/fullscreen",AM_K,0,0,AKS_TOGGLEFULLSCREEN) +DEFEVENT(SPC_TOGGLEMOUSEGRAB,"Toggle between mouse grabbed and un-grabbed",AM_K,0,0,AKS_TOGGLEMOUSEGRAB) DEFEVENT(SPC_DECREASE_REFRESHRATE,"Decrease emulation speed",AM_K,0,0,AKS_DECREASEREFRESHRATE) DEFEVENT(SPC_INCREASE_REFRESHRATE,"Increase emulation speed",AM_K,0,0,AKS_INCREASEREFRESHRATE) +DEFEVENT(SPC_SWITCHINTERPOL,"Switch between audio interpolation methods",AM_K,0,0,AKS_SWITCHINTERPOL) DEFEVENT(SPC_ARCADIA_DIAGNOSTICS,"Arcadia diagnostics dip switch",AM_K,0,0,AKS_ARCADIADIAGNOSTICS) DEFEVENT(SPC_ARCADIA_PLAYER1,"Arcadia player 1",AM_K,0,0,AKS_ARCADIAPLY1) diff --git a/memory.c b/memory.c index bd5521e4..4f043c27 100755 --- a/memory.c +++ b/memory.c @@ -75,7 +75,7 @@ void romlist_add (char *path, struct romdata *rd) char *romlist_get (struct romdata *rd) { int i; - + if (!rd) return 0; for (i = 0; i < romlist_cnt; i++) { @@ -147,7 +147,8 @@ static struct romdata roms[] = { { "Space Ranger\0ar_sprg", 0, 0, 0, 0, 43, 0, 0, ROMTYPE_ARCADIA }, { "Xenon\0ar_xeon", 0, 0, 0, 0, 44, 0, 0, ROMTYPE_ARCADIA }, - { 0 } + { NULL, 0, 0, 0, 0, 0, 0, 0, 0 } + }; struct romdata *getarcadiarombyname (char *name) @@ -183,7 +184,7 @@ uae_u8 *load_keyfile (struct uae_prefs *p, char *path, int *size) uae_u8 *keybuf = 0; int keysize = 0; char tmp[MAX_PATH], *d; - + tmp[0] = 0; if (path) strcpy (tmp, path); @@ -219,7 +220,7 @@ uae_u8 *load_keyfile (struct uae_prefs *p, char *path, int *size) f = zfile_fopen(tmp, "rb"); } } - + } } @@ -349,7 +350,7 @@ struct romdata *getromdatabyzfile (struct zfile *f) memset (p, 0, size); zfile_fseek (f, 0, SEEK_SET); zfile_fread (p, 1, size, f); - zfile_fseek (f, pos, SEEK_SET); + zfile_fseek (f, pos, SEEK_SET); rd = getromdatabydata (p, size); xfree (p); return rd; @@ -472,7 +473,7 @@ void REGPARAM2 dummy_lput (uaecptr addr, uae_u32 l) { #ifdef JIT special_mem |= S_WRITE; -#endif +#endif if (currprefs.illegal_mem) { if (illegal_count < MAX_ILG) { illegal_count++; @@ -1406,7 +1407,7 @@ int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksum, int } else { cr = 1; } - + if (cloanto_rom) *cloanto_rom = cr; @@ -1475,7 +1476,7 @@ static void kickstart_fix_checksum (uae_u8 *mem, int size) { uae_u32 cksum = 0, prevck = 0; int i, ch = size == 524288 ? 0x7ffe8 : 0x3e; - + mem[ch] = 0; mem[ch + 1] = 0; mem[ch + 2] = 0; @@ -1504,7 +1505,7 @@ static int patch_shapeshifter (uae_u8 *kickmemory) uae_u8 kickshift1[] = { 0x41, 0xf8, 0x04, 0x00 }; uae_u8 kickshift2[] = { 0x41, 0xf8, 0x10, 0x00 }; uae_u8 kickshift3[] = { 0x43, 0xf8, 0x04, 0x00 }; - + for (i = 0x200; i < 0x300; i++) { if (!memcmp (kickmemory + i, kickshift1, sizeof (kickshift1)) || !memcmp (kickmemory + i, kickshift2, sizeof (kickshift2)) || @@ -1577,7 +1578,7 @@ static int load_kickstart (void) if( f == NULL ) { /* still no luck */ #if defined(AMIGA)||defined(__POS__) #define USE_UAE_ERSATZ "USE_UAE_ERSATZ" - if( !getenv(USE_UAE_ERSATZ)) + if( !getenv(USE_UAE_ERSATZ)) { write_log ("Using current ROM. (create ENV:%s to " "use uae's ROM replacement)\n",USE_UAE_ERSATZ); @@ -1693,7 +1694,7 @@ static void delete_shmmaps (uae_u32 start, uae_u32 size) } } } - + static void add_shmmaps (uae_u32 start, addrbank *what) { shmpiece *x = shm_start; @@ -2024,14 +2025,14 @@ void memory_reset (void) #ifdef ARCADIA if (!arcadia_rom) { #endif - action_replay_memory_reset(); + action_replay_memory_reset(); #ifdef ACTION_REPLAY_HRTMON hrtmon_map_banks(); #endif #ifndef ACTION_REPLAY_HIDE_CARTRIDGES #ifdef ACTION_REPLAY - action_replay_map_banks(); + action_replay_map_banks(); #endif #endif #ifdef ARCADIA @@ -2064,10 +2065,10 @@ void memory_init (void) ersatzkickfile = 1; #endif -#ifdef ACTION_REPLAY +#ifdef ACTION_REPLAY action_replay_load(); action_replay_init(1); - + #ifdef ACTION_REPLAY_HRTM hrtmon_load(1); #endif @@ -2091,7 +2092,7 @@ void memory_cleanup (void) xfree (a1000_bootrom); if (chipmemory) mapped_free (chipmemory); - + bogomemory = 0; kickmemory = 0; a1000_bootrom = 0; @@ -2198,7 +2199,7 @@ uae_u8 *restore_rom (uae_u8 *src) { uae_u32 crc32; int i; - + restore_u32 (); restore_u32 (); restore_u32 (); diff --git a/native2amiga.c b/native2amiga.c index fe628016..34ac6185 100755 --- a/native2amiga.c +++ b/native2amiga.c @@ -4,7 +4,7 @@ * Call Amiga Exec functions outside the main UAE thread. * * Copyright 1999 Patrick Ohly - * + * * Uses the EXTER interrupt that is setup in filesys.c * and needs thread support. */ diff --git a/newcpu.c b/newcpu.c index 1c72e9c0..52115cb8 100755 --- a/newcpu.c +++ b/newcpu.c @@ -343,7 +343,7 @@ void init_m68k (void) write_log (" 24-bit addressing"); } write_log ("\n"); - + read_table68k (); do_merges (); @@ -821,7 +821,7 @@ static void exception_debug (int nr) #ifdef DEBUGGER if (!exception_debugging) return; - console_out ("Exception %d, PC=%08.8X\n", nr, m68k_getpc()); + console_out ("Exception %d, PC=%08.8X\n", nr, m68k_getpc()); #endif } @@ -1127,7 +1127,7 @@ int m68k_move2c (int regno, uae_u32 *regp) switch (regno) { case 0: regs.sfc = *regp & 7; break; case 1: regs.dfc = *regp & 7; break; - case 2: + case 2: cacr = *regp & (currprefs.cpu_level < 4 ? 0x3 : (currprefs.cpu_level == 4 ? 0x80008000 : 0xf8800e00)); #ifdef JIT if (currprefs.cpu_level < 4) { @@ -1654,14 +1654,14 @@ static int do_specialties (int cycles) if(!(regs.spcflags & ~SPCFLAG_ACTION_REPLAY)) return 0; } #endif - if ((regs.spcflags & SPCFLAG_ACTION_REPLAY) && action_replay_flag != ACTION_REPLAY_INACTIVE ) + if ((regs.spcflags & SPCFLAG_ACTION_REPLAY) && action_replay_flag != ACTION_REPLAY_INACTIVE ) { /*if(action_replay_flag == ACTION_REPLAY_ACTIVE && !is_ar_pc_in_rom())*/ /* write_log("PC:%p\n",m68k_getpc());*/ - - if(action_replay_flag == ACTION_REPLAY_ACTIVATE || action_replay_flag == ACTION_REPLAY_DORESET) + + if(action_replay_flag == ACTION_REPLAY_ACTIVATE || action_replay_flag == ACTION_REPLAY_DORESET) action_replay_enter(); - if(action_replay_flag == ACTION_REPLAY_HIDE && !is_ar_pc_in_rom()) + if(action_replay_flag == ACTION_REPLAY_HIDE && !is_ar_pc_in_rom()) { action_replay_hide(); unset_special(SPCFLAG_ACTION_REPLAY); @@ -1887,14 +1887,14 @@ void exec_nostats(void) { int new_cycles; - for (;;) - { + for (;;) + { uae_u16 opcode = get_iword(0); #if defined X86_ASSEMBLY __asm__ __volatile__("\tpush %%ebp\n\tcall *%%ebx\n\tpop %%ebp" /* FIXME */ - : "=&a" (new_cycles) + : "=&a" (new_cycles) : "b" (cpufunctbl[opcode]), "0" (opcode) - : "%edx", "%ecx", "%esi", "%edi", + : "%edx", "%ecx", "%esi", "%edi", "%ebp", "memory", "cc"); #else new_cycles = (*cpufunctbl[opcode])(opcode); @@ -1903,7 +1903,7 @@ void exec_nostats(void) new_cycles &= cycles_mask; new_cycles |= cycles_val; do_cycles (new_cycles); - + if (end_block(opcode) || regs.spcflags) { return; /* We will deal with the spcflags in the caller */ @@ -1924,9 +1924,9 @@ void execute_normal(void) return; total_cycles = 0; blocklen = 0; - start_pc_p = regs.pc_oldp; - start_pc = regs.pc; - for (;;) + start_pc_p = regs.pc_oldp; + start_pc = regs.pc; + for (;;) { /* Take note: This is the do-it-normal loop */ uae_u16 opcode = get_iword (0); @@ -1934,9 +1934,9 @@ void execute_normal(void) pc_hist[blocklen].location = (uae_u16*)regs.pc_p; #if defined X86_ASSEMBLY __asm__ __volatile__("\tpush %%ebp\n\tcall *%%ebx\n\tpop %%ebp" /* FIXME */ - : "=&a" (new_cycles) + : "=&a" (new_cycles) : "b" (cpufunctbl[opcode]), "0" (opcode) - : "%edx", "%ecx", "%esi", "%edi", + : "%edx", "%ecx", "%esi", "%edi", "%ebp", "memory", "cc"); #else new_cycles = (*cpufunctbl[opcode])(opcode); @@ -1961,11 +1961,11 @@ typedef void compiled_handler(void); static void m68k_run_2a (void) { - for (;;) { -#if defined X86_ASSEMBLY + for (;;) { +#if defined X86_ASSEMBLY __asm__ __volatile__( "\tpush %%ebp\n\tcall *%0\n\tpop %%ebp" /* FIXME */ - :: "m" (cache_tags[cacheline(regs.pc_p)].handler) + :: "m" (cache_tags[cacheline(regs.pc_p)].handler) : "%edx", "%ecx", "%eax", "%esi", "%ebx", "%edi", "%ebp", "memory", "cc"); #else @@ -2226,8 +2226,8 @@ void m68k_go (int may_quit) currprefs.cpu_level == 0 && currprefs.cpu_compatible ? m68k_run_1 : currprefs.cpu_compatible ? m68k_run_2p : m68k_run_2); #else - m68k_run1 (currprefs.cpu_cycle_exact && currprefs.cpu_level == 0 ? m68k_run_1_ce : - currprefs.cpu_compatible > 0 && currprefs.cpu_level == 0 ? m68k_run_1 : + m68k_run1 (currprefs.cpu_cycle_exact && currprefs.cpu_level == 0 ? m68k_run_1_ce : + currprefs.cpu_compatible > 0 && currprefs.cpu_level == 0 ? m68k_run_1 : currprefs.cpu_level >= 2 && currprefs.cachesize ? m68k_run_2a : currprefs.cpu_compatible ? m68k_run_2p : m68k_run_2); #endif @@ -2310,7 +2310,7 @@ void m68k_disasm (void *f, uaecptr addr, uaecptr *nextpc, int cnt) newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname); } - + for (i = 0; i < (m68kpc_offset - oldpc) / 2; i++) { f_out (f, "%04x ", get_iword_1 (oldpc + i * 2)); } @@ -2378,7 +2378,7 @@ void sm68k_disasm(char *instrname, char *instrcode, uaecptr addr, uaecptr *nextp newpc = m68k_getpc () + m68kpc_offset; newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname); } - + if (instrcode) { int i; @@ -2573,6 +2573,7 @@ void exception3 (uae_u32 opcode, uaecptr addr, uaecptr fault) { exception3f (opcode, addr, fault, 0, 0); } + void exception3i (uae_u32 opcode, uaecptr addr, uaecptr fault) { exception3f (opcode, addr, fault, 0, 1); @@ -2647,7 +2648,7 @@ void cpureset (void) Best case without signed overflow: 122 cycles. Best case with signed overflow: 120 cycles - + */ diff --git a/od-win32/ahidsound.c b/od-win32/ahidsound.c index 9a267635..e038fad9 100755 --- a/od-win32/ahidsound.c +++ b/od-win32/ahidsound.c @@ -70,7 +70,7 @@ static unsigned int dwBytes,dwBytes1,dwBytes2,espstore; static LPVOID dwData1,dwData2; int ahi_pollrate = 40; -int sound_freq_ahi; +int sound_freq_ahi, sound_channels_ahi, sound_bits_ahi; static int vin,devicenum; static int amigablksize; @@ -235,7 +235,7 @@ void ahi_updatesound(int force) //memset( lpData, 0x80,4 ); } /* - { +{ long dwEvt=1; dwEvt = MsgWaitForMultipleObjects( @@ -251,7 +251,7 @@ if (dwEvt==1)freeblock=1; if (dwEvt>1 ){calcsound=0;return;} - } +} */ hr = IDirectSoundBuffer_GetCurrentPosition(lpDSB2, &i, 0); @@ -334,10 +334,10 @@ static int ahi_init_sound_win32 (void) enumerate_sound_devices (0); wavfmt.wFormatTag = WAVE_FORMAT_PCM; - wavfmt.nChannels = 2; + wavfmt.nChannels = sound_channels_ahi; wavfmt.nSamplesPerSec = sound_freq_ahi; - wavfmt.wBitsPerSample = 16; - wavfmt.nBlockAlign = 16 / 8 * 2; + wavfmt.wBitsPerSample = sound_bits_ahi; + wavfmt.nBlockAlign = wavfmt.wBitsPerSample / 8 * wavfmt.nChannels; wavfmt.nAvgBytesPerSec = wavfmt.nBlockAlign * sound_freq_ahi; wavfmt.cbSize = 0; @@ -347,7 +347,7 @@ static int ahi_init_sound_win32 (void) if (!ahisndbuffer) return 0; hr = DirectSoundCreate( &sound_device_guid[currprefs.win32_soundcard], &lpDS2, NULL ); - if (FAILED(hr)) + if (FAILED(hr)) { write_log( "DirectSoundCreate() failure: %s\n", DXError(hr)); return 0; @@ -379,13 +379,13 @@ static int ahi_init_sound_win32 (void) if FAILED(IDirectSound_SetCooperativeLevel(lpDS2,dsound_tmpw, DSSCL_PRIORITY)) return 0; hr = IDirectSound_CreateSoundBuffer(lpDS2, &sound_buffer, &lpDSBprimary2, NULL); - if(FAILED(hr)) + if(FAILED(hr)) { write_log("CreateSoundBuffer() failure: %s\n", DXError(hr)); return 0; } hr = IDirectSoundBuffer_SetFormat(lpDSBprimary2, &wavfmt); - if(FAILED(hr)) + if(FAILED(hr)) { write_log( "SetFormat() failure: %s\n", DXError(hr)); return 0; @@ -395,7 +395,7 @@ static int ahi_init_sound_win32 (void) sound_buffer.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLVOLUME /*| DSBCAPS_CTRLPOSITIONNOTIFY */ | DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_GLOBALFOCUS |DSBCAPS_STATIC ; hr = IDirectSound_CreateSoundBuffer(lpDS2, &sound_buffer, &lpDSB2, NULL); - if (FAILED(hr)) + if (FAILED(hr)) { write_log("CreateSoundBuffer() failure: %s\n", DXError(hr)); return 0; @@ -426,21 +426,21 @@ static int ahi_init_sound_win32 (void) */ hr = IDirectSoundBuffer_SetVolume (lpDSB2, 0); - if (FAILED(hr)) + if (FAILED(hr)) { write_log("SetVolume() 2 failure: %s\n", DXError(hr)); return 0; } hr = IDirectSoundBuffer_GetFormat(lpDSBprimary2,&wavfmt,500,0); - if(FAILED(hr)) + if(FAILED(hr)) { write_log("GetFormat() failure: %s\n", DXError(hr)); return 0; } // Record begin hr = DirectSoundCaptureCreate( NULL, &lpDS2r, NULL ); - if (FAILED(hr)) + if (FAILED(hr)) { write_log( "DirectSoundCaptureCreate() failure: %s\n", DXError(hr)); norec = 1; @@ -460,14 +460,15 @@ static int ahi_init_sound_win32 (void) norec = 1; } } - + if(ahisndbuffer==0) return 0; ahisndbufpt =(int*) ahisndbuffer; sndptrmax = ahisndbuffer + ahisndbufsize; samplecount = 0; memset(ahisndbuffer, soundneutral, amigablksize*8); - write_log("Init AHI Sound Rate %d Buffsize %d\n",sound_freq_ahi,amigablksize); + write_log("Init AHI Sound Rate %d, Channels %d, Bits %d, Buffsize %d\n", + sound_freq_ahi, sound_channels_ahi, sound_bits_ahi, amigablksize); if (!norec) write_log("Init AHI Audio Recording \n"); ahi_on = 1; @@ -491,7 +492,6 @@ int ahi_open_sound (void) } -static char *addr; static void *bswap_buffer = NULL; static uae_u32 bswap_buffer_size = 0; @@ -499,6 +499,7 @@ uae_u32 ahi_demux (void) { //use the extern int (6 #13) // d0 0=opensound d1=unit d2=samplerate d3=blksize ret: sound frequency +// d0 6=opensound_new d1=unit d2=samplerate d3=blksize ret d4=channels d5=bits d6=zero: sound frequency // d0 1=closesound d1=unit // d0 2=writesamples d1=unit a0=addr write blksize samples to card // d0 3=readsamples d1=unit a0=addr read samples from card ret: d0=samples read @@ -512,7 +513,8 @@ uae_u32 ahi_demux (void) // d0 4=writeinterrupt d1=unit d0=0 no interrupt happen for this unit // d0=-2 no playing open //note units for now not support use only unit 0 -// d0=10 get clipboard size d0=size in bytes +// d0 5=? + // d0=10 get clipboard size d0=size in bytes // d0=11 get clipboard data a0=clipboarddata //Note: a get clipboard size must do before // d0=12 write clipboard data a0=clipboarddata @@ -523,7 +525,7 @@ uae_u32 ahi_demux (void) // d0=103 close dll // d0=104 screenlost // d0=105 mem offset -// d0=106 16Bit byteswap +// d0=106 16Bit byteswap // d0=107 32Bit byteswap // d0=108 free swap array // d0=200 ahitweak d1=offset for dsound position pointer @@ -539,10 +541,19 @@ uae_u32 ahi_demux (void) int cur_pos; case 0: - cap_pos=0; - sound_freq_ahi=m68k_dreg (regs, 2); - amigablksize=m68k_dreg (regs, 3); - sound_freq_ahi=ahi_open_sound(); + cap_pos = 0; + sound_freq_ahi = m68k_dreg (regs, 2); + amigablksize = m68k_dreg (regs, 3); + sound_freq_ahi = ahi_open_sound(); + uaevar.changenum--; + return sound_freq_ahi; + case 6: /* new open function */ + cap_pos = 0; + sound_freq_ahi = m68k_dreg (regs, 2); + amigablksize = m68k_dreg (regs, 3); + sound_channels_ahi = m68k_dreg (regs, 4); + sound_bits_ahi = m68k_dreg (regs, 5); + sound_freq_ahi = ahi_open_sound(); uaevar.changenum--; return sound_freq_ahi; @@ -552,107 +563,104 @@ uae_u32 ahi_demux (void) return 0; case 2: - addr=(char *)m68k_areg (regs, 0); - for (i=0;i<(amigablksize*4);i+=4) - { - ahisndbufpt[0] = get_long((unsigned int)addr+i); - ahisndbufpt+=1; - /*ahisndbufpt[0]=chipmem_bget((unsigned int)addr+i+2); - ahisndbufpt+=1; - ahisndbufpt[0]=chipmem_bget((unsigned int)addr+i+1); - ahisndbufpt+=1; - ahisndbufpt[0]=chipmem_bget((unsigned int)addr+i); - ahisndbufpt+=1;*/ - } + { + uaecptr addr = m68k_areg (regs, 0); + for (i = 0; i < amigablksize * 4; i += 4) + *ahisndbufpt++ = get_long(addr + i); ahi_finish_sound_buffer(); + } return amigablksize; case 3: - if (norec)return -1; - if (!ahi_on)return -2; - i = IDirectSoundCaptureBuffer_GetCurrentPosition(lpDSB2r,&t,&cur_pos); - t = amigablksize*4; + { + uaecptr addr; + HRESULT hr; + if (norec) + return -1; + if (!ahi_on) + return -2; + hr = IDirectSoundCaptureBuffer_GetCurrentPosition(lpDSB2r,&t,&cur_pos); + if (FAILED(hr)) + return -1; + t = amigablksize * 4; - if (cap_pos<=cur_pos) - todo=cur_pos-cap_pos; + if (cap_pos <= cur_pos) + todo = cur_pos - cap_pos; else - todo=cur_pos+(RECORDBUFFER*t)-cap_pos; - if (todobus = si[unitnum].scsibus; di->target = si[unitnum].target; di->lun = si[unitnum].lun; - di->media_inserted = mediacheck (unitnum); //si[unitnum].mediainserted; + di->media_inserted = mediacheck (unitnum); di->write_protected = 1; di->bytespersector = 2048; di->cylinders = 1; di->type = si[unitnum].type; di->id = unitnum + 1; - strcpy (di->label, si[unitnum].label); + di->label = my_strdup (si[unitnum].label); return di; } @@ -828,12 +828,14 @@ void win32_aspi_media_change (char driveletter, int insert) { int i, now; - for (i = 0; i < MAX_TOTAL_DEVICES; i++) { - now = mediacheck (i); - if (now != si[i].mediainserted) { - write_log ("ASPI: media change %c %d\n", driveletter, insert); - si[i].mediainserted = now; - scsi_do_disk_change (i + 1, insert); + for (i = 0; i < unitcnt; i++) { + if (si[i].type == INQ_ROMD) { + now = mediacheck (i); + if (now != si[i].mediainserted) { + write_log ("ASPI: media change %c %d\n", driveletter, insert); + si[i].mediainserted = now; + scsi_do_disk_change (i + 1, insert); + } } } } diff --git a/od-win32/blkdev_win32_ioctl.c b/od-win32/blkdev_win32_ioctl.c index 620d8134..e7d78e33 100755 --- a/od-win32/blkdev_win32_ioctl.c +++ b/od-win32/blkdev_win32_ioctl.c @@ -431,6 +431,7 @@ static struct device_info *info_device (int unitnum, struct device_info *di) di->write_protected = 1; di->type = ciw32[unitnum].type == DRIVE_CDROM ? INQ_ROMD : INQ_DASD; di->id = ciw32[unitnum].drvletter; + di->label = xmalloc(16); sprintf (di->label, "Drive %c:", ciw32[unitnum].drvletter); return di; } diff --git a/od-win32/blkdev_win32_spti.c b/od-win32/blkdev_win32_spti.c index 9104c511..db31acd3 100755 --- a/od-win32/blkdev_win32_spti.c +++ b/od-win32/blkdev_win32_spti.c @@ -22,9 +22,14 @@ #include #include -#include +#include // Guid definition +#include // Device guids +#include // for SetupDiXxx functions. +#include // for SetupDiXxx functions. +#include #include + typedef struct _SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER { SCSI_PASS_THROUGH_DIRECT spt; ULONG Filler; @@ -34,11 +39,11 @@ typedef struct _SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER { static int unitcnt = 0; struct dev_info_spti { - char drvletter; - char drvpath[10]; + char *drvpath; int mediainserted; HANDLE handle; int isatapi; + int type; }; static uae_sem_t scgp_sem; @@ -214,19 +219,42 @@ static uae_u8 *execscsicmd_in (int unitnum, uae_u8 *data, int len, int *outlen) return scsibuf; } -static int adddrive (int unitnum, char drive) +static int total_devices; + +static int adddrive (char *drvpath, int type) { - if (unitcnt >= MAX_TOTAL_DEVICES) + int cnt = total_devices, i; + if (cnt >= MAX_TOTAL_DEVICES) return 0; - sprintf (dev_info[unitcnt].drvpath, "\\\\.\\%c:", drive); - dev_info[unitcnt].drvletter = drive; - write_log ("SPTI: selected drive %c: (uaescsi.device:%d)\n", drive, unitnum); - unitcnt++; + for (i = 0; i < total_devices; i++) { + if (!strcmp(drvpath, dev_info[i].drvpath)) + return 0; + } + dev_info[cnt].drvpath = my_strdup(drvpath); + dev_info[cnt].type = type; + write_log ("SPTI: uaescsi.device:%d ('%s')\n", cnt, drvpath); + total_devices++; return 1; } -static int total_devices; +int rescan(void); +static int open_scsi_bus (int flags) +{ + int i; + total_devices = 0; + uae_sem_init (&scgp_sem, 0, 1); + for (i = 0; i < MAX_TOTAL_DEVICES; i++) { + memset (&dev_info[i], 0, sizeof (struct dev_info_spti)); + dev_info[i].handle = INVALID_HANDLE_VALUE; + } + if (!scsibuf) + scsibuf = VirtualAlloc (NULL, DEVICE_SCSI_BUFSIZE, MEM_COMMIT, PAGE_READWRITE); + rescan(); + return total_devices; +} + +#if 0 static int open_scsi_bus (int flags) { int dwDriveMask; @@ -264,6 +292,7 @@ static int open_scsi_bus (int flags) } return total_devices; } +#endif static void close_scsi_bus (void) { @@ -310,18 +339,23 @@ int open_scsi_device (int unitnum) char *dev; dev = dev_info[unitnum].drvpath; - if (!dev[0]) + if (!dev) return 0; h = CreateFile(dev,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL); dev_info[unitnum].handle = h; if (h == INVALID_HANDLE_VALUE) { - write_log ("failed to open cd unit %d (%s)\n", unitnum, dev); + write_log ("failed to open cd unit %d err=%d ('%s')\n", unitnum, GetLastError(), dev); } else { - dev_info[unitnum].mediainserted = mediacheck (unitnum); - dev_info[unitnum].isatapi = isatapi (unitnum); - write_log ("cd unit %d %s opened (%s), %s\n", unitnum, - dev_info[unitnum].isatapi ? "[ATAPI]" : "[SCSI]", dev, - dev_info[unitnum].mediainserted ? "CD inserted" : "Drive empty"); + if (dev_info[unitnum].type == INQ_ROMD) { + dev_info[unitnum].mediainserted = mediacheck (unitnum); + dev_info[unitnum].isatapi = isatapi (unitnum); + write_log ("scsi cd unit %d opened (%s), %s ('%s')\n", unitnum, + dev_info[unitnum].isatapi ? "[ATAPI]" : "[SCSI]", + dev_info[unitnum].mediainserted ? "CD inserted" : "Drive empty", dev); + } else { + write_log ("scsi unit %d, type %d opened ('%s')\n", + unitnum, dev_info[unitnum].type, dev); + } return 1; } return 0; @@ -339,7 +373,7 @@ static struct device_info *info_device (int unitnum, struct device_info *di) { if (unitnum >= MAX_TOTAL_DEVICES || dev_info[unitnum].handle == INVALID_HANDLE_VALUE) return 0; - sprintf(di->label,"Drive %c", dev_info[unitnum].drvletter); + di->label = my_strdup(dev_info[unitnum].drvpath); di->bus = 0; di->target = unitnum; di->lun = 0; @@ -347,13 +381,27 @@ static struct device_info *info_device (int unitnum, struct device_info *di) di->write_protected = 1; di->bytespersector = 2048; di->cylinders = 1; - di->type = INQ_ROMD; - di->id = dev_info[unitnum].drvletter; + di->type = dev_info[unitnum].type; + di->id = unitnum + 1; return di; } void win32_spti_media_change (char driveletter, int insert) { +#if 1 + int i, now; + + for (i = 0; i < total_devices; i++) { + if (dev_info[i].type == INQ_ROMD) { + now = mediacheck (i); + if (now != dev_info[i].mediainserted) { + write_log ("SPTI: media change %c %d\n", driveletter, insert); + dev_info[i].mediainserted = now; + scsi_do_disk_change (i + 1, insert); + } + } + } +#else int i; for (i = 0; i < MAX_TOTAL_DEVICES; i++) { @@ -363,6 +411,7 @@ void win32_spti_media_change (char driveletter, int insert) scsi_do_disk_change (driveletter, insert); } } +#endif } static int check_isatapi (int unitnum) @@ -376,4 +425,93 @@ struct device_functions devicefunc_win32_spti = { 0, 0, 0, 0, 0, 0, 0, check_isatapi }; -#endif \ No newline at end of file +static int getCDROMProperty(int idx, HDEVINFO DevInfo, const GUID *guid) +{ + SP_DEVICE_INTERFACE_DATA interfaceData; + PSP_DEVICE_INTERFACE_DETAIL_DATA interfaceDetailData = NULL; + DWORD interfaceDetailDataSize, reqSize; + DWORD status, errorCode; + + interfaceData.cbSize = sizeof (SP_INTERFACE_DEVICE_DATA); + status = SetupDiEnumDeviceInterfaces ( + DevInfo, // Interface Device Info handle + 0, // Device Info data + guid, // Interface registered by driver + idx, // Member + &interfaceData // Device Interface Data + ); + if (status == FALSE) + return FALSE; + + status = SetupDiGetDeviceInterfaceDetail ( + DevInfo, // Interface Device info handle + &interfaceData, // Interface data for the event class + NULL, // Checking for buffer size + 0, // Checking for buffer size + &reqSize, // Buffer size required to get the detail data + NULL // Checking for buffer size + ); + + if (status == FALSE) { + errorCode = GetLastError(); + if (errorCode != ERROR_INSUFFICIENT_BUFFER) + return FALSE; + } + + interfaceDetailDataSize = reqSize; + interfaceDetailData = malloc (interfaceDetailDataSize); + if (interfaceDetailData == NULL) + return FALSE; + interfaceDetailData->cbSize = sizeof (SP_INTERFACE_DEVICE_DETAIL_DATA); + + status = SetupDiGetDeviceInterfaceDetail ( + DevInfo, // Interface Device info handle + &interfaceData, // Interface data for the event class + interfaceDetailData, // Interface detail data + interfaceDetailDataSize,// Interface detail data size + &reqSize, // Buffer size required to get the detail data + NULL); // Interface device info + + if (status == FALSE) + return FALSE; + + adddrive (interfaceDetailData->DevicePath, INQ_ROMD); + + free (interfaceDetailData); + + return TRUE; +} + +static const GUID *guids[] = { + &GUID_DEVINTERFACE_CDROM, + &GUID_DEVINTERFACE_TAPE, + &GUID_DEVINTERFACE_WRITEONCEDISK, + &GUID_DEVINTERFACE_MEDIUMCHANGER, + &GUID_DEVINTERFACE_CDCHANGER, + &GUID_DEVINTERFACE_STORAGEPORT, + NULL}; + +static int rescan(void) +{ + HDEVINFO hDevInfo; + int idx, idx2; + + write_log("Scan starts..\n"); + for (idx2 = 0; guids[idx2]; idx2++) { + hDevInfo = SetupDiGetClassDevs( + guids[idx2], + NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE); + if (hDevInfo != INVALID_HANDLE_VALUE) { + write_log("%d:\n", idx2); + for (idx = 0; ; idx++) { + if (!getCDROMProperty(idx, hDevInfo, guids[idx2])) + break; + } + SetupDiDestroyDeviceInfoList(hDevInfo); + } + } + write_log("finished.\n"); + return 1; +} + +#endif diff --git a/od-win32/dinput.c b/od-win32/dinput.c index abc8724e..b5d85dc1 100755 --- a/od-win32/dinput.c +++ b/od-win32/dinput.c @@ -31,6 +31,7 @@ #include "keyboard.h" #include "custom.h" #include "dxwrap.h" +#include "akiko.h" #ifdef WINDDK #include @@ -87,7 +88,7 @@ static int num_mouse, num_keyboard, num_joystick; static int dd_inited, mouse_inited, keyboard_inited, joystick_inited; static int stopoutput; static HANDLE kbhandle = INVALID_HANDLE_VALUE; -static int oldleds, oldusedleds, newleds, usbledmode, oldusbleds; +static int oldleds, oldusedleds, newleds, oldusbleds; static int normalmouse, supermouse, rawmouse, winmouse, winmousenumber, winmousemode; static int normalkb, superkb, rawkb; @@ -1115,9 +1116,9 @@ static uae_u32 get_leds (void) if (ledkeystate[VK_SCROLL] & 1) led |= KBLED_SCROLLLOCK; - if (usbledmode && os_winnt) { + if (currprefs.win32_kbledmode && os_winnt) { oldusbleds = led; - } else if (!usbledmode && os_winnt && kbhandle != INVALID_HANDLE_VALUE) { + } else if (!currprefs.win32_kbledmode && os_winnt && kbhandle != INVALID_HANDLE_VALUE) { #ifdef WINDDK KEYBOARD_INDICATOR_PARAMETERS InputBuffer; KEYBOARD_INDICATOR_PARAMETERS OutputBuffer; @@ -1140,7 +1141,7 @@ static uae_u32 get_leds (void) static void set_leds (uae_u32 led) { - if (os_winnt && usbledmode) { + if (os_winnt && currprefs.win32_kbledmode) { if((oldusbleds & KBLED_NUMLOCK) != (led & KBLED_NUMLOCK)) { keybd_event (VK_NUMLOCK, 0, KEYEVENTF_EXTENDEDKEY, 0); keybd_event (VK_NUMLOCK, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); @@ -1306,6 +1307,8 @@ static int refresh_kb (LPDIRECTINPUTDEVICE8 lpdi, int num) hr = IDirectInputDevice8_GetDeviceState (lpdi, sizeof (kc), kc); if (hr == DI_OK) { for (i = 0; i < sizeof (kc); i++) { + if (i == 0x80) /* USB KB led causes this, better ignore it */ + continue; if (kc[i] & 0x80) kc[i] = 1; else kc[i] = 0; if (kc[i] != di_keycodes[num][i]) { write_log ("%02.2X -> %d\n", i, kc[i]); @@ -1323,7 +1326,7 @@ static int refresh_kb (LPDIRECTINPUTDEVICE8 lpdi, int num) } -static int keyhack (int scancode,int pressed, int num) +static int keyhack (int scancode,int pressed, int num) { static byte backslashstate,apostrophstate; @@ -1378,14 +1381,14 @@ static int keyhack (int scancode,int pressed, int num) { inputdevice_translatekeycode (num, DIK_LALT, 1); inputdevice_translatekeycode (num, DIK_LSHIFT,1); - return 4; // the german # key + return 4; // the german # key } else { inputdevice_translatekeycode (num, DIK_LALT, 0); inputdevice_translatekeycode (num, DIK_LSHIFT, 0); // Here is the same not nice but do the job - return 4; // the german # key + return 4; // the german # key } } @@ -1397,7 +1400,7 @@ static int keyhack (int scancode,int pressed, int num) { backslashstate=1; inputdevice_translatekeycode (num, DIK_RALT, 0); - return DIK_BACKSLASH; + return DIK_BACKSLASH; } else { @@ -1517,20 +1520,20 @@ static int acquire_kb (int num, int flags) unacquire (lpdi, "keyboard"); if (currprefs.keyboard_leds_in_use) { #ifdef WINDDK - if (os_winnt && !usbledmode) { + if (os_winnt && !currprefs.win32_kbledmode) { if (DefineDosDevice (DDD_RAW_TARGET_PATH, "Kbd","\\Device\\KeyboardClass0")) { kbhandle = CreateFile("\\\\.\\Kbd", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (kbhandle == INVALID_HANDLE_VALUE) { write_log ("kbled: CreateFile failed, error %d\n", GetLastError()); - usbledmode = 1; + currprefs.win32_kbledmode = 1; } } else { - usbledmode = 1; + currprefs.win32_kbledmode = 1; write_log ("kbled: DefineDosDevice failed, error %d\n", GetLastError()); } } #else - usbledmode = 1; + currprefs.kbledmode = 1; #endif oldleds = get_leds (); if (oldusedleds < 0) @@ -1567,7 +1570,7 @@ static void unacquire_kb (int num) if (currprefs.keyboard_leds_in_use) { if (oldusedleds >= 0) { - if (!usbledmode) + if (!currprefs.win32_kbledmode) set_leds (oldleds); oldusedleds = oldleds; } @@ -1856,13 +1859,22 @@ void input_get_default_joystick (struct uae_input_device *uid) { int i, port; - for (i = 0; i < num_mouse; i++) { + for (i = 0; i < num_joystick; i++) { port = i & 1; uid[i].eventid[ID_AXIS_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ; uid[i].eventid[ID_AXIS_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT; uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON; uid[i].eventid[ID_BUTTON_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON; uid[i].eventid[ID_BUTTON_OFFSET + 2][0] = port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON; + if (cd32_enabled) { + uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED; + uid[i].eventid[ID_BUTTON_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE; + uid[i].eventid[ID_BUTTON_OFFSET + 2][0] = port ? INPUTEVENT_JOY2_CD32_YELLOW : INPUTEVENT_JOY1_CD32_YELLOW; + uid[i].eventid[ID_BUTTON_OFFSET + 3][0] = port ? INPUTEVENT_JOY2_CD32_GREEN : INPUTEVENT_JOY1_CD32_GREEN; + uid[i].eventid[ID_BUTTON_OFFSET + 4][0] = port ? INPUTEVENT_JOY2_CD32_FFW : INPUTEVENT_JOY1_CD32_FFW; + uid[i].eventid[ID_BUTTON_OFFSET + 5][0] = port ? INPUTEVENT_JOY2_CD32_RWD : INPUTEVENT_JOY1_CD32_RWD; + uid[i].eventid[ID_BUTTON_OFFSET + 6][0] = port ? INPUTEVENT_JOY2_CD32_PLAY : INPUTEVENT_JOY1_CD32_PLAY; + } } uid[0].enabled = 1; } diff --git a/od-win32/dxwrap.c b/od-win32/dxwrap.c index 04cca2d7..2517500b 100755 --- a/od-win32/dxwrap.c +++ b/od-win32/dxwrap.c @@ -273,30 +273,29 @@ static int LockStub( surface_type_e type ) IDirectDrawSurface7_Restore( DirectDrawState.primary.surface ); } - while (FAILED(ddrval = IDirectDrawSurface7_Lock(surface, NULL, surfacedesc, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, - NULL))) + while (FAILED(ddrval = IDirectDrawSurface7_Lock(surface, NULL, surfacedesc, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL))) { if (ddrval == DDERR_SURFACELOST) { ddrval = restoresurface (surface); if (FAILED(ddrval)) - { - result = 0; break; - } } else if (ddrval != DDERR_SURFACEBUSY) { write_log ("lpDDS->Lock() failed - %s\n", DXError (ddrval)); - result = 0; break; } } - if(SUCCEEDED(ddrval)) - result = 1; - - if(result) + if(SUCCEEDED(ddrval)) { + static int warned = 10; + DWORD_PTR pixels = (DWORD_PTR)(surfacedesc->lpSurface); + if (warned > 0 && (pixels & 7)) { + write_log("bogus surface pointer %x!\n", pixels); + warned--; + } lockcnt++; - + result = 1; + } return result; } diff --git a/od-win32/keyboard_win32.c b/od-win32/keyboard_win32.c index 4196318a..832706bf 100755 --- a/od-win32/keyboard_win32.c +++ b/od-win32/keyboard_win32.c @@ -179,9 +179,13 @@ static struct uae_input_device_kbr_default keytrans[] = { extern int ispressed (int key); -static int endpressed (void) +static int specialkeycode (void) { - return ispressed(DIK_END); + return currprefs.win32_specialkey; +} +static int specialpressed (void) +{ + return ispressed(specialkeycode()); } static int shiftpressed (void) @@ -303,33 +307,6 @@ static int np[] = { DIK_NUMPAD0, 0, DIK_NUMPADPERIOD, 0, DIK_NUMPAD1, 1, DIK_NUM DIK_NUMPAD3, 3, DIK_NUMPAD4, 4, DIK_NUMPAD5, 5, DIK_NUMPAD6, 6, DIK_NUMPAD7, 7, DIK_NUMPAD8, 8, DIK_NUMPAD9, 9, -1 }; -#define IECODE_UP_PREFIX 0x80 -#define RAW_STEALTH 0x68 -#define STEALTHF_E0KEY 0x08 -#define STEALTHF_UPSTROKE 0x04 -#define STEALTHF_SPECIAL 0x02 -#define STEALTHF_E1KEY 0x01 - -static void sendmmcodes(int code, int newstate) -{ - uae_u8 b; - - b = RAW_STEALTH | IECODE_UP_PREFIX; - record_key(((b << 1) | (b >> 7)) & 0xff); - b = IECODE_UP_PREFIX; - if ((code >> 8) == 0x01) - b |= STEALTHF_E0KEY; - if ((code >> 8) == 0x02) - b |= STEALTHF_E1KEY; - if (!newstate) - b |= STEALTHF_UPSTROKE; - record_key(((b << 1) | (b >> 7)) & 0xff); - b = ((code >> 4) & 0x0f) | IECODE_UP_PREFIX; - record_key(((b << 1) | (b >> 7)) & 0xff); - b = (code & 0x0f) | IECODE_UP_PREFIX; - record_key(((b << 1) | (b >> 7)) & 0xff); -} - void my_kbd_handler (int keyboard, int scancode, int newstate) { int code = 0; @@ -342,7 +319,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) case DIK_F12: if (ctrlpressed ()) { code = AKS_TOGGLEFULLSCREEN; - } else if (shiftpressed () || endpressed ()) { + } else if (shiftpressed () || specialpressed ()) { disablecapture (); code = AKS_ENTERDEBUGGER; } else { @@ -359,7 +336,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) case DIK_F2: case DIK_F3: case DIK_F4: - if (endpressed ()) { + if (specialpressed ()) { if (shiftpressed ()) code = AKS_EFLOPPY0 + (scancode - DIK_F1); else @@ -367,7 +344,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) } break; case DIK_F5: - if (endpressed ()) { + if (specialpressed ()) { if (shiftpressed ()) code = AKS_STATESAVEDIALOG; else @@ -384,7 +361,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) case DIK_8: case DIK_9: case DIK_0: - if (endpressed ()) { + if (specialpressed ()) { int num = scancode - DIK_1; if (shiftpressed ()) num += 10; @@ -413,7 +390,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) case DIK_NUMPAD8: case DIK_NUMPAD9: case DIK_NUMPADPERIOD: - if (endpressed ()) { + if (specialpressed ()) { int i = 0, v = -1; while (np[i] >= 0) { v = np[i + 1]; @@ -426,10 +403,10 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) } break; case DIK_SYSRQ: - screenshot (endpressed() ? 1 : 0, 1); + screenshot (specialpressed() ? 1 : 0, 1); break; case DIK_PAUSE: - if (endpressed ()) + if (specialpressed ()) code = AKS_WARP; else code = AKS_PAUSE; @@ -446,7 +423,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) case DIK_NEXT: break; case DIK_NUMPADMINUS: - if (endpressed ()) { + if (specialpressed ()) { if (shiftpressed ()) code = AKS_DECREASEREFRESHRATE; else @@ -454,7 +431,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) } break; case DIK_NUMPADPLUS: - if (endpressed ()) { + if (specialpressed ()) { if (shiftpressed ()) code = AKS_INCREASEREFRESHRATE; else @@ -462,11 +439,11 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) } break; case DIK_NUMPADSTAR: - if (endpressed ()) + if (specialpressed ()) code = AKS_VOLMUTE; break; case DIK_NUMPADSLASH: - if (endpressed ()) + if (specialpressed ()) code = AKS_STATEREWIND; break; } @@ -475,7 +452,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) inputdevice_add_inputcode (code, 1); return; } - if (endpressed ()) + if (scancode == specialkeycode()) return; if (scancode == DIK_CAPITAL) { @@ -495,11 +472,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) return; #endif } - if (inputdevice_translatekeycode (keyboard, scancode, newstate)) - return; - - if (currprefs.mmkeyboard) - sendmmcodes(scancode, newstate); + inputdevice_translatekeycode (keyboard, scancode, newstate); } void keyboard_settrans (void) diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index cd398937..3d112337 100755 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -300,6 +300,7 @@ #define IDC_THEROOTS 1076 #define IDC_CAPS 1077 #define IDC_ABIME 1078 +#define IDC_AMIGASYS 1079 #define IDC_RICHEDIT1 1091 #define IDC_RICHEDIT2 1092 #define IDC_CONTRIBUTORS 1124 @@ -348,7 +349,6 @@ #define IDC_CYCLEEXACT 1219 #define IDC_CS_CPU_TEXT2 1219 #define IDC_CPUIDLE 1220 -#define IDC_CYCLEEXACT2 1220 #define IDC_GENLOCK 1220 #define IDC_SOUNDSETTINGS 1229 #define IDC_8BIT 1230 @@ -484,6 +484,7 @@ #define IDC_TEST16BIT 1506 #define IDC_MAPDRIVES 1507 #define IDC_CPUTEXT 1508 +#define IDC_MAPDRIVES_NET 1508 #define IDC_SWAP 1509 #define IDC_CACHETEXT 1509 #define IDC_SELECTRESTEXT 1510 @@ -531,6 +532,8 @@ #define IDC_D0 1532 #define IDC_STATE_CAPTURE 1532 #define IDC_D1 1533 +#define IDC_STATE_CAPTURE2 1533 +#define IDC_KBLED_USB 1533 #define IDC_D2 1534 #define IDC_D3 1535 #define IDC_D4 1536 diff --git a/od-win32/resources/resource.hm b/od-win32/resources/resource.hm index d62039db..55d14238 100755 --- a/od-win32/resources/resource.hm +++ b/od-win32/resources/resource.hm @@ -1,11 +1,12 @@ // Microsoft Visual C++ generated Help ID include file. // Used by winuae.rc // -#define HIDC_CREATELOGFILE 0x808d0402 // IDD_MISC1 [English (U.S.)] -#define HIDC_EDITDESCRIPTION 0x8087057e // IDD_LOADSAVE [English (U.S.)] -#define HIDC_EDITNAME 0x8087057d // IDD_LOADSAVE [English (U.S.)] -#define HIDC_EDITPATH 0x80870582 // IDD_LOADSAVE [English (U.S.)] -#define HIDC_LORES 0x806c0498 // IDD_DISPLAY [English (U.S.)] -#define HIDC_MAPDRIVES 0x807105e3 // IDD_HARDDISK [English (U.S.)] -#define HIDC_PFULLSCREEN 0x806c04a8 // IDD_DISPLAY [English (U.S.)] -#define HIDC_TEST16BIT 0x806c05e2 // IDD_DISPLAY [English (U.S.)] +#define HIDC_CREATELOGFILE 0x808d0402 // IDD_MISC1 [English (United States)] +#define HIDC_EDITDESCRIPTION 0x8087057e // IDD_LOADSAVE [English (United States)] +#define HIDC_EDITNAME 0x8087057d // IDD_LOADSAVE [English (United States)] +#define HIDC_EDITPATH 0x80870582 // IDD_LOADSAVE [English (United States)] +#define HIDC_LORES 0x806c0498 // IDD_DISPLAY [English (United States)] +#define HIDC_MAPDRIVES 0x807105e3 // IDD_HARDDISK [English (United States)] +#define HIDC_MAPDRIVES_NET 0x807105e4 // IDD_HARDDISK [English (United States)] +#define HIDC_PFULLSCREEN 0x806c04a8 // IDD_DISPLAY [English (United States)] +#define HIDC_TEST16BIT 0x806c05e2 // IDD_DISPLAY [English (United States)] diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index ddef077b..07baef9c 100755 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -201,20 +201,21 @@ BEGIN PUSHBUTTON "Delete Saveimage",IDC_SAVEIMAGE3,43,110,70,15,NOT WS_VISIBLE END -IDD_HARDDISK DIALOGEX 0, 0, 300, 242 +IDD_HARDDISK DIALOGEX 0, 0, 300, 231 STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD EXSTYLE WS_EX_CONTEXTHELP FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - CONTROL "List1",IDC_VOLUMELIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,5,290,185 - PUSHBUTTON "Add &Directory...",IDC_NEW_FS,5,196,60,15 - PUSHBUTTON "Add &Hardfile...",IDC_NEW_HF,70,196,60,15 - PUSHBUTTON "Add Ha&rddrive...",IDC_NEW_HD,135,196,60,15 - PUSHBUTTON "Remove",IDC_REMOVE,235,196,60,15 - PUSHBUTTON "&Properties",IDC_EDIT,235,217,60,15 - CONTROL "Add PC Drives at Startup",IDC_MAPDRIVES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,216,105,10,0,HIDC_MAPDRIVES - CONTROL "Disable UAEFSDB-support",IDC_NOUAEFSDB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,229,115,10 - CONTROL "Don't use Windows Recycle Bin",IDC_NORECYCLEBIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,216,115,10 + CONTROL "List1",IDC_VOLUMELIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,0,290,182 + PUSHBUTTON "Add &Directory...",IDC_NEW_FS,5,186,60,15 + PUSHBUTTON "Add &Hardfile...",IDC_NEW_HF,70,186,60,15 + PUSHBUTTON "Add Ha&rddrive...",IDC_NEW_HD,135,186,60,15 + PUSHBUTTON "Remove",IDC_REMOVE,235,186,60,15 + PUSHBUTTON "&Properties",IDC_EDIT,235,207,60,15 + CONTROL "Add PC Drives at Startup",IDC_MAPDRIVES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,205,100,10,0,HIDC_MAPDRIVES + CONTROL "Disable UAEFSDB-support",IDC_NOUAEFSDB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,110,205,115,10 + CONTROL "Don't use Windows Recycle Bin",IDC_NORECYCLEBIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,110,216,115,10 + CONTROL "Add Network Drives...",IDC_MAPDRIVES_NET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,216,101,10,0,HIDC_MAPDRIVES_NET END IDD_SOUND DIALOGEX 0, 0, 300, 244 @@ -327,7 +328,7 @@ BEGIN CONTROL "",IDC_CONTRIBUTORS,"RICHEDIT",TCS_HOTTRACK | TCS_VERTICAL | TCS_RAGGEDRIGHT | TCS_OWNERDRAWFIXED | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,4,5,404,206 END -IDD_ABOUT DIALOGEX 0, 0, 300, 175 +IDD_ABOUT DIALOGEX 0, 0, 300, 191 STYLE DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN @@ -336,13 +337,14 @@ BEGIN PUSHBUTTON "Contributors",IDC_CONTRIBUTORS,110,55,80,15 CONTROL "",IDC_UAEHOME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,20,120,80,15 CONTROL "",IDC_PICASSOHOME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,200,90,80,20 - CONTROL "",IDC_AMIGAHOME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,109,74,80,15 + CONTROL "",IDC_AMIGAHOME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,109,90,80,20 CONTROL "",IDC_WINUAEHOME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,200,120,80,15 CONTROL "",IDC_AIABHOME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,110,120,80,15 CONTROL "",IDC_THEROOTS,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,20,145,80,15 CONTROL "",IDC_CAPS,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,200,145,80,15 CONTROL "",IDC_ABIME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,110,145,80,15 CONTROL "",IDC_CLOANTOHOME,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,20,90,80,20 + CONTROL "",IDC_AMIGASYS,"RICHEDIT",TCS_SCROLLOPPOSITE | TCS_RAGGEDRIGHT | TCS_MULTISELECT | WS_DISABLED,110,169,80,15 END IDD_MISC1 DIALOGEX 0, 0, 300, 219 @@ -360,7 +362,7 @@ BEGIN CONTROL "Don't use RGB overlays",IDC_NOOVERLAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,49,120,10 CONTROL "Use ASPI SCSI layer",IDC_ASPI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,64,115,10 CONTROL "Syncronize clock",IDC_CLOCKSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,78,115,10 - GROUPBOX "Keyboard LEDs:",IDC_STATIC,7,110,85,73 + GROUPBOX "Keyboard LEDs:",IDC_STATIC,7,110,85,104 COMBOBOX IDC_KBLED1,22,123,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_KBLED2,22,142,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_KBLED3,22,162,56,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -377,6 +379,7 @@ BEGIN COMBOBOX IDC_STATE_BUFFERSIZE,248,191,38,65,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP CONTROL "Always on top",IDC_ALWAYSONTOP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,92,117,10 CONTROL "Catweasel",IDC_CATWEASEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,92,115,10 + CONTROL "USB-mode",IDC_KBLED_USB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,185,64,10 END IDD_HARDFILE DIALOGEX 0, 0, 299, 212 @@ -808,11 +811,6 @@ IDC_MYHAND CURSOR "H_arrow.cur" #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN - IDD_HARDDISK, DIALOG - BEGIN - BOTTOMMARGIN, 241 - END - IDD_SOUND, DIALOG BEGIN BOTTOMMARGIN, 243 diff --git a/od-win32/sysconfig.h b/od-win32/sysconfig.h index 4b40ac04..e2b0e0a4 100755 --- a/od-win32/sysconfig.h +++ b/od-win32/sysconfig.h @@ -81,7 +81,6 @@ #endif #ifdef WIN64 -#undef JIT #undef X86_MSVC_ASSEMBLY #define X64_MSVC_ASSEMBLY #define CPU_64_BIT diff --git a/od-win32/win32.c b/od-win32/win32.c index 5edef7be..978f2be3 100755 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -349,15 +349,15 @@ static int figure_processor_speed (void) sleep_resolution = 1; if (clkdiv >= 0.90 && clkdiv <= 1.10 && rpt_available) { limit = 2.5; - if ((ratea2 / ratecnt) < limit * clockrate1000) { /* regular Sleep() is ok */ - timermode = 1; - sleep_resolution = (int)(ratea2 * clockrate1000 / (ratecnt * 1000000)); - write_log ("Using Sleep() (resolution < %.1fms)\n", limit); - } else if (mm_timerres && (ratea1 / ratecnt) < limit * clockrate1000) { /* MM-timer is ok */ + if (mm_timerres && (ratea1 / ratecnt) < limit * clockrate1000) { /* MM-timer is ok */ timermode = 0; sleep_resolution = (int)(ratea1 * clockrate1000 / (ratecnt * 1000000)); timebegin (); write_log ("Using MultiMedia timers (resolution < %.1fms)\n", limit); + } else if ((ratea2 / ratecnt) < limit * clockrate1000) { /* regular Sleep() is ok */ + timermode = 1; + sleep_resolution = (int)(ratea2 * clockrate1000 / (ratecnt * 1000000)); + write_log ("Using Sleep() (resolution < %.1fms)\n", limit); } else { timermode = -1; /* both timers are bad, fall back to busy-wait */ write_log ("falling back to busy-loop waiting (timer resolution > %.1fms)\n", limit); @@ -595,8 +595,6 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, { PAINTSTRUCT ps; HDC hDC; - LPMINMAXINFO lpmmi; - RECT rect; int mx, my, v; static int mm; static int minimized; @@ -829,16 +827,22 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, WIN32GFX_WindowMove(); return TRUE; +#if 0 case WM_GETMINMAXINFO: - rect.left=0; - rect.top=0; - lpmmi=(LPMINMAXINFO)lParam; - rect.right=320; - rect.bottom=256; + { + LPMINMAXINFO lpmmi; + RECT rect; + rect.left = 0; + rect.top = 0; + lpmmi = (LPMINMAXINFO)lParam; + rect.right = 320; + rect.bottom = 256; //AdjustWindowRectEx(&rect,WSTYLE,0,0); - lpmmi->ptMinTrackSize.x=rect.right-rect.left; - lpmmi->ptMinTrackSize.y=rect.bottom-rect.top; + lpmmi->ptMinTrackSize.x = rect.right-rect.left; + lpmmi->ptMinTrackSize.y = rect.bottom-rect.top; + } return 0; +#endif #ifdef FILESYS case WM_DEVICECHANGE: @@ -1588,6 +1592,10 @@ int mousehack_allowed (void) return dinput_winmouse () > 0 && dinput_winmousemode (); } +void toggle_mousegrab (void) +{ +} + void logging_init( void ) { static int started; @@ -1660,6 +1668,10 @@ void target_default_options (struct uae_prefs *p, int type) p->win32_iconified_priority = 3; p->win32_notaskbarbutton = 0; p->win32_alwaysontop = 0; + p->win32_specialkey = 0xcf; // DIK_END + p->win32_automount_drives = 0; + p->win32_automount_netdrives = 0; + p->win32_kbledmode = 0; } if (type == 1 || type == 0) { p->win32_midioutdev = -2; @@ -1669,31 +1681,33 @@ void target_default_options (struct uae_prefs *p, int type) void target_save_options (struct zfile *f, struct uae_prefs *p) { - cfgfile_write (f, "win32.middle_mouse=%s\n", p->win32_middle_mouse ? "true" : "false"); - cfgfile_write (f, "win32.logfile=%s\n", p->win32_logfile ? "true" : "false"); - cfgfile_write (f, "win32.map_drives=%s\n", p->win32_automount_drives ? "true" : "false" ); - cfgfile_write (f, "win32.serial_port=%s\n", p->use_serial ? p->sername : "none" ); - cfgfile_write (f, "win32.parallel_port=%s\n", p->prtname[0] ? p->prtname : "none" ); - - cfgfile_write (f, "win32.active_priority=%d\n", priorities[p->win32_active_priority].value); - cfgfile_write (f, "win32.inactive_priority=%d\n", priorities[p->win32_inactive_priority].value); - cfgfile_write (f, "win32.inactive_nosound=%s\n", p->win32_inactive_nosound ? "true" : "false"); - cfgfile_write (f, "win32.inactive_pause=%s\n", p->win32_inactive_pause ? "true" : "false"); - cfgfile_write (f, "win32.iconified_priority=%d\n", priorities[p->win32_iconified_priority].value); - cfgfile_write (f, "win32.iconified_nosound=%s\n", p->win32_iconified_nosound ? "true" : "false"); - cfgfile_write (f, "win32.iconified_pause=%s\n", p->win32_iconified_pause ? "true" : "false"); - - cfgfile_write (f, "win32.ctrl_f11_is_quit=%s\n", p->win32_ctrl_F11_is_quit ? "true" : "false"); - cfgfile_write (f, "win32.midiout_device=%d\n", p->win32_midioutdev ); - cfgfile_write (f, "win32.midiin_device=%d\n", p->win32_midiindev ); - cfgfile_write (f, "win32.no_overlay=%s\n", p->win32_no_overlay ? "true" : "false" ); - cfgfile_write (f, "win32.aspi=%s\n", p->win32_aspi ? "true" : "false" ); - cfgfile_write (f, "win32.soundcard=%d\n", p->win32_soundcard ); - cfgfile_write (f, "win32.cpu_idle=%d\n", p->cpu_idle); - cfgfile_write (f, "win32.notaskbarbutton=%s\n", p->win32_notaskbarbutton ? "true" : "false"); - cfgfile_write (f, "win32.always_on_top=%s\n", p->win32_alwaysontop ? "true" : "false"); - cfgfile_write (f, "win32.no_recyclebin=%s\n", p->win32_norecyclebin ? "true" : "false"); -} + cfgfile_target_write (f, "middle_mouse=%s\n", p->win32_middle_mouse ? "true" : "false"); + cfgfile_target_write (f, "logfile=%s\n", p->win32_logfile ? "true" : "false"); + cfgfile_target_write (f, "map_drives=%s\n", p->win32_automount_drives ? "true" : "false"); + cfgfile_target_write (f, "map_net_drives=%s\n", p->win32_automount_netdrives ? "true" : "false"); + cfgfile_target_write (f, "serial_port=%s\n", p->use_serial ? p->sername : "none" ); + cfgfile_target_write (f, "parallel_port=%s\n", p->prtname[0] ? p->prtname : "none" ); + + cfgfile_target_write (f, "active_priority=%d\n", priorities[p->win32_active_priority].value); + cfgfile_target_write (f, "inactive_priority=%d\n", priorities[p->win32_inactive_priority].value); + cfgfile_target_write (f, "inactive_nosound=%s\n", p->win32_inactive_nosound ? "true" : "false"); + cfgfile_target_write (f, "inactive_pause=%s\n", p->win32_inactive_pause ? "true" : "false"); + cfgfile_target_write (f, "iconified_priority=%d\n", priorities[p->win32_iconified_priority].value); + cfgfile_target_write (f, "iconified_nosound=%s\n", p->win32_iconified_nosound ? "true" : "false"); + cfgfile_target_write (f, "iconified_pause=%s\n", p->win32_iconified_pause ? "true" : "false"); + + cfgfile_target_write (f, "ctrl_f11_is_quit=%s\n", p->win32_ctrl_F11_is_quit ? "true" : "false"); + cfgfile_target_write (f, "midiout_device=%d\n", p->win32_midioutdev ); + cfgfile_target_write (f, "midiin_device=%d\n", p->win32_midiindev ); + cfgfile_target_write (f, "no_overlay=%s\n", p->win32_no_overlay ? "true" : "false" ); + cfgfile_target_write (f, "aspi=%s\n", p->win32_aspi ? "true" : "false" ); + cfgfile_target_write (f, "soundcard=%d\n", p->win32_soundcard ); + cfgfile_target_write (f, "cpu_idle=%d\n", p->cpu_idle); + cfgfile_target_write (f, "notaskbarbutton=%s\n", p->win32_notaskbarbutton ? "true" : "false"); + cfgfile_target_write (f, "always_on_top=%s\n", p->win32_alwaysontop ? "true" : "false"); + cfgfile_target_write (f, "no_recyclebin=%s\n", p->win32_norecyclebin ? "true" : "false"); + cfgfile_target_write (f, "specialkey=0x%x\n", p->win32_specialkey); + cfgfile_target_write (f, "kbledmode=%d\n", p->win32_kbledmode);} static int fetchpri (int pri, int defpri) { @@ -1718,26 +1732,29 @@ int target_parse_option (struct uae_prefs *p, char *option, char *value) { int i, v; int result = (cfgfile_yesno (option, value, "middle_mouse", &p->win32_middle_mouse) + || cfgfile_yesno (option, value, "map_drives", &p->win32_automount_drives) + || cfgfile_yesno (option, value, "map_net_drives", &p->win32_automount_netdrives) || cfgfile_yesno (option, value, "logfile", &p->win32_logfile) - || cfgfile_yesno (option, value, "networking", &p->socket_emu) + || cfgfile_yesno (option, value, "networking", &p->socket_emu) || cfgfile_yesno (option, value, "no_overlay", &p->win32_no_overlay) || cfgfile_yesno (option, value, "aspi", &p->win32_aspi) - || cfgfile_yesno (option, value, "map_drives", &p->win32_automount_drives) || cfgfile_yesno (option, value, "inactive_pause", &p->win32_inactive_pause) || cfgfile_yesno (option, value, "inactive_nosound", &p->win32_inactive_nosound) || cfgfile_yesno (option, value, "iconified_pause", &p->win32_iconified_pause) || cfgfile_yesno (option, value, "iconified_nosound", &p->win32_iconified_nosound) - || cfgfile_yesno (option, value, "ctrl_f11_is_quit", &p->win32_ctrl_F11_is_quit) - || cfgfile_yesno (option, value, "no_recyclebin", &p->win32_norecyclebin) + || cfgfile_yesno (option, value, "ctrl_f11_is_quit", &p->win32_ctrl_F11_is_quit) + || cfgfile_yesno (option, value, "no_recyclebin", &p->win32_norecyclebin) || cfgfile_intval (option, value, "midi_device", &p->win32_midioutdev, 1) || cfgfile_intval (option, value, "midiout_device", &p->win32_midioutdev, 1) || cfgfile_intval (option, value, "midiin_device", &p->win32_midiindev, 1) || cfgfile_intval (option, value, "soundcard", &p->win32_soundcard, 1) || cfgfile_string (option, value, "serial_port", &p->sername[0], 256) || cfgfile_string (option, value, "parallel_port", &p->prtname[0], 256) - || cfgfile_yesno (option, value, "notaskbarbutton", &p->win32_notaskbarbutton) - || cfgfile_yesno (option, value, "always_on_top", &p->win32_alwaysontop) - || cfgfile_intval (option, value, "cpu_idle", &p->cpu_idle, 1)); + || cfgfile_yesno (option, value, "notaskbarbutton", &p->win32_notaskbarbutton) + || cfgfile_yesno (option, value, "always_on_top", &p->win32_alwaysontop) + || cfgfile_intval (option, value, "specialkey", &p->win32_specialkey, 1) + || cfgfile_intval (option, value, "kbledmode", &p->win32_kbledmode, 1) + || cfgfile_intval (option, value, "cpu_idle", &p->cpu_idle, 1)); if (cfgfile_intval (option, value, "active_priority", &v, 1)) { p->win32_active_priority = fetchpri (v, 1); @@ -2679,7 +2696,7 @@ HMODULE WIN32_LoadLibrary (const char *name) if (m) goto end; LLError(newname); -#ifndef CPU_64_BIT +#ifndef CPU_64_BIT break; #endif } diff --git a/od-win32/win32.h b/od-win32/win32.h index af7e371e..7f89938f 100755 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -22,7 +22,7 @@ extern int manual_palette_refresh_needed; extern int mouseactive, focus; extern int ignore_messages_all; #define WINUAEBETA 1 -#define WINUAEBETASTR " Beta 1" +#define WINUAEBETASTR " Beta 2" extern char start_path_exe[MAX_DPATH]; extern char start_path_data[MAX_DPATH]; diff --git a/od-win32/win32_filesys.c b/od-win32/win32_filesys.c index 4cb21296..c61cc4df 100755 --- a/od-win32/win32_filesys.c +++ b/od-win32/win32_filesys.c @@ -10,7 +10,7 @@ static int CheckRM( char *DriveName ) sprintf( filename, "%s.", DriveName ); dwHold = GetFileAttributes( filename ); if( dwHold != 0xFFFFFFFF ) - result = TRUE; + result = TRUE; return result; } @@ -23,23 +23,23 @@ static int valid_volumename( struct uaedev_mount_info *mountinfo, char *volumena int i, result = 1, illegal_count = sizeof( illegal_volumenames ) / sizeof( char *); for( i = 0; i < illegal_count; i++ ) { - if( strcmp( volumename, illegal_volumenames[i] ) == 0 ) - { - result = 0; - break; - } + if( strcmp( volumename, illegal_volumenames[i] ) == 0 ) + { + result = 0; + break; + } } /* if result is still good, we've passed the illegal names check, and must check for duplicates now */ if( result && fullcheck) { - for( i = 0; i < mountinfo->num_units; i++ ) - { - if( mountinfo->ui[i].volname && ( strcmp( mountinfo->ui[i].volname, volumename ) == 0 ) ) - { - result = 0; - break; - } - } + for( i = 0; i < mountinfo->num_units; i++ ) + { + if( mountinfo->ui[i].volname && ( strcmp( mountinfo->ui[i].volname, volumename ) == 0 ) ) + { + result = 0; + break; + } + } } return result; } @@ -64,29 +64,29 @@ static int get_volume_name( struct uaedev_mount_info *mtinf, char *volumepath, c if( result == 2 ) { - switch( drivetype ) - { - case DRIVE_FIXED: - sprintf( volumename, "WinDH_%c", volumepath[0] ); - break; - case DRIVE_CDROM: - sprintf( volumename, "WinCD_%c", volumepath[0] ); - break; - case DRIVE_REMOVABLE: - sprintf( volumename, "WinRMV_%c", volumepath[0] ); - break; - case DRIVE_REMOTE: - sprintf( volumename, "WinNET_%c", volumepath[0] ); - break; - case DRIVE_RAMDISK: - sprintf( volumename, "WinRAM_%c", volumepath[0] ); - break; - case DRIVE_UNKNOWN: - case DRIVE_NO_ROOT_DIR: - default: - result = 0; - break; - } + switch( drivetype ) + { + case DRIVE_FIXED: + sprintf( volumename, "WinDH_%c", volumepath[0] ); + break; + case DRIVE_CDROM: + sprintf( volumename, "WinCD_%c", volumepath[0] ); + break; + case DRIVE_REMOVABLE: + sprintf( volumename, "WinRMV_%c", volumepath[0] ); + break; + case DRIVE_REMOTE: + sprintf( volumename, "WinNET_%c", volumepath[0] ); + break; + case DRIVE_RAMDISK: + sprintf( volumename, "WinRAM_%c", volumepath[0] ); + break; + case DRIVE_UNKNOWN: + case DRIVE_NO_ROOT_DIR: + default: + result = 0; + break; + } } return result; @@ -102,34 +102,36 @@ void filesys_init( void ) DWORD dwDriveMask; char *result = NULL; - if( currprefs.win32_automount_drives ) + if( currprefs.win32_automount_drives || currprefs.win32_automount_netdrives ) { - dwDriveMask = GetLogicalDrives(); - dwDriveMask >>= 2; // Skip A and B drives... + dwDriveMask = GetLogicalDrives(); + dwDriveMask >>= 2; // Skip A and B drives... - for( drive = 'C'; drive <= 'Z'; ++drive ) - { + for( drive = 'C'; drive <= 'Z'; ++drive ) { sprintf( volumepath, "%c:\\", drive ); /* Is this drive-letter valid (it used to check for media in drive) */ - if( ( dwDriveMask & 1 ) /* && CheckRM( volumepath ) */ ) - { + if( dwDriveMask & 1 ) { BOOL inserted = CheckRM(volumepath); /* Is there a disk inserted? */ - drivetype = GetDriveType(volumepath); - if (drivetype != DRIVE_CDROM) { - - get_volume_name( currprefs.mountinfo, volumepath, volumename, MAX_DPATH, inserted, drivetype, 1 ); - if (drivetype == DRIVE_REMOTE) - strcat( volumepath, "." ); - else - strcat( volumepath, ".." ); - - result = add_filesys_unit (currprefs.mountinfo, 0, volumename, volumepath, 0, 0, 0, 0, 0, 0, 0, FILESYS_FLAG_DONOTSAVE); - if( result ) - write_log ("%s\n", result); - } - } /* if drivemask */ - dwDriveMask >>= 1; - } + drivetype = GetDriveType(volumepath); + if (!inserted) + continue; + if (drivetype == DRIVE_CDROM) + continue; + if (drivetype == DRIVE_REMOTE && !currprefs.win32_automount_netdrives) + continue; + if ((drivetype == DRIVE_FIXED || drivetype == DRIVE_REMOVABLE) && !currprefs.win32_automount_drives) + continue; + get_volume_name( currprefs.mountinfo, volumepath, volumename, MAX_DPATH, inserted, drivetype, 1 ); + if (drivetype == DRIVE_REMOTE) + strcat( volumepath, "." ); + else + strcat( volumepath, ".." ); + result = add_filesys_unit (currprefs.mountinfo, 0, volumename, volumepath, 0, 0, 0, 0, 0, 0, 0, FILESYS_FLAG_DONOTSAVE); + if( result ) + write_log ("%s\n", result); + } /* if drivemask */ + dwDriveMask >>= 1; + } } SetErrorMode( errormode ); } diff --git a/od-win32/win32gfx.c b/od-win32/win32gfx.c index 8938d9a3..b7fa9334 100755 --- a/od-win32/win32gfx.c +++ b/od-win32/win32gfx.c @@ -94,7 +94,6 @@ extern int console_logging; #define SM_WINDOW_OVERLAY 1 #define SM_FULLSCREEN_DX 2 #define SM_OPENGL_WINDOW 3 -//#define SM_OPENGL_FULLSCREEN_W 4 #define SM_OPENGL_FULLSCREEN_DX 4 #define SM_D3D_WINDOW 5 #define SM_D3D_FULLSCREEN_DX 6 @@ -127,13 +126,6 @@ static struct winuae_modes wmodes[] = DM_OPENGL | DM_DX_FULLSCREEN | DM_DC, 0 }, -#if 0 - { - 3, "DirectDraw Fullscreen OpenGL", - DM_OPENGL | DM_DX_FULLSCREEN | DM_DC, - 0 - }, -#endif { 0, "Windowed Direct3D", DM_D3D, @@ -1664,7 +1656,6 @@ static void createstatuswindow (void) int num_parts = 10; double scaleX, scaleY; - hStatusWnd = CreateWindowEx( 0, STATUSCLASSNAME, (LPCTSTR) NULL, SBT_TOOLTIPS | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hMainWnd, (HMENU) 1, hInst, NULL); @@ -1742,7 +1733,7 @@ static int create_windows (void) rc.top = stored_y; rc.right = rc.left + 2 + currentmode->current_width + 2; - rc.bottom = rc.top + 2 + currentmode->current_height + 2 + GetSystemMetrics (SM_CYMENU); + rc.bottom = rc.top + 2 + currentmode->current_height + 2 + GetSystemMetrics (SM_CYMENU) - 1; oldx = rc.left; oldy = rc.top; @@ -1759,17 +1750,17 @@ static int create_windows (void) } hMainWnd = CreateWindowEx (WS_EX_ACCEPTFILES | exstyle | (currprefs.win32_alwaysontop ? WS_EX_TOPMOST : 0), - "PCsuxRox", "WinUAE", - NORMAL_WINDOW_STYLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, - rc.left, rc.top, - rc.right - rc.left + 1, rc.bottom - rc.top + 1, - hhWnd, NULL, 0, NULL); + "PCsuxRox", "WinUAE", + NORMAL_WINDOW_STYLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + rc.left, rc.top, + rc.right - rc.left + 1, rc.bottom - rc.top + 1, + hhWnd, NULL, 0, NULL); if (! hMainWnd) { write_log ("main window creation failed\n"); return 0; } - + createstatuswindow (); } @@ -1782,7 +1773,7 @@ static int create_windows (void) hMainWnd ? 2 : CW_USEDEFAULT, hMainWnd ? 2 : CW_USEDEFAULT, currentmode->current_width, currentmode->current_height, hMainWnd ? hMainWnd : hhWnd, NULL, 0, NULL); - + if (! hAmigaWnd) { write_log ("creation of amiga window failed\n"); close_hwnds(); @@ -2064,12 +2055,12 @@ static BOOL doInit (void) } } else if (!(currentmode->flags & DM_SWSCALE)) { int size = currentmode->amiga_width * currentmode->amiga_height * gfxvidinfo.pixbytes; - gfxvidinfo.realbufmem = malloc (size); + gfxvidinfo.realbufmem = xmalloc (size); gfxvidinfo.bufmem = gfxvidinfo.realbufmem; gfxvidinfo.rowbytes = currentmode->amiga_width * gfxvidinfo.pixbytes; } else if (!(currentmode->flags & DM_D3D)) { int size = (currentmode->amiga_width * 2) * (currentmode->amiga_height * 3) * gfxvidinfo.pixbytes; - gfxvidinfo.realbufmem = malloc (size); + gfxvidinfo.realbufmem = xmalloc (size); memset (gfxvidinfo.realbufmem, 0, size); gfxvidinfo.bufmem = gfxvidinfo.realbufmem + (currentmode->amiga_width + (currentmode->amiga_width * 2) * currentmode->amiga_height) * gfxvidinfo.pixbytes; gfxvidinfo.rowbytes = currentmode->amiga_width * 2 * gfxvidinfo.pixbytes; @@ -2244,7 +2235,7 @@ void updatewinfsmode (struct uae_prefs *p) displayGUID = &Displays[p->gfx_display].guid; } -void fullscreentoggle (void) +void toggle_fullscreen (void) { if(picasso_on) changed_prefs.gfx_pfullscreen = !changed_prefs.gfx_pfullscreen; @@ -2284,4 +2275,4 @@ void releasehdc (HDC hdc) } #endif DirectDraw_ReleaseDC(hdc, DirectDraw_GetLockableType()); -} \ No newline at end of file +} diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index b6229a33..cef08315 100755 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -2430,7 +2430,7 @@ static INT_PTR CALLBACK ContributorsProc (HWND hDlg, UINT msg, WPARAM wParam, LP SetDlgItemText (hDlg, IDC_CONTRIBUTORS, szContributors ); SendDlgItemMessage (hDlg, IDC_CONTRIBUTORS, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat); CharFormat.dwMask |= CFM_SIZE | CFM_FACE; - CharFormat.yHeight = 10 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */ + CharFormat.yHeight = 10 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */ strcpy (CharFormat.szFaceName, "Times New Roman"); SendDlgItemMessage (hDlg, IDC_CONTRIBUTORS, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat); @@ -2465,6 +2465,7 @@ static urlinfo urls[] = {IDC_THEROOTS, FALSE, "Back To The Roots", "http://www.back2roots.org/"}, {IDC_ABIME, FALSE, "abime.net", "http://www.abime.net/"}, {IDC_CAPS, FALSE, "CAPS", "http://caps-project.org/"}, + {IDC_AMIGASYS, FALSE, "AmigaSYS", "http://amigasys.fw.hu/"}, { -1, FALSE, NULL, NULL } }; @@ -2761,7 +2762,7 @@ static void init_quickstartdlg_tooltip (HWND hDlg, char *tt) ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND; ti.hwnd = hDlg; ti.hinst = hInst; - ti.uId = (UINT)GetDlgItem (hDlg, IDC_QUICKSTART_CONFIGURATION); + ti.uId = (UINT_PTR)GetDlgItem (hDlg, IDC_QUICKSTART_CONFIGURATION); ti.lpszText = tt; SendMessage (ToolTipHWND, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); if (!tt) @@ -4445,6 +4446,9 @@ static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) case IDC_ALWAYSONTOP: workprefs.win32_alwaysontop = IsDlgButtonChecked (hDlg, IDC_ALWAYSONTOP); break; + case IDC_KBLED_USB: + workprefs.win32_kbledmode = IsDlgButtonChecked (hDlg, IDC_KBLED_USB) ? 1 : 0; + break; } return TRUE; } @@ -5445,8 +5449,8 @@ static void new_hardfile (HWND hDlg) result = add_filesys_unit (currprefs.mountinfo, current_hfdlg.devicename, 0, current_hfdlg.filename, ! current_hfdlg.rw, current_hfdlg.sectors, current_hfdlg.surfaces, - current_hfdlg.reserved, current_hfdlg.blocksize, - current_hfdlg.bootpri, current_hfdlg.fsfilename, 0); + current_hfdlg.reserved, current_hfdlg.blocksize, + current_hfdlg.bootpri, current_hfdlg.fsfilename, 0); if (result) MessageBox (hDlg, result, "Bad hardfile", MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); @@ -5458,7 +5462,7 @@ static void new_harddrive (HWND hDlg) result = add_filesys_unit (currprefs.mountinfo, 0, 0, current_hfdlg.filename, ! current_hfdlg.rw, 0, 0, - 0, current_hfdlg.blocksize, 0, 0, 0); + 0, current_hfdlg.blocksize, 0, 0, 0); if (result) MessageBox (hDlg, result, "Bad harddrive", MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); @@ -5522,8 +5526,8 @@ static void harddisk_edit (HWND hDlg) { const char *result; result = set_filesys_unit (currprefs.mountinfo, entry, current_hfdlg.devicename, 0, current_hfdlg.filename, - ! current_hfdlg.rw, current_hfdlg.sectors, current_hfdlg.surfaces, - current_hfdlg.reserved, current_hfdlg.blocksize, current_hfdlg.bootpri, current_hfdlg.fsfilename, 0); + ! current_hfdlg.rw, current_hfdlg.sectors, current_hfdlg.surfaces, + current_hfdlg.reserved, current_hfdlg.blocksize, current_hfdlg.bootpri, current_hfdlg.fsfilename, 0); if (result) MessageBox (hDlg, result, "Bad hardfile", MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); @@ -5538,8 +5542,8 @@ static void harddisk_edit (HWND hDlg) { const char *result; result = set_filesys_unit (currprefs.mountinfo, entry, 0, 0, current_hfdlg.filename, - ! current_hfdlg.rw, 0, 0, - 0, current_hfdlg.blocksize, current_hfdlg.bootpri, 0, 0); + ! current_hfdlg.rw, 0, 0, + 0, current_hfdlg.blocksize, current_hfdlg.bootpri, 0, 0); if (result) MessageBox (hDlg, result, "Bad harddrive", MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); @@ -5561,7 +5565,7 @@ static void harddisk_edit (HWND hDlg) if (DialogBox( hUIDLL ? hUIDLL : hInst, MAKEINTRESOURCE (IDD_FILESYS), hDlg, VolumeSettingsProc)) { const char *result; result = set_filesys_unit (currprefs.mountinfo, entry, current_fsvdlg.device, current_fsvdlg.volume, - current_fsvdlg.rootdir, ! current_fsvdlg.rw, 0, 0, 0, 0, current_fsvdlg.bootpri, 0, 0); + current_fsvdlg.rootdir, ! current_fsvdlg.rw, 0, 0, 0, 0, current_fsvdlg.bootpri, 0, 0); if (result) MessageBox (hDlg, result, "Bad hardfile", MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); @@ -5620,9 +5624,13 @@ static void harddiskdlg_button (HWND hDlg, int button) harddisk_move (hDlg, 0); clicked_entry++; break; - - case IDC_MAPDRIVES: - workprefs.win32_automount_drives = IsDlgButtonChecked(hDlg, button); + + case IDC_MAPDRIVES: + workprefs.win32_automount_drives = IsDlgButtonChecked(hDlg, IDC_MAPDRIVES); + break; + + case IDC_MAPDRIVES_NET: + workprefs.win32_automount_netdrives = IsDlgButtonChecked(hDlg, IDC_MAPDRIVES_NET); break; case IDC_NOUAEFSDB: @@ -5688,6 +5696,7 @@ static INT_PTR CALLBACK HarddiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA case WM_USER: CheckDlgButton (hDlg, IDC_MAPDRIVES, workprefs.win32_automount_drives); + CheckDlgButton (hDlg, IDC_MAPDRIVES_NET, workprefs.win32_automount_netdrives); CheckDlgButton (hDlg, IDC_NOUAEFSDB, workprefs.filesys_no_uaefsdb); CheckDlgButton (hDlg, IDC_NORECYCLEBIN, workprefs.win32_norecyclebin); InitializeListView (hDlg); @@ -5822,7 +5831,7 @@ static void floppytooltip (HWND hDlg, int num, uae_u32 crc32) ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND; ti.hwnd = hDlg; ti.hinst = hInst; - ti.uId = (UINT)GetDlgItem (hDlg, id); + ti.uId = (UINT_PTR)GetDlgItem (hDlg, id); SendMessage (ToolTipHWND, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); if (crc32 == 0) return; @@ -8007,7 +8016,7 @@ static BOOL CALLBACK childenumproc (HWND hwnd, LPARAM lParam) ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND; ti.hwnd = GetParent (hwnd); ti.hinst = hInst; - ti.uId = (UINT)hwnd; + ti.uId = (UINT_PTR)hwnd; ti.lpszText = p; if (imageid > 0) { int idx, i; diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index 3bbfe682..61b04506 100755 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -53,7 +53,7 @@ AdditionalOptions="" Optimization="0" AdditionalIncludeDirectories="..\..\include,..\..,..\,..\resources,..\osdep,..\sounddep" - PreprocessorDefinitions="WINVER=0x0500,_DEBUG,WIN32,_WINDOWS,ZLIB_DLL,OPENGL_SUPPORT,_WIN32_IE 0x0500,UNIX" + PreprocessorDefinitions="WINVER=0x0500,_DEBUG,WIN32,_WINDOWS,_WIN32_IE 0x0500,UNIX" ExceptionHandling="0" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -65,7 +65,7 @@ ProgramDataBaseFileName=".\Debug/" WarningLevel="3" SuppressStartupBanner="true" - Detect64BitPortabilityProblems="true" + Detect64BitPortabilityProblems="false" DebugInformationFormat="4" CompileAs="0" DisableSpecificWarnings="4996" @@ -85,7 +85,7 @@ 1) - pen = (pen & 0x000000FF) << 24 + if (Bpp > 1) + pen = (pen & 0x000000FF) << 24 | (pen & 0x0000FF00) << 8 | (pen & 0x00FF0000) >> 8 | (pen & 0xFF000000) >> 24; # endif - if (DX_Fill (x, y, width, height, pen, rgbtype)) - return; + if (DX_Fill (x, y, width, height, pen, rgbtype)) + return; } else { if (DX_Fill (x, y, width, height, picasso_vidinfo.clut[src[0]], rgbtype)) - return; + return; } P96TRACE ("P96_WARNING: do_fillrect() using fall-back routine!\n"); @@ -513,7 +513,6 @@ static void do_blit (struct RenderInfo *ri, int Bpp, int srcx, int srcy, int yoff = picasso96_state.YOffset; uae_u8 *srcp, *dstp; -// write_log ("do_blit (sx:%d sy:%d op:%d cando:%d)\n", srcx, srcy, opcode, can_do_blit); /* Clipping. */ dstx -= xoff; dsty -= yoff; @@ -547,7 +546,7 @@ static void do_blit (struct RenderInfo *ri, int Bpp, int srcx, int srcy, * Call OS blitting function that can do it in video memory. * Should return if it was successful */ - if (DX_Blit (srcx, srcy, dstx, dsty, width, height, opcode)) + if (DX_Blit (srcx, srcy, dstx, dsty, width, height, opcode)) return; } @@ -563,12 +562,12 @@ static void do_blit (struct RenderInfo *ri, int Bpp, int srcx, int srcy, goto out; dstp += dsty * picasso_vidinfo.rowbytes + dstx * picasso_vidinfo.pixbytes; P96TRACE(("do_blit with srcp 0x%x, dstp 0x%x, dst_rowbytes %d, srcx %d, srcy %d, dstx %d, dsty %d, w %d, h %d, dst_pixbytes %d\n", - srcp, dstp, picasso_vidinfo.rowbytes, srcx, srcy, dstx, dsty, width, height, picasso_vidinfo.pixbytes)); + srcp, dstp, picasso_vidinfo.rowbytes, srcx, srcy, dstx, dsty, width, height, picasso_vidinfo.pixbytes)); P96TRACE(("gfxmem is at 0x%x\n",gfxmemory)); srcp = ri->Memory + srcx * Bpp + srcy * ri->BytesPerRow; DX_Invalidate (dsty, dsty + height - 1); - + if (picasso_vidinfo.rgbformat == picasso96_state.RGBFormat) { width *= Bpp; while (height-- > 0) { @@ -758,7 +757,7 @@ void picasso_refresh (int call_setpalette) ri.BytesPerRow = picasso96_state.BytesPerRow; ri.RGBFormat = picasso96_state.RGBFormat; - if (set_panning_called) { + if (set_panning_called) { width = picasso96_state.VirtualWidth; height = picasso96_state.VirtualHeight; } else { @@ -955,7 +954,7 @@ STATIC_INLINE void do_blitrect_frame_buffer (struct RenderInfo *ri, dst += dstri->BytesPerRow; } /* for height */ } - return; + return; } // (mask != 0xFF && Bpp <= 1) tmp3 = tmp2 = tmp = xmalloc (linewidth * height); /* allocate enough memory for the src-rect */ @@ -1490,8 +1489,8 @@ uae_u32 picasso_InvertRect (void) do_invertrect (&ri, Bpp, X, Y, Width, Height); else do_blit( &ri, Bpp, X, Y, X, Y, Width, Height, BLIT_SRC, 0); - } - result = 1; + } + result = 1; } return result; } @@ -1601,8 +1600,8 @@ uae_u32 picasso_FillRect (void) int i; uaecptr addr; if (renderinfo_is_current_screen (&ri)) { - uae_u32 diff = gfxmem_start - (uae_u32)gfxmemory; - addr = ri.Memory + X * Bpp + Y * ri.BytesPerRow + diff; + uae_u32 diff = gfxmem_start - (uae_u32)gfxmemory; + addr = ri.Memory + X * Bpp + Y * ri.BytesPerRow + diff; if (Width == 1) { for (i = 0; i < Height; i++) { @@ -1675,7 +1674,7 @@ uae_u32 picasso_FillRect (void) do_blit( &ri, Bpp, X, Y, X, Y, Width, Height, BLIT_SRC, 0); result = 1; } - } + } } return result; } @@ -1738,8 +1737,8 @@ STATIC_INLINE int BlitRectHelper( void ) int can_do_visible_blit = 0; if (opcode == BLIT_DST) { - write_log( "WARNING: BlitRect() being called with opcode of BLIT_DST\n" ); - return 1; + write_log( "WARNING: BlitRect() being called with opcode of BLIT_DST\n" ); + return 1; } /* @@ -1751,11 +1750,11 @@ STATIC_INLINE int BlitRectHelper( void ) * and we need to put the results on the screen from the frame-buffer. */ if (dstri == NULL) { - if (mask != 0xFF && Bpp > 1) { - mask = 0xFF; - } - dstri = ri; - can_do_visible_blit = 1; + if (mask != 0xFF && Bpp > 1) { + mask = 0xFF; + } + dstri = ri; + can_do_visible_blit = 1; } /* Do our virtual frame-buffer memory first */ @@ -1773,15 +1772,15 @@ STATIC_INLINE int BlitRectHelper( void ) P96TRACE(("Did do_blit 1 in BlitRect()\n")); } else { - P96TRACE(("Did not do_blit 1 in BlitRect()\n")); + P96TRACE(("Did not do_blit 1 in BlitRect()\n")); } return 1; } STATIC_INLINE int BlitRect (uaecptr ri, uaecptr dstri, - unsigned long srcx, unsigned long srcy, unsigned long dstx, unsigned long dsty, - unsigned long width, unsigned long height, uae_u8 mask, BLIT_OPCODE opcode ) + unsigned long srcx, unsigned long srcy, unsigned long dstx, unsigned long dsty, + unsigned long width, unsigned long height, uae_u8 mask, BLIT_OPCODE opcode ) { /* Set up the params */ CopyRenderInfoStructureA2U( ri, &blitrectdata.ri_struct ); @@ -1882,7 +1881,7 @@ uae_u32 picasso_BlitRectNoMaskComplete (void) wgfx_flushline (); P96TRACE(("BlitRectNoMaskComplete() op 0x%2x, xy(%4d,%4d) --> xy(%4d,%4d), wh(%4d,%4d)\n", - OpCode, srcx, srcy, dstx, dsty, width, height)); + OpCode, srcx, srcy, dstx, dsty, width, height)); result = BlitRect (srcri, dstri, srcx, srcy, dstx, dsty, width, height, 0xFF, OpCode); @@ -2077,17 +2076,17 @@ uae_u32 picasso_BlitPattern (void) } /* switch (Bpp) */ } break; - } /* switch (pattern.DrawMode) */ - } /* for (bits) */ - } /* for (cols) */ - } /* for (rows) */ + } /* switch (pattern.DrawMode) */ + } /* for (bits) */ + } /* for (cols) */ + } /* for (rows) */ /* If we need to update a second-buffer (extra_mem is set), then do it only if visible! */ - if (picasso_vidinfo.extra_mem && renderinfo_is_current_screen (&ri)) + if (picasso_vidinfo.extra_mem && renderinfo_is_current_screen (&ri)) do_blit( &ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0); result = 1; - } + } } return result; } @@ -2156,13 +2155,13 @@ uae_u32 picasso_BlitTemplate (void) # endif return 0; } else - result = 1; - } else - result = 1; + result = 1; + } else + result = 1; #if 1 - if (tmp.DrawMode == COMP) { - /* workaround, let native blitter handle COMP mode */ + if (tmp.DrawMode == COMP) { + /* workaround, let native blitter handle COMP mode */ # ifdef _WIN32 flushpixels(); # endif @@ -2323,7 +2322,7 @@ static void PlanarToChunky (struct RenderInfo *ri, struct BitMap *bm, unsigned long rows, bitoffset = srcx & 7; long eol_offset; - /* if (mask != 0xFF) + /* if (mask != 0xFF) write_log ("P2C - pixel-width = %d, bit-offset = %d\n", width, bitoffset); */ /* Set up our bm->Planes[] pointers to the right horizontal offset */ @@ -2560,7 +2559,7 @@ uae_u32 picasso_BlitPlanar2Direct (void) wgfx_flushline (); if (minterm != 0x0C) { - write_log ("WARNING - BlitPlanar2Direct() has unhandled op-code 0x%x. Using fall-back routine.\n", minterm); + write_log ("WARNING - BlitPlanar2Direct() has unhandled op-code 0x%x. Using fall-back routine.\n", minterm); } else if (CopyRenderInfoStructureA2U (ri, &local_ri) && CopyBitMapStructureA2U (bm, &local_bm)) { Mask = 0xFF; CopyColorIndexMappingA2U (cim, &local_cim); @@ -2761,9 +2760,9 @@ static void REGPARAM2 gfxmem_lput (uaecptr addr, uae_u32 l) static void REGPARAM2 gfxmem_wput (uaecptr addr, uae_u32 w) { uae_u16 *m; -#ifdef JIT - special_mem|=picasso_is_special; -#endif +#ifdef JIT + special_mem|=picasso_is_special; +#endif addr -= gfxmem_start & gfxmem_mask; addr &= gfxmem_mask; m = (uae_u16 *) (gfxmemory + addr); @@ -2775,9 +2774,9 @@ static void REGPARAM2 gfxmem_wput (uaecptr addr, uae_u32 w) static void REGPARAM2 gfxmem_bput (uaecptr addr, uae_u32 b) { -#ifdef JIT - special_mem|=picasso_is_special; -#endif +#ifdef JIT + special_mem|=picasso_is_special; +#endif addr -= gfxmem_start & gfxmem_mask; addr &= gfxmem_mask; gfxmemory[addr] = b; @@ -2810,13 +2809,13 @@ int picasso_display_mode_index (uae_u32 x, uae_u32 y, uae_u32 d) { int i; for (i = 0; i < mode_count; i++) { - if (DisplayModes[i].res.width == x + if (DisplayModes[i].res.width == x && DisplayModes[i].res.height == y && DisplayModes[i].depth == d) - break; + break; } if (i == mode_count) - i = -1; + i = -1; return i; } diff --git a/readcpu.c b/readcpu.c index 854c38bd..da64a339 100755 --- a/readcpu.c +++ b/readcpu.c @@ -739,7 +739,7 @@ static void build_insn (int insn) table68k[opc].stype = srctype; table68k[opc].plev = id.plevel; table68k[opc].clev = specialcase(opc, id.cpulevel); - + #if 0 for (i = 0; i < 5; i++) { table68k[opc].flaginfo[i].flagset = id.flaginfo[i].flagset; diff --git a/savestate.c b/savestate.c index bbac98b6..81c5d801 100755 --- a/savestate.c +++ b/savestate.c @@ -24,7 +24,7 @@ * * - blitter state is not saved, blitter is forced to finish immediately if it * was active - * - disk DMA state is completely saved + * - disk DMA state is completely saved * - does not ask for statefile name and description. Currently uses DF0's disk * image name (".adf" is replaced with ".asf") * - only Amiga state is restored, harddisk support, autoconfig, expansion boards etc.. @@ -35,11 +35,11 @@ /* Usage : * * save: - * + * * set savestate_state = STATE_DOSAVE, savestate_filename = "..." * * restore: - * + * * set savestate_state = STATE_DORESTORE, savestate_filename = "..." * */ @@ -131,7 +131,7 @@ uae_u32 restore_u32_func (uae_u8 **dstp) uae_u64 restore_u64_func (uae_u8 **dstp) { uae_u64 v; - + v = restore_u32_func (dstp); v <<= 32; v |= restore_u32_func (dstp); @@ -166,7 +166,7 @@ char *restore_string_func (uae_u8 **dstp) *top++ = v; } while(v); *dstp = dst; - return to; + return to; } /* read and write IFF-style hunks */ @@ -275,7 +275,7 @@ static uae_u8 *restore_chunk (struct zfile *f, char *name, long *len, long *tota && strcmp (name, "PRAM") != 0) { /* without zeros at the end old state files may not work */ - mem = calloc (1, len2 + 32); + mem = calloc (1, len2 + 32); zfile_fread (mem, 1, len2, f); } else { mem = 0; @@ -295,7 +295,7 @@ void restore_ram (long filepos, uae_u8 *memory) uae_u8 *src = tmp; int size, fullsize; uae_u32 flags; - + zfile_fseek (savestate_file, filepos, SEEK_SET); zfile_fread (tmp, 1, sizeof(tmp), savestate_file); size = restore_u32(); @@ -552,7 +552,7 @@ void save_state (char *filename, char *description) for (i = 0; i < len2; i++) tmp[i] += 0x80; write_wavheader(f, len, 22050); - zfile_fwrite(tmp, len2, 1, f); + zfile_fwrite(tmp, len2, 1, f); xfree(tmp); } zfile_fclose (f); @@ -1033,14 +1033,14 @@ HUNK HEADER (beginning of every hunk) hunk name (4 ascii-characters) hunk size (including header) - hunk flags + hunk flags bit 0 = chunk contents are compressed with zlib (maybe RAM chunks only?) HEADER "ASF " (AmigaStateFile) - + statefile version emulator name ("uae", "fellow" etc..) emulator version string (example: "0.8.15") @@ -1105,7 +1105,7 @@ MMU (when and if MMU is supported in future..) MMUSR 4 TC 2 - + CUSTOM CHIPS "CHIP" @@ -1221,7 +1221,7 @@ INTERNAL FLOPPY CONTROLLER STATUS DSKLENGTH status 0=off,1=written once,2=written twice unused 2 -RAM SPACE +RAM SPACE "xRAM" (CRAM = chip, BRAM = bogo, FRAM = fast, ZFRAM = Z3) diff --git a/scsiemul.c b/scsiemul.c index e245b5d6..4135bfda 100755 --- a/scsiemul.c +++ b/scsiemul.c @@ -312,7 +312,7 @@ static int is_async_request (struct devstruct *dev, uaecptr request) void scsi_do_disk_change (int device_id, int insert) { int i, j; - + uae_sem_wait (&change_sem); for (i = 0; i < MAX_TOTAL_DEVICES; i++) { if (devst[i].di.id == device_id) { @@ -636,7 +636,7 @@ static void dev_reset (void) if (dev->opencnt > 0) { for (j = 0; j < MAX_ASYNC_REQUESTS; j++) { uaecptr request; - if (request = dev->d_request[i]) + if (request = dev->d_request[i]) abort_async (dev, request, 0, 0); } dev->opencnt = 1; @@ -687,6 +687,8 @@ static void dev_reset (void) } write_log ("%s = %s:%d\n", dev->di.label, UAEDEV_SCSI, dev->aunit); } + xfree(dev->di.label); + dev->di.label = NULL; } } @@ -755,7 +757,7 @@ static void diskdev_install (void) /* initcode */ initcode = here (); calltrap (deftrap (diskdev_init)); dw (RTS); - + /* Open */ openfunc = here (); calltrap (deftrap (diskdev_open)); dw (RTS); @@ -834,7 +836,7 @@ void scsidev_install (void) /* initcode */ initcode = here (); calltrap (deftrap (dev_init)); dw (RTS); - + /* Open */ openfunc = here (); calltrap (deftrap (dev_open)); dw (RTS); diff --git a/sdl-joystick.c b/sdl-joystick.c index bece7db7..8b34a388 100755 --- a/sdl-joystick.c +++ b/sdl-joystick.c @@ -1,8 +1,8 @@ - /* + /* * UAE - The Un*x Amiga Emulator - * + * * SDL Joystick code - * + * * Copyright 1997 Bernd Schmidt * Copyright 1998 Krister Walfridsson */ @@ -62,7 +62,7 @@ static void read_joy(int nr) num = SDL_JoystickNumButtons (joy); for (i = 0; i < num; i++) { int bs = SDL_JoystickGetButton (joy, i) ? 1 : 0; - setjoybuttonstate (nr, i, bs); + setjoybuttonstate (nr, i, bs); } } diff --git a/uaeexe.c b/uaeexe.c index a71911b4..ac88ae90 100755 --- a/uaeexe.c +++ b/uaeexe.c @@ -87,7 +87,7 @@ static char *get_cmd(void) char *s; if(!first) return NULL; - s = first->cmd; + s = first->cmd; cmd = first; first = first->next; if(!first) last = NULL; free(cmd); diff --git a/unzip.c b/unzip.c index 4324f5e5..495480af 100755 --- a/unzip.c +++ b/unzip.c @@ -1,4 +1,4 @@ -/* unzip.c -- IO on .zip files using zlib +/* unzip.c -- IO on .zip files using zlib Version 0.15 beta, Mar 19th, 1998, Read unzip.h for more info @@ -25,7 +25,6 @@ # include #endif - #ifndef local # define local static #endif @@ -155,7 +154,7 @@ local int unzlocal_getByte(fin,pi) /* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets + Reads a long in LSB order from the given gz_stream. Sets */ local int unzlocal_getShort (fin,pX) struct zfile* fin; @@ -167,11 +166,11 @@ local int unzlocal_getShort (fin,pX) err = unzlocal_getByte(fin,&i); x = (uLong)i; - + if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<8; - + if (err==UNZ_OK) *pX = x; else @@ -189,7 +188,7 @@ local int unzlocal_getLong (fin,pX) err = unzlocal_getByte(fin,&i); x = (uLong)i; - + if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<8; @@ -201,7 +200,7 @@ local int unzlocal_getLong (fin,pX) if (err==UNZ_OK) err = unzlocal_getByte(fin,&i); x += ((uLong)i)<<24; - + if (err==UNZ_OK) *pX = x; else @@ -245,7 +244,7 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2) #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal #endif -/* +/* Compare two filename (fileName1,fileName2). If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi @@ -266,7 +265,7 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit return strcmp(fileName1,fileName2); return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); -} +} #define BUFREADCOMMENT (0x400) @@ -282,13 +281,13 @@ local uLong unzlocal_SearchCentralDir(fin) uLong uBackRead; uLong uMaxBack=0xffff; /* maximum size of global comment */ uLong uPosFound=0; - + if (zfile_fseek(fin,0,SEEK_END) != 0) return 0; uSizeFile = zfile_ftell( fin ); - + if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; @@ -301,13 +300,13 @@ local uLong unzlocal_SearchCentralDir(fin) { uLong uReadSize,uReadPos ; int i; - if (uBackRead+BUFREADCOMMENT>uMaxBack) + if (uBackRead+BUFREADCOMMENT>uMaxBack) uBackRead = uMaxBack; else uBackRead+=BUFREADCOMMENT; uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); if (zfile_fseek(fin,uReadPos,SEEK_SET)!=0) break; @@ -316,7 +315,7 @@ local uLong unzlocal_SearchCentralDir(fin) break; for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { uPosFound = uReadPos+i; @@ -346,12 +345,12 @@ extern unzFile ZEXPORT unzOpen (fin) unz_s *s; uLong central_pos,uL; - uLong number_disk; /* number of the current dist, used for + uLong number_disk; /* number of the current dist, used for spaning ZIP, unsupported, always 0*/ uLong number_disk_with_CD; /* number the the disk with central dir, used for spaning ZIP, unsupported, always 0*/ uLong number_entry_CD; /* total number of entries in - the central dir + the central dir (same than number_entry on nospan) */ int err=UNZ_OK; @@ -395,7 +394,7 @@ extern unzFile ZEXPORT unzOpen (fin) if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) err=UNZ_ERRNO; - /* offset of start of central directory with respect to the + /* offset of start of central directory with respect to the starting disk number */ if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) err=UNZ_ERRNO; @@ -404,7 +403,7 @@ extern unzFile ZEXPORT unzOpen (fin) if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) err=UNZ_ERRNO; - if ((central_posfile,&uData) != UNZ_OK) /* size uncompr */ err=UNZ_ERRNO; -/* else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && +/* else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; */ @@ -879,7 +878,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, return err; } - + /* Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. @@ -925,7 +924,7 @@ extern int ZEXPORT unzOpenCurrentFile (file) } pfile_in_zip_read_info->stream_initialised=0; - + if ((s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; @@ -944,29 +943,29 @@ extern int ZEXPORT unzOpenCurrentFile (file) { pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; pfile_in_zip_read_info->stream.zfree = (free_func)0; - pfile_in_zip_read_info->stream.opaque = (voidpf)0; - - err=pinflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS, ZLIB_VERSION, sizeof(z_stream)); + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + + err=inflateInit2_(&pfile_in_zip_read_info->stream, -MAX_WBITS, ZLIB_VERSION, sizeof(z_stream)); if (err == Z_OK) pfile_in_zip_read_info->stream_initialised=1; /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. - * In unzip, i don't wait absolutely Z_STREAM_END because I known the + * return Z_STREAM_END. + * In unzip, i don't wait absolutely Z_STREAM_END because I known the * size of both compressed and uncompressed data */ } - pfile_in_zip_read_info->rest_read_compressed = + pfile_in_zip_read_info->rest_read_compressed = s->cur_file_info.compressed_size ; - pfile_in_zip_read_info->rest_read_uncompressed = + pfile_in_zip_read_info->rest_read_uncompressed = s->cur_file_info.uncompressed_size ; - - pfile_in_zip_read_info->pos_in_zipfile = - s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + + pfile_in_zip_read_info->pos_in_zipfile = + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + iSizeVar; - + pfile_in_zip_read_info->stream.avail_in = (uInt)0; @@ -1011,9 +1010,9 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; pfile_in_zip_read_info->stream.avail_out = (uInt)len; - + if (len>pfile_in_zip_read_info->rest_read_uncompressed) - pfile_in_zip_read_info->stream.avail_out = + pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_uncompressed; while (pfile_in_zip_read_info->stream.avail_out>0) @@ -1027,7 +1026,7 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) if (uReadThis == 0) return UNZ_EOF; if (zfile_fseek(pfile_in_zip_read_info->file, - pfile_in_zip_read_info->pos_in_zipfile + + pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) return UNZ_ERRNO; if (zfile_fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, @@ -1036,8 +1035,8 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) pfile_in_zip_read_info->pos_in_zipfile += uReadThis; pfile_in_zip_read_info->rest_read_compressed-=uReadThis; - - pfile_in_zip_read_info->stream.next_in = + + pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->read_buffer; pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; } @@ -1045,17 +1044,17 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) if (pfile_in_zip_read_info->compression_method==0) { uInt uDoCopy,i ; - if (pfile_in_zip_read_info->stream.avail_out < + if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in) uDoCopy = pfile_in_zip_read_info->stream.avail_out ; else uDoCopy = pfile_in_zip_read_info->stream.avail_in ; - + for (i=0;istream.next_out+i) = *(pfile_in_zip_read_info->stream.next_in+i); - - pfile_in_zip_read_info->crc32 = pcrc32(pfile_in_zip_read_info->crc32, + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, pfile_in_zip_read_info->stream.next_out, uDoCopy); pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; @@ -1082,23 +1081,23 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) (pfile_in_zip_read_info->rest_read_compressed == 0)) flush = Z_FINISH; */ - err=pinflate(&pfile_in_zip_read_info->stream,flush); + err=inflate(&pfile_in_zip_read_info->stream,flush); uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; uOutThis = uTotalOutAfter-uTotalOutBefore; - - pfile_in_zip_read_info->crc32 = - pcrc32(pfile_in_zip_read_info->crc32,bufBefore, + + pfile_in_zip_read_info->crc32 = + crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); - + if (err==Z_STREAM_END) return (iRead==0) ? UNZ_EOF : iRead; - if (err!=Z_OK) + if (err!=Z_OK) break; } } @@ -1130,7 +1129,7 @@ extern z_off_t ZEXPORT unztell (file) /* - return 1 if the end of file was reached, 0 elsewhere + return 1 if the end of file was reached, 0 elsewhere */ extern int ZEXPORT unzeof (file) unzFile file; @@ -1144,7 +1143,7 @@ extern int ZEXPORT unzeof (file) if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; - + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) return 1; else @@ -1162,7 +1161,7 @@ extern int ZEXPORT unzeof (file) if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. - the return value is the number of bytes copied in buf, or (if <0) + the return value is the number of bytes copied in buf, or (if <0) the error code */ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) @@ -1183,12 +1182,12 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; - size_to_read = (pfile_in_zip_read_info->size_local_extrafield - + size_to_read = (pfile_in_zip_read_info->size_local_extrafield - pfile_in_zip_read_info->pos_local_extrafield); if (buf==NULL) return (int)size_to_read; - + if (len>size_to_read) read_now = (uInt)size_to_read; else @@ -1196,9 +1195,9 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) if (read_now==0) return 0; - + if (zfile_fseek(pfile_in_zip_read_info->file, - pfile_in_zip_read_info->offset_local_extrafield + + pfile_in_zip_read_info->offset_local_extrafield + pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) return UNZ_ERRNO; @@ -1238,7 +1237,7 @@ extern int ZEXPORT unzCloseCurrentFile (file) TRYFREE(pfile_in_zip_read_info->read_buffer); pfile_in_zip_read_info->read_buffer = NULL; if (pfile_in_zip_read_info->stream_initialised) - pinflateEnd(&pfile_in_zip_read_info->stream); + inflateEnd(&pfile_in_zip_read_info->stream); pfile_in_zip_read_info->stream_initialised = 0; TRYFREE(pfile_in_zip_read_info); diff --git a/zfile.c b/zfile.c index 6a26e7f2..d1915bd8 100755 --- a/zfile.c +++ b/zfile.c @@ -34,22 +34,6 @@ struct zfile { }; static struct zfile *zlist = 0; -int is_zlib; - -#ifdef _WIN32 -static HMODULE zlib; -#include "win32.h" -#endif - -INFLATEINIT2 pinflateInit2; -INFLATEINIT pinflateInit; -INFLATEEND pinflateEnd; -INFLATE pinflate; -static DEFLATEINIT pdeflateInit; -static DEFLATEEND pdeflateEnd; -static DEFLATE pdeflate; -CRC32 pcrc32; -static int zlib_test (int, int); static struct zfile *zfile_create (void) { @@ -117,7 +101,7 @@ int zfile_gettype (struct zfile *z) { uae_u8 buf[8]; char *ext; - + if (!z) return ZFILE_UNKNOWN; ext = strrchr (z->name, '.'); @@ -236,8 +220,6 @@ static struct zfile *gunzip (struct zfile *z) struct zfile *z2; uae_u8 b; - if (!zlib_test (1, 0)) - return z; strcpy (name, z->name); memset (&zs, 0, sizeof (zs)); memset (header, 0, sizeof (header)); @@ -292,13 +274,13 @@ static struct zfile *gunzip (struct zfile *z) zs.avail_in = sizeof (buffer); zfile_fread (buffer, sizeof (buffer), 1, z); if (first) { - if (pinflateInit2 (&zs, -MAX_WBITS, ZLIB_VERSION, sizeof(z_stream)) != Z_OK) + if (inflateInit2_ (&zs, -MAX_WBITS, ZLIB_VERSION, sizeof(z_stream)) != Z_OK) break; first = 0; } - ret = pinflate (&zs, 0); + ret = inflate (&zs, 0); } while (ret == Z_OK); - pinflateEnd (&zs); + inflateEnd (&zs); if (ret != Z_STREAM_END || first != 0) { zfile_fclose (z2); return z; @@ -322,7 +304,7 @@ static struct zfile *dms (struct zfile *z) { int ret; struct zfile *zo; - + zo = zfile_fopen_empty ("zipped.dms", 1760 * 512); if (!zo) return z; ret = DMS_Process_File (z, zo, CMD_UNPACK, OPT_VERBOSE, 0, 0); @@ -349,7 +331,7 @@ static struct zfile *dms (struct zfile *z) } #endif -static char *ignoreextensions[] = +static char *ignoreextensions[] = { ".gif", ".jpg", ".png", ".xml", ".pdf", ".txt", 0 }; static char *diskimageextensions[] = { ".adf", ".adz", ".ipf", ".fdi", 0 }; @@ -412,15 +394,15 @@ static int arcacc_init (void) { if (arcacc_mod) return 1; - arcacc_mod = WIN32_LoadLibrary ("archiveaccess.dll"); + arcacc_mod = WIN32_LoadLibrary ("archiveaccess.dll"); if (!arcacc_mod) { arcacc_mod = WIN32_LoadLibrary ("archiveaccess-debug.dll"); if (!arcacc_mod) return 0; } - openArchive = (aa_pOpenArchive) GetProcAddress (arcacc_mod, "openArchive"); + openArchive = (aa_pOpenArchive) GetProcAddress (arcacc_mod, "openArchive"); getFileCount = (aa_pGetFileCount) GetProcAddress (arcacc_mod, "getFileCount"); - getFileInfo = (aa_pGetFileInfo) GetProcAddress (arcacc_mod, "getFileInfo"); + getFileInfo = (aa_pGetFileInfo) GetProcAddress (arcacc_mod, "getFileInfo"); extract = (aa_pExtract) GetProcAddress (arcacc_mod, "extract"); closeArchive = (aa_pCloseArchive) GetProcAddress (arcacc_mod, "closeArchive"); if (!openArchive || !getFileCount || !getFileInfo || !extract || !closeArchive) { @@ -556,7 +538,7 @@ static struct zfile *arcacc_unpack (struct zfile *z, int type) skipsize = 0; skipsize += (int)fi.UncompressedFileSize; } - } + } } closeArchive (ah); arcacc_pop (); @@ -568,37 +550,6 @@ static struct zfile *arcacc_unpack (struct zfile *z, int type) return z; } -static int zlib_test (int needzlib, int nomsg) -{ - static int zlibmsg; - if (is_zlib) - return 1; -#ifdef _WIN32 - zlib = WIN32_LoadLibrary ("zlib1.dll"); - if (!zlib) - zlib = WIN32_LoadLibrary("zlib1_64.dll"); - if (zlib) { - pinflateInit2 = (INFLATEINIT2)GetProcAddress (zlib, "inflateInit2_"); - pinflateInit = (INFLATEINIT)GetProcAddress (zlib, "inflateInit_"); - pinflate = (INFLATE)GetProcAddress (zlib, "inflate"); - pinflateEnd = (INFLATEEND)GetProcAddress (zlib, "inflateEnd"); - pdeflateInit = (DEFLATEINIT)GetProcAddress (zlib, "deflateInit_"); - pdeflate = (DEFLATE)GetProcAddress (zlib, "deflate"); - pdeflateEnd = (DEFLATEEND)GetProcAddress (zlib, "deflateEnd"); - pcrc32 = (CRC32)GetProcAddress (zlib, "crc32"); - is_zlib = 1; - return 1; - } -#endif - if (!needzlib && arcacc_init ()) - return 1; - if (zlibmsg || nomsg) - return 0; - zlibmsg = 1; - notify_user (NUMSG_NOZLIB); - return 0; -} - static struct zfile *unzip (struct zfile *z) { unzFile uz; @@ -609,8 +560,6 @@ static struct zfile *unzip (struct zfile *z) char tmphist[MAX_DPATH]; int first = 1; - if (!zlib_test (1, 0)) - return z; zf = 0; uz = unzOpen (z); if (!uz) @@ -676,7 +625,7 @@ static struct zfile *unzip (struct zfile *z) } zipcnt++; err = unzGoToNextFile (uz); - if (err != UNZ_OK) + if (err != UNZ_OK) break; } if (zf) { @@ -703,7 +652,7 @@ static int iszip (struct zfile *z) zfile_fseek (z, 0, SEEK_SET); zfile_fread (header, sizeof (header), 1, z); zfile_fseek (z, 0, SEEK_SET); - if (!strcasecmp (ext, ".zip") && header[0] == 'P' && header[1] == 'K' && zlib_test (1, 1)) + if (!strcasecmp (ext, ".zip") && header[0] == 'P' && header[1] == 'K') return -1; for (i = 0; plugins_7z[i]; i++) { if (plugins_7z_x[i] && !strcasecmp (ext + 1, plugins_7z[i]) && @@ -722,7 +671,7 @@ static struct zfile *zuncompress (struct zfile *z) if (ext != NULL) { ext++; - if (strcasecmp (ext, "zip") == 0 && zlib_test (1, 1)) + if (strcasecmp (ext, "zip") == 0) return unzip (z); if (strcasecmp (ext, "gz") == 0) return gunzip (z); @@ -757,7 +706,7 @@ static FILE *openzip (char *name, char *zippath) { int i, j; char v; - + i = strlen (name) - 2; if (zippath) zippath[0] = 0; @@ -929,8 +878,6 @@ static int zunzip (struct zfile *z, zfile_callback zc, void *user) struct zfile *zf; int err; - if (!zlib_test (1, 0)) - return 0; zf = 0; uz = unzOpen (z); if (!uz) @@ -1109,7 +1056,7 @@ size_t zfile_fputs (struct zfile *z, char *s) size_t zfile_fwrite (void *b, size_t l1, size_t l2, struct zfile *z) { long len = l1 * l2; - + if (z->writeskipbytes) { z->writeskipbytes -= len; if (z->writeskipbytes >= 0) @@ -1137,10 +1084,8 @@ int zfile_zuncompress (void *dst, int dstsize, struct zfile *src, int srcsize) uae_u8 inbuf[4096]; int incnt; - if (!zlib_test (1, 0)) - return 0; memset (&zs, 0, sizeof(zs)); - if (pinflateInit (&zs, ZLIB_VERSION, sizeof(z_stream)) != Z_OK) + if (inflateInit_ (&zs, ZLIB_VERSION, sizeof(z_stream)) != Z_OK) return 0; zs.next_out = dst; zs.avail_out = dstsize; @@ -1156,9 +1101,9 @@ int zfile_zuncompress (void *dst, int dstsize, struct zfile *src, int srcsize) zs.avail_in = zfile_fread (inbuf, 1, left, src); incnt += left; } - v = pinflate (&zs, 0); + v = inflate (&zs, 0); } - pinflateEnd (&zs); + inflateEnd (&zs); return 0; } @@ -1168,10 +1113,8 @@ int zfile_zcompress (struct zfile *f, void *src, int size) z_stream zs; uae_u8 outbuf[4096]; - if (!is_zlib) - return 0; memset (&zs, 0, sizeof (zs)); - if (pdeflateInit (&zs, Z_DEFAULT_COMPRESSION, ZLIB_VERSION, sizeof(z_stream)) != Z_OK) + if (deflateInit_ (&zs, Z_DEFAULT_COMPRESSION, ZLIB_VERSION, sizeof(z_stream)) != Z_OK) return 0; zs.next_in = src; zs.avail_in = size; @@ -1179,11 +1122,11 @@ int zfile_zcompress (struct zfile *f, void *src, int size) while (v == Z_OK) { zs.next_out = outbuf; zs.avail_out = sizeof (outbuf); - v = pdeflate(&zs, Z_NO_FLUSH | Z_FINISH); + v = deflate(&zs, Z_NO_FLUSH | Z_FINISH); if (sizeof(outbuf) - zs.avail_out > 0) zfile_fwrite (outbuf, 1, sizeof (outbuf) - zs.avail_out, f); } - pdeflateEnd(&zs); + deflateEnd(&zs); return zs.total_out; } @@ -1211,7 +1154,7 @@ uae_u32 zfile_crc32 (struct zfile *f) memset (p, 0, size); zfile_fseek (f, 0, SEEK_SET); zfile_fread (p, 1, size, f); - zfile_fseek (f, pos, SEEK_SET); + zfile_fseek (f, pos, SEEK_SET); crc = get_crc32 (p, size); xfree (p); return crc;