Recent Posts

Pages: [1] 2 3 ... 10
1
MasmBasic & the RichMasm IDE / Re: Cairo
« Last post by jj2007 on Today at 10:25:11 AM »
If you are successful in testing other Cairo functions, please post them. I am curious if this lib offers any advantage over plain Gdi or Gdi+.

Complete Cairo API

P.S.: Try inserting a MakePath/GuiDraw element (resizable!):

SetGlobals surface, context, double red, green, blue
MakePath 111, Bezier(150:0, 0:90, 0:120, 300:300)
MakePen hPenBez, RgbCol(200, 160, 160, 0), width 4, startarrow LineCapRoundAnchor, endarrow 12:9, inset 2
Event Paint
  invoke TextOut, PtDC, 9, 5, Str$("Cairo version %i\n", cairo_version()), s$Len
  GuiDraw 111, hPenBez, 45.0, 25.0
  mov surface, cairo_win32_surface_create(PtDC)
2
MasmBasic & the RichMasm IDE / Re: Cairo
« Last post by HSE on Today at 10:21:35 AM »
 :t Thanks.
3
MasmBasic & the RichMasm IDE / Re: Cairo
« Last post by jj2007 on Today at 10:11:43 AM »
A problem with Declare

Sorry, I haven't updated the package for a while. Attached the new Declare version, to be inserted after the Dll line.
4
MasmBasic & the RichMasm IDE / Re: Cairo
« Last post by HSE on Today at 09:07:49 AM »
A problem with Declare:
Code: [Select]
N:\jj\varios>asmC cairo2.asm
Asmc Macro Assembler Version 2.28.05
Copyright (C) The Asmc Contributors. All Rights Reserved.

 Assembling: cairo2.asm
*** MasmBasic version 25.12.2017 ***
** SetProcessUserModeExceptionPolicy
## MasmBasic GUI build ##
cairo2.asm(5) : error A2091: index value past end of string
 Declare(50)[MasmBasic.inc]: Macro called from
  cairo2.asm(5): Main line code
cairo2.asm(5) : error A2006: undefined symbol : ??03BB
 Declare(51)[MasmBasic.inc]: Macro called from
  cairo2.asm(5): Main line code
cairo2.asm(5) : error A2091: index value past end of string
 Declare(73)[MasmBasic.inc]: Macro called from
  cairo2.asm(5): Main line code
cairo2.asm(22) : error A2091: index value past end of string
 cairo_version(6)[cairo2.asm]: Macro called from
  cairo2.asm(22): Main line code
cairo2.asm(22) : error A2006: undefined symbol : ??04A0
 cairo_version(7)[cairo2.asm]: Macro called from
  cairo2.asm(22): Main line code
cairo2.asm(22) : error A2006: undefined symbol : ??04A0
 cairo_version(99)[cairo2.asm]: Macro called from
  cairo2.asm(22): Main line code
cairo2.asm(22) : error A2006: undefined symbol : ??04A0
 cairo_version(140)[cairo2.asm]: Macro called from
  cairo2.asm(22): Main line code
5
MasmBasic & the RichMasm IDE / Re: Cairo
« Last post by jj2007 on Today at 05:37:24 AM »
Tomorrow I'll try to generate my own import lib with windows native tools. We will see...  :biggrin:

Good luck :bgrin:

A link for Cairo

Thanks, Timo - that was actually the binary I was already using, it pops up on top for googling cairo windows binaries. Here is my first successful attempt:

GuiParas equ "Cairo demo", x550, y20, w160, h180, cblack, b RgbCol(255, 255, 160)
include \masm32\MasmBasic\Res\MbGui.asm         ; part of MasmBasic
Dll "\Masm32\Cairo\lib\x86\cairo.dll"  ; suggested path to the Dll
Declare cairo_version
Declare cairo_win32_surface_create, C:1
Declare cairo_create, C:1
Declare void cairo_rectangle, C:5
Declare void cairo_set_source_rgba, C:5
Declare void cairo_set_fill_rule, C:2
Declare void cairo_fill, C:1
Declare void cairo_destroy, C:1
Declare void cairo_surface_write_to_png, C:2
Declare void cairo_surface_destroy, C:1
Declare void cairo_status, C:1
Declare void cairo_surface_status, C:1
Declare void cairo_status_to_string, C:1
Enum 0:CAIRO_FILL_RULE_WINDING, CAIRO_FILL_RULE_EVEN_ODD
SetGlobals surface, context, double red, green, blue

