News:

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

MasmBasic

Started by jj2007, October 06, 2009, 08:24:57 PM

Previous topic - Next topic

jj2007

Quote from: qWord on October 22, 2009, 10:37:18 AM
Quote from: jj2007 on October 22, 2009, 09:24:06 AM
not a big deal but we are stingy, aren't we? ;-)
in case of clocks ? - yes  :bg

Hmmm... show me a speed-critical example using invoke MessageBoxW, 0, wChr$("Hello Masm32"), wChr$("Unicode is simple:"), MB_OK  :green

Your latest code works flawless, except for the bloat factor, of course :bg. Shall I incude it into the library as qChr$ and qData? What do the other hundreds of thousands of MasmBasic users out there think about it??

jj2007

Update on top of thread. New functions:
- Fsign:
Quote.if Fsign(MyRealVar)
      MsgBox 0, "MyRealVar is negative", "Fsign:", MB_OK
   .else
      MsgBox 0, "MyRealVar is not negative", "Fsign:", MB_OK
   .endif
   returns Sign?, and works with all sizes (Real4, Real8, Real10)

- Hex$:
QuotePrint Hex$(eax)
   Print Hex$(cx)
   Print Hex$(dl)
   Print Hex$(MyDword)
   Print Hex$(MyWord)
   Print Hex$(MyByte)
   Print Hex$(123)
   Let A$="Hex="+Hex$(1a2b3c4dh)+"h"

- Bin$:
QuotePrint Bin$(123)
   Let esi=Bin$(-1)+"y"
   MsgBox 0, Bin$(ebx, f), "The Bin$", MB_OK
   returns DWORD in edx - use only once in Let
   option f adds a formatted bit counter
Here is the output of the f option with Print Bin$(123, f):
00000000000000000000000001111011
10987654321098765432109876543210

jj2007

#47
Inspired by DednDave's post, I have added a 16-bit example. This is a partial update only - extract the archive to the root folder of your Masm32 drive with "use folder names" on, then open \masm32\RichMasm\RES\hello16.asc

EDIT: Now included in the updated main package.

jj2007

Since I rarely print my code on paper, I had not foreseen a printing function. As this thread shows, there is a certain demand for this feature, so I implemented it. Since I could test it only on a fake printer (PdfCreator), I would be grateful for feedback - see MasmBasic7.zip on top of this thread.

Attached an example printout: TinyRTF is the "little brother" of RichMasm, the source is included in the package.

rags

JJ,
  I am using XP SP3 and the printer is a Konica Minolta MagicColor 2300 DL laser printer. The whole document is not being printed on my machine.
On what should be a multiple page printout I am losing a line at the bottom of the printed page, or sometimes the bottom line is not completely
printed. IE- only half the line height gets printed.

Also are there more than just the fixed or proportional font options?
I personally like a smaller print size on paper and it cuts down on the paper used.
God made Man, but the monkey applied the glue -DEVO

jj2007

#50
Quote from: rags on November 03, 2009, 01:07:08 AM
I am using XP SP3 and the printer is a Konica Minolta MagicColor 2300 DL laser printer. The whole document is not being printed on my machine.
On what should be a multiple page printout I am losing a line at the bottom of the printed page, or sometimes the bottom line is not completely printed. IE- only half the line height gets printed.

rags,
version 7c attached on top of this thread fixes the printer issue by using a default value of 6mm for the bottom.

> Also are there more than just the fixed or proportional font options?
> I personally like a smaller print size on paper and it cuts down on the paper used.

\masm32\RichMasm\Res\RichMasm.ini:
[App_Info]
prtL=700
prtR=900
prtT=100
prtB=600
SizeNormal=12
SizeLarge=14 --->Control L
SizeXXL=20 --->Control Shift L
SizeSmall=8 --->Menu Format, Small font
FaceSrc=System --->default when opening source code
FaceProp=Tahoma --->Menu proportional, or Control L
FaceLarge=Arial --->Control Shift L

Copy the file to \masm32\RichMasm\User\RichMasm.ini and modify according to your needs (but don't touch the Inf200 string).

Unfortunately the functions for scaling of printer output and/or zooming a RichEdit control are a bad joke, so this is all I can offer.
EDIT: Version 7d has scaling, at least for the Adobe PDF converter. Add the following setting to \masm32\RichMasm\user\RichMasm.ini:
prtScale=50
Warning: This will most likely print only half of the pages if the printer does not support scaling (e.g. a HP Color Laserjet does not...). I have tested it only for the Adobe "Printer"; print to pdf, open the pdf in the Adobe reader and print it from there. Example output attached.
EDIT(2): Scaling works fine for PrimoPDF and PdfCreator, but not for M$ Document Imaging. I am curious whether there are real printers around that perform scaling...

jj2007

New version on top of thread, with minor bugfixes and two major new features:

1. Export of code in MasmForum "quote" format:
Quoteinclude \masm32\MasmBasic\MasmBasic.inc
.code
start:   call Convert
   Exit
Convert proc
LOCAL pos, posAfter, MyTimer, MyCounter
  and MyCounter, 0
  mov MyTimer, Timer
Recall "\Masm32\include\Windows.inc", L$()   ; load an array of strings from file
  For_ n=0 To eax-1                           ; Recall returns # of strings in eax, so we use 0 ... eax-1
   mov pos, Instr_(1, L$(n), "equ", 5)      ; start in pos 1, 1=case-insensitive + 4=full word
   .if pos
      mov esi,
Val(Mid$(L$(n), pos+3, 99))   ; get the numeric value of the string behind equ
      .if signed edx<0                     ; edx returns the number of usable chars; a
         neg edx                        ; negative number indicates a hex$ or bin$ was found
         add edx, pos
         add edx, 3
         mov posAfter, edx
         inc MyCounter
         
Let L$(n)=Left$(L$(n), pos-1)+"EQU "+Str$(esi)+Mid$(L$(n), posAfter)
      .endif
   .endif
  Next
Store "MyWindows.inc", L$()               ; write all strings back to file
  sub MyTimer, Timer
 
Print Str$("\nConverting %i hex equates in Windows.inc to decimals", MyCounter), Str$(" took %i ms\n", 0-MyTimer)
  ret
Convert endp

end start

2. Inclusion of the resource file in the main code:

QuoteSetControlsPosition endp
   
end start

Rsrc start
#include "\masm32\include\resource.h"

#define  ID_SPIN1 101      //msctls_updown32, vertical
#define  ID_SPIN2 102      //msctls_updown32, horizontal
...
    CONTROL         "Spin1",ID_SPIN1,"msctls_updown32",UDS_SETBUDDYINT |
                    UDS_AUTOBUDDY | UDS_ARROWKEYS,83,77,11,38
    CONTROL         "Spin2",ID_SPIN2,"msctls_updown32",UDS_SETBUDDYINT |
...
END
Rsrc end

RichMasm options
OPT_Susy   Windows
OPT_Icon   Hammer
OPT_Linker   polink

2-Bit Chip

Amazing project you have there jj2007. :8)

