Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
timing
#11
Quote: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.

Have you tried using one of the libraries for your graphics. (like futurelib or DQB)?

If I remember correctly both of them are in ASM and they are pretty fast.

Both of those can be found www.QB45.com.

Using a library should free up your DefSeg and allow you to use the timer (or precision timer) without a significant loss in speed.
Reply
#12
Quote: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.


EDIT- Sorry, forgot all DOS programs run at 60 Mhz.
Reply
#13
Quote: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.....
Wow! Thanks for this very comprehensive explanation.
I'm glad I don't do games and don't need to worry about this. :wink:
*****
Reply
#14
Just as a side note, with 200- and 400-line modes on the VGA, the vertical retrace happens at 70Hz, while 240- and 480-line modes are at 60Hz.

And as na_th_an said, DEF SEG should not slow your program down much at all. It just sets an internal variable to whatever value you specify that is moved to the proper segment register before the next PEEK or POKE.
Reply
#15
maybe a library? timerlib microsecond timer
Reply
#16
thank you for all your help, it seems that my program is running very well at 70 hz with the

WAIT &H3DA, 8
WAIT &H3DA, 8, 8

I knew about his code, except I never tried the second wait &H3DA, 8, 8

and that was my problem, it was a little weird on some computers, now it's fine, so thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)