From 471bde71544c78f90cd270d5948e8e343b6be461 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Thu, 2 Aug 2012 09:51:11 +0300 Subject: [PATCH] 2420b9 --- cfgfile.cpp | 3 +- cia.cpp | 13 +- custom.cpp | 89 ++++++++++---- debug.cpp | 179 ++++++++++++++++++++++------ expansion.cpp | 37 +++--- fpp.cpp | 53 ++++++--- gencpu.cpp | 7 ++ include/cia.h | 1 + include/debug.h | 1 + include/gfxfilter.h | 2 + include/memory.h | 2 + include/newcpu.h | 1 + include/readcpu.h | 4 +- include/sysdeps.h | 1 + main.cpp | 8 ++ memory.cpp | 115 +++++++++--------- newcpu.cpp | 80 ++++++++++--- od-win32/avioutput.cpp | 24 +++- od-win32/blkdev_win32_ioctl.cpp | 59 ++++++++- od-win32/direct3d.cpp | 8 +- od-win32/hardfile_win32.cpp | 28 +---- od-win32/mman.cpp | 130 +++++++++----------- od-win32/picasso96_win.cpp | 181 +++++++++++++++++++++------- od-win32/screenshot.cpp | 204 ++++++++++++++++++++------------ od-win32/sys/mman.h | 1 + od-win32/win32.cpp | 1 + od-win32/win32.h | 4 +- od-win32/win32gui.cpp | 4 +- od-win32/winuaechangelog.txt | 34 ++++++ od-win32/writelog.cpp | 12 ++ readcpu.cpp | 25 +--- table68k | 13 +- 32 files changed, 878 insertions(+), 446 deletions(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index 866d4877..321e89c5 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -584,7 +584,8 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write (f, _T("config_version"), _T("%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV); cfgfile_write_str (f, _T("config_hardware_path"), p->config_hardware_path); cfgfile_write_str (f, _T("config_host_path"), p->config_host_path); - cfgfile_write_str (f, _T("config_window_title"), p->config_window_title); + if (p->config_window_title[0]) + cfgfile_write_str (f, _T("config_window_title"), p->config_window_title); for (sl = p->all_lines; sl; sl = sl->next) { if (sl->unknown) { diff --git a/cia.cpp b/cia.cpp index 33718d3a..fb5a39a6 100644 --- a/cia.cpp +++ b/cia.cpp @@ -1317,6 +1317,11 @@ static void WriteCIAB (uae_u16 addr, uae_u8 val) } } +void cia_set_overlay (bool overlay) +{ + oldovl = overlay; +} + void CIA_reset (void) { #ifdef TOD_HACK @@ -1329,12 +1334,12 @@ void CIA_reset (void) kblostsynccnt = 0; serbits = 0; - oldovl = 1; oldcd32mute = 1; oldled = true; resetwarning_phase = resetwarning_timer = 0; if (!savestate_state) { + oldovl = true; kbstate = 0; ciaatlatch = ciabtlatch = 0; ciaapra = 0; ciaadra = 0; @@ -1357,10 +1362,12 @@ void CIA_reset (void) serial_dtr_off (); /* Drop DTR at reset */ #endif if (savestate_state) { + if (currprefs.cs_ciaoverlay) { + oldovl = true; + } bfe001_change (); if (!currprefs.cs_ciaoverlay) { - map_overlay (1); - oldovl = false; + map_overlay (oldovl ? 0 : 1); } } #ifdef CD32 diff --git a/custom.cpp b/custom.cpp index aea397d2..0b770e7a 100644 --- a/custom.cpp +++ b/custom.cpp @@ -246,7 +246,7 @@ uae_u8 cycle_line[256]; #endif static uae_u16 bplxdat[8]; -static int bpl1dat_written, bpl1dat_early; +static bool bpl1dat_written, bpl1dat_early, bpl1dat_written_at_least_once; static uae_s16 bpl1mod, bpl2mod; static uaecptr prevbpl[2][MAXVPOS][8]; static uaecptr bplpt[8], bplptx[8]; @@ -1062,7 +1062,7 @@ STATIC_INLINE void maybe_first_bpl1dat (int hpos) // early bpl1dat crap fix (Sequential engine animation) if (plfleft_real < 0) { int i; - for (i = 0; i < thisline_decision.nr_planes; i++) { + for (i = 0; i < MAX_PLANES; i++) { todisplay[i][0] = 0; #ifdef AGA todisplay[i][1] = 0; @@ -1071,7 +1071,7 @@ STATIC_INLINE void maybe_first_bpl1dat (int hpos) #endif } plfleft_real = hpos; - bpl1dat_early = 1; + bpl1dat_early = true; } } else { plfleft_real = thisline_decision.plfleft = hpos; @@ -1086,7 +1086,7 @@ STATIC_INLINE void fetch (int nr, int fm, int hpos) bplpt[nr] += 2 << fm; bplptx[nr] += 2 << fm; if (nr == 0) - bpl1dat_written = 1; + bpl1dat_written = true; #ifdef DEBUGGER if (debug_dma) record_dma (0x110 + nr * 2, chipmem_wget_indirect (p), p, hpos, vpos, DMARECORD_BITPLANE); @@ -1641,7 +1641,7 @@ STATIC_INLINE int one_fetch_cycle_0 (int pos, int ddfstop_to_test, int dma, int // and we must not draw anything at all in next dma block if this happens // (Disposable Hero titlescreen) fetch_state = fetch_was_plane0; - bpl1dat_written = 0; + bpl1dat_written = false; } fetch_cycle++; @@ -1673,7 +1673,19 @@ STATIC_INLINE int one_fetch_cycle (int pos, int ddfstop_to_test, int dma, int fm } } -static void update_fetch_x (int hpos, int fm) +static void update_bpldats (int hpos) +{ + for (int i = 0; i < MAX_PLANES; i++) { +#ifdef AGA + fetched_aga0[i] = bplxdat[i]; + fetched_aga1[i] = 0; +#endif + fetched[i] = bplxdat[i]; + } + beginning_of_plane_block (hpos, fetchmode); +} + +static void update_fetch_x (int until, int fm) { int pos; @@ -1682,23 +1694,27 @@ static void update_fetch_x (int hpos, int fm) pos = last_fetch_hpos; update_toscr_planes (); - for (int i = 0; i < 8; i++) - fetched[i] = bplxdat[i]; - beginning_of_plane_block (hpos, fm); - for (; pos < hpos; pos++) { + + // not optimized, update_fetch_x() is extremely rarely used. + for (; pos < until; pos++) { toscr_nbits += 2 << toscr_res; if (toscr_nbits > 16) { - uae_abort (_T("toscr_nbits > 16 (%d)"), toscr_nbits); + uae_abort (_T("xtoscr_nbits > 16 (%d)"), toscr_nbits); toscr_nbits = 0; } if (toscr_nbits == 16) flush_display (fm); } + + if (until >= maxhpos) { + finish_final_fetch (pos, fm); + return; + } + flush_display (fm); - bpl1dat_written = 0; } STATIC_INLINE void update_fetch (int until, int fm) @@ -1828,15 +1844,24 @@ STATIC_INLINE void decide_fetch (int hpos) #endif default: uae_abort (_T("fetchmode corrupt")); } - } else if (0 && bpl1dat_written) { - // "pio" mode display + } else if (bpl1dat_written_at_least_once) { + // "PIO" mode display update_fetch_x (hpos, fetchmode); + bpl1dat_written = false; } maybe_check (hpos); last_fetch_hpos = hpos; } } +static void reset_bpl_vars (void) +{ + out_nbits = 0; + out_offs = 0; + toscr_nbits = 0; + thisline_decision.bplres = bplcon0_res; +} + static void start_bpl_dma (int hpos, int hstart) { if (first_bpl_vpos < 0) @@ -1858,10 +1883,7 @@ static void start_bpl_dma (int hpos, int hstart) fetch_cycle = 0; last_fetch_hpos = hstart; cycle_diagram_shift = last_fetch_hpos; - out_nbits = 0; - out_offs = 0; - toscr_nbits = 0; - thisline_decision.bplres = bplcon0_res; + reset_bpl_vars (); ddfstate = DIW_waiting_stop; compute_toscr_delay (last_fetch_hpos, bplcon1); @@ -2642,8 +2664,9 @@ static void reset_decisions (void) toscr_nr_planes = toscr_nr_planes2 = 0; thisline_decision.bplres = bplcon0_res; thisline_decision.nr_planes = 0; - bpl1dat_written = 0; - bpl1dat_early = 0; + bpl1dat_written = false; + bpl1dat_written_at_least_once = false; + bpl1dat_early = false; plfleft_real = -1; thisline_decision.plfleft = -1; @@ -3928,19 +3951,23 @@ static void BPL2MOD (int hpos, uae_u16 v) bpl2mod = v; } -/* needed in special OCS/ECS "7-plane" mode. */ -/* (in reality only BPL0DAT, BPL5DAT and BPL6DAT needed) */ +/* Needed in special OCS/ECS "7-plane" mode, + * also handles CPU generated bitplane data + */ static void BPLxDAT (int hpos, int num, uae_u16 v) { decide_line (hpos); decide_fetch (hpos); bplxdat[num] = v; if (num == 0) { - bpl1dat_written = 1; + bpl1dat_written = true; + bpl1dat_written_at_least_once = true; if (thisline_decision.plfleft < 0) { thisline_decision.plfleft = hpos; + reset_bpl_vars (); compute_delay_offset (); } + update_bpldats (hpos); } } @@ -4463,7 +4490,7 @@ think, the documentation is pretty clear on this). /* Determine which cycles are available for the copper in a display * with a agiven number of planes. */ -STATIC_INLINE int copper_cant_read (int hpos, int alloc) +STATIC_INLINE int copper_cant_read2 (int hpos, int alloc) { if (hpos + 1 >= maxhpos) // first refresh slot return 1; @@ -4475,6 +4502,14 @@ STATIC_INLINE int copper_cant_read (int hpos, int alloc) return is_bitplane_dma_inline (hpos); } +static int copper_cant_read (int hpos, int alloc) +{ + int cant = copper_cant_read2 (hpos, alloc); + if (cant && debug_dma) + record_dma_event (DMA_EVENT_COPPERWANTED, hpos, vpos); + return cant; +} + static int custom_wput_copper (int hpos, uaecptr addr, uae_u32 value, int noget) { int v; @@ -4714,6 +4749,7 @@ static void update_copper (int until_hpos) break; case COP_wait1: +#if 0 /* There's a nasty case here. As stated in the "Theory" comment above, we test against the incremented copper position. I believe this means that we have to increment the _vertical_ position at the last cycle in the line, @@ -4730,7 +4766,7 @@ static void update_copper (int until_hpos) this hack: defer the entire decision until the next line if necessary. */ if (c_hpos >= (maxhpos & ~1) || (c_hpos & 1)) break; - +#endif cop_state.state = COP_wait; cop_state.vcmp = (cop_state.saved_i1 & (cop_state.saved_i2 | 0x8000)) >> 8; @@ -7576,6 +7612,7 @@ uae_u8 *restore_custom_extra (uae_u8 *src) if (!(v & 1)) v = 0; currprefs.cs_compatible = changed_prefs.cs_compatible = v >> 24; + cia_set_overlay ((v & 2) != 0); currprefs.genlock = changed_prefs.genlock = RBB; currprefs.cs_rtc = changed_prefs.cs_rtc = RB; @@ -7627,7 +7664,7 @@ uae_u8 *save_custom_extra (int *len, uae_u8 *dstptr) else dstbak = dst = xmalloc (uae_u8, 1000); - SL ((currprefs.cs_compatible << 24) | 1); + SL ((currprefs.cs_compatible << 24) | (&get_mem_bank (0) != &chipmem_bank ? 2 : 0) | 1); SB (currprefs.genlock ? 1 : 0); SB (currprefs.cs_rtc); SL (currprefs.cs_rtc_adjust); diff --git a/debug.cpp b/debug.cpp index e1e42d7d..08a3c72c 100644 --- a/debug.cpp +++ b/debug.cpp @@ -121,7 +121,8 @@ static TCHAR help[] = { _T(" Cl List currently found trainer addresses.\n") _T(" D[idxzs <[max diff]>] Deep trainer. i=new value must be larger, d=smaller,\n") _T(" x = must be same, z = must be different, s = restart.\n") - _T(" W
Write into Amiga memory.\n") + _T(" W
Write into Amiga memory.\n") + _T(" W
'string' Write into Amiga memory.\n") _T(" w
[[.x]] (read/write/opcode/freeze/mustchange).\n") _T(" Add/remove memory watchpoints.\n") _T(" wd [<0-1>] Enable illegal access logger. 1 = enable break.\n") @@ -141,7 +142,7 @@ static TCHAR help[] = { _T(" dm Dump current address space map.\n") _T(" v [] Show DMA data (accurate only in cycle-exact mode).\n") _T(" v [-1 to -4] = enable visual DMA debugger.\n") - _T(" ? Hex/Bin/Dec converter.\n") + _T(" ? Hex ($ and 0x)/Bin (%)/Dec (!) converter.\n") #ifdef _WIN32 _T(" x Close debugger.\n") _T(" xx Switch between console and GUI debugger.\n") @@ -176,6 +177,19 @@ static int debug_out (const TCHAR *format, ...) return 1; } +static bool iscancel (int counter) +{ + static int cnt; + + cnt++; + if (cnt < counter) + return false; + cnt = 0; + if (!console_isch ()) + return false; + console_getch (); + return true; +} static bool isoperator(TCHAR **cp) { @@ -271,29 +285,37 @@ static int readregx (TCHAR **c, uae_u32 *valp) return 1; } -static uae_u32 readbinx (TCHAR **c) +static bool readbinx (TCHAR **c, uae_u32 *valp) { uae_u32 val = 0; + bool first = true; ignore_ws (c); for (;;) { TCHAR nc = **c; - if (nc != '1' && nc != '0') + if (nc != '1' && nc != '0') { + if (first) + return false; break; + } + first = false; (*c)++; val <<= 1; if (nc == '1') val |= 1; } - return val; + *valp = val; + return true; } -static uae_u32 readhexx (TCHAR **c) +static bool readhexx (TCHAR **c, uae_u32 *valp) { uae_u32 val = 0; TCHAR nc; ignore_ws (c); + if (!isxdigit (peekchar (c))) + return false; while (isxdigit (nc = **c)) { (*c)++; val *= 16; @@ -304,10 +326,11 @@ static uae_u32 readhexx (TCHAR **c) val += nc - 'A' + 10; } } - return val; + *valp = val; + return true; } -static uae_u32 readintx (TCHAR **c) +static bool readintx (TCHAR **c, uae_u32 *valp) { uae_u32 val = 0; TCHAR nc; @@ -316,12 +339,15 @@ static uae_u32 readintx (TCHAR **c) ignore_ws (c); if (**c == '-') negative = 1, (*c)++; + if (!isdigit (peekchar (c))) + return false; while (isdigit (nc = **c)) { (*c)++; val *= 10; val += nc - '0'; } - return val * (negative ? -1 : 1); + *valp = val * (negative ? -1 : 1); + return true; } @@ -333,37 +359,31 @@ static int checkvaltype2 (TCHAR **c, uae_u32 *val, TCHAR def) nc = _totupper (**c); if (nc == '!') { (*c)++; - *val = readintx (c); - return 1; + return readintx (c, val) ? 1 : 0; } if (nc == '$') { (*c)++; - *val = readhexx (c); - return 1; + return readhexx (c, val) ? 1 : 0; } if (nc == '0' && _totupper ((*c)[1]) == 'X') { (*c)+= 2; - *val = readhexx (c); - return 1; + return readhexx (c, val) ? 1 : 0; } if (nc == '%') { (*c)++; - *val = readbinx (c); - return 1; + return readbinx (c, val) ? 1: 0; } if (nc >= 'A' && nc <= 'Z' && nc != 'A' && nc != 'D') { if (readregx (c, val)) return 1; } if (def == '!') { - *val = readintx (c); + return readintx (c, val) ? -1 : 0; return -1; } else if (def == '$') { - *val = readhexx (c); - return -1; + return readhexx (c, val) ? -1 : 0; } else if (def == '%') { - *val = readbinx (c); - return -1; + return readbinx (c, val) ? -1 : 0; } return 0; } @@ -523,8 +543,12 @@ int notinrom (void) static uae_u32 lastaddr (void) { + if (currprefs.z3fastmem2_size) + return z3fastmem2_start + currprefs.z3fastmem2_size; if (currprefs.z3fastmem_size) return z3fastmem_start + currprefs.z3fastmem_size; + if (currprefs.z3chipmem_size) + return z3chipmem_start + currprefs.z3chipmem_size; if (currprefs.mbresmem_high_size) return a3000hmem_start + currprefs.mbresmem_high_size; if (currprefs.mbresmem_low_size) @@ -545,9 +569,29 @@ static uaecptr nextaddr2 (uaecptr addr, int *next) *next = -1; return 0xffffffff; } - prev = currprefs.z3fastmem_start; - size = currprefs.z3fastmem_size; + prev = currprefs.z3fastmem_start + currprefs.z3fastmem_size; + size = currprefs.z3fastmem2_size; + if (currprefs.z3fastmem_size) { + prevx = prev; + sizex = size; + size = currprefs.z3fastmem_size; + prev = z3fastmem_start; + if (addr == prev + size) { + *next = prevx + sizex; + return prevx; + } + } + if (currprefs.z3chipmem_size) { + prevx = prev; + sizex = size; + size = currprefs.z3chipmem_size; + prev = z3chipmem_start; + if (addr == prev + size) { + *next = prevx + sizex; + return prevx; + } + } if (currprefs.mbresmem_high_size) { sizex = size; prevx = prev; @@ -602,6 +646,7 @@ static uaecptr nextaddr2 (uaecptr addr, int *next) static uaecptr nextaddr (uaecptr addr, uaecptr last, uaecptr *end) { + static uaecptr old; uaecptr paddr = addr; int next; if (last && 0) { @@ -619,6 +664,11 @@ static uaecptr nextaddr (uaecptr addr, uaecptr last, uaecptr *end) addr = nextaddr2 (addr + 1, &next); if (end) *end = next; + if (old != next) { + if (addr != 0xffffffff) + console_out_f (_T("Scanning.. %08x - %08x (%s)\n"), addr & 0xffffff00, next, get_mem_bank (addr).name); + old = next; + } #if 0 if (next && addr != 0xffffffff) { uaecptr xa = addr; @@ -630,7 +680,7 @@ static uaecptr nextaddr (uaecptr addr, uaecptr last, uaecptr *end) return addr; } -int safe_addr(uaecptr addr, int size) +int safe_addr (uaecptr addr, int size) { addrbank *ab = &get_mem_bank (addr); if (!ab) @@ -1054,6 +1104,8 @@ static void decode_dma_record (int hpos, int vpos, int toggle, bool logfile) l3[cl2++] = 'p'; if (dr->evt & DMA_EVENT_COPPERWAKE) l3[cl2++] = 'W'; + if (dr->evt & DMA_EVENT_COPPERWANTED) + l3[cl2++] = 'c'; if (dr->evt & DMA_EVENT_CPUIRQ) l3[cl2++] = 'I'; if (dr->evt & DMA_EVENT_INTREQ) @@ -1412,6 +1464,10 @@ static void deepcheatsearch (TCHAR **c) break; addrcnt += 2; } + if (iscancel (65536)) { + console_out_f (_T("Aborted at %08X\n"), addr); + break; + } } console_out_f (_T("%d addresses found\n"), cnt); @@ -1512,6 +1568,10 @@ static void cheatsearch (TCHAR **c) } } memcnt++; + if (iscancel (65536)) { + console_out_f (_T("Aborted at %08X\n"), addr); + break; + } } if (!first) { while (prevmemcnt < memcnt) { @@ -1781,6 +1841,8 @@ uae_u8 *save_debug_memwatch (int *len, uae_u8 *dstptr) save_u32 (m->modval); save_u32 (m->val_mask); save_u32 (m->val_size); + save_u32 (m->val); + save_u32 (m->pc); save_store_size (); } *len = dst - dstbak; @@ -1806,6 +1868,8 @@ uae_u8 *restore_debug_memwatch (uae_u8 *src) m->modval = restore_u32 (); m->val_mask = restore_u32 (); m->val_size = restore_u32 (); + m->val = restore_u32 (); + m->pc = restore_u32 (); restore_store_size (); } return src; @@ -2402,20 +2466,49 @@ static void writeintomem (TCHAR **c) ignore_ws(c); addr = readhex (c); - ignore_ws(c); - val = readhex (c, &len); - - if (len == 4) { - put_long (addr, val); - cc = 'L'; - } else if (len == 2) { - put_word (addr, val); - cc = 'W'; + + ignore_ws (c); + if (!more_params (c)) + return; + cc = peekchar (c); + if (cc == '\'' || cc == '\"') { + next_char (c); + while (more_params (c)) { + TCHAR str[2]; + char *astr; + cc = next_char (c); + if (cc == '\'' || cc == '\"') + break; + str[0] = cc; + str[1] = 0; + astr = ua (str); + put_byte (addr, astr[0]); + xfree (astr); + addr++; + } } else { - put_byte (addr, val); - cc = 'B'; + for (;;) { + ignore_ws (c); + if (!more_params (c)) + break; + val = readhex (c, &len); + + if (len == 4) { + put_long (addr, val); + cc = 'L'; + } else if (len == 2) { + put_word (addr, val); + cc = 'W'; + } else if (len == 1) { + put_byte (addr, val); + cc = 'B'; + } else { + break; + } + console_out_f (_T("Wrote %X (%u) at %08X.%c\n"), val, val, addr, cc); + addr += len; + } } - console_out_f (_T("Wrote %X (%u) at %08X.%c\n"), val, val, addr, cc); } static uae_u8 *dump_xlate (uae_u32 addr) @@ -2808,7 +2901,7 @@ int instruction_breakpoint (TCHAR **c) return 1; } -static int process_breakpoint(TCHAR **c) +static int process_breakpoint (TCHAR **c) { processptr = 0; xfree (processname); @@ -2955,6 +3048,10 @@ static void searchmem (TCHAR **cc) break; } } + if (iscancel (65536)) { + console_out_f (_T("Aborted at %08X\n"), addr); + break; + } } if (!got) console_out (_T("nothing found")); @@ -3233,7 +3330,7 @@ static void find_ea (TCHAR **inptr) end = readhex (inptr); } console_out_f (_T("Searching from %08X to %08X\n"), addr, end); - while((addr = nextaddr(addr, end, &end)) != 0xffffffff) { + while((addr = nextaddr (addr, end, &end)) != 0xffffffff) { if ((addr & 1) == 0 && addr + 6 <= end) { sea = 0xffffffff; dea = 0xffffffff; @@ -3246,6 +3343,10 @@ static void find_ea (TCHAR **inptr) break; } } + if (iscancel (65536)) { + console_out_f (_T("Aborted at %08X\n"), addr); + break; + } } } } diff --git a/expansion.cpp b/expansion.cpp index 468aafba..663bc13c 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -1581,35 +1581,38 @@ void expamem_reset (void) void expansion_init (void) { - allocated_fastmem = 0; - fastmem_mask = fastmem_start = 0; - fastmemory = 0; + if (savestate_state != STATE_RESTORE) { + + allocated_fastmem = 0; + fastmem_mask = fastmem_start = 0; + fastmemory = 0; #ifdef PICASSO96 - allocated_gfxmem = 0; - gfxmem_mask = gfxmem_start = 0; - gfxmemory = 0; + allocated_gfxmem = 0; + gfxmem_mask = gfxmem_start = 0; + gfxmemory = 0; #endif #ifdef CATWEASEL - catweasel_mask = catweasel_start = 0; + catweasel_mask = catweasel_start = 0; #endif + allocated_z3fastmem = 0; + z3fastmem_mask = z3fastmem_start = 0; + z3fastmem = 0; + allocated_z3fastmem2 = 0; + z3fastmem2_mask = z3fastmem2_start = 0; + z3fastmem2 = 0; + allocated_z3chipmem = 0; + z3chipmem_mask = z3chipmem_start = 0; + z3chipmem = 0; + } + #ifdef FILESYS filesys_start = 0; filesysory = 0; #endif - allocated_z3fastmem = 0; - z3fastmem_mask = z3fastmem_start = 0; - z3fastmem = 0; - allocated_z3fastmem2 = 0; - z3fastmem2_mask = z3fastmem2_start = 0; - z3fastmem2 = 0; - allocated_z3chipmem = 0; - z3chipmem_mask = z3chipmem_start = 0; - z3chipmem = 0; - allocate_expamem (); #ifdef FILESYS diff --git a/fpp.cpp b/fpp.cpp index 53126d7e..6a66c9fe 100644 --- a/fpp.cpp +++ b/fpp.cpp @@ -197,13 +197,13 @@ static void fpu_op_illg (uae_u32 opcode, int pcoffset) op_illg (opcode); } -STATIC_INLINE int fault_if_no_fpu (uae_u32 opcode, int pcoffset) +static bool 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 true; } - return 0; + return false; } static int get_fpu_version (void) @@ -817,6 +817,7 @@ void fpuop_dbcc (uae_u32 opcode, uae_u16 extra) if (fault_if_no_fpu (opcode, 4)) return; + regs.fpiar = m68k_getpc () - 4; disp = (uae_s32) (uae_s16) x_next_iword (); cc = fpp_cond (extra & 0x3f); if (cc == -1) { @@ -843,6 +844,7 @@ void fpuop_scc (uae_u32 opcode, uae_u16 extra) if (fault_if_no_fpu (opcode, 4)) return; + regs.fpiar = m68k_getpc () - 4; cc = fpp_cond (extra & 0x3f); if (cc == -1) { fpu_op_illg (opcode, 4); @@ -860,40 +862,44 @@ void fpuop_scc (uae_u32 opcode, uae_u16 extra) void fpuop_trapcc (uae_u32 opcode, uaecptr oldpc, uae_u16 extra) { int cc; + uaecptr pc = m68k_getpc (); #if DEBUG_FPP if (!isinrom ()) write_log (_T("ftrapcc_opp at %08lx\n"), m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, m68k_getpc() - oldpc)) + if (fault_if_no_fpu (opcode, pc - oldpc)) return; + regs.fpiar = oldpc; cc = fpp_cond (extra & 0x3f); if (cc == -1) { - fpu_op_illg (opcode, m68k_getpc () - oldpc); + fpu_op_illg (opcode, pc - oldpc); } if (cc) Exception (7); } -void fpuop_bcc (uae_u32 opcode, uaecptr pc, uae_u32 extra) +void fpuop_bcc (uae_u32 opcode, uaecptr oldpc, uae_u32 extra) { int cc; + uaecptr pc = m68k_getpc (); #if DEBUG_FPP if (!isinrom ()) write_log (_T("fbcc_opp at %08lx\n"), m68k_getpc ()); #endif - if (fault_if_no_fpu (opcode, m68k_getpc () - pc)) + if (fault_if_no_fpu (opcode, pc - oldpc)) return; + regs.fpiar = oldpc; cc = fpp_cond (opcode & 0x3f); if (cc == -1) { - fpu_op_illg (opcode, m68k_getpc () - pc); + fpu_op_illg (opcode, pc - oldpc); } else if (cc) { if ((opcode & 0x40) == 0) extra = (uae_s32) (uae_s16) extra; - m68k_setpc (pc + extra); + m68k_setpc (oldpc + extra); } } @@ -902,6 +908,7 @@ void fpuop_save (uae_u32 opcode) uae_u32 ad; int incr = (opcode & 0x38) == 0x20 ? -1 : 1; int fpu_version = get_fpu_version(); + uaecptr pc = m68k_getpc () - 2; int i; #if DEBUG_FPP @@ -919,6 +926,8 @@ void fpuop_save (uae_u32 opcode) // if (regs.fpcr == 0 && regs.fpsr == 0 && regs.fpiar == 0 && // regs.fp[0] == + regs.fpiar = pc; + if (currprefs.fpu_model == 68060) { /* 12 byte 68060 IDLE frame. */ if (incr < 0) { @@ -975,6 +984,7 @@ void fpuop_save (uae_u32 opcode) void fpuop_restore (uae_u32 opcode) { + uaecptr pc = m68k_getpc () - 2; uae_u32 ad; uae_u32 d; int incr = (opcode & 0x38) == 0x20 ? -1 : 1; @@ -991,6 +1001,8 @@ void fpuop_restore (uae_u32 opcode) return; } + regs.fpiar = pc; + if (currprefs.fpu_model == 68060) { /* all 68060 FPU frames are 12 bytes */ if (incr < 0) { @@ -1069,10 +1081,11 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) { int reg; fptype src; + uaecptr pc = m68k_getpc () - 4; #if DEBUG_FPP if (!isinrom ()) - write_log (_T("FPP %04lx %04x at %08lx\n"), opcode & 0xffff, extra, m68k_getpc () - 4); + write_log (_T("FPP %04lx %04x at %08lx\n"), opcode & 0xffff, extra, pc); #endif if (fault_if_no_fpu (opcode, 4)) return; @@ -1081,7 +1094,7 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) case 3: if (put_fp_value (regs.fp[(extra >> 7) & 7], opcode, extra) == 0) { - m68k_setpc (m68k_getpc () - 4); + m68k_setpc (pc); op_illg (opcode); } return; @@ -1141,7 +1154,7 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) int incr = 0; if (get_fp_ad (opcode, &ad) == 0) { - m68k_setpc (m68k_getpc () - 4); + m68k_setpc (pc); op_illg (opcode); return; } @@ -1177,7 +1190,7 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) int incr = 0; if (get_fp_ad (opcode, &ad) == 0) { - m68k_setpc (m68k_getpc () - 4); + m68k_setpc (pc); op_illg (opcode); return; } @@ -1218,7 +1231,7 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) if (extra & 0x2000) { /* FMOVEM FPP->memory */ if (get_fp_ad (opcode, &ad) == 0) { - m68k_setpc (m68k_getpc () - 4); + m68k_setpc (pc); op_illg (opcode); return; } @@ -1276,7 +1289,7 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) } else { /* FMOVEM memory->FPP */ if (get_fp_ad (opcode, &ad) == 0) { - m68k_setpc (m68k_getpc () - 4); + m68k_setpc (pc); op_illg (opcode); return; } @@ -1407,7 +1420,7 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) regs.fp[reg] = *fp_1e4096; break; default: - m68k_setpc (m68k_getpc () - 4); + m68k_setpc (pc); op_illg (opcode); return; } @@ -1415,11 +1428,13 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) return; } if (get_fp_value (opcode, extra, &src) == 0) { - m68k_setpc (m68k_getpc () - 4); + m68k_setpc (pc); op_illg (opcode); return; } + regs.fpiar = pc; + switch (extra & 0x7f) { case 0x00: /* FMOVE */ @@ -1646,14 +1661,14 @@ static void fpuop_arithmetic2 (uae_u32 opcode, uae_u16 extra) MAKE_FPSR (src); return; default: - m68k_setpc (m68k_getpc () - 4); + m68k_setpc (pc); op_illg (opcode); return; } MAKE_FPSR (regs.fp[reg]); return; } - m68k_setpc (m68k_getpc () - 4); + m68k_setpc (pc); op_illg (opcode); } diff --git a/gencpu.cpp b/gencpu.cpp index 709a93b3..0145d2f1 100644 --- a/gencpu.cpp +++ b/gencpu.cpp @@ -3141,6 +3141,13 @@ static void gen_opcode (unsigned long int opcode) int old_brace_level; genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0); + if (cpu_level == 5 && curi->size > 0) { + printf ("\tif ((dsta & %d) && currprefs.cpu_compatible && get_cpu_model () == 68060) {\n", curi->size == 1 ? 1 : 3); + printf ("\t\top_unimpl ();\n"); + printf ("\t\tgoto %s;\n", endlabelstr); + printf ("\t}\n"); + need_endlabel = 1; + } fill_prefetch_0 (); start_brace (); printf ("\tint ru = (src >> 6) & 7;\n"); diff --git a/include/cia.h b/include/cia.h index 63398bba..97b6d929 100644 --- a/include/cia.h +++ b/include/cia.h @@ -20,6 +20,7 @@ extern void cia_diskindex (void); extern void dumpcia (void); extern void rethink_cias (void); extern int resetwarning_do (int); +extern void cia_set_overlay (bool); extern int parallel_direct_write_data (uae_u8, uae_u8); extern int parallel_direct_read_data (uae_u8*); diff --git a/include/debug.h b/include/debug.h index 9120bdfd..7d0e1caa 100644 --- a/include/debug.h +++ b/include/debug.h @@ -94,6 +94,7 @@ struct dma_rec #define DMA_EVENT_COPPERWAKE 16 #define DMA_EVENT_CPUIRQ 32 #define DMA_EVENT_INTREQ 64 +#define DMA_EVENT_COPPERWANTED 128 #define DMARECORD_REFRESH 1 #define DMARECORD_CPU 2 diff --git a/include/gfxfilter.h b/include/gfxfilter.h index 1b133558..67985752 100644 --- a/include/gfxfilter.h +++ b/include/gfxfilter.h @@ -81,6 +81,8 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height void getfilteroffset (int *dx, int *dy, int *mx, int *my); uae_u8 *getfilterbuffer (int *widthp, int *heightp, int *pitch, int *depth); uae_u8 *getfilterbuffer3d (int *widthp, int *heightp, int *pitch, int *depth); +uae_u8 *getrtgbuffer (int *widthp, int *heightp, int *pitch, int *depth, uae_u8 *palette); +void freertgbuffer (uae_u8 *dst); extern void getrtgfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height); #endif diff --git a/include/memory.h b/include/memory.h index 4b07be7b..1542097e 100644 --- a/include/memory.h +++ b/include/memory.h @@ -19,6 +19,7 @@ extern void cache_free (uae_u8*); #endif bool init_shm (void); +void free_shm (void); bool preinit_shm (void); extern bool canbang; extern int candirect; @@ -329,6 +330,7 @@ typedef struct shmpiece_reg { uae_u8 *native_address; int id; uae_u32 size; + const TCHAR *name; struct shmpiece_reg *next; struct shmpiece_reg *prev; } shmpiece; diff --git a/include/newcpu.h b/include/newcpu.h index 11095658..35d22595 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -66,6 +66,7 @@ struct comptbl { #endif extern uae_u32 REGPARAM3 op_illg (uae_u32) REGPARAM; +extern void REGPARAM3 op_unimpl (void) REGPARAM; typedef uae_u8 flagtype; diff --git a/include/readcpu.h b/include/readcpu.h index f242766b..871973df 100644 --- a/include/readcpu.h +++ b/include/readcpu.h @@ -96,9 +96,9 @@ extern struct instr { unsigned int suse:1; unsigned int duse:1; unsigned int unused1:1; - unsigned int clev:3; + unsigned int clev:3, unimpclev:3; unsigned int isjmp:1; - unsigned int unused2:4; + unsigned int unused2:1; } *table68k; extern void read_table68k (void); diff --git a/include/sysdeps.h b/include/sysdeps.h index e06132ab..bc584c9d 100644 --- a/include/sysdeps.h +++ b/include/sysdeps.h @@ -478,6 +478,7 @@ extern void console_out (const TCHAR *); extern void console_out_f (const TCHAR *, ...); extern void console_flush (void); extern int console_get (TCHAR *, int); +extern bool console_isch (void); extern TCHAR console_getch (void); extern void f_out (void *, const TCHAR *, ...); extern TCHAR* buf_out (TCHAR *buffer, int *bufsize, const TCHAR *format, ...); diff --git a/main.cpp b/main.cpp index c7a8897f..01e051e6 100644 --- a/main.cpp +++ b/main.cpp @@ -845,6 +845,7 @@ void do_leave_program (void) device_func_reset (); savestate_free (); memory_cleanup (); + free_shm (); cfgfile_addcfgparam (0); machdep_free (); } @@ -955,9 +956,15 @@ static int real_main2 (int argc, TCHAR **argv) init_shm (); #endif +#ifdef PICASSO96 + picasso_reset (); +#endif + +#if 0 #ifdef JIT if (!(currprefs.cpu_model >= 68020 && currprefs.address_space_24 == 0 && currprefs.cachesize)) canbang = 0; +#endif #endif fixup_prefs (&currprefs); @@ -972,6 +979,7 @@ static int real_main2 (int argc, TCHAR **argv) savestate_init (); keybuf_init (); /* Must come after init_joystick */ + memory_hardreset (2); memory_reset (); #ifdef AUTOCONFIG diff --git a/memory.cpp b/memory.cpp index f083c67d..2c95acdb 100644 --- a/memory.cpp +++ b/memory.cpp @@ -39,7 +39,7 @@ int candirect = -1; /* Set by each memory handler that does not simply access real memory. */ int special_mem; #endif -static int mem_hardreset = 3; +static int mem_hardreset; static bool isdirectjit (void) { @@ -54,12 +54,11 @@ static bool canjit (void) } static bool needmman (void) { - if (canjit ()) - return true; #ifdef _WIN32 - if (currprefs.rtgmem_size) - return true; + return true; #endif + if (canjit ()) + return true; return false; } @@ -85,6 +84,7 @@ static size_t bootrom_filepos, chip_filepos, bogo_filepos, rom_filepos, a3000lme and we must clear all memory to prevent bogus contents from confusing the Kickstart. */ static bool need_hardreset; +static bool bogomem_aliasing; /* The address space setting used during the last reset. */ static bool last_address_space_24; @@ -1671,10 +1671,12 @@ static bool load_extendedkickstart (const TCHAR *romextfile, int type) case EXTENDED_ROM_CDTV: extendedkickmemory = mapped_malloc (extendedkickmem_size, _T("rom_f0")); extendedkickmem_bank.baseaddr = extendedkickmemory; + extendedkickmem_start = 0xf00000; break; case EXTENDED_ROM_CD32: extendedkickmemory = mapped_malloc (extendedkickmem_size, _T("rom_e0")); extendedkickmem_bank.baseaddr = extendedkickmemory; + extendedkickmem_start = 0xe00000; break; } if (extendedkickmemory) { @@ -1864,9 +1866,11 @@ static int load_kickstart (void) extendedkickmem_type = EXTENDED_ROM_CDTV; extendedkickmem_size *= 2; extendedkickmemory = mapped_malloc (extendedkickmem_size, _T("rom_f0")); + extendedkickmem_start = 0xf00000; } else { extendedkickmem_type = EXTENDED_ROM_KS; extendedkickmemory = mapped_malloc (extendedkickmem_size, _T("rom_e0")); + extendedkickmem_start = 0xe00000; } extendedkickmem_bank.baseaddr = extendedkickmemory; zfile_fseek (f, extpos, SEEK_SET); @@ -1882,6 +1886,7 @@ static int load_kickstart (void) zfile_fseek (f, extpos + 524288 * 2, SEEK_SET); read_kickstart (f, extendedkickmemory2 + 524288, 524288, 0, 1); extendedkickmem2_mask = extendedkickmem2_size - 1; + extendedkickmem2_start = 0xa80000; } } @@ -1933,13 +1938,15 @@ static void dumplist (void) write_log (_T("End Dump:\n")); } -static shmpiece *find_shmpiece (uae_u8 *base) +static shmpiece *find_shmpiece (uae_u8 *base, bool safe) { shmpiece *x = shm_start; while (x && x->native_address != base) x = x->next; if (!x) { + if (safe || bogomem_aliasing) + return 0; write_log (_T("NATMEM: Failure to find mapping at %08X, %p\n"), base - NATMEM_OFFSET, base); nocanbang (); return 0; @@ -1949,10 +1956,8 @@ static shmpiece *find_shmpiece (uae_u8 *base) static void delete_shmmaps (uae_u32 start, uae_u32 size) { -#if 0 if (!needmman ()) return; -#endif while (size) { uae_u8 *base = mem_banks[bankindex (start)]->baseaddr; @@ -1960,7 +1965,7 @@ static void delete_shmmaps (uae_u32 start, uae_u32 size) shmpiece *x; //base = ((uae_u8*)NATMEM_OFFSET)+start; - x = find_shmpiece (base); + x = find_shmpiece (base, true); if (!x) return; @@ -1998,16 +2003,16 @@ static void add_shmmaps (uae_u32 start, addrbank *what) shmpiece *y; uae_u8 *base = what->baseaddr; -#if 0 if (!needmman ()) return; -#endif + if (!base) return; - x = find_shmpiece (base); + x = find_shmpiece (base, false); if (!x) return; + y = xmalloc (shmpiece, 1); *y = *x; base = ((uae_u8 *) NATMEM_OFFSET) + start; @@ -2032,12 +2037,10 @@ uae_u8 *mapped_malloc (size_t s, const TCHAR *file) shmpiece *x; static int recurse; -#if 0 if (!needmman ()) { nocanbang (); return xcalloc (uae_u8, s + 4); } -#endif id = shmget (IPC_PRIVATE, s, 0x1ff, file); if (id == -1) { @@ -2057,6 +2060,7 @@ uae_u8 *mapped_malloc (size_t s, const TCHAR *file) x->native_address = (uae_u8*)answer; x->id = id; x->size = s; + x->name = file; x->next = shm_start; x->prev = NULL; if (x->next) @@ -2088,32 +2092,35 @@ static void init_mem_banks (void) static void allocate_memory (void) { + bogomem_aliasing = false; /* emulate 0.5M+0.5M with 1M Agnus chip ram aliasing */ - if ((allocated_chipmem != currprefs.chipmem_size || allocated_bogomem != currprefs.bogomem_size) && - currprefs.chipmem_size == 0x80000 && currprefs.bogomem_size >= 0x80000 && - (currprefs.chipset_mask & CSMASK_ECS_AGNUS) && !(currprefs.chipset_mask & CSMASK_AGA) && !needmman ()) { - int memsize1, memsize2; - if (chipmemory) - mapped_free (chipmemory); - chipmemory = 0; - if (bogomemory_allocated) - mapped_free (bogomemory); - bogomemory = 0; - bogomemory_allocated = 0; - memsize1 = allocated_chipmem = currprefs.chipmem_size; - memsize2 = allocated_bogomem = currprefs.bogomem_size; - chipmem_mask = allocated_chipmem - 1; - chipmem_full_mask = allocated_chipmem * 2 - 1; - chipmem_full_size = 0x80000 * 2; - chipmemory = mapped_malloc (memsize1 + memsize2, _T("chip")); - bogomemory = chipmemory + memsize1; - bogomem_mask = allocated_bogomem - 1; - if (chipmemory == 0) { - write_log (_T("Fatal error: out of memory for chipmem.\n")); - allocated_chipmem = 0; - } else { - need_hardreset = 1; + if (currprefs.chipmem_size == 0x80000 && currprefs.bogomem_size >= 0x80000 && + (currprefs.chipset_mask & CSMASK_ECS_AGNUS) && !(currprefs.chipset_mask & CSMASK_AGA) && currprefs.cpu_model < 68020) { + if ((allocated_chipmem != currprefs.chipmem_size || allocated_bogomem != currprefs.bogomem_size)) { + int memsize1, memsize2; + if (chipmemory) + mapped_free (chipmemory); + chipmemory = 0; + if (bogomemory_allocated) + mapped_free (bogomemory); + bogomemory = 0; + bogomemory_allocated = 0; + memsize1 = allocated_chipmem = currprefs.chipmem_size; + memsize2 = allocated_bogomem = currprefs.bogomem_size; + chipmem_mask = allocated_chipmem - 1; + chipmem_full_mask = allocated_chipmem * 2 - 1; + chipmem_full_size = 0x80000 * 2; + chipmemory = mapped_malloc (memsize1 + memsize2, _T("chip")); + bogomemory = chipmemory + memsize1; + bogomem_mask = allocated_bogomem - 1; + if (chipmemory == 0) { + write_log (_T("Fatal error: out of memory for chipmem.\n")); + allocated_chipmem = 0; + } else { + need_hardreset = true; + } } + bogomem_aliasing = true; } if (allocated_chipmem != currprefs.chipmem_size) { @@ -2135,7 +2142,7 @@ static void allocate_memory (void) write_log (_T("Fatal error: out of memory for chipmem.\n")); allocated_chipmem = 0; } else { - need_hardreset = 1; + need_hardreset = true; if (memsize > allocated_chipmem) memset (chipmemory + allocated_chipmem, 0xff, memsize - allocated_chipmem); } @@ -2167,7 +2174,7 @@ static void allocate_memory (void) allocated_bogomem = 0; } } - need_hardreset = 1; + need_hardreset = true; } if (allocated_a3000lmem != currprefs.mbresmem_low_size) { if (a3000lmemory) @@ -2184,7 +2191,7 @@ static void allocate_memory (void) allocated_a3000lmem = 0; } } - need_hardreset = 1; + need_hardreset = true; } if (allocated_a3000hmem != currprefs.mbresmem_high_size) { if (a3000hmemory) @@ -2201,7 +2208,7 @@ static void allocate_memory (void) allocated_a3000hmem = 0; } } - need_hardreset = 1; + need_hardreset = true; } #ifdef CDTV if (allocated_cardmem != currprefs.cs_cdtvcard * 1024) { @@ -2413,6 +2420,12 @@ void memory_reset (void) int bnk, bnk_end; bool gayleorfatgary; + need_hardreset = false; + /* Use changed_prefs, as m68k_reset is called later. */ + if (last_address_space_24 != changed_prefs.address_space_24) + need_hardreset = true; + last_address_space_24 = changed_prefs.address_space_24; + if (mem_hardreset > 2) memory_init (); @@ -2433,13 +2446,6 @@ void memory_reset (void) gayleorfatgary = (currprefs.chipset_mask & CSMASK_AGA) || currprefs.cs_pcmcia || currprefs.cs_ide > 0 || currprefs.cs_mbdmac; - need_hardreset = 0; - /* Use changed_prefs, as m68k_reset is called later. */ - if (last_address_space_24 != changed_prefs.address_space_24) - need_hardreset = 1; - - last_address_space_24 = changed_prefs.address_space_24; - init_mem_banks (); allocate_memory (); chipmem_setindirect (); @@ -2458,7 +2464,7 @@ void memory_reset (void) memcpy (currprefs.romfile, changed_prefs.romfile, sizeof currprefs.romfile); memcpy (currprefs.romextfile, changed_prefs.romextfile, sizeof currprefs.romextfile); - need_hardreset = 1; + need_hardreset = true; mapped_free (extendedkickmemory); extendedkickmemory = 0; extendedkickmem_size = 0; @@ -2691,6 +2697,7 @@ void memory_reset (void) void memory_init (void) { + init_mem_banks (); virtualdevice_init (); allocated_chipmem = 0; @@ -2709,8 +2716,6 @@ void memory_init (void) custmem1 = 0; custmem2 = 0; - init_mem_banks (); - kickmemory = mapped_malloc (0x80000, _T("kick")); memset (kickmemory, 0, 0x80000); kickmem_bank.baseaddr = kickmemory; @@ -2957,7 +2962,8 @@ uae_u8 *restore_rom (uae_u8 *src) } xfree (s); if (!crcdet) - write_log (_T("WARNING: ROM '%s' not found!\n"), romn); + write_log (_T("WARNING: ROM '%s' %d.%d (CRC32=%08x %08x-%08x) not found!\n"), + romn, version >> 16, version & 0xffff, crc32, mem_start, mem_start + mem_size - 1); xfree (romn); return src; } @@ -3005,6 +3011,9 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr) mem_real_start = extendedkickmemory; mem_size = extendedkickmem_size; path = currprefs.romextfile; + version = longget (mem_start + 12); /* version+revision */ + if (version == 0xffffffff) + version = longget (mem_start + 16); _stprintf (tmpname, _T("Extended")); break; default: diff --git a/newcpu.cpp b/newcpu.cpp index b3082176..dea56512 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -955,6 +955,14 @@ static uae_u32 REGPARAM2 op_illg_1 (uae_u32 opcode) op_illg (opcode); return 4; } +static uae_u32 REGPARAM2 op_unimpl_1 (uae_u32 opcode) +{ + if ((opcode & 0xf000) == 0xf000 || currprefs.cpu_model < 68060) + op_illg (opcode); + else + op_unimpl (); + return 4; +} static void build_cpufunctbl (void) { @@ -1043,22 +1051,35 @@ static void build_cpufunctbl (void) cpufunctbl[tbl[i].opcode] = tbl[i].handler; } } + opcnt = 0; for (opcode = 0; opcode < 65536; opcode++) { cpuop_func *f; + instr *table = &table68k[opcode]; + + if (table->mnemo == i_ILLG) + continue; - if (table68k[opcode].mnemo == i_ILLG) + /* unimplemented opcode? */ + if (table->unimpclev > 0 && lvl >= table->unimpclev) { + if (currprefs.cpu_compatible && currprefs.cpu_model == 68060) { + cpufunctbl[opcode] = op_unimpl_1; + } else { + cpufunctbl[opcode] = op_illg_1; + } continue; + } + if (currprefs.fpu_model && currprefs.cpu_model < 68020) { /* more hack fpu to 68000/68010 mode */ - if (table68k[opcode].clev > lvl && (opcode & 0xfe00) != 0xf200) + if (table->clev > lvl && (opcode & 0xfe00) != 0xf200) continue; - } else if (table68k[opcode].clev > lvl) { + } else if (table->clev > lvl) { continue; } - if (table68k[opcode].handler != -1) { - int idx = table68k[opcode].handler; + if (table->handler != -1) { + int idx = table->handler; f = cpufunctbl[idx]; if (f == op_illg_1) abort (); @@ -2756,11 +2777,15 @@ STATIC_INLINE int div_unsigned (uae_u32 src_hi, uae_u32 src_lo, uae_u32 div, uae void m68k_divl (uae_u32 opcode, uae_u32 src, uae_u16 extra) { -#if defined (uae_s64) + if ((extra & 0x400) && currprefs.cpu_compatible && currprefs.cpu_model == 68060) { + op_unimpl (); + return; + } if (src == 0) { Exception (5); return; } +#if defined (uae_s64) if (extra & 0x800) { /* signed variant */ uae_s64 a = (uae_s64)(uae_s32)m68k_dreg (regs, (extra >> 12) & 7); @@ -2812,10 +2837,6 @@ void m68k_divl (uae_u32 opcode, uae_u32 src, uae_u16 extra) } } #else - if (src == 0) { - Exception (5); - return; - } if (extra & 0x800) { /* signed variant */ uae_s32 lo = (uae_s32)m68k_dreg (regs, (extra >> 12) & 7); @@ -2895,6 +2916,10 @@ STATIC_INLINE void mul_unsigned (uae_u32 src1, uae_u32 src2, uae_u32 *dst_hi, ua void m68k_mull (uae_u32 opcode, uae_u32 src, uae_u16 extra) { + if ((extra & 0x400) && currprefs.cpu_compatible && currprefs.cpu_model == 68060) { + op_unimpl (); + return; + } #if defined (uae_s64) if (extra & 0x800) { /* signed variant */ @@ -3067,6 +3092,11 @@ void m68k_reset (int hardreset) fill_prefetch_quick (); } +void REGPARAM2 op_unimpl (void) +{ + Exception (61); +} + uae_u32 REGPARAM2 op_illg (uae_u32 opcode) { uaecptr pc = m68k_getpc (); @@ -3258,11 +3288,6 @@ static void mmu_op30_pflush (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr e void mmu_op30 (uaecptr pc, uae_u32 opcode, uae_u16 extra, uaecptr extraa) { - if (currprefs.cpu_model != 68030) { - m68k_setpc (pc); - op_illg (opcode); - return; - } if (extra & 0x8000) mmu_op30_ptest (pc, opcode, extra, extraa); else if (extra & 0x2000) @@ -4507,20 +4532,29 @@ void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int struct mnemolookup *lookup; struct instr *dp; int oldpc; + int m68kpc_illg = 0; + bool illegal = false; oldpc = m68kpc_offset; opcode = get_iword_1 (m68kpc_offset); - if (cpufunctbl[opcode] == op_illg_1) { - opcode = 0x4AFC; + if (cpufunctbl[opcode] == op_illg_1 || cpufunctbl[opcode] == op_unimpl_1) { + m68kpc_illg = m68kpc_offset + 2; + illegal = TRUE; } + dp = table68k + opcode; + if (dp->mnemo == i_ILLG) { + illegal = FALSE; + opcode = 0x4AFC; + dp = table68k + opcode; + } for (lookup = lookuptab;lookup->mnemo != dp->mnemo; lookup++) ; buf = buf_out (buf, &bufsize, _T("%08lX "), m68k_getpc () + m68kpc_offset); m68kpc_offset += 2; - + if (lookup->friendlyname) _tcscpy (instrname, lookup->friendlyname); else @@ -4585,7 +4619,11 @@ void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int while (i++ < 5) buf = buf_out (buf, &bufsize, _T(" ")); + if (illegal) + buf = buf_out (buf, &bufsize, _T("[ ")); buf = buf_out (buf, &bufsize, instrname); + if (illegal) + buf = buf_out (buf, &bufsize, _T(" ]")); if (ccpt != 0) { if (deaddr) @@ -4600,6 +4638,9 @@ void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int buf = buf_out (buf, &bufsize, _T(" == $%08lX"), newpc); } buf = buf_out (buf, &bufsize, _T("\n")); + + if (illegal) + m68kpc_offset = m68kpc_illg; } if (nextpc) *nextpc = m68k_getpc () + m68kpc_offset; @@ -4808,7 +4849,8 @@ void m68k_dumpstate (void *f, uaecptr *nextpc) f_out (f, _T("\n")); } fpsr = get_fpsr (); - f_out (f, _T("N=%d Z=%d I=%d NAN=%d\n"), + f_out (f, _T("FPSR: %04X FPCR: %08x FPIAR: %08x N=%d Z=%d I=%d NAN=%d\n"), + fpsr, regs.fpcr, regs.fpiar, (fpsr & 0x8000000) != 0, (fpsr & 0x4000000) != 0, (fpsr & 0x2000000) != 0, diff --git a/od-win32/avioutput.cpp b/od-win32/avioutput.cpp index 333df317..92c12835 100644 --- a/od-win32/avioutput.cpp +++ b/od-win32/avioutput.cpp @@ -482,8 +482,14 @@ static int AVIOutput_AllocateVideo (void) avioutput_fps = (int)(vblank_hz + 0.5); if (!avioutput_fps) avioutput_fps = ispal () ? 50 : 60; - if (avioutput_originalsize) - getfilterbuffer (&avioutput_width, &avioutput_height, NULL, &avioutput_bits); + if (avioutput_originalsize) { + int pitch; + if (!WIN32GFX_IsPicassoScreen ()) { + getfilterbuffer (&avioutput_width, &avioutput_height, &pitch, &avioutput_bits); + } else { + freertgbuffer (getrtgbuffer (&avioutput_width, &avioutput_height, &pitch, &avioutput_bits, NULL)); + } + } if (avioutput_width == 0 || avioutput_height == 0 || avioutput_bits == 0) { avioutput_width = WIN32GFX_GetWidth (); @@ -851,13 +857,17 @@ extern uae_u8 *bufmem_ptr; static int getFromBuffer (struct avientry *ae, int original) { int x, y, w, h, d; - uae_u8 *src; + uae_u8 *src, *mem; uae_u8 *dst = ae->lpVideo; int spitch, dpitch; + mem = NULL; dpitch = ((avioutput_width * avioutput_bits + 31) & ~31) / 8; if (original) { - src = getfilterbuffer (&w, &h, &spitch, &d); + if (!WIN32GFX_IsPicassoScreen ()) + src = getfilterbuffer (&w, &h, &spitch, &d); + else + src = mem = getrtgbuffer (&w, &h, &spitch, &d, NULL); } else { spitch = gfxvidinfo.outbuffer->rowbytes; src = bufmem_ptr; @@ -899,6 +909,8 @@ static int getFromBuffer (struct avientry *ae, int original) } src += spitch; } + if (mem) + freertgbuffer (mem); return 1; } #endif @@ -918,11 +930,11 @@ void AVIOutput_WriteVideo (void) dorestart (); waitqueuefull (); ae = allocavientry_video (); - if (avioutput_originalsize && !WIN32GFX_IsPicassoScreen ()) { + if (avioutput_originalsize) { v = getFromBuffer (ae, 1); } else { #if defined (GFXFILTER) - if (!usedfilter || WIN32GFX_IsPicassoScreen ()) + if (!usedfilter) v = getFromDC (ae); else v = getFromBuffer (ae, 0); diff --git a/od-win32/blkdev_win32_ioctl.cpp b/od-win32/blkdev_win32_ioctl.cpp index f449f1b1..67369808 100644 --- a/od-win32/blkdev_win32_ioctl.cpp +++ b/od-win32/blkdev_win32_ioctl.cpp @@ -1199,8 +1199,6 @@ static void trim (TCHAR *s) /* open device level access to cd rom drive */ static int sys_cddev_open (struct dev_info_ioctl *ciw, int unitnum) { - uae_u8 inquiry[256]; - int datalen; ciw->cdda_volume[0] = 0x7fff; ciw->cdda_volume[1] = 0x7fff; @@ -1212,9 +1210,16 @@ static int sys_cddev_open (struct dev_info_ioctl *ciw, int unitnum) return 1; } + memset (ciw->di.vendorid, 0, sizeof ciw->di.vendorid); + memset (ciw->di.productid, 0, sizeof ciw->di.productid); + memset (ciw->di.revision, 0, sizeof ciw->di.revision); _tcscpy (ciw->di.vendorid, _T("UAE")); _stprintf (ciw->di.productid, _T("SCSI CD%d IMG"), unitnum); _tcscpy (ciw->di.revision, _T("0.2")); + +#if 0 + uae_u8 inquiry[256]; + int datalen; memset (inquiry, 0, sizeof inquiry); if (spti_inquiry (ciw, unitnum, inquiry, &datalen)) { // check also that device type is non-zero and it is removable @@ -1242,11 +1247,61 @@ static int sys_cddev_open (struct dev_info_ioctl *ciw, int unitnum) } close_createfile (ciw); } +#endif if (!open_createfile (ciw, 0)) { write_log (_T("IOCTL: failed to open '%s', err=%d\n"), ciw->devname, GetLastError ()); goto error; } + + STORAGE_PROPERTY_QUERY query; + UCHAR outBuf[20000]; + ULONG returnedLength; + memset (&query, 0, sizeof query); + query.PropertyId = StorageDeviceProperty; + query.QueryType = PropertyStandardQuery; + if (DeviceIoControl( + ciw->h, + IOCTL_STORAGE_QUERY_PROPERTY, + &query, + sizeof (STORAGE_PROPERTY_QUERY), + &outBuf, + sizeof (outBuf), + &returnedLength, + NULL + )) { + PSTORAGE_DEVICE_DESCRIPTOR devDesc; + devDesc = (PSTORAGE_DEVICE_DESCRIPTOR) outBuf; + int size = devDesc->Version; + PUCHAR p = (PUCHAR) outBuf; + for (;;) { + if (offsetof(STORAGE_DEVICE_DESCRIPTOR, CommandQueueing) > size) + break; + if (size > offsetof(STORAGE_DEVICE_DESCRIPTOR, VendorIdOffset) && devDesc->VendorIdOffset && p[devDesc->VendorIdOffset]) { + ciw->di.vendorid[0] = 0; + ciw->di.productid[0] = 0; + ciw->di.revision[0] = 0; + int j = 0; + for (int i = devDesc->VendorIdOffset; p[i] != (UCHAR) NULL && i < returnedLength && j < sizeof (ciw->di.vendorid) / sizeof (TCHAR) - 1; i++) + ciw->di.vendorid[j++] = p[i]; + } + if (size > offsetof(STORAGE_DEVICE_DESCRIPTOR, ProductIdOffset) && devDesc->ProductIdOffset && p[devDesc->ProductIdOffset]) { + int j = 0; + for (int i = devDesc->ProductIdOffset; p[i] != (UCHAR) NULL && i < returnedLength && j < sizeof (ciw->di.productid) / sizeof (TCHAR) - 1; i++) + ciw->di.productid[j++] = p[i]; + } + if (size > offsetof(STORAGE_DEVICE_DESCRIPTOR, ProductRevisionOffset) && devDesc->ProductRevisionOffset && p[devDesc->ProductRevisionOffset]) { + int j = 0; + for (int i = devDesc->ProductRevisionOffset; p[i] != (UCHAR) NULL && i < returnedLength && j < sizeof (ciw->di.revision) / sizeof (TCHAR) - 1; i++) + ciw->di.revision[j++] = p[i]; + } + trim (ciw->di.vendorid); + trim (ciw->di.productid); + trim (ciw->di.revision); + break; + } + } + write_log (_T("IOCTL: device '%s' (%s/%s/%s) opened succesfully (unit=%d,media=%d)\n"), ciw->devname, ciw->di.vendorid, ciw->di.productid, ciw->di.revision, unitnum, ciw->di.media_inserted); diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index 1dbaf76f..824a7c58 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -2379,8 +2379,8 @@ int D3D_needreset (void) hr = d3ddev->TestCooperativeLevel (); if (hr == S_PRESENT_OCCLUDED) return 0; - if (hr == D3DERR_DEVICENOTRESET) { - write_log (_T("%s: DEVICENOTRESET\n"), D3DHEAD); + if (hr == D3DERR_DEVICENOTRESET || hr == D3DERR_DEVICELOST) { + write_log (_T("%s: %s\n"), D3DHEAD, hr == D3DERR_DEVICENOTRESET ? _T("DEVICENOTRESET"): _T("DEVICELOST")); devicelost = 2; invalidatedeviceobjects (); hr = reset (); @@ -2397,10 +2397,6 @@ int D3D_needreset (void) write_log (_T("%s: Reset succeeded\n"), D3DHEAD); restoredeviceobjects (); return -1; - } else if (hr == D3DERR_DEVICELOST) { - write_log (_T("%s: D3DERR_DEVICELOST\n"), D3DHEAD); - invalidatedeviceobjects (); - return 0; } else if (hr == S_PRESENT_MODE_CHANGED) { write_log (_T("%s: S_PRESENT_MODE_CHANGED (%d,%d)\n"), D3DHEAD, ddraw_fs, ddraw_fs_attempt); #if 0 diff --git a/od-win32/hardfile_win32.cpp b/od-win32/hardfile_win32.cpp index bea98081..1f7ce563 100644 --- a/od-win32/hardfile_win32.cpp +++ b/od-win32/hardfile_win32.cpp @@ -1061,7 +1061,6 @@ static BOOL GetDevicePropertyFromName(const TCHAR *DevicePath, DWORD Index, DWOR UCHAR outBuf[20000]; DISK_GEOMETRY dg; GET_LENGTH_INFORMATION gli; - PSTORAGE_ADAPTER_DESCRIPTOR adpDesc; int gli_ok; BOOL status; ULONG length = 0, returned = 0, returnedLength; @@ -1111,25 +1110,6 @@ static BOOL GetDevicePropertyFromName(const TCHAR *DevicePath, DWORD Index, DWOR showonly = TRUE; } - query.PropertyId = StorageAdapterProperty; - query.QueryType = PropertyStandardQuery; - - status = DeviceIoControl( - hDevice, - IOCTL_STORAGE_QUERY_PROPERTY, - &query, - sizeof(STORAGE_PROPERTY_QUERY), - &outBuf, - sizeof (outBuf), - &returnedLength, - NULL - ); - if (!status) { - write_log (_T("IOCTL_STORAGE_QUERY_PROPERTY failed with error code %d.\n"), GetLastError()); - } else { - adpDesc = (PSTORAGE_ADAPTER_DESCRIPTOR) outBuf; - } - memset (outBuf, 0, sizeof outBuf); query.PropertyId = StorageDeviceProperty; query.QueryType = PropertyStandardQuery; @@ -1137,7 +1117,7 @@ static BOOL GetDevicePropertyFromName(const TCHAR *DevicePath, DWORD Index, DWOR hDevice, IOCTL_STORAGE_QUERY_PROPERTY, &query, - sizeof(STORAGE_PROPERTY_QUERY), + sizeof (STORAGE_PROPERTY_QUERY), &outBuf, sizeof outBuf, &returnedLength, @@ -1434,7 +1414,6 @@ static int hdf_init2 (int force) #endif DWORD index = 0, index2 = 0, drive; uae_u8 *buffer; - UINT errormode; DWORD dwDriveMask; static int done; @@ -1445,7 +1424,6 @@ static int hdf_init2 (int force) #ifdef WINDDK buffer = (uae_u8*)VirtualAlloc (NULL, 65536, MEM_COMMIT, PAGE_READWRITE); if (buffer) { - errormode = SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); memset (uae_drives, 0, sizeof (uae_drives)); num_drives = 0; hIntDevInfo = SetupDiGetClassDevs (&GUID_DEVINTERFACE_DISK, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE); @@ -1474,7 +1452,6 @@ static int hdf_init2 (int force) } dwDriveMask >>= 1; } - SetErrorMode (errormode); #if 0 hIntDevInfo = SetupDiGetClassDevs (&GUID_DEVCLASS_MTD, NULL, NULL, DIGCF_PRESENT); if (hIntDevInfo != INVALID_HANDLE_VALUE) { @@ -1602,14 +1579,11 @@ static int hmc (struct hardfiledata *hfd) int first = 1; while (hfd->handle_valid) { - DWORD errormode; write_log (_T("testing if %s has media inserted\n"), hfd->emptyname); status = 0; - errormode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); SetFilePointer (hfd->handle->h, 0, NULL, FILE_BEGIN); ret = ReadFile (hfd->handle->h, buf, hfd->blocksize, &got, NULL); err = GetLastError (); - SetErrorMode(errormode); if (ret) { if (got == hfd->blocksize) { write_log (_T("read ok (%d)\n"), got); diff --git a/od-win32/mman.cpp b/od-win32/mman.cpp index dc58e518..bfd34ba8 100644 --- a/od-win32/mman.cpp +++ b/od-win32/mman.cpp @@ -18,10 +18,10 @@ uae_u32 max_z3fastmem; -/* JIT can access few bytes outside of memory block of it executes code at the very end of memory block */ +/* JIT can access few bytes outside of memory block if it executes code at the very end of memory block */ #define BARRIER 32 -#define MAXZ3MEM 0x7F000000 +#define MAXZ3MEM32 0x7F000000 #define MAXZ3MEM64 0xF0000000 static struct shmid_ds shmids[MAX_SHMID]; @@ -152,17 +152,17 @@ bool preinit_shm (void) } } size64 = total64; - if (maxmem < 0) - size64 = MAXZ3MEM; - else if (maxmem > 0) - size64 = maxmem * 1024 * 1024; if (os_64bit) { if (size64 > MAXZ3MEM64) size64 = MAXZ3MEM64; } else { - if (size64 > MAXZ3MEM) - size64 = MAXZ3MEM; + if (size64 > MAXZ3MEM32) + size64 = MAXZ3MEM32; } + if (maxmem < 0) + size64 = MAXZ3MEM64; + else if (maxmem > 0) + size64 = maxmem * 1024 * 1024; if (size64 < 8 * 1024 * 1024) size64 = 8 * 1024 * 1024; if (max_allowed_mman * 1024 * 1024 > size64) @@ -172,7 +172,7 @@ bool preinit_shm (void) if (natmem_size < 256 * 1024 * 1024) natmem_size = 256 * 1024 * 1024; - write_log (_T("Total physical RAM %uM\n"), totalphys64 >> 20); + write_log (_T("Total physical RAM %lluM. Attempting to reserve: %uM.\n"), totalphys64 >> 20, natmem_size >> 20); for (;;) { natmem_offset = (uae_u8*)VirtualAlloc (NULL, natmem_size, MEM_RESERVE | (VAMODE == 1 ? MEM_WRITE_WATCH : 0), PAGE_READWRITE); if (natmem_offset) @@ -184,7 +184,7 @@ bool preinit_shm (void) } } max_z3fastmem = natmem_size; - write_log (_T("NATMEM: Our special area: 0x%p-0x%p (%08x %dM)\n"), + write_log (_T("Reserved: 0x%p-0x%p (%08x %dM)\n"), natmem_offset, (uae_u8*)natmem_offset + natmem_size, natmem_size, natmem_size >> 20); @@ -196,7 +196,7 @@ bool preinit_shm (void) return true; } -static void resetmem (void) +static void resetmem (bool decommit) { int i; @@ -214,14 +214,18 @@ static void resetmem (void) continue; if (s->fake) continue; - if (((uae_u8*)s->attached - (uae_u8*)s->natmembase) >= 0x10000000) + if (!decommit && ((uae_u8*)s->attached - (uae_u8*)s->natmembase) >= 0x10000000) continue; shmaddr = natmem_offset + ((uae_u8*)s->attached - (uae_u8*)s->natmembase); - result = virtualallocwithlock (shmaddr, size, MEM_COMMIT, PAGE_READWRITE); - if (result != shmaddr) - write_log (_T("NATMEM: realloc(%p-%p,%d,%d,%s) failed, err=%d\n"), shmaddr, shmaddr + size, size, s->mode, s->name, GetLastError ()); - else - write_log (_T("NATMEM: rellocated(%p-%p,%d,%s)\n"), shmaddr, shmaddr + size, size, s->name); + if (decommit) { + VirtualFree (shmaddr, size, MEM_DECOMMIT); + } else { + result = virtualallocwithlock (shmaddr, size, decommit ? MEM_DECOMMIT : MEM_COMMIT, PAGE_READWRITE); + if (result != shmaddr) + write_log (_T("NATMEM: realloc(%p-%p,%d,%d,%s) failed, err=%d\n"), shmaddr, shmaddr + size, size, s->mode, s->name, GetLastError ()); + else + write_log (_T("NATMEM: rellocated(%p-%p,%d,%s)\n"), shmaddr, shmaddr + size, size, s->name); + } } } @@ -369,7 +373,7 @@ restart: natmem_offset_end = natmem_offset + natmemsize; } - resetmem (); + resetmem (false); return canbang; } @@ -570,13 +574,19 @@ bool init_shm (void) doinit_shm (); - resetmem (); + resetmem (false); clear_shm (); memory_hardreset (2); return true; } +void free_shm (void) +{ + resetmem (true); + clear_shm (); +} + void mapped_free (uae_u8 *mem) { shmpiece *x = shm_start; @@ -661,41 +671,34 @@ void *shmat (int shmid, void *shmaddr, int shmflg) got = TRUE; if (getz2endaddr () <= 2 * 1024 * 1024 || currprefs.chipmem_size < 2 * 1024 * 1024) size += BARRIER; - } - if(!_tcscmp (shmids[shmid].name, _T("kick"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("kick"))) { shmaddr=natmem_offset + 0xf80000; got = TRUE; size += BARRIER; readonly = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("rom_a8"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("rom_a8"))) { shmaddr=natmem_offset + 0xa80000; got = TRUE; readonly = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("rom_e0"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("rom_e0"))) { shmaddr=natmem_offset + 0xe00000; got = TRUE; readonly = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("rom_f0"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("rom_f0"))) { shmaddr=natmem_offset + 0xf00000; got = TRUE; readonly = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("rtarea"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("rtarea"))) { shmaddr=natmem_offset + rtarea_base; got = TRUE; readonly = TRUE; readonlysize = RTAREA_TRAPS; - } - if(!_tcscmp (shmids[shmid].name, _T("fast"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("fast"))) { shmaddr=natmem_offset + 0x200000; got = TRUE; if (!(currprefs.rtgmem_size && !currprefs.rtgmem_type)) size += BARRIER; - } - if(!_tcscmp (shmids[shmid].name, _T("z2_gfx"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("z2_gfx"))) { ULONG start = getz2rtgaddr (); got = TRUE; p96special = TRUE; @@ -703,45 +706,37 @@ void *shmat (int shmid, void *shmaddr, int shmflg) p96ram_start = start; if (start + currprefs.rtgmem_size < 10 * 1024 * 1024) size += BARRIER; - } - if(!_tcscmp (shmids[shmid].name, _T("ramsey_low"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("ramsey_low"))) { shmaddr=natmem_offset + a3000lmem_start; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("ramsey_high"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("ramsey_high"))) { shmaddr=natmem_offset + a3000hmem_start; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("z3"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("z3"))) { shmaddr=natmem_offset + z3fastmem_start; if (!currprefs.z3fastmem2_size) size += BARRIER; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("z3_2"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("z3_2"))) { shmaddr=natmem_offset + z3fastmem_start + currprefs.z3fastmem_size; size += BARRIER; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("z3_chip"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("z3_chip"))) { shmaddr=natmem_offset + z3chipmem_start; size += BARRIER; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("z3_gfx"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("z3_gfx"))) { got = TRUE; p96special = TRUE; p96ram_start = p96mem_offset - natmem_offset; shmaddr = natmem_offset + p96ram_start; size += BARRIER; - } - if(!_tcscmp (shmids[shmid].name, _T("bogo"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("bogo"))) { shmaddr=natmem_offset+0x00C00000; got = TRUE; if (currprefs.bogomem_size <= 0x100000) size += BARRIER; - } - if(!_tcscmp (shmids[shmid].name, _T("filesys"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("filesys"))) { static uae_u8 *filesysptr; if (filesysptr == NULL) filesysptr = xcalloc (uae_u8, size); @@ -749,61 +744,48 @@ void *shmat (int shmid, void *shmaddr, int shmflg) shmids[shmid].attached = result; shmids[shmid].fake = true; return result; - } - if(!_tcscmp (shmids[shmid].name, _T("custmem1"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("custmem1"))) { shmaddr=natmem_offset + currprefs.custom_memory_addrs[0]; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("custmem2"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("custmem2"))) { shmaddr=natmem_offset + currprefs.custom_memory_addrs[1]; got = TRUE; - } - - if(!_tcscmp (shmids[shmid].name, _T("hrtmem"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("hrtmem"))) { shmaddr=natmem_offset + 0x00a10000; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("arhrtmon"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("arhrtmon"))) { shmaddr=natmem_offset + 0x00800000; size += BARRIER; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("xpower_e2"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("xpower_e2"))) { shmaddr=natmem_offset + 0x00e20000; size += BARRIER; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("xpower_f2"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("xpower_f2"))) { shmaddr=natmem_offset + 0x00f20000; size += BARRIER; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("nordic_f0"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("nordic_f0"))) { shmaddr=natmem_offset + 0x00f00000; size += BARRIER; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("nordic_f4"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("nordic_f4"))) { shmaddr=natmem_offset + 0x00f40000; size += BARRIER; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("nordic_f6"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("nordic_f6"))) { shmaddr=natmem_offset + 0x00f60000; size += BARRIER; got = TRUE; - } - if(!_tcscmp(shmids[shmid].name, _T("superiv_b0"))) { + } else if(!_tcscmp(shmids[shmid].name, _T("superiv_b0"))) { shmaddr=natmem_offset + 0x00b00000; size += BARRIER; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("superiv_d0"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("superiv_d0"))) { shmaddr=natmem_offset + 0x00d00000; size += BARRIER; got = TRUE; - } - if(!_tcscmp (shmids[shmid].name, _T("superiv_e0"))) { + } else if(!_tcscmp (shmids[shmid].name, _T("superiv_e0"))) { shmaddr=natmem_offset + 0x00e00000; size += BARRIER; got = TRUE; diff --git a/od-win32/picasso96_win.cpp b/od-win32/picasso96_win.cpp index 1fe6205a..064f48c9 100644 --- a/od-win32/picasso96_win.cpp +++ b/od-win32/picasso96_win.cpp @@ -828,14 +828,12 @@ static void recursor (void) setspriteimage (boardinfo); } -static void setconvert (void) +static int getconvert (int rgbformat, int pixbytes) { - static int ohost_mode, orgbformat; - int d = picasso_vidinfo.pixbytes; - int v; + int v = 0; + int d = pixbytes; - v = 0; - switch (picasso96_state.RGBFormat) + switch (rgbformat) { case RGBFB_CLUT: if (d == 1) @@ -921,20 +919,28 @@ static void setconvert (void) v = RGBFB_R8G8B8A8_32; break; } - picasso_convert = v; + return v; +} + +static void setconvert (void) +{ + static int ohost_mode, orgbformat; + + picasso_convert = getconvert (picasso96_state.RGBFormat, picasso_vidinfo.pixbytes); if (currprefs.gfx_api) { - host_mode = d == 4 ? RGBFB_B8G8R8A8 : RGBFB_B5G6R5PC; + host_mode = picasso_vidinfo.pixbytes == 4 ? RGBFB_B8G8R8A8 : RGBFB_B5G6R5PC; } else { host_mode = DirectDraw_GetSurfacePixelFormat (NULL); } - if (d == 4) + if (picasso_vidinfo.pixbytes == 4) alloc_colors_rgb (8, 8, 8, 16, 8, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc); else alloc_colors_rgb (5, 6, 5, 11, 5, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc); gfx_set_picasso_colors (picasso96_state.RGBFormat); picasso_palette (); if (host_mode != ohost_mode || picasso96_state.RGBFormat != orgbformat) { - write_log (_T("RTG conversion: Depth=%d HostRGBF=%d P96RGBF=%d Mode=%d\n"), d, host_mode, picasso96_state.RGBFormat, v); + write_log (_T("RTG conversion: Depth=%d HostRGBF=%d P96RGBF=%d Mode=%d\n"), + picasso_vidinfo.pixbytes, host_mode, picasso96_state.RGBFormat, picasso_convert); ohost_mode = host_mode; orgbformat = picasso96_state.RGBFormat; } @@ -2427,6 +2433,8 @@ static uae_u32 REGPARAM2 picasso_SetColorArray (TrapContext *ctx) uae_u16 count = m68k_dreg (regs, 1); uaecptr boardinfo = m68k_areg (regs, 0); uaecptr clut = boardinfo + PSSO_BoardInfo_CLUT; + if (start > 256 || start + count > 256) + return 0; if (updateclut (clut, start, count)) full_refresh = 1; P96TRACE((_T("SetColorArray(%d,%d)\n"), start, count)); @@ -3631,21 +3639,21 @@ static void statusline (uae_u8 *dst) } } -static void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width) +static void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width, int srcbytesperrow, int srcpixbytes, int dstbytesperrow, int dstpixbytes, bool direct, int convert_mode) { - uae_u8 *src2 = src + y * picasso96_state.BytesPerRow; - uae_u8 *dst2 = dst + y * picasso_vidinfo.rowbytes; + uae_u8 *src2 = src + y * srcbytesperrow; + uae_u8 *dst2 = dst + y * dstbytesperrow; int endx = x + width, endx4; - int dstpix = picasso_vidinfo.pixbytes; - int srcpix = picasso96_state.BytesPerPixel; + int dstpix = dstpixbytes; + int srcpix = srcpixbytes; - if (picasso96_state.RGBFormat == host_mode) { + if (direct) { memcpy (dst2 + x * dstpix, src2 + x * srcpix, width * dstpix); return; } // native match? if (currprefs.gfx_api) { - switch (picasso_convert) + switch (convert_mode) { case RGBFB_B8G8R8A8_32: case RGBFB_R5G6B5PC_16: @@ -3653,7 +3661,7 @@ static void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width) return; } } else { - switch (picasso_convert) + switch (convert_mode) { case RGBFB_B8G8R8A8_32: case RGBFB_R5G6B5PC_16: @@ -3664,7 +3672,7 @@ static void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width) endx4 = endx & ~3; - switch (picasso_convert) + switch (convert_mode) { /* 24bit->32bit */ case RGBFB_R8G8B8_32: @@ -3862,46 +3870,99 @@ static void copyrow (uae_u8 *src, uae_u8 *dst, int x, int y, int width) } } -static void copyallinvert (uae_u8 *src, uae_u8 *dst, int pwidth, int pheight) +static void copyallinvert (uae_u8 *src, uae_u8 *dst, int pwidth, int pheight, int srcbytesperrow, int srcpixbytes, int dstbytesperrow, int dstpixbytes, bool direct, int mode_convert) { int x, y, w; - w = pwidth * picasso_vidinfo.pixbytes; - if (picasso96_state.RGBFormat == host_mode) { + w = pwidth * dstpixbytes; + if (direct) { for (y = 0; y < pheight; y++) { for (x = 0; x < w; x++) dst[x] = src[x] ^ 0xff; - dst += picasso_vidinfo.rowbytes; - src += picasso96_state.BytesPerRow; + dst += dstbytesperrow; + src += srcbytesperrow; } } else { uae_u8 *src2 = src; for (y = 0; y < pheight; y++) { for (x = 0; x < w; x++) src2[x] ^= 0xff; - copyrow (src, dst, 0, y, pwidth); + copyrow (src, dst, 0, y, pwidth, srcbytesperrow, srcpixbytes, dstbytesperrow, dstpixbytes, direct, mode_convert); for (x = 0; x < w; x++) src2[x] ^= 0xff; - src2 += picasso96_state.BytesPerRow; + src2 += srcbytesperrow; } } } -static void copyall (uae_u8 *src, uae_u8 *dst, int pwidth, int pheight) +static void copyall (uae_u8 *src, uae_u8 *dst, int pwidth, int pheight, int srcbytesperrow, int srcpixbytes, int dstbytesperrow, int dstpixbytes, bool direct, int mode_convert) { int y; - if (picasso96_state.RGBFormat == host_mode) { + if (direct) { int w = pwidth * picasso_vidinfo.pixbytes; for (y = 0; y < pheight; y++) { memcpy (dst, src, w); - dst += picasso_vidinfo.rowbytes; - src += picasso96_state.BytesPerRow; + dst += dstbytesperrow; + src += srcbytesperrow; } } else { for (y = 0; y < pheight; y++) - copyrow (src, dst, 0, y, pwidth); + copyrow (src, dst, 0, y, pwidth, srcbytesperrow, srcpixbytes, dstbytesperrow, dstpixbytes, direct, mode_convert); + } +} + +uae_u8 *getrtgbuffer (int *widthp, int *heightp, int *pitch, int *depth, uae_u8 *palette) +{ + uae_u8 *src = p96ram_start + natmem_offset; + int off = picasso96_state.XYOffset - gfxmem_start; + int width, height, pixbytes; + uae_u8 *dst; + int convert; + int hmode; + + if (!picasso_vidinfo.extra_mem) + return NULL; + + width = picasso96_state.VirtualWidth; + height = picasso96_state.VirtualHeight; + pixbytes = picasso96_state.BytesPerPixel == 1 && palette ? 1 : 4; + + dst = xmalloc (uae_u8, width * height * pixbytes); + if (!dst) + return NULL; + hmode = pixbytes == 1 ? RGBFB_CLUT : RGBFB_B8G8R8A8; + convert = getconvert (picasso96_state.RGBFormat, pixbytes); + + if (pixbytes > 1 && hmode != convert) { + copyall (src + off, dst, width, height, picasso96_state.BytesPerRow, picasso96_state.BytesPerPixel, width * pixbytes, pixbytes, false, convert); + } else { + uae_u8 *dstp = dst; + uae_u8 *srcp = src; + for (int y = 0; y < height; y++) { + memcpy (dstp, srcp, width * pixbytes); + dstp += width * pixbytes; + srcp += picasso96_state.BytesPerRow; + } } + if (pixbytes == 1) { + for (int i = 0; i < 256; i++) { + palette[i * 3 + 0] = picasso96_state.CLUT[i].Red; + palette[i * 3 + 1] = picasso96_state.CLUT[i].Green; + palette[i * 3 + 2] = picasso96_state.CLUT[i].Blue; + } + } + + *widthp = width; + *heightp = height; + *pitch = width * pixbytes; + *depth = pixbytes * 8; + + return dst; +} +void freertgbuffer (uae_u8 *dst) +{ + xfree (dst); } static bool flushpixels (void) @@ -3974,9 +4035,16 @@ static bool flushpixels (void) if (dofull) { if (flashscreen != 0) - copyallinvert (src + off, dst, pwidth, pheight); + copyallinvert (src + off, dst, pwidth, pheight, + picasso96_state.BytesPerRow, picasso96_state.BytesPerPixel, + picasso_vidinfo.rowbytes, picasso_vidinfo.pixbytes, + picasso96_state.RGBFormat == host_mode, picasso_convert); else - copyall (src + off, dst, pwidth, pheight); + copyall (src + off, dst, pwidth, pheight, + picasso96_state.BytesPerRow, picasso96_state.BytesPerPixel, + picasso_vidinfo.rowbytes, picasso_vidinfo.pixbytes, + picasso96_state.RGBFormat == host_mode, picasso_convert); + miny = 0; maxy = pheight; break; @@ -3999,14 +4067,20 @@ static bool flushpixels (void) int w = gwwpagesize / picasso96_state.BytesPerPixel; x = (realoffset % picasso96_state.BytesPerRow) / picasso96_state.BytesPerPixel; if (x < pwidth) - copyrow (src + off, dst, x, y, pwidth - x); + copyrow (src + off, dst, x, y, pwidth - x, + picasso96_state.BytesPerRow, picasso96_state.BytesPerPixel, + picasso_vidinfo.rowbytes, picasso_vidinfo.pixbytes, + picasso96_state.RGBFormat == host_mode, picasso_convert); w = (gwwpagesize - (picasso96_state.BytesPerRow - x * picasso96_state.BytesPerPixel)) / picasso96_state.BytesPerPixel; if (y < miny) miny = y; y++; while (y < pheight && w > 0) { int maxw = w > pwidth ? pwidth : w; - copyrow (src + off, dst, 0, y, maxw); + copyrow (src + off, dst, 0, y, maxw, + picasso96_state.BytesPerRow, picasso96_state.BytesPerPixel, + picasso_vidinfo.rowbytes, picasso_vidinfo.pixbytes, + picasso96_state.RGBFormat == host_mode, picasso_convert); w -= maxw; y++; } @@ -4409,13 +4483,15 @@ static void inituaegfxfuncs (uaecptr start, uaecptr ABI) void picasso_reset (void) { - uaegfx_base = 0; - uaegfx_old = 0; - uaegfx_active = 0; - interrupt_enabled = 0; - reserved_gfxmem = 0; - resetpalette (); - InitPicasso96 (); + if (savestate_state != STATE_RESTORE) { + uaegfx_base = 0; + uaegfx_old = 0; + uaegfx_active = 0; + interrupt_enabled = 0; + reserved_gfxmem = 0; + resetpalette (); + InitPicasso96 (); + } } void uaegfx_install_code (uaecptr start) @@ -4566,10 +4642,15 @@ void restore_p96_finish (void) init_alloc (NULL, 0); if (uaegfx_rom && boardinfo) inituaegfxfuncs (uaegfx_rom, boardinfo); - if (set_gc_called) { +#if 0 + if (picasso_requested_on) { + picasso_on = true; + set_gc_called = 1; init_picasso_screen (); init_hz_p96 (); + picasso_refresh (); } +#endif } uae_u8 *restore_p96 (uae_u8 *src) @@ -4608,6 +4689,13 @@ uae_u8 *restore_p96 (uae_u8 *src) boardinfo = restore_u32 (); for (i = 0; i < 4; i++) cursorrgb[i] = restore_u32 (); + if (flags & 64) { + for (i = 0; i < 256; i++) { + picasso96_state.CLUT[i].Red = restore_u8 (); + picasso96_state.CLUT[i].Green = restore_u8 (); + picasso96_state.CLUT[i].Blue = restore_u8 (); + } + } picasso96_state.HostAddress = NULL; picasso_SetPanningInit(); picasso96_state.Extent = picasso96_state.Address + picasso96_state.BytesPerRow * picasso96_state.VirtualHeight; @@ -4627,7 +4715,7 @@ uae_u8 *save_p96 (int *len, uae_u8 *dstptr) dstbak = dst = xmalloc (uae_u8, 1000); save_u32 (2); save_u32 ((picasso_on ? 1 : 0) | (set_gc_called ? 2 : 0) | (set_panning_called ? 4 : 0) | - (hwsprite ? 8 : 0) | (cursorvisible ? 16 : 0) | (interrupt_enabled ? 32 : 0)); + (hwsprite ? 8 : 0) | (cursorvisible ? 16 : 0) | (interrupt_enabled ? 32 : 0) | 64); save_u32 (currprefs.rtgmem_size); save_u32 (picasso96_state.Address); save_u32 (picasso96_state.RGBFormat); @@ -4646,6 +4734,11 @@ uae_u8 *save_p96 (int *len, uae_u8 *dstptr) save_u32 (boardinfo); for (i = 0; i < 4; i++) save_u32 (cursorrgb[i]); + for (i = 0; i < 256; i++) { + save_u8 (picasso96_state.CLUT[i].Red); + save_u8 (picasso96_state.CLUT[i].Green); + save_u8 (picasso96_state.CLUT[i].Blue); + } *len = dst - dstbak; return dstbak; } diff --git a/od-win32/screenshot.cpp b/od-win32/screenshot.cpp index f4939569..6c02511b 100644 --- a/od-win32/screenshot.cpp +++ b/od-win32/screenshot.cpp @@ -68,7 +68,7 @@ static int toclipboard (BITMAPINFO *bi, void *bmp) } static HDC surface_dc, offscreen_dc; -static BITMAPINFO bi; // bitmap info +static BITMAPINFO *bi; // bitmap info static LPVOID lpvBits = NULL; // pointer to bitmap bits array static HBITMAP offscreen_bitmap; static int screenshot_prepared; @@ -102,65 +102,102 @@ int screenshot_prepare (void) regqueryint (NULL, _T("Screenshot_Original"), &screenshot_originalsize); - if (screenshot_originalsize && !WIN32GFX_IsPicassoScreen ()) { + if (screenshot_originalsize) { int spitch, dpitch, x, y; - uae_u8 *src, *dst; + uae_u8 *src, *dst, *mem; + uae_u8 *palette = NULL; + int rgb_bb2, rgb_gb2, rgb_rb2; + int rgb_bs2, rgb_gs2, rgb_rs2; + uae_u8 pal[256 * 3]; - src = getfilterbuffer (&width, &height, &spitch, &bits); + if (WIN32GFX_IsPicassoScreen ()) { + src = mem = getrtgbuffer (&width, &height, &spitch, &bits, pal); + rgb_bb2 = 8; + rgb_gb2 = 8; + rgb_rb2 = 8; + rgb_bs2 = 0; + rgb_gs2 = 8; + rgb_rs2 = 16; + } else { + src = mem = getfilterbuffer (&width, &height, &spitch, &bits); + rgb_bb2 = rgb_bb; + rgb_gb2 = rgb_gb; + rgb_rb2 = rgb_rb; + rgb_bs2 = rgb_bs; + rgb_gs2 = rgb_gs; + rgb_rs2 = rgb_rs; + } if (src == NULL || width == 0 || height == 0) goto donormal; - ZeroMemory (&bi, sizeof(bi)); - bi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER); - bi.bmiHeader.biWidth = width; - bi.bmiHeader.biHeight = height; - bi.bmiHeader.biPlanes = 1; - bi.bmiHeader.biBitCount = 24; - bi.bmiHeader.biCompression = BI_RGB; - dpitch = ((bi.bmiHeader.biWidth * bi.bmiHeader.biBitCount + 31) & ~31) / 8; - bi.bmiHeader.biSizeImage = dpitch * bi.bmiHeader.biHeight; - bi.bmiHeader.biXPelsPerMeter = 0; - bi.bmiHeader.biYPelsPerMeter = 0; - bi.bmiHeader.biClrUsed = 0; - bi.bmiHeader.biClrImportant = 0; - if (!(lpvBits = xmalloc (uae_u8, bi.bmiHeader.biSizeImage))) + ZeroMemory (bi, sizeof(bi)); + bi->bmiHeader.biSize = sizeof (BITMAPINFOHEADER); + bi->bmiHeader.biWidth = width; + bi->bmiHeader.biHeight = height; + bi->bmiHeader.biPlanes = 1; + bi->bmiHeader.biBitCount = bits <= 8 ? 8 : 24; + bi->bmiHeader.biCompression = BI_RGB; + dpitch = ((bi->bmiHeader.biWidth * bi->bmiHeader.biBitCount + 31) & ~31) / 8; + bi->bmiHeader.biSizeImage = dpitch * bi->bmiHeader.biHeight; + bi->bmiHeader.biXPelsPerMeter = 0; + bi->bmiHeader.biYPelsPerMeter = 0; + bi->bmiHeader.biClrUsed = bits <= 8 ? (1 << bits) : 0; + bi->bmiHeader.biClrImportant = bi->bmiHeader.biClrUsed; + if (bits <= 8) { + for (int i = 0; i < bi->bmiHeader.biClrUsed; i++) { + bi->bmiColors[i].rgbRed = pal[i * 3 + 0]; + bi->bmiColors[i].rgbGreen = pal[i * 3 + 1]; + bi->bmiColors[i].rgbBlue = pal[i * 3 + 2]; + } + } + if (!(lpvBits = xmalloc (uae_u8, bi->bmiHeader.biSizeImage))) goto oops; dst = (uae_u8*)lpvBits + (height - 1) * dpitch; - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - int shift; - uae_u32 v = 0; - uae_u32 v2; - - if (bits == 16) - v = ((uae_u16*)src)[x]; - else if (bits == 32) - v = ((uae_u32*)src)[x]; - - shift = 8 - rgb_bb; - v2 = (v >> rgb_bs) & ((1 << rgb_bb) - 1); - v2 <<= shift; - if (rgb_bb < 8) - v2 |= (v2 >> shift) & ((1 < shift) - 1); - dst[x * 3 + 0] = v2; - - shift = 8 - rgb_gb; - v2 = (v >> rgb_gs) & ((1 << rgb_gb) - 1); - v2 <<= (8 - rgb_gb); - if (rgb_gb < 8) - v2 |= (v2 >> shift) & ((1 < shift) - 1); - dst[x * 3 + 1] = v2; - - shift = 8 - rgb_rb; - v2 = (v >> rgb_rs) & ((1 << rgb_rb) - 1); - v2 <<= (8 - rgb_rb); - if (rgb_rb < 8) - v2 |= (v2 >> shift) & ((1 < shift) - 1); - dst[x * 3 + 2] = v2; - + if (bits <=8) { + for (y = 0; y < height; y++) { + memcpy (dst, src, width); + src += spitch; + dst -= dpitch; + } + } else { + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + int shift; + uae_u32 v = 0; + uae_u32 v2; + + if (bits == 16) + v = ((uae_u16*)src)[x]; + else if (bits == 32) + v = ((uae_u32*)src)[x]; + + shift = 8 - rgb_bb2; + v2 = (v >> rgb_bs2) & ((1 << rgb_bb2) - 1); + v2 <<= shift; + if (rgb_bb2 < 8) + v2 |= (v2 >> shift) & ((1 < shift) - 1); + dst[x * 3 + 0] = v2; + + shift = 8 - rgb_gb2; + v2 = (v >> rgb_gs2) & ((1 << rgb_gb2) - 1); + v2 <<= (8 - rgb_gb2); + if (rgb_gb < 8) + v2 |= (v2 >> shift) & ((1 < shift) - 1); + dst[x * 3 + 1] = v2; + + shift = 8 - rgb_rb2; + v2 = (v >> rgb_rs2) & ((1 << rgb_rb2) - 1); + v2 <<= (8 - rgb_rb2); + if (rgb_rb < 8) + v2 |= (v2 >> shift) & ((1 < shift) - 1); + dst[x * 3 + 2] = v2; + + } + src += spitch; + dst -= dpitch; } - src += spitch; - dst -= dpitch; } + if (WIN32GFX_IsPicassoScreen ()) + freertgbuffer (mem); } else { donormal: @@ -189,25 +226,25 @@ donormal: // de-select offscreen_bitmap SelectObject (offscreen_dc, hgdiobj); - ZeroMemory (&bi, sizeof(bi)); - bi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER); - bi.bmiHeader.biWidth = width; - bi.bmiHeader.biHeight = height; - bi.bmiHeader.biPlanes = 1; - bi.bmiHeader.biBitCount = 24; - bi.bmiHeader.biCompression = BI_RGB; - bi.bmiHeader.biSizeImage = (((bi.bmiHeader.biWidth * bi.bmiHeader.biBitCount + 31) & ~31) / 8) * bi.bmiHeader.biHeight; - bi.bmiHeader.biXPelsPerMeter = 0; - bi.bmiHeader.biYPelsPerMeter = 0; - bi.bmiHeader.biClrUsed = 0; - bi.bmiHeader.biClrImportant = 0; + ZeroMemory (bi, sizeof(bi)); + bi->bmiHeader.biSize = sizeof (BITMAPINFOHEADER); + bi->bmiHeader.biWidth = width; + bi->bmiHeader.biHeight = height; + bi->bmiHeader.biPlanes = 1; + bi->bmiHeader.biBitCount = 24; + bi->bmiHeader.biCompression = BI_RGB; + bi->bmiHeader.biSizeImage = (((bi->bmiHeader.biWidth * bi->bmiHeader.biBitCount + 31) & ~31) / 8) * bi->bmiHeader.biHeight; + bi->bmiHeader.biXPelsPerMeter = 0; + bi->bmiHeader.biYPelsPerMeter = 0; + bi->bmiHeader.biClrUsed = 0; + bi->bmiHeader.biClrImportant = 0; // Reserve memory for bitmap bits - if (!(lpvBits = xmalloc (uae_u8, bi.bmiHeader.biSizeImage))) + if (!(lpvBits = xmalloc (uae_u8, bi->bmiHeader.biSizeImage))) goto oops; // out of memory // Have GetDIBits convert offscreen_bitmap to a DIB (device-independent bitmap): - if (!GetDIBits (offscreen_dc, offscreen_bitmap, 0, bi.bmiHeader.biHeight, lpvBits, &bi, DIB_RGB_COLORS)) + if (!GetDIBits (offscreen_dc, offscreen_bitmap, 0, bi->bmiHeader.biHeight, lpvBits, bi, DIB_RGB_COLORS)) goto oops; // GetDIBits FAILED releasehdc (surface_dc); @@ -223,6 +260,8 @@ oops: void Screenshot_RGBinfo (int rb, int gb, int bb, int rs, int gs, int bs) { + if (!bi) + bi = xcalloc (BITMAPINFO, sizeof BITMAPINFO + 256 * sizeof RGBQUAD); rgb_rb = rb; rgb_gb = gb; rgb_bb = rb; @@ -249,8 +288,10 @@ static int savepng (FILE *fp) png_structp png_ptr; png_infop info_ptr; png_bytep *row_pointers; - int h = bi.bmiHeader.biHeight; - int w = bi.bmiHeader.biWidth; + int h = bi->bmiHeader.biHeight; + int w = bi->bmiHeader.biWidth; + int d = bi->bmiHeader.biBitCount; + png_color pngpal[256]; int i; png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, pngtest_blah, pngtest_blah, pngtest_blah); @@ -269,16 +310,25 @@ static int savepng (FILE *fp) png_init_io (png_ptr, fp); png_set_filter (png_ptr, 0, PNG_FILTER_NONE); png_set_IHDR (png_ptr, info_ptr, - w, h, 8, PNG_COLOR_TYPE_RGB, + w, h, 8, d <= 8 ? PNG_COLOR_TYPE_PALETTE : PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + if (d <= 8) { + for (i = 0; i < (1 << d); i++) { + pngpal[i].red = bi->bmiColors[i].rgbRed; + pngpal[i].green = bi->bmiColors[i].rgbGreen; + pngpal[i].blue = bi->bmiColors[i].rgbBlue; + } + png_set_PLTE (png_ptr, info_ptr, pngpal, 1 << d); + } row_pointers = xmalloc (png_bytep, h); for (i = 0; i < h; i++) { int j = h - i - 1; - row_pointers[i] = (uae_u8*)lpvBits + j * (((w * 24 + 31) & ~31) / 8); + row_pointers[i] = (uae_u8*)lpvBits + j * (((w * (d <= 8 ? 8 : 24) + 31) & ~31) / 8); } png_set_rows (png_ptr, info_ptr, row_pointers); png_write_png (png_ptr,info_ptr, PNG_TRANSFORM_BGR, NULL); png_destroy_write_struct (&png_ptr, &info_ptr); + xfree (row_pointers); return 1; } #endif @@ -288,15 +338,19 @@ static int savebmp (FILE *fp) BITMAPFILEHEADER bfh; // write the file header, bitmap information and pixel data bfh.bfType = 19778; - bfh.bfSize = sizeof (BITMAPFILEHEADER) + sizeof (BITMAPINFOHEADER) + bi.bmiHeader.biSizeImage; + bfh.bfSize = sizeof (BITMAPFILEHEADER) + sizeof (BITMAPINFOHEADER) + (bi->bmiHeader.biClrUsed * sizeof RGBQUAD) + bi->bmiHeader.biSizeImage; bfh.bfReserved1 = 0; bfh.bfReserved2 = 0; - bfh.bfOffBits = sizeof (BITMAPFILEHEADER) + sizeof (BITMAPINFOHEADER); + bfh.bfOffBits = sizeof (BITMAPFILEHEADER) + sizeof (BITMAPINFOHEADER) + bi->bmiHeader.biClrUsed * sizeof RGBQUAD; if (fwrite (&bfh, 1, sizeof (BITMAPFILEHEADER), fp) < sizeof (BITMAPFILEHEADER)) return 0; // failed to write bitmap file header + if (bi->bmiHeader.biClrUsed) { + if (fwrite (bi->bmiColors, 1, bi->bmiHeader.biClrUsed * sizeof RGBQUAD, fp) < bi->bmiHeader.biClrUsed * sizeof RGBQUAD) + return 0; // failed to write bitmap file header + } if (fwrite (&bi, 1, sizeof (BITMAPINFOHEADER), fp) < sizeof (BITMAPINFOHEADER)) return 0; // failed to write bitmap infomation header - if (fwrite (lpvBits, 1, bi.bmiHeader.biSizeImage, fp) < bi.bmiHeader.biSizeImage) + if (fwrite (lpvBits, 1, bi->bmiHeader.biSizeImage, fp) < bi->bmiHeader.biSizeImage) return 0; // failed to write the bitmap return 1; } @@ -324,7 +378,7 @@ int screenshotf (const TCHAR *spath, int mode, int doprepare) } if (mode == 0) { - toclipboard (&bi, lpvBits); + toclipboard (bi, lpvBits); } else { TCHAR filename[MAX_DPATH]; TCHAR path[MAX_DPATH]; @@ -389,7 +443,7 @@ oops: fclose (fp); if (doprepare) - screenshot_free(); + screenshot_free (); recursive--; diff --git a/od-win32/sys/mman.h b/od-win32/sys/mman.h index 4e3fbabd..2edb8feb 100644 --- a/od-win32/sys/mman.h +++ b/od-win32/sys/mman.h @@ -36,6 +36,7 @@ int shmdt (const void *shmaddr); int shmget (key_t key, size_t size, int shmflg, const TCHAR*); int shmctl (int shmid, int cmd, struct shmid_ds *buf); bool init_shm (void); +void free_shm (void); #define PROT_READ 0x01 #define PROT_WRITE 0x02 diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 0658712e..229c8054 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -5865,6 +5865,7 @@ int PASCAL wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdL } #endif #endif + SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); SetDllDirectory (_T("")); /* Make sure we do an InitCommonControls() to get some advanced controls */ InitCommonControls (); diff --git a/od-win32/win32.h b/od-win32/win32.h index 72219b3d..d5a2737d 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -19,8 +19,8 @@ #define LANG_DLL 1 //#define WINUAEBETA _T("") -#define WINUAEBETA _T("7") -#define WINUAEDATE MAKEBD(2012, 7, 20) +#define WINUAEBETA _T("9") +#define WINUAEDATE MAKEBD(2012, 8, 1) #define WINUAEEXTRA _T("") //#define WINUAEEXTRA _T("AmiKit Preview") #define WINUAEREV _T("") diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 27c62abb..c7895b09 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -8070,7 +8070,7 @@ static void enable_for_cpudlg (HWND hDlg) ew (hDlg, IDC_CS_CACHE_TEXT, enable); ew (hDlg, IDC_CACHE, enable); ew (hDlg, IDC_JITENABLE, jitenable); - ew (hDlg, IDC_COMPATIBLE, !workprefs.cpu_cycle_exact && !workprefs.cachesize); + ew (hDlg, IDC_COMPATIBLE, (!workprefs.cpu_cycle_exact && !workprefs.cachesize) || workprefs.cpu_model >= 68040); ew (hDlg, IDC_COMPATIBLE_FPU, workprefs.fpu_model > 0); #if 0 ew (hDlg, IDC_CPU_MULTIPLIER, workprefs.cpu_cycle_exact); @@ -8238,8 +8238,6 @@ static void values_from_cpudlg (HWND hDlg) if (workprefs.cpu_idle > 0) workprefs.cpu_idle = (12 - workprefs.cpu_idle) * 15; - if (workprefs.cachesize > 0) - workprefs.cpu_compatible = 0; if (pages[KICKSTART_ID]) SendMessage (pages[KICKSTART_ID], WM_USER, 0, 0); if (pages[DISPLAY_ID]) diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 6547e21a..3d47a0f5 100644 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -1,6 +1,40 @@ - restore only single input target to default. +Beta 9: + +- Replaced readpu.c 68020+ special case TST An/PC-rel and CMP #imm,PC-rel variants with proper table68k entries. +- Debugger disassembler decodes illegal instructions if opcode is supported by higher CPU model, + shown in parenthesis, note that PC is only incremented by 2 in this situation. +- Debugger W (write to memory) command supports multiple values and strings. +- Slow debugger commands can be aborted by pressing return (console only) +- 64-bit DIVL.L checked div by zero exception before checking if instruction is 68060 compatible. +- Use IOCTL_STORAGE_QUERY_PROPERTY to query optical drive vendor/product/version information instead of SCSI inquiry. +- "Take screenshots before filtering" supported in RTG modes, takes screenshot from emulated VRAM buffer. + 8-bit png if 8-bit RTG mode, 24-bit png if >8 bit RTG mode. Does not capture mouse if mouse is emulated hardware sprite. +- "Capture before filtering" recording option supported in RTG modes. +- D3D D3DERR_DEVICELOST handling improved. +- Inhibit Windows error dialogs completely. On some systems missing harddrive still opened annoying Windows no disk error dialog(s). +- Improved extended ROM statefile support. +- Save ROM overlay state to statefile separately from CIA OVL pin state, fixes loading of statefiles if current configuration has + CIA overlay support but state configuration does not. (Gayle based chipset or CD32) +- Misc statefile load compatibility improvements when current config is very different compared to statefile's configuration. +- DMA debugger 'c' = copper wanted this cycle but it wasn't available +- BPLxDAT non-DMA modifications emulated while bitplane DMA is disabled, not perfect but at least screen isn't completely blank anymore. +- Ancient Superfrog copper hack removed, it isn't needed anymore. (EyeQlazer/Scoopex is nearly correct now) + +Beta 8: + +- 68060 and CPU compatible checkbox ticked: generate unimplemented instruction exceptions instead of emulating instructions + that real 68060 don't have. Integer instructions only, 040/060 FPU emulation still supports all 6888x instructions. +- Set FPU FPIAR register (No one shouldn't care, except unimplemented FPU exception handler which isn't supported) +- RTG state restore broke in previous update. +- Save RTG mode palette to statefile (Quite important missing information if dislay mode is 8-bit..) +- More memory space reservation updates. +- "Restart" GUI option improved, shouldn't cause strange errors if new config has 32-bit RAM enabled and old one didn't. +- Savestates with 32-bit RAM configured should now load without need to first load configuration that has same amount + (or more) RAM configured. + Beta 7: - Directory filesystem 64-bit seek (ACTION_CHANGE_FILE_POSITION64) broke in 240b27 diff --git a/od-win32/writelog.cpp b/od-win32/writelog.cpp index 5e014b01..b6c61969 100644 --- a/od-win32/writelog.cpp +++ b/od-win32/writelog.cpp @@ -300,6 +300,18 @@ void console_out (const TCHAR *txt) console_put (txt); } +bool console_isch (void) +{ + if (realconsole) { + return false; + } else if (consoleopen < 0) { + DWORD events = 0; + GetNumberOfConsoleInputEvents (stdinput, &events); + return events > 0; + } + return false; +} + TCHAR console_getch (void) { if (realconsole) { diff --git a/readcpu.cpp b/readcpu.cpp index aa8eb763..018b4d6b 100644 --- a/readcpu.cpp +++ b/readcpu.cpp @@ -154,28 +154,6 @@ struct mnemolookup lookuptab[] = { struct instr *table68k; -static int specialcase (uae_u16 opcode, int cpu_lev) -{ - int mode = (opcode >> 3) & 7; - int reg = opcode & 7; - - if (cpu_lev >= 2) - return cpu_lev; - /* TST.W A0, TST.L A0, TST.x (d16,PC) and TST.x (d8,PC,Xn) are 68020+ only */ - if ((opcode & 0xff00) == 0x4a00) { - if (mode == 7 && (reg == 4 || reg == 2 || reg == 3)) - return 2; - if (mode == 1) /* Ax */ - return 2; - } - /* CMPI.W #x,(d16,PC) and CMPI.W #x,(d8,PC,Xn) are 68020+ only */ - if ((opcode & 0xff00) == 0x0c00) { - if (mode == 7 && (reg == 2 || reg == 3)) - return 2; - } - return cpu_lev; -} - static amodes mode_from_str (const TCHAR *str) { if (_tcsncmp (str, _T("Dreg"), 4) == 0) return Dreg; @@ -751,7 +729,8 @@ endofline: table68k[opc].duse = usedst; table68k[opc].stype = srctype; table68k[opc].plev = id.plevel; - table68k[opc].clev = specialcase(opc, id.cpulevel); + table68k[opc].clev = id.cpulevel; + table68k[opc].unimpclev = id.unimpcpulevel; #if 0 for (i = 0; i < 5; i++) { diff --git a/table68k b/table68k index 8d0a165a..6ddaad4c 100644 --- a/table68k +++ b/table68k @@ -84,13 +84,14 @@ 0000 1010 0011 1100:000:XNZVC:XNZVC:10: EORSR.B #1 0000 1010 0111 1100:002:?????:?????:10: EORSR.W #1 0000 1010 zzdd dDDD:000:-NZ00:-----:13: EOR.z #z,d[!Areg] -0000 1100 zzss sSSS:000:-NZVC:-----:11: CMP.z #z,s[!Areg,Immd] +0000 1100 zzss sSSS:000:-NZVC:-----:11: CMP.z #z,s[!Areg,Immd,PC8r,PC16] +0000 1100 zzss sSSS:200:-NZVC:-----:11: CMP.z #z,s[PC8r,PC16] 0000 1010 11ss sSSS:200:?????:?????:13: CAS.B #1,s[!Dreg,Areg,Immd,PC8r,PC16] 0000 1100 11ss sSSS:200:?????:?????:13: CAS.W #1,s[!Dreg,Areg,Immd,PC8r,PC16] 0000 1100 1111 1100:250:?????:?????:10: CAS2.W #2 0000 1110 zzss sSSS:202:?????:?????:13: MOVES.z #1,s[!Dreg,Areg,Immd,PC8r,PC16] -0000 1110 11ss sSSS:250:?????:?????:13: CAS.L #1,s[!Dreg,Areg,Immd,PC8r,PC16] +0000 1110 11ss sSSS:200:?????:?????:13: CAS.L #1,s[!Dreg,Areg,Immd,PC8r,PC16] 0000 1110 1111 1100:250:?????:?????:10: CAS2.L #2 0000 rrr1 00dd dDDD:000:-----:-----:12: MVPMR.W d[Areg-Ad16],Dr @@ -126,11 +127,12 @@ 0100 1000 11dd dDDD:000:-NZ00:-----:30: EXT.L d[Dreg] 0100 1000 11dd dDDD:000:-----:-----:02: MVMLE.L #1,d[!Dreg,Areg,Aipi] 0100 1001 11dd dDDD:200:-NZ00:-----:30: EXT.B d[Dreg] -0100 1010 zzss sSSS:000:-NZ00:-----:10: TST.z s +0100 1010 zzss sSSS:000:-NZ00:-----:10: TST.z s[!Areg,PC16,PC8r] +0100 1010 zzss sSSS:200:-NZ00:-----:10: TST.z s[Areg,PC16,PC8r] 0100 1010 11dd dDDD:000:?????:?????:30: TAS.B d[!Areg] 0100 1010 1111 1100:000:?????:?????:00: ILLEGAL -0100 1100 00ss sSSS:250:-NZVC:-----:13: MULL.L #1,s[!Areg] -0100 1100 01ss sSSS:250:?????:?????:13: DIVL.L #1,s[!Areg] +0100 1100 00ss sSSS:200:-NZVC:-----:13: MULL.L #1,s[!Areg] +0100 1100 01ss sSSS:200:?????:?????:13: DIVL.L #1,s[!Areg] 0100 1100 10ss sSSS:000:-----:-----:01: MVMEL.W #1,s[!Dreg,Areg,Apdi,Immd] 0100 1100 11ss sSSS:000:-----:-----:01: MVMEL.L #1,s[!Dreg,Areg,Apdi,Immd] 0100 1110 0100 JJJJ:000:-----:XNZVC:10: TRAP #J @@ -267,6 +269,7 @@ 1111 0101 0000 1rrr:402:-----:-----:00: PFLUSH Ara 1111 0101 0001 0rrr:402:-----:-----:00: PFLUSHAN Ara 1111 0101 0001 1rrr:402:-----:-----:00: PFLUSHA Ara +% 68040 only 1111 0101 0100 1rrr:452:-----:-----:00: PTESTR Ara 1111 0101 0110 1rrr:452:-----:-----:00: PTESTW Ara -- 2.47.3