Author Topic: MasmBasic  (Read 19578 times)

Mike Lobanovsky

  • Guest
Re: MasmBasic
« Reply #15 on: November 09, 2016, 02:35:02 AM »
Jochen,

I'm greatful for the invitation and also for choosing my avatar for your experimentation (I wish I could do the same in return on the FBSL forum) but I won't run your exe pack on my machines for the reasons I've stated earlier regarding the validity of executable file names and the uncertainty of the outcome of such experimentation from the file system integrity perspective.

I am sorry but that's the point I'm going to stand by, paranoia or schizophrenia, whatever. :)

jj2007

  • Guest
Re: MasmBasic
« Reply #16 on: November 09, 2016, 10:17:58 AM »
validity of executable file names and the uncertainty of the outcome of such experimentation from the file system integrity perspective.

Mike,

These are absolutely valid Unicode file names. Microsoft takes pride in that, and if a Billion Chinese users had the same fear as you, it would be bad for their business.

At least on my Italian OS, none of these exes had any problems *)

You might check your views on locales. Afaik Windows Explorer doesn't care for locales, it just uses Unicode under the hood, even if it can't display the font. Do you see them in Explorer, actually? I see all file names properly, and I doubt that all these fonts are installed by default.

It is a problem, though, for non-Unicode file managers like my old FreeCommander version. When I double-click the ? ? ? ? ? ? ? ?.exe, nothing happens. However, even then, file integrity problems should be a phenomenon of the very very early days of Windows.

P.S.: I've had a look at MSDN, who confirm what I wrote on the use of Unicode above. There is one notable exception: The use of the Yen symbol in applications that work on FAT filesystems:
Quote
For security reasons, your applications should not typically allow the character U+00A5 in a Unicode string that might be converted for use as a FAT file name.

*) I just tested the PlayingWithUnicode.zip attached above also on a FAT32 USB stick. Everything works like a charm, including saving rotated images in Hindi, Chinese, Russian etc; I did a scandisk afterwards, no problems found.
« Last Edit: November 09, 2016, 12:23:51 PM by jj2007 »

Mike Lobanovsky

  • Guest
Re: MasmBasic
« Reply #17 on: November 09, 2016, 09:03:40 PM »
This is a "clean" (of all localization packs; LCID=1033) installation of Win 7 Pro Sp1 I'm using for C/C++ development:

jj2007

  • Guest
Re: MasmBasic
« Reply #18 on: November 10, 2016, 01:44:43 AM »
This is a "clean" (of all localization packs; LCID=1033) installation of Win 7 Pro Sp1 I'm using for C/C++ development:

Thanks, Mike. Weird that Explorer can handle Unicode filenames (the images are loaded etc) but can't display them, while the message boxes have a bad caption but Chinese text is displayed properly. Mysteries of Windows 8)

Mike Lobanovsky

  • Guest
Re: MasmBasic
« Reply #19 on: November 10, 2016, 07:42:42 AM »
Mysteries of Windows 8)

Yeah, there's also absolutely no problem with net browsing either. Prolly all major browsers have their own locale support utils to cover most if not all of the browser page text requests. I wish I knew how to handle those to be able to use them too on the installations that don't support those CPs and fonts officially. ;)

jj2007

  • Guest
Displaying animated GIF images
« Reply #20 on: November 26, 2016, 09:43:56 AM »
Download update 26 Nov 16:

Inter alia, GuiImage handles now animated GIFs automatically; search \Masm32\MasmBasic\MbGuide.rtf for .MbGui

Example (a complete Windows GUI application with a sizeable window):
Code: [Select]
include \masm32\MasmBasic\Res\MbGui.asm
Event Paint
  GuiImage "http://retrogamecoding.org/board/index.php?action=dlattach;attach=1045;type=avatar", fit
GuiEnd

The more elaborate attached demo displays (provided MasmBasic is installed)
- a static background car.jpg
- an avatar (members only, sorry :biggrin:)
- a smiley (the car needed a little decoration)
- and an animated GIF from the resources

