Author |
Message
|
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [1110] - posted: 2012-05-15 21:02:59
ok , when putting ';' i got that error
“ |
[2,13]: Expected program but found ; in [sprite.zir]
Code:
plugin off;
|
http://www.freewebs.com/ogremagic/index.htm |
Admin Site Admin
(send private message)
Posts: 933 Topics: 55
Location: OverHertz Studio | [1112] - posted: 2012-05-15 21:19:06 lol... still incorrect
replace "plugin" with "plugins"
Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message. |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [1113] - posted: 2012-05-15 21:27:04
oh , sorry.
have an other problem with my code , i am afraid to post it because it is long.
can i post it here or send to you in zip file?
http://www.freewebs.com/ogremagic/index.htm |
Admin Site Admin
(send private message)
Posts: 933 Topics: 55
Location: OverHertz Studio | [1114] - posted: 2012-05-15 21:35:00 posting is fine
Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message. |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [1116] - posted: 2012-05-15 21:50:47 ok , i divided my source code into 4 files.
the main one is here 'sprite.zir'
Code:plugins off;
program WIN32GUI 'Sprite';
#include 'user32.zir';
#include 'kernel32.zir';
#include 'messages.zir';
#include 'colors.zir';
#include 'console.zir';
#include 'strings.zir';
#include 'FPScalc.zir';
#include 'Dx9.zir';
#include 'Win.zir';
Dword HWin = CreateWin(1024,768);
IDirect3DDevice9 Dx9device = InitDx9(HWin,1024,768);
edi = Dx9device;
push esi;
esi = 0xFF000000;
// Set up message loop
dword quit;
while (quit <> WM_QUIT)
{
edi.clear(0, nil, 3, esi, 1.0, 0);
edi.BeginScene;
FPScalc();
edi.EndScene;
edi.Present(nil, nil, 0, nil);
add esi, 0x512
SetWindowText(HWin,@StringFPS);
quit = DoEvent();
}
edi as nothing;
pop esi
ExitProcess(0);
'Dx9.zir' file is
Code:#include 'directx/direct3d9.zir';
const D3DPRESENT_INTERVAL_IMMEDIATE = 0x80000000;
const D3DADAPTER_DEFAULT = 0;
const D3D_OK = 0;
type bool = boolean;
function InitDx9(Dword Wnd,Width,Height;bool pVsync = true,pFullscreen = false)
{
uses edi;
D3DPRESENT_PARAMETERS presParams;
D3DDISPLAYMODE mDisplayMode;
IDirect3DDevice9 dx_device;
IDirect3D9 dx_object = Direct3DCreate9(D3D_SDK_VERSION);
Edi = dx_object as IDirect3D9;
// Windowed
if (!pFullscreen)
{
Edi.GetAdapterDisplayMode (D3DADAPTER_DEFAULT, @mDisplayMode);
if (eax != D3D_OK)
{
print('error');
}
else
// Full screen
{
mDisplayMode.Width = Width;
mDisplayMode.Height = Height;
mDisplayMode.RefreshRate = 0;
mDisplayMode.Format = D3DFMT_A8R8G8B8;
}
m_strFill(@presParams, sizeof presParams, 0);
// Windowed
if (!pFullscreen)
{
presParams.Windowed = true;
presParams.BackBufferWidth = Width;
presParams.BackBufferHeight = Height;
}
else
// Full screen
{
presParams.Windowed = false;
presParams.BackBufferWidth = mDisplayMode.Width;
presParams.BackBufferHeight = mDisplayMode.Height;
}
presParams.hDeviceWindow = Wnd;
presParams.BackBufferCount = 1;
presParams.BackBufferFormat = mDisplayMode.Format;
presParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
presParams.AutoDepthStencilFormat = D3DFMT_D16;
presParams.EnableAutoDepthStencil = True;
presParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
DWORD mQualityLevels;
D3DCAPS9 pCaps;
Edi = dx_object as IDirect3D9;
Edi.GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, @pCaps);
Edi.CheckDeviceMultiSampleType(pCaps.AdapterOrdinal,pCaps.DeviceType,mDisplayMode.Format,presParams.Windowed,D3DMULTISAMPLE_2_SAMPLES,@mQualityLevels);
presParams.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
presParams.MultiSampleQuality = mQualityLevels;
Eax = Edi.CreateDevice(0, D3DDEVTYPE_HAL, Wnd, 64, @presParams, @dx_device);
return dx_device;
}
'Win.zir' file is
Code:const SM_CXSCREEN = 0;
const SM_CYSCREEN = 1;
function abs(int32 val)
{
eax = val;
if(eax:int < 0)
{
neg eax;
}
}
//////////////////////////////
function WindowProc(Dword hWnd, uMsg, wParam, lParam)
{
if (uMsg == WM_DESTROY) {
PostQuitMessage(0);
}
DefWindowProc(hWnd, uMsg, wParam, lParam);
}
//
function CreateWin(dword Width,Height)
{
const className = 'ZMainFRM';
tagWndClassA wndClass;
Dword hInstance = GetModuleHandleA(nil);
Dword hWin;
m_strFill(@wndClass, sizeof tagWndClassA, 0);
wndClass.hbrBackground = COLOR_BACKGROUND;
wndClass.hInstance = hInstance;
wndClass.lpszClassName = className;
wndClass.lpfnWndProc = @WindowProc;
if (RegisterClassA(@wndClass) == 0) {
eax = GetLastError();
print('RegisterClassA error: ',eax:int,'\r\n');
}
hWin = CreateWindowExA(0, className, 'window Demo', WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, Width,Height, 0, 0, hInstance, nil);
if (hWin == null) {
eax = GetLastError();
print('CreateWindowExA error: ',eax:int,'\r\n');
}
// center our window before shoing it
GetSystemMetrics (SM_CXSCREEN);
eax -= Width;
if(eax < 0)
{
neg eax;
}
eax >> 1;
int32 mCenterX = eax;
GetSystemMetrics (SM_CYSCREEN);
eax -= Height;
if(eax < 0)
{
neg eax;
}
eax >> 1;
int32 mCenterY = eax;
SetWindowPos (hWin, 0, mCenterX, mCenterY, Width,Height, 0 );
ShowWindow(hWin, SW_SHOWNORMAL);
return hWin;
}
//variables
function DoEvent()
{
tagMsg msg;
if (PeekMessage(@msg, 0, 0, 0, 1))
{
TranslateMessage(@msg);
DispatchMessage(@msg);
}
return msg.message;
}
'FPScalc.zir' file is
Code:char* fpsview='FPS %d';
byte StringFPS[255];
dword FPS;
dword LastTime;
procedure FPScalc()
{
FPS++;
Edx = GetTickCount();
Eax -= LastTime;
if(Eax => 1000)
{
LastTime = Edx;
wsprintf(@StringFPS,fpsview,FPS);
FPS=0;
}
}
then when compiling it i get that error
“ |
[29,32]: Expected identifier but found Width in [Win.zir]
Code:
function CreateWin(dword Width,Height)
|
any help please?
http://www.freewebs.com/ogremagic/index.htm |
Admin Site Admin
(send private message)
Posts: 933 Topics: 55
Location: OverHertz Studio | [1117] - posted: 2012-05-15 22:51:45 I couldn't quite read your code so i've rewrote some of it and re-tabbed, anyways got it compiling and working:
sprite.zir: Code:plugins off;
program WIN32CUI 'Sprite';
#include 'messages.zir';
#include 'colors.zir';
#include 'ch.zir';
#include 'Win.zir';
#include 'FPScalc.zir';
#include 'Dx9.zir';
Dword HWin = CreateWin(1024,768);
IDirect3DDevice9 Dx9device = InitDx9(HWin,1024,768);
edi = Dx9device as IDirect3DDevice9;
// Set up message loop
eax = 0;
while (eax <> WM_QUIT) {
edi.clear(0, nil, 3, 0xFF000000, 1.0, 0);
edi.BeginScene;
FPScalc();
edi.EndScene;
edi.Present(nil, nil, 0, nil);
SetWindowText(HWin,@StringFPS);
eax = DoEvent();
}
ExitProcess(0);
Dx9.zir: [b]note there is still 1 problem in this function but i will let you solve it, tomorrow if you did not i will take another look
Code:#include 'directx/direct3d9.zir';
const D3DPRESENT_INTERVAL_IMMEDIATE = 0x80000000;
const D3DADAPTER_DEFAULT = 0;
const D3D_OK = 0;
type bool = boolean;
function InitDx9(Dword Wnd,Width,Height;bool pVsync = true,pFullscreen = false) {
uses edi;
D3DPRESENT_PARAMETERS presParams;
D3DDISPLAYMODE mDisplayMode;
IDirect3DDevice9 dx_device;
m_strFill(@mDisplayMode, sizeof mDisplayMode, 0);
m_strFill(@presParams, sizeof presParams, 0);
IDirect3D9 dx_object = Direct3DCreate9(D3D_SDK_VERSION);
Edi = dx_object as IDirect3D9;
if (!pFullscreen) {
eax = edi.GetAdapterDisplayMode (D3DADAPTER_DEFAULT, @mDisplayMode);
if (eax != D3D_OK) {
print('error\r\n');
}
} else {
//fullscreen
mDisplayMode.Width = Width;
mDisplayMode.Height = Height;
mDisplayMode.RefreshRate = 0;
mDisplayMode.Format = D3DFMT_A8R8G8B8;
}
if (!pFullscreen) {
// Windowed
presParams.Windowed = true;
presParams.BackBufferWidth = Width;
presParams.BackBufferHeight = Height;
} else {
// Full screen
presParams.Windowed = false;
presParams.BackBufferWidth = mDisplayMode.Width;
presParams.BackBufferHeight = mDisplayMode.Height;
}
presParams.hDeviceWindow = Wnd;
presParams.BackBufferCount = 1;
presParams.BackBufferFormat = mDisplayMode.Format;
presParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
presParams.AutoDepthStencilFormat = D3DFMT_D24X8; //D3DFMT_D16;
presParams.EnableAutoDepthStencil = True;
presParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
/* the following code crashes app >>>>
DWORD mQualityLevels;
D3DCAPS9 pCaps;
eax = edi.GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, @pCaps);
edi.CheckDeviceMultiSampleType(pCaps.AdapterOrdinal,pCaps.DeviceType,mDisplayMode.Format,presParams.Windowed,D3DMULTISAMPLE_2_SAMPLES,@mQualityLevels);
presParams.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
presParams.MultiSampleQuality = mQualityLevels;
*/
Eax = Edi.CreateDevice(0, D3DDEVTYPE_HAL, Wnd, 64, @presParams, @dx_device);
return dx_device;
}
FPScalc.zir: Code:char* fpsview='FPS %d';
byte StringFPS[255];
dword FPS;
dword LastTime;
procedure FPScalc()
{
FPS++;
Edx = GetTickCount();
Eax -= LastTime;
if(Eax => 1000)
{
LastTime = Edx;
wsprintf(@StringFPS,fpsview,FPS);
FPS=0;
}
}
Win.zir: Code:const SM_CXSCREEN = 0;
const SM_CYSCREEN = 1;
function abs(int32 val) {
if (val < 0) {
eax = val;
neg eax;
}
}
//////////////////////////////
function WindowProc(Dword hWnd, uMsg, wParam, lParam)
{
if (uMsg == WM_DESTROY) {
PostQuitMessage(0);
}
DefWindowProc(hWnd, uMsg, wParam, lParam);
}
//
function CreateWin(DWord width, height) {
uses edi;
const className = 'ZMainFRM';
tagWndClassA wndClass;
Dword hInstance = GetModuleHandleA(nil);
m_strFill(@wndClass, sizeof tagWndClassA, 0);
wndClass.hbrBackground = COLOR_BACKGROUND;
wndClass.hInstance = hInstance;
wndClass.lpszClassName = className;
wndClass.lpfnWndProc = @WindowProc;
if (RegisterClassA(@wndClass) == 0) {
eax = GetLastError();
print('RegisterClassA error: ',eax:int,'\r\n');
}
edi = CreateWindowExA(0, className, 'window Demo', WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width, height, 0, 0, hInstance, nil);
if (edi == null) {
eax = GetLastError();
print('CreateWindowExA error: ',eax:int,'\r\n');
}
ShowWindow(edi, SW_SHOWNORMAL);
return edi;
}
/*
function CreateWin(dword Width,Height)
{
const className = 'ZMainFRM';
tagWndClassA wndClass;
Dword hInstance = GetModuleHandleA(nil);
Dword hWin;
m_strFill(@wndClass, sizeof tagWndClassA, 0);
wndClass.hbrBackground = COLOR_BACKGROUND;
wndClass.hInstance = hInstance;
wndClass.lpszClassName = className;
wndClass.lpfnWndProc = @WindowProc;
if (RegisterClassA(@wndClass) == 0) {
eax = GetLastError();
print('RegisterClassA error: ',eax:int,'\r\n');
}
hWin = CreateWindowExA(0, className, 'window Demo', WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, Width,Height, 0, 0, hInstance, nil);
if (hWin == null) {
eax = GetLastError();
print('CreateWindowExA error: ',eax:int,'\r\n');
}
// center our window before shoing it
GetSystemMetrics (SM_CXSCREEN);
eax -= Width;
if(eax < 0)
{
neg eax;
}
eax >> 1;
int32 mCenterX = eax;
GetSystemMetrics (SM_CYSCREEN);
eax -= Height;
if(eax < 0)
{
neg eax;
}
eax >> 1;
int32 mCenterY = eax;
SetWindowPos (hWin, 0, mCenterX, mCenterY, Width,Height, 0 );
ShowWindow(hWin, SW_SHOWNORMAL);
return hWin;
}*/
//variables
function DoEvent()
{
tagMsg msg;
if (PeekMessage(@msg, 0, 0, 0, 1))
{
TranslateMessage(@msg);
DispatchMessage(@msg);
}
return msg.message;
}
now i will go to bath, good night
Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message. |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [1118] - posted: 2012-05-16 18:42:36
ok your modification solve the error.
but what was the problem there , i want to know to avoid that in the future.
http://www.freewebs.com/ogremagic/index.htm |
Admin Site Admin
(send private message)
Posts: 933 Topics: 55
Location: OverHertz Studio | [1119] - posted: 2012-05-16 19:11:42 The problem was in InitDx9 function
Code: if (!pFullscreen)
{
Edi.GetAdapterDisplayMode (D3DADAPTER_DEFAULT, @mDisplayMode);
if (eax != D3D_OK)
{
print('error');
}
else
// Full screen
{
mDisplayMode.Width = Width;
mDisplayMode.Height = Height;
mDisplayMode.RefreshRate = 0;
mDisplayMode.Format = D3DFMT_A8R8G8B8;
}
here you were missing 1 }, but actually there was no syntax error because the code was folded into the main procedure which caused a problem
Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message. |