Register | Login
Forum Index > Source Help > do not know where is the bug
Author Message
Pages: 1 2 3 4
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1088] do not know where is the bug - posted: 2012-05-13 19:36:53

Hi ,

i really did not know the bug in the next function

Code:
char  fpsview='FPS %d';
byte  StringFPS[255];
dword FPS;
dword LastTime;

procedure FPScalc()
{
  FPS++;
  GetTickCount();
  Eax -= LastTime;
  if(Eax => 1000)
   {
    LastTime = Eax;
    wsprintf(@StringFPS,@fpsview,FPS);
    FPS=0;
   }
}


StringFPS variable is always hold a fiexd string as '!@'

any help please.

http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1089] - posted: 2012-05-13 19:44:16
Code:
char  fpsview='FPS %d';


='FPS %d'; is a pointer

try

Code:
char* fpsview='FPS %d';


then pass it directly without @

alternatively

Code:
char fpsview[7];
strlcpy(@fpsview, 'FPS %d', 7);


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1090] - posted: 2012-05-13 19:51:44
btw you could probably do a better job without using wsprintf

Code:
char fpsview[255];
dword FPS;
dword LastTime;

procedure FPScalc() {
  char buf[32];
  FPS++;
  eax = GetTickCount();
  eax -= LastTime;
  if (eax => 1000) {
    LastTime = Eax;
    
    strlcpy(@fpsview, 'FPS: ', 6);
    IntToStr(FPS, @buf);
    strAppend(@fpsview, @buf, 255);
  
    FPS = 0;
  }
}


something like this.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1091] - posted: 2012-05-13 19:51:48

ok it works.

but seems there is a logical bug in that function because it always hold '1' , it should hold
the frame per second of the animation.

http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1092] - posted: 2012-05-13 19:54:12
LastTime = Eax;

this is it probably, since eax already has sub the lasttime etc, it is no longer gettickcount value

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1093] - posted: 2012-05-13 19:56:53
try

Code:
char fpsview[255];
dword FPS;
dword LastTime;

procedure FPScalc() {
  char buf[32];
  FPS++;
  ecx = GetTickCount();
  eax -= LastTime;
  if (eax => 1000) {
    LastTime = ecx;
    
    strlcpy(@fpsview, 'FPS: ', 6);
    IntToStr(FPS, @buf);
    strAppend(@fpsview, @buf, 255);
  
    FPS = 0;
  }
}


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1094] - posted: 2012-05-13 20:01:45

ok , thanks here is the correct one

Code:
char fpsview[255];
dword FPS;
dword LastTime;

procedure FPScalc() {
  char buf[32];
  FPS++;
  edx = GetTickCount();
  eax -= LastTime;
  if (eax => 1000) {
    LastTime = edx;
    
    strlcpy(@fpsview, 'FPS: ', 6);
    IntToStr(FPS, @buf);
    strAppend(@fpsview, @buf, 255);
  
    FPS = 0;
  }
}


http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1095] - posted: 2012-05-13 20:13:30

there is an other bug here.

the string is growing after each second

for example
Code:
FPS: 61
FPS: 6161
FPS: 616161
 ........... etc


http://www.freewebs.com/ogremagic/index.htm
Pages: 1 2 3 4
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 7 user(s) online. 0 member(s) and 7 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd