From 911e2a467ab9f9e465bf7b0f2378c824212880d8 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 23 Mar 2008 14:36:29 +0200 Subject: [PATCH] imported winuaesrc1500b10.zip --- autoconf.c | 30 ++ bsdsocket.c | 3 + custom.c | 2 + drawing.c | 30 +- include/autoconf.h | 1 + include/readcpu.h | 1 + memory.c | 4 +- newcpu.c | 113 ++++- od-win32/caps/caps_win32.c | 22 +- od-win32/dxwrap.c | 177 ++++--- od-win32/dxwrap.h | 6 + od-win32/hardfile_win32.c | 18 +- od-win32/mman.c | 112 +++-- od-win32/picasso96_win.c | 625 ++++++++++++++++++------ od-win32/picasso96_win.h | 562 +++++++++------------ od-win32/srcrelease.cmd | 2 + od-win32/win32.c | 54 +- od-win32/win32.h | 4 +- od-win32/win32_scale2x.c | 4 + od-win32/winuae_msvc/winuae_msvc.vcproj | 2 +- od-win32/winuaechangelog.txt | 15 + readcpu.c | 8 +- uaelib.c | 40 +- 23 files changed, 1159 insertions(+), 676 deletions(-) diff --git a/autoconf.c b/autoconf.c index d8842516..24465420 100755 --- a/autoconf.c +++ b/autoconf.c @@ -264,3 +264,33 @@ void rtarea_setup (void) rtarea_base = base; } } + +uaecptr makedatatable (uaecptr resid, uaecptr resname, uae_u8 type, uae_s8 priority, uae_u16 ver, uae_u16 rev) +{ + uaecptr datatable = here (); + + dw (0xE000); /* INITBYTE */ + dw (0x0008); /* LN_TYPE */ + dw (type << 8); + dw (0xE000); /* INITBYTE */ + dw (0x0009); /* LN_PRI */ + dw (priority << 8); + dw (0xC000); /* INITLONG */ + dw (0x000A); /* LN_NAME */ + dl (resname); + dw (0xE000); /* INITBYTE */ + dw (0x000E); /* LIB_FLAGS */ + dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */ + dw (0xD000); /* INITWORD */ + dw (0x0014); /* LIB_VERSION */ + dw (ver); + dw (0xD000); /* INITWORD */ + dw (0x0016); /* LIB_REVISION */ + dw (rev); + dw (0xC000); /* INITLONG */ + dw (0x0018); /* LIB_IDSTRING */ + dl (resid); + dw (0x0000); /* end of table */ + return datatable; +} + diff --git a/bsdsocket.c b/bsdsocket.c index 5f5ee44b..188fd365 100755 --- a/bsdsocket.c +++ b/bsdsocket.c @@ -1541,6 +1541,9 @@ void bsdlib_install (void) dw (0xE000); /* INITBYTE */ dw (0x0008); /* LN_TYPE */ dw (0x0900); /* NT_LIBRARY */ + dw (0xE000); /* INITBYTE */ + dw (0x0009); /* LN_PRI */ + dw (0xCE00); /* -50 */ dw (0xC000); /* INITLONG */ dw (0x000A); /* LN_NAME */ dl (resname); diff --git a/custom.c b/custom.c index 744bddaf..8e395a9d 100755 --- a/custom.c +++ b/custom.c @@ -4822,6 +4822,8 @@ void customreset (int hardreset) bogusframe = 1; sprite_buffer_res = (currprefs.chipset_mask & CSMASK_AGA) ? RES_SUPERHIRES : RES_LORES; + if (sprite_buffer_res > currprefs.gfx_resolution) + sprite_buffer_res = currprefs.gfx_resolution; if (savestate_state == STATE_RESTORE) { uae_u16 v; uae_u32 vv; diff --git a/drawing.c b/drawing.c index a496e372..123c6aa1 100755 --- a/drawing.c +++ b/drawing.c @@ -108,7 +108,8 @@ struct vidbuf_description gfxvidinfo; /* OCS/ECS color lookup table. */ xcolnr xcolors[4096]; -static uae_u8 spritepixels[MAX_PIXELS_PER_LINE * 4]; /* used when sprite resolution > lores */ +static uae_u8 spritepixels[MAX_PIXELS_PER_LINE * 5]; /* used when sprite resolution > lores */ +static int sprite_aga_first_x, sprite_aga_last_x; #ifdef AGA /* AGA mode color lookup tables */ @@ -406,15 +407,23 @@ static void pfield_init_linetoscr (void) unpainted = visible_left_border < playfield_start ? 0 : visible_left_border - playfield_start; src_pixel = MAX_PIXELS_PER_LINE + res_shift_from_window (playfield_start - native_ddf_left + unpainted); - if (seen_sprites) { + if (sprite_aga_first_x < sprite_aga_last_x) { + uae_u8 *p = spritepixels + sprite_aga_first_x; + int len = sprite_aga_last_x - sprite_aga_first_x + 1; + int i; /* clear previous sprite data storage line */ - memset (spritepixels, 0, sizeof (spritepixels)); - seen_sprites = 0; + for (i = 0; i < (1 << (res_shift < 0 ? 0 : res_shift)); i++) { + memset (p, 0, len); + p += MAX_PIXELS_PER_LINE; + } + sprite_aga_last_x = 0; + sprite_aga_first_x = MAX_PIXELS_PER_LINE; } + seen_sprites = 0; if (dip_for_drawing->nr_sprites == 0) return; - if (seen_sprites < 0) - memset (spritepixels, 0, sizeof (spritepixels)); + if (seen_sprites < 0 && sprite_buffer_res > 0) + memset (spritepixels, 0, sizeof spritepixels); seen_sprites = 1; /* Must clear parts of apixels. */ if (linetoscr_diw_start < native_ddf_left) { @@ -1034,7 +1043,10 @@ STATIC_INLINE void draw_sprites_2 (struct sprite_entry *e, int ham, int dualpf, else if (posdoubling) window_pos <<= posdoubling; window_pos += pixels_offset; - + if (aga) { + if (window_pos < sprite_aga_first_x) + sprite_aga_first_x = window_pos; + } for (pos = e->pos; pos < e->max; pos += 1 << sizeskip) { int maskshift, plfmask; unsigned int v = buf[pos]; @@ -1193,6 +1205,10 @@ STATIC_INLINE void draw_sprites_2 (struct sprite_entry *e, int ham, int dualpf, } } + if (aga) { + if (window_pos > sprite_aga_last_x) + sprite_aga_last_x = window_pos; + } } STATIC_INLINE void draw_sprites_1 (struct sprite_entry *e, int ham, int dualpf, int doubling, int skip, int has_attach) diff --git a/include/autoconf.h b/include/autoconf.h index 9009bf3d..9c6f9cf5 100755 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -17,6 +17,7 @@ extern uae_u32 ds (const char *); extern void calltrap (uae_u32); extern void org (uae_u32); extern uae_u32 here (void); +extern uaecptr makedatatable (uaecptr resid, uaecptr resname, uae_u8 type, uae_s8 priority, uae_u16 ver, uae_u16 rev); #define deftrap(f) define_trap((f), 0, "") #define deftrap2(f, mode, str) define_trap((f), (mode), (str)) diff --git a/include/readcpu.h b/include/readcpu.h index 14195514..07be5dcb 100755 --- a/include/readcpu.h +++ b/include/readcpu.h @@ -36,6 +36,7 @@ ENUMDECL { extern struct mnemolookup { instrmnem mnemo; const char *name; + const char *friendlyname; } lookuptab[]; ENUMDECL { diff --git a/memory.c b/memory.c index c60a751d..4b12931b 100755 --- a/memory.c +++ b/memory.c @@ -3392,6 +3392,8 @@ void memory_init (void) custmem1 = 0; custmem2 = 0; + init_mem_banks (); + kickmemory = mapped_malloc (0x80000, "kick"); memset (kickmemory, 0, 0x80000); kickmem_bank.baseaddr = kickmemory; @@ -3409,8 +3411,6 @@ void memory_init (void) hrtmon_load(); #endif #endif - - init_mem_banks (); } void memory_cleanup (void) diff --git a/newcpu.c b/newcpu.c index cc11589d..3da5ca8f 100755 --- a/newcpu.c +++ b/newcpu.c @@ -1610,7 +1610,7 @@ void m68k_reset (int hardreset) if (currprefs.cpu_model == 68060) { regs.pcr = currprefs.fpu_model ? MC68060_PCR : MC68EC060_PCR; regs.pcr |= (currprefs.cpu060_revision & 0xff) << 8; - regs.pcr |= 2; + regs.pcr |= 2; /* disable FPU */ } fill_prefetch_slow (®s); } @@ -2529,6 +2529,87 @@ static const char* ccnames[] = { "T ","F ","HI","LS","CC","CS","NE","EQ", "VC","VS","PL","MI","GE","LT","GT","LE" }; +static void addmovemreg (char *out, int *prevreg, int *lastreg, int *first, int reg) +{ + char *p = out + strlen (out); + if (*prevreg < 0) { + *prevreg = reg; + *lastreg = reg; + return; + } + if ((*prevreg) + 1 != reg || (reg & 8) != ((*prevreg & 8))) { + sprintf (p, "%s%c%d", (*first) ? "" : "/", (*lastreg) < 8 ? 'D' : 'A', (*lastreg) & 7); + p = p + strlen (p); + if ((*lastreg) + 2 == reg) { + sprintf (p, "/%c%d", (*prevreg) < 8 ? 'D' : 'A', (*prevreg) & 7); + } else if ((*lastreg) != (*prevreg)) { + sprintf (p, "-%c%d", (*prevreg) < 8 ? 'D' : 'A', (*prevreg) & 7); + } + *lastreg = reg; + *first = 0; + } + *prevreg = reg; +} + +static void movemout (char *out, uae_u16 mask, int mode) +{ + unsigned int dmask, amask; + int prevreg = -1, lastreg = -1, first = 1; + if (mode == Apdi) { + int i; + uae_u8 dmask2 = (mask >> 8) & 0xff; + uae_u8 amask2 = mask & 0xff; + dmask = 0; + amask = 0; + for (i = 0; i < 8; i++) { + if (dmask2 & (1 << i)) + dmask |= 1 << (7 - i); + if (amask2 & (1 << i)) + amask |= 1 << (7 - i); + } + } else { + dmask = mask & 0xff; + amask = (mask >> 8) & 0xff; + } + while (dmask) { addmovemreg (out, &prevreg, &lastreg, &first, movem_index1[dmask]); dmask = movem_next[dmask]; } + while (amask) { addmovemreg (out, &prevreg, &lastreg, &first, movem_index1[amask] + 8); amask = movem_next[amask]; } + addmovemreg (out, &prevreg, &lastreg, &first, -1); +} + +static void disasm_size (char *instrname, struct instr *dp) +{ +#if 0 + int i, size; + uae_u16 mnemo = dp->mnemo; + + size = dp->size; + for (i = 0; i < 65536; i++) { + struct instr *in = &table68k[i]; + if (in->mnemo == mnemo && in != dp) { + if (size != in->size) + break; + } + } + if (i == 65536) + size = -1; +#endif + switch (dp->size) + { + case sz_byte: + strcat (instrname, ".B "); + break; + case sz_word: + strcat (instrname, ".W "); + break; + case sz_long: + strcat (instrname, ".L "); + break; + default: + strcat (instrname, " "); + break; + } +} + void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr, int safemode) { uaecptr newpc = 0; @@ -2559,20 +2640,18 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c m68kpc_offset += 2; - strcpy (instrname, lookup->name); + if (lookup->friendlyname) + strcpy (instrname, lookup->friendlyname); + else + strcpy (instrname, lookup->name); ccpt = strstr (instrname, "cc"); if (ccpt != 0) { strncpy (ccpt, ccnames[dp->cc], 2); } - switch (dp->size){ - case sz_byte: strcat (instrname, ".B "); break; - case sz_word: strcat (instrname, ".W "); break; - case sz_long: strcat (instrname, ".L "); break; - default: strcat (instrname, " "); break; - } + disasm_size (instrname, dp); if (lookup->mnemo == i_MOVEC2 || lookup->mnemo == i_MOVE2C) { - uae_u16 imm = get_iword_1 (m68kpc_offset) & 0xffff; + uae_u16 imm = get_iword_1 (m68kpc_offset); uae_u16 creg = imm & 0x0fff; uae_u16 r = imm >> 12; char regs[16], *cname = "?"; @@ -2594,6 +2673,18 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c strcat (instrname, regs); } m68kpc_offset += 2; + } else if (lookup->mnemo == i_MVMEL) { + newpc = m68k_getpc (®s) + m68kpc_offset; + newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode); + strcat (instrname, ","); + movemout (instrname, get_iword_1 (m68kpc_offset), dp->dmode); + m68kpc_offset += 2; + } else if (lookup->mnemo == i_MVMLE) { + movemout (instrname, get_iword_1 (m68kpc_offset), dp->dmode); + strcat (instrname, ","); + newpc = m68k_getpc (®s) + m68kpc_offset; + newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode); + m68kpc_offset += 2; } else { if (dp->suse) { newpc = m68k_getpc (®s) + m68kpc_offset; @@ -2637,7 +2728,7 @@ void m68k_disasm_ea (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *s { char *buf; - buf = (char*)malloc ((MAX_LINEWIDTH + 1) * cnt); + buf = malloc ((MAX_LINEWIDTH + 1) * cnt); if (!buf) return; m68k_disasm_2 (buf, (MAX_LINEWIDTH + 1) * cnt, addr, nextpc, cnt, seaddr, deaddr, 1); @@ -2648,7 +2739,7 @@ void m68k_disasm (void *f, uaecptr addr, uaecptr *nextpc, int cnt) { char *buf; - buf = (char*)malloc ((MAX_LINEWIDTH + 1) * cnt); + buf = malloc ((MAX_LINEWIDTH + 1) * cnt); if (!buf) return; m68k_disasm_2 (buf, (MAX_LINEWIDTH + 1) * cnt, addr, nextpc, cnt, NULL, NULL, 0); diff --git a/od-win32/caps/caps_win32.c b/od-win32/caps/caps_win32.c index 61c404c7..b3c7a915 100755 --- a/od-win32/caps/caps_win32.c +++ b/od-win32/caps/caps_win32.c @@ -8,6 +8,7 @@ #include "zfile.h" #include "gui.h" #include "win32.h" +#include #include "ComType.h" #include "CapsAPI.h" @@ -44,16 +45,25 @@ int caps_init (void) int i; HMODULE h; struct CapsVersionInfo cvi; + char *dllname = "CAPSImg.dll"; if (init) return 1; - h = WIN32_LoadLibrary ("CAPSImg.dll"); + h = WIN32_LoadLibrary (dllname); if (!h) { - if (noticed) - return 0; - notify_user (NUMSG_NOCAPS); - noticed = 1; - return 0; + char tmp[MAX_DPATH]; + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, tmp))) { + strcat (tmp, "\\Software Preservation Society\\"); + strcat (tmp, dllname); + h = LoadLibrary (tmp); + if (!h) { + if (noticed) + return 0; + notify_user (NUMSG_NOCAPS); + noticed = 1; + return 0; + } + } } if (GetProcAddress(h, "CAPSLockImageMemory") == 0 || GetProcAddress(h, "CAPSGetVersionInfo") == 0) { if (noticed) diff --git a/od-win32/dxwrap.c b/od-win32/dxwrap.c index dd04ed65..298f7c32 100755 --- a/od-win32/dxwrap.c +++ b/od-win32/dxwrap.c @@ -12,6 +12,7 @@ struct ddstuff dxdata; static int flipinterval_supported = 1; +int ddforceram = 0; HRESULT DirectDraw_GetDisplayMode (void) { @@ -48,73 +49,6 @@ static void freemainsurface (void) dxdata.backbuffers = 0; } -void DirectDraw_Release (void) -{ - if (!dxdata.ddinit) - return; - dxdata.ddinit = 0; - freemainsurface (); - if (dxdata.fsmodeset) - IDirectDraw7_RestoreDisplayMode (dxdata.maindd); - dxdata.fsmodeset = 0; - IDirectDraw7_SetCooperativeLevel (dxdata.maindd, dxdata.hwnd, DDSCL_NORMAL); - releaser (dxdata.dclip, IDirectDrawClipper_Release); - releaser (dxdata.maindd, IDirectDraw_Release); - memset (&dxdata, 0, sizeof (dxdata)); -} - -int DirectDraw_Start (GUID *guid) -{ - HRESULT ddrval; - LPDIRECT3D9 d3d; - D3DCAPS9 d3dCaps; - - if (dxdata.ddinit) { - if (guid == NULL && dxdata.ddzeroguid) - return -1; - if (guid && !memcmp (guid, &dxdata.ddguid, sizeof (GUID))) - return -1; - DirectDraw_Release (); - } - - ddrval = DirectDrawCreate (guid, &dxdata.olddd, NULL); - if (FAILED(ddrval)) { - if (guid != NULL) - return 0; - goto oops; - } - ddrval = IDirectDraw_QueryInterface (dxdata.olddd, &IID_IDirectDraw7, (LPVOID*)&dxdata.maindd); - if(FAILED(ddrval)) { - gui_message("start_ddraw(): DirectX 7 or newer required"); - DirectDraw_Release(); - return 0; - } - - dxdata.maxwidth = 16384; - dxdata.maxheight = 16384; - d3d = Direct3DCreate9 (D3D9b_SDK_VERSION); - if (d3d) { - IDirect3D9_GetDeviceCaps (d3d, 0, D3DDEVTYPE_HAL, &d3dCaps); - dxdata.maxwidth = d3dCaps.MaxTextureWidth; - dxdata.maxheight = d3dCaps.MaxTextureHeight; - write_log ("Max hardware surface size: %dx%d\n", dxdata.maxwidth, dxdata.maxheight); - } - - if (SUCCEEDED (DirectDraw_GetDisplayMode ())) { - dxdata.ddinit = 1; - dxdata.ddzeroguid = 1; - if (guid) { - dxdata.ddzeroguid = 0; - memcpy (&dxdata.ddguid, guid, sizeof (GUID)); - } - return 1; - } - oops: - write_log ("DirectDraw_Start: %s\n", DXError (ddrval)); - DirectDraw_Release(); - return 0; -} - HRESULT restoresurface (LPDIRECTDRAWSURFACE7 surf) { HRESULT ddrval; @@ -183,28 +117,53 @@ void unlocksurface (LPDIRECTDRAWSURFACE7 surf) write_log ("IDirectDrawSurface7_Unlock: %s\n", DXError (ddrval)); } -LPDIRECTDRAWSURFACE7 allocsurface (int width, int height) +static char *alloctexts[] = { "NonLocalVRAM", "DefaultRAM", "VRAM", "RAM" }; +LPDIRECTDRAWSURFACE7 allocsurface_2 (int width, int height, int forcemode) { HRESULT ddrval; - DDSURFACEDESC2 desc = { 0 }; + DDSURFACEDESC2 desc; LPDIRECTDRAWSURFACE7 surf; + memset (&desc, 0, sizeof desc); desc.dwSize = sizeof (desc); desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; - desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - if (width > dxdata.maxwidth || height > dxdata.maxheight) - desc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; + desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_NONLOCALVIDMEM | DDSCAPS_VIDEOMEMORY; + if (forcemode >= DDFORCED_DEFAULT) + desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + if (forcemode == DDFORCED_VIDMEM) + desc.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY; + if (width > dxdata.maxwidth || height > dxdata.maxheight || forcemode == DDFORCED_SYSMEM) + desc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; desc.dwWidth = width; desc.dwHeight = height; memcpy (&desc.ddpfPixelFormat, &dxdata.native.ddpfPixelFormat, sizeof (DDPIXELFORMAT)); ddrval = IDirectDraw7_CreateSurface (dxdata.maindd, &desc, &surf, NULL); if (FAILED (ddrval)) { - write_log ("IDirectDraw7_CreateSurface: %s\n", DXError (ddrval)); + write_log ("IDirectDraw7_CreateSurface (%dx%d,%s): %s\n", width, height, alloctexts[forcemode], DXError (ddrval)); } else { - clearsurf (surf); + clearsurf (surf); + write_log ("Created %dx%d surface in %s (%d)\n", width, height, alloctexts[forcemode]); } return surf; } + +LPDIRECTDRAWSURFACE7 allocsurface (int width, int height) +{ + LPDIRECTDRAWSURFACE7 s; + int mode = ddforceram; + + for (;;) { + s = allocsurface_2 (width, height, mode); + if (s) + return s; + mode++; + if (mode >= 4) + mode = 0; + if (mode == ddforceram) + return NULL; + } +} + void freesurface (LPDIRECTDRAWSURFACE7 surf) { if (surf) @@ -759,3 +718,73 @@ HRESULT DirectDraw_CreatePalette (LPPALETTEENTRY pal) return ddrval; } +void DirectDraw_Release (void) +{ + if (!dxdata.ddinit) + return; + dxdata.ddinit = 0; + freemainsurface (); + if (dxdata.fsmodeset) + IDirectDraw7_RestoreDisplayMode (dxdata.maindd); + dxdata.fsmodeset = 0; + IDirectDraw7_SetCooperativeLevel (dxdata.maindd, dxdata.hwnd, DDSCL_NORMAL); + releaser (dxdata.dclip, IDirectDrawClipper_Release); + releaser (dxdata.maindd, IDirectDraw_Release); + memset (&dxdata, 0, sizeof (dxdata)); +} + +int DirectDraw_Start (GUID *guid) +{ + HRESULT ddrval; + LPDIRECT3D9 d3d; + D3DCAPS9 d3dCaps; + + if (dxdata.ddinit) { + if (guid == NULL && dxdata.ddzeroguid) + return -1; + if (guid && !memcmp (guid, &dxdata.ddguid, sizeof (GUID))) + return -1; + DirectDraw_Release (); + } + + ddrval = DirectDrawCreate (guid, &dxdata.olddd, NULL); + if (FAILED(ddrval)) { + if (guid != NULL) + return 0; + goto oops; + } + ddrval = IDirectDraw_QueryInterface (dxdata.olddd, &IID_IDirectDraw7, (LPVOID*)&dxdata.maindd); + if(FAILED(ddrval)) { + gui_message("start_ddraw(): DirectX 7 or newer required"); + DirectDraw_Release(); + return 0; + } + + dxdata.maxwidth = 16384; + dxdata.maxheight = 16384; + d3d = Direct3DCreate9 (D3D9b_SDK_VERSION); + if (d3d) { + IDirect3D9_GetDeviceCaps (d3d, 0, D3DDEVTYPE_HAL, &d3dCaps); + dxdata.maxwidth = d3dCaps.MaxTextureWidth; + dxdata.maxheight = d3dCaps.MaxTextureHeight; + write_log ("Max hardware surface size: %dx%d\n", dxdata.maxwidth, dxdata.maxheight); + if (dxdata.maxwidth < 2048) + dxdata.maxwidth = 2048; + if (dxdata.maxheight < 2048) + dxdata.maxheight = 2048; + } + + if (SUCCEEDED (DirectDraw_GetDisplayMode ())) { + dxdata.ddinit = 1; + dxdata.ddzeroguid = 1; + if (guid) { + dxdata.ddzeroguid = 0; + memcpy (&dxdata.ddguid, guid, sizeof (GUID)); + } + return 1; + } + oops: + write_log ("DirectDraw_Start: %s\n", DXError (ddrval)); + DirectDraw_Release(); + return 0; +} diff --git a/od-win32/dxwrap.h b/od-win32/dxwrap.h index e60bbae5..a307f07e 100755 --- a/od-win32/dxwrap.h +++ b/od-win32/dxwrap.h @@ -177,5 +177,11 @@ HRESULT DirectDraw_SetPaletteEntries (int start, int count, PALETTEENTRY *palett HRESULT DirectDraw_SetPalette (int remove); HRESULT DirectDraw_CreatePalette (LPPALETTEENTRY pal); + +#define DDFORCED_NONLOCAL 0 +#define DDFORCED_DEFAULT 1 +#define DDFORCED_VIDMEM 2 +#define DDFORCED_SYSMEM 3 + #endif diff --git a/od-win32/hardfile_win32.c b/od-win32/hardfile_win32.c index eada1361..5d841bf5 100755 --- a/od-win32/hardfile_win32.c +++ b/od-win32/hardfile_win32.c @@ -26,6 +26,7 @@ #include // for SetupDiXxx functions. #include // for SetupDiXxx functions. #endif +#include static int usefloppydrives = 0; @@ -662,29 +663,35 @@ static int getstorageproperty (PUCHAR outBuf, int returnedLength, struct uae_dri char orgname[1024]; PUCHAR p; int i, j; + int size; devDesc = (PSTORAGE_DEVICE_DESCRIPTOR) outBuf; + size = devDesc->Version; p = (PUCHAR) outBuf; + if (offsetof(STORAGE_DEVICE_DESCRIPTOR, CommandQueueing) > size) { + write_log ("too short STORAGE_DEVICE_DESCRIPTOR only %d bytes\n", size); + return 1; + } if (devDesc->DeviceType != INQ_DASD && devDesc->DeviceType != INQ_ROMD && devDesc->DeviceType != INQ_OPTD) { write_log ("not a direct access device, ignored (type=%d)\n", devDesc->DeviceType); return 1; } - if (devDesc->VendorIdOffset && p[devDesc->VendorIdOffset]) { + if (size > offsetof(STORAGE_DEVICE_DESCRIPTOR, VendorIdOffset) && devDesc->VendorIdOffset && p[devDesc->VendorIdOffset]) { j = 0; for (i = devDesc->VendorIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++) udi->vendor_id[j++] = p[i]; } - if (devDesc->ProductIdOffset && p[devDesc->ProductIdOffset]) { + if (size > offsetof(STORAGE_DEVICE_DESCRIPTOR, ProductIdOffset) && devDesc->ProductIdOffset && p[devDesc->ProductIdOffset]) { j = 0; for (i = devDesc->ProductIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++) udi->product_id[j++] = p[i]; } - if (devDesc->ProductRevisionOffset && p[devDesc->ProductRevisionOffset]) { + if (size > offsetof(STORAGE_DEVICE_DESCRIPTOR, ProductRevisionOffset) && devDesc->ProductRevisionOffset && p[devDesc->ProductRevisionOffset]) { j = 0; for (i = devDesc->ProductRevisionOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++) udi->product_rev[j++] = p[i]; } - if (devDesc->SerialNumberOffset && p[devDesc->SerialNumberOffset]) { + if (size > offsetof(STORAGE_DEVICE_DESCRIPTOR, SerialNumberOffset) && devDesc->SerialNumberOffset && p[devDesc->SerialNumberOffset]) { j = 0; for (i = devDesc->SerialNumberOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++) udi->product_serial[j++] = p[i]; @@ -794,6 +801,7 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD adpDesc = (PSTORAGE_ADAPTER_DESCRIPTOR) outBuf; } + memset (outBuf, 0, sizeof outBuf); query.PropertyId = StorageDeviceProperty; query.QueryType = PropertyStandardQuery; status = DeviceIoControl( @@ -802,7 +810,7 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD &query, sizeof(STORAGE_PROPERTY_QUERY), &outBuf, - sizeof (outBuf), + sizeof outBuf, &returnedLength, NULL); if (!status) { diff --git a/od-win32/mman.c b/od-win32/mman.c index 574b9eef..85a4648c 100755 --- a/od-win32/mman.c +++ b/od-win32/mman.c @@ -58,7 +58,7 @@ static void setworkingset(void) static uae_u32 lowmem (void) { uae_u32 change = 0; - if (currprefs.z3fastmem_size >= 8 * 1024 * 1024 && currprefs.gfxmem_size < 256 * 1024 * 1024) { + if (currprefs.z3fastmem_size >= 8 * 1024 * 1024 && currprefs.gfxmem_size < 64 * 1024 * 1024) { change = currprefs.z3fastmem_size - currprefs.z3fastmem_size / 2; currprefs.z3fastmem_size >>= 1; changed_prefs.z3fastmem_size = currprefs.z3fastmem_size; @@ -231,57 +231,63 @@ void preinit_shm (void) int init_shm (void) { int i; - LPVOID blah = NULL; uae_u32 size, totalsize, z3size, natmemsize, rtgbarrier, rtgextra; + int rounds = 0; - if (natmem_offset) - VirtualFree(natmem_offset, 0, MEM_RELEASE); - natmem_offset = NULL; - natmem_offset_end = NULL; - canbang = 0; - - z3size = 0; - size = 0x1000000; - rtgextra = 0; - rtgbarrier = si.dwPageSize; - if (currprefs.cpu_model >= 68020) - size = 0x10000000; - if (currprefs.z3fastmem_size) { - z3size = currprefs.z3fastmem_size + (currprefs.z3fastmem_start - 0x10000000); - if (currprefs.gfxmem_size) - rtgbarrier = 16 * 1024 * 1024; - } else { - rtgbarrier = 0; - } - - totalsize = size + z3size + currprefs.gfxmem_size; - while (totalsize > size64) { - int change = lowmem (); - if (!change) +restart: + for (;;) { + LPVOID blah = NULL; + if (rounds > 0) + write_log ("NATMEM: retrying %d..\n", rounds); + rounds++; + if (natmem_offset) + VirtualFree(natmem_offset, 0, MEM_RELEASE); + natmem_offset = NULL; + natmem_offset_end = NULL; + canbang = 0; + + z3size = 0; + size = 0x1000000; + rtgextra = 0; + rtgbarrier = si.dwPageSize; + if (currprefs.cpu_model >= 68020) + size = 0x10000000; + if (currprefs.z3fastmem_size) { + z3size = currprefs.z3fastmem_size + (currprefs.z3fastmem_start - 0x10000000); + if (currprefs.gfxmem_size) + rtgbarrier = 16 * 1024 * 1024; + } else { + rtgbarrier = 0; + } + totalsize = size + z3size + currprefs.gfxmem_size; + while (totalsize > size64) { + int change = lowmem (); + if (!change) + return 0; + totalsize -= change; + } + if ((rounds > 1 && totalsize < 0x10000000) || rounds > 20) { + write_log ("NATMEM: No special area could be allocated (3)!\n"); return 0; - totalsize -= change; - } + } + natmemsize = size + z3size; - shm_start = 0; - for (i = 0; i < MAX_SHMID; i++) { - shmids[i].attached = 0; - shmids[i].key = -1; - shmids[i].size = 0; - shmids[i].addr = NULL; - shmids[i].name[0] = 0; - } - natmemsize = size + z3size; - xfree (memwatchtable); - memwatchtable = 0; - if (currprefs.gfxmem_size) { - if (!memwatchok) { - write_log ("GetWriteWatch() not supported, using guard pages, performance will be slower.\n"); - memwatchtable = xcalloc (currprefs.gfxmem_size / si.dwPageSize + 1, 1); + shm_start = 0; + for (i = 0; i < MAX_SHMID; i++) { + shmids[i].attached = 0; + shmids[i].key = -1; + shmids[i].size = 0; + shmids[i].addr = NULL; + shmids[i].name[0] = 0; + } + xfree (memwatchtable); + memwatchtable = 0; + if (currprefs.gfxmem_size) { + if (!memwatchok) { + write_log ("GetWriteWatch() not supported, using guard pages, performance will be slower.\n"); + memwatchtable = xcalloc (currprefs.gfxmem_size / si.dwPageSize + 1, 1); + } } - } -restart: - for (;;) { - int change; if (currprefs.gfxmem_size) { rtgextra = si.dwPageSize; } else { @@ -289,17 +295,17 @@ restart: rtgextra = 0; } blah = VirtualAlloc (NULL, natmemsize + rtgbarrier + currprefs.gfxmem_size + rtgextra + 16 * si.dwPageSize, MEM_RESERVE, PAGE_READWRITE); - if (blah) + if (blah) { + natmem_offset = blah; break; - write_log ("NATMEM: %dM area failed to allocate, err=%d\n", natmemsize >> 20, GetLastError ()); - change = lowmem (); - totalsize -= change; - if (change == 0 || totalsize < 0x10000000) { + } + write_log ("NATMEM: %dM area failed to allocate, err=%d (Z3=%dM,RTG=%dM)\n", + natmemsize >> 20, GetLastError (), currprefs.z3fastmem_size >> 20, currprefs.gfxmem_size >> 20); + if (!lowmem ()) { write_log ("NATMEM: No special area could be allocated (2)!\n"); return 0; } } - natmem_offset = blah; p96mem_size = currprefs.gfxmem_size; if (p96mem_size) { VirtualFree (natmem_offset, 0, MEM_RELEASE); diff --git a/od-win32/picasso96_win.c b/od-win32/picasso96_win.c index 6057853d..2f73ca63 100755 --- a/od-win32/picasso96_win.c +++ b/od-win32/picasso96_win.c @@ -48,7 +48,8 @@ #define NOBLITTER 0 -static int hwsprite; +static int hwsprite = 0; +static int uaegfxcard_old = 1; #include "registry.h" #include "dxwrap.h" @@ -111,6 +112,11 @@ static int reloadcursor, cursorvisible, cursordeactivate; static uaecptr cursorbi; +static uaecptr uaegfx_resname, + uaegfx_resid, + uaegfx_init, + uaegfx_base; + typedef enum { BLIT_FALSE, BLIT_NOR, @@ -625,11 +631,20 @@ static void mouseupdate (void) gfx_unlock_picasso (); } +static int framecnt; +int p96skipmode = -1; +static int doskip (void) +{ + if (framecnt >= currprefs.gfx_framerate) + framecnt = 0; + return framecnt > 0; +} + void picasso_handle_vsync (void) { static int vsynccnt; - static int updatecnt; + framecnt++; mouseupdate (); if (currprefs.chipset_refreshrate >= 100) { @@ -638,10 +653,10 @@ void picasso_handle_vsync (void) return; vsynccnt = 0; } - updatecnt--; - if (updatecnt <= 0) { + if (doskip () && p96skipmode == 0) { + ; + } else { flushpixels (); - updatecnt = 1; } gfx_unlock_picasso (); } @@ -981,32 +996,6 @@ static int do_blitrect_frame_buffer (struct RenderInfo *ri, struct return 0; } -/* -SetSprite: -Synopsis: SetSprite(bi, activate, RGBFormat); -Inputs: a0: struct BoardInfo *bi -d0: BOOL activate -d7: RGBFTYPE RGBFormat - -This function activates or deactivates the hardware sprite. -*/ -uae_u32 REGPARAM2 picasso_SetSprite (struct regstruct *regs) -{ - uae_u32 result = 0; - uae_u32 activate = m68k_dreg (regs, 0); - if (!hwsprite) - return 0; - if (activate) { - picasso_SetSpriteImage (regs); - cursorvisible = 1; - } else { - cursordeactivate = 2; - } - result = 1; - P96TRACE_SPR (("SetSprite: %d\n", activate)); - return result; -} - /* SetSpritePosition: Synopsis: SetSpritePosition(bi, RGBFormat); @@ -1014,8 +1003,9 @@ Inputs: a0: struct BoardInfo *bi d7: RGBFTYPE RGBFormat */ -uae_u32 REGPARAM2 picasso_SetSpritePosition (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_SetSpritePosition (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr bi = m68k_areg (regs, 0); newcursor_x = (uae_s16)get_word (bi + PSSO_BoardInfo_MouseX) - picasso96_state.XOffset; newcursor_y = (uae_s16)get_word (bi + PSSO_BoardInfo_MouseY) - picasso96_state.YOffset; @@ -1037,8 +1027,9 @@ d7: RGBFTYPE RGBFormat This function changes one of the possible three colors of the hardware sprite. */ -uae_u32 REGPARAM2 picasso_SetSpriteColor (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_SetSpriteColor (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr bi = m68k_areg (regs, 0); uae_u8 idx = m68k_dreg (regs, 0); uae_u8 red = m68k_dreg (regs, 1); @@ -1055,32 +1046,6 @@ uae_u32 REGPARAM2 picasso_SetSpriteColor (struct regstruct *regs) } -/* -SetSpriteImage: -Synopsis: SetSpriteImage(bi, RGBFormat); -Inputs: a0: struct BoardInfo *bi -d7: RGBFTYPE RGBFormat - -This function gets new sprite image data from the MouseImage field of the BoardInfo structure and writes -it to the board. - -There are three possible cases: - -BIB_HIRESSPRITE is set: -skip the first two long words and the following sprite data is arranged as an array of two longwords. Those form the -two bit planes for one image line respectively. - -BIB_HIRESSPRITE and BIB_BIGSPRITE are not set: -skip the first two words and the following sprite data is arranged as an array of two words. Those form the two -bit planes for one image line respectively. - -BIB_HIRESSPRITE is not set and BIB_BIGSPRITE is set: -skip the first two words and the following sprite data is arranged as an array of two words. Those form the two bit -planes for one image line respectively. You have to double each pixel horizontally and vertically. All coordinates -used in this case already assume a zoomed sprite, only the sprite data is not zoomed yet. You will have to -compensate for this when accounting for hotspot offsets and sprite dimensions. -*/ - static uae_u32 setspriteimage (uaecptr bi); static RECT cursor_r1, cursor_r2; static int mouseput; @@ -1381,13 +1346,66 @@ end: return ret; } -uae_u32 REGPARAM2 picasso_SetSpriteImage (struct regstruct *regs) +/* +SetSpriteImage: +Synopsis: SetSpriteImage(bi, RGBFormat); +Inputs: a0: struct BoardInfo *bi +d7: RGBFTYPE RGBFormat + +This function gets new sprite image data from the MouseImage field of the BoardInfo structure and writes +it to the board. + +There are three possible cases: + +BIB_HIRESSPRITE is set: +skip the first two long words and the following sprite data is arranged as an array of two longwords. Those form the +two bit planes for one image line respectively. + +BIB_HIRESSPRITE and BIB_BIGSPRITE are not set: +skip the first two words and the following sprite data is arranged as an array of two words. Those form the two +bit planes for one image line respectively. + +BIB_HIRESSPRITE is not set and BIB_BIGSPRITE is set: +skip the first two words and the following sprite data is arranged as an array of two words. Those form the two bit +planes for one image line respectively. You have to double each pixel horizontally and vertically. All coordinates +used in this case already assume a zoomed sprite, only the sprite data is not zoomed yet. You will have to +compensate for this when accounting for hotspot offsets and sprite dimensions. +*/ +static uae_u32 REGPARAM2 picasso_SetSpriteImage (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr bi = m68k_areg (regs, 0); cursorbi = bi; return setspriteimage (bi); } +/* +SetSprite: +Synopsis: SetSprite(bi, activate, RGBFormat); +Inputs: a0: struct BoardInfo *bi +d0: BOOL activate +d7: RGBFTYPE RGBFormat + +This function activates or deactivates the hardware sprite. +*/ +static uae_u32 REGPARAM2 picasso_SetSprite (TrapContext *ctx) +{ + struct regstruct *regs = &ctx->regs; + uae_u32 result = 0; + uae_u32 activate = m68k_dreg (regs, 0); + if (!hwsprite) + return 0; + if (activate) { + picasso_SetSpriteImage (ctx); + cursorvisible = 1; + } else { + cursordeactivate = 2; + } + result = 1; + P96TRACE_SPR (("SetSprite: %d\n", activate)); + return result; +} + /* * BOOL FindCard(struct BoardInfo *bi); and * @@ -1403,10 +1421,16 @@ uae_u32 REGPARAM2 picasso_SetSpriteImage (struct regstruct *regs) * BoardInfo struct supplied by the caller, the rtg.library, for example * the MemoryBase, MemorySize and RegisterBase fields. */ -uae_u32 REGPARAM2 picasso_FindCard (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_FindCard (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr AmigaBoardInfo = m68k_areg (regs, 0); /* NOTES: See BoardInfo struct definition in Picasso96 dev info */ +#ifdef UAEGFX_INTERNAL + if (!uaegfx_base) + return 0; + put_long (uaegfx_base + CARD_BOARDINFO, AmigaBoardInfo); +#endif if (allocated_gfxmem && !picasso96_state.CardFound) { /* Fill in MemoryBase, MemorySize */ put_long (AmigaBoardInfo + PSSO_BoardInfo_MemoryBase, gfxmem_start); @@ -1564,15 +1588,19 @@ static void CopyLibResolutionStructureU2A (struct LibResolution *libres, uaecptr put_long (amigamemptr + PSSO_LibResolution_BoardInfo, libres->BoardInfo); } + static int missmodes[] = { 320, 200, 320, 240, 640, 400, 640, 480, -1 }; +#ifdef UAEGFX_INTERNAL +static uaecptr uaegfx_card_install (TrapContext *ctx, uae_u32 size); +#endif void picasso96_alloc (TrapContext *ctx) { int i, j, size, cnt; int misscnt; - uaecptr rt; SYSTEM_INFO si; + uaegfx_resname = ds ("uaegfx.card"); xfree (newmodes); newmodes = NULL; picasso96_amem = picasso96_amemend = 0; @@ -1664,11 +1692,29 @@ void picasso96_alloc (TrapContext *ctx) #if 0 ShowSupportedResolutions (); #endif +#ifdef UAEGFX_INTERNAL + picasso96_amem = NULL; + if (uaegfx_card_install (ctx, size)) { + picasso96_amem = get_long (uaegfx_base + CARD_RESLIST); + picasso96_amemend = picasso96_amem + size; + write_log("P96 RESINFO: %08X-%08X (%d,%d)\n", picasso96_amem, picasso96_amemend, cnt, size); + } +#else m68k_dreg (&ctx->regs, 0) = size; m68k_dreg (&ctx->regs, 1) = 65536 + 1; - picasso96_amem = CallLib (ctx, get_long (4), -0xC6); /* AllocMem */ - picasso96_amemend = picasso96_amem + size; - write_log("P96 RESINFO: %08X-%08X (%d,%d)\n", picasso96_amem, picasso96_amemend, cnt, size); + if ((picasso96_amem = CallLib (ctx, get_long (4), -0xC6))) { /* AllocMem */ + uaecptr rt; + picasso96_amemend = picasso96_amem + size; + write_log("P96 RESINFO: %08X-%08X (%d,%d)\n", picasso96_amem, picasso96_amemend, cnt, size); + /* put magic rtarea pointer to end of display ram */ + put_long (p96ram_start + allocated_gfxmem - 12, 'UAE_'); + rt = need_uae_boot_rom (); + if (rt) + rt += 0xff60; + put_long (p96ram_start + allocated_gfxmem - 8, rt); + put_long (p96ram_start + allocated_gfxmem - 4, '_UAE'); + } +#endif xfree (gwwbuf); GetSystemInfo (&si); @@ -1676,22 +1722,17 @@ void picasso96_alloc (TrapContext *ctx) gwwbufsize = allocated_gfxmem / gwwpagesize + 1; gwwpagemask = gwwpagesize - 1; gwwbuf = xmalloc (gwwbufsize * sizeof (void*)); - - /* put magic rtarea pointer to end of display ram */ - put_long (p96ram_start + allocated_gfxmem - 12, 'UAE_'); - rt = need_uae_boot_rom (); - if (rt) - rt += 0xff60; - put_long (p96ram_start + allocated_gfxmem - 8, rt); - put_long (p96ram_start + allocated_gfxmem - 4, '_UAE'); } +#ifndef UAEGFX_INTERNAL static void uaegfxversion (uaecptr bi) { uaecptr addr = get_long (bi + 16); /* gbi_BoardName */ int max = 1000; int ok = 0; + uaegfxcard_old = 1; + addr &= ~1; for (;;) { if (!valid_address (addr, 24) || bi == 0) { @@ -1712,9 +1753,13 @@ static void uaegfxversion (uaecptr bi) uaecptr ver = get_long (addr + 18); if (valid_address (ver, 8)) { char *vers = my_strdup (get_real_address (ver)); + int version = get_byte (addr + 11); while (strlen (vers) > 0 && (vers[strlen (vers) - 1] == 10 || vers[strlen (vers) - 1] == 13)) vers[strlen (vers) - 1] = 0; - write_log ("P96: %s\n", vers); + + write_log ("P96: v%d %08X %s\n", version, addr, vers); + if (version >= 2) + uaegfxcard_old = 0; xfree (vers); ok = 1; } @@ -1723,7 +1768,80 @@ static void uaegfxversion (uaecptr bi) if (!ok) write_log ("P96: uaegfx.card not detected!?\n"); } +#endif +static void inituaegfxfuncs (uaecptr ABI); +static void inituaegfx (uaecptr ABI) +{ + uae_u32 flags; + + put_word (ABI + PSSO_BoardInfo_BitsPerCannon, 8); + put_word (ABI + PSSO_BoardInfo_RGBFormats, picasso96_pixel_format); + put_long (ABI + PSSO_BoardInfo_BoardType, BT_uaegfx); + put_long (ABI + PSSO_BoardInfo_GraphicsControllerType, GCT_Unknown); + put_long (ABI + PSSO_BoardInfo_PaletteChipType, PCT_Unknown); + put_long (ABI + PSSO_BoardInfo_BoardName, uaegfx_resname); + put_long (ABI + PSSO_BoardInfo_BoardType, 1); + + /* only 1 clock */ + put_long (ABI + PSSO_BoardInfo_PixelClockCount + PLANAR * 4, 1); + put_long (ABI + PSSO_BoardInfo_PixelClockCount + CHUNKY * 4, 1); + put_long (ABI + PSSO_BoardInfo_PixelClockCount + HICOLOR * 4, 1); + put_long (ABI + PSSO_BoardInfo_PixelClockCount + TRUECOLOR * 4, 1); + put_long (ABI + PSSO_BoardInfo_PixelClockCount + TRUEALPHA * 4, 1); + + /* we have 16 bits for horizontal and vertical timings - hack */ + put_word (ABI + PSSO_BoardInfo_MaxHorValue + PLANAR * 2, 0xffff); + put_word (ABI + PSSO_BoardInfo_MaxHorValue + CHUNKY * 2, 0xffff); + put_word (ABI + PSSO_BoardInfo_MaxHorValue + HICOLOR * 2, 0xffff); + put_word (ABI + PSSO_BoardInfo_MaxHorValue + TRUECOLOR * 2, 0xffff); + put_word (ABI + PSSO_BoardInfo_MaxHorValue + TRUEALPHA * 2, 0xffff); + put_word (ABI + PSSO_BoardInfo_MaxVerValue + PLANAR * 2, 0xffff); + put_word (ABI + PSSO_BoardInfo_MaxVerValue + CHUNKY * 2, 0xffff); + put_word (ABI + PSSO_BoardInfo_MaxVerValue + HICOLOR * 2, 0xffff); + put_word (ABI + PSSO_BoardInfo_MaxVerValue + TRUECOLOR * 2, 0xffff); + put_word (ABI + PSSO_BoardInfo_MaxVerValue + TRUEALPHA * 2, 0xffff); + + flags = get_long (ABI + PSSO_BoardInfo_Flags); + flags &= 0xffff0000; + flags |= BIF_HARDWARESPRITE | BIF_BLITTER | BIF_NOMEMORYMODEMIX; + put_long (ABI + PSSO_BoardInfo_Flags, flags); +#ifndef UAEGFX_INTERNAL + flags = get_long (ABI + PSSO_BoardInfo_Flags); + if (flags & BIF_HARDWARESPRITE) { + hwsprite = 1; + put_word (ABI + PSSO_BoardInfo_SoftSpriteFlags, 0); + write_log ("P96: uaegfx.card: hardware sprite support enabled\n"); + } else { + hwsprite = 0; + write_log ("P96: uaegfx.card: no hardware sprite support\n"); + put_word (ABI + PSSO_BoardInfo_SoftSpriteFlags, picasso96_pixel_format); + } + if (uaegfxcard_old && (flags & BIF_HARDWARESPRITE)) { + flags &= ~BIF_HARDWARESPRITE; + write_log ("P96: uaegfx.card: old version (<2.0), forced hardware sprite disabled\n"); + } + if (!(flags & BIF_BLITTER)) + write_log ("P96: no blitter support, bogus uaegfx.card!?\n"); + put_long (ABI + PSSO_BoardInfo_Flags, flags); +#endif + if (flags & BIF_NOBLITTER) + write_log ("P96: blitter disabled in devs:monitors/uaegfx!\n"); + + put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 0, planar.width); + put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 2, chunky.width); + put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 4, hicolour.width); + put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 6, truecolour.width); + put_word (ABI + PSSO_BoardInfo_MaxHorResolution + 8, alphacolour.width); + put_word (ABI + PSSO_BoardInfo_MaxVerResolution + 0, planar.height); + put_word (ABI + PSSO_BoardInfo_MaxVerResolution + 2, chunky.height); + put_word (ABI + PSSO_BoardInfo_MaxVerResolution + 4, hicolour.height); + put_word (ABI + PSSO_BoardInfo_MaxVerResolution + 6, truecolour.height); + put_word (ABI + PSSO_BoardInfo_MaxVerResolution + 8, alphacolour.height); +#ifdef UAEGFX_INTERNAL + inituaegfxfuncs (ABI); +#endif +} /**************************************** * InitCard() @@ -1731,51 +1849,25 @@ static void uaegfxversion (uaecptr bi) * a2: BoardInfo structure ptr - Amiga-based address in Intel endian-format * */ -uae_u32 REGPARAM2 picasso_InitCard (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; struct LibResolution res; int ModeInfoStructureCount = 1, LibResolutionStructureCount = 0; int i, j, unkcnt; uaecptr amem; - uaecptr AmigaBoardInfo = m68k_areg (regs, 2); - uae_u32 flags; + uaecptr AmigaBoardInfo = m68k_areg (regs, 0); +#ifndef UAEGFX_INTERNAL uaegfxversion (AmigaBoardInfo); +#endif if (!picasso96_amem) { write_log ("P96: InitCard() but no resolution memory!\n"); return 0; } amem = picasso96_amem; - put_word (AmigaBoardInfo + PSSO_BoardInfo_BitsPerCannon, 8); - put_word (AmigaBoardInfo + PSSO_BoardInfo_RGBFormats, picasso96_pixel_format); - put_long (AmigaBoardInfo + PSSO_BoardInfo_BoardType, BT_uaegfx); - flags = get_long (AmigaBoardInfo + PSSO_BoardInfo_Flags); - if (flags & BIF_HARDWARESPRITE) { - hwsprite = 1; - put_word (AmigaBoardInfo + PSSO_BoardInfo_SoftSpriteFlags, 0); - write_log ("P96: uaegfx.card: hardware sprite support enabled\n"); - } else { - hwsprite = 0; - write_log ("P96: uaegfx.card: no hardware sprite support\n"); - put_word (AmigaBoardInfo + PSSO_BoardInfo_SoftSpriteFlags, picasso96_pixel_format); - } - if (!(flags & BIF_BLITTER)) - write_log ("P96: no blitter support, bogus uaegfx.card!?\n"); - if (flags & BIF_NOBLITTER) - write_log ("P96: blitter disabled in devs:monitors/uaegfx!\n"); - put_long (AmigaBoardInfo + PSSO_BoardInfo_Flags, flags); - - put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 0, planar.width); - put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 2, chunky.width); - put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 4, hicolour.width); - put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 6, truecolour.width); - put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 8, alphacolour.width); - put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 0, planar.height); - put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 2, chunky.height); - put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 4, hicolour.height); - put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 6, truecolour.height); - put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 8, alphacolour.height); + inituaegfx (AmigaBoardInfo); i = 0; unkcnt = 0; @@ -1834,8 +1926,9 @@ uae_u32 REGPARAM2 picasso_InitCard (struct regstruct *regs) * * NOTE: Return the opposite of the switch-state. BDK */ -uae_u32 REGPARAM2 picasso_SetSwitch (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_SetSwitch (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uae_u16 flag = m68k_dreg (regs, 0) & 0xFFFF; char p96text[100]; @@ -1896,10 +1989,11 @@ static int updateclut (uaecptr clut, int start, int count) } return changed; } -uae_u32 REGPARAM2 picasso_SetColorArray (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_SetColorArray (TrapContext *ctx) { /* Fill in some static UAE related structure about this new CLUT setting * We need this for CLUT-based displays, and for mapping CLUT to hi/true colour */ + struct regstruct *regs = &ctx->regs; uae_u16 start = m68k_dreg (regs, 0); uae_u16 count = m68k_dreg (regs, 1); uaecptr boardinfo = m68k_areg (regs, 0); @@ -1918,8 +2012,9 @@ uae_u32 REGPARAM2 picasso_SetColorArray (struct regstruct *regs) * e.g. from chunky to TrueColor. Usually, all you have to do is to set * the RAMDAC of your board accordingly. */ -uae_u32 REGPARAM2 picasso_SetDAC (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_SetDAC (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; /* Fill in some static UAE related structure about this new DAC setting * Lets us keep track of what pixel format the Amiga is thinking about in our frame-buffer */ @@ -1960,12 +2055,17 @@ static void init_picasso_screen(void) * or linear start adress. They will be set when appropriate by their * own functions. */ -uae_u32 REGPARAM2 picasso_SetGC (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_SetGC (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; /* Fill in some static UAE related structure about this new ModeInfo setting */ + uaecptr AmigaBoardInfo = m68k_areg (regs, 0); uae_u32 border = m68k_dreg (regs, 0); uaecptr modeinfo = m68k_areg (regs, 1); + put_long (AmigaBoardInfo + PSSO_BoardInfo_ModeInfo, modeinfo); + put_word (AmigaBoardInfo + PSSO_BoardInfo_Border, border); + picasso96_state.Width = get_word (modeinfo + PSSO_ModeInfo_Width); picasso96_state.VirtualWidth = picasso96_state.Width; /* in case SetPanning doesn't get called */ @@ -2006,7 +2106,7 @@ uae_u32 REGPARAM2 picasso_SetGC (struct regstruct *regs) * because SetSwitch() is not called for subsequent Picasso screens. */ -static void picasso_SetPanningInit(void) +static void picasso_SetPanningInit (void) { picasso96_state.XYOffset = picasso96_state.Address + (picasso96_state.XOffset * picasso96_state.BytesPerPixel) + (picasso96_state.YOffset * picasso96_state.BytesPerRow); @@ -2016,8 +2116,9 @@ static void picasso_SetPanningInit(void) picasso96_state.BigAssBitmap = 0; } -uae_u32 REGPARAM2 picasso_SetPanning (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_SetPanning (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uae_u16 Width = m68k_dreg (regs, 0); uaecptr start_of_screen = m68k_areg (regs, 1); uaecptr bi = m68k_areg (regs, 0); @@ -2038,6 +2139,8 @@ uae_u32 REGPARAM2 picasso_SetPanning (struct regstruct *regs) picasso96_state.Address = start_of_screen; /* Amiga-side address */ picasso96_state.XOffset = (uae_s16)(m68k_dreg (regs, 1) & 0xFFFF); picasso96_state.YOffset = (uae_s16)(m68k_dreg (regs, 2) & 0xFFFF); + put_word (bi + PSSO_BoardInfo_XOffset, picasso96_state.XOffset); + put_word (bi + PSSO_BoardInfo_YOffset, picasso96_state.YOffset); picasso96_state.VirtualWidth = bme_width; picasso96_state.VirtualHeight = bme_height; picasso96_state.RGBFormat = m68k_dreg (regs, 7); @@ -2093,8 +2196,9 @@ static void do_xor8 (uae_u8 *p, int w, uae_u32 v) * This function is used to invert a rectangular area on the board. It is called by BltBitMap, * BltPattern and BltTemplate. */ -uae_u32 REGPARAM2 picasso_InvertRect (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_InvertRect (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr renderinfo = m68k_areg (regs, 1); unsigned long X = (uae_u16)m68k_dreg (regs, 0); unsigned long Y = (uae_u16)m68k_dreg (regs, 1); @@ -2144,8 +2248,9 @@ FillRect: * d5: UBYTE Mask * d7: uae_u32 RGBFormat ***********************************************************/ -uae_u32 REGPARAM2 picasso_FillRect (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_FillRect (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr renderinfo = m68k_areg (regs, 1); uae_u32 X = (uae_u16)m68k_dreg (regs, 0); uae_u32 Y = (uae_u16)m68k_dreg (regs, 1); @@ -2323,8 +2428,9 @@ BlitRect: * d6: UBYTE Mask * d7: uae_u32 RGBFormat ***********************************************************/ -uae_u32 REGPARAM2 picasso_BlitRect (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_BlitRect (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr renderinfo = m68k_areg (regs, 1); unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); unsigned long srcy = (uae_u16)m68k_dreg (regs, 1); @@ -2360,8 +2466,9 @@ BlitRectNoMaskComplete: * because the RGBFormat or opcode aren't supported. * OTHERWISE return 1 ***********************************************************/ -uae_u32 REGPARAM2 picasso_BlitRectNoMaskComplete (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_BlitRectNoMaskComplete (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr srcri = m68k_areg (regs, 1); uaecptr dstri = m68k_areg (regs, 2); unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); @@ -2376,16 +2483,6 @@ uae_u32 REGPARAM2 picasso_BlitRectNoMaskComplete (struct regstruct *regs) if (NOBLITTER) return 0; - { - uaecptr a5 = m68k_areg (regs, 5) & ~0xffff; - if (a5 != RTAREA_DEFAULT && a5 != RTAREA_BACKUP) { - static int notified; - if (!notified) - gui_message ("Picasso96 function call with invalid parameters!\n" - "Most likely reason: unsupported version of p96_uae_tweak"); - notified = 1; - } - } P96TRACE(("BlitRectNoMaskComplete() op 0x%02x, %08x:(%4d,%4d) --> %08x:(%4d,%4d), wh(%4d,%4d)\n", OpCode, get_long (srcri + PSSO_RenderInfo_Memory), srcx, srcy, get_long (dstri + PSSO_RenderInfo_Memory), dstx, dsty, width, height)); @@ -2439,8 +2536,9 @@ STATIC_INLINE void PixelWrite (uae_u8 *mem, int bits, uae_u32 fgpen, int Bpp, ua * always 16 pixels (one word) and the height is calculated as 2^Size. The data must be shifted up * and to the left by XOffset and YOffset pixels at the beginning. */ -uae_u32 REGPARAM2 picasso_BlitPattern (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_BlitPattern (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr rinf = m68k_areg (regs, 1); uaecptr pinf = m68k_areg (regs, 2); unsigned long X = (uae_u16)m68k_dreg (regs, 0); @@ -2600,8 +2698,9 @@ BlitTemplate: * using a single plane of image data which will be expanded to the destination RGBFormat * using ForeGround and BackGround pens as well as draw modes. ***********************************************************************************/ -uae_u32 REGPARAM2 picasso_BlitTemplate (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_BlitTemplate (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uae_u8 inversion = 0; uaecptr rinf = m68k_areg (regs, 1); uaecptr tmpl = m68k_areg (regs, 2); @@ -2761,8 +2860,9 @@ uae_u32 REGPARAM2 picasso_BlitTemplate (struct regstruct *regs) * This function calculates the amount of bytes needed for a line of * "Width" pixels in the given RGBFormat. */ -uae_u32 REGPARAM2 picasso_CalculateBytesPerRow (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_CalculateBytesPerRow (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uae_u16 width = m68k_dreg (regs, 0); uae_u32 type = m68k_dreg (regs, 7); width = GetBytesPerPixel (type) * width; @@ -2777,8 +2877,9 @@ uae_u32 REGPARAM2 picasso_CalculateBytesPerRow (struct regstruct *regs) * * NOTE: return the opposite of the state */ -uae_u32 REGPARAM2 picasso_SetDisplay (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_SetDisplay (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uae_u32 state = m68k_dreg (regs, 0); P96TRACE (("SetDisplay(%d)\n", state)); return !state; @@ -2909,8 +3010,9 @@ static void PlanarToChunky (struct RenderInfo *ri, struct BitMap *bm, * on the board. Watch out for plane pointers that are 0x00000000 (represents a plane with all bits "0") * or 0xffffffff (represents a plane with all bits "1"). */ -uae_u32 REGPARAM2 picasso_BlitPlanar2Chunky (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_BlitPlanar2Chunky (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr bm = m68k_areg (regs, 1); uaecptr ri = m68k_areg (regs, 2); unsigned long srcx = (uae_u16)m68k_dreg (regs, 0); @@ -3048,8 +3150,9 @@ static void PlanarToDirect (struct RenderInfo *ri, struct BitMap *bm, * triple bytes or longwords respectively similar to the color values used in FillRect(), BlitPattern() or * BlitTemplate(). */ -uae_u32 REGPARAM2 picasso_BlitPlanar2Direct (struct regstruct *regs) +static uae_u32 REGPARAM2 picasso_BlitPlanar2Direct (TrapContext *ctx) { + struct regstruct *regs = &ctx->regs; uaecptr bm = m68k_areg (regs, 1); uaecptr ri = m68k_areg (regs, 2); uaecptr cim = m68k_areg (regs, 3); @@ -3109,6 +3212,10 @@ static void flushpixels (void) for (;;) { gwwcnt = 0; + + if (doskip () && p96skipmode == 1) + break; + if (palette_changed < 0) { palette_changed = 1; if (picasso_palette ()) { @@ -3140,6 +3247,9 @@ static void flushpixels (void) if (dst == NULL) break; + if (doskip () && p96skipmode == 2) + break; + for (i = 0; i < gwwcnt; i++) { int pscnt = gwwpagesize; uae_u8 *p = gwwbuf[i]; @@ -3264,11 +3374,20 @@ static void flushpixels (void) if(lock) gfx_unlock_picasso (); if (dst && gwwcnt) { - mman_ResetWatch (src_start, src_end - src_start); - palette_changed = 0; + if (doskip () && p96skipmode == 3) { + ; + } else { + mman_ResetWatch (src_start, src_end - src_start); + } + palette_changed = 0; + } + if (maxy >= 0) { + if (doskip () && p96skipmode == 4) { + ; + } else { + DX_Invalidate (0, miny, picasso96_state.Width, maxy - miny + 1); + } } - if (maxy >= 0) - DX_Invalidate (0, miny, picasso96_state.Width, maxy - miny + 1); } static uae_u32 REGPARAM2 gfxmem_lgetx (uaecptr addr) @@ -3436,4 +3555,238 @@ uae_u8 *save_p96 (int *len, uae_u8 *dstptr) #endif +#ifdef UAEGFX_INTERNAL +#define RTGCALL(ABI,func,funcdef,call) \ + put_long (ABI + func, here ()); \ + dl (0x48e78000); \ + calltrap (deftrap (call)); \ + dw (0x4a80); \ + dl (0x4cdf0001);\ + dw (0x6604); \ + dw (0x2f28); \ + dw (funcdef); \ + dw (RTS); + +#define RTGCALL2(ABI,func,call) \ + put_long (ABI + func, here ()); \ + calltrap (deftrap (call)); \ + dw (RTS); + +#define RTGCALLDEFAULT(ABI,func,funcdef) \ + put_long (ABI + func, here ()); \ + dw (0x2f28); \ + dw (funcdef); \ + dw (RTS); + +#define RTGNONE(ABI,func) \ + put_long (ABI + func, start); + +static void inituaegfxfuncs (uaecptr ABI) +{ + uaecptr start = here (); + + dw (RTS); + /* ResolvePixelClock + move.l D0,gmi_PixelClock(a1) ; pass the pixelclock through + moveq #0,D0 ; index is 0 + move.b #98,gmi_Numerator(a1) ; whatever + move.b #14,gmi_Denominator(a1) ; whatever + rts + */ + put_long (ABI + PSSO_BoardInfo_ResolvePixelClock, here ()); + dl (0x2340002c); + dw (0x7000); + dl (0x137c0062); dw (0x002a); + dl (0x137c000e); dw (0x002b); + dw (RTS); + + /* GetPixelClock + move.l #CLOCK,D0 ; fill in D0 with our one true pixel clock + rts + */ + put_long (ABI + PSSO_BoardInfo_GetPixelClock, here ()); + dw (0x203c); + dl (100227260); + dw (RTS); + + /* CalculateMemory + ; this is simple, because we're not supporting planar modes in UAE + move.l a1,d0 + rts + */ + put_long (ABI + PSSO_BoardInfo_CalculateMemory, here ()); + dw (0x2009); + dw (RTS); + + /* GetCompatibleFormats + ; all formats can coexist without any problems, since we don't support planar stuff in UAE + move.l #~RGBFF_PLANAR,d0 + rts + */ + put_long (ABI + PSSO_BoardInfo_GetCompatibleFormats, here ()); + dw (0x203c); + dl (0xfffffffe); + dw (RTS); + + RTGNONE(ABI, PSSO_BoardInfo_SetClock); + RTGNONE(ABI, PSSO_BoardInfo_SetMemoryMode); + RTGNONE(ABI, PSSO_BoardInfo_SetWriteMask); + RTGNONE(ABI, PSSO_BoardInfo_SetClearMask); + RTGNONE(ABI, PSSO_BoardInfo_SetReadPlane); + + RTGNONE(ABI, PSSO_BoardInfo_WaitVerticalSync); /* FIXME */ + RTGNONE(ABI, PSSO_BoardInfo_WaitBlitter); + +#if 0 + RTGCALL2(ABI, PSSO_BoardInfo_, picasso_); + RTGCALL(ABI, PSSO_BoardInfo_, PSSO_BoardInfo_Default, picasso_); + RTGCALLDEFAULT(ABI, PSSO_BoardInfo_, PSSO_BoardInfo_Default); +#endif + + RTGCALL(ABI, PSSO_BoardInfo_BlitPlanar2Direct, PSSO_BoardInfo_BlitPlanar2DirectDefault, picasso_BlitPlanar2Direct); + RTGCALL(ABI, PSSO_BoardInfo_FillRect, PSSO_BoardInfo_FillRectDefault, picasso_FillRect); + RTGCALL(ABI, PSSO_BoardInfo_BlitRect, PSSO_BoardInfo_BlitRectDefault, picasso_BlitRect); + RTGCALL(ABI, PSSO_BoardInfo_BlitPlanar2Chunky, PSSO_BoardInfo_BlitPlanar2ChunkyDefault, picasso_BlitPlanar2Chunky); + RTGCALL(ABI, PSSO_BoardInfo_BlitTemplate, PSSO_BoardInfo_BlitTemplateDefault, picasso_BlitTemplate); + RTGCALL(ABI, PSSO_BoardInfo_InvertRect, PSSO_BoardInfo_InvertRectDefault, picasso_InvertRect); + RTGCALL(ABI, PSSO_BoardInfo_BlitRectNoMaskComplete, PSSO_BoardInfo_BlitRectNoMaskCompleteDefault, picasso_BlitRectNoMaskComplete); + RTGCALL(ABI, PSSO_BoardInfo_BlitPattern, PSSO_BoardInfo_BlitPatternDefault, picasso_BlitPattern); + + RTGCALL2(ABI, PSSO_BoardInfo_SetSwitch, picasso_SetSwitch); + RTGCALL2(ABI, PSSO_BoardInfo_SetColorArray, picasso_SetColorArray); + RTGCALL2(ABI, PSSO_BoardInfo_SetDAC, picasso_SetDAC); + RTGCALL2(ABI, PSSO_BoardInfo_SetGC, picasso_SetGC); + RTGCALL2(ABI, PSSO_BoardInfo_SetPanning, picasso_SetPanning); + RTGCALL2(ABI, PSSO_BoardInfo_CalculateBytesPerRow, picasso_CalculateBytesPerRow); + RTGCALL2(ABI, PSSO_BoardInfo_SetDisplay, picasso_SetDisplay); + + RTGCALL2(ABI, PSSO_BoardInfo_SetSprite, picasso_SetSprite); + RTGCALL2(ABI, PSSO_BoardInfo_SetSpritePosition, picasso_SetSpritePosition); + RTGCALL2(ABI, PSSO_BoardInfo_SetSpriteImage, picasso_SetSpriteImage); + RTGCALL2(ABI, PSSO_BoardInfo_SetSpriteColor, picasso_SetSpriteColor); + + RTGCALLDEFAULT(ABI, PSSO_BoardInfo_ScrollPlanar, PSSO_BoardInfo_ScrollPlanarDefault); + RTGCALLDEFAULT(ABI, PSSO_BoardInfo_UpdatePlanar, PSSO_BoardInfo_UpdatePlanarDefault); + RTGCALLDEFAULT(ABI, PSSO_BoardInfo_DrawLine, PSSO_BoardInfo_DrawLineDefault); + + write_log ("uaegfx.card magic code: %08X-%08X\n", start, here ()); +} + +#define UAEGFX_VERSION 3 +#define UAEGFX_REVISION 0 + +static uae_u32 REGPARAM2 gfx_open (TrapContext *context) +{ + put_word (uaegfx_base + 32, get_word (uaegfx_base + 32) + 1); + return uaegfx_base; +} +static uae_u32 REGPARAM2 gfx_close (TrapContext *context) +{ + put_word (uaegfx_base + 32, get_word (uaegfx_base + 32) - 1); + return 0; +} +static uae_u32 REGPARAM2 gfx_expunge (TrapContext *context) +{ + return 0; +} + +static uaecptr uaegfx_card_install (TrapContext *ctx, uae_u32 extrasize) +{ + uae_u32 functable, datatable, a2; + uaecptr openfunc, closefunc, expungefunc; + uaecptr findcardfunc, initcardfunc; + uaecptr exec = get_long (4); + + uaegfx_resid = ds ("UAE Graphics Card 3.0"); + + /* Open */ + openfunc = here (); + calltrap (deftrap (gfx_open)); dw (RTS); + + /* Close */ + closefunc = here (); + calltrap (deftrap (gfx_close)); dw (RTS); + + /* Expunge */ + expungefunc = here (); + calltrap (deftrap (gfx_expunge)); dw (RTS); + + /* FindCard */ + findcardfunc = here (); + calltrap (deftrap (picasso_FindCard)); dw (RTS); + + /* InitCard */ + initcardfunc = here (); + calltrap (deftrap (picasso_InitCard)); dw (RTS); + + functable = here (); + dl (openfunc); + dl (closefunc); + dl (expungefunc); + dl (EXPANSION_nullfunc); + dl (findcardfunc); + dl (initcardfunc); + dl (0xFFFFFFFF); /* end of table */ + + datatable = makedatatable (uaegfx_resid, uaegfx_resname, 0x09, -50, UAEGFX_VERSION, UAEGFX_REVISION); + + a2 = m68k_areg (&ctx->regs, 2); + m68k_areg (&ctx->regs, 0) = functable; + m68k_areg (&ctx->regs, 1) = datatable; + m68k_areg (&ctx->regs, 2) = 0; + m68k_dreg (&ctx->regs, 0) = CARD_SIZEOF + extrasize; + m68k_dreg (&ctx->regs, 1) = 0; + uaegfx_base = CallLib (ctx, exec, -0x54); /* MakeLibrary */ + m68k_areg (&ctx->regs, 2) = a2; + if (uaegfx_base) { + m68k_areg (&ctx->regs, 1) = uaegfx_base; + CallLib (ctx, exec, -0x18c); /* AddLibrary */ + } + m68k_areg (&ctx->regs, 1) = EXPANSION_explibname; + m68k_dreg (&ctx->regs, 0) = 0; + put_long (uaegfx_base + CARD_EXPANSIONBASE, CallLib (ctx, exec, -0x228)); /* OpenLibrary */ + put_long (uaegfx_base + CARD_EXECBASE, exec); + put_long (uaegfx_base + CARD_NAME, uaegfx_resname); + put_long (uaegfx_base + CARD_RESLIST, uaegfx_base + CARD_SIZEOF); + + write_log ("uaegfx.card %d.%d init @%08X\n", UAEGFX_VERSION, UAEGFX_REVISION, uaegfx_base); + return uaegfx_base; +} +#endif + +#ifndef UAEGFX_INTERNAL +uae_u32 picasso_demux (uae_u32 arg, TrapContext *context) +{ + switch (arg) + { + case 16: return picasso_FindCard (context); + case 17: return picasso_FillRect (context); + case 18: return picasso_SetSwitch (context); + case 19: return picasso_SetColorArray (context); + case 20: return picasso_SetDAC (context); + case 21: return picasso_SetGC (context); + case 22: return picasso_SetPanning (context); + case 23: return picasso_CalculateBytesPerRow (context); + case 24: return picasso_BlitPlanar2Chunky (context); + case 25: return picasso_BlitRect (context); + case 26: return picasso_SetDisplay (context); + case 27: return picasso_BlitTemplate (context); + case 28: return picasso_BlitRectNoMaskComplete (context); + case 29: return picasso_InitCard (context); + case 30: return picasso_BlitPattern (context); + case 31: return picasso_InvertRect (context); + case 32: return picasso_BlitPlanar2Direct (context); + /* case 34: return picasso_WaitVerticalSync (); handled in asm-code */ + case 35: return allocated_gfxmem ? 1 : 0; + case 36: return picasso_SetSprite (context); + case 37: return picasso_SetSpritePosition (context); + case 38: return picasso_SetSpriteImage (context); + case 39: return picasso_SetSpriteColor (context); + } + return 0; +} +#endif + #endif + + diff --git a/od-win32/picasso96_win.h b/od-win32/picasso96_win.h index b4152303..db94f800 100755 --- a/od-win32/picasso96_win.h +++ b/od-win32/picasso96_win.h @@ -115,13 +115,13 @@ struct CLUTEntry { uae_u8 Blue; }; -#define PSSO_BitMap_BytesPerRow 0 -#define PSSO_BitMap_Rows 2 -#define PSSO_BitMap_Flags 4 -#define PSSO_BitMap_Depth 5 -#define PSSO_BitMap_pad 6 -#define PSSO_BitMap_Planes 8 -#define PSSO_BitMap_sizeof 40 +#define PSSO_BitMap_BytesPerRow 0 +#define PSSO_BitMap_Rows 2 +#define PSSO_BitMap_Flags 4 +#define PSSO_BitMap_Depth 5 +#define PSSO_BitMap_pad 6 +#define PSSO_BitMap_Planes 8 +#define PSSO_BitMap_sizeof 40 struct BitMap { @@ -135,18 +135,18 @@ struct BitMap /************************************************************************/ -#define SETTINGSNAMEMAXCHARS 30 -#define BOARDNAMEMAXCHARS 30 +#define SETTINGSNAMEMAXCHARS 30 +#define BOARDNAMEMAXCHARS 30 struct Settings { - uae_u32 BoardType; + uae_u32 BoardType; /* a value discribing assignment to nth board local to boardtype * to be used for reassignment when boards are added or removed. */ - uae_u16 LocalOrdering; - uae_s16 LastSelected; - char NameField[SETTINGSNAMEMAXCHARS]; + uae_u16 LocalOrdering; + uae_s16 LastSelected; + char NameField[SETTINGSNAMEMAXCHARS]; /* neu! */ - char *BoardName; + char *BoardName; }; #define MAXRESOLUTIONNAMELENGTH 22 @@ -155,15 +155,15 @@ struct Settings { * only used within rtg.library * ********************************/ -#define PSSO_LibResolution_P96ID 14 -#define PSSO_LibResolution_Name 20 -#define PSSO_LibResolution_DisplayID 42 /* Name + MAXRESOLUTIONNAMELENGTH */ -#define PSSO_LibResolution_Width 46 -#define PSSO_LibResolution_Height 48 -#define PSSO_LibResolution_Flags 50 -#define PSSO_LibResolution_Modes 52 -#define PSSO_LibResolution_BoardInfo (52 + MAXMODES*4) -#define PSSO_LibResolution_sizeof (60 + MAXMODES*4) +#define PSSO_LibResolution_P96ID 14 +#define PSSO_LibResolution_Name 20 +#define PSSO_LibResolution_DisplayID 42 /* Name + MAXRESOLUTIONNAMELENGTH */ +#define PSSO_LibResolution_Width 46 +#define PSSO_LibResolution_Height 48 +#define PSSO_LibResolution_Flags 50 +#define PSSO_LibResolution_Modes 52 +#define PSSO_LibResolution_BoardInfo (52 + MAXMODES * 4) +#define PSSO_LibResolution_sizeof (60 + MAXMODES * 4) struct LibResolution { char P96ID[6]; @@ -184,32 +184,32 @@ struct LibResolution { #define P96F_PUBLIC (1< 3) + ddforceram = 0; + i++; + continue; + } if (!strcmp (arg, "-affinity")) { cpu_affinity = getval (np); i++; @@ -2824,6 +2812,12 @@ static int process_arg(char **xargv) inipath = my_strdup (np); continue; } + if (!strcmp (arg, "-p96skipmode")) { + extern int p96skipmode; + i++; + p96skipmode = getval (np); + continue; + } #ifdef RETROPLATFORM if (!strcmp (arg, "-rphost")) { i++; diff --git a/od-win32/win32.h b/od-win32/win32.h index 2465f496..ea2edf09 100755 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -15,9 +15,9 @@ #define GETBDM(x) (((x) - ((x / 10000) * 10000)) / 100) #define GETBDD(x) ((x) % 100) -#define WINUAEBETA 9 +#define WINUAEBETA 10 #define WINUAEPUBLICBETA 1 -#define WINUAEDATE MAKEBD(2008, 3, 18) +#define WINUAEDATE MAKEBD(2008, 3, 23) #define WINUAEEXTRA "" #define WINUAEREV "" diff --git a/od-win32/win32_scale2x.c b/od-win32/win32_scale2x.c index df9f1823..bb705f58 100755 --- a/od-win32/win32_scale2x.c +++ b/od-win32/win32_scale2x.c @@ -183,6 +183,10 @@ void S2X_init (int dw, int dh, int aw, int ah, int mult, int ad, int dd) temp_height = dst_height * 3; if (temp_height > dxdata.maxheight) temp_height = dxdata.maxheight; + if (temp_width < dst_width) + temp_width = dst_width; + if (temp_height < dst_height) + temp_height = dst_height; tempsurf = allocsurface (temp_width, temp_height); if (!tempsurf) write_log ("DDRAW: failed to create temp surface (%dx%d)\n", temp_width, temp_height); diff --git a/od-win32/winuae_msvc/winuae_msvc.vcproj b/od-win32/winuae_msvc/winuae_msvc.vcproj index 9ce5434f..6a92e19a 100755 --- a/od-win32/winuae_msvc/winuae_msvc.vcproj +++ b/od-win32/winuae_msvc/winuae_msvc.vcproj @@ -92,7 +92,7 @@ LinkIncremental="2" SuppressStartupBanner="true" GenerateManifest="false" - DelayLoadDLLs="setupapi.dll;wpcap.dll;packet.dll" + DelayLoadDLLs="wpcap.dll;packet.dll" GenerateDebugInformation="true" ProgramDatabaseFile=".\Debug/winuae.pdb" SubSystem="2" diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 97886474..5c7bada8 100755 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -1,4 +1,19 @@ +Beta 10: + +- MOVEM is not weird in debugger anymore +- JIT RAM allocation failure path fixed (if Z3+RTG RAM fails to + allocate, lower amount of RAM automatically and try again) +- limit internal sprite resolution to current display resolution + (setting in display panel), should improve performance slightly + in AGA modes if lots of sprites are used and display isn't shres +- harddrive detection crash if returned STORAGE_DEVICE_DESCRIPTOR + was shorter than expected +- disable hardware sprite if uaegfx.card is old version without + hardware sprite support and devs:monitors/info has softsprite=no +- added -ddforceram and -ddforcevram debugging command line params + try -ddforceram if you have slow P96Speed results + Beta 9: - crash when fullscreen enabled and error dialog was shown before diff --git a/readcpu.c b/readcpu.c index 07ec9cb7..5fa94af6 100755 --- a/readcpu.c +++ b/readcpu.c @@ -54,8 +54,8 @@ struct mnemolookup lookuptab[] = { { i_SWAP, "SWAP" }, { i_EXG, "EXG" }, { i_EXT, "EXT" }, - { i_MVMEL, "MVMEL" }, - { i_MVMLE, "MVMLE" }, + { i_MVMEL, "MVMEL", "MOVEM" }, + { i_MVMLE, "MVMLE", "MOVEM" }, { i_TRAP, "TRAP" }, { i_MVR2USP, "MVR2USP" }, { i_MVUSP2R, "MVUSP2R" }, @@ -98,8 +98,8 @@ struct mnemolookup lookuptab[] = { { i_ROXLW, "ROXLW" }, { i_ROXRW, "ROXRW" }, - { i_MOVE2C, "MOVE2C" }, - { i_MOVEC2, "MOVEC2" }, + { i_MOVE2C, "MOVE2C", "MOVEC" }, + { i_MOVEC2, "MOVEC2", "MOVEC" }, { i_CAS, "CAS" }, { i_CAS2, "CAS2" }, { i_MULL, "MULL" }, diff --git a/uaelib.c b/uaelib.c index ee1f1e41..d1f3065f 100755 --- a/uaelib.c +++ b/uaelib.c @@ -376,6 +376,9 @@ static int native_dos_op (uae_u32 mode, uae_u32 p1, uae_u32 p2, uae_u32 p3) } return 0; } +#ifndef UAEGFX_INTERNAL +extern uae_u32 picasso_demux (uae_u32 arg, TrapContext *context); +#endif static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context) { @@ -386,6 +389,11 @@ static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context) #define ARG4 (get_long (m68k_areg (&context->regs, 7) + 20)) #define ARG5 (get_long (m68k_areg (&context->regs, 7) + 24)) +#ifndef UAEGFX_INTERNAL + if (ARG0 >= 16 && ARG0 <= 39) + return picasso_demux (ARG0, context); +#endif + switch (ARG0) { case 0: return emulib_GetVersion (); @@ -406,31 +414,6 @@ static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context) case 14: return emulib_GetDisk (ARG1, ARG2); case 15: return emulib_Debug (); -#ifdef PICASSO96 - case 16: return picasso_FindCard (&context->regs); - case 17: return picasso_FillRect (&context->regs); - case 18: return picasso_SetSwitch (&context->regs); - case 19: return picasso_SetColorArray (&context->regs); - case 20: return picasso_SetDAC (&context->regs); - case 21: return picasso_SetGC (&context->regs); - case 22: return picasso_SetPanning (&context->regs); - case 23: return picasso_CalculateBytesPerRow (&context->regs); - case 24: return picasso_BlitPlanar2Chunky (&context->regs); - case 25: return picasso_BlitRect (&context->regs); - case 26: return picasso_SetDisplay (&context->regs); - case 27: return picasso_BlitTemplate (&context->regs); - case 28: return picasso_BlitRectNoMaskComplete (&context->regs); - case 29: return picasso_InitCard (&context->regs); - case 30: return picasso_BlitPattern (&context->regs); - case 31: return picasso_InvertRect (&context->regs); - case 32: return picasso_BlitPlanar2Direct (&context->regs); - /* case 34: return picasso_WaitVerticalSync (); handled in asm-code */ - case 35: return allocated_gfxmem ? 1 : 0; - case 36: return picasso_SetSprite (&context->regs); - case 37: return picasso_SetSpritePosition (&context->regs); - case 38: return picasso_SetSpriteImage (&context->regs); - case 39: return picasso_SetSpriteColor (&context->regs); -#endif case 68: return emulib_Minimize (); case 69: return emulib_ExecuteNativeCode (&context->regs); @@ -457,11 +440,18 @@ static uae_u32 REGPARAM2 uaelib_demux (TrapContext *context) { uae_u32 v; struct regstruct *r = &context->regs; + if (uaelib_debug) write_log ("%d: %08x %08x %08x %08x %08x %08x %08x %08x, %08x %08x %08x %08x %08x %08x %08x %08x\n", ARG0, r->regs[0],r->regs[1],r->regs[2],r->regs[3],r->regs[4],r->regs[5],r->regs[6],r->regs[7], r->regs[8],r->regs[9],r->regs[10],r->regs[11],r->regs[12],r->regs[13],r->regs[14],r->regs[15]); +#ifdef UAEGFX_INTERNAL + if (ARG0 >= 16 && ARG0 <= 39) { + write_log ("uaelib: obsolete Picasso96 uaelib hook called, call ignored\n"); + return 0; + } +#endif v = uaelib_demux2 (context); if (uaelib_debug) write_log ("=%08x\n", v); -- 2.47.3