static void viewreg_lock_alloc(NP2VIEW_T *view, void *src) { if (view->lock) { if (view->buf1.type != ALLOCTYPE_REG) { if (viewcmn_alloc(&view->buf1, view->memsize)) { view->lock = FALSE; viewmenu_lock(view); } else { view->buf1.type = ALLOCTYPE_REG; CopyMemory(view->buf1.ptr, src, view->memsize); } viewcmn_putcaption(view); } } }
static void viewasm_paint(NP2VIEW_T *view, RECT *rc, HDC hdc) { LONG x, y, i; UINT32 seg4; UINT16 off, prevoff; UINT32 pos; UINT8 *p; UINT8 buf[16]; TCHAR str[16]; _UNASM una; int step; #if defined(UNICODE) TCHAR cnv[64]; #endif COLORREF bkcol; if (view->lock) { if ((view->buf1.type != ALLOCTYPE_SEG) || (view->buf1.arg != view->seg)) { if (viewcmn_alloc(&view->buf1, view->memsize)) { view->lock = FALSE; viewmenu_lock(view); } else { view->buf1.type = ALLOCTYPE_SEG; view->buf1.arg = view->seg; viewmem_read(&view->dmem, seg_to_real(view->buf1.arg), (BYTE *)view->buf1.ptr, view->memsize); view->buf2.type = ALLOCTYPE_NONE; } viewcmn_putcaption(view); } } seg4 = seg_to_real(view->seg); pos = view->pos; if ((view->buf2.type != ALLOCTYPE_ASM) || (view->buf2.arg != (seg4 + view->off))) { if (viewcmn_alloc(&view->buf2, view->maxline*2)) { pos = 0; } else { DWORD i; UINT16 *r; r = (UINT16 *)view->buf2.ptr; view->buf2.type = ALLOCTYPE_ASM; view->buf2.arg = seg4 + view->off; off = view->off; for (i=0; i<(view->maxline - 1); i++) { *r++ = off; step = viewasm_unasm_next(NULL, buf, view, off); off += (UINT16)step; } *r = off; } } prevoff = off = viewasm_line_to_off(view, view->pos); for (y=0; y<rc->bottom; y+=viewcfg.font_height) { x = 0; // Emphasize wrapping if(prevoff > off) { viewpaint_line_fill(rc, hdc, y, 2, viewcfg.color_hilite); } bkcol = viewpaint_line_set_colors(view, rc, hdc, y, off, CPU_CS, CPU_IP); viewpaint_print_addr(hdc, x, y, view->seg, off, TRUE); SetBkColor(hdc, bkcol); step = viewasm_unasm_next(&una, buf, view, off); p = buf; if (!step) { break; } x += 11 * np2viewfontwidth; for(i = 0; i < step; i++) { wsprintf(str + (i*2), _T("%02x"), *p); p++; } TextOut(hdc, x, y, str, i * 2); x += 15 * np2viewfontwidth; #if defined(UNICODE) TextOut(hdc, x, y, cnv, MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, una.mnemonic, -1, cnv, NELEMENTS(cnv))); #else TextOut(hdc,x, y, una.mnemonic, lstrlen(una.mnemonic)); #endif x += 7 * np2viewfontwidth; if (una.operand[0]) { #if defined(UNICODE) TextOut(hdc, x, y, cnv, MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, una.operand, -1, cnv, NELEMENTS(cnv))); #else TextOut(hdc, x, y, una.operand, lstrlen(una.operand)); #endif } prevoff = off; off += (UINT16)step; } }
static void viewsnd_paint(NP2VIEW_T *view, RECT *rc, HDC hdc) { int x; LONG y; UINT pos; const UINT8 *p; TCHAR str[16]; HFONT hfont; UINT reg; UINT16 mask; hfont = CreateFont(16, 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH, np2viewfont); SetTextColor(hdc, 0xffffff); SetBkColor(hdc, 0x400000); hfont = (HFONT)SelectObject(hdc, hfont); if (view->lock) { if (view->buf1.type != ALLOCTYPE_SND) { if (viewcmn_alloc(&view->buf1, 0x400)) { view->lock = FALSE; viewmenu_lock(view); } else { view->buf1.type = ALLOCTYPE_SND; CopyMemory(view->buf1.ptr, opn.reg, 0x400); CopyMemory(view->buf1.ptr, &psg1.reg, 0x10); CopyMemory(((UINT8 *)view->buf1.ptr) + 0x200, &psg2.reg, 0x10); } viewcmn_putcaption(view); } } pos = view->pos; for (y=0; (y<rc->bottom) && (pos<NELEMENTS(fmsndtbl)); y+=16, pos++) { if (fmsndtbl[pos].str) { TextOut(hdc, 0, y, fmsndtbl[pos].str, lstrlen(fmsndtbl[pos].str)); } else { reg = fmsndtbl[pos].reg; mask = fmsndtbl[pos].mask; wsprintf(str, _T("%04x"), reg & 0x1ff); TextOut(hdc, 0, y, str, 4); if (view->lock) { p = (UINT8 *)view->buf1.ptr; p += reg; } else if (reg & 0x1ff) { p = opn.reg + reg; } else if (reg & 0x200) { p = (UINT8 *)&psg2.reg; } else { p = (UINT8 *)&psg1.reg; } for (x=0; x<16; x++) { if (mask & 1) { str[0] = viewcmn_hex[*p >> 4]; str[1] = viewcmn_hex[*p & 15]; str[2] = 0; TextOut(hdc, (6 + x*3) * 8, y, str, 2); } p++; mask >>= 1; } } }