Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jj2007

Pages: [1] 2 3 ... 9
1
Community news and announcements / Re: MasmBasic
« on: 10. November 2017, 00:48:57 »
Then it's normally one macro only. However, the wide versions (wOpen, wPrint, ...) count as separate macros.

2
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

3
Code and examples / Map viewer
« on: 23. October 2017, 00:40:01 »
A simple map viewer, full source and exe attached (building requires MasmBasic 23 Oct 2017 or later). Extract all files to a folder and launch the exe.

To make it run properly, an instance of M$ Excel should be running. In case you don't have Office: Microsoft's free Excel Viewer works perfectly.

The map viewer example does the following in just under 100 lines of code:
- grab data from an Excel spreadsheet
- translate the data into a colour code, from green=good, yellow=medium to red=bad
- display everything as a map, including tooltips as shown below.

Tested so far on Win7-64 and Win10, grateful for feedback. Hit F1 to see the data as a list.

4
Code and examples / Re: Fall Foliage
« on: 23. October 2017, 00:34:30 »
Looks pretty realistic - compliments :)

5
Fantastic, Dunny!

6
Offtopic / Re: WhatA Fu** they...
« on: 06. August 2017, 02:46:57 »
GCC is fine but nobody really uses it with an IDE these days

Found something that supports your statement:
Quote
more and more compilers are adopting gcc command line options, pragmas, extensions, abi compatibility, and even bugs

That's the trend: GCC for command line compiling, or from an editor (I compile from RichMasm, of course). That is much better than, for example, using VS Community, which is just horribly bloated and incredibly slow.

Recently I managed to use the GCC QuadMath library from MasmBasic. That was tough, because it's barely documented, and under the hood GCC does really strange things. I spent several days debugging the C code until I had a clue how parameters are passed. C compilers can produce really ugly code 8)

P.S.: FreeBasic may soon have QuadMath, too.

7
I liked the discussion about including Strings.h ;D

8
Is there a reason you didn't try the link?

I tried the link, immediately after I had read your post.

9
Do:the:rules:allow:multiple:instructions:on:one:line?

10
General questions and discussions / Re: Method or Madness ;-))
« on: 30. May 2017, 10:21:30 »
JJ, after some research, my graphics card is AMD Radeon HD 6319, CPU is AMD E-300 APU 1.3 GHz
How does this info help? I have junk, right?

No, you don't have junk. It's 399 points (mine) against 170 (yours), but that is OK.

But I really wonder what you are measuring. The time it takes to calculate a Bresenham circle? I doubt it, because even with these values, you need to tell the graphics card what to do with it, via the line command. And that command might be a lot slower than the math...

To illustrate the problem, here a snippet that prints 360x the sinus and cosinus, in double precision. That is more than enough to get a precise 300 pixel circle. The second loop is identical, except that it doesn't print the values, i.e. you get the pure calculation time. And it does the second loop 10,000 times. Check yourself how much time it needs on your PC.

include \masm32\MasmBasic\MasmBasic.inc      ; download
  SetGlobals REAL8 px, py, REAL10 pi180=0.01745329251994329577
  Init
  For_ ecx=0 To 359
      push ecx
      fld pi180
      fimul stack
      fsincos
      fstp py
      fstp px
      Print Str$(ecx), Str$("\t%Cf  \t", py), Str$("%Cf\n", px)
      pop eax
  Next
  NanoTimer()
  push 9999
  .Repeat
      xor ecx, ecx
      .Repeat
            push ecx
            fld pi180
            fimul stack
            fsincos
            fstp py
            fstp px
            ; no Print Str$(ecx), Str$("\t%f\t", py), Str$("%f\n", px)
            pop eax
            inc ecx
      .Until ecx>=360
      dec stack
  .Until Sign?
  pop edx
  Inkey Str$("10000 calculations took %i ms", NanoTimer(ms))
EndOfCode

11
General questions and discussions / Re: Method or Madness ;-))
« on: 30. May 2017, 00:31:57 »
@B+: Which Windows version, which CPU, which graphics card?

I have a simple i5 with a standard Nvidia... and 100 circles take 20ms

12
General questions and discussions / Re: Method or Madness ;-))
« on: 29. May 2017, 04:02:11 »
Are you just using Paint to fill the circle?

No, it's GdipAddPathEllipse, a Windows Gdi+ function. As mentioned above, Ellipse is an even faster option, if you just want simple low quality circles.

The file is RTF, it opens in RichMasm, WordPad, MS Word, LibreOffice, ...

13
Code and examples / Re: Tree Swirl
« on: 28. May 2017, 18:02:09 »
Beautiful!

14
General questions and discussions / Re: Method or Madness ;-))
« on: 28. May 2017, 17:54:00 »
The speed of Small Basic for drawing circles, was unexpected.

Your 156 ms on top of the image are realistic. This is roughly what I get on my core i5 with the attached code, which simply uses the built-in Windows function GdipAddPathEllipse. What is your cpu?

Note that GdipAddPathEllipse is a slow Gdi+ function. The standard GDI Ellipse function is about ten times as fast.

15
General questions and discussions / Re: Method or Madness ;-))
« on: 26. May 2017, 14:51:54 »
In my experience, the time to draw circles depends exclusively on what the graphics card can deliver. Calculating sinuses costs cycles, of course, but the filling and drawing costs much more.

Do you have an explanation why you see such big differences? Do you have timings?

Attached an example that fills a window with a hundred circles. Here is the source:

include \masm32\MasmBasic\Res\MbGui.asm      ; MasmBasic
  Dim Pens() As DWORD
  Dim Brushes() As DWORD
  For_ ct=0 To 99
      MakePen Pens(ct), Rand(-1), width 9      ; use random colours
      MakeBrush Brushes(ct), Rand(-1)      ; also for the fill
  Next
  MakePath      123, Circle(200)      ; radius as n/1000 of window rect
  SetGlobals posX, posY, pen, brush
Event Paint
  NanoTimer()
  For_ ecx=0 To 99      ; ID            pen/brush                  x            y            scaleX            scaleY
      GuiDraw 123, <Pens(ecx)/Brushes(ecx)>, <Rand(500)>, <Rand(550)>, <Rand(800)>, <Rand(800)>
  Next
  GuiText 100.0-220, 100.0-22, Str$("%i ms (resize window to refresh)", NanoTimer(ms))      ; ca 20ms on a Core i5
GuiEnd

Pages: [1] 2 3 ... 9