add flat assembler toolchain
This commit is contained in:
425
toolchain/fasmw17332/EXAMPLES/WIN64/MANDEL/DDRAW64.INC
Normal file
425
toolchain/fasmw17332/EXAMPLES/WIN64/MANDEL/DDRAW64.INC
Normal file
@ -0,0 +1,425 @@
|
||||
|
||||
; DirectDraw interface
|
||||
|
||||
interface DirectDraw,\
|
||||
QueryInterface,\
|
||||
AddRef,\
|
||||
Release,\
|
||||
Compact,\
|
||||
CreateClipper,\
|
||||
CreatePalette,\
|
||||
CreateSurface,\
|
||||
DuplicateSurface,\
|
||||
EnumDisplayModes,\
|
||||
EnumSurfaces,\
|
||||
FlipToGDISurface,\
|
||||
GetCaps,\
|
||||
GetDisplayMode,\
|
||||
GetFourCCCodes,\
|
||||
GetGDISurface,\
|
||||
GetMonitorFrequency,\
|
||||
GetScanLine,\
|
||||
GetVerticalBlankStatus,\
|
||||
Initialize,\
|
||||
RestoreDisplayMode,\
|
||||
SetCooperativeLevel,\
|
||||
SetDisplayMode,\
|
||||
WaitForVerticalBlank,\
|
||||
GetAvailableVidMem,\
|
||||
GetSurfaceFromDC,\
|
||||
RestoreAllSurfaces,\
|
||||
TestCooperativeLevel,\
|
||||
GetDeviceIdentifier,\
|
||||
StartModeTest,\
|
||||
EvaluateMode
|
||||
|
||||
interface DirectDrawSurface,\
|
||||
QueryInterface,\
|
||||
AddRef,\
|
||||
Release,\
|
||||
AddAttachedSurface,\
|
||||
AddOverlayDirtyRect,\
|
||||
Blt,\
|
||||
BltBatch,\
|
||||
BltFast,\
|
||||
DeleteAttachedSurface,\
|
||||
EnumAttachedSurfaces,\
|
||||
EnumOverlayZOrders,\
|
||||
Flip,\
|
||||
GetAttachedSurface,\
|
||||
GetBltStatus,\
|
||||
GetCaps,\
|
||||
GetClipper,\
|
||||
GetColorKey,\
|
||||
GetDC,\
|
||||
GetFlipStatus,\
|
||||
GetOverlayPosition,\
|
||||
GetPalette,\
|
||||
GetPixelFormat,\
|
||||
GetSurfaceDesc,\
|
||||
Initialize,\
|
||||
IsLost,\
|
||||
Lock,\
|
||||
ReleaseDC,\
|
||||
Restore,\
|
||||
SetClipper,\
|
||||
SetColorKey,\
|
||||
SetOverlayPosition,\
|
||||
SetPalette,\
|
||||
Unlock,\
|
||||
UpdateOverlay,\
|
||||
UpdateOverlayDisplay,\
|
||||
UpdateOverlayZOrder,\
|
||||
GetDDInterface,\
|
||||
PageLock,\
|
||||
PageUnlock,\
|
||||
SetSurfaceDesc,\
|
||||
SetPrivateData,\
|
||||
GetPrivateData,\
|
||||
FreePrivateData,\
|
||||
GetUniquenessValue,\
|
||||
ChangeUniquenessValue,\
|
||||
SetPriority,\
|
||||
GetPriority,\
|
||||
SetLOD,\
|
||||
GetLOD
|
||||
|
||||
interface DirectDrawPalette,\
|
||||
QueryInterface,\
|
||||
AddRef,\
|
||||
Release,\
|
||||
GetCaps,\
|
||||
GetEntries,\
|
||||
Initialize,\
|
||||
SetEntries
|
||||
|
||||
interface DirectDrawClipper,\
|
||||
QueryInterface,\
|
||||
AddRef,\
|
||||
Release,\
|
||||
GetClipList,\
|
||||
GetHWnd,\
|
||||
Initialize,\
|
||||
IsClipListChanged,\
|
||||
SetClipList,\
|
||||
SetHWnd
|
||||
|
||||
interface DirectDrawColorControl,\
|
||||
QueryInterface,\
|
||||
AddRef,\
|
||||
Release,\
|
||||
GetColorControls,\
|
||||
SetColorControls
|
||||
|
||||
interface DirectDrawGammaControl,\
|
||||
QueryInterface,\
|
||||
AddRef,\
|
||||
Release,\
|
||||
GetGammaRamp,\
|
||||
SetGammaRamp
|
||||
|
||||
struct DDCOLORKEY
|
||||
dwColorSpaceLowValue dd ?
|
||||
dwColorSpaceHighValue dd ?
|
||||
ends
|
||||
|
||||
struct DDPIXELFORMAT
|
||||
dwSize dd ?
|
||||
dwFlags dd ?
|
||||
dwFourCC dd ?
|
||||
union
|
||||
dwRGBBitCount dd ?
|
||||
dwYUVBitCount dd ?
|
||||
dwZBufferBitDepth dd ?
|
||||
dwAlphaBitDepth dd ?
|
||||
dwLuminanceBitCount dd ?
|
||||
dwBumpBitCount dd ?
|
||||
ends
|
||||
union
|
||||
dwRBitMask dd ?
|
||||
dwYBitMask dd ?
|
||||
dwStencilBitDepth dd ?
|
||||
dwLuminanceBitMask dd ?
|
||||
dwBumpDuBitMask dd ?
|
||||
ends
|
||||
union
|
||||
dwGBitMask dd ?
|
||||
dwUBitMask dd ?
|
||||
dwZBitMask dd ?
|
||||
dwBumpDvBitMask dd ?
|
||||
ends
|
||||
union
|
||||
dwBBitMask dd ?
|
||||
dwVBitMask dd ?
|
||||
dwStencilBitMask dd ?
|
||||
dwBumpLuminanceBitMask dd ?
|
||||
ends
|
||||
union
|
||||
dwRGBAlphaBitMask dd ?
|
||||
dwYUVAlphaBitMask dd ?
|
||||
dwLuminanceAlphaBitMask dd ?
|
||||
dwRGBZBitMask dd ?
|
||||
dwYUVZBitMask dd ?
|
||||
ends
|
||||
ends
|
||||
|
||||
struct DDSCAPS
|
||||
dwCaps dd ?
|
||||
ends
|
||||
|
||||
struct DDSURFACEDESC
|
||||
dwSize dd ?
|
||||
dwFlags dd ?
|
||||
dwHeight dd ?
|
||||
dwWidth dd ?
|
||||
union
|
||||
lPitch dd ?
|
||||
dwLinearSize dd ?
|
||||
ends
|
||||
dwBackBufferCount dd ?
|
||||
union
|
||||
dwMipMapCount dd ?
|
||||
dwZBufferBitDepth dd ?
|
||||
dwRefreshRate dd ?
|
||||
ends
|
||||
dwAlphaBitDepth dd ?
|
||||
dwReserved dd ?,?
|
||||
lpSurface dq ?
|
||||
ddckCKDestOverlay DDCOLORKEY
|
||||
ddckCKDestBlt DDCOLORKEY
|
||||
ddckCKSrcOverlay DDCOLORKEY
|
||||
ddckCKSrcBlt DDCOLORKEY
|
||||
ddpfPixelFormat DDPIXELFORMAT
|
||||
ddsCaps DDSCAPS
|
||||
dd ?
|
||||
ends
|
||||
|
||||
; SetCooperativeLevel flags
|
||||
|
||||
DDSCL_FULLSCREEN = 000000001h
|
||||
DDSCL_ALLOWREBOOT = 000000002h
|
||||
DDSCL_NOWINDOWCHANGES = 000000004h
|
||||
DDSCL_NORMAL = 000000008h
|
||||
DDSCL_EXCLUSIVE = 000000010h
|
||||
DDSCL_ALLOWMODEX = 000000040h
|
||||
|
||||
; Blt flags
|
||||
|
||||
DDBLT_ALPHADEST = 000000001h
|
||||
DDBLT_ALPHADESTCONSTOVERRIDE = 000000002h
|
||||
DDBLT_ALPHADESTNEG = 000000004h
|
||||
DDBLT_ALPHADESTSURFACEOVERRIDE = 000000008h
|
||||
DDBLT_ALPHAEDGEBLEND = 000000010h
|
||||
DDBLT_ALPHASRC = 000000020h
|
||||
DDBLT_ALPHASRCCONSTOVERRIDE = 000000040h
|
||||
DDBLT_ALPHASRCNEG = 000000080h
|
||||
DDBLT_ALPHASRCSURFACEOVERRIDE = 000000100h
|
||||
DDBLT_ASYNC = 000000200h
|
||||
DDBLT_COLORFILL = 000000400h
|
||||
DDBLT_DDFX = 000000800h
|
||||
DDBLT_DDROPS = 000001000h
|
||||
DDBLT_KEYDEST = 000002000h
|
||||
DDBLT_KEYDESTOVERRIDE = 000004000h
|
||||
DDBLT_KEYSRC = 000008000h
|
||||
DDBLT_KEYSRCOVERRIDE = 000010000h
|
||||
DDBLT_ROP = 000020000h
|
||||
DDBLT_ROTATIONANGLE = 000040000h
|
||||
DDBLT_ZBUFFER = 000080000h
|
||||
DDBLT_ZBUFFERDESTCONSTOVERRIDE = 000100000h
|
||||
DDBLT_ZBUFFERDESTOVERRIDE = 000200000h
|
||||
DDBLT_ZBUFFERSRCCONSTOVERRIDE = 000400000h
|
||||
DDBLT_ZBUFFERSRCOVERRIDE = 000800000h
|
||||
DDBLT_WAIT = 001000000h
|
||||
DDBLT_DEPTHFILL = 002000000h
|
||||
|
||||
; BltFast flags
|
||||
|
||||
DDBLTFAST_NOCOLORKEY = 000000000h
|
||||
DDBLTFAST_SRCCOLORKEY = 000000001h
|
||||
DDBLTFAST_DESTCOLORKEY = 000000002h
|
||||
DDBLTFAST_WAIT = 000000010h
|
||||
|
||||
; Flip flags
|
||||
|
||||
DDFLIP_WAIT = 000000001h
|
||||
DDFLIP_EVEN = 000000002h
|
||||
DDFLIP_ODD = 000000004h
|
||||
|
||||
; DDSURFACEDESC field flags
|
||||
|
||||
DDSD_CAPS = 000000001h
|
||||
DDSD_HEIGHT = 000000002h
|
||||
DDSD_WIDTH = 000000004h
|
||||
DDSD_PITCH = 000000008h
|
||||
DDSD_BACKBUFFERCOUNT = 000000020h
|
||||
DDSD_ZBUFFERBITDEPTH = 000000040h
|
||||
DDSD_ALPHABITDEPTH = 000000080h
|
||||
DDSD_LPSURFACE = 000000800h
|
||||
DDSD_PIXELFORMAT = 000001000h
|
||||
DDSD_CKDESTOVERLAY = 000002000h
|
||||
DDSD_CKDESTBLT = 000004000h
|
||||
DDSD_CKSRCOVERLAY = 000008000h
|
||||
DDSD_CKSRCBLT = 000010000h
|
||||
DDSD_MIPMAPCOUNT = 000020000h
|
||||
DDSD_REFRESHRATE = 000040000h
|
||||
DDSD_LINEARSIZE = 000080000h
|
||||
DDSD_ALL = 0000FF9EEh
|
||||
|
||||
; DirectDrawSurface capability flags
|
||||
|
||||
DDSCAPS_RESERVED1 = 000000001h
|
||||
DDSCAPS_ALPHA = 000000002h
|
||||
DDSCAPS_BACKBUFFER = 000000004h
|
||||
DDSCAPS_COMPLEX = 000000008h
|
||||
DDSCAPS_FLIP = 000000010h
|
||||
DDSCAPS_FRONTBUFFER = 000000020h
|
||||
DDSCAPS_OFFSCREENPLAIN = 000000040h
|
||||
DDSCAPS_OVERLAY = 000000080h
|
||||
DDSCAPS_PALETTE = 000000100h
|
||||
DDSCAPS_PRIMARYSURFACE = 000000200h
|
||||
DDSCAPS_PRIMARYSURFACELEFT = 000000400h
|
||||
DDSCAPS_SYSTEMMEMORY = 000000800h
|
||||
DDSCAPS_TEXTURE = 000001000h
|
||||
DDSCAPS_3DDEVICE = 000002000h
|
||||
DDSCAPS_VIDEOMEMORY = 000004000h
|
||||
DDSCAPS_VISIBLE = 000008000h
|
||||
DDSCAPS_WRITEONLY = 000010000h
|
||||
DDSCAPS_ZBUFFER = 000020000h
|
||||
DDSCAPS_OWNDC = 000040000h
|
||||
DDSCAPS_LIVEVIDEO = 000080000h
|
||||
DDSCAPS_HWCODEC = 000100000h
|
||||
DDSCAPS_MODEX = 000200000h
|
||||
DDSCAPS_MIPMAP = 000400000h
|
||||
DDSCAPS_RESERVED2 = 000800000h
|
||||
DDSCAPS_ALLOCONLOAD = 004000000h
|
||||
DDSCAPS_VIDEOPORT = 008000000h
|
||||
DDSCAPS_LOCALVIDMEM = 010000000h
|
||||
DDSCAPS_NONLOCALVIDMEM = 020000000h
|
||||
DDSCAPS_STANDARDVGAMODE = 040000000h
|
||||
DDSCAPS_OPTIMIZED = 080000000h
|
||||
|
||||
; DirectDrawSurface lock flags
|
||||
|
||||
DDLOCK_SURFACEMEMORYPTR = 000000000h
|
||||
DDLOCK_WAIT = 000000001h
|
||||
DDLOCK_EVENT = 000000002h
|
||||
DDLOCK_READONLY = 000000010h
|
||||
DDLOCK_WRITEONLY = 000000020h
|
||||
DDLOCK_NOSYSLOCK = 000000800h
|
||||
|
||||
; DirectDrawPalette capabilities
|
||||
|
||||
DDPCAPS_4BIT = 000000001h
|
||||
DDPCAPS_8BITENTRIES = 000000002h
|
||||
DDPCAPS_8BIT = 000000004h
|
||||
DDPCAPS_INITIALIZE = 000000008h
|
||||
DDPCAPS_PRIMARYSURFACE = 000000010h
|
||||
DDPCAPS_PRIMARYSURFACELEFT = 000000020h
|
||||
DDPCAPS_ALLOW256 = 000000040h
|
||||
DDPCAPS_VSYNC = 000000080h
|
||||
DDPCAPS_1BIT = 000000100h
|
||||
DDPCAPS_2BIT = 000000200h
|
||||
|
||||
; DirectDraw errors
|
||||
|
||||
DDERR_ALREADYINITIALIZED = 088760000h+5
|
||||
DDERR_CANNOTATTACHSURFACE = 088760000h+10
|
||||
DDERR_CANNOTDETACHSURFACE = 088760000h+20
|
||||
DDERR_CURRENTLYNOTAVAIL = 088760000h+40
|
||||
DDERR_EXCEPTION = 088760000h+55
|
||||
DDERR_HEIGHTALIGN = 088760000h+90
|
||||
DDERR_INCOMPATIBLEPRIMARY = 088760000h+95
|
||||
DDERR_INVALIDCAPS = 088760000h+100
|
||||
DDERR_INVALIDCLIPLIST = 088760000h+110
|
||||
DDERR_INVALIDMODE = 088760000h+120
|
||||
DDERR_INVALIDOBJECT = 088760000h+130
|
||||
DDERR_INVALIDPIXELFORMAT = 088760000h+145
|
||||
DDERR_INVALIDRECT = 088760000h+150
|
||||
DDERR_LOCKEDSURFACES = 088760000h+160
|
||||
DDERR_NO3D = 088760000h+170
|
||||
DDERR_NOALPHAHW = 088760000h+180
|
||||
DDERR_NOCLIPLIST = 088760000h+205
|
||||
DDERR_NOCOLORCONVHW = 088760000h+210
|
||||
DDERR_NOCOOPERATIVELEVELSET = 088760000h+212
|
||||
DDERR_NOCOLORKEY = 088760000h+215
|
||||
DDERR_NOCOLORKEYHW = 088760000h+220
|
||||
DDERR_NODIRECTDRAWSUPPORT = 088760000h+222
|
||||
DDERR_NOEXCLUSIVEMODE = 088760000h+225
|
||||
DDERR_NOFLIPHW = 088760000h+230
|
||||
DDERR_NOGDI = 088760000h+240
|
||||
DDERR_NOMIRRORHW = 088760000h+250
|
||||
DDERR_NOTFOUND = 088760000h+255
|
||||
DDERR_NOOVERLAYHW = 088760000h+260
|
||||
DDERR_NORASTEROPHW = 088760000h+280
|
||||
DDERR_NOROTATIONHW = 088760000h+290
|
||||
DDERR_NOSTRETCHHW = 088760000h+310
|
||||
DDERR_NOT4BITCOLOR = 088760000h+316
|
||||
DDERR_NOT4BITCOLORINDEX = 088760000h+317
|
||||
DDERR_NOT8BITCOLOR = 088760000h+320
|
||||
DDERR_NOTEXTUREHW = 088760000h+330
|
||||
DDERR_NOVSYNCHW = 088760000h+335
|
||||
DDERR_NOZBUFFERHW = 088760000h+340
|
||||
DDERR_NOZOVERLAYHW = 088760000h+350
|
||||
DDERR_OUTOFCAPS = 088760000h+360
|
||||
DDERR_OUTOFVIDEOMEMORY = 088760000h+380
|
||||
DDERR_OVERLAYCANTCLIP = 088760000h+382
|
||||
DDERR_OVERLAYCOLORKEYONLYONEACTI = 088760000h+384
|
||||
DDERR_PALETTEBUSY = 088760000h+387
|
||||
DDERR_COLORKEYNOTSET = 088760000h+400
|
||||
DDERR_SURFACEALREADYATTACHED = 088760000h+410
|
||||
DDERR_SURFACEALREADYDEPENDENT = 088760000h+420
|
||||
DDERR_SURFACEBUSY = 088760000h+430
|
||||
DDERR_CANTLOCKSURFACE = 088760000h+435
|
||||
DDERR_SURFACEISOBSCURED = 088760000h+440
|
||||
DDERR_SURFACELOST = 088760000h+450
|
||||
DDERR_SURFACENOTATTACHED = 088760000h+460
|
||||
DDERR_TOOBIGHEIGHT = 088760000h+470
|
||||
DDERR_TOOBIGSIZE = 088760000h+480
|
||||
DDERR_TOOBIGWIDTH = 088760000h+490
|
||||
DDERR_UNSUPPORTEDFORMAT = 088760000h+510
|
||||
DDERR_UNSUPPORTEDMASK = 088760000h+520
|
||||
DDERR_VERTICALBLANKINPROGRESS = 088760000h+537
|
||||
DDERR_WASSTILLDRAWING = 088760000h+540
|
||||
DDERR_XALIGN = 088760000h+560
|
||||
DDERR_INVALIDDIRECTDRAWGUID = 088760000h+561
|
||||
DDERR_DIRECTDRAWALREADYCREATED = 088760000h+562
|
||||
DDERR_NODIRECTDRAWHW = 088760000h+563
|
||||
DDERR_PRIMARYSURFACEALREADYEXIST = 088760000h+564
|
||||
DDERR_NOEMULATION = 088760000h+565
|
||||
DDERR_REGIONTOOSMALL = 088760000h+566
|
||||
DDERR_CLIPPERISUSINGHWND = 088760000h+567
|
||||
DDERR_NOCLIPPERATTACHED = 088760000h+568
|
||||
DDERR_NOHWND = 088760000h+569
|
||||
DDERR_HWNDSUBCLASSED = 088760000h+570
|
||||
DDERR_HWNDALREADYSET = 088760000h+571
|
||||
DDERR_NOPALETTEATTACHED = 088760000h+572
|
||||
DDERR_NOPALETTEHW = 088760000h+573
|
||||
DDERR_BLTFASTCANTCLIP = 088760000h+574
|
||||
DDERR_NOBLTHW = 088760000h+575
|
||||
DDERR_NODDROPSHW = 088760000h+576
|
||||
DDERR_OVERLAYNOTVISIBLE = 088760000h+577
|
||||
DDERR_NOOVERLAYDEST = 088760000h+578
|
||||
DDERR_INVALIDPOSITION = 088760000h+579
|
||||
DDERR_NOTAOVERLAYSURFACE = 088760000h+580
|
||||
DDERR_EXCLUSIVEMODEALREADYSET = 088760000h+581
|
||||
DDERR_NOTFLIPPABLE = 088760000h+582
|
||||
DDERR_CANTDUPLICATE = 088760000h+583
|
||||
DDERR_NOTLOCKED = 088760000h+584
|
||||
DDERR_CANTCREATEDC = 088760000h+585
|
||||
DDERR_NODC = 088760000h+586
|
||||
DDERR_WRONGMODE = 088760000h+587
|
||||
DDERR_IMPLICITLYCREATED = 088760000h+588
|
||||
DDERR_NOTPALETTIZED = 088760000h+589
|
||||
DDERR_UNSUPPORTEDMODE = 088760000h+590
|
||||
DDERR_NOMIPMAPHW = 088760000h+591
|
||||
DDERR_INVALIDSURFACETYPE = 088760000h+592
|
||||
DDERR_NOOPTIMIZEHW = 088760000h+600
|
||||
DDERR_NOTLOADED = 088760000h+601
|
||||
DDERR_DCALREADYCREATED = 088760000h+620
|
||||
DDERR_NONONLOCALVIDMEM = 088760000h+630
|
||||
DDERR_CANTPAGELOCK = 088760000h+640
|
||||
DDERR_CANTPAGEUNLOCK = 088760000h+660
|
||||
DDERR_NOTPAGELOCKED = 088760000h+680
|
||||
DDERR_MOREDATA = 088760000h+690
|
||||
DDERR_VIDEONOTACTIVE = 088760000h+695
|
||||
DDERR_DEVICEDOESNTOWNSURFACE = 088760000h+699
|
319
toolchain/fasmw17332/EXAMPLES/WIN64/MANDEL/MANDEL.ASM
Normal file
319
toolchain/fasmw17332/EXAMPLES/WIN64/MANDEL/MANDEL.ASM
Normal file
@ -0,0 +1,319 @@
|
||||
|
||||
format PE64 GUI 5.0
|
||||
entry start
|
||||
|
||||
include 'win64a.inc'
|
||||
include 'ddraw64.inc'
|
||||
|
||||
section '.text' code readable executable
|
||||
|
||||
start:
|
||||
|
||||
sub rsp,8
|
||||
|
||||
and [DDraw],0
|
||||
and [DDSPrimary],0
|
||||
and [DDSBack],0
|
||||
|
||||
invoke GetModuleHandle,NULL
|
||||
mov [hinstance],rax
|
||||
mov [wc.hInstance],rax
|
||||
|
||||
invoke LoadIcon,NULL,IDI_APPLICATION
|
||||
mov [wc.hIcon],rax
|
||||
invoke LoadCursor,NULL,IDC_ARROW
|
||||
mov [wc.hCursor],rax
|
||||
invoke RegisterClassEx,wc
|
||||
test rax,rax
|
||||
jz startup_error
|
||||
|
||||
invoke CreateWindowEx,\
|
||||
0,_class,_title,WS_POPUP+WS_VISIBLE,0,0,0,0,NULL,NULL,[hinstance],NULL
|
||||
test rax,rax
|
||||
jz startup_error
|
||||
mov [hwnd],rax
|
||||
|
||||
invoke DirectDrawCreate,NULL,DDraw,NULL
|
||||
test rax,rax
|
||||
jnz ddraw_error
|
||||
|
||||
cominvk DDraw,SetCooperativeLevel,\
|
||||
[hwnd],DDSCL_EXCLUSIVE+DDSCL_FULLSCREEN
|
||||
test rax,rax
|
||||
jnz ddraw_error
|
||||
|
||||
cominvk DDraw,SetDisplayMode,\
|
||||
640,480,32
|
||||
test rax,rax
|
||||
jnz ddraw_error
|
||||
|
||||
mov [ddsd.dwSize],sizeof.DDSURFACEDESC
|
||||
mov [ddsd.dwFlags],DDSD_CAPS+DDSD_BACKBUFFERCOUNT
|
||||
mov [ddsd.ddsCaps.dwCaps],DDSCAPS_PRIMARYSURFACE+DDSCAPS_FLIP+DDSCAPS_COMPLEX
|
||||
mov [ddsd.dwBackBufferCount],1
|
||||
cominvk DDraw,CreateSurface,\
|
||||
ddsd,DDSPrimary,NULL
|
||||
or eax,eax
|
||||
jnz ddraw_error
|
||||
|
||||
mov [ddscaps.dwCaps],DDSCAPS_BACKBUFFER
|
||||
cominvk DDSPrimary,GetAttachedSurface,\
|
||||
ddscaps,DDSBack
|
||||
or eax,eax
|
||||
jnz ddraw_error
|
||||
|
||||
refresh:
|
||||
|
||||
cominvk DDSPrimary,IsLost
|
||||
test rax,rax
|
||||
jz paint
|
||||
cmp eax,DDERR_SURFACELOST
|
||||
jne end_loop
|
||||
cominvk DDSPrimary,Restore
|
||||
|
||||
paint:
|
||||
mov [ddsd.dwSize],sizeof.DDSURFACEDESC
|
||||
mov [ddsd.dwFlags],0
|
||||
cominvk DDSBack,Lock,NULL,ddsd,DDLOCK_SURFACEMEMORYPTR+DDLOCK_WAIT,NULL
|
||||
test rax,rax
|
||||
jnz main_loop
|
||||
mov rdi,[ddsd.lpSurface]
|
||||
mov r10d,[ddsd.lPitch]
|
||||
xor edx,edx
|
||||
movsd xmm8,[y_top]
|
||||
screen:
|
||||
xor ebx,ebx
|
||||
movsd xmm7,[x_left]
|
||||
unpcklpd xmm7,xmm8
|
||||
row:
|
||||
mov rcx,255
|
||||
xorpd xmm1,xmm1
|
||||
iterate:
|
||||
|
||||
movapd xmm3,xmm1
|
||||
unpckhpd xmm3,xmm3
|
||||
mulsd xmm3,xmm1
|
||||
addsd xmm3,xmm3
|
||||
|
||||
mulpd xmm1,xmm1
|
||||
movapd xmm2,xmm1 ; for SSE3-capable processor
|
||||
unpckhpd xmm2,xmm2 ; these three instructions can be
|
||||
subsd xmm1,xmm2 ; replaced with HSUBPD XMM1,XMM1
|
||||
unpcklpd xmm1,xmm3
|
||||
addpd xmm1,xmm7
|
||||
|
||||
movapd xmm0,xmm1
|
||||
mulpd xmm0,xmm0
|
||||
movapd xmm2,xmm0 ; for SSE3-capable processor
|
||||
shufpd xmm2,xmm2,1 ; these three instructions can be
|
||||
addsd xmm0,xmm2 ; replaced with HADDPD XMM0,XMM0
|
||||
sqrtpd xmm0,xmm0
|
||||
comisd xmm0,[limit]
|
||||
ja over
|
||||
|
||||
loop iterate
|
||||
over:
|
||||
xor al,al
|
||||
stosb
|
||||
mov al,cl
|
||||
stosb
|
||||
ror al,3
|
||||
stosb
|
||||
stosb
|
||||
|
||||
movsd xmm0,[x_step]
|
||||
addpd xmm7,xmm0
|
||||
inc ebx
|
||||
cmp ebx,640
|
||||
jb row
|
||||
sub rdi,640*4
|
||||
add rdi,r10
|
||||
subsd xmm8,[y_step]
|
||||
inc edx
|
||||
cmp edx,480
|
||||
jb screen
|
||||
|
||||
mov [refresh_needed],0
|
||||
cominvk DDSBack,Unlock,NULL
|
||||
cominvk DDSPrimary,Flip,0,0
|
||||
|
||||
main_loop:
|
||||
|
||||
invoke PeekMessage,msg,NULL,0,0,PM_NOREMOVE
|
||||
or eax,eax
|
||||
jz no_message
|
||||
invoke GetMessage,msg,NULL,0,0
|
||||
cmp eax,1
|
||||
jb end_loop
|
||||
jne no_message
|
||||
invoke TranslateMessage,msg
|
||||
invoke DispatchMessage,msg
|
||||
|
||||
cmp [refresh_needed],0
|
||||
jne refresh
|
||||
|
||||
jmp main_loop
|
||||
|
||||
no_message:
|
||||
invoke WaitMessage
|
||||
jmp main_loop
|
||||
|
||||
ddraw_error:
|
||||
invoke wsprintf,buffer,_ddraw_error,rax
|
||||
invoke MessageBox,[hwnd],buffer,_error,MB_OK+MB_ICONERROR
|
||||
invoke DestroyWindow,[hwnd]
|
||||
invoke PostQuitMessage,2
|
||||
jmp main_loop
|
||||
|
||||
startup_error:
|
||||
invoke MessageBox,[hwnd],_startup_error,_error,MB_OK+MB_ICONERROR
|
||||
invoke ExitProcess,1
|
||||
|
||||
end_loop:
|
||||
cominvk DDraw,RestoreDisplayMode
|
||||
|
||||
cmp [DDSBack],0
|
||||
je back_surface_released
|
||||
cominvk DDSPrimary,DeleteAttachedSurface,0,DDSBack
|
||||
back_surface_released:
|
||||
cmp [DDSPrimary],0
|
||||
je primary_surface_released
|
||||
cominvk DDSPrimary,Release
|
||||
primary_surface_released:
|
||||
cmp [DDraw],0
|
||||
je ddraw_released
|
||||
cominvk DDraw,Release
|
||||
ddraw_released:
|
||||
|
||||
invoke ExitProcess,[msg.wParam]
|
||||
|
||||
proc WindowProc uses rbx rsi rdi, hwnd,wmsg,wparam,lparam
|
||||
cmp edx,WM_CREATE
|
||||
je .wmcreate
|
||||
cmp edx,WM_DESTROY
|
||||
je .wmdestroy
|
||||
cmp edx,WM_LBUTTONDOWN
|
||||
je .wmlbuttondown
|
||||
cmp edx,WM_RBUTTONDOWN
|
||||
je .wmrbuttondown
|
||||
cmp edx,WM_KEYDOWN
|
||||
je .wmkeydown
|
||||
cmp edx,WM_ACTIVATE
|
||||
je .wmactivate
|
||||
.defwindowproc:
|
||||
invoke DefWindowProc,rcx,rdx,r8,r9
|
||||
jmp .finish
|
||||
.wmcreate:
|
||||
xor eax,eax
|
||||
jmp .finish
|
||||
.wmactivate:
|
||||
test r8,r8
|
||||
jz .finish
|
||||
or [refresh_needed],1
|
||||
jmp .finish
|
||||
.wmlbuttondown:
|
||||
movapd xmm0,[step]
|
||||
divpd xmm0,[zoom]
|
||||
movapd xmm1,xmm0
|
||||
subpd xmm1,[step]
|
||||
movapd [step],xmm0
|
||||
movzx eax,r9w
|
||||
cvtsi2sd xmm3,eax
|
||||
shr r9,16
|
||||
movzx eax,r9w
|
||||
cvtsi2sd xmm4,eax
|
||||
unpcklpd xmm3,xmm4
|
||||
mulpd xmm1,xmm3
|
||||
xorpd xmm1,[negate]
|
||||
addpd xmm1,[origin]
|
||||
movapd [origin],xmm1
|
||||
or [refresh_needed],1
|
||||
jmp .finish
|
||||
.wmrbuttondown:
|
||||
movapd xmm0,[step]
|
||||
mulpd xmm0,[zoom]
|
||||
movapd xmm1,xmm0
|
||||
subpd xmm1,[step]
|
||||
movapd [step],xmm0
|
||||
movzx eax,r9w
|
||||
cvtsi2sd xmm3,eax
|
||||
shr r9,16
|
||||
movzx eax,r9w
|
||||
cvtsi2sd xmm4,eax
|
||||
unpcklpd xmm3,xmm4
|
||||
mulpd xmm1,xmm3
|
||||
xorpd xmm1,[negate]
|
||||
addpd xmm1,[origin]
|
||||
movapd [origin],xmm1
|
||||
or [refresh_needed],1
|
||||
jmp .finish
|
||||
.wmkeydown:
|
||||
cmp r8d,VK_ESCAPE
|
||||
jne .finish
|
||||
.wmdestroy:
|
||||
invoke PostQuitMessage,0
|
||||
xor eax,eax
|
||||
.finish:
|
||||
ret
|
||||
endp
|
||||
|
||||
section '.data' data readable writeable
|
||||
|
||||
wc WNDCLASSEX sizeof.WNDCLASSEX,0,WindowProc,0,0,NULL,NULL,NULL,NULL,NULL,_class,NULL
|
||||
|
||||
_title db 'flat assembler DirectDraw application',0
|
||||
_class db 'FDDRAW64',0
|
||||
|
||||
_error db 'Error',0
|
||||
_startup_error db 'Startup failed',0
|
||||
_ddraw_error db 'Direct Draw initialization failed (error code 0x%x).',0
|
||||
|
||||
align 16 ; SSE data follows
|
||||
|
||||
label origin dqword
|
||||
x_left dq -2.2
|
||||
y_top dq 1.25
|
||||
|
||||
label step dqword
|
||||
x_step dq 0.0045
|
||||
y_step dq 0.0052
|
||||
|
||||
label zoom dqword
|
||||
dq 1.2,1.2
|
||||
|
||||
label negate dqword
|
||||
dq 8000000000000000h,0
|
||||
|
||||
limit dq 2.5
|
||||
|
||||
section '.bss' readable writeable
|
||||
|
||||
hinstance dq ?
|
||||
hwnd dq ?
|
||||
msg MSG
|
||||
|
||||
ddsd DDSURFACEDESC
|
||||
ddscaps DDSCAPS
|
||||
|
||||
DDraw DirectDraw
|
||||
DDSPrimary DirectDrawSurface
|
||||
DDSBack DirectDrawSurface
|
||||
|
||||
rect RECT
|
||||
|
||||
refresh_needed dd ?
|
||||
|
||||
buffer rb 100h
|
||||
|
||||
|
||||
section '.idata' import data readable
|
||||
|
||||
library kernel32,'KERNEL32.DLL',\
|
||||
user32,'USER32.DLL',\
|
||||
ddraw,'DDRAW.DLL'
|
||||
|
||||
include 'api\kernel32.inc'
|
||||
include 'api\user32.inc'
|
||||
|
||||
import ddraw,\
|
||||
DirectDrawCreate,'DirectDrawCreate'
|
Reference in New Issue
Block a user