Event Paint
  invoke TextOut, PtDC, 9, 5, Str$("Cairo version %i\n", cairo_version()), s$Len
  mov surface, cairo_win32_surface_create(PtDC)
  mov context, cairo_create(surface)
  cairo_rectangle(context, FP8(20.0), FP8(30.0), FP8(100.0), FP8(100.0))
  Rand(0.0, 1.0, red)
  Rand(0.0, 1.0, green)         ; generate random colours
  Rand(0.0, 1.0, blue)
  cairo_set_source_rgba(context, red, green, blue, FP8(0.5))    ; last arg is transparency
  cairo_set_fill_rule(context, CAIRO_FILL_RULE_EVEN_ODD)
  cairo_fill(context)
  cairo_destroy(context);
  ; cairo_surface_write_to_png(surface, "test.png")    ; saves client area to disk
  cairo_surface_destroy(surface);
GuiEnd


When sizing, you can see the random colours generated. I ran it with a timer and MemState, no leaks detected.

Source & exe attached, including my Pelles C test case (which works only when in the same folder as the DLL... :()

The DLL is 2MB, too big to be posted here; but all you need is cairo.dll from the link you posted (download), which I suggest to save to \Masm32\Cairo\lib\x86\cairo.dll for those who want to follow this thread.
6
Irvine Book Questions. / Re: help please: masm32 input dialog box
« Last post by jj2007 on Today at 05:21:37 AM »
Hi Jochen,

Interesting, but maybe you should announce that the example creates a key in the registry...

Why should I announce that my example creates a key in the registry when I attach the source code? Is it improper to add a key in the section HKEY_CURRENT_USER?

Hi Erol,

Please don't be offended, it was not meant to. Your code is fine, but it came without any explanation - and as an assembly coder, I have that reflex "hey, he is fumbling my registry, why that?". My machine is getting slower and slower, and I am getting more and more sensitive to programs that add more stuff to my registry. Yours is a tiny bit indeed, not worth mentioning except for the good cause, i.e. you should explain to us n00bs in a few words what you did there ;-)
 :icon14:
7
Irvine Book Questions. / Re: help please: masm32 input dialog box
« Last post by Vortex on Today at 04:09:03 AM »
Hi Jochen,

Interesting, but maybe you should announce that the example creates a key in the registry...

Why should I announce that my example creates a key in the registry when I attach the source code? Is it improper to add a key in the section HKEY_CURRENT_USER?

I am not a big fan of the registry but setting a DOS variable to the output of a command is not a very comfortable task. Here is an alternative version not using the registry :

Code: [Select]
FOR /F %%A in ('InputBox.exe "Type yes to continue, no to exit" "Hello" 100 100') do SET string=%%A
BusyBox, the tiny UNIX\Linux shell is easier to use for the same purpose :

https://frippery.org/busybox/

Code: [Select]
string=$(InputBox.exe "What is your name?" "Hello" 100 100)

echo Your name is $string
8
Examples / Re: Small CPU - Memory Info App.
« Last post by hutch-- on Today at 03:31:46 AM »
I prefer "Industrial Robot".  :biggrin:
9
Examples / Re: Small CPU - Memory Info App.
« Last post by anunitu on Today at 03:23:41 AM »
playing with zombie code then hutch??
10
MasmBasic & the RichMasm IDE / Sorting strings
« Last post by jj2007 on Today at 03:06:10 AM »
Generates two Million random strings and sorts them using QSort (which is an in-place mergesort).
Source & binaries attached: Extract exe and dll to the same folder, then run the exe. Typical result for a Core i5:
Code: [Select]
11 s for writing 2 Millon strings
106 ms for reading 5 Million strings
3.2 seconds for sorting 5 Million strings
Pages: [1] 2 3 ... 10