jj2007

  • Guest
Re: MasmBasic
« Reply #21 on: December 02, 2016, 09:14:24 AM »
MasmBasic update 2 December got several new features (see here for some examples), inter alia the StringToArray function can now be fed with files from disk, from the internet, and with a text file embedded in the resouce section:

include \masm32\MasmBasic\MasmBasic.inc Init
  StringToArray 123, my$()            ; 123 is the resource ID
  For_ ct=0 To Min(39, eax)            ; loop max 40 times
      PrintLine Str$("Line %i\t", ct), my$(ct)
  Next
  Inkey "--- hit any key ---"
EndOfCode

Rsrc            ; when hitting F6, RichMasm exports this section to [filename].rc
123 RCDATA "\\Masm32\\MasmBasic\\MasmBasic.inc"
Rsrc

jj2007

  • Guest
MasmBasic hits the 400 commands mark
« Reply #22 on: November 09, 2017, 08:38:41 AM »
Version 8 November 2017 is ready to be installed. Changes:

- updated help file, with now 400+ macros documented (also online - use Ctrl F to find commands; but remember the best help option is to use RichMasm, hover over a keyword like Open, then right-click on the word and copy the line that fits your case)

- fDate$() and fTime$() can now take a third parameter to force any language:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  Print "Right now, ", fDate$(0, "dddd dd MMMM yyyy "), fTime$(0, "HH:mm:ss"), Str$(", we are in ISO week %i\n", IsoWeek())
  Print fDate$(0, "dddd dd MMMM yyyy ", russian), fTime$(0, "HH:mm"), Str$(", мы находимся в ИСО неделе %i", IsoWeek())
  wMsgBox 0, wCat$(wfDate$(0, "dddd dd MMMM yyyy ", hindi)+wfTime$(0)), "This is Unicode:", MB_OK
EndOfCode

Output:
Right now, Wednesday 08 November 2017 04:55:26, we are in ISO week 45
среда 08 ноября 2017 04:55, мы находимся в ИСО неделе 45


- SetInt can now move the content of ST(0) to xmm0:
  fldpi
  Print Str$("PI=\t%Jf\n", ST(0))
  fmul FP4(100.0)
  SetInt ecx
  Print Str$("100*PI=\t %i\n", ecx)
  fldpi
  fmul FP8(10.0e16)
  SetInt xmm0
  Print Str$("100*PI=\t %i\n", xmm0)


Code: [Select]
Output:
PI=     3.141592653589793238
100*PI=  314
10e16*PI=314159265358979324

- finally, the ternary operator If? can now also take the Zero? and Carry? flags as input (testbed attached):

  xor ecx, ecx
  Print Str$("zero flag set: %i\txor ecx, ecx\n", If?(zero?, 111, 222))         ; prints first number, 111
  or ecx, -1
  Print Str$("zero flag set: %i\tor ecx, -1\n", If?(zero?, 111, 222))   ; prints second number, 222
  stc
  Print Str$("carry set: %i\tstc\n", If?(Carry?, 111, 222))     ; carry is set, prints 111
  clc
  Print Str$("carry set: %i\tclc\n", If?(Carry?, 111, 222))     ; carry clear, prints 222

B+

  • Guest
Re: MasmBasic
« Reply #23 on: November 09, 2017, 06:19:37 PM »
Hi JJ,

Congratulations! How do you count it when macro name is same but has optional parameter, one or two?

jj2007

  • Guest
Re: MasmBasic
« Reply #24 on: November 09, 2017, 11:48:57 PM »
Then it's normally one macro only. However, the wide versions (wOpen, wPrint, ...) count as separate macros.

jj2007

  • Guest
Re: MasmBasic
« Reply #25 on: December 26, 2017, 01:09:14 AM »
MasmBasic got updated, see download and installation. Inter alia, many standard Windows controls are now easily accessible via the GuiControl command:
Code: [Select]
include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyEdit, "richedit", NoTag$(FileRead$("http://retrogamecoding.org/board/index.php?board=17.0"))
GuiEnd

