From: Toni Wilen Date: Sun, 1 Jan 2023 14:00:19 +0000 (+0200) Subject: addrdiff X-Git-Tag: 41010~43 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=87afbcdbc19024a7b9bcff1346e1bbebb7307c87;p=francis%2Fwinuae.git addrdiff --- diff --git a/custom.cpp b/custom.cpp index ee5a46c3..0293e05c 100644 --- a/custom.cpp +++ b/custom.cpp @@ -10318,7 +10318,7 @@ static uae_u16 sprite_fetch(struct sprite *s, uaecptr pt, int hpos, int slot, in } #endif #ifdef DEBUGGER - int num = (int)(s - &spr[0]); + int num = addrdiff(s, &spr[0]); if (debug_dma) { record_dma_read(num * 8 + 0x140 + mode * 4 + slot * 2, pt, hpos, vpos, DMARECORD_SPRITE, num); } diff --git a/od-win32/blkdev_win32_spti.cpp b/od-win32/blkdev_win32_spti.cpp index b89c5b1a..03e0be75 100644 --- a/od-win32/blkdev_win32_spti.cpp +++ b/od-win32/blkdev_win32_spti.cpp @@ -77,7 +77,7 @@ static int getunitnum (struct dev_info_spti *di) { if (!di) return -1; - int idx = (int)(di - &dev_info[0]); + int idx = addrdiff(di, &dev_info[0]); for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) { if (unittable[i] - 1 == idx) return i; diff --git a/od-win32/clipboard_win32.cpp b/od-win32/clipboard_win32.cpp index 4cfc29d4..2ccaec90 100644 --- a/od-win32/clipboard_win32.cpp +++ b/od-win32/clipboard_win32.cpp @@ -415,7 +415,7 @@ static void to_iff_ilbm(TrapContext *ctx, HBITMAP hbmp) } } - tsize = (int)(p - iff - 8); + tsize = addrdiff(p, iff) - 8; p = iff + 4; p[0] = tsize >> 24; p[1] = tsize >> 16; diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index 4a04b8da..5b0a4af3 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -1949,7 +1949,7 @@ static int createmasktexture (struct d3dstruct *d3d, const TCHAR *filename, stru D3DXIMAGE_INFO dinfo; TCHAR tmp[MAX_DPATH]; int maskwidth, maskheight; - int idx = (int)(sd - &d3d->shaders[0]); + int idx = addrdiff(sd, &d3d->shaders[0]); if (filename[0] == 0) return 0; diff --git a/od-win32/direct3d11.cpp b/od-win32/direct3d11.cpp index 8c50226d..4ede0102 100644 --- a/od-win32/direct3d11.cpp +++ b/od-win32/direct3d11.cpp @@ -2134,7 +2134,7 @@ static bool allocshadertex(struct d3d11struct *d3d, struct shadertex *t, int w, static bool allocextratextures(struct d3d11struct *d3d, struct shaderdata11 *s, int w, int h) { - int scnt = (int)(s - &d3d->shaders[0]); + int scnt = addrdiff(s, &d3d->shaders[0]); if (!allocshadertex(d3d, &s->lpWorkTexture1, w, h, scnt)) return false; if (!allocshadertex(d3d, &s->lpWorkTexture2, w, h, scnt)) diff --git a/od-win32/screenshot.cpp b/od-win32/screenshot.cpp index da218f44..aefe9d36 100644 --- a/od-win32/screenshot.cpp +++ b/od-win32/screenshot.cpp @@ -983,7 +983,7 @@ static int saveiff(FILE *fp, bool alpha) } } - int tsize = (int)(p - iff - 8); + int tsize = addrdiff(p, iff) - 8; p = iff + 4; p[0] = tsize >> 24; p[1] = tsize >> 16;