--- np2/win9x/debuguty/viewasm.cpp 2003/10/16 17:59:10 1.1 +++ np2/win9x/debuguty/viewasm.cpp 2005/03/20 08:58:19 1.9 @@ -1,16 +1,16 @@ #include "compiler.h" #include "resource.h" #include "np2.h" -#include "i286.h" #include "viewer.h" #include "viewcmn.h" #include "viewmenu.h" #include "viewmem.h" #include "viewasm.h" #include "unasm.h" +#include "cpucore.h" -static void set_viewseg(HWND hwnd, NP2VIEW_T *view, WORD seg) { +static void set_viewseg(HWND hwnd, NP2VIEW_T *view, UINT16 seg) { if (view->seg != seg) { view->seg = seg; @@ -18,24 +18,26 @@ static void set_viewseg(HWND hwnd, NP2VI } } - static void viewasm_paint(NP2VIEW_T *view, RECT *rc, HDC hdc) { - LONG y; - DWORD seg4; - WORD off; - DWORD pos; - BYTE *p; - BYTE buf[16]; - char str[16]; - HFONT hfont; - PREFIX_T fix; - UNASM_T una; - int step; + LONG y; + UINT32 seg4; + UINT16 off; + UINT32 pos; + UINT8 *p; + UINT8 buf[16]; + TCHAR str[16]; + HFONT hfont; + BOOL opsize; + _UNASM una; + int step; +#if defined(UNICODE) + TCHAR cnv[64]; +#endif hfont = CreateFont(16, 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY, FIXED_PITCH, "£Í£Ó¥´¥·¥Ã¥¯"); + DEFAULT_QUALITY, FIXED_PITCH, np2viewfont); SetTextColor(hdc, 0xffffff); SetBkColor(hdc, 0x400000); hfont = (HFONT)SelectObject(hdc, hfont); @@ -68,12 +70,11 @@ static void viewasm_paint(NP2VIEW_T *vie } else { int i; - WORD *r; - r = (WORD *)view->buf2.ptr; + UINT16 *r; + r = (UINT16 *)view->buf2.ptr; view->buf2.type = ALLOCTYPE_ASM; view->buf2.arg = seg4 + view->off; off = view->off; - unasm_reset(&fix); for (i=0; i<255; i++) { off &= 0xffff; *r++ = off; @@ -81,7 +82,7 @@ static void viewasm_paint(NP2VIEW_T *vie p = (BYTE *)view->buf1.ptr; p += off; if (off > 0xfff0) { - DWORD pos = 0x10000 - off; + UINT32 pos = 0x10000 - off; CopyMemory(buf, p, pos); CopyMemory(buf + pos, view->buf1.ptr, 16 - pos); p = buf; @@ -91,8 +92,8 @@ static void viewasm_paint(NP2VIEW_T *vie p = buf; viewmem_read(&(view->dmem), seg4 + off, buf, 16); } - step = unasm(off, p, &fix, NULL); - off += (WORD)step; + step = unasm(NULL, p, 16, FALSE, off); + off += (UINT16)step; } *r = off; } @@ -100,22 +101,21 @@ static void viewasm_paint(NP2VIEW_T *vie } if ((pos) && (pos < 256)) { - off = *(((WORD *)view->buf2.ptr) + pos); + off = *(((UINT16 *)view->buf2.ptr) + pos); } else { off = view->off; } - unasm_reset(&fix); for (y=0; ybottom; y+=16) { - wsprintf(str, "%04x:%04x", view->seg, off); + wsprintf(str, _T("%04x:%04x"), view->seg, off); TextOut(hdc, 0, y, str, 9); off &= 0xffff; if (view->lock) { p = (BYTE *)view->buf1.ptr; p += off; if (off > 0xfff0) { - DWORD pos = 0x10000 - off; + UINT32 pos = 0x10000 - off; CopyMemory(buf, p, pos); CopyMemory(buf + pos, view->buf1.ptr, 16 - pos); p = buf; @@ -125,15 +125,26 @@ static void viewasm_paint(NP2VIEW_T *vie p = buf; viewmem_read(&(view->dmem), seg4 + off, buf, 16); } - step = unasm(off, p, &fix, &una); + step = unasm(&una, p, 16, FALSE, off); if (!step) { break; } - TextOut(hdc, 11 * 8, y, una.mnemonic, strlen(una.mnemonic)); +#if defined(UNICODE) + TextOut(hdc, 11 * 8, y, cnv, MultiByteToWideChar(CP_ACP, + MB_PRECOMPOSED, una.mnemonic, -1, cnv, NELEMENTS(cnv))); +#else + TextOut(hdc, 11 * 8, y, una.mnemonic, lstrlen(una.mnemonic)); +#endif if (una.operand[0]) { - TextOut(hdc, (11 + 7) * 8, y, una.operand, strlen(una.operand)); +#if defined(UNICODE) + TextOut(hdc, (11 + 7) * 8, y, cnv, MultiByteToWideChar(CP_ACP, + MB_PRECOMPOSED, una.operand, -1, cnv, NELEMENTS(cnv))); +#else + TextOut(hdc, (11 + 7) * 8, y, + una.operand, lstrlen(una.operand)); +#endif } - off += (WORD)step; + off += (UINT16)step; } DeleteObject(SelectObject(hdc, hfont)); @@ -147,19 +158,19 @@ LRESULT CALLBACK viewasm_proc(NP2VIEW_T case WM_COMMAND: switch(LOWORD(wp)) { case IDM_SEGCS: - set_viewseg(hwnd, view, I286_CS); + set_viewseg(hwnd, view, CPU_CS); break; case IDM_SEGDS: - set_viewseg(hwnd, view, I286_DS); + set_viewseg(hwnd, view, CPU_DS); break; case IDM_SEGES: - set_viewseg(hwnd, view, I286_ES); + set_viewseg(hwnd, view, CPU_ES); break; case IDM_SEGSS: - set_viewseg(hwnd, view, I286_SS); + set_viewseg(hwnd, view, CPU_SS); break; case IDM_SEGTEXT: @@ -190,17 +201,17 @@ void viewasm_init(NP2VIEW_T *dst, NP2VIE switch(src->type) { case VIEWMODE_SEG: dst->seg = dst->seg; - dst->off = (WORD)(dst->pos << 4); + dst->off = (UINT16)(dst->pos << 4); break; case VIEWMODE_1MB: if (dst->pos < 0x10000) { - dst->seg = (WORD)dst->pos; + dst->seg = (UINT16)dst->pos; dst->off = 0; } else { dst->seg = 0xffff; - dst->off = (WORD)((dst->pos - 0xffff) << 4); + dst->off = (UINT16)((dst->pos - 0xffff) << 4); } break; @@ -215,11 +226,12 @@ void viewasm_init(NP2VIEW_T *dst, NP2VIE } } if (!src) { - dst->seg = I286_CS; - dst->off = I286_IP; + dst->seg = CPU_CS; + dst->off = CPU_IP; } dst->type = VIEWMODE_ASM; dst->maxline = 256; dst->mul = 1; dst->pos = 0; } +