This is sufficient to create a full-fledged Windows application. Here is a more elaborate example of an application with 18 controls, like edit, static, richedit, syslink, date & time, progressbar, trackbar, etc.


Btw with 5319 characters in 80 lines, the source for this demo would have fit into the 100 Line-of-Code Programming Language Competition:
The limit is 255 characters X 100 lines = 25500 characters, that is a clear limit.

jj2007

  • Guest
Re: MasmBasic
« Reply #26 on: November 28, 2018, 12:35:41 PM »
News from the MasmBasic subforum:



The source (requires the Masm32 SDK plus the MasmBasic library):

GuiParas equ "Plot sinus & cosinus curves", x600, y100, w600, h500, bRgbCol(192, 255, 255)
include \masm32\MasmBasic\Res\MbGui.asm
  Dim MySinus() As REAL4                       ; REAL4 precision is enough ...
  Dim MyCosinus() As REAL8                     ; ... but REAL8 is ok, too
  For_ ecx=0 To 359
        SetFloat MySinus(ecx)=Sinus(ecx)       ; fill an array
        SetFloat MyCosinus(ecx)=Cosinus(ecx)   ; you may use ArrayRead for reading data from a file
  Next
  MakeFont hHorzFont, Height:18, Weight:FW_SEMIBOLD, Italic:TRUE
  MakeFont hVertFont, Height:18, Weight:FW_SEMIBOLD, Escapement:900, Italic:FALSE
  MakePen hPenAxis, RgbCol(255, 0, 0)
  MakePen hPenGrid, RgbCol(255, 255, 222), width 2
  SetAxisX "degrees", s 0, d 15.0/3, grid 1, penx hPenAxis, peng hPenGrid, font hHorzFont, format "%i" ; s=start value, d=difference between gridlines
  SetAxisY "sinus & cosinus", s -1, d 0.2/5, grid 2, font hVertFont, format "%2f"
  $Data "Plotting an array of points is very easy: All you need is the array itself, plus a Paint event that draws it."
  $Data "The axes can be set using SetAxisX and SetAxisY, taking arguments as shown in the source. Now resize this window to see how it behaves"
  Read desc$()                          ; read a string array from $Data
  Event Paint
  ArrayPlot MySinus(), RgbCol(255, 222, 160), 2, 00000110h, 0, -1, 1    ; red sinus, 2px wide; use margins left top right bottom, min0, max-1, filled=1 ArrayPlot MyCosinus(), RgbCol(0, 0, 255)             ; plot the cosinus array in blue, same margins as previous plot
  ArrayPlot exit, 0150006028# "Sinus & Cosinus"        ; finish with a title; optional: xxxxyyyyFF#: x, y pos, font size
  GuiTextBox 12, 100.0-80, 440, 66, Join$(desc$(), " "), bcol RgbCol(192, 255, 192)
  GuiEnd


Project attached. To build it, open the *.asc file in \Masm32\MasmBasic\RichMasm.exe and hit F6.
« Last Edit: November 28, 2018, 12:38:17 PM by jj2007 »

jj2007

  • Guest
Re: MasmBasic
« Reply #27 on: April 02, 2019, 02:47:24 AM »


Source (67 lines of code) and data are attached; building requires MasmBasic version 2 April 2019 or later, plus the Masm32 SDK

jj2007

  • Guest
Re: MasmBasic
« Reply #28 on: May 08, 2019, 02:13:12 PM »
MasmBasic version 8 May 2019 features some improvements under the hood, plus more comfortable working with maps. Below a screenshot, these 14 lines of code are the source:

include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyMap, "canvas", w660
  GuiControl TheManual, "richedit", res:92, x660, w340, bcol RgbCol(255, 255, 222)
  GuiControl Sbar, "statusbar", bcol RgbCol(255, 0, 0), wRec$("Click into a country / Нажмите в страну / 點擊進入一個國家 - this toolbar uses common controls version "+ComCtl32$()), font -16:FW_SEMIBOLD
  ArrayLoadMap 0, 90                    ; Europe.dmi and Europe.map in resources
  MapColours(0, "abcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghi")      ; set colours to map 0 (a=red, i=green)
