TGC Codebase Backup



Speaking Clock by Anonymous Coder

2nd May 2008 16:54
Summary

Speaking Clock converted by Jonathan Hawkins from Atari ST Fast Basic by Dave Jones from Atari User February 1987,you need the Speech Module for it to work.



Description

Speaks for itself



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Project: speaking clocks
Rem Created: 01/04/2008 21:55:22

rem taken from Atari User February 1987
rem converted from Atari ST Fast Basic to Darkbasic Pro
rem for this basic program to work you need the speak module extension for it to work
rem Converted By Jonathan Hawkins from Fast Basic by David Jones

Rem ***** Main Source File *****

white=rgb(255,255,255)
red=rgb(255,0,0)
blue=rgb(0,0,255)
yellow=rgb(255,255,0)

clockx=320
clocky=240

`make watch
ink white,0
circle 320,240,100
for m=1 to 60
   x=cos(360/60*m)*95
   y=sin(360/60*m)*95
   dot clockx+x,clocky+y
next m
for h=1 to 12
   x=cos(360/12*h)*95
   y=sin(360/12*h)*95
   box clockx+x-1,clocky+y-1,clockx+x+1,clocky+y+1
next h

get voice list
clear entry buffer
dim number$(23)
global number$
init()
time$=time()
stored_sec=second
secondhand=second
global secondhand
global stored_sec
global second
global hours
global minute
global second
do
   repeat
   time$=time()
   repeat
   rem updateclock()
ink red,0
minutex=cos(360/60*second-90)*75
minutey=sin(360/60*second-90)*75
line clockx,clocky,clockx+minutex,clocky+minutey
cls
   until second mod 1=0

ink white,0
circle 320,240,100
for m=1 to 60
   x=cos(360/60*m)*95
   y=sin(360/60*m)*95
   dot clockx+x,clocky+y
next m
for h=1 to 12
   x=cos(360/12*h)*95
   y=sin(360/12*h)*95
   box clockx+x-1,clocky+y-1,clockx+x+1,clocky+y+1
next h

ink yellow,0
hourx=cos(360/12*hours-90)*65
houry=sin(360/12*hours-90)*65
line clockx,clocky,clockx+hourx,clocky+houry
numbersonclock()
`display minutes
ink blue,0
minutex=cos(360/60*minute-90)*75
minutey=sin(360/60*minute-90)*75
line clockx,clocky,clockx+minutex,clocky+minutey

ink red,0
minutex=cos(360/60*second-90)*75
minutey=sin(360/60*second-90)*75
line clockx,clocky,clockx+minutex,clocky+minutey

until second mod 10=0

if second<>stored_sec
   stored_sec=second
endif

   rem print get time$()

   send voice message xml time$
   clear entry buffer
   cls
ink red,0
minutex=cos(360/60*second-90)*75
minutey=sin(360/60*second-90)*75
line clockx,clocky,clockx+minutex,clocky+minutey
   circle 320,240,100
   for m=1 to 60
   x=cos(360/60*m)*95
   y=sin(360/60*m)*95
   dot clockx+x,clocky+y
   next m
   for h=1 to 12
   x=cos(360/12*h)*95
   y=sin(360/12*h)*95
   box clockx+x-1,clocky+y-1,clockx+x+1,clocky+y+1
   next h

   loop

end
function init
store_sec=0

for i=1 to 23
   read number$(i)
next i
   data "one","two","three","four","five","six","seven","eight","nine"
   data "ten","eleven","twelve","thirteen","fourteen","fifteen"
   data "sixteen","seventeen","eighteen","nineteen"
   data "twenty","thirty","fourty","fifty"
endfunction


function time
time$ = get time$()

hour1$ = mid$(time$,1)
hour2$ = mid$(time$,2)
hour$ = hour1$ + hour2$
hours = val(hour$)

minutes1$ = mid$(time$,4)
minutes2$ = mid$(time$,5)
minutes$ = minutes1$ + minutes2$
minute = val(minutes$)

seconds1$ = mid$(time$,7)
seconds2$ = mid$(time$,8)
seconds$ = seconds1$ + seconds2$
second = val(seconds$)

if hours=0
   conhour$="zero"
else
   conhour$=convert(hours)
endif
   conhour$ = conhour$+" "
if minute=0
   conminute$="O clock"
else
   conminute$=convert(minute)
endif
if minute<10
conminute$="0 "+conminute$
endif
if second>0
   conminute$=conminute$+" and "
endif
   if second=0
   consecond$="exactly"
else
   consecond$=convert(second)+" second"
endif
if second>1
   consecond$=consecond$+"s"
endif
   contime$ = conhour$ + conminute$ + consecond$
endfunction contime$

function convert(figure)
if figure<20
 figure$=number$(figure)
   else
   figure$=number$(18+figure/10)+" "+number$(figure mod 10)
endif
endfunction figure$

function numbersonclock
set cursor 310,120 : print "12"
set cursor 320,340 : print "6"
endfunction
function updateclock
ink yellow,0
hourx=cos(360/12*hours-90)*65
houry=sin(360/12*hours-90)*65
line clockx,clocky,clockx+hourx,clocky+houry
numbersonclock()
`display minutes
ink blue,0
minutex=cos(360/60*minute-90)*75
minutey=sin(360/60*minute-90)*75
line clockx,clocky,clockx+minutex,clocky+minutey
ink red,0
secondx=cos(360/60*second-90)*75
secondy=sin(360/60*second-90)*75
line clockx,clocky,clockx+secondx,clocky+secondy
endfunction