From 9b89649308f7b960c20a7280b9904ce242c6264e Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 6 Feb 2010 18:35:11 +0200 Subject: [PATCH] imported winuaesrc2020b8.zip --- archivers/dms/pfile.c | 29 +- blitter.c | 2 +- cia.c | 14 +- custom.c | 280 +-- debug.c | 4 +- epsonprinter.c | 12 +- fpp.c | 2053 +++++++++++----------- gencpu.c | 7 +- hardfile.c | 256 +-- include/cpu_prefetch.h | 30 +- include/events_jit.h | 10 +- include/filesys.h | 2 +- include/memory.h | 4 +- include/newcpu.h | 4 +- jit/compemu_support.c | 4 +- main.c | 15 +- newcpu.c | 48 +- od-win32/bsdsock.c | 2 +- od-win32/debug_win32.c | 22 +- od-win32/dinput.c | 12 + od-win32/direct3d.cpp | 261 ++- od-win32/mman.c | 5 +- od-win32/parser.c | 20 +- od-win32/prowizard/prowizard.vcproj | 137 ++ od-win32/resources/resource | 2 + od-win32/resources/winuae.rc | 4 +- od-win32/resources/winuae64.exe.manifest | 21 + od-win32/sysconfig.h | 1 + od-win32/win32.c | 48 +- od-win32/win32.h | 4 +- od-win32/win32_filesys.c | 2 + od-win32/win32_scale2x.c | 3 + od-win32/win32gfx.c | 4 +- od-win32/win32gui.c | 71 +- od-win32/winuae_msvc/winuae_msvc.vcproj | 1035 ++++------- od-win32/winuaechangelog.txt | 18 + uaeunp.c | 2 +- 37 files changed, 2259 insertions(+), 2189 deletions(-) create mode 100644 od-win32/resources/winuae64.exe.manifest diff --git a/archivers/dms/pfile.c b/archivers/dms/pfile.c index 548c446f..fcfd473f 100644 --- a/archivers/dms/pfile.c +++ b/archivers/dms/pfile.c @@ -33,7 +33,10 @@ #include "crc_csum.h" #include "pfile.h" +static int dolog = 0; +#define DMSFLAG_ENCRYPTED 2 +#define DMSFLAG_HD 16 static USHORT Process_Track(struct zfile *, struct zfile *, UCHAR *, UCHAR *, USHORT, USHORT, int); static USHORT Unpack_Track(UCHAR *, UCHAR *, USHORT, USHORT, UCHAR, UCHAR, USHORT, USHORT, USHORT, int); @@ -123,7 +126,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o PWDCRC = PCRC; - if ( (cmd == CMD_VIEW) || (cmd == CMD_VIEWFULL) ) { + if (dolog) { pv = (USHORT)(c_version/100); write_log (L" Created with DMS version %d.%02d ",pv,c_version-pv*100); @@ -203,7 +206,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o } - if (cmd == CMD_VIEWFULL) { + if (dolog) { write_log (L" Track Plength Ulength Cmode USUM HCRC DCRC Cflag\n"); write_log (L" ------ ------- ------- ------ ---- ---- ---- -----\n"); } @@ -217,12 +220,11 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o if (cmd != CMD_VIEW) { if (cmd == CMD_SHOWBANNER) /* Banner is in the first track */ - ret = Process_Track(fi,NULL,b1,b2,cmd,opt,(geninfo & 2)); + ret = Process_Track(fi,NULL,b1,b2,cmd,opt,geninfo); else { - zfile_fseek (fo, from * 512 * 22, SEEK_SET); for (;;) { int ok = 0; - ret = Process_Track(fi,fo,b1,b2,cmd,opt,(geninfo & 2)); + ret = Process_Track(fi,fo,b1,b2,cmd,opt,geninfo); if (ret == DMS_FILE_END) break; if (ret == NO_PROBLEM) @@ -275,7 +277,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o -static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR *b2, USHORT cmd, USHORT opt, int enc){ +static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR *b2, USHORT cmd, USHORT opt, int dmsflags){ USHORT hcrc, dcrc, usum, number, pklen1, pklen2, unpklen, l; UCHAR cmode, flags; int crcerr = 0; @@ -307,9 +309,10 @@ static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR usum = (USHORT)((b1[14] << 8) | b1[15]); /* Track Data CheckSum AFTER unpacking */ dcrc = (USHORT)((b1[16] << 8) | b1[17]); /* Track Data CRC BEFORE unpacking */ - //write_log (L"DMS: track=%d\n", number); + if (dolog) + write_log (L"DMS: track=%d\n", number); - if (cmd == CMD_VIEWFULL) { + if (dolog) { if (number==80) write_log (L" FileID "); else if (number==0xffff) @@ -339,20 +342,22 @@ static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR if ((cmd == CMD_UNPACK) && (number<80) && (unpklen>2048)) { memset(b2, 0, unpklen); if (!crcerr) - Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum, enc); - if (zfile_fwrite(b2,1,(size_t)unpklen,fo) != unpklen) return ERR_CANTWRITE; + Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum, dmsflags & DMSFLAG_ENCRYPTED); + zfile_fseek (fo, number * 512 * 22 * ((dmsflags & DMSFLAG_HD) ? 2 : 1), SEEK_SET); + if (zfile_fwrite(b2,1,(size_t)unpklen,fo) != unpklen) + return ERR_CANTWRITE; } if (crcerr) return NO_PROBLEM; if ((cmd == CMD_SHOWBANNER) && (number == 0xffff)){ - Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum, enc); + Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum, dmsflags & DMSFLAG_ENCRYPTED); printbandiz(b2,unpklen); } if ((cmd == CMD_SHOWDIZ) && (number == 80)) { - Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum, enc); + Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum, dmsflags & DMSFLAG_ENCRYPTED); printbandiz(b2,unpklen); } diff --git a/blitter.c b/blitter.c index 4e44ce07..444b413c 100644 --- a/blitter.c +++ b/blitter.c @@ -300,7 +300,7 @@ static void blitter_interrupt (int hpos, int done) if (!done && (!currprefs.blitter_cycle_exact || (currprefs.chipset_mask & CSMASK_AGA))) return; blit_interrupt = 1; - send_interrupt (6, 2); + send_interrupt (6, 0); if (debug_dma) record_dma_event (DMA_EVENT_BLITIRQ, hpos, vpos); } diff --git a/cia.c b/cia.c index aaa18735..b9187cfc 100644 --- a/cia.c +++ b/cia.c @@ -89,7 +89,7 @@ static void RethinkICRA (void) { if (ciaaimask & ciaaicr) { ciaaicr |= 0x80; - send_interrupt (3, 2); + send_interrupt (3, 0); } } @@ -97,7 +97,7 @@ static void RethinkICRB (void) { if (ciabimask & ciabicr) { ciabicr |= 0x80; - send_interrupt (13, 2); + send_interrupt (13, 0); } } @@ -1237,10 +1237,11 @@ STATIC_INLINE isgayle (void) return (currprefs.cs_ide == IDE_A600A1200 || currprefs.cs_pcmcia); } -/* e-clock is 10 CPU cycles, 6 cycles low, 4 high +/* e-clock is 10 CPU cycles, 4 cycles high, 6 low * data transfer happens during 4 high cycles */ #define ECLOCK_DATA_CYCLE 4 +#define ECLOCK_WAIT_CYCLE 6 static void cia_wait_pre (void) { @@ -1248,12 +1249,11 @@ static void cia_wait_pre (void) int div10 = (get_cycles () - eventtab[ev_cia].oldcycles) % DIV10; int cycles; - cycles = 5 * CYCLE_UNIT / 2; if (div10 > DIV10 * ECLOCK_DATA_CYCLE / 10) { - cycles += DIV10 - div10; + cycles = DIV10 - div10; cycles += DIV10 * ECLOCK_DATA_CYCLE / 10; } else { - cycles += DIV10 * ECLOCK_DATA_CYCLE / 10 - div10; + cycles = DIV10 * ECLOCK_DATA_CYCLE / 10 - div10; } do_cycles (cycles); #endif @@ -1261,7 +1261,7 @@ static void cia_wait_pre (void) static void cia_wait_post (void) { - do_cycles (2 * CYCLE_UNIT / 2); + do_cycles (6 * CYCLE_UNIT / 2); } static uae_u32 REGPARAM2 cia_bget (uaecptr addr) diff --git a/custom.c b/custom.c index b64dce17..04cf5713 100644 --- a/custom.c +++ b/custom.c @@ -166,7 +166,7 @@ static int REGPARAM3 custom_wput_1 (int, uaecptr, uae_u32, int) REGPARAM; static uae_u16 cregs[256]; -uae_u16 intena, intreq, intreqr; +uae_u16 intena, intreq; uae_u16 dmacon; uae_u16 adkcon; /* used by audio code */ @@ -2966,7 +2966,7 @@ STATIC_INLINE uae_u16 INTENAR (void) } uae_u16 INTREQR (void) { - return intreqr; + return intreq; } STATIC_INLINE uae_u16 ADKCONR (void) { @@ -3358,33 +3358,36 @@ void NMI_delayed (void) irq_nmi = 1; } +static uae_u16 intreq_internal, intena_internal; + int intlev (void) { - uae_u16 imask = intreq & intena; + uae_u16 imask = intreq_internal & intena_internal; if (irq_nmi) { irq_nmi = 0; return 7; } - if (!(imask && (intena & 0x4000))) + if (!(imask && (intena_internal & 0x4000))) return -1; - if (imask & (0x4000 | 0x2000)) // 13 14 + if (imask & (0x4000 | 0x2000)) // 13 14 return 6; - if (imask & (0x1000 | 0x0800)) // 11 12 + if (imask & (0x1000 | 0x0800)) // 11 12 return 5; - if (imask & (0x0400 | 0x0200 | 0x0100 | 0x0080)) // 7 8 9 10 + if (imask & (0x0400 | 0x0200 | 0x0100 | 0x0080)) // 7 8 9 10 return 4; - if (imask & (0x0040 | 0x0020 | 0x0010)) // 4 5 6 + if (imask & (0x0040 | 0x0020 | 0x0010)) // 4 5 6 return 3; - if (imask & 0x0008) // 3 + if (imask & 0x0008) // 3 return 2; - if (imask & (0x0001 | 0x0002 | 0x0004)) // 0 1 2 + if (imask & (0x0001 | 0x0002 | 0x0004)) // 0 1 2 return 1; return -1; } +#define INT_PROCESSING_DELAY 3 STATIC_INLINE int use_eventmode (void) { - return currprefs.cpu_cycle_exact != 0; + return currprefs.cpu_cycle_exact != 0 && currprefs.cpu_model == 68000; } static void send_interrupt_do (uae_u32 v) @@ -3395,55 +3398,55 @@ static void send_interrupt_do (uae_u32 v) void send_interrupt (int num, int delay) { if (use_eventmode () && delay > 0) { - if (!(intreqr & (1 << num))) + if (!(intreq & (1 << num))) event2_newevent_xx (-1, delay * CYCLE_UNIT, num, send_interrupt_do); } else { send_interrupt_do (num); } } -STATIC_INLINE void INTENA (uae_u16 v) +static void send_intena_do (uae_u32 v) +{ + intena_internal = v; + doint (); +} +static void send_intreq_do (uae_u32 v) { - setclr (&intena,v); + intreq_internal = v; + doint (); +} + +static void INTENA (uae_u16 v) +{ + uae_u16 old = intena; + setclr (&intena, v); + + if (old != intena || (v & 0x8000)) { + if (use_eventmode ()) + event2_newevent_xx (-1, INT_PROCESSING_DELAY * CYCLE_UNIT, intena, send_intena_do); + else + send_intena_do (intena); + } #if 0 if (v & 0x40) write_log (L"INTENA %04X (%04X) %p\n", intena, v, M68K_GETPC); #endif -#if 0 - if (use_eventmode ()) { - send_interrupt (); - } else if (v & 0x8000) { - doint (); - } -#endif - if (v & 0x8000) - doint (); } void INTREQ_0 (uae_u16 v) { - uae_u16 tmp = intreq; - intreqr = intreq; - /* data in intreq is immediately available (vsync only currently because there is something unknown..) */ - setclr (&intreqr, v & (0x8000 | 0x20)); + uae_u16 old = intreq; setclr (&intreq, v); - if (v & (0x80 | 0x100 | 0x200 | 0x400)) + if (v & (0x0080 | 0x0100 | 0x0200 | 0x0400)) audio_update_irq (v); - intreqr = intreq; -#if 0 - if (use_eventmode ()) { - if (tmp != intreq) - send_interrupt (); - if (tmp > intreq) { - if (debug_dma) - record_dma_event (DMA_EVENT_INTREQ, current_hpos (), vpos); - } - } else { - doint (); + + if (old != intreq || (v & 0x8000)) { + if (use_eventmode ()) + event2_newevent_xx (-1, INT_PROCESSING_DELAY * CYCLE_UNIT, intreq, send_intreq_do); + else + send_intreq_do (intreq); } -#endif - doint (); } void INTREQ (uae_u16 data) @@ -3471,7 +3474,7 @@ static void ADKCON (int hpos, uae_u16 v) if (currprefs.produce_sound > 0) update_audio (); - setclr (&adkcon,v); + setclr (&adkcon, v); audio_update_adkmasks (); DISK_update (hpos); if ((v >> 11) & 1) @@ -5686,7 +5689,8 @@ void customreset (int hardreset) memset (spr, 0, sizeof spr); nr_armed = 0; - dmacon = intena = 0; + dmacon = 0; + intena = intena_internal = 0; copcon = 0; DSKLEN (0, 0); @@ -6417,37 +6421,37 @@ uae_u8 *restore_custom (uae_u8 *src) changed_prefs.chipset_mask = currprefs.chipset_mask = RL; update_mirrors (); - RW; /* 000 BLTDDAT */ - RW; /* 002 DMACONR */ - RW; /* 004 VPOSR */ - RW; /* 006 VHPOSR */ - RW; /* 008 DSKDATR (dummy register) */ - RW; /* 00A JOY0DAT */ - RW; /* 00C JOY1DAT */ - clxdat = RW; /* 00E CLXDAT */ - RW; /* 010 ADKCONR */ - RW; /* 012 POT0DAT* */ - RW; /* 014 POT1DAT* */ - RW; /* 016 POTINP* */ - RW; /* 018 SERDATR* */ - dskbytr = RW; /* 01A DSKBYTR */ - RW; /* 01C INTENAR */ - RW; /* 01E INTREQR */ - dskpt = RL; /* 020-022 DSKPT */ - dsklen = RW; /* 024 DSKLEN */ - RW; /* 026 DSKDAT */ - RW; /* 028 REFPTR */ + RW; /* 000 BLTDDAT */ + RW; /* 002 DMACONR */ + RW; /* 004 VPOSR */ + RW; /* 006 VHPOSR */ + RW; /* 008 DSKDATR (dummy register) */ + RW; /* 00A JOY0DAT */ + RW; /* 00C JOY1DAT */ + clxdat = RW; /* 00E CLXDAT */ + RW; /* 010 ADKCONR */ + RW; /* 012 POT0DAT* */ + RW; /* 014 POT1DAT* */ + RW; /* 016 POTINP* */ + RW; /* 018 SERDATR* */ + dskbytr = RW; /* 01A DSKBYTR */ + RW; /* 01C INTENAR */ + RW; /* 01E INTREQR */ + dskpt = RL; /* 020-022 DSKPT */ + dsklen = RW; /* 024 DSKLEN */ + RW; /* 026 DSKDAT */ + RW; /* 028 REFPTR */ i = RW; lof = (i & 0x8000) ? 1 : 0; lol = (i & 0x0080); /* 02A VPOSW */ - RW; /* 02C VHPOSW */ - COPCON (RW); /* 02E COPCON */ - RW; /* 030 SERDAT* */ - RW; /* 032 SERPER* */ - POTGO (RW); /* 034 POTGO */ - RW; /* 036 JOYTEST* */ - RW; /* 038 STREQU */ - RW; /* 03A STRVHBL */ - RW; /* 03C STRHOR */ - RW; /* 03E STRLONG */ + RW; /* 02C VHPOSW */ + COPCON (RW); /* 02E COPCON */ + RW; /* 030 SERDAT* */ + RW; /* 032 SERPER* */ + POTGO (RW); /* 034 POTGO */ + RW; /* 036 JOYTEST* */ + RW; /* 038 STREQU */ + RW; /* 03A STRVHBL */ + RW; /* 03C STRHOR */ + RW; /* 03E STRLONG */ BLTCON0 (0, RW); /* 040 BLTCON0 */ BLTCON1 (0, RW); /* 042 BLTCON1 */ BLTAFWM (0, RW); /* 044 BLTAFWM */ @@ -6456,89 +6460,89 @@ uae_u8 *restore_custom (uae_u8 *src) BLTBPTH (0, RW);BLTBPTL(0, RW); /* 04C-04F BLTBPT */ BLTAPTH (0, RW);BLTAPTL(0, RW); /* 050-053 BLTAPT */ BLTDPTH (0, RW);BLTDPTL(0, RW); /* 054-057 BLTDPT */ - RW; /* 058 BLTSIZE */ - RW; /* 05A BLTCON0L */ - blt_info.vblitsize = RW; /* 05C BLTSIZV */ - blt_info.hblitsize = RW; /* 05E BLTSIZH */ + RW; /* 058 BLTSIZE */ + RW; /* 05A BLTCON0L */ + blt_info.vblitsize = RW;/* 05C BLTSIZV */ + blt_info.hblitsize = RW;/* 05E BLTSIZH */ BLTCMOD (0, RW); /* 060 BLTCMOD */ BLTBMOD (0, RW); /* 062 BLTBMOD */ BLTAMOD (0, RW); /* 064 BLTAMOD */ BLTDMOD (0, RW); /* 066 BLTDMOD */ - RW; /* 068 ? */ - RW; /* 06A ? */ - RW; /* 06C ? */ - RW; /* 06E ? */ + RW; /* 068 ? */ + RW; /* 06A ? */ + RW; /* 06C ? */ + RW; /* 06E ? */ BLTCDAT (0, RW); /* 070 BLTCDAT */ BLTBDAT (0, RW); /* 072 BLTBDAT */ BLTADAT (0, RW); /* 074 BLTADAT */ - RW; /* 076 ? */ - RW; /* 078 ? */ - RW; /* 07A ? */ - RW; /* 07C LISAID */ + RW; /* 076 ? */ + RW; /* 078 ? */ + RW; /* 07A ? */ + RW; /* 07C LISAID */ DSKSYNC (-1, RW); /* 07E DSKSYNC */ - cop1lc = RL; /* 080/082 COP1LC */ - cop2lc = RL; /* 084/086 COP2LC */ - RW; /* 088 ? */ - RW; /* 08A ? */ - RW; /* 08C ? */ - diwstrt = RW; /* 08E DIWSTRT */ - diwstop = RW; /* 090 DIWSTOP */ - ddfstrt = RW; /* 092 DDFSTRT */ - ddfstop = RW; /* 094 DDFSTOP */ + cop1lc = RL; /* 080/082 COP1LC */ + cop2lc = RL; /* 084/086 COP2LC */ + RW; /* 088 ? */ + RW; /* 08A ? */ + RW; /* 08C ? */ + diwstrt = RW; /* 08E DIWSTRT */ + diwstop = RW; /* 090 DIWSTOP */ + ddfstrt = RW; /* 092 DDFSTRT */ + ddfstop = RW; /* 094 DDFSTOP */ dmacon = RW & ~(0x2000|0x4000); /* 096 DMACON */ - CLXCON (RW); /* 098 CLXCON */ - intena = RW; /* 09A INTENA */ - intreq = intreqr = RW | 0x20; /* 09C INTREQ */ - adkcon = RW; /* 09E ADKCON */ + CLXCON (RW); /* 098 CLXCON */ + intena = intena_internal = RW; /* 09A INTENA */ + intreq = intreq_internal = RW | 0x20; /* 09C INTREQ */ + adkcon = RW; /* 09E ADKCON */ for (i = 0; i < 8; i++) bplptx[i] = bplpt[i] = RL; - bplcon0 = RW; /* 100 BPLCON0 */ - bplcon1 = RW; /* 102 BPLCON1 */ - bplcon2 = RW; /* 104 BPLCON2 */ - bplcon3 = RW; /* 106 BPLCON3 */ - bpl1mod = RW; /* 108 BPL1MOD */ - bpl2mod = RW; /* 10A BPL2MOD */ - bplcon4 = RW; /* 10C BPLCON4 */ - clxcon2 = RW; /* 10E CLXCON2* */ + bplcon0 = RW; /* 100 BPLCON0 */ + bplcon1 = RW; /* 102 BPLCON1 */ + bplcon2 = RW; /* 104 BPLCON2 */ + bplcon3 = RW; /* 106 BPLCON3 */ + bpl1mod = RW; /* 108 BPL1MOD */ + bpl2mod = RW; /* 10A BPL2MOD */ + bplcon4 = RW; /* 10C BPLCON4 */ + clxcon2 = RW; /* 10E CLXCON2* */ for(i = 0; i < 8; i++) bplxdat[i] = RW; /* BPLXDAT */ for(i = 0; i < 32; i++) current_colors.color_regs_ecs[i] = RW; /* 180 COLORxx */ - htotal = RW; /* 1C0 HTOTAL */ - hsstop = RW; /* 1C2 HSTOP ? */ - hbstrt = RW; /* 1C4 HBSTRT ? */ - hbstop = RW; /* 1C6 HBSTOP ? */ - vtotal = RW; /* 1C8 VTOTAL */ - vsstop = RW; /* 1CA VSSTOP */ - vbstrt = RW; /* 1CC VBSTRT */ - vbstop = RW; /* 1CE VBSTOP */ - RW; /* 1D0 ? */ - RW; /* 1D2 ? */ - RW; /* 1D4 ? */ - RW; /* 1D6 ? */ - RW; /* 1D8 ? */ - RW; /* 1DA ? */ + htotal = RW; /* 1C0 HTOTAL */ + hsstop = RW; /* 1C2 HSTOP ? */ + hbstrt = RW; /* 1C4 HBSTRT ? */ + hbstop = RW; /* 1C6 HBSTOP ? */ + vtotal = RW; /* 1C8 VTOTAL */ + vsstop = RW; /* 1CA VSSTOP */ + vbstrt = RW; /* 1CC VBSTRT */ + vbstop = RW; /* 1CE VBSTOP */ + RW; /* 1D0 ? */ + RW; /* 1D2 ? */ + RW; /* 1D4 ? */ + RW; /* 1D6 ? */ + RW; /* 1D8 ? */ + RW; /* 1DA ? */ new_beamcon0 = RW; /* 1DC BEAMCON0 */ - hsstrt = RW; /* 1DE HSSTRT */ - vsstrt = RW; /* 1E0 VSSTT */ - hcenter = RW; /* 1E2 HCENTER */ - diwhigh = RW; /* 1E4 DIWHIGH */ + hsstrt = RW; /* 1DE HSSTRT */ + vsstrt = RW; /* 1E0 VSSTT */ + hcenter = RW; /* 1E2 HCENTER */ + diwhigh = RW; /* 1E4 DIWHIGH */ diwhigh_written = (diwhigh & 0x8000) ? 1 : 0; hdiwstate = (diwhigh & 0x4000) ? DIW_waiting_stop : DIW_waiting_start; diwhigh &= 0x3fff; - RW; /* 1E6 ? */ - RW; /* 1E8 ? */ - RW; /* 1EA ? */ - RW; /* 1EC ? */ - RW; /* 1EE ? */ - RW; /* 1F0 ? */ - RW; /* 1F2 ? */ - RW; /* 1F4 ? */ - RW; /* 1F6 ? */ - RW; /* 1F8 ? */ - RW; /* 1FA ? */ - fmode = RW; /* 1FC FMODE */ - last_custom_value1 = RW; /* 1FE ? */ + RW; /* 1E6 ? */ + RW; /* 1E8 ? */ + RW; /* 1EA ? */ + RW; /* 1EC ? */ + RW; /* 1EE ? */ + RW; /* 1F0 ? */ + RW; /* 1F2 ? */ + RW; /* 1F4 ? */ + RW; /* 1F6 ? */ + RW; /* 1F8 ? */ + RW; /* 1FA ? */ + fmode = RW; /* 1FC FMODE */ + last_custom_value1 = RW;/* 1FE ? */ DISK_restore_custom (dskpt, dsklen, dskbytr); @@ -6917,6 +6921,7 @@ uae_u32 wait_cpu_cycle_read (uaecptr addr, int mode) struct dma_rec *dr; hpos = dma_cycle (); + regs.ipl = regs.ipl_pin; do_cycles_ce (CYCLE_UNIT); #ifdef DEBUGGER @@ -6991,6 +6996,7 @@ void wait_cpu_cycle_write (uaecptr addr, int mode, uae_u32 v) int hpos; hpos = dma_cycle (); + regs.ipl = regs.ipl_pin; do_cycles_ce (CYCLE_UNIT); #ifdef DEBUGGER diff --git a/debug.c b/debug.c index db1325c9..31b7fae5 100644 --- a/debug.c +++ b/debug.c @@ -3717,14 +3717,13 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2) struct mmudata *snptr; struct mmunode *mn; static int wasjit; - +#ifdef JIT if (currprefs.cachesize) { wasjit = currprefs.cachesize; changed_prefs.cachesize = 0; console_out (L"MMU: JIT disabled\n"); check_prefs_changed_comp (); } - if (mode == 0) { if (mmu_enabled) { mmu_free (); @@ -3735,6 +3734,7 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2) mmu_logging = 0; return 1; } +#endif if (mode == 1) { if (!mmu_enabled) diff --git a/epsonprinter.c b/epsonprinter.c index 27a986b2..2525e85e 100644 --- a/epsonprinter.c +++ b/epsonprinter.c @@ -24,6 +24,8 @@ #include "sysdeps.h" #include "uae.h" +#ifndef CPU_64_BIT + #define C_LIBPNG #define FREETYPE2_STATIC @@ -1970,14 +1972,17 @@ static int epson_ft (void) } return 1; } - +#endif void epson_printchar(uae_u8 c) { +#ifndef CPU_64_BIT printChar (c); +#endif } int epson_init(int type) { +#ifndef CPU_64_BIT if (type == PARALLEL_MATRIX_EPSON9) pins = 9; else @@ -1985,11 +1990,16 @@ int epson_init(int type) epson_ft (); write_log (L"EPSONPRINTER%d: start\n", pins); return printer_init(300, 83, 117, L"png", 0, pins); +#else + return 0; +#endif } void epson_close(void) { +#ifndef CPU_64_BIT if (page && !isBlank ()) { outputPage(); } printer_close(); +#endif } diff --git a/fpp.c b/fpp.c index e608532a..c5940cdd 100644 --- a/fpp.c +++ b/fpp.c @@ -114,374 +114,379 @@ float fp_1e0 = 1, fp_1e1 = 10, fp_1e2 = 100, fp_1e4 = 10000; #define MAKE_FPSR(r) (regs).fp_result=(r) static uae_u16 x87_cw_tab[] = { - 0x137f, 0x1f7f, 0x177f, 0x1b7f, /* Extended */ - 0x107f, 0x1c7f, 0x147f, 0x187f, /* Single */ - 0x127f, 0x1e7f, 0x167f, 0x1a7f, /* Double */ - 0x137f, 0x1f7f, 0x177f, 0x1b7f}; /* undefined */ - /* Nearest, toZero, Down, Up */ - static __inline__ void native_set_fpucw (uae_u32 m68k_cw) - { + 0x137f, 0x1f7f, 0x177f, 0x1b7f, /* Extended */ + 0x107f, 0x1c7f, 0x147f, 0x187f, /* Single */ + 0x127f, 0x1e7f, 0x167f, 0x1a7f, /* Double */ + 0x137f, 0x1f7f, 0x177f, 0x1b7f /* undefined */ +}; +/* Nearest, toZero, Down, Up */ +static __inline__ void native_set_fpucw (uae_u32 m68k_cw) +{ #if USE_X86_FPUCW - uae_u16 x87_cw = x87_cw_tab[(m68k_cw >> 4) & 0xf]; + uae_u16 x87_cw = x87_cw_tab[(m68k_cw >> 4) & 0xf]; #if defined(X86_MSVC_ASSEMBLY) - __asm { - fldcw word ptr x87_cw - } + __asm { + fldcw word ptr x87_cw + } #elif defined(X86_ASSEMBLY) - __asm__ ("fldcw %0" : : "m" (*&x87_cw)); + __asm__ ("fldcw %0" : : "m" (*&x87_cw)); #endif #endif - } +} #if defined(uae_s64) /* Close enough for government work? */ - typedef uae_s64 tointtype; +typedef uae_s64 tointtype; #else - typedef uae_s32 tointtype; +typedef uae_s32 tointtype; #endif - STATIC_INLINE uae_u32 next_ilong_fpu (void) - { - if (currprefs.mmu_model) - return next_ilong_mmu (); - else if (currprefs.cpu_cycle_exact) - return next_ilong_020ce (); - else - return next_ilong (); - } - STATIC_INLINE uae_u32 next_iword_fpu (void) - { - if (currprefs.mmu_model) - return next_iword_mmu (); - else if (currprefs.cpu_cycle_exact) - return next_iword_020ce (); - else - return next_iword (); - } - STATIC_INLINE void put_long_fpu (uaecptr addr, uae_u32 v) - { - if (currprefs.mmu_model) - put_long_mmu (addr, v); - else if (currprefs.cpu_cycle_exact) - put_long_ce020 (addr, v); - else - put_long (addr, v); - } - STATIC_INLINE uae_u32 get_long_fpu (uaecptr addr) - { - if (currprefs.mmu_model) - return get_long_mmu (addr); - else if (currprefs.cpu_cycle_exact) - return get_long_ce020 (addr); - else - return get_long (addr); - } - STATIC_INLINE void put_word_fpu (uaecptr addr, uae_u32 v) - { - if (currprefs.mmu_model) - put_word_mmu (addr, v); - else if (currprefs.cpu_cycle_exact) - put_word_ce020 (addr, v); - else - put_word (addr, v); - } - STATIC_INLINE uae_u32 get_word_fpu (uaecptr addr) - { - if (currprefs.mmu_model) - return get_word_mmu (addr); - else if (currprefs.cpu_cycle_exact) - return get_word_ce020 (addr); - else - return get_word (addr); - } - STATIC_INLINE void put_byte_fpu (uaecptr addr, uae_u32 v) - { - if (currprefs.mmu_model) - put_byte_mmu (addr, v); - else if (currprefs.cpu_cycle_exact) - put_byte_ce020 (addr, v); - else - put_byte (addr, v); - } - STATIC_INLINE uae_u32 get_byte_fpu (uaecptr addr) - { - if (currprefs.mmu_model) - return get_byte_mmu (addr); - else if (currprefs.cpu_cycle_exact) - return get_byte_ce020 (addr); - else - return get_byte (addr); - } +STATIC_INLINE uae_u32 next_ilong_fpu (void) +{ + if (currprefs.mmu_model) + return next_ilong_mmu (); + else if (currprefs.cpu_cycle_exact) + return next_ilong_020ce (); + else + return next_ilong (); +} +STATIC_INLINE uae_u32 next_iword_fpu (void) +{ + if (currprefs.mmu_model) + return next_iword_mmu (); + else if (currprefs.cpu_cycle_exact) + return next_iword_020ce (); + else + return next_iword (); +} +STATIC_INLINE void put_long_fpu (uaecptr addr, uae_u32 v) +{ + if (currprefs.mmu_model) + put_long_mmu (addr, v); + else if (currprefs.cpu_cycle_exact) + put_long_ce020 (addr, v); + else + put_long (addr, v); +} +STATIC_INLINE uae_u32 get_long_fpu (uaecptr addr) +{ + if (currprefs.mmu_model) + return get_long_mmu (addr); + else if (currprefs.cpu_cycle_exact) + return get_long_ce020 (addr); + else + return get_long (addr); +} +STATIC_INLINE void put_word_fpu (uaecptr addr, uae_u32 v) +{ + if (currprefs.mmu_model) + put_word_mmu (addr, v); + else if (currprefs.cpu_cycle_exact) + put_word_ce020 (addr, v); + else + put_word (addr, v); +} +STATIC_INLINE uae_u32 get_word_fpu (uaecptr addr) +{ + if (currprefs.mmu_model) + return get_word_mmu (addr); + else if (currprefs.cpu_cycle_exact) + return get_word_ce020 (addr); + else + return get_word (addr); +} +STATIC_INLINE void put_byte_fpu (uaecptr addr, uae_u32 v) +{ + if (currprefs.mmu_model) + put_byte_mmu (addr, v); + else if (currprefs.cpu_cycle_exact) + put_byte_ce020 (addr, v); + else + put_byte (addr, v); +} +STATIC_INLINE uae_u32 get_byte_fpu (uaecptr addr) +{ + if (currprefs.mmu_model) + return get_byte_mmu (addr); + else if (currprefs.cpu_cycle_exact) + return get_byte_ce020 (addr); + else + return get_byte (addr); +} - static void fpu_op_illg (uae_u32 opcode, int pcoffset) - { - if ((currprefs.cpu_model == 68060 && (currprefs.fpu_model == 0 || (regs.pcr & 2))) - || (currprefs.cpu_model == 68040 && currprefs.fpu_model == 0)) { - /* 68040 unimplemented/68060 FPU disabled exception. - * Line F exception with different stack frame.. */ - uaecptr newpc = m68k_getpc (); - uaecptr oldpc = newpc - pcoffset; - regs.t0 = regs.t1 = 0; - MakeSR (); - if (!regs.s) { - regs.usp = m68k_areg (regs, 7); - m68k_areg (regs, 7) = regs.isp; - } - regs.s = 1; - m68k_areg (regs, 7) -= 4; - put_long_fpu (m68k_areg (regs, 7), oldpc); - m68k_areg (regs, 7) -= 4; - put_long_fpu (m68k_areg (regs, 7), oldpc); - m68k_areg (regs, 7) -= 2; - put_word_fpu (m68k_areg (regs, 7), 0x4000 + 11 * 4); - m68k_areg (regs, 7) -= 4; - put_long_fpu (m68k_areg (regs, 7), newpc); - m68k_areg (regs, 7) -= 2; - put_word_fpu (m68k_areg (regs, 7), regs.sr); - write_log (L"68040/060 FPU disabled exception PC=%x\n", newpc); - newpc = get_long_fpu (regs.vbr + 11 * 4); - m68k_setpc (newpc); - set_special (SPCFLAG_END_COMPILE); - return; - } - op_illg (opcode); +static void fpu_op_illg (uae_u32 opcode, int pcoffset) +{ + if ((currprefs.cpu_model == 68060 && (currprefs.fpu_model == 0 || (regs.pcr & 2))) + || (currprefs.cpu_model == 68040 && currprefs.fpu_model == 0)) { + /* 68040 unimplemented/68060 FPU disabled exception. + * Line F exception with different stack frame.. */ + uaecptr newpc = m68k_getpc (); + uaecptr oldpc = newpc - pcoffset; + regs.t0 = regs.t1 = 0; + MakeSR (); + if (!regs.s) { + regs.usp = m68k_areg (regs, 7); + m68k_areg (regs, 7) = regs.isp; + } + regs.s = 1; + m68k_areg (regs, 7) -= 4; + put_long_fpu (m68k_areg (regs, 7), oldpc); + m68k_areg (regs, 7) -= 4; + put_long_fpu (m68k_areg (regs, 7), oldpc); + m68k_areg (regs, 7) -= 2; + put_word_fpu (m68k_areg (regs, 7), 0x4000 + 11 * 4); + m68k_areg (regs, 7) -= 4; + put_long_fpu (m68k_areg (regs, 7), newpc); + m68k_areg (regs, 7) -= 2; + put_word_fpu (m68k_areg (regs, 7), regs.sr); + write_log (L"68040/060 FPU disabled exception PC=%x\n", newpc); + newpc = get_long_fpu (regs.vbr + 11 * 4); + m68k_setpc (newpc); + set_special (SPCFLAG_END_COMPILE); + return; } + op_illg (opcode); +} - STATIC_INLINE int fault_if_no_fpu (uae_u32 opcode, int pcoffset) - { - if ((regs.pcr & 2) || currprefs.fpu_model <= 0) { - fpu_op_illg (opcode, pcoffset); - return 1; - } - return 0; +STATIC_INLINE int fault_if_no_fpu (uae_u32 opcode, int pcoffset) +{ + if ((regs.pcr & 2) || currprefs.fpu_model <= 0) { + fpu_op_illg (opcode, pcoffset); + return 1; } + return 0; +} - static int get_fpu_version (void) - { - int v = 0; +static int get_fpu_version (void) +{ + int v = 0; - if (currprefs.fpu_revision >= 0) - return currprefs.fpu_revision; - switch (currprefs.fpu_model) - { - case 68881: - v = 0x1f; - break; - case 68882: - v = 0x20; /* ??? */ - break; - case 68040: - v = 0x41; - break; - } - return v; + if (currprefs.fpu_revision >= 0) + return currprefs.fpu_revision; + switch (currprefs.fpu_model) + { + case 68881: + v = 0x1f; + break; + case 68882: + v = 0x20; /* ??? */ + break; + case 68040: + v = 0x41; + break; } + return v; +} #define fp_round_to_minus_infinity(x) fp_floor(x) #define fp_round_to_plus_infinity(x) fp_ceil(x) #define fp_round_to_zero(x) ((int)(x)) #define fp_round_to_nearest(x) ((int)((x) + 0.5)) - STATIC_INLINE tointtype toint (fptype src, fptype minval, fptype maxval) - { - if (src < minval) - src = minval; - if (src > maxval) - src = maxval; +STATIC_INLINE tointtype toint (fptype src, fptype minval, fptype maxval) +{ + if (src < minval) + src = minval; + if (src > maxval) + src = maxval; #if defined(X86_MSVC_ASSEMBLY) - { - fptype tmp_fp; - __asm { - fld LDPTR src - frndint - fstp LDPTR tmp_fp - } - return (tointtype)tmp_fp; + { + fptype tmp_fp; + __asm { + fld LDPTR src + frndint + fstp LDPTR tmp_fp } + return (tointtype)tmp_fp; + } #else /* no X86_MSVC */ - switch (get_fpcr() & 0x30) { + { + int result = src; +#if 0 + switch (get_fpcr () & 0x30) { case FPCR_ROUND_ZERO: - result = fp_round_to_zero(src); + result = fp_round_to_zero (src); break; case FPCR_ROUND_MINF: - result = fp_round_to_minus_infinity(src); + result = fp_round_to_minus_infinity (src); break; case FPCR_ROUND_NEAR: - result = fp_round_to_nearest(src); + result = fp_round_to_nearest (src); break; case FPCR_ROUND_PINF: - result = fp_round_to_plus_infinity(src); + result = fp_round_to_plus_infinity (src); break; default: result = src; /* should never be reached */ break; - } - return result; #endif + return result; } +#endif +} - uae_u32 get_fpsr (void) - { - uae_u32 answer = regs.fpsr & 0x00ffffff; +uae_u32 get_fpsr (void) +{ + uae_u32 answer = regs.fpsr & 0x00ffffff; #ifdef HAVE_ISNAN - if (isnan (regs.fp_result)) - answer |= 0x01000000; - else + if (isnan (regs.fp_result)) + answer |= 0x01000000; + else #endif - { - if (regs.fp_result == 0) - answer |= 0x04000000; - else if (regs.fp_result < 0) - answer |= 0x08000000; + { + if (regs.fp_result == 0) + answer |= 0x04000000; + else if (regs.fp_result < 0) + answer |= 0x08000000; #ifdef HAVE_ISINF - if (isinf (regs.fp_result)) - answer |= 0x02000000; + if (isinf (regs.fp_result)) + answer |= 0x02000000; #endif - } - return answer; } + return answer; +} - STATIC_INLINE void set_fpsr (uae_u32 x) - { - regs.fpsr = x; +STATIC_INLINE void set_fpsr (uae_u32 x) +{ + regs.fpsr = x; - if (x & 0x01000000) { - regs.fp_result = *fp_nan; - } - else if (x & 0x04000000) - regs.fp_result = 0; - else if (x & 0x08000000) - regs.fp_result = -1; - else - regs.fp_result = 1; + if (x & 0x01000000) { + regs.fp_result = *fp_nan; } + else if (x & 0x04000000) + regs.fp_result = 0; + else if (x & 0x08000000) + regs.fp_result = -1; + else + regs.fp_result = 1; +} - /* single : S 8*E 23*F */ - /* double : S 11*E 52*F */ - /* extended : S 15*E 64*F */ - /* E = 0 & F = 0 -> 0 */ - /* E = MAX & F = 0 -> Infin */ - /* E = MAX & F # 0 -> NotANumber */ - /* E = biased by 127 (single) ,1023 (double) ,16383 (extended) */ +/* single : S 8*E 23*F */ +/* double : S 11*E 52*F */ +/* extended : S 15*E 64*F */ +/* E = 0 & F = 0 -> 0 */ +/* E = MAX & F = 0 -> Infin */ +/* E = MAX & F # 0 -> NotANumber */ +/* E = biased by 127 (single) ,1023 (double) ,16383 (extended) */ - STATIC_INLINE fptype to_pack (uae_u32 wrd1, uae_u32 wrd2, uae_u32 wrd3) - { - fptype d; - char *cp; - char str[100]; - - cp = str; - if (wrd1 & 0x80000000) - *cp++ = '-'; - *cp++ = (wrd1 & 0xf) + '0'; - *cp++ = '.'; - *cp++ = ((wrd2 >> 28) & 0xf) + '0'; - *cp++ = ((wrd2 >> 24) & 0xf) + '0'; - *cp++ = ((wrd2 >> 20) & 0xf) + '0'; - *cp++ = ((wrd2 >> 16) & 0xf) + '0'; - *cp++ = ((wrd2 >> 12) & 0xf) + '0'; - *cp++ = ((wrd2 >> 8) & 0xf) + '0'; - *cp++ = ((wrd2 >> 4) & 0xf) + '0'; - *cp++ = ((wrd2 >> 0) & 0xf) + '0'; - *cp++ = ((wrd3 >> 28) & 0xf) + '0'; - *cp++ = ((wrd3 >> 24) & 0xf) + '0'; - *cp++ = ((wrd3 >> 20) & 0xf) + '0'; - *cp++ = ((wrd3 >> 16) & 0xf) + '0'; - *cp++ = ((wrd3 >> 12) & 0xf) + '0'; - *cp++ = ((wrd3 >> 8) & 0xf) + '0'; - *cp++ = ((wrd3 >> 4) & 0xf) + '0'; - *cp++ = ((wrd3 >> 0) & 0xf) + '0'; - *cp++ = 'E'; - if (wrd1 & 0x40000000) - *cp++ = '-'; - *cp++ = ((wrd1 >> 24) & 0xf) + '0'; - *cp++ = ((wrd1 >> 20) & 0xf) + '0'; - *cp++ = ((wrd1 >> 16) & 0xf) + '0'; - *cp = 0; - sscanf (str, "%le", &d); - return d; - } +STATIC_INLINE fptype to_pack (uae_u32 wrd1, uae_u32 wrd2, uae_u32 wrd3) +{ + fptype d; + char *cp; + char str[100]; + + cp = str; + if (wrd1 & 0x80000000) + *cp++ = '-'; + *cp++ = (wrd1 & 0xf) + '0'; + *cp++ = '.'; + *cp++ = ((wrd2 >> 28) & 0xf) + '0'; + *cp++ = ((wrd2 >> 24) & 0xf) + '0'; + *cp++ = ((wrd2 >> 20) & 0xf) + '0'; + *cp++ = ((wrd2 >> 16) & 0xf) + '0'; + *cp++ = ((wrd2 >> 12) & 0xf) + '0'; + *cp++ = ((wrd2 >> 8) & 0xf) + '0'; + *cp++ = ((wrd2 >> 4) & 0xf) + '0'; + *cp++ = ((wrd2 >> 0) & 0xf) + '0'; + *cp++ = ((wrd3 >> 28) & 0xf) + '0'; + *cp++ = ((wrd3 >> 24) & 0xf) + '0'; + *cp++ = ((wrd3 >> 20) & 0xf) + '0'; + *cp++ = ((wrd3 >> 16) & 0xf) + '0'; + *cp++ = ((wrd3 >> 12) & 0xf) + '0'; + *cp++ = ((wrd3 >> 8) & 0xf) + '0'; + *cp++ = ((wrd3 >> 4) & 0xf) + '0'; + *cp++ = ((wrd3 >> 0) & 0xf) + '0'; + *cp++ = 'E'; + if (wrd1 & 0x40000000) + *cp++ = '-'; + *cp++ = ((wrd1 >> 24) & 0xf) + '0'; + *cp++ = ((wrd1 >> 20) & 0xf) + '0'; + *cp++ = ((wrd1 >> 16) & 0xf) + '0'; + *cp = 0; + sscanf (str, "%le", &d); + return d; +} - STATIC_INLINE void from_pack (fptype src, uae_u32 * wrd1, uae_u32 * wrd2, uae_u32 * wrd3) - { - int i; - int t; - char *cp; - char str[100]; - - sprintf (str, "%.16e", src); - cp = str; - *wrd1 = *wrd2 = *wrd3 = 0; +STATIC_INLINE void from_pack (fptype src, uae_u32 * wrd1, uae_u32 * wrd2, uae_u32 * wrd3) +{ + int i; + int t; + char *cp; + char str[100]; + + sprintf (str, "%.16e", src); + cp = str; + *wrd1 = *wrd2 = *wrd3 = 0; + if (*cp == '-') { + cp++; + *wrd1 = 0x80000000; + } + if (*cp == '+') + cp++; + *wrd1 |= (*cp++ - '0'); + if (*cp == '.') + cp++; + for (i = 0; i < 8; i++) { + *wrd2 <<= 4; + if (*cp >= '0' && *cp <= '9') + *wrd2 |= *cp++ - '0'; + } + for (i = 0; i < 8; i++) { + *wrd3 <<= 4; + if (*cp >= '0' && *cp <= '9') + *wrd3 |= *cp++ - '0'; + } + if (*cp == 'e' || *cp == 'E') { + cp++; if (*cp == '-') { cp++; - *wrd1 = 0x80000000; + *wrd1 |= 0x40000000; } if (*cp == '+') cp++; - *wrd1 |= (*cp++ - '0'); - if (*cp == '.') - cp++; - for (i = 0; i < 8; i++) { - *wrd2 <<= 4; + t = 0; + for (i = 0; i < 3; i++) { if (*cp >= '0' && *cp <= '9') - *wrd2 |= *cp++ - '0'; - } - for (i = 0; i < 8; i++) { - *wrd3 <<= 4; - if (*cp >= '0' && *cp <= '9') - *wrd3 |= *cp++ - '0'; - } - if (*cp == 'e' || *cp == 'E') { - cp++; - if (*cp == '-') { - cp++; - *wrd1 |= 0x40000000; - } - if (*cp == '+') - cp++; - t = 0; - for (i = 0; i < 3; i++) { - if (*cp >= '0' && *cp <= '9') - t = (t << 4) | (*cp++ - '0'); - } - *wrd1 |= t << 16; + t = (t << 4) | (*cp++ - '0'); } + *wrd1 |= t << 16; } +} - STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src) - { - uaecptr tmppc; - uae_u16 tmp; - int size, mode, reg; - uae_u32 ad = 0; - static const int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 }; - static const int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 }; - - if (!(extra & 0x4000)) { - *src = regs.fp[(extra >> 10) & 7]; - return 1; - } - mode = (opcode >> 3) & 7; - reg = opcode & 7; - size = (extra >> 10) & 7; +STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src) +{ + uaecptr tmppc; + uae_u16 tmp; + int size, mode, reg; + uae_u32 ad = 0; + static const int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 }; + static const int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 }; + + if (!(extra & 0x4000)) { + *src = regs.fp[(extra >> 10) & 7]; + return 1; + } + mode = (opcode >> 3) & 7; + reg = opcode & 7; + size = (extra >> 10) & 7; - switch (mode) { + switch (mode) { case 0: switch (size) { - case 6: - *src = (fptype) (uae_s8) m68k_dreg (regs, reg); - break; - case 4: - *src = (fptype) (uae_s16) m68k_dreg (regs, reg); - break; - case 0: - *src = (fptype) (uae_s32) m68k_dreg (regs, reg); - break; - case 1: - *src = to_single (m68k_dreg (regs, reg)); - break; - default: - return 0; + case 6: + *src = (fptype) (uae_s8) m68k_dreg (regs, reg); + break; + case 4: + *src = (fptype) (uae_s16) m68k_dreg (regs, reg); + break; + case 0: + *src = (fptype) (uae_s32) m68k_dreg (regs, reg); + break; + case 1: + *src = to_single (m68k_dreg (regs, reg)); + break; + default: + return 0; } return 1; case 1: @@ -505,32 +510,32 @@ static uae_u16 x87_cw_tab[] = { break; case 7: switch (reg) { - case 0: - ad = (uae_s32) (uae_s16) next_iword_fpu (); - break; - case 1: - ad = next_ilong_fpu (); - break; - case 2: - ad = m68k_getpc (); - ad += (uae_s32) (uae_s16) next_iword_fpu (); - break; - case 3: - tmppc = m68k_getpc (); - tmp = next_iword_fpu (); - ad = get_disp_ea_020 (tmppc, tmp); - break; - case 4: - ad = m68k_getpc (); - m68k_setpc (ad + sz2[size]); - if (size == 6) - ad++; - break; - default: - return 0; + case 0: + ad = (uae_s32) (uae_s16) next_iword_fpu (); + break; + case 1: + ad = next_ilong_fpu (); + break; + case 2: + ad = m68k_getpc (); + ad += (uae_s32) (uae_s16) next_iword_fpu (); + break; + case 3: + tmppc = m68k_getpc (); + tmp = next_iword_fpu (); + ad = get_disp_ea_020 (tmppc, tmp); + break; + case 4: + ad = m68k_getpc (); + m68k_setpc (ad + sz2[size]); + if (size == 6) + ad++; + break; + default: + return 0; } - } - switch (size) { + } + switch (size) { case 0: *src = (fptype) (uae_s32) get_long_fpu (ad); break; @@ -573,50 +578,50 @@ static uae_u16 x87_cw_tab[] = { break; default: return 0; - } - return 1; } + return 1; +} - STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra) - { - uae_u16 tmp; - uaecptr tmppc; - int size, mode, reg; - uae_u32 ad; - static int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 }; - static int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 }; +STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra) +{ + uae_u16 tmp; + uaecptr tmppc; + int size, mode, reg; + uae_u32 ad; + static int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 }; + static int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 }; #if DEBUG_FPP - if (!isinrom ()) - write_log (L"PUTFP: %f %04X %04X\n", value, opcode, extra); + if (!isinrom ()) + write_log (L"PUTFP: %f %04X %04X\n", value, opcode, extra); #endif - if (!(extra & 0x4000)) { - regs.fp[(extra >> 10) & 7] = value; - return 1; - } - reg = opcode & 7; - mode = (opcode >> 3) & 7; - size = (extra >> 10) & 7; - ad = -1; - switch (mode) { + if (!(extra & 0x4000)) { + regs.fp[(extra >> 10) & 7] = value; + return 1; + } + reg = opcode & 7; + mode = (opcode >> 3) & 7; + size = (extra >> 10) & 7; + ad = -1; + switch (mode) { case 0: switch (size) { - case 6: - m68k_dreg (regs, reg) = (uae_u32)(((toint (value, -128.0, 127.0) & 0xff) - | (m68k_dreg (regs, reg) & ~0xff))); - break; - case 4: - m68k_dreg (regs, reg) = (uae_u32)(((toint (value, -32768.0, 32767.0) & 0xffff) - | (m68k_dreg (regs, reg) & ~0xffff))); - break; - case 0: - m68k_dreg (regs, reg) = (uae_u32)toint (value, -2147483648.0, 2147483647.0); - break; - case 1: - m68k_dreg (regs, reg) = from_single (value); - break; - default: - return 0; + case 6: + m68k_dreg (regs, reg) = (uae_u32)(((toint (value, -128.0, 127.0) & 0xff) + | (m68k_dreg (regs, reg) & ~0xff))); + break; + case 4: + m68k_dreg (regs, reg) = (uae_u32)(((toint (value, -32768.0, 32767.0) & 0xffff) + | (m68k_dreg (regs, reg) & ~0xffff))); + break; + case 0: + m68k_dreg (regs, reg) = (uae_u32)toint (value, -2147483648.0, 2147483647.0); + break; + case 1: + m68k_dreg (regs, reg) = from_single (value); + break; + default: + return 0; } return 1; case 1: @@ -640,30 +645,30 @@ static uae_u16 x87_cw_tab[] = { break; case 7: switch (reg) { - case 0: - ad = (uae_s32) (uae_s16) next_iword_fpu (); - break; - case 1: - ad = next_ilong_fpu (); - break; - case 2: - ad = m68k_getpc (); - ad += (uae_s32) (uae_s16) next_iword_fpu (); - break; - case 3: - tmppc = m68k_getpc (); - tmp = next_iword_fpu (); - ad = get_disp_ea_020 (tmppc, tmp); - break; - case 4: - ad = m68k_getpc (); - m68k_setpc (ad + sz2[size]); - break; - default: - return 0; + case 0: + ad = (uae_s32) (uae_s16) next_iword_fpu (); + break; + case 1: + ad = next_ilong_fpu (); + break; + case 2: + ad = m68k_getpc (); + ad += (uae_s32) (uae_s16) next_iword_fpu (); + break; + case 3: + tmppc = m68k_getpc (); + tmp = next_iword_fpu (); + ad = get_disp_ea_020 (tmppc, tmp); + break; + case 4: + ad = m68k_getpc (); + m68k_setpc (ad + sz2[size]); + break; + default: + return 0; } - } - switch (size) { + } + switch (size) { case 0: put_long_fpu (ad, (uae_u32)toint (value, -2147483648.0, 2147483647.0)); break; @@ -708,20 +713,20 @@ static uae_u16 x87_cw_tab[] = { break; default: return 0; - } - return 1; } + return 1; +} - STATIC_INLINE int get_fp_ad (uae_u32 opcode, uae_u32 * ad) - { - uae_u16 tmp; - uaecptr tmppc; - int mode; - int reg; - - mode = (opcode >> 3) & 7; - reg = opcode & 7; - switch (mode) { +STATIC_INLINE int get_fp_ad (uae_u32 opcode, uae_u32 * ad) +{ + uae_u16 tmp; + uaecptr tmppc; + int mode; + int reg; + + mode = (opcode >> 3) & 7; + reg = opcode & 7; + switch (mode) { case 0: case 1: return 0; @@ -742,42 +747,42 @@ static uae_u16 x87_cw_tab[] = { break; case 7: switch (reg) { - case 0: - *ad = (uae_s32) (uae_s16) next_iword_fpu (); - break; - case 1: - *ad = next_ilong_fpu (); - break; - case 2: - *ad = m68k_getpc (); - *ad += (uae_s32) (uae_s16) next_iword_fpu (); - break; - case 3: - tmppc = m68k_getpc (); - tmp = next_iword_fpu (); - *ad = get_disp_ea_020 (tmppc, tmp); - break; - default: - return 0; + case 0: + *ad = (uae_s32) (uae_s16) next_iword_fpu (); + break; + case 1: + *ad = next_ilong_fpu (); + break; + case 2: + *ad = m68k_getpc (); + *ad += (uae_s32) (uae_s16) next_iword_fpu (); + break; + case 3: + tmppc = m68k_getpc (); + tmp = next_iword_fpu (); + *ad = get_disp_ea_020 (tmppc, tmp); + break; + default: + return 0; } - } - return 1; } + return 1; +} - STATIC_INLINE int fpp_cond (int condition) - { - int N = (regs.fp_result < 0.0); - int Z = (regs.fp_result == 0.0); - int NotANumber = 0; +STATIC_INLINE int fpp_cond (int condition) +{ + int N = (regs.fp_result < 0.0); + int Z = (regs.fp_result == 0.0); + int NotANumber = 0; #ifdef HAVE_ISNAN - NotANumber = isnan (regs.fp_result); + NotANumber = isnan (regs.fp_result); #endif - if (NotANumber) - N=Z=0; + if (NotANumber) + N=Z=0; - switch (condition) { + switch (condition) { case 0x00: return 0; case 0x01: @@ -842,281 +847,281 @@ static uae_u16 x87_cw_tab[] = { return !Z; case 0x1f: return 1; - } - return -1; } + return -1; +} - void fpuop_dbcc (uae_u32 opcode, uae_u16 extra) - { - uaecptr pc = (uae_u32) m68k_getpc (); - uae_s32 disp; - int cc; +void fpuop_dbcc (uae_u32 opcode, uae_u16 extra) +{ + uaecptr pc = (uae_u32) m68k_getpc (); + uae_s32 disp; + int cc; #if DEBUG_FPP - if (!isinrom ()) - write_log (L"fdbcc_opp at %08lx\n", m68k_getpc ()); + if (!isinrom ()) + write_log (L"fdbcc_opp at %08lx\n", m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, 4)) - return; - - disp = (uae_s32) (uae_s16) next_iword_fpu (); - cc = fpp_cond (extra & 0x3f); - if (cc == -1) { - fpu_op_illg (opcode, 4); - } else if (!cc) { - int reg = opcode & 0x7; - - m68k_dreg (regs, reg) = ((m68k_dreg (regs, reg) & 0xffff0000) - | (((m68k_dreg (regs, reg) & 0xffff) - 1) & 0xffff)); - if ((m68k_dreg (regs, reg) & 0xffff) != 0xffff) - m68k_setpc (pc + disp); - } + if (fault_if_no_fpu (opcode, 4)) + return; + + disp = (uae_s32) (uae_s16) next_iword_fpu (); + cc = fpp_cond (extra & 0x3f); + if (cc == -1) { + fpu_op_illg (opcode, 4); + } else if (!cc) { + int reg = opcode & 0x7; + + m68k_dreg (regs, reg) = ((m68k_dreg (regs, reg) & 0xffff0000) + | (((m68k_dreg (regs, reg) & 0xffff) - 1) & 0xffff)); + if ((m68k_dreg (regs, reg) & 0xffff) != 0xffff) + m68k_setpc (pc + disp); } +} - void fpuop_scc (uae_u32 opcode, uae_u16 extra) - { - uae_u32 ad; - int cc; +void fpuop_scc (uae_u32 opcode, uae_u16 extra) +{ + uae_u32 ad; + int cc; #if DEBUG_FPP - if (!isinrom ()) - write_log (L"fscc_opp at %08lx\n", m68k_getpc ()); + if (!isinrom ()) + write_log (L"fscc_opp at %08lx\n", m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, 4)) - return; - - cc = fpp_cond (extra & 0x3f); - if (cc == -1) { - fpu_op_illg (opcode, 4); - } else if ((opcode & 0x38) == 0) { - m68k_dreg (regs, opcode & 7) = (m68k_dreg (regs, opcode & 7) & ~0xff) | (cc ? 0xff : 0x00); - } else { - if (get_fp_ad (opcode, &ad) == 0) { - m68k_setpc (m68k_getpc () - 4); - op_illg (opcode); - } else - put_byte_fpu (ad, cc ? 0xff : 0x00); - } + if (fault_if_no_fpu (opcode, 4)) + return; + + cc = fpp_cond (extra & 0x3f); + if (cc == -1) { + fpu_op_illg (opcode, 4); + } else if ((opcode & 0x38) == 0) { + m68k_dreg (regs, opcode & 7) = (m68k_dreg (regs, opcode & 7) & ~0xff) | (cc ? 0xff : 0x00); + } else { + if (get_fp_ad (opcode, &ad) == 0) { + m68k_setpc (m68k_getpc () - 4); + op_illg (opcode); + } else + put_byte_fpu (ad, cc ? 0xff : 0x00); } +} - void fpuop_trapcc (uae_u32 opcode, uaecptr oldpc, uae_u16 extra) - { - int cc; +void fpuop_trapcc (uae_u32 opcode, uaecptr oldpc, uae_u16 extra) +{ + int cc; #if DEBUG_FPP - if (!isinrom ()) - write_log (L"ftrapcc_opp at %08lx\n", m68k_getpc ()); + if (!isinrom ()) + write_log (L"ftrapcc_opp at %08lx\n", m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, m68k_getpc() - oldpc)) - return; + if (fault_if_no_fpu (opcode, m68k_getpc() - oldpc)) + return; - cc = fpp_cond (extra & 0x3f); - if (cc == -1) { - fpu_op_illg (opcode, m68k_getpc () - oldpc); - } - if (cc) - Exception (7, oldpc - 2); + cc = fpp_cond (extra & 0x3f); + if (cc == -1) { + fpu_op_illg (opcode, m68k_getpc () - oldpc); } + if (cc) + Exception (7, oldpc - 2); +} - void fpuop_bcc (uae_u32 opcode, uaecptr pc, uae_u32 extra) - { - int cc; +void fpuop_bcc (uae_u32 opcode, uaecptr pc, uae_u32 extra) +{ + int cc; #if DEBUG_FPP - if (!isinrom ()) - write_log (L"fbcc_opp at %08lx\n", m68k_getpc ()); + if (!isinrom ()) + write_log (L"fbcc_opp at %08lx\n", m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, m68k_getpc () - pc)) - return; - - cc = fpp_cond (opcode & 0x3f); - if (cc == -1) { - fpu_op_illg (opcode, m68k_getpc () - pc); - } else if (cc) { - if ((opcode & 0x40) == 0) - extra = (uae_s32) (uae_s16) extra; - m68k_setpc (pc + extra); - } + if (fault_if_no_fpu (opcode, m68k_getpc () - pc)) + return; + + cc = fpp_cond (opcode & 0x3f); + if (cc == -1) { + fpu_op_illg (opcode, m68k_getpc () - pc); + } else if (cc) { + if ((opcode & 0x40) == 0) + extra = (uae_s32) (uae_s16) extra; + m68k_setpc (pc + extra); } +} - void fpuop_save (uae_u32 opcode) - { - uae_u32 ad; - int incr = (opcode & 0x38) == 0x20 ? -1 : 1; - int fpu_version = get_fpu_version(); - int i; +void fpuop_save (uae_u32 opcode) +{ + uae_u32 ad; + int incr = (opcode & 0x38) == 0x20 ? -1 : 1; + int fpu_version = get_fpu_version(); + int i; #if DEBUG_FPP - if (!isinrom ()) - write_log (L"fsave_opp at %08lx\n", m68k_getpc ()); + if (!isinrom ()) + write_log (L"fsave_opp at %08lx\n", m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, 2)) - return; + if (fault_if_no_fpu (opcode, 2)) + return; - if (get_fp_ad (opcode, &ad) == 0) { - fpu_op_illg (opcode, 2); - return; - } + if (get_fp_ad (opcode, &ad) == 0) { + fpu_op_illg (opcode, 2); + return; + } - if (currprefs.fpu_model == 68060) { - /* 12 byte 68060 IDLE frame. */ - if (incr < 0) { - ad -= 4; - put_long_fpu (ad, 0x00000000); - ad -= 4; - put_long_fpu (ad, 0x00000000); + if (currprefs.fpu_model == 68060) { + /* 12 byte 68060 IDLE frame. */ + if (incr < 0) { + ad -= 4; + put_long_fpu (ad, 0x00000000); + ad -= 4; + put_long_fpu (ad, 0x00000000); + ad -= 4; + put_long_fpu (ad, 0x00006000); + } else { + put_long_fpu (ad, 0x00006000); + ad += 4; + put_long_fpu (ad, 0x00000000); + ad += 4; + put_long_fpu (ad, 0x00000000); + ad += 4; + } + } else if (currprefs.fpu_model == 68040) { + /* 4 byte 68040 IDLE frame. */ + if (incr < 0) { + ad -= 4; + put_long_fpu (ad, fpu_version << 24); + } else { + put_long_fpu (ad, fpu_version << 24); + ad += 4; + } + } else { /* 68881/68882 */ + int idle_size = currprefs.fpu_model == 68882 ? 0x38 : 0x18; + if (incr < 0) { + ad -= 4; + put_long_fpu (ad, 0x70000000); + for (i = 0; i < (idle_size - 1) / 4; i++) { ad -= 4; - put_long_fpu (ad, 0x00006000); - } else { - put_long_fpu (ad, 0x00006000); - ad += 4; put_long_fpu (ad, 0x00000000); - ad += 4; - put_long_fpu (ad, 0x00000000); - ad += 4; - } - } else if (currprefs.fpu_model == 68040) { - /* 4 byte 68040 IDLE frame. */ - if (incr < 0) { - ad -= 4; - put_long_fpu (ad, fpu_version << 24); - } else { - put_long_fpu (ad, fpu_version << 24); - ad += 4; } - } else { /* 68881/68882 */ - int idle_size = currprefs.fpu_model == 68882 ? 0x38 : 0x18; - if (incr < 0) { - ad -= 4; - put_long_fpu (ad, 0x70000000); - for (i = 0; i < (idle_size - 1) / 4; i++) { - ad -= 4; - put_long_fpu (ad, 0x00000000); - } - ad -= 4; - put_long_fpu (ad, (fpu_version << 24) | (idle_size << 16)); - } else { - put_long_fpu (ad, (fpu_version << 24) | (idle_size << 16)); - ad += 4; - for (i = 0; i < (idle_size - 1) / 4; i++) { - put_long_fpu (ad, 0x00000000); - ad += 4; - } - put_long_fpu (ad, 0x70000000); + ad -= 4; + put_long_fpu (ad, (fpu_version << 24) | (idle_size << 16)); + } else { + put_long_fpu (ad, (fpu_version << 24) | (idle_size << 16)); + ad += 4; + for (i = 0; i < (idle_size - 1) / 4; i++) { + put_long_fpu (ad, 0x00000000); ad += 4; } + put_long_fpu (ad, 0x70000000); + ad += 4; } - if ((opcode & 0x38) == 0x18) - m68k_areg (regs, opcode & 7) = ad; - if ((opcode & 0x38) == 0x20) - m68k_areg (regs, opcode & 7) = ad; } + if ((opcode & 0x38) == 0x18) + m68k_areg (regs, opcode & 7) = ad; + if ((opcode & 0x38) == 0x20) + m68k_areg (regs, opcode & 7) = ad; +} - void fpuop_restore (uae_u32 opcode) - { - uae_u32 ad; - uae_u32 d; - int incr = (opcode & 0x38) == 0x20 ? -1 : 1; +void fpuop_restore (uae_u32 opcode) +{ + uae_u32 ad; + uae_u32 d; + int incr = (opcode & 0x38) == 0x20 ? -1 : 1; #if DEBUG_FPP - if (!isinrom ()) - write_log (L"frestore_opp at %08lx\n", m68k_getpc ()); + if (!isinrom ()) + write_log (L"frestore_opp at %08lx\n", m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, 2)) - return; + if (fault_if_no_fpu (opcode, 2)) + return; - if (get_fp_ad (opcode, &ad) == 0) { - fpu_op_illg (opcode, 2); - return; - } + if (get_fp_ad (opcode, &ad) == 0) { + fpu_op_illg (opcode, 2); + return; + } - if (currprefs.fpu_model == 68060) { - /* all 68060 FPU frames are 12 bytes */ - if (incr < 0) { - ad -= 4; - d = get_long_fpu (ad); - ad -= 8; - } else { - d = get_long_fpu (ad); - ad += 4; - ad += 8; - } + if (currprefs.fpu_model == 68060) { + /* all 68060 FPU frames are 12 bytes */ + if (incr < 0) { + ad -= 4; + d = get_long_fpu (ad); + ad -= 8; + } else { + d = get_long_fpu (ad); + ad += 4; + ad += 8; + } - } else if (currprefs.fpu_model == 68040) { - /* 68040 */ - if (incr < 0) { - /* @@@ This may be wrong. */ - ad -= 4; - d = get_long_fpu (ad); - if ((d & 0xff000000) != 0) { /* Not a NULL frame? */ - if ((d & 0x00ff0000) == 0) { /* IDLE */ - } else if ((d & 0x00ff0000) == 0x00300000) { /* UNIMP */ - ad -= 44; - } else if ((d & 0x00ff0000) == 0x00600000) { /* BUSY */ - ad -= 92; - } - } - } else { - d = get_long_fpu (ad); - ad += 4; - if ((d & 0xff000000) != 0) { /* Not a NULL frame? */ - if ((d & 0x00ff0000) == 0) { /* IDLE */ - } else if ((d & 0x00ff0000) == 0x00300000) { /* UNIMP */ - ad += 44; - } else if ((d & 0x00ff0000) == 0x00600000) { /* BUSY */ - ad += 92; - } + } else if (currprefs.fpu_model == 68040) { + /* 68040 */ + if (incr < 0) { + /* @@@ This may be wrong. */ + ad -= 4; + d = get_long_fpu (ad); + if ((d & 0xff000000) != 0) { /* Not a NULL frame? */ + if ((d & 0x00ff0000) == 0) { /* IDLE */ + } else if ((d & 0x00ff0000) == 0x00300000) { /* UNIMP */ + ad -= 44; + } else if ((d & 0x00ff0000) == 0x00600000) { /* BUSY */ + ad -= 92; } } - } else { /* 68881/68882 */ - if (incr < 0) { - ad -= 4; - d = get_long_fpu (ad); - if ((d & 0xff000000) != 0) { - if ((d & 0x00ff0000) == 0x00180000) - ad -= 6 * 4; - else if ((d & 0x00ff0000) == 0x00380000) - ad -= 14 * 4; - else if ((d & 0x00ff0000) == 0x00b40000) - ad -= 45 * 4; - } - } else { - d = get_long_fpu (ad); - ad += 4; - if ((d & 0xff000000) != 0) { - if ((d & 0x00ff0000) == 0x00180000) - ad += 6 * 4; - else if ((d & 0x00ff0000) == 0x00380000) - ad += 14 * 4; - else if ((d & 0x00ff0000) == 0x00b40000) - ad += 45 * 4; + } else { + d = get_long_fpu (ad); + ad += 4; + if ((d & 0xff000000) != 0) { /* Not a NULL frame? */ + if ((d & 0x00ff0000) == 0) { /* IDLE */ + } else if ((d & 0x00ff0000) == 0x00300000) { /* UNIMP */ + ad += 44; + } else if ((d & 0x00ff0000) == 0x00600000) { /* BUSY */ + ad += 92; } } } - if ((opcode & 0x38) == 0x18) - m68k_areg (regs, opcode & 7) = ad; - if ((opcode & 0x38) == 0x20) - m68k_areg (regs, opcode & 7) = ad; + } else { /* 68881/68882 */ + if (incr < 0) { + ad -= 4; + d = get_long_fpu (ad); + if ((d & 0xff000000) != 0) { + if ((d & 0x00ff0000) == 0x00180000) + ad -= 6 * 4; + else if ((d & 0x00ff0000) == 0x00380000) + ad -= 14 * 4; + else if ((d & 0x00ff0000) == 0x00b40000) + ad -= 45 * 4; + } + } else { + d = get_long_fpu (ad); + ad += 4; + if ((d & 0xff000000) != 0) { + if ((d & 0x00ff0000) == 0x00180000) + ad += 6 * 4; + else if ((d & 0x00ff0000) == 0x00380000) + ad += 14 * 4; + else if ((d & 0x00ff0000) == 0x00b40000) + ad += 45 * 4; + } + } } + if ((opcode & 0x38) == 0x18) + m68k_areg (regs, opcode & 7) = ad; + if ((opcode & 0x38) == 0x20) + m68k_areg (regs, opcode & 7) = ad; +} - static void fround (int reg) - { - regs.fp[reg] = (float)regs.fp[reg]; - } +static void fround (int reg) +{ + regs.fp[reg] = (float)regs.fp[reg]; +} - void fpuop_arithmetic (uae_u32 opcode, uae_u16 extra) - { - int reg; - fptype src; +void fpuop_arithmetic (uae_u32 opcode, uae_u16 extra) +{ + int reg; + fptype src; #if DEBUG_FPP - if (!isinrom ()) - write_log (L"FPP %04lx %04x at %08lx\n", opcode & 0xffff, extra, m68k_getpc () - 4); + if (!isinrom ()) + write_log (L"FPP %04lx %04x at %08lx\n", opcode & 0xffff, extra, m68k_getpc () - 4); #endif - if (fault_if_no_fpu (opcode, 4)) - return; + if (fault_if_no_fpu (opcode, 4)) + return; - switch ((extra >> 13) & 0x7) { + switch ((extra >> 13) & 0x7) { case 3: if (put_fp_value (regs.fp[(extra >> 7) & 7], opcode, extra) == 0) { @@ -1262,22 +1267,22 @@ static uae_u16 x87_cw_tab[] = { return; } switch ((extra >> 11) & 3) { - case 0: /* static pred */ - list = extra & 0xff; - incr = -1; - break; - case 1: /* dynamic pred */ - list = m68k_dreg (regs, (extra >> 4) & 3) & 0xff; - incr = -1; - break; - case 2: /* static postinc */ - list = extra & 0xff; - incr = 1; - break; - case 3: /* dynamic postinc */ - list = m68k_dreg (regs, (extra >> 4) & 3) & 0xff; - incr = 1; - break; + case 0: /* static pred */ + list = extra & 0xff; + incr = -1; + break; + case 1: /* dynamic pred */ + list = m68k_dreg (regs, (extra >> 4) & 3) & 0xff; + incr = -1; + break; + case 2: /* static postinc */ + list = extra & 0xff; + incr = 1; + break; + case 3: /* dynamic postinc */ + list = m68k_dreg (regs, (extra >> 4) & 3) & 0xff; + incr = 1; + break; } if (incr < 0) { for (reg = 7; reg >= 0; reg--) { @@ -1320,22 +1325,22 @@ static uae_u16 x87_cw_tab[] = { return; } switch ((extra >> 11) & 3) { - case 0: /* static pred */ - list = extra & 0xff; - incr = -1; - break; - case 1: /* dynamic pred */ - list = m68k_dreg (regs, (extra >> 4) & 3) & 0xff; - incr = -1; - break; - case 2: /* static postinc */ - list = extra & 0xff; - incr = 1; - break; - case 3: /* dynamic postinc */ - list = m68k_dreg (regs, (extra >> 4) & 3) & 0xff; - incr = 1; - break; + case 0: /* static pred */ + list = extra & 0xff; + incr = -1; + break; + case 1: /* dynamic pred */ + list = m68k_dreg (regs, (extra >> 4) & 3) & 0xff; + incr = -1; + break; + case 2: /* static postinc */ + list = extra & 0xff; + incr = 1; + break; + case 3: /* dynamic postinc */ + list = m68k_dreg (regs, (extra >> 4) & 3) & 0xff; + incr = 1; + break; } if (incr < 0) { for (reg = 7; reg >= 0; reg--) { @@ -1379,76 +1384,76 @@ static uae_u16 x87_cw_tab[] = { reg = (extra >> 7) & 7; if ((extra & 0xfc00) == 0x5c00) { switch (extra & 0x7f) { - case 0x00: - regs.fp[reg] = *fp_pi; - break; - case 0x0b: - regs.fp[reg] = *fp_l10_2; - break; - case 0x0c: - regs.fp[reg] = *fp_exp_1; - break; - case 0x0d: - regs.fp[reg] = *fp_l2_e; - break; - case 0x0e: - regs.fp[reg] = *fp_l10_e; - break; - case 0x0f: - regs.fp[reg] = 0.0; - break; - case 0x30: - regs.fp[reg] = *fp_ln_2; - break; - case 0x31: - regs.fp[reg] = *fp_ln_10; - break; - case 0x32: - regs.fp[reg] = (fptype)fp_1e0; - break; - case 0x33: - regs.fp[reg] = (fptype)fp_1e1; - break; - case 0x34: - regs.fp[reg] = (fptype)fp_1e2; - break; - case 0x35: - regs.fp[reg] = (fptype)fp_1e4; - break; - case 0x36: - regs.fp[reg] = (fptype)fp_1e8; - break; - case 0x37: - regs.fp[reg] = *fp_1e16; - break; - case 0x38: - regs.fp[reg] = *fp_1e32; - break; - case 0x39: - regs.fp[reg] = *fp_1e64; - break; - case 0x3a: - regs.fp[reg] = *fp_1e128; - break; - case 0x3b: - regs.fp[reg] = *fp_1e256; - break; - case 0x3c: - regs.fp[reg] = *fp_1e512; - break; - case 0x3d: - regs.fp[reg] = *fp_1e1024; - break; - case 0x3e: - regs.fp[reg] = *fp_1e2048; - break; - case 0x3f: - regs.fp[reg] = *fp_1e4096; - break; - default: - m68k_setpc (m68k_getpc () - 4); - op_illg (opcode); - return; + case 0x00: + regs.fp[reg] = *fp_pi; + break; + case 0x0b: + regs.fp[reg] = *fp_l10_2; + break; + case 0x0c: + regs.fp[reg] = *fp_exp_1; + break; + case 0x0d: + regs.fp[reg] = *fp_l2_e; + break; + case 0x0e: + regs.fp[reg] = *fp_l10_e; + break; + case 0x0f: + regs.fp[reg] = 0.0; + break; + case 0x30: + regs.fp[reg] = *fp_ln_2; + break; + case 0x31: + regs.fp[reg] = *fp_ln_10; + break; + case 0x32: + regs.fp[reg] = (fptype)fp_1e0; + break; + case 0x33: + regs.fp[reg] = (fptype)fp_1e1; + break; + case 0x34: + regs.fp[reg] = (fptype)fp_1e2; + break; + case 0x35: + regs.fp[reg] = (fptype)fp_1e4; + break; + case 0x36: + regs.fp[reg] = (fptype)fp_1e8; + break; + case 0x37: + regs.fp[reg] = *fp_1e16; + break; + case 0x38: + regs.fp[reg] = *fp_1e32; + break; + case 0x39: + regs.fp[reg] = *fp_1e64; + break; + case 0x3a: + regs.fp[reg] = *fp_1e128; + break; + case 0x3b: + regs.fp[reg] = *fp_1e256; + break; + case 0x3c: + regs.fp[reg] = *fp_1e512; + break; + case 0x3d: + regs.fp[reg] = *fp_1e1024; + break; + case 0x3e: + regs.fp[reg] = *fp_1e2048; + break; + case 0x3f: + regs.fp[reg] = *fp_1e4096; + break; + default: + m68k_setpc (m68k_getpc () - 4); + op_illg (opcode); + return; } MAKE_FPSR (regs.fp[reg]); return; @@ -1461,299 +1466,299 @@ static uae_u16 x87_cw_tab[] = { switch (extra & 0x7f) { - case 0x00: /* FMOVE */ - case 0x40: /* Explicit rounding. This is just a quick fix. */ - case 0x44: /* Same for all other cases that have three choices */ - regs.fp[reg] = src; /* Brian King was here. */ - /* to register needs FPSR updated. See Motorola 68K Manual. */ - if ((extra & 0x44) == 0x40) - fround (reg); - break; - case 0x01: /* FINT */ - /* need to take the current rounding mode into account */ + case 0x00: /* FMOVE */ + case 0x40: /* Explicit rounding. This is just a quick fix. */ + case 0x44: /* Same for all other cases that have three choices */ + regs.fp[reg] = src; /* Brian King was here. */ + /* to register needs FPSR updated. See Motorola 68K Manual. */ + if ((extra & 0x44) == 0x40) + fround (reg); + break; + case 0x01: /* FINT */ + /* need to take the current rounding mode into account */ #if defined(X86_MSVC_ASSEMBLY) - { - fptype tmp_fp; + { + fptype tmp_fp; - __asm { - fld LDPTR src - frndint - fstp LDPTR tmp_fp - } - regs.fp[reg] = tmp_fp; + __asm { + fld LDPTR src + frndint + fstp LDPTR tmp_fp } + regs.fp[reg] = tmp_fp; + } #else /* no X86_MSVC */ - switch ((regs.fpcr >> 4) & 3) { - case 0: /* to nearest */ - regs.fp[reg] = floor (src + 0.5); - break; - case 1: /* to zero */ - if (src >= 0.0) - regs.fp[reg] = floor (src); - else - regs.fp[reg] = ceil (src); - break; - case 2: /* down */ - regs.fp[reg] = floor (src); - break; - case 3: /* up */ - regs.fp[reg] = ceil (src); - break; - default: /* never reached */ - regs.fp[reg] = src; - } + switch ((regs.fpcr >> 4) & 3) { + case 0: /* to nearest */ + regs.fp[reg] = floor (src + 0.5); + break; + case 1: /* to zero */ + if (src >= 0.0) + regs.fp[reg] = floor (src); + else + regs.fp[reg] = ceil (src); + break; + case 2: /* down */ + regs.fp[reg] = floor (src); + break; + case 3: /* up */ + regs.fp[reg] = ceil (src); + break; + default: /* never reached */ + regs.fp[reg] = src; + } #endif /* X86_MSVC */ - break; - case 0x02: /* FSINH */ - regs.fp[reg] = sinh (src); - break; - case 0x03: /* FINTRZ */ - regs.fp[reg] = fp_round_to_zero(src); - break; - case 0x04: /* FSQRT */ - case 0x41: - case 0x45: - regs.fp[reg] = sqrt (src); - if ((extra & 0x44) == 0x40) - fround (reg); - break; - case 0x06: /* FLOGNP1 */ - regs.fp[reg] = log (src + 1.0); - break; - case 0x08: /* FETOXM1 */ - regs.fp[reg] = exp (src) - 1.0; - break; - case 0x09: /* FTANH */ - regs.fp[reg] = tanh (src); - break; - case 0x0a: /* FATAN */ - regs.fp[reg] = atan (src); - break; - case 0x0c: /* FASIN */ - regs.fp[reg] = asin (src); - break; - case 0x0d: /* FATANH */ + break; + case 0x02: /* FSINH */ + regs.fp[reg] = sinh (src); + break; + case 0x03: /* FINTRZ */ + regs.fp[reg] = fp_round_to_zero(src); + break; + case 0x04: /* FSQRT */ + case 0x41: + case 0x45: + regs.fp[reg] = sqrt (src); + if ((extra & 0x44) == 0x40) + fround (reg); + break; + case 0x06: /* FLOGNP1 */ + regs.fp[reg] = log (src + 1.0); + break; + case 0x08: /* FETOXM1 */ + regs.fp[reg] = exp (src) - 1.0; + break; + case 0x09: /* FTANH */ + regs.fp[reg] = tanh (src); + break; + case 0x0a: /* FATAN */ + regs.fp[reg] = atan (src); + break; + case 0x0c: /* FASIN */ + regs.fp[reg] = asin (src); + break; + case 0x0d: /* FATANH */ #if 1 /* The BeBox doesn't have atanh, and it isn't in the HPUX libm either */ - regs.fp[reg] = 0.5 * log ((1 + src) / (1 - src)); + regs.fp[reg] = 0.5 * log ((1 + src) / (1 - src)); #else - regs.fp[reg] = atanh (src); + regs.fp[reg] = atanh (src); #endif - break; - case 0x0e: /* FSIN */ - regs.fp[reg] = sin (src); - break; - case 0x0f: /* FTAN */ - regs.fp[reg] = tan (src); - break; - case 0x10: /* FETOX */ - regs.fp[reg] = exp (src); - break; - case 0x11: /* FTWOTOX */ - regs.fp[reg] = pow (2.0, src); - break; - case 0x12: /* FTENTOX */ - regs.fp[reg] = pow (10.0, src); - break; - case 0x14: /* FLOGN */ - regs.fp[reg] = log (src); - break; - case 0x15: /* FLOG10 */ - regs.fp[reg] = log10 (src); - break; - case 0x16: /* FLOG2 */ - regs.fp[reg] = *fp_l2_e * log (src); - break; - case 0x18: /* FABS */ - case 0x58: - case 0x5c: - regs.fp[reg] = src < 0 ? -src : src; - if ((extra & 0x44) == 0x40) - fround (reg); - break; - case 0x19: /* FCOSH */ - regs.fp[reg] = cosh (src); - break; - case 0x1a: /* FNEG */ - case 0x5a: - case 0x5e: - regs.fp[reg] = -src; - if ((extra & 0x44) == 0x40) - fround (reg); - break; - case 0x1c: /* FACOS */ - regs.fp[reg] = acos (src); - break; - case 0x1d: /* FCOS */ - regs.fp[reg] = cos (src); - break; - case 0x1e: /* FGETEXP */ - { - if (src == 0) { - regs.fp[reg] = 0; - } else { - int expon; - frexp (src, &expon); - regs.fp[reg] = (double) (expon - 1); - } - } - break; - case 0x1f: /* FGETMAN */ - { - if (src == 0) { - regs.fp[reg] = 0; - } else { - int expon; - regs.fp[reg] = frexp (src, &expon) * 2.0; - } - } - break; - case 0x20: /* FDIV */ - case 0x60: - case 0x64: - regs.fp[reg] /= src; - if ((extra & 0x44) == 0x40) - fround (reg); - break; - case 0x21: /* FMOD */ - { - fptype quot = fp_round_to_zero(regs.fp[reg] / src); - regs.fp[reg] = regs.fp[reg] - quot * src; + break; + case 0x0e: /* FSIN */ + regs.fp[reg] = sin (src); + break; + case 0x0f: /* FTAN */ + regs.fp[reg] = tan (src); + break; + case 0x10: /* FETOX */ + regs.fp[reg] = exp (src); + break; + case 0x11: /* FTWOTOX */ + regs.fp[reg] = pow (2.0, src); + break; + case 0x12: /* FTENTOX */ + regs.fp[reg] = pow (10.0, src); + break; + case 0x14: /* FLOGN */ + regs.fp[reg] = log (src); + break; + case 0x15: /* FLOG10 */ + regs.fp[reg] = log10 (src); + break; + case 0x16: /* FLOG2 */ + regs.fp[reg] = *fp_l2_e * log (src); + break; + case 0x18: /* FABS */ + case 0x58: + case 0x5c: + regs.fp[reg] = src < 0 ? -src : src; + if ((extra & 0x44) == 0x40) + fround (reg); + break; + case 0x19: /* FCOSH */ + regs.fp[reg] = cosh (src); + break; + case 0x1a: /* FNEG */ + case 0x5a: + case 0x5e: + regs.fp[reg] = -src; + if ((extra & 0x44) == 0x40) + fround (reg); + break; + case 0x1c: /* FACOS */ + regs.fp[reg] = acos (src); + break; + case 0x1d: /* FCOS */ + regs.fp[reg] = cos (src); + break; + case 0x1e: /* FGETEXP */ + { + if (src == 0) { + regs.fp[reg] = 0; + } else { + int expon; + frexp (src, &expon); + regs.fp[reg] = (double) (expon - 1); } - break; - case 0x22: /* FADD */ - case 0x62: - case 0x66: - regs.fp[reg] += src; - if ((extra & 0x44) == 0x40) - fround (reg); - break; - case 0x23: /* FMUL */ - case 0x63: - case 0x67: - regs.fp[reg] *= src; - if ((extra & 0x44) == 0x40) - fround (reg); - break; - case 0x24: /* FSGLDIV */ - regs.fp[reg] /= src; - break; - case 0x25: /* FREM */ - { - fptype quot = fp_round_to_nearest(regs.fp[reg] / src); - regs.fp[reg] = regs.fp[reg] - quot * src; + } + break; + case 0x1f: /* FGETMAN */ + { + if (src == 0) { + regs.fp[reg] = 0; + } else { + int expon; + regs.fp[reg] = frexp (src, &expon) * 2.0; } - break; - case 0x26: /* FSCALE */ - if (src != 0) { + } + break; + case 0x20: /* FDIV */ + case 0x60: + case 0x64: + regs.fp[reg] /= src; + if ((extra & 0x44) == 0x40) + fround (reg); + break; + case 0x21: /* FMOD */ + { + fptype quot = fp_round_to_zero(regs.fp[reg] / src); + regs.fp[reg] = regs.fp[reg] - quot * src; + } + break; + case 0x22: /* FADD */ + case 0x62: + case 0x66: + regs.fp[reg] += src; + if ((extra & 0x44) == 0x40) + fround (reg); + break; + case 0x23: /* FMUL */ + case 0x63: + case 0x67: + regs.fp[reg] *= src; + if ((extra & 0x44) == 0x40) + fround (reg); + break; + case 0x24: /* FSGLDIV */ + regs.fp[reg] /= src; + break; + case 0x25: /* FREM */ + { + fptype quot = fp_round_to_nearest(regs.fp[reg] / src); + regs.fp[reg] = regs.fp[reg] - quot * src; + } + break; + case 0x26: /* FSCALE */ + if (src != 0) { #ifdef ldexp - regs.fp[reg] = ldexp (regs.fp[reg], (int) src); + regs.fp[reg] = ldexp (regs.fp[reg], (int) src); #else - regs.fp[reg] *= exp (*fp_ln_2 * (int) src); + regs.fp[reg] *= exp (*fp_ln_2 * (int) src); #endif - } - break; - case 0x27: /* FSGLMUL */ - regs.fp[reg] *= src; - break; - case 0x28: /* FSUB */ - case 0x68: - case 0x6c: - regs.fp[reg] -= src; - if ((extra & 0x44) == 0x40) - fround (reg); - break; - case 0x30: /* FSINCOS */ - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - regs.fp[extra & 7] = cos (src); - regs.fp[reg] = sin (src); - break; - case 0x38: /* FCMP */ - { - fptype tmp = regs.fp[reg] - src; - regs.fpsr = 0; - MAKE_FPSR (tmp); - } - return; - case 0x3a: /* FTST */ + } + break; + case 0x27: /* FSGLMUL */ + regs.fp[reg] *= src; + break; + case 0x28: /* FSUB */ + case 0x68: + case 0x6c: + regs.fp[reg] -= src; + if ((extra & 0x44) == 0x40) + fround (reg); + break; + case 0x30: /* FSINCOS */ + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + regs.fp[extra & 7] = cos (src); + regs.fp[reg] = sin (src); + break; + case 0x38: /* FCMP */ + { + fptype tmp = regs.fp[reg] - src; regs.fpsr = 0; - MAKE_FPSR (src); - return; - default: - m68k_setpc (m68k_getpc () - 4); - op_illg (opcode); - return; + MAKE_FPSR (tmp); + } + return; + case 0x3a: /* FTST */ + regs.fpsr = 0; + MAKE_FPSR (src); + return; + default: + m68k_setpc (m68k_getpc () - 4); + op_illg (opcode); + return; } MAKE_FPSR (regs.fp[reg]); return; - } - m68k_setpc (m68k_getpc () - 4); - op_illg (opcode); } + m68k_setpc (m68k_getpc () - 4); + op_illg (opcode); +} - void fpu_reset (void) - { - regs.fpcr = regs.fpsr = regs.fpiar = 0; - regs.fp_result = 1; - fpux_restore (NULL); - } +void fpu_reset (void) +{ + regs.fpcr = regs.fpsr = regs.fpiar = 0; + regs.fp_result = 1; + fpux_restore (NULL); +} - uae_u8 *restore_fpu (uae_u8 *src) - { - int i; - uae_u32 flags; - - changed_prefs.fpu_model = currprefs.fpu_model = restore_u32 (); - flags = restore_u32 (); - for (i = 0; i < 8; i++) { - uae_u32 w1 = restore_u32 (); - uae_u32 w2 = restore_u32 (); - uae_u32 w3 = restore_u16 (); - regs.fp[i] = to_exten (w1, w2, w3); - } - regs.fpcr = restore_u32 (); - native_set_fpucw (regs.fpcr); - regs.fpsr = restore_u32 (); - regs.fpiar = restore_u32 (); - if (flags & 0x80000000) { - restore_u32(); - restore_u32(); - } - write_log (L"FPU: %d\n", currprefs.fpu_model); - return src; +uae_u8 *restore_fpu (uae_u8 *src) +{ + int i; + uae_u32 flags; + + changed_prefs.fpu_model = currprefs.fpu_model = restore_u32 (); + flags = restore_u32 (); + for (i = 0; i < 8; i++) { + uae_u32 w1 = restore_u32 (); + uae_u32 w2 = restore_u32 (); + uae_u32 w3 = restore_u16 (); + regs.fp[i] = to_exten (w1, w2, w3); + } + regs.fpcr = restore_u32 (); + native_set_fpucw (regs.fpcr); + regs.fpsr = restore_u32 (); + regs.fpiar = restore_u32 (); + if (flags & 0x80000000) { + restore_u32(); + restore_u32(); } + write_log (L"FPU: %d\n", currprefs.fpu_model); + return src; +} - uae_u8 *save_fpu (int *len, uae_u8 *dstptr) - { - uae_u8 *dstbak,*dst; - int i; +uae_u8 *save_fpu (int *len, uae_u8 *dstptr) +{ + uae_u8 *dstbak,*dst; + int i; - *len = 0; - if (currprefs.fpu_model == 0) - return 0; - if (dstptr) - dstbak = dst = dstptr; - else - dstbak = dst = malloc (4+4+8*10+4+4+4+4+4); - save_u32 (currprefs.fpu_model); - save_u32 (0x80000000); - for (i = 0; i < 8; i++) { - uae_u32 w1, w2, w3; - from_exten (regs.fp[i], &w1, &w2, &w3); - save_u32 (w1); - save_u32 (w2); - save_u16 (w3); - } - save_u32 (regs.fpcr); - save_u32 (regs.fpsr); - save_u32 (regs.fpiar); - save_u32 (-1); - save_u32 (0); - *len = dst - dstbak; - return dstbak; + *len = 0; + if (currprefs.fpu_model == 0) + return 0; + if (dstptr) + dstbak = dst = dstptr; + else + dstbak = dst = malloc (4+4+8*10+4+4+4+4+4); + save_u32 (currprefs.fpu_model); + save_u32 (0x80000000); + for (i = 0; i < 8; i++) { + uae_u32 w1, w2, w3; + from_exten (regs.fp[i], &w1, &w2, &w3); + save_u32 (w1); + save_u32 (w2); + save_u16 (w3); } + save_u32 (regs.fpcr); + save_u32 (regs.fpsr); + save_u32 (regs.fpiar); + save_u32 (-1); + save_u32 (0); + *len = dst - dstbak; + return dstbak; +} diff --git a/gencpu.c b/gencpu.c index 40da5667..9a3af880 100644 --- a/gencpu.c +++ b/gencpu.c @@ -738,10 +738,13 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g if ((using_prefetch || using_ce) && using_exception_3 && getv != 0 && size != sz_byte) { int offset = 0; - if (flags & GF_MOVE) + if (flags & GF_MOVE) { offset = m68k_pc_offset; - else + if (getv == 2) + offset += 2; + } else { offset = m68k_pc_offset_last; + } printf ("\tif (%sa & 1) {\n", name); printf ("\t\texception3 (opcode, m68k_getpc () + %d, %sa);\n", offset, name); diff --git a/hardfile.c b/hardfile.c index 152f5af7..37092e31 100644 --- a/hardfile.c +++ b/hardfile.c @@ -460,126 +460,6 @@ int hdf_dup (struct hardfiledata *dhfd, const struct hardfiledata *shfd) extern int get_guid_target (uae_u8 *out); -int vhd_create (const TCHAR *name, uae_u64 size) -{ - struct hardfiledata hfd; - struct zfile *zf; - uae_u8 *b; - int cyl, cylsec, head, tracksec; - uae_u32 crc, blocksize, batsize, batentrysize; - int ret, i; - time_t tm; - - if (size >= (uae_u64)10 * 1024 * 1024 * 1024) - blocksize = 2 * 1024 * 1024; - else - blocksize = 512 * 1024; - batsize = (size + blocksize - 1) / blocksize; - batentrysize = batsize; - batsize *= 4; - batsize += 511; - batsize &= ~511; - ret = 0; - b = NULL; - zf = zfile_fopen (name, L"wb", 0); - if (!zf) - goto end; - b = xcalloc (512 + 1024 + batsize + 512, 1); - if (zfile_fwrite (b, 512 + 1024 + batsize + 512, 1, zf) != 1) - goto end; - - memset (&hfd, 0, sizeof hfd); - hfd.virtsize = hfd.physsize = size; - hfd.blocksize = 512; - strcpy (b, "conectix"); // cookie - b[0x0b] = 2; // features - b[0x0d] = 1; // version - b[0x10 + 6] = 2; // data offset - // time stamp - tm = time (NULL) - 946684800; - b[0x18] = tm >> 24; - b[0x19] = tm >> 16; - b[0x1a] = tm >> 8; - b[0x1b] = tm >> 0; - strcpy (b + 0x1c, "vpc "); // creator application - b[0x21] = 5; // creator version - strcpy (b + 0x24, "Wi2k"); // creator host os - // original and current size - b[0x28] = b[0x30] = size >> 56; - b[0x29] = b[0x31] = size >> 48; - b[0x2a] = b[0x32] = size >> 40; - b[0x2b] = b[0x33] = size >> 32; - b[0x2c] = b[0x34] = size >> 24; - b[0x2d] = b[0x35] = size >> 16; - b[0x2e] = b[0x36] = size >> 8; - b[0x2f] = b[0x37] = size >> 0; - getchs2 (&hfd, &cyl, &cylsec, &head, &tracksec); - // cylinders - b[0x38] = cyl >> 8; - b[0x39] = cyl; - // heads - b[0x3a] = head; - // sectors per track - b[0x3b] = tracksec; - // disk type - b[0x3c + 3] = VHD_DYNAMIC; - get_guid_target (b + 0x44); - crc = vhd_checksum (b, -1); - b[0x40] = crc >> 24; - b[0x41] = crc >> 16; - b[0x42] = crc >> 8; - b[0x43] = crc >> 0; - - // write header - zfile_fseek (zf, 0, SEEK_SET); - zfile_fwrite (b, 512, 1, zf); - // write footer - zfile_fseek (zf, 512 + 1024 + batsize, SEEK_SET); - zfile_fwrite (b, 512, 1, zf); - - // dynamic disk header - memset (b, 0, 1024); - // cookie - strcpy (b, "cxsparse"); - // data offset - for (i = 0; i < 8; i++) - b[0x08 + i] = 0xff; - // table offset (bat) - b[0x10 + 6] = 0x06; - // version - b[0x19] = 1; - // max table entries - b[0x1c] = batentrysize >> 24; - b[0x1d] = batentrysize >> 16; - b[0x1e] = batentrysize >> 8; - b[0x1f] = batentrysize >> 0; - b[0x20] = blocksize >> 24; - b[0x21] = blocksize >> 16; - b[0x22] = blocksize >> 8; - b[0x23] = blocksize >> 0; - crc = vhd_checksum (b, -1); - b[0x24] = crc >> 24; - b[0x25] = crc >> 16; - b[0x26] = crc >> 8; - b[0x27] = crc >> 0; - - // write dynamic header - zfile_fseek (zf, 512, SEEK_SET); - zfile_fwrite (b, 1024, 1, zf); - - // bat - memset (b, 0, batsize); - memset (b, 0xff, batentrysize * 4); - zfile_fwrite (b, batsize, 1, zf); - - ret = 1; - -end: - xfree (b); - zfile_fclose (zf); - return ret; -} - static uae_u64 vhd_read (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len) { uae_u32 bamoffset; @@ -731,6 +611,142 @@ static uae_u64 vhd_write (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 off return written; } + +int vhd_create (const TCHAR *name, uae_u64 size, uae_u32 dostype) +{ + struct hardfiledata hfd; + struct zfile *zf; + uae_u8 *b; + int cyl, cylsec, head, tracksec; + uae_u32 crc, blocksize, batsize, batentrysize; + int ret, i; + time_t tm; + + if (size >= (uae_u64)10 * 1024 * 1024 * 1024) + blocksize = 2 * 1024 * 1024; + else + blocksize = 512 * 1024; + batsize = (size + blocksize - 1) / blocksize; + batentrysize = batsize; + batsize *= 4; + batsize += 511; + batsize &= ~511; + ret = 0; + b = NULL; + zf = zfile_fopen (name, L"wb", 0); + if (!zf) + goto end; + b = xcalloc (512 + 1024 + batsize + 512, 1); + if (zfile_fwrite (b, 512 + 1024 + batsize + 512, 1, zf) != 1) + goto end; + + memset (&hfd, 0, sizeof hfd); + hfd.virtsize = hfd.physsize = size; + hfd.blocksize = 512; + strcpy (b, "conectix"); // cookie + b[0x0b] = 2; // features + b[0x0d] = 1; // version + b[0x10 + 6] = 2; // data offset + // time stamp + tm = time (NULL) - 946684800; + b[0x18] = tm >> 24; + b[0x19] = tm >> 16; + b[0x1a] = tm >> 8; + b[0x1b] = tm >> 0; + strcpy (b + 0x1c, "vpc "); // creator application + b[0x21] = 5; // creator version + strcpy (b + 0x24, "Wi2k"); // creator host os + // original and current size + b[0x28] = b[0x30] = size >> 56; + b[0x29] = b[0x31] = size >> 48; + b[0x2a] = b[0x32] = size >> 40; + b[0x2b] = b[0x33] = size >> 32; + b[0x2c] = b[0x34] = size >> 24; + b[0x2d] = b[0x35] = size >> 16; + b[0x2e] = b[0x36] = size >> 8; + b[0x2f] = b[0x37] = size >> 0; + getchs2 (&hfd, &cyl, &cylsec, &head, &tracksec); + // cylinders + b[0x38] = cyl >> 8; + b[0x39] = cyl; + // heads + b[0x3a] = head; + // sectors per track + b[0x3b] = tracksec; + // disk type + b[0x3c + 3] = VHD_DYNAMIC; + get_guid_target (b + 0x44); + crc = vhd_checksum (b, -1); + b[0x40] = crc >> 24; + b[0x41] = crc >> 16; + b[0x42] = crc >> 8; + b[0x43] = crc >> 0; + + // write header + zfile_fseek (zf, 0, SEEK_SET); + zfile_fwrite (b, 512, 1, zf); + // write footer + zfile_fseek (zf, 512 + 1024 + batsize, SEEK_SET); + zfile_fwrite (b, 512, 1, zf); + + // dynamic disk header + memset (b, 0, 1024); + // cookie + strcpy (b, "cxsparse"); + // data offset + for (i = 0; i < 8; i++) + b[0x08 + i] = 0xff; + // table offset (bat) + b[0x10 + 6] = 0x06; + // version + b[0x19] = 1; + // max table entries + b[0x1c] = batentrysize >> 24; + b[0x1d] = batentrysize >> 16; + b[0x1e] = batentrysize >> 8; + b[0x1f] = batentrysize >> 0; + b[0x20] = blocksize >> 24; + b[0x21] = blocksize >> 16; + b[0x22] = blocksize >> 8; + b[0x23] = blocksize >> 0; + crc = vhd_checksum (b, -1); + b[0x24] = crc >> 24; + b[0x25] = crc >> 16; + b[0x26] = crc >> 8; + b[0x27] = crc >> 0; + + // write dynamic header + zfile_fseek (zf, 512, SEEK_SET); + zfile_fwrite (b, 1024, 1, zf); + + // bat + memset (b, 0, batsize); + memset (b, 0xff, batentrysize * 4); + zfile_fwrite (b, batsize, 1, zf); + + zfile_fclose (zf); + zf = NULL; + + if (dostype) { + uae_u8 bootblock[512] = { 0 }; + bootblock[0] = dostype >> 24; + bootblock[1] = dostype >> 16; + bootblock[2] = dostype >> 8; + bootblock[3] = dostype >> 0; + if (hdf_open (&hfd, name)) { + vhd_write (&hfd, bootblock, 0, 512); + hdf_close (&hfd); + } + } + + ret = 1; + +end: + xfree (b); + zfile_fclose (zf); + return ret; +} + static int hdf_read2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len) { if (hfd->vhd_type == VHD_DYNAMIC) diff --git a/include/cpu_prefetch.h b/include/cpu_prefetch.h index ca77e7bf..0b0f4ef0 100644 --- a/include/cpu_prefetch.h +++ b/include/cpu_prefetch.h @@ -12,11 +12,6 @@ STATIC_INLINE uae_u32 get_long_prefetch (int o) return v; } -STATIC_INLINE void prefetch_common_ce000 (void) -{ - regs.lastfetch = get_cycles (); -} - #ifdef CPUEMU_20 STATIC_INLINE void checkcycles_ce020 (void) @@ -276,27 +271,29 @@ STATIC_INLINE uae_u32 next_ilong_020ce (void) STATIC_INLINE uae_u32 mem_access_delay_word_read (uaecptr addr) { - prefetch_common_ce000 (); switch (ce_banktype[addr >> 16]) { case CE_MEMBANK_CHIP: return wait_cpu_cycle_read (addr, 1); case CE_MEMBANK_FAST: case CE_MEMBANK_FAST16BIT: - do_cycles_ce000 (4); + do_cycles_ce000 (2); + regs.ipl = regs.ipl_pin; + do_cycles_ce000 (2); break; } return get_word (addr); } STATIC_INLINE uae_u32 mem_access_delay_wordi_read (uaecptr addr) { - prefetch_common_ce000 (); switch (ce_banktype[addr >> 16]) { case CE_MEMBANK_CHIP: return wait_cpu_cycle_read (addr, 1); case CE_MEMBANK_FAST: - do_cycles_ce000 (4); + do_cycles_ce000 (2); + regs.ipl = regs.ipl_pin; + do_cycles_ce000 (2); break; } return get_wordi (addr); @@ -304,13 +301,14 @@ STATIC_INLINE uae_u32 mem_access_delay_wordi_read (uaecptr addr) STATIC_INLINE uae_u32 mem_access_delay_byte_read (uaecptr addr) { - prefetch_common_ce000 (); switch (ce_banktype[addr >> 16]) { case CE_MEMBANK_CHIP: return wait_cpu_cycle_read (addr, 0); case CE_MEMBANK_FAST: - do_cycles_ce000 (4); + do_cycles_ce000 (2); + regs.ipl = regs.ipl_pin; + do_cycles_ce000 (2); break; } @@ -318,21 +316,21 @@ STATIC_INLINE uae_u32 mem_access_delay_byte_read (uaecptr addr) } STATIC_INLINE void mem_access_delay_byte_write (uaecptr addr, uae_u32 v) { - prefetch_common_ce000 (); switch (ce_banktype[addr >> 16]) { case CE_MEMBANK_CHIP: wait_cpu_cycle_write (addr, 0, v); return; case CE_MEMBANK_FAST: - do_cycles_ce000 (4); + do_cycles_ce000 (2); + regs.ipl = regs.ipl_pin; + do_cycles_ce000 (2); break; } put_byte (addr, v); } STATIC_INLINE void mem_access_delay_word_write (uaecptr addr, uae_u32 v) { - prefetch_common_ce000 (); switch (ce_banktype[addr >> 16]) { case CE_MEMBANK_CHIP: @@ -340,7 +338,9 @@ STATIC_INLINE void mem_access_delay_word_write (uaecptr addr, uae_u32 v) return; break; case CE_MEMBANK_FAST: - do_cycles_ce000 (4); + do_cycles_ce000 (2); + regs.ipl = regs.ipl_pin; + do_cycles_ce000 (2); break; } put_word (addr, v); diff --git a/include/events_jit.h b/include/events_jit.h index e02132cb..cebdb990 100644 --- a/include/events_jit.h +++ b/include/events_jit.h @@ -29,7 +29,7 @@ extern signed long pissoff; STATIC_INLINE void cycles_do_special (void) { - if (pissoff >= 0) + if (pissoff > 0) pissoff = -1; } @@ -46,6 +46,10 @@ STATIC_INLINE unsigned long int get_cycles (void) STATIC_INLINE void set_cycles (unsigned long int x) { currcycle = x; +#ifdef EVT_DEBUG + if (currcycle & (CYCLE_UNIT - 1)) + write_log (L"%x\n", currcycle); +#endif } STATIC_INLINE void do_cycles_slow (unsigned long cycles_to_add) @@ -79,6 +83,10 @@ STATIC_INLINE void do_cycles_slow (unsigned long cycles_to_add) events_schedule (); } currcycle += cycles_to_add; +#ifdef EVT_DEBUG + if (currcycle & (CYCLE_UNIT - 1)) + write_log (L"%x\n", currcycle); +#endif } #define do_cycles do_cycles_slow diff --git a/include/filesys.h b/include/filesys.h index 79682ccf..901852fa 100644 --- a/include/filesys.h +++ b/include/filesys.h @@ -111,7 +111,7 @@ int hdf_hd_open(struct hd_hardfiledata *hfd, const TCHAR *path, int blocksize, i int bootpri, const TCHAR *filesys); -extern int vhd_create (const TCHAR *name, uae_u64 size); +extern int vhd_create (const TCHAR *name, uae_u64 size, uae_u32); extern int hdf_init_target (void); extern int hdf_open_target (struct hardfiledata *hfd, const TCHAR *name); diff --git a/include/memory.h b/include/memory.h index 6d5bcae7..3ef61037 100644 --- a/include/memory.h +++ b/include/memory.h @@ -16,11 +16,11 @@ extern int special_mem; extern void *cache_alloc (int); extern void cache_free (void*); +#endif -extern int canbang, candirect; int init_shm (void); void preinit_shm (void); -#endif +extern int canbang, candirect; #ifdef ADDRESS_SPACE_24BIT #define MEMORY_BANKS 256 diff --git a/include/newcpu.h b/include/newcpu.h index e0cab404..dded7b47 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -133,7 +133,7 @@ extern struct regstruct flagtype x; flagtype stopped; int intmask; - int ipl; + int ipl, ipl_pin; uae_u32 vbr, sfc, dfc; @@ -389,7 +389,7 @@ extern void flush_icache (uaecptr, int n); extern void compemu_reset (void); extern int check_prefs_changed_comp (void); #else -#define flush_icache(X) do {} while (0) +#define flush_icache(uaecptr, int) do {} while (0) #endif extern void flush_mmu (uaecptr, int); diff --git a/jit/compemu_support.c b/jit/compemu_support.c index 2cc219a4..60c4788f 100644 --- a/jit/compemu_support.c +++ b/jit/compemu_support.c @@ -5,6 +5,9 @@ #define USE_MATCHSTATE 0 #include "sysconfig.h" #include "sysdeps.h" + +#if defined(JIT) + #include "options.h" #include "events.h" #include "include/memory.h" @@ -13,7 +16,6 @@ #include "comptbl.h" #include "compemu.h" -#if defined(JIT) #define NATMEM_OFFSETX (uae_u32)NATMEM_OFFSET diff --git a/main.c b/main.c index 99bb03be..74823a3b 100644 --- a/main.c +++ b/main.c @@ -706,9 +706,16 @@ void leave_program (void) do_leave_program (); } +#ifdef _WIN64 +extern int DummyException (LPEXCEPTION_POINTERS blah, int n_except) +{ + return EXCEPTION_CONTINUE_SEARCH; +} +#endif + static int real_main2 (int argc, TCHAR **argv) { -#if defined (JIT) && (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER) +#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER) extern int EvalException (LPEXCEPTION_POINTERS blah, int n_except); __try #endif @@ -854,8 +861,12 @@ static int real_main2 (int argc, TCHAR **argv) } } -#if defined (JIT) && (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER) +#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER) +#ifdef JIT __except (EvalException (GetExceptionInformation (), GetExceptionCode ())) +#else + __except (DummyException (GetExceptionInformation (), GetExceptionCode ())) +#endif { // EvalException does the good stuff... } diff --git a/newcpu.c b/newcpu.c index 9ec4b90e..66ef86a8 100644 --- a/newcpu.c +++ b/newcpu.c @@ -1457,8 +1457,8 @@ static void Exception_mmu (int nr, uaecptr oldpc) if (nr == 2) { write_log (L"%08x %08x %08x\n", currpc, oldpc, regs.mmu_fault_addr); - if (currpc == 0x0013b5e2) - activate_debugger (); +// if (currpc == 0x0013b5e2) +// activate_debugger (); // bus error for (i = 0 ; i < 7 ; i++) { m68k_areg (regs, 7) -= 4; @@ -2206,6 +2206,7 @@ void m68k_mull (uae_u32 opcode, uae_u32 src, uae_u16 extra) void m68k_reset (int hardreset) { regs.spcflags = 0; + regs.ipl = regs.ipl_pin = 0; #ifdef SAVESTATE if (savestate_state == STATE_RESTORE || savestate_state == STATE_REWIND) { m68k_setpc (regs.pc); @@ -2571,30 +2572,32 @@ static void do_trace (void) } -static int interrupt_cycles_active; -static evt interrupt_cycle; - // handle interrupt delay (few cycles) STATIC_INLINE int time_for_interrupt (void) { - if (interrupt_cycles_active) { - if (regs.lastfetch - interrupt_cycle >= 2 * CYCLE_UNIT) { - interrupt_cycles_active = 0; - return 1; - } else { - return 0; + if (regs.ipl > 0 && (regs.ipl > regs.intmask || regs.ipl == 7)) { +#if 0 + if (regs.ipl == 3 && current_hpos () < 11) { + write_log (L"%d\n", current_hpos ()); + activate_debugger (); } +#endif + return 1; } - return 1; + return 0; } void doint (void) { - regs.ipl = intlev (); if (currprefs.cpu_cycle_exact) { + int newipl = intlev (); + + if (newipl == regs.ipl_pin) + return; + regs.ipl_pin = newipl; + if (currprefs.cpu_model != 68000) + regs.ipl = regs.ipl_pin; set_special (SPCFLAG_INT); - interrupt_cycle = get_cycles (); - interrupt_cycles_active = 1; return; } if (currprefs.cpu_compatible) @@ -2677,9 +2680,10 @@ STATIC_INLINE int do_specialties (int cycles) do_copper (); if (currprefs.cpu_cycle_exact) { - if (regs.ipl > 0 && regs.ipl > regs.intmask) { - if (time_for_interrupt ()) - do_interrupt (regs.ipl); + regs.ipl = regs.ipl_pin; + if (time_for_interrupt ()) { + unset_special (SPCFLAG_INT | SPCFLAG_DOINT); + do_interrupt (regs.ipl); } } else { if (regs.spcflags & (SPCFLAG_INT | SPCFLAG_DOINT)) { @@ -2723,9 +2727,9 @@ STATIC_INLINE int do_specialties (int cycles) do_trace (); if (currprefs.cpu_cycle_exact) { - if (regs.ipl > 0 && (regs.ipl > regs.intmask || regs.ipl == 7)) { - if (time_for_interrupt ()) - do_interrupt (regs.ipl); + if (time_for_interrupt ()) { + unset_special (SPCFLAG_INT | SPCFLAG_DOINT); + do_interrupt (regs.ipl); } } else { if (regs.spcflags & SPCFLAG_INT) { @@ -2889,7 +2893,6 @@ static void m68k_run_1_ce (void) for (;;) { uae_u32 opcode = r->ir; - (*cpufunctbl[opcode])(opcode); if (r->spcflags) { if (do_specialties (0)) @@ -2981,7 +2984,6 @@ static void m68k_run_2a (void) /* Whenever we return from that, we should check spcflags */ if (uae_int_requested) { intreq |= 0x0008; - intreqr = intreq; set_special (SPCFLAG_INT); } if (regs.spcflags) { diff --git a/od-win32/bsdsock.c b/od-win32/bsdsock.c index 1252917f..1a48e181 100644 --- a/od-win32/bsdsock.c +++ b/od-win32/bsdsock.c @@ -935,7 +935,7 @@ static unsigned int __stdcall sock_thread(void *p) { __try { return sock_thread2 (p); - } __except(WIN32_ExceptionFilter(GetExceptionInformation(), GetExceptionCode())) { + } __except(WIN32_ExceptionFilter (GetExceptionInformation (), GetExceptionCode ())) { } return 0; } diff --git a/od-win32/debug_win32.c b/od-win32/debug_win32.c index 36f25212..c9a97b8d 100644 --- a/od-win32/debug_win32.c +++ b/od-win32/debug_win32.c @@ -797,7 +797,7 @@ static LRESULT CALLBACK InputProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM } break; } - oldproc = (WNDPROC)GetWindowLongPtr(hWnd, GWL_USERDATA); + oldproc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_USERDATA); return CallWindowProc(oldproc, hWnd, message, wParam, lParam); } @@ -865,7 +865,7 @@ static LRESULT CALLBACK MemInputProc (HWND hWnd, UINT message, WPARAM wParam, LP } break; } - oldproc = (WNDPROC)GetWindowLongPtr(hWnd, GWL_USERDATA); + oldproc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_USERDATA); return CallWindowProc(oldproc, hWnd, message, wParam, lParam); } @@ -886,8 +886,8 @@ static INT_PTR CALLBACK AddrInputDialogProc(HWND hDlg, UINT msg, WPARAM wParam, DWORD msgpos = GetMessagePos(); HWND hwnd = GetDlgItem(hDlg, IDC_DBG_MEMINPUT2); SendMessage(hwnd, EM_LIMITTEXT, 8, 0); - oldproc = (WNDPROC)SetWindowLongPtr(hwnd, GWL_WNDPROC, (LONG_PTR)MemInputProc); - SetWindowLongPtr(hwnd, GWL_USERDATA, (LONG_PTR)oldproc); + oldproc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)MemInputProc); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc); GetWindowRect(hDlg, &r); r.right -= r.left; r.bottom -= r.top; @@ -1165,7 +1165,7 @@ static LRESULT CALLBACK ListboxEditProc(HWND hWnd, UINT message, WPARAM wParam, ListboxEndEdit(hparent, TRUE); break; } - oldproc = (WNDPROC)GetWindowLongPtr(hWnd, GWL_USERDATA); + oldproc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_USERDATA); return CallWindowProc(oldproc, hWnd, message, wParam, lParam); } @@ -1261,8 +1261,8 @@ static void ListboxEdit(HWND hwnd, int x, int y) SendMessage(hedit, EM_LIMITTEXT, length, 0); MoveWindow(hedit, ri.left, ri.top, ri.right - ri.left, ri.bottom - ri.top, FALSE); ShowWindow(hedit, SW_SHOWNORMAL); - oldproc = (WNDPROC)SetWindowLongPtr(hedit, GWL_WNDPROC, (LONG_PTR)ListboxEditProc); - SetWindowLongPtr(hedit, GWL_USERDATA, (LONG_PTR)oldproc); + oldproc = (WNDPROC)SetWindowLongPtr(hedit, GWLP_WNDPROC, (LONG_PTR)ListboxEditProc); + SetWindowLongPtr(hedit, GWLP_USERDATA, (LONG_PTR)oldproc); hfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0); SendMessage(hedit, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); memset(txt + offset + length, 0, MAX_LINEWIDTH + 1 - offset - length); @@ -1448,7 +1448,7 @@ static LRESULT CALLBACK ListboxProc(HWND hWnd, UINT message, WPARAM wParam, LPAR } break; } - oldproc = (WNDPROC)GetWindowLongPtr(hWnd, GWL_USERDATA); + oldproc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_USERDATA); return CallWindowProc(oldproc, hWnd, message, wParam, lParam); } @@ -1469,7 +1469,7 @@ static LRESULT CALLBACK EditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM } break; } - oldproc = (WNDPROC)GetWindowLongPtr(hWnd, GWL_USERDATA); + oldproc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_USERDATA); return CallWindowProc(oldproc, hWnd, message, wParam, lParam); } @@ -1650,8 +1650,8 @@ static BOOL CALLBACK InitChildWindows(HWND hWnd, LPARAM lParam) break; } if (newproc) { - oldproc = (WNDPROC)SetWindowLongPtr(hWnd, GWL_WNDPROC, (LONG_PTR)newproc); - SetWindowLongPtr(hWnd, GWL_USERDATA, (LONG_PTR)oldproc); + oldproc = (WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)newproc); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)oldproc); } EnableWindow(hWnd, enable); return TRUE; diff --git a/od-win32/dinput.c b/od-win32/dinput.c index 27f9d819..2c8853d5 100644 --- a/od-win32/dinput.c +++ b/od-win32/dinput.c @@ -445,6 +445,7 @@ static int gettabletres (AXIS *a) void *open_tablet (HWND hwnd) { +#ifndef _WIN64 LOGCONTEXT lc; AXIS tx = { 0 }, ty = { 0 }, tz = { 0 }; AXIS pres = { 0 }; @@ -488,16 +489,23 @@ void *open_tablet (HWND hwnd) tablet_x = -1; inputdevice_tablet_info (xmax, ymax, zmax, axmax, aymax, azmax, xres, yres); return WTOpen (hwnd, &lc, TRUE); +#else + return 0; +#endif } int close_tablet (void *ctx) { +#ifndef _WIN64 if (ctx != NULL) WTClose (ctx); ctx = NULL; if (!tablet) return 0; return 1; +#else + return 0; +#endif } int is_tablet (void) @@ -507,6 +515,7 @@ int is_tablet (void) static int initialize_tablet (void) { +#ifndef _WIN64 HANDLE h; TCHAR name[MAX_DPATH]; struct tagAXIS ori[3]; @@ -538,6 +547,9 @@ static int initialize_tablet (void) tabletname = my_strdup (name); tablet = TRUE; return 1; +#else + return 0; +#endif } static int initialize_catweasel (void) diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index 53431bf8..ae9bbc73 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -19,6 +19,7 @@ extern "C" #include "statusline.h" #include "hq2x_d3d.h" #include "zfile.h" +extern int D3DEX, d3ddebug; } #include @@ -26,8 +27,6 @@ extern "C" #include "direct3d.h" -static int D3DEX = 1; - static TCHAR *D3DHEAD = L"-"; static int tex_pow2, tex_square, tex_dynamic; static int psEnabled, psActive, psPreProcess; @@ -49,9 +48,9 @@ static ID3DXSprite *sprite; static HWND d3dhwnd; static int devicelost; -static D3DXMATRIX m_matProj; -static D3DXMATRIX m_matWorld; -static D3DXMATRIX m_matView; +static D3DXMATRIX m_matProj, m_matProj2; +static D3DXMATRIX m_matWorld, m_matWorld2; +static D3DXMATRIX m_matView, m_matView2; static D3DXMATRIX m_matPreProj; static D3DXMATRIX m_matPreView; static D3DXMATRIX m_matPreWorld; @@ -72,6 +71,58 @@ struct TLVERTEX { D3DXVECTOR2 texcoord; // texture coords }; +static int ddraw_fs; +static LPDIRECTDRAW7 ddraw; + +static void ddraw_fs_hack_free (void) +{ + HRESULT hr; + + if (!ddraw_fs) + return; + if (ddraw_fs == 2) + IDirectDraw7_RestoreDisplayMode (ddraw); + hr = IDirectDraw7_SetCooperativeLevel (ddraw, d3dhwnd, DDSCL_NORMAL); + if (FAILED (hr)) { + write_log (L"IDirectDraw7_SetCooperativeLevel CLEAR: %s\n", DXError (hr)); + } + IDirectDraw7_Release (ddraw); + ddraw = NULL; + ddraw_fs = 0; + +} + +static int ddraw_fs_hack_init (void) +{ + HRESULT hr; + struct MultiDisplay *md; + + ddraw_fs_hack_free (); + md = getdisplay (&currprefs); + if (!md) + return 0; + hr = DirectDrawCreateEx (md->primary ? NULL : &md->guid, (LPVOID*)&ddraw, IID_IDirectDraw7, NULL); + if (FAILED (hr)) { + write_log (L"DirectDrawCreateEx failed, %s\n", DXError (hr)); + return 0; + } + ddraw_fs = 1; + hr = IDirectDraw7_SetCooperativeLevel (ddraw, d3dhwnd, DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + if (FAILED (hr)) { + write_log (L"IDirectDraw7_SetCooperativeLevel SET: %s\n", DXError (hr)); + ddraw_fs_hack_free (); + return 0; + } + hr = IDirectDraw7_SetDisplayMode (ddraw, dpp.BackBufferWidth, dpp.BackBufferHeight, t_depth, dpp.FullScreen_RefreshRateInHz, 0); + if (FAILED (hr)) { + write_log (L"IDirectDraw7_SetDisplayMode: %s\n", DXError (hr)); + ddraw_fs_hack_free (); + return 0; + } + ddraw_fs = 2; + return 1; +} + static TCHAR *D3D_ErrorText (HRESULT error) { return L""; @@ -784,8 +835,8 @@ static int createsltexture (void) static int createmasktexture (TCHAR *filename) { - int ww = required_sl_texture_w; - int hh = required_sl_texture_h; + int ww = tin_w; + int hh = tin_h; struct zfile *zf; int size; uae_u8 *buf; @@ -793,12 +844,17 @@ static int createmasktexture (TCHAR *filename) LPDIRECT3DTEXTURE9 tx; HRESULT hr; D3DLOCKED_RECT lock, slock; + TCHAR tmp[MAX_DPATH]; tx = NULL; - zf = zfile_fopen (filename, L"rb", ZFD_NORMAL); + _stprintf (tmp, L"%s%soverlays\\%s", start_path_exe, WIN32_PLUGINDIR, filename); + zf = zfile_fopen (tmp, L"rb", ZFD_NORMAL); if (!zf) { - write_log (L"%s: couldn't open mask '%s'\n", filename); - return 0; + zf = zfile_fopen (filename, L"rb", ZFD_NORMAL); + if (!zf) { + write_log (L"%s: couldn't open mask '%s'\n", D3DHEAD, filename); + return 0; + } } size = zfile_size (zf); buf = (uae_u8*)xmalloc (size); @@ -818,7 +874,7 @@ static int createmasktexture (TCHAR *filename) write_log (L"%s: temp mask texture GetLevelDesc() failed: %s\n", D3DHEAD, D3D_ErrorString (hr)); goto end; } - masktexture = createtext (&ww, &hh, D3DFMT_A8R8G8B8); + masktexture = createtext (&ww, &hh, D3DFMT_X8R8G8B8); if (FAILED (hr)) { write_log (L"%s: mask texture creation failed: %s\n", D3DHEAD, D3D_ErrorString (hr)); goto end; @@ -832,20 +888,24 @@ static int createmasktexture (TCHAR *filename) if (SUCCEEDED (hr = tx->LockRect (0, &slock, NULL, 0))) { int x, y, sx, sy; uae_u32 *sptr, *ptr; - sx = 0; sy = 0; for (y = 0; y < maskdesc.Height; y++) { + sx = 0; for (x = 0; x < maskdesc.Width; x++) { + uae_u32 v; sptr = (uae_u32*)((uae_u8*)slock.pBits + sy * slock.Pitch + sx * 4); ptr = (uae_u32*)((uae_u8*)lock.pBits + y * lock.Pitch + x * 4); - *ptr = *sptr; + v = *sptr; +// v &= 0x00FFFFFF; +// v |= 0x80000000; + *ptr = v; sx++; if (sx >= tmpdesc.Width) - sx -= tmpdesc.Width; + sx = 0; } sy++; if (sy >= tmpdesc.Height) - sy -= tmpdesc.Height; + sy = 0; } tx->UnlockRect (0); } @@ -993,20 +1053,33 @@ static void createvertex (void) vertices[3].position.x = 0.5f; vertices[3].position.y = 0.5f; vertices[3].diffuse = 0xFFFFFFFF; vertices[3].texcoord.x = sizex; vertices[3].texcoord.y = 0.0f; + // fullscreen vertices + vertices[4].position.x = -0.5f; vertices[0].position.y = -0.5f; + vertices[4].diffuse = 0xFFFFFFFF; + vertices[4].texcoord.x = 0.0f; vertices[0].texcoord.y = 1.0f; + vertices[5].position.x = -0.5f; vertices[1].position.y = 0.5f; + vertices[5].diffuse = 0xFFFFFFFF; + vertices[5].texcoord.x = 0.0f; vertices[1].texcoord.y = 0.0f; + vertices[6].position.x = 0.5f; vertices[2].position.y = -0.5f; + vertices[6].diffuse = 0xFFFFFFFF; + vertices[6].texcoord.x = 1.0f; vertices[2].texcoord.y = 1.0f; + vertices[7].position.x = 0.5f; vertices[3].position.y = 0.5f; + vertices[7].diffuse = 0xFFFFFFFF; + vertices[7].texcoord.x = 1.0f; vertices[3].texcoord.y = 0.0f; // Additional vertices required for some PS effects if (psPreProcess) { - vertices[4].position.x = 0.0f; vertices[4].position.y = 0.0f; - vertices[4].diffuse = 0xFFFFFF00; - vertices[4].texcoord.x = 0.0f; vertices[4].texcoord.y = 1.0f; - vertices[5].position.x = 0.0f; vertices[5].position.y = 1.0f; - vertices[5].diffuse = 0xFFFFFF00; - vertices[5].texcoord.x = 0.0f; vertices[5].texcoord.y = 0.0f; - vertices[6].position.x = 1.0f; vertices[6].position.y = 0.0f; - vertices[6].diffuse = 0xFFFFFF00; - vertices[6].texcoord.x = 1.0f; vertices[6].texcoord.y = 1.0f; - vertices[7].position.x = 1.0f; vertices[7].position.y = 1.0f; - vertices[7].diffuse = 0xFFFFFF00; - vertices[7].texcoord.x = 1.0f; vertices[7].texcoord.y = 0.0f; + vertices[8].position.x = 0.0f; vertices[4].position.y = 0.0f; + vertices[8].diffuse = 0xFFFFFF00; + vertices[8].texcoord.x = 0.0f; vertices[4].texcoord.y = 1.0f; + vertices[9].position.x = 0.0f; vertices[5].position.y = 1.0f; + vertices[9].diffuse = 0xFFFFFF00; + vertices[9].texcoord.x = 0.0f; vertices[5].texcoord.y = 0.0f; + vertices[10].position.x = 1.0f; vertices[6].position.y = 0.0f; + vertices[10].diffuse = 0xFFFFFF00; + vertices[10].texcoord.x = 1.0f; vertices[6].texcoord.y = 1.0f; + vertices[11].position.x = 1.0f; vertices[7].position.y = 1.0f; + vertices[11].diffuse = 0xFFFFFF00; + vertices[11].texcoord.x = 1.0f; vertices[7].texcoord.y = 0.0f; } hr = IDirect3DVertexBuffer9_Unlock (vertexBuffer); } @@ -1015,22 +1088,30 @@ static void settransformsl (void) { HRESULT hr; + // Disable Shaders + hr = IDirect3DDevice9_SetVertexShader (d3ddev, 0); + hr = IDirect3DDevice9_SetPixelShader (d3ddev, 0); hr = IDirect3DDevice9_SetTransform (d3ddev, D3DTS_PROJECTION, &m_matProj); hr = IDirect3DDevice9_SetTransform (d3ddev, D3DTS_VIEW, &m_matView); hr = IDirect3DDevice9_SetTransform (d3ddev, D3DTS_WORLD, &m_matWorld); } -static void settransform (void) +static void settransformfs (void) { HRESULT hr; + // Disable Shaders + hr = IDirect3DDevice9_SetVertexShader (d3ddev, 0); + hr = IDirect3DDevice9_SetPixelShader (d3ddev, 0); + hr = IDirect3DDevice9_SetTransform (d3ddev, D3DTS_PROJECTION, &m_matProj2); + hr = IDirect3DDevice9_SetTransform (d3ddev, D3DTS_VIEW, &m_matView2); + hr = IDirect3DDevice9_SetTransform (d3ddev, D3DTS_WORLD, &m_matWorld2); +} + +static void settransform (void) +{ if (!psActive) { - // Disable Shaders - hr = IDirect3DDevice9_SetVertexShader (d3ddev, 0); - hr = IDirect3DDevice9_SetPixelShader (d3ddev, 0); - hr = IDirect3DDevice9_SetTransform (d3ddev, D3DTS_PROJECTION, &m_matProj); - hr = IDirect3DDevice9_SetTransform (d3ddev, D3DTS_VIEW, &m_matView); - hr = IDirect3DDevice9_SetTransform (d3ddev, D3DTS_WORLD, &m_matWorld); + settransformsl (); } else { if (psPreProcess) { // Projection is (0,0,0) -> (1,1,1) @@ -1111,7 +1192,7 @@ static void createscanlines (int force) static void invalidatedeviceobjects (void) { if (texture) { - IDirect3DTexture9_Release (texture); + texture->Release (); texture = NULL; } if (sprite) { @@ -1119,27 +1200,27 @@ static void invalidatedeviceobjects (void) sprite = NULL; } if (ledtexture) { - IDirect3DTexture9_Release (ledtexture); + ledtexture->Release (); ledtexture = NULL; } if (sltexture) { - IDirect3DTexture9_Release (sltexture); + sltexture->Release (); sltexture = NULL; } if (masktexture) { - IDirect3DTexture9_Release (masktexture); + masktexture->Release (); masktexture = NULL; } if (lpWorkTexture1) { - IDirect3DTexture9_Release (lpWorkTexture1); + lpWorkTexture1->Release (); lpWorkTexture1 = NULL; } if (lpWorkTexture2) { - IDirect3DTexture9_Release (lpWorkTexture2); + lpWorkTexture2->Release (); lpWorkTexture2 = NULL; } if (lpHq2xLookupTexture) { - IDirect3DVolumeTexture9_Release (lpHq2xLookupTexture); + lpHq2xLookupTexture->Release (); lpHq2xLookupTexture = NULL; } if (pEffect) { @@ -1187,9 +1268,9 @@ static int restoredeviceobjects (void) if (currprefs.gfx_filtermask[0]) createmasktexture (currprefs.gfx_filtermask); - vbsize = sizeof (struct TLVERTEX) * 4; + vbsize = sizeof (struct TLVERTEX) * 8; if (psPreProcess) - vbsize = sizeof (struct TLVERTEX) * 8; + vbsize = sizeof (struct TLVERTEX) * 12; hr = d3ddev->SetFVF (D3DFVF_TLVERTEX); if (FAILED (d3ddev->CreateVertexBuffer (vbsize, D3DUSAGE_WRITEONLY, D3DFVF_TLVERTEX, D3DPOOL_DEFAULT, &vertexBuffer, NULL))) { @@ -1213,16 +1294,16 @@ static int restoredeviceobjects (void) return 1; } -void D3D_free (void) +static void D3D_free2 (void) { D3D_clear (); invalidatedeviceobjects (); if (d3ddev) { - IDirect3DDevice9_Release (d3ddev); + d3ddev->Release (); d3ddev = NULL; } if (d3d) { - IDirect3D9_Release (d3d); + d3d->Release (); d3d = NULL; } d3d_enabled = 0; @@ -1233,6 +1314,12 @@ void D3D_free (void) changed_prefs.leds_on_screen = currprefs.leds_on_screen = currprefs.leds_on_screen & ~STATUSLINE_TARGET; } +void D3D_free (void) +{ + D3D_free2 (); + ddraw_fs_hack_free (); +} + const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth) { HRESULT ret, hr; @@ -1245,7 +1332,7 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth typedef HRESULT (WINAPI *LPDIRECT3DCREATE9EX)(UINT, IDirect3D9Ex**); LPDIRECT3DCREATE9EX d3dexp = NULL; - D3D_free (); + D3D_free2 (); D3D_canshaders (); d3d_enabled = 0; if (!currprefs.gfx_api) { @@ -1320,7 +1407,7 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; dpp.BackBufferWidth = w_w; dpp.BackBufferHeight = w_h; - dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; + dpp.PresentationInterval = dpp.Windowed ? D3DPRESENT_INTERVAL_IMMEDIATE : D3DPRESENT_INTERVAL_DEFAULT; modeex.Width = w_w; modeex.Height = w_h; @@ -1344,6 +1431,7 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth } d3dhwnd = ahwnd; + t_depth = depth; // Check if hardware vertex processing is available if(d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) @@ -1360,6 +1448,16 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth } if (FAILED (ret)) { _stprintf (errmsg, L"%s failed, %s\n", d3d_ex && D3DEX ? L"CreateDeviceEx" : L"CreateDevice", D3D_ErrorString (ret)); + if (ret == D3DERR_INVALIDCALL && dpp.Windowed == 0 && dpp.FullScreen_RefreshRateInHz && !ddraw_fs) { + write_log (L"%s\n", errmsg); + write_log (L"%s: Retrying fullscreen with DirectDraw\n", D3DHEAD); + if (ddraw_fs_hack_init ()) { + const TCHAR *err2 = D3D_init (ahwnd, w_w, w_h, t_w, t_h, depth); + if (err2) + ddraw_fs_hack_free (); + return err2; + } + } if (d3d_ex && D3DEX) { write_log (L"%s\n", errmsg); D3DEX = 0; @@ -1405,6 +1503,13 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth dpp.Windowed ? 0 : dpp.FullScreen_RefreshRateInHz, currprefs.gfx_avsync ? L" VSYNC" : L"" ); + if ((d3dCaps.PixelShaderVersion < 3 || d3dCaps.VertexShaderVersion < 3 || tex_pow2 || tex_square || !tex_dynamic || max_texture_w < 4096 || max_texture_h < 4096) && D3DEX) { + D3DEX = 0; + write_log (L"Disabling D3D9Ex\n"); + return D3D_init (ahwnd, w_w, w_h, t_w, t_h, depth); + } + + mult = S2X_getmult (); t_w *= mult; t_h *= mult; @@ -1424,7 +1529,6 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth changed_prefs.gfx_filter_scanlines = currprefs.gfx_filter_scanlines = 0; } - t_depth = depth; switch (depth) { case 32: @@ -1458,6 +1562,10 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth write_log (L"%s: LED D3DXSprite failed: %s\n", D3D_ErrorString (hr), D3DHEAD); } + MatrixOrthoOffCenterLH (&m_matProj2, 0, window_w, 0, window_h, 0.0f, 1.0f); + MatrixTranslation (&m_matView2, -0.5f + window_w / 2, 0.5f + window_h / 2, 0); + MatrixScaling (&m_matWorld2, window_w, window_h, 1.0f); + createscanlines (1); d3d_enabled = 1; return 0; @@ -1520,7 +1628,7 @@ void D3D_clear (void) if (!isd3d ()) return; for (i = 0; i < 2; i++) { - hr = d3ddev->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 0, 0); + hr = d3ddev->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, d3ddebug ? 0x80 : 0x00), 0, 0); hr = d3ddev->Present (NULL, NULL, NULL, NULL); } } @@ -1532,13 +1640,10 @@ static void D3D_render22 (int clear) if (!isd3d ()) return; - if (clear) { - setupscenescaled (); - } setupscenecoords (); settransform (); if (needclear || clear) { - hr = d3ddev->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 0, 0); + hr = d3ddev->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, d3ddebug ? 0x80 : 0x00, 0), 0, 0); if (FAILED (hr)) write_log (L"%s: Clear() failed: %s\n", D3DHEAD, D3D_ErrorString (hr)); needclear = 0; @@ -1547,6 +1652,7 @@ static void D3D_render22 (int clear) write_log (L"%s: BeginScene: %s\n", D3DHEAD, D3D_ErrorString (hr)); return; } + setupscenescaled (); if (window_h > tin_h || window_w > tin_w) { D3DRECT r[4]; int num; @@ -1575,7 +1681,7 @@ static void D3D_render22 (int clear) r[num].y2 = window_h; num++; } - d3ddev->Clear (num, r, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 0, 0); + d3ddev->Clear (num, r, D3DCLEAR_TARGET, D3DCOLOR_XRGB(d3ddebug ? 0x80 : 0x00, 0, 0), 0, 0); } if (psActive) { UINT uPasses, uPass; @@ -1608,7 +1714,7 @@ pass2: for (uPass = 0; uPass < uPasses; uPass++) { if (!psEffect_BeginPass (uPass)) return; - d3ddev->DrawPrimitive (D3DPT_TRIANGLESTRIP, 4, 2); + d3ddev->DrawPrimitive (D3DPT_TRIANGLESTRIP, 8, 2); psEffect_EndPass (); } if (!psEffect_End ()) @@ -1638,22 +1744,31 @@ pass2: } else { - hr = d3ddev->SetTexture (0, (IDirect3DBaseTexture9*)texture); + if (masktexture) { + hr = d3ddev->SetTexture (0, masktexture); + hr = d3ddev->SetTextureStageState (0, D3DTSS_TEXCOORDINDEX, 0); + hr = d3ddev->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); + hr = d3ddev->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE); + hr = d3ddev->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); + + hr = d3ddev->SetTexture (1, texture); + hr = d3ddev->SetTextureStageState (1, D3DTSS_TEXCOORDINDEX, 0); + hr = d3ddev->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_MODULATE); + hr = d3ddev->SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_TEXTURE); + hr = d3ddev->SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_CURRENT); + } else { + hr = d3ddev->SetTexture (0, texture); + } hr = d3ddev->DrawPrimitive (D3DPT_TRIANGLESTRIP, 0, 2); - } - if (sprite && (sltexture || ledtexture || masktexture)) { + if (sprite && (sltexture || ledtexture)) { D3DXVECTOR3 v; sprite->Begin (D3DXSPRITE_ALPHABLEND); if (sltexture) { v.x = v.y = v.z = 0; sprite->Draw (sltexture, NULL, NULL, &v, 0xffffffff); } - if (masktexture) { - v.x = v.y = v.z = 0; - sprite->Draw (masktexture, NULL, NULL, &v, 0xffffffff); - } if (ledtexture) { v.x = 0; v.y = window_h - TD_TOTAL_HEIGHT; @@ -1664,12 +1779,15 @@ pass2: } hr = d3ddev->EndScene (); + if (FAILED (hr)) + write_log (L"%s: EndScene() %s\n", D3DHEAD, D3D_ErrorString (hr)); hr = d3ddev->Present (NULL, NULL, NULL, NULL); - if (hr == D3DERR_DEVICELOST) { - write_log (L"%s: DEVICELOST\n", D3DHEAD); - devicelost = 1; + if (FAILED (hr)) { + write_log (L"%s: Present() %s\n", D3DHEAD, D3D_ErrorString (hr)); + if (hr == D3DERR_DEVICELOST) { + devicelost = 1; + } } - } static void D3D_render2 (int clear) @@ -1705,7 +1823,7 @@ uae_u8 *D3D_locktexture (int *pitch) if (!isd3d ()) return NULL; - if (currprefs.turbo_emulation && currprefs.gfx_avsync && frameskip-- > 0) + if (currprefs.turbo_emulation && isfullscreen () > 0 && frameskip-- > 0) return NULL; frameskip = 50; @@ -1713,11 +1831,8 @@ uae_u8 *D3D_locktexture (int *pitch) locked.Pitch = 0; hr = texture->LockRect (0, &locked, NULL, 0); if (FAILED (hr)) { - if (hr != D3DERR_DRIVERINTERNALERROR) { - write_log (L"%s: LockRect failed: %s\n", D3DHEAD, D3D_ErrorString (hr)); - D3D_unlocktexture (); - return NULL; - } + write_log (L"%s: LockRect failed: %s\n", D3DHEAD, D3D_ErrorString (hr)); + return NULL; } if (locked.pBits == NULL || locked.Pitch == 0) { write_log (L"%s: LockRect returned NULL texture\n", D3DHEAD); diff --git a/od-win32/mman.c b/od-win32/mman.c index c2dac551..db667367 100644 --- a/od-win32/mman.c +++ b/od-win32/mman.c @@ -16,6 +16,7 @@ #define BARRIER 32 #define MAXZ3MEM 0x7F000000 +#define MAXZ3MEM64 0xF0000000 static struct shmid_ds shmids[MAX_SHMID]; static int memwatchok = 0; @@ -231,8 +232,8 @@ end: else if (maxmem > 0) size64 = maxmem * 1024 * 1024; if (os_64bit) { - if (size64 > MAXZ3MEM) - size64 = MAXZ3MEM; + if (size64 > MAXZ3MEM64) + size64 = MAXZ3MEM64; } else { if (size64 > MAXZ3MEM) size64 = MAXZ3MEM; diff --git a/od-win32/parser.c b/od-win32/parser.c index de775518..77699a7e 100644 --- a/od-win32/parser.c +++ b/od-win32/parser.c @@ -54,8 +54,8 @@ #include "uaeipc.h" #include "xwin.h" -#include #include +#include #define MIN_PRTBYTES 10 @@ -78,31 +78,31 @@ static struct zfile *prtdump; static int psmode = 0; static HMODULE gsdll; -static gs_main_instance *gsinstance; +static void *gsinstance; static int gs_exitcode; typedef int (CALLBACK* GSAPI_REVISION)(gsapi_revision_t *pr, int len); static GSAPI_REVISION ptr_gsapi_revision; -typedef int (CALLBACK* GSAPI_NEW_INSTANCE)(gs_main_instance **pinstance, void *caller_handle); +typedef int (CALLBACK* GSAPI_NEW_INSTANCE)(void **pinstance, void *caller_handle); static GSAPI_NEW_INSTANCE ptr_gsapi_new_instance; -typedef void (CALLBACK* GSAPI_DELETE_INSTANCE)(gs_main_instance *instance); +typedef void (CALLBACK* GSAPI_DELETE_INSTANCE)(void *instance); static GSAPI_DELETE_INSTANCE ptr_gsapi_delete_instance; -typedef int (CALLBACK* GSAPI_SET_STDIO)(gs_main_instance *instance, +typedef int (CALLBACK* GSAPI_SET_STDIO)(void *instance, int (GSDLLCALLPTR stdin_fn)(void *caller_handle, char *buf, int len), int (GSDLLCALLPTR stdout_fn)(void *caller_handle, const char *str, int len), int (GSDLLCALLPTR stderr_fn)(void *caller_handle, const char *str, int len)); static GSAPI_SET_STDIO ptr_gsapi_set_stdio; -typedef int (CALLBACK* GSAPI_INIT_WITH_ARGS)(gs_main_instance *instance, int argc, char **argv); +typedef int (CALLBACK* GSAPI_INIT_WITH_ARGS)(void *instance, int argc, char **argv); static GSAPI_INIT_WITH_ARGS ptr_gsapi_init_with_args; -typedef int (CALLBACK* GSAPI_EXIT)(gs_main_instance *instance); +typedef int (CALLBACK* GSAPI_EXIT)(void *instance); static GSAPI_EXIT ptr_gsapi_exit; -typedef (CALLBACK* GSAPI_RUN_STRING_BEGIN)(gs_main_instance *instance, int user_errors, int *pexit_code); +typedef (CALLBACK* GSAPI_RUN_STRING_BEGIN)(void *instance, int user_errors, int *pexit_code); static GSAPI_RUN_STRING_BEGIN ptr_gsapi_run_string_begin; -typedef (CALLBACK* GSAPI_RUN_STRING_CONTINUE)(gs_main_instance *instance, const char *str, unsigned int length, int user_errors, int *pexit_code); +typedef (CALLBACK* GSAPI_RUN_STRING_CONTINUE)(void *instance, const char *str, unsigned int length, int user_errors, int *pexit_code); static GSAPI_RUN_STRING_CONTINUE ptr_gsapi_run_string_continue; -typedef (CALLBACK* GSAPI_RUN_STRING_END)(gs_main_instance *instance, int user_errors, int *pexit_code); +typedef (CALLBACK* GSAPI_RUN_STRING_END)(void *instance, int user_errors, int *pexit_code); static GSAPI_RUN_STRING_END ptr_gsapi_run_string_end; static uae_u8 **psbuffer; diff --git a/od-win32/prowizard/prowizard.vcproj b/od-win32/prowizard/prowizard.vcproj index 95e41ac5..2cb723c0 100644 --- a/od-win32/prowizard/prowizard.vcproj +++ b/od-win32/prowizard/prowizard.vcproj @@ -12,6 +12,9 @@ + @@ -148,6 +151,140 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/od-win32/resources/resource b/od-win32/resources/resource index e4efc72c..845f435e 100644 --- a/od-win32/resources/resource +++ b/od-win32/resources/resource @@ -764,6 +764,8 @@ #define IDC_MINIMIZED_PRI 1636 #define IDC_FILTERAUTOSCALE 1636 #define IDC_VOLUME_BOOTPRI_TEXT 1637 +#define IDC_FILTERAUTOSCALE2 1637 +#define IDC_FILTEROVERLAY 1637 #define IDC_VOLUME_BOOTPRI 1638 #define IDC_KBLED1 1639 #define IDC_KBLED2 1640 diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index 06b65b76..8ad1b52e 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -752,10 +752,10 @@ BEGIN COMBOBOX IDC_FILTERXTRA,105,151,138,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_FILTERASPECT,14,151,73,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP CONTROL "Keep aspect ratio",IDC_FILTERKEEPASPECT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,14,168,85,10 - RTEXT "Automatic scaling:",-1,9,38,79,10,SS_CENTERIMAGE COMBOBOX IDC_FILTERAUTOSCALE,132,36,83,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_FILTERASPECT2,14,180,73,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP CONTROL "Direct3D",IDC_FILTERD3D,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,38,63,10 + COMBOBOX IDC_FILTEROVERLAY,20,36,103,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP END IDD_HARDDRIVE DIALOGEX 0, 0, 380, 76 @@ -1478,7 +1478,7 @@ BEGIN IDS_TABLET_BOTH_CURSORS "Show both cursors" IDS_TABLET_NATIVE_CURSOR "Show native cursor only" IDS_TABLET_HOST_CURSOR "Show host cursor only" - IDS_AUTOSCALE_DISABLED "Disabled" + IDS_AUTOSCALE_DISABLED "No Autoscaling" IDS_AUTOSCALE_SCALING "Automatic scaling" IDS_AUTOSCALE_RESIZE "Automatic resize" IDS_PRINTER_ASCII "ASCII-Only" diff --git a/od-win32/resources/winuae64.exe.manifest b/od-win32/resources/winuae64.exe.manifest new file mode 100644 index 00000000..f9701443 --- /dev/null +++ b/od-win32/resources/winuae64.exe.manifest @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + diff --git a/od-win32/sysconfig.h b/od-win32/sysconfig.h index 302dcac0..39811815 100644 --- a/od-win32/sysconfig.h +++ b/od-win32/sysconfig.h @@ -100,6 +100,7 @@ #ifdef WIN64 #undef X86_MSVC_ASSEMBLY +#undef JIT #define X64_MSVC_ASSEMBLY #define CPU_64_BIT #define SIZEOF_VOID_P 8 diff --git a/od-win32/win32.c b/od-win32/win32.c index 6653d4f4..f033b587 100644 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -107,6 +107,7 @@ void *globalipc, *serialipc; int qpcdivisor = 0; int cpu_mmx = 1; static int userdtsc = 0; +int D3DEX = 1, d3ddebug = 0; HINSTANCE hInst = NULL; HMODULE hUIDLL = NULL; @@ -1266,7 +1267,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, } } - +#ifndef _WIN64 case WT_PROXIMITY: { send_tablet_proximity (LOWORD (lParam) ? 1 : 0); @@ -1299,7 +1300,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, } return 0; } - +#endif default: break; } @@ -1990,13 +1991,18 @@ void logging_init (void) logging_open (first ? 0 : 1, 0); logging_started = 1; first++; +#ifdef _WIN64 + wow64 = 1; +#else fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress (GetModuleHandle (L"kernel32"), "IsWow64Process"); if (fnIsWow64Process) fnIsWow64Process (GetCurrentProcess (), &wow64); +#endif write_log (L"%s (%d.%d %s%s[%d])", VersionStr, osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.szCSDVersion, _tcslen (osVersion.szCSDVersion) > 0 ? L" " : L"", os_winnt_admin); - write_log (L" %d-bit %X.%X %d", wow64 ? 64 : 32, + write_log (L" %d-bit %X.%X %d", + wow64 ? 64 : 32, SystemInfo.wProcessorLevel, SystemInfo.wProcessorRevision, SystemInfo.dwNumberOfProcessors); write_log (L"\n(c) 1995-2001 Bernd Schmidt - Core UAE concept and implementation." @@ -3856,11 +3862,17 @@ static void makeverstr (TCHAR *s) if (_tcslen (WINUAEBETA) > 0) { _stprintf (BetaStr, L" (%sBeta %s, %d.%02d.%02d)", WINUAEPUBLICBETA > 0 ? L"Public " : L"", WINUAEBETA, GETBDY(WINUAEDATE), GETBDM(WINUAEDATE), GETBDD(WINUAEDATE)); +#ifdef _WIN64 + _tcscat (BetaStr, L" 64-bit"); +#endif _stprintf (s, L"WinUAE %d.%d.%d%s%s", UAEMAJOR, UAEMINOR, UAESUBREV, WINUAEREV, BetaStr); } else { _stprintf (s, L"WinUAE %d.%d.%d%s (%d.%02d.%02d)", UAEMAJOR, UAEMINOR, UAESUBREV, WINUAEREV, GETBDY(WINUAEDATE), GETBDM(WINUAEDATE), GETBDD(WINUAEDATE)); +#ifdef _WIN64 + _tcscat (s, L" 64-bit"); +#endif } if (_tcslen (WINUAEEXTRA) > 0) { _tcscat (s, L" "); @@ -3969,6 +3981,14 @@ static int parseargs (const TCHAR *arg, const TCHAR *np, const TCHAR *np2) ddsoftwarecolorkey = 1; return 1; } + if (!_tcscmp (arg, L"-nod3d9ex")) { + D3DEX = 0; + return 1; + } + if (!_tcscmp (arg, L"-d3ddebug")) { + d3ddebug = 1; + return 1; + } if (!_tcscmp (arg, L"-logflush")) { extern int always_flush_log; always_flush_log = 1; @@ -4398,9 +4418,9 @@ int driveclick_loadresource (struct drvsample *sp, int drivetype) return ok; } -#if defined(WIN64) +#if defined(_WIN64) -static LONG WINAPI WIN32_ExceptionFilter( struct _EXCEPTION_POINTERS * pExceptionPointers, DWORD ec) +LONG WINAPI WIN32_ExceptionFilter (struct _EXCEPTION_POINTERS * pExceptionPointers, DWORD ec) { write_log (L"EVALEXCEPTION!\n"); return EXCEPTION_EXECUTE_HANDLER; @@ -4726,21 +4746,21 @@ HMODULE WIN32_LoadLibrary_2 (const TCHAR *name, int expand) switch(round) { case 0: - p = strstr (newname,"32"); + p = _tcsstr (newname, L"32"); if (p) { p[0] = '6'; p[1] = '4'; } break; case 1: - p = strchr (newname,'.'); - _tcscpy(p,"_64"); - _tcscat(p, strchr (name,'.')); + p = _tcschr (newname, '.'); + _tcscpy(p, L"_64"); + _tcscat(p, _tcschr (name, '.')); break; case 2: - p = strchr (newname,'.'); - _tcscpy (p,"64"); - _tcscat (p, strchr (name,'.')); + p = _tcschr (newname, '.'); + _tcscpy (p, L"64"); + _tcscat (p, _tcschr (name, '.')); break; } #endif @@ -4858,14 +4878,18 @@ uae_u32 emulib_target_getcpurate (uae_u32 v, uae_u32 *low) void fpux_save (int *v) { +#ifndef _WIN64 *v = _controlfp (fpucontrol, _MCW_IC | _MCW_RC | _MCW_PC); +#endif } void fpux_restore (int *v) { +#ifndef _WIN64 if (v) _controlfp (*v, _MCW_IC | _MCW_RC | _MCW_PC); else _controlfp (fpucontrol, _MCW_IC | _MCW_RC | _MCW_PC); +#endif } typedef BOOL (CALLBACK* SETPROCESSDPIAWARE)(void); diff --git a/od-win32/win32.h b/od-win32/win32.h index 5731b295..61bf955a 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -18,8 +18,8 @@ #define WINUAEPUBLICBETA 1 #define LANG_DLL 1 -#define WINUAEBETA L"Beta 7" -#define WINUAEDATE MAKEBD(2010, 1, 30) +#define WINUAEBETA L"8" +#define WINUAEDATE MAKEBD(2010, 2, 6) #define WINUAEEXTRA L"" #define WINUAEREV L"" diff --git a/od-win32/win32_filesys.c b/od-win32/win32_filesys.c index 2f9d5582..3be4f488 100644 --- a/od-win32/win32_filesys.c +++ b/od-win32/win32_filesys.c @@ -55,6 +55,8 @@ int target_get_volume_name (struct uaedev_mount_info *mtinf, const TCHAR *volume _tcscpy (volumename, L"AmigaOS3.5"); if(!_tcscmp (volumename, L"AmigaOS39")) _tcscpy (volumename, L"AmigaOS3.9"); + if(!_tcscmp (volumename, L"AmigaOS_XL")) + _tcscpy (volumename, L"AmigaOS XL"); // ---Bernd Roesch if (_tcslen (volumename) > 0) result = 1; diff --git a/od-win32/win32_scale2x.c b/od-win32/win32_scale2x.c index 6635d58a..dcf4e5b9 100644 --- a/od-win32/win32_scale2x.c +++ b/od-win32/win32_scale2x.c @@ -604,6 +604,8 @@ void S2X_render (void) } else if (usedfilter->type == UAE_FILTER_HQ) { /* 32/2X+3X+4X */ +#ifndef CPU_64_BIT + if (tempsurf2 && scale >= 2 && scale <= 4) { /* Aaaaaaaarghhhghgh.. */ uae_u8 *sptr2 = tempsurf3; @@ -641,6 +643,7 @@ void S2X_render (void) dptr += pitch; } } +#endif } else if (usedfilter->type == UAE_FILTER_SUPEREAGLE) { /* 16/32/2X */ diff --git a/od-win32/win32gfx.c b/od-win32/win32gfx.c index dbfc8969..654a2b4a 100644 --- a/od-win32/win32gfx.c +++ b/od-win32/win32gfx.c @@ -1196,10 +1196,11 @@ int check_prefs_changed_gfx (void) c |= currprefs.gfx_pvsync != changed_prefs.gfx_pvsync ? 2 | 16 : 0; c |= currprefs.gfx_refreshrate != changed_prefs.gfx_refreshrate ? 2 | 16 : 0; c |= currprefs.gfx_autoresolution != changed_prefs.gfx_autoresolution ? (2|8) : 0; - c |= currprefs.gfx_api != changed_prefs.gfx_api ? (1|8) : 0; + c |= currprefs.gfx_api != changed_prefs.gfx_api ? (1|8|32) : 0; c |= currprefs.gfx_filter != changed_prefs.gfx_filter ? (2|8) : 0; c |= _tcscmp (currprefs.gfx_filtershader, changed_prefs.gfx_filtershader) ? (2|8) : 0; + c |= _tcscmp (currprefs.gfx_filtermask, changed_prefs.gfx_filtermask) ? (2|8) : 0; c |= currprefs.gfx_filter_filtermode != changed_prefs.gfx_filter_filtermode ? (2|8) : 0; c |= currprefs.gfx_filter_bilinear != changed_prefs.gfx_filter_bilinear ? (2|8) : 0; c |= currprefs.gfx_filter_horiz_zoom_mult != changed_prefs.gfx_filter_horiz_zoom_mult ? (1|8) : 0; @@ -1257,6 +1258,7 @@ int check_prefs_changed_gfx (void) currprefs.gfx_filter = changed_prefs.gfx_filter; _tcscpy (currprefs.gfx_filtershader, changed_prefs.gfx_filtershader); + _tcscpy (currprefs.gfx_filtermask, changed_prefs.gfx_filtermask); currprefs.gfx_filter_filtermode = changed_prefs.gfx_filter_filtermode; currprefs.gfx_filter_bilinear = changed_prefs.gfx_filter_bilinear; currprefs.gfx_filter_horiz_zoom_mult = changed_prefs.gfx_filter_horiz_zoom_mult; diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index 847b2e3c..ba99b72c 100644 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -889,7 +889,7 @@ static HWND cachedlist = NULL; #define MIN_SLOW_MEM 0 #define MAX_SLOW_MEM 4 #define MIN_Z3_MEM 0 -#define MAX_Z3_MEM ((max_z3fastmem >> 20) < 512 ? 12 : ((max_z3fastmem >> 20) < 1024 ? 13 : ((max_z3fastmem >> 20) < 2048) ? 14 : 16)) +#define MAX_Z3_MEM ((max_z3fastmem >> 20) < 512 ? 12 : ((max_z3fastmem >> 20) < 1024 ? 13 : ((max_z3fastmem >> 20) < 2048) ? 14 : ((max_z3fastmem >> 20) < 2560) ? 15 : ((max_z3fastmem >> 20) < 3072) ? 16 : 17)) #define MIN_P96_MEM 0 #define MAX_P96_MEM ((max_z3fastmem >> 20) < 512 ? 8 : ((max_z3fastmem >> 20) < 1024 ? 9 : ((max_z3fastmem >> 20) < 2048) ? 10 : 11)) #define MIN_MB_MEM 0 @@ -2062,6 +2062,7 @@ static BOOL CreateHardFile (HWND hDlg, UINT hfsizem, TCHAR *dostype, TCHAR *newp outpath[0] = 0; sparse = 0; dynamic = 0; + dt = 0; hfsize = (uae_u64)hfsizem * 1024 * 1024; if (IsDlgButtonChecked (hDlg, IDC_HF_SPARSE) == BST_CHECKED) sparse = 1; @@ -2074,7 +2075,9 @@ static BOOL CreateHardFile (HWND hDlg, UINT hfsizem, TCHAR *dostype, TCHAR *newp GetDlgItemText (hDlg, IDC_PATH_NAME, init_path, MAX_DPATH); if (*init_path && hfsize) { if (dynamic) { - result = vhd_create (init_path, hfsize); + if (!_stscanf (dostype, L"%x", &dt)) + dt = 0; + result = vhd_create (init_path, hfsize, dt); } else { SetCursor (LoadCursor (NULL, IDC_WAIT)); if ((hf = CreateFile (init_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) { @@ -2149,6 +2152,8 @@ static const TCHAR *memsize_names[] = { /* 17*/ L"384 MB", /* 18*/ L"768 MB", /* 19*/ L"1.5 GB", + /* 20*/ L"2.5 GB", + /* 21*/ L"3 GB" }; static unsigned long memsizes[] = { @@ -2172,12 +2177,14 @@ static unsigned long memsizes[] = { /* 17*/ 0x18000000, //384M /* 18*/ 0x30000000, //768M /* 19*/ 0x60000000, //1.5GB + /* 20*/ 0xA8000000, //2.5GB + /* 21*/ 0xC0000000, //3GB }; static int msi_chip[] = { 1, 2, 3, 14, 4, 5, 6 }; static int msi_bogo[] = { 0, 2, 3, 14, 15 }; static int msi_fast[] = { 0, 3, 4, 5, 6 }; -static int msi_z3fast[] = { 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 17, 12, 18, 13, 19, 16 }; +static int msi_z3fast[] = { 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 17, 12, 18, 13, 19, 16, 20, 21 }; static int msi_gfx[] = { 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; static int CalculateHardfileSize (HWND hDlg) @@ -5811,14 +5818,18 @@ static void values_to_memorydlg (HWND hDlg) mem_size = 10; else if (v < 0x30000000) mem_size = 11; - else if (v < 0x40000000) + else if (v < 0x40000000) // 1GB mem_size = 12; - else if (v < 0x60000000) + else if (v < 0x60000000) // 1.5GB mem_size = 13; - else if (v < 0x80000000) + else if (v < 0x80000000) // 2GB mem_size = 14; - else + else if (v < 0xA8000000) // 2.5GB mem_size = 15; + else if (v < 0xC0000000) // 3GB + mem_size = 16; + else + mem_size = 17; SendDlgItemMessage (hDlg, IDC_Z3FASTMEM, TBM_SETPOS, TRUE, mem_size); SetDlgItemText (hDlg, IDC_Z3FASTRAM, memsize_names[msi_z3fast[mem_size]]); @@ -5929,6 +5940,12 @@ static void updatez3 (uae_u32 *size1p, uae_u32 *size2p) int i; uae_u32 s1, s2; + // no 2GB Z3 size so we need 2x1G + if (*size1p >= 0x80000000) { + *size2p = *size1p - 0x40000000; + *size1p = 0x40000000; + return; + } s1 = *size1p; *size1p = 0; *size2p = 0; @@ -7007,7 +7024,7 @@ static void enable_for_cpudlg (HWND hDlg) ew (hDlg, IDC_NOFLAGS, enable); ew (hDlg, IDC_CS_CACHE_TEXT, enable); ew (hDlg, IDC_CACHE, enable); - ew (hDlg, IDC_JITENABLE, cpu_based_enable); + ew (hDlg, IDC_JITENABLE, cpu_based_enable && enable); ew (hDlg, IDC_COMPATIBLE, !workprefs.cpu_cycle_exact && !workprefs.cachesize); ew (hDlg, IDC_COMPATIBLE_FPU, workprefs.fpu_model > 0); #if 0 @@ -10715,6 +10732,7 @@ static void enable_for_hw3ddlg (HWND hDlg) ew (hDlg, IDC_FILTERKEEPASPECT, v); ew (hDlg, IDC_FILTERASPECT, v); ew (hDlg, IDC_FILTERASPECT2, v && workprefs.gfx_filter_keep_aspect); + ew (hDlg, IDC_FILTEROVERLAY, workprefs.gfx_api && !workprefs.gfx_filtershader[0]); ew (hDlg, IDC_FILTERPRESETSAVE, filterpreset_builtin < 0); ew (hDlg, IDC_FILTERPRESETLOAD, filterpreset_selected > 0); @@ -10891,9 +10909,12 @@ static void values_to_hw3ddlg (HWND hDlg) SendDlgItemMessage (hDlg, IDC_FILTERVO, TBM_SETRANGE, TRUE, MAKELONG (-999, +999)); SendDlgItemMessage (hDlg, IDC_FILTERVO, TBM_SETPAGESIZE, 0, 1); + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_RESETCONTENT, 0, 0L); SendDlgItemMessage (hDlg, IDC_FILTERMODE, CB_RESETCONTENT, 0, 0L); WIN32GUI_LoadUIString (IDS_NONE, tmp, MAX_DPATH); SendDlgItemMessage (hDlg, IDC_FILTERMODE, CB_ADDSTRING, 0, (LPARAM)tmp); + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_ADDSTRING, 0, (LPARAM)tmp); + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_SETCURSEL, 0, 0); uf = NULL; fltnum = 0; i = 0; j = 1; @@ -10925,6 +10946,26 @@ static void values_to_hw3ddlg (HWND hDlg) h = INVALID_HANDLE_VALUE; } } + _stprintf (tmp, L"%s%soverlays\\*.*", start_path_exe, WIN32_PLUGINDIR); + h = FindFirstFile (tmp, &wfd); + i = 0; j = 1; + while (h != INVALID_HANDLE_VALUE) { + TCHAR *ext = _tcsrchr (wfd.cFileName, '.'); + if (ext && ( + !_tcsicmp (ext, L".png") || + !_tcsicmp (ext, L".bmp"))) + { + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_ADDSTRING, 0, (LPARAM)wfd.cFileName); + if (!_tcsicmp (wfd.cFileName, workprefs.gfx_filtermask)) + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_SETCURSEL, j, 0); + j++; + + } + if (!FindNextFile (h, &wfd)) { + FindClose (h); + h = INVALID_HANDLE_VALUE; + } + } } SendDlgItemMessage (hDlg, IDC_FILTERMODE, CB_SETCURSEL, fltnum, 0); @@ -11177,6 +11218,19 @@ static void filter_handle (HWND hDlg) if (workprefs.gfx_filter == 0 && !workprefs.gfx_api) workprefs.gfx_filter_autoscale = 0; } + item = SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_GETCURSEL, 0, 0L); + if (item != CB_ERR) { + TCHAR tmp[MAX_DPATH]; + tmp[0] = 0; + if (item > 0) { + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_GETLBTEXT, (WPARAM)item, (LPARAM)tmp); + if (_tcsicmp (workprefs.gfx_filtermask, tmp)) { + _tcscpy (workprefs.gfx_filtermask, tmp); + } + } else { + workprefs.gfx_filtermask[0] = 0; + } + } enable_for_hw3ddlg (hDlg); updatedisplayarea (); } @@ -11301,6 +11355,7 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM break; case IDC_FILTERMODE: case IDC_FILTERFILTER: + case IDC_FILTEROVERLAY: filter_handle (hDlg); values_to_hw3ddlg (hDlg); break; diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index 18273ede..b59c515e 100644 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -20,8 +20,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -675,6 +108,7 @@ /> @@ -1206,25 +668,27 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \plugins\overlays +- DMS files with fake complete first cyl (containing BBS ads) didn't + unpack correctly. Support HD DMS files (not tested) +- CE interrupt handling rewritten (still not good enough) + Beta 7: - Direct3D errors didn't properly reset back to non-D3D mode diff --git a/uaeunp.c b/uaeunp.c index 86b6c797..2d50bc5c 100644 --- a/uaeunp.c +++ b/uaeunp.c @@ -698,7 +698,7 @@ int wmain (int argc, wchar_t *argv[], wchar_t *envp[]) ok = 1; } if (!ok) { - _tprintf (L"UAE unpacker uaeunp 0.8 by Toni Wilen (c)2009\n"); + _tprintf (L"UAE unpacker uaeunp 0.8b by Toni Wilen (c)2010\n"); _tprintf (L"\n"); _tprintf (L"List: \"uaeunp (-l) \"\n"); _tprintf (L"List all recursively: \"uaeunp -l **\"\n"); -- 2.47.3