Jump to content
  • Advertisement
  • entries
  • comments
  • views

TIME$ to resume work on TI-83+ BBC BASIC

Sign in to follow this  


It's been a while since I worked on the TI-83+ calculator port of BBC BASIC, and due to a relatively modular design some of the new features I'd been working on for the Z80 computer project version could be easily transferred across.

The first addition to the calculator port is the TIME$ keyword, which lets you get or set the system time.

That's all very well and good, but only the TI-84+ calculator has real-time clock hardware - the TI-83+ doesn't have any sort of accurate timekeeping to speak of. Rather than display an error when TIME$ is used I opted to use an inaccurate software-based clock. It uses the TI-83+'s timer interrupts (roughly 118Hz) to update the date and time about once a second. The clock is reset to Mon,01 Jan 2001.00:00:00 every time BBC BASIC is restarted and keeps abysmal time, but software designed to use the clock will at least run.

I have been transferring and amending documentation from Richard Russell's website to a private installation of MediaWiki. There are about 120 entries so far; having documentation puts me much closer to being able to make a release.

I have also fixed a handful of bugs. One that had me tearing my hair out was something like this:

  250 DEF PROC_someproc(a,b)
260 a=a*PI

The program kept displaying a No such variable error on line 260. Well, a is clearly defined, and retyping the procedure in another program worked, so what was the problem here? I thought that maybe one of the graphics calls or similar was corrupting some important memory or modifying a register it shouldn't. It turns out that the problem lay in the Windows-based tokeniser - it was not picking up PI as a token, for starters, and was storing the ASCII string "PI" instead. On top of that, it was treating anything after a * as a star command, which aren't tokenised either. (Star commands, such as *REFRESH, are passed directly to the host interface or OS). Retyping the problematic lines caused BBC BASIC to retokenise them, which was why I couldn't replicate the problem in other programs. By fixing the tokeniser, everything started working again.

The source code for the analogue clock program is listed below.

20 VDU 29,48;32;
30 GCOL 0,128
50 t$=TIME$
60 hour%=VAL(MID$(t$,17,2))MOD12
70 min%=VAL(MID$(t$,20,2))
80 sec%=VAL(MID$(t$,23,2))
90 sec=sec%/60
100 min=(min%+sec)/60
110 hour=(hour%+min)/12
120 CLG
130 GCOL 0,127
140 MOVE 0,0
150 PLOT 153,31,0
160 GCOL 0,0
170 FOR h=1TO12
180 hA= h/6*PI
190 hX=30*SIN(hA)
200 hY=30*COS(hA)
210 MOVE hX,hY
220 DRAW hX*0.9,hY*0.9
230 NEXT h
240 PROC_drawHand(sec,30)
250 PROC_drawHand(min,24)
260 PROC_drawHand(hour,16)
280 UNTIL INKEY(0)<>-1
300 END
310 DEF PROC_drawHand(pos,length)
320 MOVE 0,0
330 pos=pos*2*PI
340 DRAW length*SIN(pos),-length*COS(pos)

I translated the tokeniser source code to PHP so that by pointing a browser to file.bbcs for a known file.bbc the highlighted, detokenised source code is served as HTML instead. Hurrah for mod_rewrite, and if you're using IIS Ionic's Isapi Rewrite Filter performs a similar job using the same syntax.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!