Author Topic: MasmBasic  (Read 439438 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #30 on: March 02, 2013, 10:45:17 AM »
btw - when i "install" MasmBasic, where are the read-me's that outline how to do that ?

After unzipping with "use folder names" with the root of your Masm32 as start directory, there is one in
\Masm32\RichMasm\ReadMeMasmBasic.txt

\Masm32\MasmBasic\MbGuide.rtf is more interesting, though ;-)

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: MasmBasic - a fast and easy-to-use library
« Reply #31 on: March 02, 2013, 11:00:57 AM »
\Masm32\MasmBasic\MbGuide.rtf is more interesting, though ;-)
yea, if one has no problem with developing eye cancer  ;-D

BTW: what about double buffering?
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #32 on: March 02, 2013, 11:14:45 AM »
BTW: what about double buffering?

What do you mean??

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: MasmBasic - a fast and easy-to-use library
« Reply #33 on: March 02, 2013, 11:20:21 AM »
BTW: what about double buffering?

What do you mean??
Sry, I was talking about the example with ArrayPlot - it flickers on resizing.
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #34 on: March 02, 2013, 11:25:12 AM »
Yes, that's true. I wanted to keep the example simple. To reduce the flicker, do the following:

- line 135:
        mov wc.style, CS_BYTEALIGNWINDOW

- in line 238, add:

    .elseif uMsg == WM_SIZE
       invoke InvalidateRect, hWnd, 0, 0
    .elseif uMsg == WM_CREATE

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: MasmBasic - a fast and easy-to-use library
« Reply #35 on: March 02, 2013, 11:29:32 AM »
It's much simpler: set the background brush to zero
Code: [Select]
mov wc.hbrBackground,  0
 :biggrin:
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #36 on: March 02, 2013, 11:33:01 AM »
Good trick, but you still need the InvalidateRect in the WM_SIZE handler. Even better but CPU-hungry: InvalidateRect in the WM_SIZING handler.

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: MasmBasic - a fast and easy-to-use library
« Reply #37 on: March 02, 2013, 11:37:44 AM »
Good trick, but you still need the InvalidateRect in the WM_SIZE handler. Even better but CPU-hungry: InvalidateRect in the WM_SIZING handler.
your original example does not need that, because the window class has the CS_HREDRAW and CS_VREDRAW style.
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #38 on: March 02, 2013, 11:41:19 AM »
i didn't think CS_BYTEALIGNWINDOW meant much on modern displays

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #39 on: March 02, 2013, 11:48:14 AM »
your original example does not need InvalidateRect, because the window class has the CS_HREDRAW and CS_VREDRAW style.

That's right - CS_HREDRAW or CS_VREDRAW plus a zero background brush seems to give the best results. Thanks, the new version is uploaded above :t

The documentation is still incomplete; for example, you can add a margin and a legend:

    .elseif uMsg == WM_PAINT
        ArrayPlot hWnd, RgbCol(200, 255, 240)                ; init with window (or control) handle and background colour
        ArrayPlot 0, RgbCol(200, 200, 200), lines:2, 00001900h        ; plot map 0 as loaded above, with grey border and 2px lines, margin right=19h
        ArrayPlot Sinus()        ; plot the sinus curve defined above
        ArrayPlot NormalDist()
        ; ------ here you could add additional features, e.g. a legend ------
        invoke SetBkMode, APs.apMemDC, TRANSPARENT
        invoke SelectObject, APs.apMemDC, LegendFont
        invoke TextOut, APs.apMemDC, 380, 100, Chr$("Legend"), 6
        ArrayPlot exit, "Europe"        ; finish with a title

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: MasmBasic - a fast and easy-to-use library
« Reply #40 on: March 04, 2013, 10:16:42 AM »
Hi Jochen,

Thanks, the new version is uploaded above :t

in which post? I'd like to test it.

Gunther
You have to know the facts before you can distort them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #41 on: March 04, 2013, 10:21:26 AM »
Hi Gunther,

It's always attached to the first post in this thread. Feedback welcome ;)

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: MasmBasic - a fast and easy-to-use library
« Reply #42 on: March 04, 2013, 06:45:06 PM »
Thank you, Jochen.  :t

Gunther
You have to know the facts before you can distort them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Bug warning
« Reply #43 on: March 06, 2013, 10:32:46 AM »
Version 6 March uploaded here. It fixes a nasty little bug in the ArrayRead macro (the wrong file was closed). Usage:

        Dim rc4() As REAL4   ; can be REAL4, REAL8, DWORD, ... structures
        ArrayRead rc4(), "MyReal4.dat"

To compensate for this bug :redface:, I added ArrayMean:

                        ArrayMean MyR8()                            ; all array elements are added up, then the sum is divided by the count
                        Print Str$("Resall=\t%f\n", ST(0))      ; the resulting mean is left on the FPU
                        fstp st
                        ArrayMean MyR8(XY)                        ; same as before but we assume the array consists of x,y pairs
                        Print Str$("ResY=\t%f\n", ST(0))       ; the mean of the Y elements is returned in ST(0)
                        fstp st
                        Print Str$("ResX=\t%f\n", ST(0))       ; the mean of the X elements is returned in ST(1)
                        fstp st
Rem        returns mean(s) on the FPU and total number of elements in eax

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #44 on: March 24, 2013, 11:35:40 AM »
Version 24 March uploaded (download: top of thread)

New functions are ArraySet, SetPoly3 and GetPoly3, see example below and \Masm32\MasmBasic\MbGuide.rtf

As shown in the repeat loop below, AllPts(ecx+1) is now valid syntax (same for string arrays)

include \masm32\MasmBasic\MasmBasic.inc        ; download
        Init
        Dim My3Pts(5) As DWORD                ; create an array with 3 XY pairs, i.e. 6 elements (0 .. 5)
        ArraySet My3Pts() = 1, 100, 2, 300, 4, 150        ; assign XY values (ArraySet can be handy but any other array works, too)
        SetPoly3 My3Pts()                ; create coefficients for a 3-point polynomial, i.e. Y=a0+a1*X+a2*X2
        Dim AllPts(11) As REAL4                ; create a destination array with 12 elements
        Print "N", Tb$, "X", Tb$, "Y", Tb$, "Y(ecx)"        ; the last column uses the "direct" variant GetPoly3(X)
        GetPoly3(AllPts())                ; fill starting from X=0, create coefficients for Y=a0+a1*X+a2*X2
        add eax, eax
        push eax
        xor ecx, ecx
        .Repeat                ; print N, X, Y=f(x), Y=f(2*X)
                Print Str$("\n%i\t", ecx/2), Str$("%2f\t", AllPts(ecx)), Str$("%3f\t", AllPts(ecx+1)), Str$("%3f", GetPoly3(ecx))
                fstp st                ; pop the return value from the FPU
                add ecx, 2
        .Until ecx>=stack
        pop eax
        Inkey CrLf$, "ok"
        Exit
end start

Output:
N       X       Y       Y(ecx)
0       0.0     -283.0  -283.0
1       1.0     100.0   300.0
2       2.0     300.0   150.0
3       3.0     317.0   -733.0
4       4.0     150.0   -2.35e+03
5       5.0     -200.0  -4.70e+03