Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
timing
#1
is there any way to do timing other than TIMER, and the
"Precise timer" code at QbasicNews FAQ - http://faq.qbasicnews.com/?blast=PreciseTimer

it can not use the PEEK, POKE, or DEF SEG, because my graphics engine needs those to be free.

any help would be appreciated.
Reply
#2
Quote:is there any way to do timing other than TIMER, and the
"Precise timer" code at QbasicNews FAQ - http://faq.qbasicnews.com/?blast=PreciseTimer

I've always used vsync to time my games and I find it pretty straightforward and I think that 60 fps is the perfect rate.

Quote:it can not use the PEEK, POKE, or DEF SEG, because my graphics engine needs those to be free.

That doesn't make sense at all. PEEK reads from memory. POKE writes in memory. DEF SEG changes the current segment in use. I can't see how that interferes with anything, specially in a monolitic, monotask, monouser operating system such as MSDOS.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
Can you be more specific as to why you can't use Timer?
Reply
#4
Quote:.....
I've always used vsync to time my games and I find it pretty straightforward and I think that 60 fps is the perfect rate.

What is vsync?
*****
Reply
#5
vsynch is synchronizing your program to the vertical refresh rate of your monitor.

inside (crt) monitors, there is a gun shooting from side to side, one line at a time. the refresh rate is the time it takes to get from top to bottom. so if your rate is 60hz, it happens 60 times a second. if you then vsynch your prog, it will wait for that vertical 'reset' of the gun, locking your prog at 60hz (60 fps)

im like 95% sure about it anyways
Reply
#6
Quote:vsynch is synchronizing your program to the vertical refresh rate of your monitor.

inside (crt) monitors, there is a gun shooting from side to side, one line at a time. the refresh rate is the time it takes to get from top to bottom. so if your rate is 60hz, it happens 60 times a second. if you then vsynch your prog, it will wait for that vertical 'reset' of the gun, locking your prog at 60hz (60 fps)

im like 95% sure about it anyways
Interesting, but where/how do I obtain this event that happens every 60 seconds?
*****
Reply
#7
in qb:

Code:
Wait &h3da, 8
Wait &h3da, 8, 8

in fb:

Code:
ScreenSync
Reply
#8
ok, the reason I can't use PEEK or POKE, is because I can't use DEF SEG.
I have set the graphics to send data directly to the VRAM, because this is one of the quickest ways to do graphics.
and If I change the segment, I slow the program down by all the speed I gained while using the POKEing method.
and the TIMER thing won't work, cause it slows it just too much,
the timer resolution is too low.
Reply
#9
Quote:in qb:

Code:
Wait &h3da, 8
Wait &h3da, 8, 8
Read the description of the WAIT in the QB Online Help, and your examples don't make any sense, especially since the first parameter is supposed to be a port number between 0 and 255. &h3da is beyond 255. The fact that WAIT can also loop back is confusing.

How would I use the WAIT to determine elapsed time between start and end times?
*****
Reply
#10
Then the help file has a bug.

The first parameter is a port number. As the processor has 16 address lines for ports, the range is from 0 to 65535.

"WAIT X, bitmask" checks if the bits in the bitmask are set, if not it just halts the execution. WAIT &H3DA waits until bit 3 of port &H3DA is set.

"WAIT X, bitmask1, bitmask2" does exactly the opposite if bitmask1=bitmaks2, i.e. WAIT &H3DA waits until bit 3 of port &H3DA is reset.

To understand the logics, it works in the same way as the typical "wait for a keypress" subroutine:

Code:
WHILE INKEY$<>"": WEND
WHILE INKEY$="": WEND

The first line assures that the keyboard buffer is empty. The second one waits for the first keypress to happen.

The graphics card sets a bit 3 in port &H3DA when the electron beam has drawn the whole image on your monitor screen, then resets it when it starts the next one. With the two instructions, you first assure that the Vsync has not yet started, then you wait until it ends (or the way around, it doesn't matter very much Big Grin).

The VSync subroutine is not used to measure time, but to provide a constant framerate and to prevent flickering on screen, as it is used so the new frame is rendered to the VGA memory in the gap of time which is between the screen has been output to your monitor and the begin of the next "redrawing", i.e., while the electron beam is going back from the bottom right side of the screen to the top left one to start again with the next frame. That way stuff won't be "visible" while it's being drawn. It's some kind of "drawing while the monitor doesn't notice".

As the redrawing happens 60 times a second, you know that your main loop will run exactly 60 times a second (as long as the loop can run in less than 1/60 seconds, of course), so it's perfect for timing in games.

---

About the DEFSEG thingo, I can assure you that it won't slow your program.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)