Ok, here it is another demo. Fullscreen, escape (and finish the program) with the esc key. Made with a nice model from DAYDREAMER. .exe attached.
Special notes: I was having the approach of test the directx 9 functions (of course just a few of them) and the include files (provided from Siekmanski) and then sharing here the results. That's why the code is not too much commented (sorry). Now i think i will start a game, so i will (hopefully) take some time and upload the game and the source code (well commented) when i finish. :icon14:
DAYDREAMER: Do you see this baby moving in your screen in a future? Maybe you should try it! :greensml:
.686
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\d3dx9.lib
include \masm32\include\DX9Includes\d3d9.inc
include \masm32\include\DX9Includes\d3DX9.inc
SCREEN_WIDTH equ 1024 ; Kind of old standard
SCREEN_HEIGHT equ 768 ; resolution.
.data
align 1
class_name byte "game class",0
wnd_name byte "DAYDREAMER'S AIR FORCE",0
d3d9_lib byte "d3d9.dll",0
dx9func0 byte "Direct3DCreate9",0
the_model byte "MIG31.jpg",0 ; Daydreamer's air force model.
align 4
float4 dword 1.0
.data?
align 4
hinstance dword ?
hwindow dword ?
bye dword ?
hdll dword ?
proc_add dword ?
inter_add dword ?
d3dpp D3DPRESENT_PARAMETERS <?>
d3ddev dword ?
backbuffer dword ?
surface dword ?
result dword ?
.code
align 4
start:
push ebp
mov ebp,esp
push NULL ; Get a handle for the program instance.
call GetModuleHandle
mov hinstance,eax
sub esp,76 ; WNDCLASSEX and MSG.
mov dword ptr[ebp-48],48 ; The size of the structure.
mov dword ptr[ebp-44],CS_HREDRAW or CS_VREDRAW ; The style of the class.
mov [ebp-40],wndproc
mov dword ptr[ebp-36],0 ; No extra
mov dword ptr[ebp-32],0 ; bytes.
mov eax,hinstance
mov [ebp-28],eax
push 500
push eax
call LoadIcon
mov [ebp-24],eax
push IDC_ARROW ; The system cursor.
push NULL
call LoadCursor
mov [ebp-20],eax ; hCursor.
push WHITE_BRUSH ; Typical background color for a window.
call GetStockObject ; Get the handle of the brush.
mov [ebp-16],eax ; hBrush.
mov dword ptr[ebp-12],NULL ; No menu.
mov [ebp-8],offset class_name
mov dword ptr[ebp-4],NULL ; Use the same app icon for the small one.
lea eax,[ebp-48] ; WNDCLASSEX.
push eax
call RegisterClassEx
push NULL ; No value passed to the window.
push hinstance
push NULL ; No menu.
push NULL ; No parent of the window.
push SCREEN_HEIGHT ; Old standar
push SCREEN_WIDTH ; resolution.
push CW_USEDEFAULT ; Default position
push CW_USEDEFAULT ; of the window.
push WS_EX_TOPMOST or WS_VISIBLE or WS_POPUP ; Game window style.
push offset wnd_name ; Name of the game window.
push offset class_name
push WS_EX_TOPMOST ; Some extension of the style.
call CreateWindowEx
mov hwindow,eax
push SW_SHOWNORMAL ; Displaying the window for the first time.
push eax
call ShowWindow
push hwindow
call UpdateWindow ; Update the client area.
push offset d3d9_lib
call LoadLibrary ; Load d3d9.dll to the address space of this program.
mov hdll,eax ; Handle to the module loaded.
push offset dx9func0 ; Direct3DCreate9.
push eax ; hdll.
call GetProcAddress ; Get the address of the dx9 function.
mov proc_add,eax ; Save the address of the funtion Direct3DCreate9.
push D3D_SDK_VERSION
call eax ; Call the function Direct3DCreate9.
mov inter_add,eax ; Safe the com interface address.
mov esi,offset d3dpp
mov ecx,14 ; There are 14 dword members in this structure.
align 4
fill_struc:
mov dword ptr[esi],0
add esi,4 ; Next field.
loop fill_struc ; Fill the structure with 0.
mov esi,offset d3dpp
mov dword ptr[esi+0],SCREEN_WIDTH ; Backbuffer width.
mov dword ptr[esi+4],SCREEN_HEIGHT ; Backbuffer height.
mov dword ptr[esi+8],D3DFMT_X8R8G8B8 ; Backbuffer format.
mov dword ptr[esi+12],1 ; Backbuffer count.
mov dword ptr[esi+24],D3DSWAPEFFECT_DISCARD ; Swap effect.
mov eax,hwindow
mov dword ptr[esi+28],eax ; device window.
mov dword ptr[esi+32],FALSE ; Not windowed, we want fullscreen.
push offset d3ddev
push offset d3dpp
push D3DCREATE_SOFTWARE_VERTEXPROCESSING
push eax ; hwindow
push D3DDEVTYPE_HAL
push D3DADAPTER_DEFAULT
mov eax,inter_add ; Com interface address.
push eax
mov eax,[eax] ; Get address of the method.
call dword ptr[eax+IDirect3D9_CreateDevice] ; Call method CreateDevice.
push 0
push float4
push 00000000h ; Black color.
push D3DCLEAR_TARGET
push NULL
push 0
mov eax,d3ddev
push eax
mov eax,[eax]
call dword ptr[eax+IDirect3DDevice9_Clear]
push offset backbuffer
push D3DBACKBUFFER_TYPE_MONO
push 0
push 0
mov eax,d3ddev
push eax
mov eax,[eax]
call dword ptr[eax+IDirect3DDevice9_GetBackBuffer]
push NULL
push offset surface
push D3DPOOL_DEFAULT
push D3DFMT_X8R8G8B8
push 480 ; Height of the surface.
push 680 ; Width of the surface.
mov eax,d3ddev
push eax
mov eax,[eax]
call dword ptr[eax+IDirect3DDevice9_CreateOffscreenPlainSurface]
mov result,eax
push NULL
push 0
push D3DX_DEFAULT
push NULL
push offset the_model
push NULL
push NULL
push surface
call D3DXLoadSurfaceFromFile
push D3DTEXF_NONE
push NULL
push backbuffer
push NULL
push surface
mov eax,d3ddev
push eax
mov eax,[eax]
call dword ptr[eax+IDirect3DDevice9_StretchRect]
lea esi,[ebp-76] ; MSG.
mov bye,0 ; Flag to stop the game loop.
align 4
msgloop:
push PM_REMOVE ; Pull out messages.
push 0 ; Retrieve all
push 0 ; available messages.
push NULL ; Messages of any window of this thread.
push esi ; MSG.
call PeekMessage
cmp eax,0
je no_msg ; No messages yet. Give the game the resources.
push esi
call TranslateMessage ; Translate keyboard to messages.
push esi
call DispatchMessage ; Dispatch messages to wndproc.
cmp bye,1
je end_program ; Check if the game is over.
align 4
no_msg:
mov eax,d3ddev
push eax
mov eax,[eax]
call dword ptr[eax+IDirect3DDevice9_BeginScene]
push offset backbuffer
push D3DBACKBUFFER_TYPE_MONO
push 0
push 0
mov eax,d3ddev
push eax
mov eax,[eax]
call dword ptr[eax+IDirect3DDevice9_GetBackBuffer]
push D3DTEXF_NONE
push NULL
push backbuffer
push NULL
push surface
mov eax,d3ddev
push eax
mov eax,[eax]
call dword ptr[eax+IDirect3DDevice9_StretchRect]
mov eax,d3ddev
push eax
mov eax,[eax]
call dword ptr[eax+IDirect3DDevice9_EndScene]
push NULL
push NULL
push NULL
push NULL
mov eax,d3ddev
push eax
mov eax,[eax]
call dword ptr[eax+IDirect3DDevice9_Present]
push VK_ESCAPE
call GetAsyncKeyState ; The esc key turns off the game.
test eax,80000000h
jz keep_rolling ; If is not pressed keep playing.
push 0
push 0
push WM_DESTROY
push hwindow
call PostMessage ; If pressed let start to shutdown the game.
align 4
keep_rolling:
jmp msgloop ; All again.
align 4
end_program:
mov eax,[ebp-68] ; wParam (exit code).
mov esp,ebp
pop ebp
push eax
call ExitProcess ; End the program.
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
align 4
wndproc: ; The window procedure for the main window class.
push ebp
mov ebp,esp
cmp dword ptr[ebp+12],WM_DESTROY ; Game over.
jne do_the_default
cmp d3ddev,NULL
je skip_cleaning
mov eax,d3ddev
push eax
mov eax,[eax]
call dword ptr[eax+IUnknown_Release]
cmp inter_add,NULL
je skip_cleaning
mov eax,inter_add
push eax
mov eax,[eax]
call dword ptr[eax+IUnknown_Release]
align 4
skip_cleaning:
push 0 ; Exit code (wParam in WM_QUIT).
call PostQuitMessage ; Notify to windows that is the end of the application.
mov bye,1 ; To stop the game loop.
xor eax,eax
mov esp,ebp
pop ebp
ret 16
align 4
do_the_default:
push dword ptr[ebp+20] ; lParam.
push dword ptr[ebp+16] ; wParam.
push dword ptr[ebp+12] ; The message.
push dword ptr[ebp+8] ; Handle of the window.
call DefWindowProc ; Default processing for all the other messages.
mov esp,ebp
pop ebp
ret 16
end start
Hi Felipe, you must have forgotten to join the asset. All I see is black screen. exe size is 2kb
Yeah, MIG31.jpg is not included in the zip
:lol: Sorry for that. Put this image in the same folder of the .exe. :idea:
It works, nice.
:icon_exclaim: Please note the program will not run if you haven't installed this runtime libraries:
https://www.microsoft.com/en-us/download/details.aspx?id=8109 (https://www.microsoft.com/en-us/download/details.aspx?id=8109) I haven't done any checking in the program for the libs, so it will crash if you try it without this libs in your system, but windows handle the situation correctly. Sorry about that. :redface:
Quote from: felipe on April 23, 2018, 06:26:01 AM
Ok, here it is another demo. Fullscreen, escape (and finish the program) with the esc key. Made with a nice model from DAYDREAMER. .exe attached.
Special notes: I was having the approach of test the directx 9 functions (of course just a few of them) and the include files (provided from Siekmanski) and then sharing here the results. That's why the code is not too much commented (sorry). Now i think i will start a game, so i will (hopefully) take some time and upload the game and the source code (well commented) when i finish. :icon14:
DAYDREAMER: Do you see this baby moving in your screen in a future? Maybe you should try it! :greensml:
great Felipe, looking forward to your game
fightergame over grand canyon?
Quote from: Siekmanski on April 23, 2018, 06:40:36 AM
Yeah, MIG31.jpg is not included in the zip
Quote from: felipe on April 23, 2018, 08:46:10 AM
:icon_exclaim: Please note the program will not run if you haven't installed this runtime libraries
Slow down felipe, catch your breath...
Still a work in progress, I gather. But thats not a bad thing.
Hope that you get it all together, and thanks for keeping us updated on your progress. :t
I've seen in my game Dev book that you can use a grid in a bmp filled with different animation frames in each,in this case I could make it with a smaller airplane, if you are interested?
It's nice to see you show your progress step by step
daydreamer it would be nice if you want. Thanks. :icon14:
still interested in continue this Felipe?
an aircraft game needs ofcourse several types of planes so you can see difference between you and your wingmans jets and opposing airforce
and different kinds of choices of greenish camoflage or greyish,best would be if someone mastered d3d9 multitextures so you can customize your jets with choose between different countries markings
modern airfighting ofcourse you need to have missiles if you dont want to make very old jet wars with gatling cannons
i may be interested :icon14:, unfortunately that doesn't mean i have the time of doing it... :(
It would be nice if some of us team up for a game or demo,different talents combined,alone harder to make a good game if you lack skill in (me)music or graphics
Also a game always end up unfinished (me) alone,but a team could code several different modules if we work out some standard for proc calling and same global data structure