Event CanvasPaint
  ArrayPlot RgbCol(0, 240, 255)         ; init and set background colour
  PaintMap RgbCol(127, 127, 127), lines=2       ; map with grey borders 2px thick
  ArrayPlot exit, "Europe"
  GuiTextBox 99.0-120, 52.0, 120, 60, "This program requires the file Europe.map", bcol LiteGreen, font -18:FW_NORMAL
Event Message
  If_ uMsg_==WM_MAPCLICKED Then <SetWin$ hSbar=If?(MapRegion ge 0, "You clicked on "+MapRegion$, Time$)>
GuiEnd


« Last Edit: May 08, 2019, 02:21:16 PM by jj2007 »

jj2007

  • Guest
Fast and powerful string sort
« Reply #29 on: August 22, 2019, 12:01:05 PM »
The new MasmBasic version of 20 August 2019 features an improved sort algo. Case-sensitive sorts are now over 20% faster, case-insensitive sorting is now almost a factor 3 faster.
Code: [Select]
Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz

sorting 1000000 lines case-insensitive took 504 ms
AAaAHZybMJfIBMDPTlGpjvUIKUAUarYYBhwoQzXDbBiAcpCJBdWibuPGKXCeSrAcOsQVouKGLUtXF
aAABoYraUmtdbUjgRDbugWslpjAUIKuszBiOYgbGgDwawBsyfUTodDuktDyLUCdtDSYqIFfwxoBlKDfbiuHQ
aaadeaEoIYWvHUzkSOtliXprvQLwLRmQtZnACEWprRsosQEBCExqPRkIFHyxbkWHovUZtDOKw
...
ZZzyzetRGgWITClgQOTutTCdCiuHMxPNPuxGIsUFqStMIuIRPqlWpHdzyckcajQMCgNTbYzilNuy
zzZzcsrZGTHbiajufJIMXwWdbKFncznEBmlSLCGJBKFTHoixDzzNgeXSRohyfJHAQreI
zZZzToOoFStspcNrVaEIfjsxTNFZWUIwVWqxrzppJBjnxhbFgXmoCjUQxitzjpsLsmkTJefTDsKUKDj

sorting 1000000 lines case-sensitive took 444 ms
AAAJkbfOkQBObDHcbTIwHpqfZhoeEAOdznaOpVJqBwanparynNfGQbaMfZwqeWVzuereGocrnKWbAx
AAAKDBqCLIvtYhNOwRHDkUdYhtCnqVlAtRxBIyOmZtyRTJmmduoLcogeGKDYzS
AAANyurgtXuGMSDjUiphJpjDEIXsqWblivOefMURODFFRLEmyNHboCtnRgrrGsTpQXBZ
...
zzzMNTYBXQesyiSPhDSnEMllmqJyPOetjQASwTjPPdMGALxaTsXIBwpiDnRqaG
zzzWKRnlAPdJrfgIgiHjbJTvoMgrRnxVAukqhhjMqshOgVAuaGceqItZADoDlNBtykFZjwKyKuMhTJeu
zzzYZAgWBUtSZfUmlAWnFFRpDcGgwdOFndrhSJZcyMsgkvLnTOTRmUtwjKvNKJndDYagMFDBnZQduJzTADOTbIsyx

P.S.: A fat text file for testing sort algorithms is here. To test them, extract the exe attached below to a folder, then open a DOS prompt and run it e.g. as MbSortText.exe RandSheet.tab

The example text files are tab-delimited, so that they are useful to test the sort-by-column feature of QSort(). With sort algos that do not have such a feature, they behave like a normal text file, i.e. the tabs will be ignored.
« Last Edit: August 22, 2019, 12:08:54 PM by jj2007 »