timing

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
evildragon
Very interested
Posts: 326
Joined: Mon Mar 12, 2007 1:53 am
Contact:

timing

Post by evildragon » Thu May 24, 2007 7:33 pm

I am making a simple seconds counter for the Genesis.. im using BASIC as I don't want to touch assembly (i get headaches, lol), and i have a problem.. while it works great for NTSC systems, which uses 60Hz, and that's equal to time, but when I run this code in 50Hz systems, the clock runs slower.... here's my code.. any suggestions?

Code: Select all

10 print ""
20 print ""
30 print ""
40 print ""
50 print ""
60 print ""
70 print ""
80 print ""
90 print ""
100 print ""
110 print ""
120 print "        Evil Dragon Presents:"
130 sleep 240
140 cls
150 sleep 60
210 print ""
220 print ""
230 print ""
240 print ""
250 print ""
260 print ""
270 print ""
280 print ""
290 print ""
300 print ""
310 print ""
320 print "           Sega Stop Watch"
330 sleep 240
340 cls
410 print ""
420 print ""
430 print ""
440 print ""
450 print ""
460 print ""
470 print ""
480 print ""
490 print ""
500 print ""
510 print ""
520 input "         Press Start to Start"
529 cls
530 counter=0
610 print ""
620 print ""
630 print ""
640 print ""
650 print ""
660 print ""
670 print ""
680 print ""
690 print ""
700 print ""
710 print ""
720 print "Seconds: ";counter;""
730 counter=counter+1
740 sleep 60
750 cls
760 goto 610

8bitwizard
Very interested
Posts: 159
Joined: Sat Feb 24, 2007 11:35 pm
Location: San Antonio, TX

Post by 8bitwizard » Thu May 24, 2007 8:43 pm

Uhhh... maybe change that "sleep 60" to "sleep 50"?

Clearly it's using vblank as a timer. If you want your code to work with both PAL and NTSC, you need to check the byte at $A10001. If it has the $40 bit set, you are running on a PAL (50Hz) system.

evildragon
Very interested
Posts: 326
Joined: Mon Mar 12, 2007 1:53 am
Contact:

Post by evildragon » Thu May 24, 2007 8:59 pm

8bitwizard wrote:Uhhh... maybe change that "sleep 60" to "sleep 50"?

Clearly it's using vblank as a timer. If you want your code to work with both PAL and NTSC, you need to check the byte at $A10001. If it has the $40 bit set, you are running on a PAL (50Hz) system.
yea, on my long 32 mile drive home, that light bulb in my head went off.. if it's going 10Hz slower, make the sleep shorter by 10... I thought I had to do some weird number..

thanks for that suggestion, i'll do that.. at the moment i have two versions..

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri May 25, 2007 7:33 am

Warm recommendation: forget line numbers and use lablels instead
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

evildragon
Very interested
Posts: 326
Joined: Mon Mar 12, 2007 1:53 am
Contact:

Post by evildragon » Fri May 25, 2007 9:07 am

TmEE co.(TM) wrote:Warm recommendation: forget line numbers and use lablels instead
i prefer line numbers.. i tried using lables once, and didn't like it.. not to mention, i don't know if Sega Basic can do lables..

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri May 25, 2007 9:27 am

All BAX sources I've seen seemed to use line labels. I thought that line numbers are better in the beginning, but later it became real pain in the @$$ when I improved my code or added additional features, I had to renumber everything... well, BAX is not QB so I haven't used it more, I prefer ASM.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Post Reply