News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Scrolling issues

Started by NoCforMe, October 13, 2011, 06:15:11 PM

Previous topic - Next topic

dedndave

i usually use this little ditty to convert 4 bits to ASCII hex...
        and     al,0Fh
        cmp     al,0Ah
        sbb     al,69h
        das                              ;0-9 > '0'-'9', 10-15 > 'A'-'F'


the scrolling is MUCH better   :U
and no bang !

dedndave

here's the one i used to use
i found this in the original IBM PC BIOS code   :bg
        add     al,90h
        daa
        adc     al,40h
        daa


but, Larry Hammick showed us a better way...
http://www.masm32.com/board/index.php?topic=12964.0

ToutEnMasm


a simple way is to use an array
Quote
ASCII db "0123456789ABCDEF",0
lea ecx,ASCII
mov edx,0    ;digit to convert
mov al,byte ptr [ecx+edx]

dedndave

Yves is right (although, you don't need to terminate the string with a null)
actually, it only takes 512 bytes to make the full hex byte string look-up-table
that is probably going to be the fastest method of converting bytes to hex without using SSE instructions
you can allocate space in uninitialized data and fill it during program init

ToutEnMasm

Quote
although, you don't need to terminate the string with a null
What is  suspicious chain ?.It's a chain without zero.Also I put one even if it is not needed.

NoCforMe

Quote from: dedndave on October 14, 2011, 12:34:13 PM
i usually use this little ditty to convert 4 bits to ASCII hex...
        and     al,0Fh
        cmp     al,0Ah
        sbb     al,69h
        das                              ;0-9 > '0'-'9', 10-15 > 'A'-'F'

But I'm going the other way (ASCII hex--> binary), and it's even simpler than that:



cadH18: SUB AL, 7 ;Convert A-F--> '10-15'
cadH20: SUB AL, '0'
STOSB
...
MOV AL, BYTE PTR [EDI - 1] ;Next char. to left
SHL EAX, CL ;Shift nybble into position
OR EBX, EAX



keeping in mind that I've previously massaged the chars to make sure they're in the range '0'-'9':'A'-'F' (lowercase 'a'-'f' being converted to uppercase).

Quotethe scrolling is MUCH better   :U
and no bang !

Thanks. Did you try the goto address field? Wondering if other people like the way it works.

dedndave

ohhh - i wondered what you were talking about
i didn't see it down there


NoCforMe

Oh, crap, the window isn't big enough!

Could you reassemble it and increase $mainWinHeight (near top of file, currently set at, what, 400-something?). The controls are all covered up!

Shows a difference between my OS (W2K) and yours. I made it too tight; need more padding space.

dedndave

no - it's because i switched to 120 DPI video setting
you can use GetDeviceCaps(LOGPIXELSY) and SystemParametersInfo(SPI_NONCLIENTMETRICS)
to determine what the user settings are and calculate the required height

i think that is the "message" font from NONCLIENTMETRICS
then, use LOGPIXELSY to convert font size to pixels

another way to go...
set your video to Large Fonts and 120 DPI
then measure and hard-code a value that works   :P
not as pretty
but, there are times when it's hard to make measurements, too
i hard-code a value like that for the minimum window width to keep the menu from wrapping
(after spending 2 days trying to find the "right" way)

NoCforMe

OK, that DPI display setting stuff gives me a headache at the moment; will tackle it later.

If you could be so kind, there's another small problem with this app. If you minimize it, then restore it, all the controls (radio buttons, edit control and checkbox) disappear. In fact, the rectangles where they should be are transparent!

I tried to take care of this by capturing the WM_SHOWWINDOW message (where wParam=TRUE, meaning the window has been shown after being minimized) and then using InvalidateRect() and UpdateWindow() to restore the controls, but no joy. ?????

dedndave

yah - you have another little problem too
until i open a file, the CPU usage is ~50%
use the task manager to see it - i always turn on the task manager CPU and CPU Usage columns

NoCforMe

Oh, yeah, I always have the Task Manager open (minimized, ready for use). Have had to use it many times to kill an endlessly-looping application. Will check out the CPU usage issue.

Uh-oh, actually worse than you reported: 75-90%. Ugh.

What's the most likely culprit? Doesn't seem like it's doing much, just sitting there handling a few messages.

dedndave

that is probably something simple   :P
like painting an empty buffer or similar

you have some code for WM_SHOWWINDOW
you could just use WM_SIZE, instead   :P
you get WM_SIZE whenever you first show a window - and when minimize/maximize/restore

dedndave

ok - another way to solve this issue is to specify a font and size for the stuff under the text window
i.e., make em use Tahoma 10 or something
still - 10 pt on 120 DPI takes more pixels than 10 pt on 96 DPI
also - you have a lot of space ABOVE the window   :bg


dedndave

this change seems to have fixed the disappearing controls thing, as long as a file has been opened...
CMP EAX, WM_SIZE    ;was WM_SHOWWINDOW
JE doshow