I would like to contribute this:  :lol

PrintLn MACRO args
    .if args == 0
        Print 13,10   
    .else 
        Print args,13,10
ENDM


It can be used to print normally with a new line, or just a newline itself.

PrintLn Str$("Have a good day!") or PrintLn

jj2007

Quote from: 2-Bit Chip on November 28, 2009, 03:45:16 AM
Amazing project you have there jj2007. :8)
:bg See the comments of Hutch and Sinsi in the Romper Room

Quote
I would like to contribute this:  :lol

Good idea, I will include it in the package. Here it is in an example:

Quoteinclude \masm32\MasmBasic\MasmBasic.inc

PrintLine MACRO args      ; credits to 2-Bit Chip
  ifb <args>
   Print
  else
   Print args, CrLf$
  endif
ENDM

.code
start:   GetFiles *.asc   ; get all assembler sources in the current folder
   mov ebx, eax      ; #files found
   PrintLine
   PrintLine
   PrintLine "Hello"
   PrintLine "Hello"
   PrintLine
   PrintLine Str$("%i files found\n", ebx)
   For_ n=0 To ebx-1
      PrintLine Files$(n)
   Next

   getkey      ; standard macro from the Masm32 library
   
Exit      ; Uppercase please, the strings need cleanup
[/color]
end start

Output:



Hello
Hello

71 files found

Bin2Byte.asc
Bin2ByteB.asc
Bin2ByteInMB.asc
Bin2ByteX.asc
BinSwap.asc

dedndave

don't mind Hutch and sinsi, Jochen
they are just jealous because they didn't think of it, first - lol

jj2007

Quote from: dedndave on November 28, 2009, 04:10:22 PM
don't mind Hutch and sinsi, Jochen
they are just jealous because they didn't think of it, first - lol

Dave, they are RealMen(TM) and prefer endless greeeey listings. I fully understand that. At my advanced age, I need color to remember where the difficult bits of my code where :toothy

@2-Bit Chip: PrintLine is in, see version 8c on top of thread.

Another minor bugfix: The deb macro choked for deb 5, "First loop", eax, ebx, ST(0), My$

deb 1, "Test", eax, esi$ displays the contents of eax as an integer, the contents of esi as a string. You may use deb 2, "Second loop", eax etc. and cancel the displayed MsgBox individually for deb 1...4. However, deb 5 appends the contents to DebLog.txt in the current folder - an extremely handy feature that didn't work in version 8b.

jj2007

This orphanage thread on reading strings led to another update: Version 8e (on top of this thread) includes an example on how listboxes with many items can be displayed faster: While the standard way needs 1,200 milliseconds, it can be done in only 30 - a factor 40 improvement.
For making this work, Recall had to be modified so that it returns the # of bytes read from file.

From the template available at File/New Masm source/Listbox and Recall:

Quote   sm EQU <invoke SendMessage, >              ; an equate to save some typing
   sm hListbox, WM_SETREDRAW, 0, 0           ; A: stop the screen updating (the order is very important!)

   sm hListbox, LB_RESETCONTENT, 0, 0   ;      B: clear the listbox
   Recall "\Masm32\include\Windows.inc", L$()        ; read the strings from file to the L$() array ; eax=line count, edx=bytes read
   mov linecount, eax
   sm hListbox, LB_INITSTORAGE, eax, edx        ; C: tell the OS what you need
   For_ n=0 To linecount-1

         sm hListbox, LB_ADDSTRING, 0, L$(n)
   Next
   sm hListbox, WM_SETREDRAW, 1, 0           ; D: turn on screen updating

ecube

no included source, i'll pass

jj2007

Quote from: E^cube on December 01, 2009, 04:55:24 AM
no included source, i'll pass
You wouldn't understand it anyway. If somebody is seriously interested, pm me ("seriously" means I expect proof that the sender has already coded something in MB).

ecube

Quote from: jj2007 on December 01, 2009, 07:51:44 AM
Quote from: E^cube on December 01, 2009, 04:55:24 AM
no included source, i'll pass
You wouldn't understand it anyway. If somebody is seriously interested, pm me ("seriously" means I expect proof that the sender has already coded something in MB).

uh i've programmed in vb for awhile, and I understand ASM minus sse2 etc which I HIGHLY doubt your code contains that. Anyway you keep being arrogant and thinking you're some kinda ASM wizard, cause you already seen what happens when you release your "amazing" code, people like lingo come by and write something far faster/smaller.