*/
if (armodel == 1) {
- uae_u16 search_value_rel = end_addr - start_addr;
+ uae_u16 search_value_rel = addrdiff(end_addr, start_addr);
addr = find_relative_word(start_addr, end_addr, search_value_rel);
if (addr) {
}
}
} else {
- uae_u32 search_value_abs = arrom_start + end_addr - start_addr;
+ uae_u32 search_value_abs = arrom_start + addrdiff(end_addr, start_addr);
addr = find_absolute_long (start_addr, end_addr, search_value_abs);
if (addr) {
sprintf((char*)p, "%03d", y);
p += 3;
*p++ = 0x0d;
- touch_write_buf_offset = p - touch_data_w;
+ touch_write_buf_offset = addrdiff(p, touch_data_w);
cubo_flag |= 0x40000000;
}
#undef YieldProcessor
#endif
+#if 0
#ifndef YieldProcessor
#ifdef __GNUC__
INLINE void YieldProcessor(void)
}
#endif
#endif
-
+#endif
//============================================================
strack++;
}
addtocentry (&p2, &maxlen, 0xa2, 0xaa, msf, p, toc);
- int tlen = p2 - (p + 2);
+ int tlen = addrdiff(p2, p + 2);
p[0] = tlen >> 8;
p[1] = tlen >> 0;
scsi_len = tlen + 2;
// regenerate Q-subchannel
uae_u8 *s = dst + SUB_ENTRY_SIZE;
s[0] = (t->ctrl << 4) | (t->adr << 0);
- s[1] = tobcd (t - &cdu->toc[0] + 1);
- s[2] = tobcd (1);
- int msf = lsn2msf (sector);
- tolongbcd (s + 7, msf);
- msf = lsn2msf (sector - t->address - 150);
- tolongbcd (s + 3, msf);
+ s[1] = tobcd(addrdiff(t, &cdu->toc[0] + 1));
+ s[2] = tobcd(1);
+ int msf = lsn2msf(sector);
+ tolongbcd(s + 7, msf);
+ msf = lsn2msf(addrdiff(sector, t->address - 150));
+ tolongbcd(s + 3, msf);
ret = 2;
}
if (ret == 1) {
cdimage_unpack_thread = -1;
}
-static void audio_unpack (struct cdunit *cdu, struct cdtoc *t)
+static void audio_unpack(struct cdunit *cdu, struct cdtoc *t)
{
// do this even if audio is not compressed, t->handle also could be
// compressed and we want to unpack it in background too
while (cdimage_unpack_active == 1)
sleep_millis(10);
cdimage_unpack_active = 0;
- write_comm_pipe_u32 (&unpack_pipe, cdu - &cdunits[0], 0);
- write_comm_pipe_u32 (&unpack_pipe, t - &cdu->toc[0], 1);
+ write_comm_pipe_u32(&unpack_pipe, addrdiff(cdu, &cdunits[0]), 0);
+ write_comm_pipe_u32(&unpack_pipe, addrdiff(t, &cdu->toc[0]), 1);
while (cdimage_unpack_active == 0)
sleep_millis(10);
}
p += SUB_CHANNEL_SIZE;
}
}
- ret += p - data;
+ ret += addrdiff(p, data);
data = p;
sector++;
}
}
if (audio_frame_size && audio_data_remaining)
- p += l64111_get_frame(p, L64111_FIFO_BYTES - (p - l64111_fifo));
+ p += l64111_get_frame(p, L64111_FIFO_BYTES - addrdiff(p, l64111_fifo));
- while (p - l64111_fifo < L64111_FIFO_LOOKUP || ((p - l64111_fifo) & 1)) {
+ while (p - l64111_fifo < L64111_FIFO_LOOKUP || (addrdiff(p, l64111_fifo) & 1)) {
uae_u8 *op = p;
int size = 0;
}
if (audio_skip_size) {
- int size = audio_skip_size > L64111_FIFO_BYTES - (p - l64111_fifo) ? L64111_FIFO_BYTES - (p - l64111_fifo) : audio_skip_size;
+ int size = audio_skip_size > L64111_FIFO_BYTES - addrdiff(p, l64111_fifo) ? L64111_FIFO_BYTES - addrdiff(p, l64111_fifo) : audio_skip_size;
p += size;
audio_skip_size -= size;
}
if (L64111_FIFO_BYTES - (p - l64111_fifo) > 0 && audio_data_remaining) {
if (audio_frame_size) {
- p += l64111_get_frame(p, L64111_FIFO_BYTES - (p - l64111_fifo));
+ p += l64111_get_frame(p, L64111_FIFO_BYTES - addrdiff(p, l64111_fifo));
} else if (p[0] == 0xff && (p[1] & (0x80 | 0x40 | 0x20)) == (0x80 | 0x40 | 0x20)) {
if (parse_mp2_frame(p))
- p += l64111_get_frame(p, L64111_FIFO_BYTES - (p - l64111_fifo));
+ p += l64111_get_frame(p, L64111_FIFO_BYTES - addrdiff(p, l64111_fifo));
}
}
audio_data_remaining--;
}
}
- l64111_fifo_cnt = L64111_FIFO_BYTES - (p - l64111_fifo);
+ l64111_fifo_cnt = L64111_FIFO_BYTES - addrdiff(p, l64111_fifo);
if (l64111_fifo_cnt < 0)
l64111_fifo_cnt = 0;
if (l64111_fifo_cnt > 0)
if (cmd & TOSCR_SPC_HIRES_END) {
toscr_res_pixels_mask_hr = 1 >> toscr_res_pixels_shift_hr;
}
- toscr_special_skip_ptr += 1 << toscr_res_pixels_shift_hr;
+ int sh = 1 << toscr_res_pixels_shift_hr;
+ toscr_special_skip_ptr += sh;
if (*toscr_special_skip_ptr == 0) {
toscr_special_skip_ptr = NULL;
break;
while (dstmfmbuf - drv->bigmfmbuf < tracklen / 2)
*dstmfmbuf++ = 0x9254;
drv->skipoffset = 0;
- drv->tracklen = (dstmfmbuf - drv->bigmfmbuf) * 16;
+ drv->tracklen = addrdiff(dstmfmbuf, drv->bigmfmbuf) * 16;
if (disk_debug_logging > 0)
write_log (_T("pcdos read track %d\n"), tr);
}
strcpy ((char*)p, "Generic Emulated PCMCIA IDE");
p += strlen ((char*)p) + 1;
*p++= 0xff;
- *rp = p - rp - 1;
+ *rp = addrdiff(p, rp - 1);
/* CISTPL_FUNCID */
*p++ = 0x21;
sprintf ((char*)p, "Generic Emulated %dKB PCMCIA SRAM Card", size >> 10);
p += strlen ((char*)p) + 1;
*p++= 0xff;
- *rp = p - rp - 1;
+ *rp = addrdiff(p, rp - 1);
/* CISTPL_FUNCID */
*p++ = 0x21;
#include "rtgmodes.h"
#include "xwin.h"
#include "gfxfilter.h"
+#include "machdep/maccess.h"
#include <math.h>
int lbmask = (1 << blue_bits) - 1;
for (i = 65535; i >= 0; i--) {
uae_u32 r, g, b, c;
- uae_u32 j = byte_swap ? bswap_16 (i) : i;
+ uae_u32 j = byte_swap ? do_byteswap_16(i) : i;
r = (((j >> red_shift) & lrmask) << lrbits) | lowbits (j, red_shift, lrbits);
g = (((j >> green_shift) & lgmask) << lgbits) | lowbits (j, green_shift, lgbits);
b = (((j >> blue_shift) & lbmask) << lbbits) | lowbits (j, blue_shift, lbbits);
if (byte_swap) {
if (bpp <= 16) {
- rc[i] = bswap_16 (rc[i]);
- gc[i] = bswap_16 (gc[i]);
- bc[i] = bswap_16 (bc[i]);
+ rc[i] = do_byteswap_16(rc[i]);
+ gc[i] = do_byteswap_16(gc[i]);
+ bc[i] = do_byteswap_16 (bc[i]);
} else {
- rc[i] = bswap_32 (rc[i]);
- gc[i] = bswap_32 (gc[i]);
- bc[i] = bswap_32 (bc[i]);
+ rc[i] = do_byteswap_32(rc[i]);
+ gc[i] = do_byteswap_32(gc[i]);
+ bc[i] = do_byteswap_32(bc[i]);
}
}
if (bpp <= 16) {
xcolors[i] = doMask(r, rw, rs) | doMask(g, gw, gs) | doMask(b, bw, bs) | doAlpha(alpha, aw, as);
if (byte_swap) {
if (bpp <= 16) {
- xcolors[i] = bswap_16(xcolors[i]);
+ xcolors[i] = do_byteswap_16(xcolors[i]);
} else {
- xcolors[i] = bswap_32(xcolors[i]);
+ xcolors[i] = do_byteswap_32(xcolors[i]);
}
}
if (bpp <= 16) {
xcolors[i] = doMask(r, 5, 11) | doMask(g, 6, 5) | doMask(b, 5, 0);
if (byte_swap) {
if (bpp <= 16)
- xcolors[i] = bswap_16 (xcolors[i]);
+ xcolors[i] = do_byteswap_16(xcolors[i]);
else
- xcolors[i] = bswap_32 (xcolors[i]);
+ xcolors[i] = do_byteswap_32(xcolors[i]);
}
if (bpp <= 16) {
/* Fill upper 16 bits of each colour value
#include <tchar.h>
+#if CPU_64_BIT
+#define addrdiff(a, b) ((int)((a) - (b)))
+#else
+#define addrdiff(a, b) ((a) - (b))
+#endif
+
#ifndef __STDC__
#ifndef _MSC_VER
#error "Your compiler is not ANSI. Get a real one."
*/
#define CPU_EMU_SIZE 0
-/*
- * Byte-swapping functions
- */
-
-/* Try to use system bswap_16/bswap_32 functions. */
-#if defined HAVE_BSWAP_16 && defined HAVE_BSWAP_32
-# include <byteswap.h>
-# ifdef HAVE_BYTESWAP_H
-# include <byteswap.h>
-# endif
-#else
-/* Else, if using SDL, try SDL's endian functions. */
-# ifdef USE_SDL
-# include <SDL_endian.h>
-# define bswap_16(x) SDL_Swap16(x)
-# define bswap_32(x) SDL_Swap32(x)
-# else
-/* Otherwise, we'll roll our own. */
-# define bswap_16(x) (((x) >> 8) | (((x) & 0xFF) << 8))
-# define bswap_32(x) (((x) << 24) | (((x) << 8) & 0x00FF0000) | (((x) >> 8) & 0x0000FF00) | ((x) >> 24))
-# endif
-#endif
-
#ifndef __cplusplus
#define xmalloc(T, N) malloc(sizeof (T) * (N))
{
if (!input_record || !inprec_zf)
return;
- int size = inprec_p - inprec_plast;
+ int size = addrdiff(inprec_p, inprec_plast);
inprec_plast[1] = size >> 8;
inprec_plast[2] = size >> 0;
flush ();
write_log (_T("INPREC: play -> record\n"));
input_record = INPREC_RECORD_RERECORD;
input_play = 0;
- int offset = inprec_p - inprec_buffer;
+ int offset = addrdiff(inprec_p, inprec_buffer);
zfile_fseek (inprec_zf, offset, SEEK_SET);
zfile_truncate (inprec_zf, offset);
xfree (inprec_buffer);
i = inprec_pu32 ();
while (i-- > 0)
inprec_pu8 ();
- header_end = inprec_plastptr - inprec_buffer;
+ header_end = addrdiff(inprec_plastptr, inprec_buffer);
inprec_pstr (savestate_fname);
if (savestate_fname[0]) {
savestate_state = STATE_RESTORE;
}
}
inprec_p = inprec_plastptr;
- header_end2 = inprec_plastptr - inprec_buffer;
+ header_end2 = addrdiff(inprec_plastptr, inprec_buffer);
findlast ();
} else if (input_record) {
seed = uaesrand (seed);
{
int pos = -1;
if (input_play == INPREC_PLAY_RERECORD) {
- pos = inprec_p - inprec_buffer;
+ pos = addrdiff(inprec_p, inprec_buffer);
} else if (input_record) {
pos = zfile_ftell32(inprec_zf);
}
if (recordbuf == 0 || !valid_address (recordbuf, bytes))
return;
alClear ();
- alcCaptureSamples(dsahip->al_recorddev, (void*)recordbuf, dsahip->record_samples);
+ alcCaptureSamples(dsahip->al_recorddev, get_real_address(recordbuf), dsahip->record_samples);
if (alGetError () != AL_NO_ERROR)
return;
put_word (pbase + pub_RecordHookDone, 0);
bmpw = (w * (bmpdepth / 8) + 3) & ~3;
bmsize = sizeof (BITMAPINFO);
- if (bmpdepth <= 8)
- bmsize += (1 << planes) * sizeof (RGBQUAD);
+ if (bmpdepth <= 8) {
+ int psize = (1 << planes);
+ bmsize += psize * sizeof (RGBQUAD);
+ }
bmih = (BITMAPINFO*)xcalloc (uae_u8, bmsize);
bmih->bmiHeader.biSize = sizeof (bmih->bmiHeader);
bmih->bmiHeader.biWidth = w;
GetWindowText(hWnd, buf, txtlen + 1);
if (_tcscmp(buf, currhist->command)) {
SetWindowText(hWnd, currhist->command);
- txtlen = _tcslen(currhist->command);
+ txtlen = uaetcslen(currhist->command);
SendMessage(hWnd, EM_SETSEL, (WPARAM)txtlen, (LPARAM)txtlen);
SendMessage(hWnd, EM_SETSEL, -1, -1);
}
if (chars == 0)
return 0;
WriteOutput(linebreak + 1, 2);
- WriteOutput(out, _tcslen(out));
+ WriteOutput(out, uaetcslen(out));
WriteOutput(linebreak + 1, 2);
AddToHistory(out);
SetWindowText(hInput, _T(""));
static int CheckLineLimit(HWND hWnd, const TCHAR *out)
{
TCHAR *tmp, *p;
- int lines_have, lines_new = 0, lastchr, txtlen, visible;
+ int lines_new = 0, txtlen, visible;
+ LRESULT lines_have, lastchr;
tmp = (TCHAR *)out;
lines_have = SendMessage(hWnd, EM_GETLINECOUNT, 0, 0);
void WriteOutput(const TCHAR *out, int len)
{
- int txtlen, pos = 0, count, index, leave = 0;
+ int pos = 0, leave = 0;
+ LRESULT count, index, txtlen;
TCHAR *buf = 0, *p, *tmp;
if (!hOutput || !_tcscmp(out, _T(">")) || len == 0)
for(;;) {
p = _tcschr(tmp, '\n');
if (p) {
- pos = p - tmp + 1;
+ pos = addrdiff(p, tmp + 1);
if (pos > (MAX_LINEWIDTH + 1))
pos = MAX_LINEWIDTH + 1;
buf = xcalloc(TCHAR, pos + 2);
static int ulbs_pos;
static void UpdateListboxString(HWND hWnd, int pos, TCHAR *out, int mark)
{
- int count;
+ LRESULT count;
TCHAR text[MAX_LINEWIDTH + 1], *p;
COLORREF cr;
static int GetLBOutputLines(HWND hWnd)
{
- int lines = 0, clientsize, itemsize;
+ int lines = 0;
+ LRESULT itemsize, clientsize;
RECT rc;
GetClientRect(hWnd, &rc);
clientsize = rc.bottom - rc.top;
itemsize = SendMessage(hWnd, LB_GETITEMHEIGHT, 0, 0);
while (clientsize > itemsize) {
- lines ++;
+ lines++;
clientsize -= itemsize;
}
return lines;
static void ShowBreakpoints(void)
{
HWND hBrkpts;
- int i, lines_old, got;
+ int i, got;
+ LRESULT lines_old;
TCHAR outbp[MAX_LINEWIDTH + 1], outw[50];
hBrkpts = GetDlgItem(hDbgWnd, IDC_DBG_BRKPTS);
static void ShowMem(int offset)
{
uae_u32 addr;
- int i, lines_old, lines_new;
+ int i, lines_new;
+ LRESULT lines_old;
TCHAR out[MAX_LINEWIDTH + 1];
HWND hMemory;
static void ShowDasm(int direction)
{
uae_u32 addr = 0, prev;
- int i, lines_old, lines_new;
+ int i, lines_new;
+ LRESULT lines_old;
TCHAR out[MAX_LINEWIDTH + 1];
HWND hDasm;
if (!width)
return tm.tmHeight + tm.tmExternalLeading;
else if (text)
- return tm.tmMaxCharWidth * _tcslen(text);
+ return tm.tmMaxCharWidth * uaetcslen(text);
return 0;
}
case 0x16: //ctrl+v
break;
default:
- if (!debugger_active || !_tcschr(allowed, wParam))
+ if (!debugger_active || !_tcschr(allowed, (TCHAR)wParam))
return 0;
break;
}
if (!OpenClipboard(hwnd))
return;
EmptyClipboard();
- if ((count = SendMessage(hwnd, LB_GETCOUNT, 0, 0)) < 1)
+ if ((count = (int)SendMessage(hwnd, LB_GETCOUNT, 0, 0)) < 1)
return;
if (all) {
start = 0;
end = start + 1;
}
for (i = start; i < end; i++)
- size += (SendMessage(hwnd, LB_GETTEXTLEN, i, 0) + 2);
+ size += (int)(SendMessage(hwnd, LB_GETTEXTLEN, i, 0) + 2);
size++;
hdata = GlobalAlloc(GMEM_MOVEABLE, size * sizeof (TCHAR));
if (hdata) {
lptstr = (LPWSTR)GlobalLock(hdata);
lptstr[size - 1] = '\0';
for (i = start; i < end; i++) {
- int len = SendMessage(hwnd, LB_GETTEXTLEN, i, 0);
+ int len = (int)SendMessage(hwnd, LB_GETTEXTLEN, i, 0);
SendMessage(hwnd, LB_GETTEXT, i, (LPARAM)lptstr);
lptstr[len] = '\r';
lptstr[len + 1] = '\n';
ListboxEndEdit(hparent, FALSE);
return 0;
default:
- if (!_tcschr(allowed, wParam))
+ if (!_tcschr(allowed, (TCHAR)wParam))
return 0;
break;
}
else if (id == IDC_DBG_FPREG)
length = 20;
else
- length = _tcslen(txt + offset);
+ length = uaetcslen(txt + offset);
_tcsncpy(tmp, txt, offset);
tmp[offset] = '\0';
ri.left += GetTextSize(hwnd, tmp, TRUE);
height = rc.bottom - rc.top;
width = rc.right - rc.left;
bottom = rc.bottom;
- itemheight = SendMessage(hWnd, LB_GETITEMHEIGHT, 0, 0);
+ itemheight = (int)SendMessage(hWnd, LB_GETITEMHEIGHT, 0, 0);
rc.bottom = itemheight;
- count = SendMessage(hWnd, LB_GETCOUNT, 0, 0);
+ count = (int)SendMessage(hWnd, LB_GETCOUNT, 0, 0);
compdc = CreateCompatibleDC(hdc);
compbmp = CreateCompatibleBitmap(hdc, width, height);
oldbmp = (HBITMAP)SelectObject(compdc, compbmp);
dis.itemState = 0;
dis.hwndItem = hWnd;
dis.hDC = compdc;
- top = SendMessage(hWnd, LB_GETTOPINDEX, 0, 0);
+ top = (int)SendMessage(hWnd, LB_GETTOPINDEX, 0, 0);
for (i = top; i < count && rc.top < height; i++) {
dis.itemID = i;
dis.rcItem = rc;
SetBkMode(hdc, TRANSPARENT);
if (wParam == IDC_DBG_STATUS) {
SetTextColor(hdc, GetSysColor(pstatuscolor[pdis->itemID]));
- DrawText(hdc, pname[pdis->itemID], _tcslen(pname[pdis->itemID]), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
+ DrawText(hdc, pname[pdis->itemID], uaetcslen(pname[pdis->itemID]), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
return TRUE;
}
else {
FillRect(hdc, &rc, GetSysColorBrush(COLOR_WINDOW));
SetBkColor(hdc, GetSysColor(COLOR_WINDOW));
}
- SetTextColor(hdc, pdis->itemData);
+ SetTextColor(hdc, (COLORREF)pdis->itemData);
if (wParam == IDC_DBG_DASM || wParam == IDC_DBG_DASM2) {
TCHAR addrstr[11] = { '0', 'x', '\0'}, *btemp;
int i, j, size = rc.bottom - rc.top;
if (btemp)
_tcsncpy(addrstr + 2, btemp + 4, 8);
else {
- int pos = 34 + _tcslen(ucbranch[i]) + 3;
+ int pos = 34 + uaetcslen(ucbranch[i]) + 3;
if (text[pos] == '$') //absolute addressing
_tcsncpy(addrstr + 2, text + pos + 1, 8);
else if (text[pos] == '(' && _istdigit(text[pos + 2])) { //address register indirect
SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
}
- TextOut(hdc, rc.left, rc.top, text, _tcslen(text));
+ TextOut(hdc, rc.left, rc.top, text, uaetcslen(text));
i = 0;
while (markinstr[i]) {
- if (!_tcsncmp(text + 34, markinstr[i], _tcslen(markinstr[i]))) {
+ if (!_tcsncmp(text + 34, markinstr[i], uaetcslen(markinstr[i]))) {
MoveToEx(hdc, rc.left, rc.bottom - 1, NULL);
LineTo(hdc, rc.right, rc.bottom - 1);
break;
DrawFocusRect(hdc, &rc);
}
else if (wParam == IDC_DBG_MEM || wParam == IDC_DBG_MEM2) {
- TextOut(hdc, rc.left, rc.top, text, _tcslen(text));
+ TextOut(hdc, rc.left, rc.top, text, uaetcslen(text));
if ((pdis->itemState) & (ODS_SELECTED))
DrawFocusRect(hdc, &rc);
}
else
- TextOut(hdc, rc.left, rc.top, text, _tcslen(text));
+ TextOut(hdc, rc.left, rc.top, text, uaetcslen(text));
return TRUE;
}
break;
console_out(internalcmd);
console_out(_T("\n"));
_tcsncpy(out, internalcmd, maxlen);
- return _tcslen(out);
+ return uaetcslen(out);
}
else
return GetInput(out, maxlen);
uae_u16 *tmplbuf = NULL;
if (indirect) {
- tmplbuf = xcalloc(uae_u16, 1 << pattern.Size);
+ int size = 1 << pattern.Size;
+ tmplbuf = xcalloc(uae_u16, size);
trap_get_words(ctx, tmplbuf, pattern.AMemory, 1 << pattern.Size);
}
-#include <emmintrin.h>
+#include <intrin.h>
#include <math.h>
#include <stddef.h>
znnew = zvolume_addfile_abs (zv, &zai);
if (znnew) {
znnew->offset = block;
- znnew->offset2 = p - adf->block;
+ znnew->offset2 = addrdiff(p, adf->block);
}
}
xfree (zai.comment);