|
Clock
Aug 1, 2007 1:22:26 GMT -5
Post by evildragon on Aug 1, 2007 1:22:26 GMT -5
I made a clock a while ago for the Genesis, but I'm getting complaints that it looses times, like, within 10 minutes.. This didn't happen on my emulator (Genesis Plus for Macintosh).. Can someone else test it for me on real hardware? I don't have a flash cart.. I wrote it on Basiegaxorz a while ago, I might have the source code still on my laptop... blackevilweredragon.spymac.com/seggen/sgclock/index.htmlAlso, if this does have a problem, then that means my other application GenTimer would also have a problem, as it was based on the source of my clock..
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Clock
Aug 1, 2007 15:59:19 GMT -5
Post by oompa loompa on Aug 1, 2007 15:59:19 GMT -5
i can check it on the real thing later
but anyways, how did you implement the timing functions (like, how do you know exactly that one second has passed)? did you use for...next delay kinda loops, or did you use v-blank?
if you used for...next loops for your delays, expect inconsistent results because emulators will never be able to emulate the exact timing of the genesis. waiting for the TV vertical blank is much nicer because tv-blank is always 1/60 seconds for ntsc, or 1/50 seconds for pal tv sets.
|
|
|
Clock
Aug 1, 2007 20:48:16 GMT -5
Post by evildragon on Aug 1, 2007 20:48:16 GMT -5
i can check it on the real thing later but anyways, how did you implement the timing functions (like, how do you know exactly that one second has passed)? did you use for...next delay kinda loops, or did you use v-blank? if you used for...next loops for your delays, expect inconsistent results because emulators will never be able to emulate the exact timing of the genesis. waiting for the TV vertical blank is much nicer because tv-blank is always 1/60 seconds for ntsc, or 1/50 seconds for pal tv sets. I used vertical blanks.. But the thing that seems to be stopping me is, is that TVs are technically 59.99, and that little bit brings it out of sync after a while...
|
|
|
Clock
Aug 1, 2007 20:51:48 GMT -5
Post by evildragon on Aug 1, 2007 20:51:48 GMT -5
here's my source code...
1 print "" 2 print "" 3 print " EvilDragon Software " 4 sleep 240 5 print "" 6 print " SegaClock" 7 sleep 240 8 print "" 9 print "To set time, use Up or Down to" 10 print "select number, then press A for next" 11 print "number. Also press A to set a" 12 print "trailing 0 the number, then press" 13 print "Start. For example, for 43 minutes," 14 print "enter 430." 15 print "" 50 input "Insert Hour", hour 51 input "Insert Minute", minute 52 input "Insert Second", second 67 cls 71 print "" 72 print "" 73 print "" 74 print "" 75 print "" 76 print "" 77 print "" 78 print "" 79 print "" 80 print "" 81 print "" 100 print " ";hour;":";minute;":";second;"" 120 second=second+1 130 if second=60 then minute=minute+1 140 if minute=60 then hour=hour+1 150 if second=60 then second=0 160 if minute=60 then minute=0 170 if hour=13 then hour=1 180 sleep 60 190 cls 200 goto 71
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Clock
Aug 3, 2007 1:31:18 GMT -5
Post by oompa loompa on Aug 3, 2007 1:31:18 GMT -5
the CLS command takes a long time to execute, and might take longer than one a vblank, so your clock may be running slow. PRINT commands also take up time, so minimizing the number of display related commands should make the clock more accurate.
i wouldn't use too many print commands just to do a carriage return, i would use LOCATE instead. eg: "locate 10,10" positions the the cursor at (10,10).
a lot of the games that keep track of time basically increment a variable inside the v-blank interrupt routine, since the interrupter occurs every 1/60 seconds (unless doing dma). if you want to know how to do interrupters in basiegaxorz, let me know - i actually made it very easy to use interrupts with basic.
|
|
|
Clock
Aug 3, 2007 3:01:47 GMT -5
Post by evildragon on Aug 3, 2007 3:01:47 GMT -5
sure, i'd like to learn it...
i'll try the locate command later too.. (going to be helping my school move to a new building today and tomorrow..)
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Clock
Aug 3, 2007 4:10:30 GMT -5
Post by oompa loompa on Aug 3, 2007 4:10:30 GMT -5
to do interrupters in basiegaxorz: we first need to use the ON command to specify which label we want our program to jump to when an interrupt occurs. for example: "on vblank gosub my_interrupt". this line of code should be self explanatory - when TV vblank occurs, the cpu will finish whatever it's doing, and then will jump to the label called my_interrupt. this is the only initialization for the vblank interrupt in basiegaxorz interrupters are not enabled yet, so once they're enabled, the cpu will jump to our vblank subroutine when vblank occurs. this is accomplished by using "enable interrupt vblank". to turn off the calling of the vblank subroutine interrupt, we can use "disable interrupt vblank". all interrupters are disabled by default then we just need to create the vblank subroutine code, then place a "return" command whenever we want to jump back to normal program execution, and we're done be careful because all variables in basiegaxorz are global. you can easily mess up a variable that you don't want messed up in the interrupter subroutine. i mean, it doesn't just change variables randomly on you, it's just messy programming that will cause problems so now that you have coded your vblank interrupt program, you should now have something exactly like this ' goto subroutine "my_interrupt" when vblank occurs. on vblank gosub my_interrupt
' initialize all our variables time_1in60 = 0 time_seconds = 0 time_minutes = 0 counter& = 0
print "v-blank interrupter example!" ' after this next line is executed, the cpu will jump to our vblank ' interrupter when an interrupt occurs. enable interrupt vblank ' notice that we don't change the time_seconds and time_minutes ' variables in our infinite loop :P! main: locate 10, 10 print "The current time is "; time_minutes; ":"; time_seconds; " " locate 11, 10 print "Counter: "; counter&
counter& = counter& + 1 goto main
' this is the vblank interrupt subroutine. ' this subroutine will be called every 1/60 seconds. my_interrupt: ' increment the time. ' another variable (time_1in60) has to be used because we only ' want to update the seconds variable only when we have gone ' through vblank 60 times. time_1in60 = time_1in60 + 1 if time_1in60 = 60 then time_1in60 = 0 time_seconds = time_seconds + 1 if time_seconds = 60 then time_seconds = 0 time_minutes = time_minutes + 1 endif endif ' a must!!! ' we must always return back to the original program when we're ' finished! return
|
|
|
Clock
Aug 3, 2007 4:21:19 GMT -5
Post by evildragon on Aug 3, 2007 4:21:19 GMT -5
woah, that's some serious BASIC programming.. and here i am still using the old fasion stuff..
I think first I should re-learn BASIC.. I learned BASIC on my IBM XT, which had "BASICA" on it's ROM... Much more simpler than that...
thanks for the information, I'll use this, to make my clock much more optimized in it's next version (also when i learn the newer BASIC commands)
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Clock
Aug 21, 2007 1:44:34 GMT -5
Post by oompa loompa on Aug 21, 2007 1:44:34 GMT -5
i was browsing through the basiegaxorz examples, and i guess a while ago, i did make a clock for the genesis too - lol it's not actually in the v0.19 examples distribution, but it's only for the nexw compiler (the one that only i have). i'll still share the source though -- it will not compile on v0.19, v0.26 beta, v0.21, or whatever option CASESENSE dim time_sec_l as integer dim time_sec_h as integer dim time_min_l as integer dim time_min_h as integer dim time_hour_l as integer dim time_hour_h as integer
dim counter as integer
time_sec_l=0 time_sec_h=0 time_min_l=0 time_min_h=0 time_hour_l=0 time_hour_h=0
textstart 0,0 textarea 28,40
ink 1 locate 7,7: print "Genny Clock!" locate 11,12: print "X" locate 15,12: print "X" locate 11,26: print "X" locate 15,26: print "X" locate 20,10: print "Press:" locate 21,12: print "A+"+chr$(&h18)+": Increase Minutes" locate 22,12: print "A+"+chr$(&h19)+": Decrease Minutes" locate 23,12: print "A+"+chr$(&h1B)+": Increase Hours" locate 24,12: print "A+"+chr$(&h1A)+": Decrease Hours" ink 2 on vblank gosub vblank enable INTERRUPT VBLANK end
vblank: counter++ if counter%10=0 then joy=joypad() if joy.6 then ' A button -> Adjust settings if joy.0 then ' Up Button -> Increment Minutes time_min_l++ if time_min_l=10 then time_min_l=0: time_min_h++ if time_min_h=6 then time_min_h=0 goto update endif if joy.1 then ' Down Button -> Decrement Minutes time_min_l-- if time_min_l=-1 then time_min_l=0: time_min_h-- if time_min_h=-1 then time_min_h=0: time_min_h=5: time_min_l=9 goto update endif if joy.2 then ' Left Button -> Decrement Hours time_hour_l++ if time_hour_l=10 then time_hour_l=0: time_hour_h++ if time_hour_h=2 and time_hour_l=4 then time_hour_h=0: time_hour_l=0 goto update endif if joy.3 then ' Right Button -> Increment Hours time_hour_l-- if time_hour_l=-1 then time_hour_l=0: time_hour_h-- if time_hour_h=-1 then time_hour_h=0: time_hour_h=2: time_hour_l=3 goto update endif endif endif if counter<>60 then return time_sec_l++ if time_sec_l=10 then time_sec_l=0: time_sec_h++ if time_sec_h=6 then time_sec_h=0: time_min_l++ if time_min_l=10 then time_min_l=0: time_min_h++ if time_min_h=6 then time_min_h=0: time_hour_l++ if time_hour_l=10 then time_hour_l=0: time_hour_h++ if time_hour_h=2 and time_hour_l=4 then time_sec_l=0 time_sec_h=0 time_min_l=0 time_min_h=0 time_hour_l=0 time_hour_h=0 endif update: counter=0 showtime return
declare sub showtime showdigit 0,10,time_hour_h showdigit 6,10,time_hour_l showdigit 14,10,time_min_h showdigit 20,10,time_min_l showdigit 28,10,time_sec_h showdigit 34,10,time_sec_l end sub
declare sub showdigit(posx as integer, posy as integer, number as integer) select case number case 0: locate posy+0,posx: print " XXX " locate posy+1,posx: print "X X" locate posy+2,posx: print "X X" locate posy+3,posx: print "X X" locate posy+4,posx: print "X X" locate posy+5,posx: print "X X" locate posy+6,posx: print " XXX " exit sub case 1: locate posy+0,posx: print " X " locate posy+1,posx: print " XX " locate posy+2,posx: print "X X " locate posy+3,posx: print " X " locate posy+4,posx: print " X " locate posy+5,posx: print " X " locate posy+6,posx: print "XXXXX" exit sub case 2: locate posy+0,posx: print " XXX " locate posy+1,posx: print "X X" locate posy+2,posx: print " X " locate posy+3,posx: print " X " locate posy+4,posx: print " X " locate posy+5,posx: print "X " locate posy+6,posx: print "XXXXX" exit sub case 3: locate posy+0,posx: print "XXXX " locate posy+1,posx: print " X" locate posy+2,posx: print " X" locate posy+3,posx: print "XXXX " locate posy+4,posx: print " X" locate posy+5,posx: print " X" locate posy+6,posx: print "XXXX " exit sub case 4: locate posy+0,posx: print "X X " locate posy+1,posx: print "X X " locate posy+2,posx: print "X X " locate posy+3,posx: print "XXXXX" locate posy+4,posx: print " X " locate posy+5,posx: print " X " locate posy+6,posx: print " X " exit sub case 5: locate posy+0,posx: print "XXXXX" locate posy+1,posx: print "X " locate posy+2,posx: print "X " locate posy+3,posx: print "XXXX " locate posy+4,posx: print " X" locate posy+5,posx: print " X" locate posy+6,posx: print "XXXX " exit sub case 6: locate posy+0,posx: print " XXX " locate posy+1,posx: print "X X" locate posy+2,posx: print "X " locate posy+3,posx: print "XXXX " locate posy+4,posx: print "X X" locate posy+5,posx: print "X X" locate posy+6,posx: print " XXX " exit sub case 7: locate posy+0,posx: print "XXXXX" locate posy+1,posx: print " X" locate posy+2,posx: print " X" locate posy+3,posx: print " X " locate posy+4,posx: print " X " locate posy+5,posx: print " X " locate posy+6,posx: print " X " exit sub case 8: locate posy+0,posx: print " XXX " locate posy+1,posx: print "X X" locate posy+2,posx: print "X X" locate posy+3,posx: print " XXX " locate posy+4,posx: print "X X" locate posy+5,posx: print "X X" locate posy+6,posx: print " XXX " exit sub case 9: locate posy+0,posx: print " XXX " locate posy+1,posx: print "X X" locate posy+2,posx: print "X X" locate posy+3,posx: print " XXXX" locate posy+4,posx: print " X" locate posy+5,posx: print "X X" locate posy+6,posx: print " XXX " exit sub end select end sub
i can build the binary if anyone is interested
|
|
|
Clock
Aug 22, 2007 10:12:01 GMT -5
Post by Tulio Adriano on Aug 22, 2007 10:12:01 GMT -5
Oh dear God I am so excited! ;D Subs!!! I wonder what else is comming on the new compiler but I hope most of the things we mentioned some time before, like two dimention arrays, etc. Thank you very much Devster! Way to go!
|
|