Author Topic: MasmBasic  (Read 153270 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7737
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #30 on: January 09, 2013, 08:46:14 AM »
Dave is correct, they are defined in Windows.inc

How does your source start? There should be no problem if your first line is
include \masm32\MasmBasic\MasmBasic.inc

On top of MasmBasic.inc you find this:
IFNDEF _wininc_
   include   \masm32\include\masm32rt.inc
   .686   ; JWasm needs this
   .xmm
ENDIF


In other words, all standard includes are in anyway.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7737
  • Assembler is fun ;-)
    • MasmBasic
MasmBasic - major update
« Reply #31 on: March 02, 2013, 10:34:04 AM »
With 145 downloads, the Jan 2 version got a bit stale, so I guess it's time for an update.

Many improvements "under the hood", but also some visible goodies; inter alia, all arrays (strings, byte/word/dword, REAL4/8/10, structures) can now be dynamically defined, e.g.

        Dim My$()
        Dim NormalDist() As DWORD
        Dim Sinus() As REAL8

Note though, that values can be assigned only incrementally, e.g.

        Dim My$()
        Let My$(99)="Hello"        ; illegal, will throw an error
        xor ecx, ecx
        .Repeat
                Let My$(ecx)=Str$("#%i", ecx)
                inc ecx
        .Until ecx>9999

The deb macro has learned to display flags (without changing them, of course):

        deb 4, "End of loop:", ecx, flags, FLAGS

flags displays carry, zero, sign and overflow, FLAGS the whole set:

End of loop:
ecx             10000
flags:          czso
FLAGS:          cpAzstIdo


c means carry clear, C carry set, etc.

Last but not least, attached a minimally modified \Masm32\examples\exampl01\generic\generic.asm:
1. Includes were replaced by the usual one-liner: include \masm32\MasmBasic\MasmBasic.inc
2. These few lines were added below "end menu commands":

    ;====== end menu commands ======

    .elseif uMsg == WM_CREATE
        ToolTips start        ; we'd like to see the country names
        ToolTips end

        Dim NormalDist() As DWORD        ; read the data of a normal distribution from file
        ArrayRead NormalDist(), "NormalDist.dat"

        ArrayLoadMap 0, "Europe"        ; load a map

        Dim Sinus() As REAL8        ; define an array for a sinus curve
        xor ecx, ecx
        push 180
        fild stack        ; stack is an equate for dword ptr [esp]
        push ecx
        fldpi
        fdivr
        fstp REAL4 PTR stack[4]
        .Repeat
                mov stack, ecx
                fild stack
                fmul REAL4 PTR stack[4]
                fsin
                fstp Sinus(ecx)
                inc ecx
        .Until ecx>500
        pop ecx
        pop eax

    .elseif uMsg == WM_MOUSEMOVE
                ArrayMapRegion(lParam, 0, hWnd)

    .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        ; plot map 0 as loaded above, with grey border and 2px lines
        ArrayPlot Sinus()        ; plot the sinus curve defined above
        ArrayPlot NormalDist()
        ; ------ here you could add additional features, e.g. a legend ------
        ArrayPlot exit, "Europe"        ; finish with a title

    .elseif uMsg == WM_CLOSE


The output? Check yourself :biggrin:

P.S.: With more recent MasmBasic versions, replace the start: label with Init, otherwise it will crash.
« Last Edit: September 19, 2017, 06:18:37 PM by jj2007 »

dedndave

  • Member
  • *****
  • Posts: 8749
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #32 on: March 02, 2013, 10:41:08 AM »
so - what are we looking at, Jochen ???
is it, in any way, related to the pr0n ban in Iceland ?   :redface:
it seems not to have affected pr0n in Western Europe   :P

btw - when i "install" MasmBasic, where are the read-me's that outline how to do that ?

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7737
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #33 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: 1471
  • The base type of a type is the type itself
    • SmplMath macros
Re: MasmBasic - a fast and easy-to-use library
« Reply #34 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: 7737
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #35 on: March 02, 2013, 11:14:45 AM »
BTW: what about double buffering?

What do you mean??

qWord

  • Member
  • *****
  • Posts: 1471
  • The base type of a type is the type itself
    • SmplMath macros
Re: MasmBasic - a fast and easy-to-use library
« Reply #36 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: 7737
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #37 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: 1471
  • The base type of a type is the type itself
    • SmplMath macros
Re: MasmBasic - a fast and easy-to-use library
« Reply #38 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: 7737
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #39 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: 1471
  • The base type of a type is the type itself
    • SmplMath macros
Re: MasmBasic - a fast and easy-to-use library
« Reply #40 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: 8749
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic - a fast and easy-to-use library
« Reply #41 on: March 02, 2013, 11:41:19 AM »
i didn't think CS_BYTEALIGNWINDOW meant much on modern displays

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7737
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic - a fast and easy-to-use library
« Reply #42 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: 3517
  • Forgive your enemies, but never forget their names
Re: MasmBasic - a fast and easy-to-use library
« Reply #43 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
Get your facts first, and then you can distort them.

jj2007

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

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