Author Topic: Object-oriented programming (OOP) in Asmc  (Read 7760 times)

nidud

  • Member
  • *****
  • Posts: 2013
    • https://github.com/nidud/asmc
Re: Object-oriented programming (OOP) in Asmc
« Reply #45 on: October 07, 2020, 04:18:06 AM »
Simple Direct2D Application

  Draws shapes, text, and images with Direct2D.

This sample loads two images. One from disk and one from resource. However, the image is rather big (770K) so the app just download the image from the MS site instead. The first run will therefor take some time to load.

Files
SimpleDirect2dApplication.asm: Contains the application entry point and the implementation of the DemoApp class.
SimpleDirect2dApplication.inc: The header file for the DemoApp class.

Building the Sample

  To build the sample using the command prompt:

asmc64 -pe -ws -gui SimpleDirect2dApplication.asm

nidud

  • Member
  • *****
  • Posts: 2013
    • https://github.com/nidud/asmc
Re: Object-oriented programming (OOP) in Asmc
« Reply #46 on: October 12, 2020, 11:36:30 PM »
Direct2D Geometry Realization Sample

This sample shows how to use opacity masks and A8 targets to enhance performance for anti-aliased geometries. It also shows how to use meshes to enhance performance for aliased geometries.

Files
GeometryRealization.asm: Implements the IGeometryRealization interface.
GeometryRealization.inc: Defines the IGeometryRealization interface and related types.
GeometryRealizationSample.asm: Implements the DemoApp class, which creates a window and demonstrates the IGeometryRealization interface.
GeometryRealizationSample.inc: Defines the the DemoApp class.
RingBuffer.inc: The header file for the RingBuffer class. RingBuffer works like a standard array, except that when it fills up, data at the beginning is overwritten.
stdafx.inc: Defines standard system include files, or project specific include files that are used frequently, but are changed infrequently.

Building the Sample
Generate PE binary file:
  asmc64 -pe -Cs -ws -gui GeometryRealizationSample.asm
Using LINKW:
  asmc64 -q -ws -Cs GeometryRealization.asm
  asmc64 -q -ws -Cs GeometryRealizationSample.asm
  linkw system gui_64W file GeometryRealizationSample, GeometryRealization

Running the Sample
This sample uses the following controls:

  Up Arrow: Increases the number of primitives rendered
  Down Arrow: Decreases the number of primitives rendered
  Spacebar: Pauses/resumes the animation.
  Mouse Wheel: Zooms in and out.
  'T' key: Toggles between hardware and software rendering.
  'R' key: Toggles between rendering geometry with and without realizations.
  'A' key: Toggles between rendering modes.
  'S' key: Toggles Draw Stroke (outlines).
« Last Edit: October 13, 2020, 08:38:14 PM by nidud »

nidud

  • Member
  • *****
  • Posts: 2013
    • https://github.com/nidud/asmc
Re: Object-oriented programming (OOP) in Asmc
« Reply #47 on: October 17, 2020, 04:43:51 AM »
Direct2D List View Sample

This sample shows how to create and use a bitmap atlas to create and animate a list of items. The list view loads the files and directories from the current directory with the icons. The directories and files in the list view can be sorted in the alphabetical and reverse alphabetical order.

Files
ListViewSample.asm: Contains the application entry point and the implementation of the ListViewAppclass.
ListViewSample.inc: The header file for the ListViewApp class.

Running the Sample
Use the following keys to sort the list:

'A' key: sorts the list alphabetically.
'Z' Key: sorts the list in reverse alphabetical order.
'D' Key: sorts the list alphabetically with directories first.

Changes
Support for a second pointer added to INVOKE. This is added for accessing members of a class and static levels of functions in regular structures.

Example

.class ListViewApp

    m_pD2DFactory           LPID2D1Factory ?
    m_pWICFactory           LPIWICImagingFactory ?
    m_pDWriteFactory        LPIDWriteFactory ?
    m_pRT                   LPID2D1HwndRenderTarget ?
    m_pTextFormat           LPIDWriteTextFormat ?
    m_pBlackBrush           LPID2D1SolidColorBrush ?
    m_pBindContext          LPIBindCtx ?
    m_pBitmapAtlas          LPID2D1Bitmap ?

These pointers may now be accessed directly:

       .new dpiX:FLOAT
       .new dpiY:FLOAT

        this.m_pD2DFactory.GetDesktopDpi(&dpiX, &dpiY)
        this.m_pTextFormat.SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING)

It adds a move to resolve the pointer using RAX but the arguments are sorted before the call so there is no risk of trashing registers.

   *    lea r8, dpiY
   *    lea rdx, dpiX
   *    mov rax, this
   *    mov rcx, [rax].ListViewApp.m_pD2DFactory
   *    mov rax, [rcx]
   *    call [rax].ID2D1FactoryVtbl.GetDesktopDpi


nidud

  • Member
  • *****
  • Posts: 2013
    • https://github.com/nidud/asmc
Re: Object-oriented programming (OOP) in Asmc
« Reply #48 on: October 22, 2020, 02:14:51 AM »
Added some more of the mf headers and a console sample.

    mfapi.inc
    mferror.inc
    mfidl.inc
    mfobjects.inc
    mfreadwrite.inc
    mftransform.inc


AudioClip sample

Demonstrates using the IMFSourceReader API to get uncompressed media data from a media file. This sample application reads audio data from a media file and writes the uncompressed audio to a WAVE file.

Files
AudioClip.asm
« Last Edit: October 22, 2020, 12:25:48 PM by nidud »

nidud

  • Member
  • *****
  • Posts: 2013
    • https://github.com/nidud/asmc
Re: Object-oriented programming (OOP) in Asmc
« Reply #49 on: October 22, 2020, 12:27:20 PM »
Added mfplay.inc and a gui sample.

SimplePlay Sample

  Shows how to play a media file using the MFPlay API.

APIs Demonstrated
This sample demonstrates the following Microsoft Media Foundation interfaces:

  IMFPMediaItem
  IMFPMediaPlayer
  IMFPMediaPlayerCallback

Files
SimplePlay.asm

nidud

  • Member
  • *****
  • Posts: 2013
    • https://github.com/nidud/asmc
Re: Object-oriented programming (OOP) in Asmc
« Reply #50 on: November 14, 2020, 01:37:13 PM »
Extended the .pragma comment() directive to include direct linker configurations. The option /manifestdependency is also added to LINKW.

This option produce a manifest in the name.exe.manifest format.
.pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

UI Automation simple provider sample
This sample application creates a simple custom control that implements Microsoft UI Automation provider interfaces. By implementing these interfaces, assistive technologies such as screen readers can programmatically access information about the control and make the control accessible to users with disabilities.

The control is a simple custom button that supports the Invoke control pattern. Clicking the button causes it to change color. You can also tab to the button and click it by pressing the spacebar.

nidud

  • Member
  • *****
  • Posts: 2013
    • https://github.com/nidud/asmc
Re: Object-oriented programming (OOP) in Asmc
« Reply #51 on: November 15, 2020, 02:09:47 AM »
Added some small changes to the link directive.

The text passed to the linker may have multiple lines:

.pragma comment(linker,
    "/manifestdependency:\""
    "type='win32' "
    "name='Microsoft.Windows.Common-Controls' "
    "version='6.0.0.0' "
    "processorArchitecture='*' "
    "publicKeyToken='6595b64144ccf1df' "
    "language='*'"
    "\""
    )

Options stored in the .drectve section are separated by a space char so multiple options as above needs quotes.

Asmc adds the following to this section:

    -export:
    -import:
    -entry:
    -defaultlib:

LINKW support the above plus -manifestdependency:

The pragma directive should not include any spaces. Slash is allowed but converted to - in the output. This removes some warnings when LIBC is used with LINK.

.pragma comment(linker, "/merge:.CRT=.rdata")

nidud

  • Member
  • *****
  • Posts: 2013
    • https://github.com/nidud/asmc
Re: Object-oriented programming (OOP) in Asmc
« Reply #52 on: November 19, 2020, 09:36:59 AM »
Added assignment to .new name:type = value

    .new bGotMemory:BOOL = FALSE
    .new hDXGI:HINSTANCE = LoadLibrary( "dxgi.dll" )

A new sample using this feature from the DirectX-SDK-samples.

VideoMemory
Display the amount of available memory.

Files
VideoMemory.asm
VidMemViaD3D9.asm
VidMemViaDDraw.asm
VidMemViaDxDiag.asm
VidMemViaDXGI.asm
VidMemViaWMI.asm

nidud

  • Member
  • *****
  • Posts: 2013
    • https://github.com/nidud/asmc
Re: Object-oriented programming (OOP) in Asmc
« Reply #53 on: November 20, 2020, 05:48:48 AM »
Added a Tutorial from the DirectX-SDK.

Files
    - CreateDevice.asm
    - Vertices.asm
    - Matrices.asm
    - Lights.asm
    - Textures.asm
    - Meshes.asm