From: Toni Wilen Date: Mon, 28 Mar 2005 06:51:29 +0000 (+0300) Subject: imported winuaesrc1000b5.zip X-Git-Tag: 2100~316 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=83baf066bad5facca23d37eb9523ba1dc5f1c76b;p=francis%2Fwinuae.git imported winuaesrc1000b5.zip --- diff --git a/custom.c b/custom.c index 2beffb92..eb89d1a1 100755 --- a/custom.c +++ b/custom.c @@ -12,7 +12,7 @@ #define DEBUG_COPPER 0 #define SPRITE_DEBUG 0 #define SPRITE_DEBUG_MINY 0 -#define SPRITE_DEBUG_MAXY 41 +#define SPRITE_DEBUG_MAXY 100 //#define SPRITE_MASK 0 #define SPRITE_MASK (1|2|4|8|16|32|64|128) #define SPR0_HPOS 0x15 @@ -212,7 +212,8 @@ enum diw_states int plffirstline, plflastline; int plfstrt, plfstop; -static int last_diw_pix_hpos, last_ddf_pix_hpos, last_decide_line_hpos; +static int last_diw_pix_hpos, last_ddf_pix_hpos; +static int last_decide_line_hpos, last_sprite_decide_line_hpos; static int last_fetch_hpos, last_sprite_hpos; int diwfirstword, diwlastword; static enum diw_states diwstate, hdiwstate, ddfstate; @@ -1607,9 +1608,11 @@ STATIC_INLINE void decide_line (int hpos) } #ifndef CUSTOM_SIMPLE - if (last_decide_line_hpos < SPR0_HPOS + 4 * MAX_SPRITES) + if (last_sprite_decide_line_hpos < SPR0_HPOS + 4 * MAX_SPRITES) do_sprites (hpos); #endif + last_sprite_decide_line_hpos = hpos; + last_decide_line_hpos = hpos; } @@ -1966,11 +1969,6 @@ static void decide_sprites (int hpos) decide_diw (hpos); decide_line (hpos); -#if 0 - /* This tries to detect whether the line is border, but that doesn't work, it's too early. */ - if (thisline_decision.plfleft == -1) - return; -#endif count = 0; for (i = 0; i < MAX_SPRITES; i++) { int sprxp = spr[i].xpos; @@ -2097,11 +2095,11 @@ static void finish_decisions (void) dp = line_decisions + next_lineno; changed = thisline_changed; - if (thisline_decision.plfleft != -1) { + if (thisline_decision.plfleft != -1) record_diw_line (thisline_decision.plfleft, diwfirstword, diwlastword); + if (thisline_decision.plfleft != -1 || (bplcon3 & 2)) decide_sprites (hpos); - } dip->last_sprite_entry = next_sprite_entry; dip->last_color_change = next_color_change; @@ -2175,6 +2173,7 @@ static void reset_decisions (void) memset (outword, 0, sizeof outword); last_decide_line_hpos = -1; + last_sprite_decide_line_hpos = -1; last_diw_pix_hpos = -1; last_ddf_pix_hpos = -1; last_sprite_hpos = -1; @@ -2309,6 +2308,10 @@ static void calcdiw (void) diwfirstword = coord_diw_to_window_x (hstrt); diwlastword = coord_diw_to_window_x (hstop); + if (diwfirstword >= diwlastword) { + diwfirstword = 0; + diwlastword = max_diwlastword; + } if (diwfirstword < 0) diwfirstword = 0; diff --git a/drawing.c b/drawing.c index ab75926d..53034fe3 100755 --- a/drawing.c +++ b/drawing.c @@ -1446,8 +1446,8 @@ STATIC_INLINE void pfield_draw_line (int lineno, int gfx_ypos, int follow_ypos) #endif xlinebuffer -= linetoscr_x_adjust_bytes; - if (border == 0) { + pfield_expand_dp_bplcon (); if (bplres == RES_LORES && ! currprefs.gfx_lores) @@ -1507,16 +1507,15 @@ STATIC_INLINE void pfield_draw_line (int lineno, int gfx_ypos, int follow_ypos) } if (currprefs.gfx_lores == 2) currprefs.gfx_lores = 0; + } else if (border == 1) { + adjust_drawing_colors (dp_for_drawing->ctable, 0); if (dip_for_drawing->nr_color_changes == 0) { fill_line (); do_flush_line (gfx_ypos); -#if 0 - if (dh == dh_emerg) - abort (); -#endif + if (do_double) { if (dh == dh_buf) { xlinebuffer = row_map[follow_ypos] - linetoscr_x_adjust_bytes; @@ -1547,12 +1546,15 @@ STATIC_INLINE void pfield_draw_line (int lineno, int gfx_ypos, int follow_ypos) * from linemem. */ do_flush_line (follow_ypos); } + } else { + xcolnr tmp = colors_for_drawing.acolors[0]; colors_for_drawing.acolors[0] = getxcolor (0); fill_line (); do_flush_line (gfx_ypos); colors_for_drawing.acolors[0] = tmp; + } } diff --git a/filesys.c b/filesys.c index 977472dd..3f9e562b 100755 --- a/filesys.c +++ b/filesys.c @@ -3496,8 +3496,6 @@ void filesys_start_threads (void) UnitInfo *uip; int i; - if (savestate_state == STATE_RESTORE) - init_filesys_diagentry (); free_mountinfo (¤t_mountinfo); dup_mountinfo (&options_mountinfo, ¤t_mountinfo); uip = current_mountinfo.ui; diff --git a/memory.c b/memory.c index 8c86a4f9..7428d569 100755 --- a/memory.c +++ b/memory.c @@ -2158,7 +2158,7 @@ uae_u8 *restore_rom (uae_u8 *src) restore_u32 (); crc32 = restore_u32 (); for (i = 0; i < romlist_cnt; i++) { - if (rl[i].rd->crc32 == crc32) { + if (rl[i].rd->crc32 == crc32 && crc32) { strncpy (changed_prefs.romfile, rl[i].path, 255); break; } diff --git a/od-win32/dinput.c b/od-win32/dinput.c index 69ed605f..6ace22ca 100755 --- a/od-win32/dinput.c +++ b/od-win32/dinput.c @@ -468,7 +468,7 @@ static int acquire (LPDIRECTINPUTDEVICE8 lpdi, char *txt) static int setcoop (LPDIRECTINPUTDEVICE8 lpdi, DWORD mode, char *txt) { HRESULT hr = DI_OK; - if (lpdi) { + if (lpdi && hMainWnd) { hr = IDirectInputDevice8_SetCooperativeLevel (lpdi, hMainWnd, mode); if (hr != DI_OK && hr != E_NOTIMPL) write_log ("setcooperativelevel %s failed, %s\n", txt, DXError (hr)); diff --git a/od-win32/mman.c b/od-win32/mman.c index 49bea7b6..fa506eca 100755 --- a/od-win32/mman.c +++ b/od-win32/mman.c @@ -12,7 +12,7 @@ #include "autoconf.h" #include "win32.h" -static struct shmid_ds shmids[ MAX_SHMID ]; +static struct shmid_ds shmids[MAX_SHMID]; static uae_u32 gfxoffs; uae_u32 natmem_offset = 0; @@ -21,56 +21,41 @@ void init_shm( void ) { int i; LPVOID blah = NULL; -#if 0 - LPBYTE address = NULL; // Let the system decide where to put the memory... -#else LPBYTE address = (LPBYTE)0x10000000; // Letting the system decide doesn't seem to work on some systems -#endif int size = 0x19000000; int add = 0x1000000; canbang = 0; gfxoffs = 0; shm_start = 0; - for( i = 0; i < MAX_SHMID; i++ ) - { + 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; } - while (address < (LPBYTE)0xa0000000) - { - blah = VirtualAlloc( address, size, MEM_RESERVE, PAGE_EXECUTE_READWRITE ); - if (blah == NULL) - { - address += add; - } - else - { - natmem_offset = (uae_u32)blah; - write_log ("NATMEM: Our special area: 0x%x-0x%x\n", natmem_offset, natmem_offset + size); - VirtualFree (blah, 0, MEM_RELEASE); - while (address < (LPBYTE)0xa0000000) { + if (os_winnt) { + natmem_offset = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_EXECUTE_READWRITE); + } else { + while (address < (LPBYTE)0xa0000000) { + blah = VirtualAlloc(address, size, MEM_RESERVE, PAGE_EXECUTE_READWRITE); + if (blah == NULL) { + address += add; + } else { + VirtualFree (blah, 0, MEM_RELEASE); address += add * 32; - if (!os_winnt) /* Windows 9x/ME sucks */ - break; - blah = VirtualAlloc (address, size, MEM_RESERVE, PAGE_EXECUTE_READWRITE); - if (blah == NULL) { - address -= add * 32; - break; - } - VirtualFree (blah, 0, MEM_RELEASE); + natmem_offset = (uae_u8*)address; + break; } - natmem_offset = (uae_u8*)natmem_offset + ((uae_u8*)address - (uae_u8*)natmem_offset) / 2; - write_log ("NATMEM: after adjustment: 0x%x-0x%x\n", natmem_offset, natmem_offset + size); - canbang = 1; - break; } } if (!natmem_offset) { - write_log( "NATMEM: No special area could be allocated!\n" ); + write_log("NATMEM: No special area could be allocated!\n"); + } else { + write_log("NATMEM: Our special area: 0x%p-0x%p\n", + natmem_offset, (uae_u8*)natmem_offset + size); + canbang = 1; } } @@ -96,7 +81,7 @@ void mapped_free(uae_u8 *mem) else { //free( x->native_address ); - VirtualFree((LPVOID)mem, 0, MEM_DECOMMIT |MEM_RELEASE ); + VirtualFree((LPVOID)mem, 0, os_winnt ? MEM_RESET : (MEM_DECOMMIT | MEM_RELEASE)); } } x = x->next; @@ -151,8 +136,8 @@ void *shmat(int shmid, LPVOID shmaddr, int shmflg) { shmaddr=natmem_offset; got = TRUE; - if(!currprefs.fastmem_size) - size+=32; +// if(!currprefs.fastmem_size) +// size+=32; } if(!strcmp(shmids[shmid].name,"kick")) { @@ -220,22 +205,18 @@ void *shmat(int shmid, LPVOID shmaddr, int shmflg) } #endif - if( ( shmids[shmid].key == shmid ) && shmids[shmid].size ) - { + if( ( shmids[shmid].key == shmid ) && shmids[shmid].size ) { got = FALSE; if (got == FALSE) { - if (shmaddr) - { - result=(void*)VirtualFree(shmaddr,0,MEM_RELEASE); + if (shmaddr) { + result = (void*)VirtualFree(shmaddr, 0, os_winnt ? MEM_RESET : MEM_RELEASE); } - result = VirtualAlloc(shmaddr,size,MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE ); - if( result == NULL ) - { + result = VirtualAlloc(shmaddr, size, os_winnt ? MEM_COMMIT : (MEM_RESERVE | MEM_COMMIT), + PAGE_EXECUTE_READWRITE); + if( result == NULL ) { result = (void *)-1; - write_log ("VirtualAlloc %x %x failed %d\n", shmaddr, size, GetLastError ()); - } - else - { + write_log ("VirtualAlloc %p %x failed %d\n", shmaddr, size, GetLastError ()); + } else { shmids[shmid].attached=result; } } else { diff --git a/od-win32/picasso96_win.c b/od-win32/picasso96_win.c index c6a09196..868b790d 100755 --- a/od-win32/picasso96_win.c +++ b/od-win32/picasso96_win.c @@ -53,7 +53,8 @@ int p96hack_vpos, p96hack_vpos2, p96refresh_active; int have_done_picasso; /* For the JIT compiler */ int picasso_is_special = PIC_WRITE; /* ditto */ int picasso_is_special_read = PIC_READ; /* ditto */ -static int p96syncrate; +static int vsyncgfxwrite = 0; +static int p96syncrate,vsyncgfxcount; int p96hsync_counter; #define SWAPSPEEDUP #ifdef PICASSO96 @@ -706,9 +707,10 @@ static void do_blit( struct RenderInfo *ri, int Bpp, width *= Bpp; while (height-- > 0) { - memcpy (dstp, srcp, width); + memcpy (dstp, srcp, width); srcp += ri->BytesPerRow; dstp += picasso_vidinfo.rowbytes; + } } else @@ -920,6 +922,25 @@ void picasso_handle_vsync (void) DX_SetPalette (0,256); palette_changed = 0; } + + if (vsyncgfxwrite==1) { + static long blitcount; + vsyncgfxcount++; + if (vsyncgfxcount>1) { + if (picasso_on) { + if (picasso96_state.RGBFormat == picasso_vidinfo.rgbformat + || picasso96_state.RGBFormat == RGBFB_CHUNKY) { + static frame_time_t cycles; + blitcount++; + cycles = read_processor_time(); + picasso_refresh(1); + vsyncgfxcount = 0; + write_log("%d Blitnum %.3fms\n", blitcount, + (read_processor_time() - cycles) * 1000 / (double)syncbase); + } + } + } + } } static int set_panning_called = 0; @@ -935,9 +956,8 @@ void picasso_refresh ( int call_setpalette ) { struct RenderInfo ri; static int beamcon0_before, p96refresh_was; - - if (! picasso_on) - return; + + if (! picasso_on)return; { //for higher P96 mousedraw rate /* HACK */ extern uae_u16 vtotal; @@ -1995,7 +2015,7 @@ uae_u32 picasso_InvertRect (void) for (lines = 0; lines < Height; lines++, uae_mem += ri.BytesPerRow) do_xor8 (uae_mem, width_in_bytes, xorval); - if (renderinfo_is_current_screen (&ri)) { + if (vsyncgfxwrite==0) if (renderinfo_is_current_screen (&ri)) { if (mask == 0xFF) do_invertrect( &ri, Bpp, X, Y, Width, Height ); else @@ -2121,7 +2141,7 @@ uae_u32 picasso_FillRect (void) if( Y+Height > picasso96_state.Height) Height = picasso96_state.Height - Y; - do_fillrect( src, X, Y, Width, Height, Pen, Bpp, RGBFormat ); + if (vsyncgfxwrite==0)do_fillrect( src, X, Y, Width, Height, Pen, Bpp, RGBFormat ); } } result = 1; @@ -2152,7 +2172,7 @@ uae_u32 picasso_FillRect (void) } } } - if (renderinfo_is_current_screen (&ri)) + if (vsyncgfxwrite==0) if (renderinfo_is_current_screen (&ri)) do_blit( &ri, Bpp, X, Y, X, Y, Width, Height, BLIT_SRC, 0); result = 1; } @@ -2249,7 +2269,8 @@ STATIC_INLINE int BlitRectHelper( void ) /* Do our virtual frame-buffer memory first */ do_blitrect_frame_buffer( ri, dstri, srcx, srcy, dstx, dsty, width, height, mask, opcode ); /* Now we do the on-screen display, if renderinfo points to it */ - if (renderinfo_is_current_screen (dstri)) + if (vsyncgfxwrite==1)return 1; + if (renderinfo_is_current_screen (dstri)) { if (mask == 0xFF || Bpp > 1) { if( can_do_visible_blit ) @@ -2603,7 +2624,7 @@ uae_u32 picasso_BlitPattern (void) /* If we need to update a second-buffer (extra_mem is set), then do it only if visible! */ if ( picasso_vidinfo.extra_mem && renderinfo_is_current_screen (&ri)) - do_blit( &ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0); + if (vsyncgfxwrite==0)do_blit( &ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0); result = 1; } @@ -2792,7 +2813,7 @@ uae_u32 picasso_BlitTemplate (void) /* If we need to update a second-buffer (extra_mem is set), then do it only if visible! */ if( picasso_vidinfo.extra_mem && renderinfo_is_current_screen( &ri ) ) - do_blit( &ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0 ); + if (vsyncgfxwrite==0)do_blit( &ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0 ); result = 1; } @@ -2840,7 +2861,7 @@ uae_u32 picasso_SetDisplay (void) void picasso_handle_hsync (void) { static int p96hsync; - + if (currprefs.gfxmem_size == 0) return; if (WIN32GFX_IsPicassoScreen () && currprefs.gfx_pfullscreen && currprefs.gfx_vsync) { @@ -2993,7 +3014,7 @@ uae_u32 picasso_BlitPlanar2Chunky (void) PlanarToChunky (&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, mask); if (renderinfo_is_current_screen (&local_ri)) { - do_blit( &local_ri, GetBytesPerPixel( local_ri.RGBFormat ), dstx, dsty, dstx, dsty, width, height, BLIT_SRC, 0); + if (!vsyncgfxwrite)do_blit( &local_ri, GetBytesPerPixel( local_ri.RGBFormat ), dstx, dsty, dstx, dsty, width, height, BLIT_SRC, 0); } result = 1; } @@ -3150,7 +3171,7 @@ uae_u32 picasso_BlitPlanar2Direct (void) srcx, srcy, dstx, dsty, width, height, minterm, Mask, local_bm.Depth)); PlanarToDirect (&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, Mask, &local_cim); if (renderinfo_is_current_screen (&local_ri)) - do_blit( &local_ri, GetBytesPerPixel( local_ri.RGBFormat ), dstx, dsty, dstx, dsty, width, height, BLIT_SRC, 0); + if (!vsyncgfxwrite)do_blit( &local_ri, GetBytesPerPixel( local_ri.RGBFormat ), dstx, dsty, dstx, dsty, width, height, BLIT_SRC, 0); result = 1; } #ifdef LOCK_UNLOCK_MADNESS @@ -3666,7 +3687,7 @@ l2: do_put_mem_long(m, l); #endif /* write the long-word to our displayable memory */ - write_gfx_long(addr, l); + if (vsyncgfxwrite==0)write_gfx_long(addr, l); } static void REGPARAM2 gfxmem_wput (uaecptr addr, uae_u32 w) @@ -3679,7 +3700,7 @@ static void REGPARAM2 gfxmem_wput (uaecptr addr, uae_u32 w) do_put_mem_word(m, (uae_u16)w); /* write the word to our displayable memory */ - write_gfx_word(addr, (uae_u16)w); + if (vsyncgfxwrite==0)write_gfx_word(addr, (uae_u16)w); } static void REGPARAM2 gfxmem_bput (uaecptr addr, uae_u32 b) @@ -3690,7 +3711,7 @@ static void REGPARAM2 gfxmem_bput (uaecptr addr, uae_u32 b) gfxmemory[addr] = b; /* write the byte to our displayable memory */ - write_gfx_byte(addr, (uae_u8)b); + if (vsyncgfxwrite==0)write_gfx_byte(addr, (uae_u8)b); } static int REGPARAM2 gfxmem_check (uaecptr addr, uae_u32 size) diff --git a/od-win32/win32.c b/od-win32/win32.c index 12d90320..0a9f525f 100755 --- a/od-win32/win32.c +++ b/od-win32/win32.c @@ -68,6 +68,7 @@ unsigned long *win32_freestack[42]; //EXTRA_STACK_SIZE extern FILE *debugfile; extern int console_logging; static OSVERSIONINFO osVersion; +static SYSTEM_INFO SystemInfo; int useqpc = 0; /* Set to TRUE to use the QueryPerformanceCounter() function instead of rdtsc() */ int cpu_mmx = 0; @@ -1609,6 +1610,12 @@ void logging_init( void ) write_log (" (%s %d.%d %s%s)", os_winnt ? "NT" : "W9X/ME", osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.szCSDVersion, os_winnt_admin ? " Admin" : ""); + write_log (" %s %X.%X %d", + SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL ? "32-bit x86" : + SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 ? "IA64" : + SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ? "AMD64" : "Unknown", + SystemInfo.wProcessorLevel, SystemInfo.wProcessorRevision, + SystemInfo.dwNumberOfProcessors); write_log ("\n(c) 1995-2001 Bernd Schmidt - Core UAE concept and implementation." "\n(c) 1998-2005 Toni Wilen - Win32 port, core code updates." "\n(c) 1996-2001 Brian King - Win32 port, Picasso96 RTG, and GUI." @@ -2117,16 +2124,23 @@ static int isadminpriv (void) return isadmin; } +typedef void (CALLBACK* PGETNATIVESYSTEMINFO)(LPSYSTEM_INFO); +static PGETNATIVESYSTEMINFO pGetNativeSystemInfo; + static int osdetect (void) { os_winnt = 0; os_winnt_admin = 0; - osVersion.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); - if( GetVersionEx( &osVersion ) ) - { - if( ( osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT ) && - ( osVersion.dwMajorVersion <= 4 ) ) + pGetNativeSystemInfo = (PGETNATIVESYSTEMINFO)GetProcAddress( + GetModuleHandle("kernel32.dll"), "GetNativeSystemInfo"); + GetNativeSystemInfo(&SystemInfo); + if (pGetNativeSystemInfo) + pGetNativeSystemInfo(&SystemInfo); + osVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (GetVersionEx(&osVersion)) { + if ((osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) && + (osVersion.dwMajorVersion <= 4)) { /* WinUAE not supported on this version of Windows... */ char szWrongOSVersion[ MAX_DPATH ]; @@ -2157,6 +2171,7 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR int i; int multi_display = 1; +#if 1 #ifdef __GNUC__ __asm__ ("leal -2300*1024(%%esp),%0" : "=r" (win32_stackbase) :); #else @@ -2166,6 +2181,7 @@ __asm{ mov win32_stackbase,eax } #endif +#endif #ifdef _DEBUG { diff --git a/od-win32/win32.h b/od-win32/win32.h index a851395d..6d25d480 100755 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -22,7 +22,7 @@ extern int manual_palette_refresh_needed; extern int mouseactive, focus; extern int ignore_messages_all; #define WINUAEBETA 1 -#define WINUAEBETASTR " Beta 4" +#define WINUAEBETASTR " Beta 5" extern void my_kbd_handler (int, int, int); extern void clearallkeys(void); diff --git a/savestate.c b/savestate.c index 7ffa898c..c0ce13fa 100755 --- a/savestate.c +++ b/savestate.c @@ -237,6 +237,7 @@ static uae_u8 *restore_chunk (struct zfile *f, char *name, long *len, long *tota uae_u32 flags; long len2; + *totallen = 0; /* chunk name */ zfile_fread (name, 1, 4, f); name[4] = 0; @@ -359,7 +360,7 @@ void restore_state (char *filename) if (!strcmp (name, prevchunk)) break; strcpy (prevchunk, name); - write_log ("Chunk '%s' size %d\n", name, len); + write_log ("Chunk '%s' size %d (%d)\n", name, len, totallen); if (!strcmp (name, "END ")) break; if (!strcmp (name, "CRAM")) {