News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

ModernUI_Spinner Control

Started by fearless, June 28, 2019, 09:38:27 AM

Previous topic - Next topic

jj2007

Quote from: HSE on July 01, 2019, 09:36:50 AM
Hi fearless:
If You use "fcomp" don't need fstp.

You mean fcomip, I suppose?

include \masm32\MasmBasic\MasmBasic.inc
  Init
  fld FP10(179.9)      ; current value
  fld FP10(180.0)      ; compare with 180
  fcomip ST, ST(1)     ; compare and pop
  .if Carry?
        PrintLine Str$("%f is above 180", ST(0))
  .elseif Zero?
        PrintLine Str$("%f equals 180", ST(0))
  .else
        PrintLine Str$("%f is below 180", ST(0))
  .endif
  fld FP10(0.1)
  fadd
  fld FP10(180.0)
  fcomip ST, ST(1)
  .if Carry?
        PrintLine Str$("%f is above 180", ST(0))
  .elseif Zero?
        PrintLine Str$("%f equals 180", ST(0))
  .else
        PrintLine Str$("%f is below 180", ST(0))
  .endif
  fld FP10(0.1)
  fadd
  fld FP10(180.0)
  fcomip ST, ST(1)
  .if Carry?
        PrintLine Str$("%f is above 180", ST(0))
  .elseif Zero?
        PrintLine Str$("%f equals 180", ST(0))
  .else
        PrintLine Str$("%f is below 180", ST(0))
  .endif
  Inkey
EndOfCode


179.9000 is below 180
180.0000 equals 180
180.1000 is above 180

Biterider

Hi fearless
Just a minor optimization; if the divisor (the get the number of rotated images) is a multiple of 2, you can flip vertically the rotated images up to 180° in reverse order to get the remaining 180°.
The same way, if the divisor is a multiple of 4, you can first apply an horizontally flip in reverse order of images you previously get from the first quadrant.
The idea is to get a better performance than simply rotating all the images.  :icon_idea:

Just my 2 cents.

Biterider

LiaoMi

Hi fearless,

I still have flickering on the problem pictures, i.e. When switching to a repeated circle, the picture completely disappears and reappears, this causes flicker.

fearless

Hi LiaoMi,

On the far right spinner (which is now slowed down) can you tell which frame is disappearing? The far right faded wheel spinner has 12 segments - so should have 12 images.

LiaoMi

Quote from: fearless on July 02, 2019, 02:10:17 AM
Hi LiaoMi,

On the far right spinner (which is now slowed down) can you tell which frame is disappearing? The far right faded wheel spinner has 12 segments - so should have 12 images.

I downloaded the last example again, now the animation works everywhere as it should, maybe I'm wrong, but I downloaded the same archive, very strange  :biggrin: Now everything is great! Thanks for the cool example!

fearless

Great news. I thought I had missed something.

HSE

Quote from: jj2007 on July 01, 2019, 11:28:33 AM
You mean fcomip, I suppose?

NO, I mean fcomp  :biggrin:

For sure your program have problems because iisn't tranfering conditions from FPU to CPU and fcomp pop st(0). If you want to show st(0), you have to store it in a real8 variable before fcomp operation.

Just a note: I never transfer conditions but test ah. Perhaps and old recommendation, I don't remember.
Equations in Assembly: SmplMath

jj2007

So you are using fcomp + fstsw + sahf? Can you post a short example? I'd like to make a benchmark, out of curiosity.

HSE

macro and equ:compvalR macro a1,a2
Fld a1
fcomp a2
fstsw ax
endm

FP_LESSTHAN equ 01h
FP_EQUALTO equ 40h


use:compvalR x, minimox
.if ( ah & FP_LESSTHAN)
fld x
fstp minimox
.endif
Equations in Assembly: SmplMath

fearless

I updated the x64 version of the ModernUI_Spinner and started making an x64 demo version MUISpinner1

I found some odd issues with GDI+ in x64 that I can't explain and haven't found anything online specifically about the issue. Appears to make the loaded png images slightly misshapen and attempting to create a spinner from a single png and rotate it works, but the image is ever so slightly out in each frame so the whole image appears to wobble. png spritesheets also appear to exhibit parts of the image being cutoff by a pixel or so in width and/or height from what i can estimate. the bmp frames and spritesheet spinners appear to work fine.

I did try adding a dependency in the xml manifest relating to gdiplus, but didnt seem to make much of a difference.

I could be GDI+ on win7 x64 that is the issue, so I wonder if others could test it out and see if it does show any odd wobbles and misshapen images

The x64 library is here: https://github.com/mrfearless/ModernUI64/blob/master/Release/ModernUI_Spinner.zip?raw=true
The entire RadASM project is here: https://github.com/mrfearless/ModernUI64/blob/master/Release/MUISpinner1.zip?raw=true

Attached is the example exe in a zip (without RadASM project)

jj2007

Looks cute on my Win7-64, and I don't see problems other than slightly rough edges :thumbsup:

Biterider

Hi Fearless
Same result as above here (Win10/64). The 10th spinner has a dramatic offset. Maybe it is the place to start looking for.

Biterider

fearless

And its like the anti-aliasing, smoothing and other stuff isn't being applied by the GDI+, which you can see in the image JJ posted, which is what I see as well. Might have to look at the include files to see if there is something not set correctly, maybe that's where the problem is. Normally with the code below it should apply all those:

    Invoke GdipSetPixelOffsetMode, pGraphicsBuffer, PixelOffsetModeHighQuality
    Invoke GdipSetPageUnit, pGraphicsBuffer, UnitPixel
    Invoke GdipSetSmoothingMode, pGraphicsBuffer, SmoothingModeAntiAlias
    Invoke GdipSetInterpolationMode, pGraphicsBuffer, InterpolationModeHighQualityBicubic

fearless

Turns out my gdiplus definition files did have some incorrect values for those equates listed above - I copied the values from those defined in the windows.inc and the image quality looks better now, but still getting a small drift in the image position as it rotates, which I can't seem to resolve at the moment. Still noticing some tiny clipping or offset placement is out by a pixel or so on the spritesheet images, and the 10th spinner image is still in the upper left quadrant of the control for some reason. Slight progress, but still some mysteries left to solve.

jj2007

It's in Windows.inc, and the values are correct afaik. There is little difference between 2 and 4, though.
if 0
SmoothingModeDefault = 0 ; Gdi+ version is always 6.1.7601.24440 on Win7-64
SmoothingModeHighSpeed = 1 ; on Win7-64, Gdi+ 1.1.0.0 gets loaded independently of the manifest
SmoothingModeHighQuality = 2
SmoothingModeNone = 3
SmoothingModeAntiAlias = 4
SmoothingModeAntiAlias8x4= SmoothingModeAntiAlias= 4
SmoothingModeAntiAlias8x8= 5
endif
gdi+ GdipSetSmoothingMode, GraphObj, gdiSmoothing  ; a global variable for playing ;-)