flat assembler
Message board for the users of flat assembler.
Index
> Windows > Quaternion Julia Sets rendering in 1020-bytes executable |
Author |
|
randall 16 May 2019, 19:20
x86 assembly (using fasm of course) + GLSL.
Requires decent GPU and OpenGL 4.1 driver. https://github.com/michal-z/1kdemo |
|||
16 May 2019, 19:20 |
|
randall 17 May 2019, 13:07
bitRAKE wrote: Thank you for including all the dependencies - makes playing with it much easier. Thanks for looking at it and for the suggestions! |
|||
17 May 2019, 13:07 |
|
bitRAKE 18 May 2019, 00:55
Another, quite hacky method I tried:
Code: format MS COFF extrn '__imp__ExitProcess@4' as ExitProcess:dword extrn '__imp__CreateWindowExA@48' as CreateWindowEx:dword extrn '__imp__SetPixelFormat@12' as SetPixelFormat:dword extrn '__imp__ChoosePixelFormat@8' as ChoosePixelFormat:dword extrn '__imp__ShowCursor@4' as ShowCursor:dword extrn '__imp__GetDC@4' as GetDC:dword extrn '__imp__GetAsyncKeyState@4' as GetAsyncKeyState:dword extrn '__imp__PeekMessageA@20' as PeekMessage:dword extrn '__imp__DispatchMessageA@4' as DispatchMessage:dword extrn '__imp__timeGetTime@0' as timeGetTime:dword extrn '__imp__timeBeginPeriod@4' as timeBeginPeriod:dword extrn '__imp__SwapBuffers@4' as SwapBuffers:dword extrn '__imp__ChangeDisplaySettingsA@8' as ChangeDisplaySettings:dword extrn '__imp__wglMakeCurrent@8' as wglMakeCurrent:dword extrn '__imp__wglCreateContext@4' as wglCreateContext:dword extrn '__imp__wglGetProcAddress@4' as wglGetProcAddress:dword extrn '__imp__glRecti@16' as glRecti:dword extrn '__imp__glTexCoord1f@4' as glTexCoord1f:dword extrn '__imp__SetProcessDPIAware@0' as SetProcessDPIAware:dword section '.text' code readable executable writeable _Start: call __Start dd ScreenSettings dd 4 ; CDS_FULLSCREEN dd 0 ; dwExStyle dd S.WinClassName ; lpClassName dd 0 ; lpWindowName dd 91000000h ; dwStyle = WS_POPUP|WS_VISIBLE|WS_MAXIMIZE dd 0 ; x dd 0 ; y dd 0 ; nWidth dd 0 ; nHeight dd 0 ; hWndParent dd 0 ; hMenu dd 0 ; hInstance dd 0 ; lpParam dd PixelFormatDesc dd PixelFormatDesc dd 0 ; for ShowCursor dd S.glUseProgram dd S.glCreateShaderProgramv dd 8B30h ; GL_FRAGMENT_SHADER dd 1 dd ShaderCodePtr dd 1 ; ask for 1 ms timer resolution rd 2 Message: PixelFormatDesc: dd 0 dd 00000021h ; PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER ScreenSettings: db 32 dup 0 dd 0 dw .size dw 0 dd 001C0000h ; DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL db 60 dup 0 dd 32,1920,1080 dd 11 dup 0 .size = $-ScreenSettings ShaderCodePtr dd ShaderCode ShaderCode: file '1kdemo-small.glsl' db 0 S.WinClassName db 'edit',0 S.glCreateShaderProgramv db 'glCreateShaderProgramv',0 S.glUseProgram db 'glUseProgram',0 reg_hDC equ ebx reg_Prg equ esi reg_Time equ edi public _Start __Start: pop esp call [ChangeDisplaySettings] call [SetProcessDPIAware] call [CreateWindowEx] push eax ; hwnd call [GetDC] push eax ; hdc mov reg_hDC,eax call [ChoosePixelFormat] push eax ; pixel format id push reg_hDC call [SetPixelFormat] push reg_hDC call [wglCreateContext] push eax ; GL context push reg_hDC call [wglMakeCurrent] call [ShowCursor] call [wglGetProcAddress] mov reg_Prg,eax ; pointer to glUseProgram call [wglGetProcAddress] call eax ; glCreateShaderProgramv push eax ; GL program to use call reg_Prg ; glUseProgram call [timeBeginPeriod] call [timeGetTime] mov reg_Time,eax ; beginTime .mainLoop: push 1 ; PM_REMOVE push 0 push 0 push 0 push Message call [PeekMessage] call [timeGetTime] sub eax,reg_Time ; currentTime = time - beginTime push eax fild dword [esp] fstp dword [esp] call [glTexCoord1f] push 1 push 1 push -1 push -1 call [glRecti] push reg_hDC call [SwapBuffers] push 27 ; VK_ESCAPE call [GetAsyncKeyState] xchg ecx,eax jecxz .mainLoop ; no error code? call [ExitProcess] 32-bit stack calling has so much flexibility. I did shave some bytes off the shader, though. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
18 May 2019, 00:55 |
|
comrade 18 May 2019, 05:59
Very cool!
|
|||
18 May 2019, 05:59 |
|
macgub 27 May 2019, 17:39
Nice !
@randall If you want you may do animation posibilities: zoom +/-, rotating etc.. Like tthsqe done for Mandelbrotset 2d (see section examples of fasm site). But code of app will be bit larger... And also working in current resolution will be welcome (not all machines are full hd) . Just a few suggestions ... Anyway good luck |
|||
27 May 2019, 17:39 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.