diff -awurd 421vanilla/src/win/wddlock.c 421noasm/src/win/wddlock.c --- 421vanilla/src/win/wddlock.c Fri Oct 28 06:57:00 2005 +++ 421noasm/src/win/wddlock.c Thu Mar 1 20:48:15 2007 @@ -23,9 +23,68 @@ #define PREFIX_E "al-wddlock ERROR: " +//if asm is used, this code is in asmlock.s instead +#if defined ALLEGRO_NO_ASM || defined ALLEGRO_USE_C + +static void update_dirty_lines (BITMAP *bmp) { + int i; + RECT rect; + //the width is always the full bitmap width, because we have no + // mechanism for measuring the X range of the update + rect.left = 0; + rect.right = bmp->w; + for (i = 0; i < bmp->h; i++) { + if (wd_dirty_lines[i]) { + int j = i+1; + rect.top = i; + //consecutive dirty lines are combined into ranges of Y values + for (; wd_dirty_lines[j]; j++) ; + rect.bottom = j; + update_window(&rect); + i = j+1; + } + } +} + +uintptr_t gfx_directx_write_bank (BITMAP *bmp, int line) { + if (!(bmp->id & BMP_ID_LOCKED)) + gfx_directx_autolock(bmp); + return (uintptr_t) bmp->line[line]; +} + +void gfx_directx_unwrite_bank (BITMAP *bmp) { + if (!(bmp->id & BMP_ID_AUTOLOCK)) return; + gfx_directx_unlock(bmp); + bmp->id &= ~ BMP_ID_AUTOLOCK; +} + +uintptr_t gfx_directx_write_bank_win (BITMAP *bmp, int line) { + wd_dirty_lines[bmp->y_ofs+line] = 1; + if (!(bmp->id & BMP_ID_LOCKED)) gfx_directx_autolock(bmp); + return (uintptr_t) bmp->line[line]; +} + +void gfx_directx_unwrite_bank_win (BITMAP *bmp) { + if (!(bmp->id & BMP_ID_AUTOLOCK)) return; + gfx_directx_unlock(bmp); + bmp->id &= ~BMP_ID_AUTOLOCK; + // update dirty lines: this is safe because autolocking + // is guaranteed to be the only level of locking. + // (or at least, that's what it says in asmlock.s) + update_dirty_lines(gfx_directx_forefront_bitmap); +} + +void gfx_directx_unlock_win (BITMAP *bmp) { + gfx_directx_unlock(bmp); + // forefront_bitmap may still be locked in case of nested locking + if (!(gfx_directx_forefront_bitmap->id & BMP_ID_LOCKED)) + update_dirty_lines(gfx_directx_forefront_bitmap); +} +#else +//asmlock.s requires these two variables void (*ptr_gfx_directx_autolock) (BITMAP* bmp) = gfx_directx_autolock; void (*ptr_gfx_directx_unlock) (BITMAP* bmp) = gfx_directx_unlock; - +#endif//defined ALLEGRO_NO_ASM || defined ALLEGRO_USE_C /* gfx_directx_switch_out: diff -awurd 421vanilla/src/win/wddraw.h 421noasm/src/win/wddraw.h --- 421vanilla/src/win/wddraw.h Sun May 15 02:54:00 2005 +++ 421noasm/src/win/wddraw.h Thu Mar 1 20:48:15 2007 @@ -116,18 +116,23 @@ AL_FUNC(int, set_video_mode, (int w, int h, int v_w, int v_h, int color_depth)); -/* bitmap locking (from wddlock.c and asmlock.s) */ +/* bitmap locking (from wddlock.c and wgdi.c and possibly asmlock.s) */ AL_FUNC(void, gfx_directx_lock, (BITMAP *bmp)); AL_FUNC(void, gfx_directx_autolock, (BITMAP* bmp)); AL_FUNC(void, gfx_directx_unlock, (BITMAP *bmp)); AL_FUNC(void, gfx_directx_unlock_win, (BITMAP *bmp)); AL_FUNC(void, gfx_directx_release_lock, (BITMAP * bmp)); -AL_FUNC(void, gfx_directx_write_bank, (void)); -AL_FUNC(void, gfx_directx_unwrite_bank, (void)); -AL_FUNC(void, gfx_directx_write_bank_win, (void)); -AL_FUNC(void, gfx_directx_unwrite_bank_win, (void)); -AL_FUNCPTR(void, ptr_gfx_directx_autolock, (BITMAP* bmp)); -AL_FUNCPTR(void, ptr_gfx_directx_unlock, (BITMAP* bmp)); +AL_FUNC(uintptr_t, gfx_directx_write_bank, (BITMAP *bmp, int line)); +AL_FUNC(void, gfx_directx_unwrite_bank, (BITMAP *bmp)); +AL_FUNC(uintptr_t, gfx_directx_write_bank_win, (BITMAP *bmp, int line)); +AL_FUNC(void, gfx_directx_unwrite_bank_win, (BITMAP *bmp)); +AL_FUNC(void, gfx_gdi_autolock, (struct BITMAP* bmp)); +AL_FUNC(void, gfx_gdi_unlock, (struct BITMAP* bmp)); +AL_FUNC(uintptr_t, gfx_gdi_write_bank, (BITMAP *bmp, int line)); +AL_FUNC(void, gfx_gdi_unwrite_bank, (BITMAP *bmp)); +/* dirty window updating (from wddwin.c, used in wddlock.c or asmlock.s) */ +AL_VAR(char *, wd_dirty_lines); +AL_FUNCPTR(void, update_window, (RECT *rect)); /* bitmap creation (from wddbmp.c) */ diff -awurd 421vanilla/src/win/wddwin.c 421noasm/src/win/wddwin.c --- 421vanilla/src/win/wddwin.c Sat Dec 31 12:42:00 2005 +++ 421noasm/src/win/wddwin.c Thu Mar 1 20:48:15 2007 @@ -25,7 +25,6 @@ #define PREFIX_E "al-wddwin ERROR: " -/* exported only for asmlock.s */ char *wd_dirty_lines = NULL; /* used in WRITE_BANK() */ void (*update_window) (RECT *rect) = NULL; /* window updater */ diff -awurd 421vanilla/src/win/wgdi.c 421noasm/src/win/wgdi.c --- 421vanilla/src/win/wgdi.c Sat Jul 29 15:57:00 2006 +++ 421noasm/src/win/wgdi.c Thu Mar 1 20:48:15 2007 @@ -32,16 +32,32 @@ #define PREFIX_E "al-wgdi ERROR: " -/* function from asmlock.s */ -extern void gfx_gdi_write_bank(void); -extern void gfx_gdi_unwrite_bank(void); - -/* exported only for asmlock.s */ static void gfx_gdi_autolock(struct BITMAP* bmp); static void gfx_gdi_unlock(struct BITMAP* bmp); + +//this is used only in asmlock.s and this file +char *gdi_dirty_lines = NULL; /* used in WRITE_BANK() */ + +//if asm is used, this code is in asmlock.s instead +#if defined ALLEGRO_NO_ASM || defined ALLEGRO_USE_C + +uintptr_t gfx_gdi_write_bank (BITMAP *bmp, int line) { + gdi_dirty_lines[bmp->y_ofs] = 1; + if (!(bmp->id & BMP_ID_LOCKED)) gfx_gdi_autolock(bmp); + return (uintptr_t) bmp->line[line]; +} +void gfx_gdi_unwrite_bank (BITMAP *bmp) { + if (!(bmp->id & BMP_ID_AUTOLOCK)) return; + gfx_gdi_unlock(bmp); + bmp->id &= ~ BMP_ID_AUTOLOCK; +} +#else +//asmlock.s requires these two variables void (*ptr_gfx_gdi_autolock) (struct BITMAP* bmp) = gfx_gdi_autolock; void (*ptr_gfx_gdi_unlock) (struct BITMAP* bmp) = gfx_gdi_unlock; -char *gdi_dirty_lines = NULL; /* used in WRITE_BANK() */ +//wddraw.h, despite its name, includes the exports from asmlock.s +#include "wddraw.h" +#endif//defined ALLEGRO_NO_ASM || defined ALLEGRO_USE_C static struct BITMAP *gfx_gdi_init(int w, int h, int v_w, int v_h, int color_depth);