Author Topic: ModernUI_Spinner Control  (Read 1908 times)

jj2007

  • Member
  • *****
  • Posts: 9804
  • Assembler is fun ;-)
    • MasmBasic
Re: ModernUI_Spinner Control
« Reply #30 on: July 01, 2019, 11:28:33 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


Code: [Select]
179.9000 is below 180
180.0000 equals 180
180.1000 is above 180

Biterider

  • Member
  • ***
  • Posts: 393
  • ObjAsm32 + ObjAsm64 = ObjAsm
    • ObjAsm
Re: ModernUI_Spinner Control
« Reply #31 on: July 01, 2019, 03:32:49 PM »
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

  • Member
  • ****
  • Posts: 595
Re: ModernUI_Spinner Control
« Reply #32 on: July 01, 2019, 11:52:41 PM »
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

  • Member
  • ***
  • Posts: 469
    • LetTheLightIn
Re: ModernUI_Spinner Control
« Reply #33 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.
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

My Github  Twitter

LiaoMi

  • Member
  • ****
  • Posts: 595
Re: ModernUI_Spinner Control
« Reply #34 on: July 02, 2019, 02:23:56 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

  • Member
  • ***
  • Posts: 469
    • LetTheLightIn
Re: ModernUI_Spinner Control
« Reply #35 on: July 02, 2019, 02:48:27 AM »
Great news. I thought I had missed something.
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

My Github  Twitter

HSE

  • Member
  • *****
  • Posts: 1148
  • <AMD>< 7-32>
Re: ModernUI_Spinner Control
« Reply #36 on: July 02, 2019, 10:03:08 PM »
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.

jj2007

  • Member
  • *****
  • Posts: 9804
  • Assembler is fun ;-)
    • MasmBasic
Re: ModernUI_Spinner Control
« Reply #37 on: July 02, 2019, 11:53:54 PM »
So you are using fcomp + fstsw + sahf? Can you post a short example? I'd like to make a benchmark, out of curiosity.

HSE

  • Member
  • *****
  • Posts: 1148
  • <AMD>< 7-32>
Re: ModernUI_Spinner Control
« Reply #38 on: July 03, 2019, 12:18:07 AM »
macro and equ:
Code: [Select]
compvalR macro a1,a2
Fld a1
fcomp a2
fstsw ax
endm

FP_LESSTHAN equ 01h
FP_EQUALTO equ 40h

use:
Code: [Select]
compvalR x, minimox
.if ( ah & FP_LESSTHAN)
fld x
fstp minimox
.endif

fearless

  • Member
  • ***
  • Posts: 469
    • LetTheLightIn
Re: ModernUI_Spinner Control
« Reply #39 on: July 22, 2019, 07:42:05 AM »
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)
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

My Github  Twitter

jj2007

  • Member
  • *****
  • Posts: 9804
  • Assembler is fun ;-)
    • MasmBasic
Re: ModernUI_Spinner Control
« Reply #40 on: July 22, 2019, 12:27:33 PM »
Looks cute on my Win7-64, and I don't see problems other than slightly rough edges :thumbsup:

Biterider

  • Member
  • ***
  • Posts: 393
  • ObjAsm32 + ObjAsm64 = ObjAsm
    • ObjAsm
Re: ModernUI_Spinner Control
« Reply #41 on: July 22, 2019, 03:49:42 PM »
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

  • Member
  • ***
  • Posts: 469
    • LetTheLightIn
Re: ModernUI_Spinner Control
« Reply #42 on: July 22, 2019, 07:38:29 PM »
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:

Code: [Select]
    Invoke GdipSetPixelOffsetMode, pGraphicsBuffer, PixelOffsetModeHighQuality
    Invoke GdipSetPageUnit, pGraphicsBuffer, UnitPixel
    Invoke GdipSetSmoothingMode, pGraphicsBuffer, SmoothingModeAntiAlias
    Invoke GdipSetInterpolationMode, pGraphicsBuffer, InterpolationModeHighQualityBicubic
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

My Github  Twitter

fearless

  • Member
  • ***
  • Posts: 469
    • LetTheLightIn
Re: ModernUI_Spinner Control
« Reply #43 on: July 22, 2019, 09:17:49 PM »
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.
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

My Github  Twitter

jj2007

  • Member
  • *****
  • Posts: 9804
  • Assembler is fun ;-)
    • MasmBasic
Re: ModernUI_Spinner Control
« Reply #44 on: July 22, 2019, 10:44:11 PM »
It's in Windows.inc, and the values are correct afaik. There is little difference between 2 and 4, though.
Code: [Select]
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 ;-)