Applesoft Basic and Virtual Basic code, listing, script examples
__   ___     _             _   ___          _    
\ \ / (_)_ _| |_ _  _ __ _| | | _ ) __ _ __(_)__ 
 \ V /| | '_|  _| || / _` | | | _ \/ _` (_-< / _|
  \_/ |_|_|  \__|\_,_\__,_|_| |___/\__,_/__/_\__|
                                                 

Clock

(clock3.flv) Clock
(Use authentic machine speed) not use shape table, only basic
Virtual basic Applesoft basic
rem * control D char
d${Cmd}= chr$(4)
pi= 3.14159:ci{circumference in radians}= (2 * pi)

rem * width max, height max for screen (279, 191, 159)
ml%{widthMax}= 279:mw%{widthMax}= ml%:mh%{HeightMax}= 191
if peek(33){mode 80 cols} = 80 then mh%{HeightMax}= 159 

rem * true random number
def fn alea{true random number}(x) = int(rnd(peek(78)+peek(79)*256) * x + 1)

rem * beep and buzz by default
bz%{NbreBuzz}= 3:be%{NbreBeep}= 1


section intro
text:home
gosub @splash
gosub @help
closesection

section global vars
def fn hdigi(x)= int( ( ml%{widthmax} - (x * 7.75) ) / 2 )
def fn ten(x)= int(x / 10) * 10
de%{delay}= 10
sn%{sound}= 0
ry%{radius}= 50:di%{digiEdge}= 10
# size of digit numbers
dg%{digitspace}= int( (di%{digiEdge} * 2) + (di%{digiEdge} / 2) + (di%{digiEdge} / 4) )
xo%{OrigX}= 140:yo%{OrigY}= 80
hh%{hours}= 0:mm%{mins}= 0:ss%{secs}= 0
closesection

section main program
£begin
{*** beginning of the main loop ***}
bp%{mainloop}= bp%{mainloop} + 1
# reset to defaut the values
xo%{OrigX}= 140:yo%{OrigY}= 80
hh%{hours}= 0:mm%{mins}= 0:ss%{secs}= 0
hcolor= 3 # white

# every day redraw all
# switch to graphic mode
gosub @hgrscreen
hcolor= 3 # white
# draw the clock
gosub @clockdecoration
gosub @clockcircle

{one day}
# - - - - - - - - - - - - - - - hours
for b1=0 to 23
	gosub @showhour
# - - - - - - - - - - - - - - - minutes
	for b2=0 to 59
		gosub @showminute
		# when minutes erase hour
		if b1 * 5 = mm% - 1 or (b1 - 12) * 5 = mm% - 1 then gosub @showhour
# - - - - - - - - - - - - - - - - seconds	
		for b3=0 to 59
			gosub @showseconde
			if sn%{sound} = 1 then gosub @beep
			
			ki%{keyboardInput}= peek(49152)
			if ki%{keyboardInput}= 209{"Q"} then goto @endprogram
			if ki%{keyboardInput}= 212{"T"} then gosub @setclock
			if ki%{keyboardInput}= 214{"V"} then gosub @setspeed
			if ki%{keyboardInput}= 200{"H"} then gosub @helpbis
			# toggle sound
			if sn%{sound}= 1 and ki%{keyboardInput}= 211{s} then sn%{sound}= 0:goto @soundend
			if ki%{keyboardInput}= 211{"S"} then sn%{sound}= 1
			£soundend
			gosub @keyboardcapture
			# rem * delay
			for b4= 0 to de%{delay}
next : next : next : next

# can run one month
if (bp%{mainloop} < 32) then goto @begin

£endprogram
	text:home:poke 49168,0
	gosub @credits
	end
closesection

section subscripts
{*** subscripts ***}

section diginumbers
# digit schema
# a---b
# |   |
# c---d
# |   |
# e---f
# coordinates postions
# x1%, y1% are a (origin) coordinates
# di%{digiEdge} equal to width of a -> b
£a 
x2%= x1%:y2%= y1%:return
£b 
x2%= x1% + di%{digiEdge}:y2%= y1%:return
£c 
x2%= x1%:y2%= y1% + di%{digiEdge}:return
£d 
x2%= x1% + di%{digiEdge}:y2%= y1% + di%{digiEdge}:return
£e 
x2%= x1%:y2%= y1% + (2 * di%{digiEdge}):return
£f 
x2%= x1% + di%{digiEdge}:y2%= y1% + (2 * di%{digiEdge}):return

# digit numbers
£zero
	x1%= xo%{OrigX}:y1%= yo%{OrigY}
	gosub @a:hplot x2%,y2%
	gosub @b:hplot to x2%,y2%
	gosub @f:hplot to x2%,y2%
	gosub @e:hplot to x2%,y2%
	gosub @a:hplot to x2%,y2%
return

£one
	x1%= xo%{OrigX}:y1%= yo%{OrigY}
	gosub @b:hplot x2%,y2%
	gosub @f:hplot to x2%,y2%
return

£two
	x1%= xo%{OrigX}:y1%= yo%{OrigY}
	gosub @a:hplot x2%,y2%
	gosub @b:hplot to x2%,y2%
	gosub @d:hplot to x2%,y2%
	gosub @c:hplot to x2%,y2%
	gosub @e:hplot to x2%,y2%
	gosub @f:hplot to x2%,y2%
return

£three
	x1%= xo%{OrigX}:y1%= yo%{OrigY}
	gosub @a:hplot x2%,y2%
	gosub @b:hplot to x2%,y2%
	gosub @d:hplot to x2%,y2%
	gosub @c:hplot to x2%,y2%
	gosub @d:hplot to x2%,y2%
	gosub @f:hplot to x2%,y2%
	gosub @e:hplot to x2%,y2%
return

£four
	x1%= xo%{OrigX}:y1%= yo%{OrigY}
	gosub @a:hplot x2%,y2%
	gosub @c:hplot to x2%,y2%
	gosub @d:hplot to x2%,y2%
	gosub @f:hplot to x2%,y2%
	gosub @b:hplot to x2%,y2%
return

£five
	x1%= xo%{OrigX}:y1%= yo%{OrigY}
	gosub @b:hplot x2%,y2%
	gosub @a:hplot to x2%,y2%
	gosub @c:hplot to x2%,y2%
	gosub @d:hplot to x2%,y2%
	gosub @f:hplot to x2%,y2%
	gosub @e:hplot to x2%,y2%
return

£six
	x1%= xo%{OrigX}:y1%= yo%{OrigY}
	gosub @a:hplot x2%,y2%
	gosub @e:hplot to x2%,y2%
	gosub @f:hplot to x2%,y2%
	gosub @d:hplot to x2%,y2%
	gosub @c:hplot to x2%,y2%
return

£seven
	x1%= xo%{OrigX}:y1%= yo%{OrigY}
	gosub @a:hplot x2%,y2%
	gosub @b:hplot to x2%,y2%
	gosub @f:hplot to x2%,y2%
return

£eight
	x1%= xo%{OrigX}:y1%= yo%{OrigY}
	gosub @a:hplot x2%,y2%
	gosub @e:hplot to x2%,y2%
	gosub @f:hplot to x2%,y2%
	gosub @d:hplot to x2%,y2%
	gosub @c:hplot to x2%,y2%
	gosub @a:hplot to x2%,y2%
	gosub @b:hplot to x2%,y2%
	gosub @d:hplot to x2%,y2%
return

£nine
	x1%= xo%{OrigX}:y1%= yo%{OrigY}
	gosub @f:hplot x2%,y2%
	gosub @b:hplot to x2%,y2%
	gosub @a:hplot to x2%,y2%
	gosub @c:hplot to x2%,y2%
	gosub @d:hplot to x2%,y2%
return
closesection

section draw digital clock
£digisecs
	if ss%{secs} < 10 then s1%= 1:s2%= ss%{secs} + 1
	if ss%{secs} >= 10 then s1%= int(ss%{secs} / 10) + 1:s2%= ss%{secs} - fn ten(ss%{secs}) + 1
	on s1% gosub @zero, @one, @two, @three, @four, @five, @six, @seven, @eight, @nine
	xo%{OrigX}= xo%{OrigX} + (di%{digiEdge} + int(di%{digiEdge} / 4))
	on s2% gosub @zero, @one, @two, @three, @four, @five, @six, @seven, @eight, @nine
return

£digimins
	if mm%{mins} < 10 then m1%= 1:m2%= mm%{mins} + 1
	if mm%{mins} >= 10 then m1%= int(mm%{mins} / 10) + 1:m2%= mm%{mins} - fn ten(mm%{mins}) + 1
	on m1% gosub @zero, @one, @two, @three, @four, @five, @six, @seven, @eight, @nine
	xo%{OrigX}= xo%{OrigX} + (di%{digiEdge} + int(di%{digiEdge} / 4))
	on m2% gosub @zero, @one, @two, @three, @four, @five, @six, @seven, @eight, @nine
return

£digihours
	if hh%{hours} < 10 then h1%= 1:h2%= hh%{hours} + 1
	if hh%{hours} >= 10 then h1%= int(hh%{hours} / 10) + 1:h2%= hh%{hours} - fn ten(hh%{hours}) + 1
	on h1% gosub @zero, @one, @two, @three, @four, @five, @six, @seven, @eight, @nine
	xo%{OrigX}= xo%{OrigX} + (di%{digiEdge} + int(di%{digiEdge} / 4))
	on h2% gosub @zero, @one, @two, @three, @four, @five, @six, @seven, @eight, @nine
return
closesection

section draw arrows 
£secondsarrows
	ag= (ss%{secs} + 45) * (ci / 60) 
	x2= xo%{OrigX} + ( ry%{radius} * cos(ag) )
	y2= yo%{OrigY} + ( ry%{radius} * sin(ag) )
	x1= xo%{OrigX} + ( (ry%{radius}-6) * cos(ag) )
	y1= yo%{OrigY} + ( (ry%{radius}-6) * sin(ag) )
	hplot x1{OrigX},y1{OrigY} to x2,y2
return 

£minutesarrows
	ag= (mm%{mins} + 45) * (ci / 60)
	x2= xo%{OrigX} + ( (ry%{radius}-10) * cos(ag) )
	y2= yo%{OrigY} + ( (ry%{radius}-10) * sin(ag) )
	x1= xo%{OrigX} + ( (ry%{radius}-40) * cos(ag) )
	y1= yo%{OrigY} + ( (ry%{radius}-40) * sin(ag) )
	hplot x1{OrigX},y1{OrigY} to x2,y2
return

£hoursarrows
	ag= (hh%{hours} + 9) * (ci / 12) 
	x2= xo%{OrigX} + ( (ry%{radius} - 18) * cos(ag) ) 
	y2= yo%{OrigY} + ( (ry%{radius} - 18) * sin(ag) )
	x1= xo%{OrigX} + ( (ry%{radius}-40) * cos(ag) )
	y1= yo%{OrigY} + ( (ry%{radius}-40) * sin(ag) )
	hplot x1{OrigX},y1{OrigY} to x2,y2
return
closesection

section show the clock time
£showseconde
	# erase old second arrow
	hcolor= 0
	xo%{OrigX}= 140:yo%{OrigY}= 80
	gosub @secondsarrows
	xo%{OrigX}= fn hdigi(di%{digiEdge}) :yo%{OrigY}= 160
	xo% = xo% + ( dg%{digitspace} * 2 )
	gosub @digisecs
	# draw new second arrow
	hcolor= 3
	ss%{secs}= b3 # new second arrow = b3
	xo%{OrigX}= 140:yo%{OrigY}= 80
	gosub @secondsarrows
	xo%{OrigX}= fn hdigi(di%{digiEdge}) :yo%{OrigY}= 160
	xo% = xo% + ( dg%{digitspace} * 2 )
	gosub @digisecs
return

£showminute
	# erase old minute
	hcolor= 0
	xo%{OrigX}= 140:yo%{OrigY}= 80
	gosub @minutesarrows
	mm%{mins} = 88 # digit erase
	xo%{OrigX}= fn hdigi(di%{digiEdge}) :yo%{OrigY}= 160
	xo% = xo% + dg%{digitspace}
	gosub @digimins
	# new time
	hcolor= 3
	mm%{mins}= b2
	xo%{OrigX}= 140:yo%{OrigY}= 80
	gosub @minutesarrows
	xo%{OrigX}= fn hdigi(di%{digiEdge}) :yo%{OrigY}= 160
	xo% = xo% + dg%{digitspace}
	gosub @digimins
return

£showhour
	# erase old hour
	hcolor= 0
	xo%{OrigX}= 140:yo%{OrigY}= 80
	gosub @hoursarrows
	hh%{hours} = 88 # digit erase
	xo%{OrigX}= fn hdigi(di%{digiEdge}) :yo%{OrigY}= 160
	gosub @digihours
	# new time
	hcolor= 3
	hh%{hours}= b1
	xo%{OrigX}= 140:yo%{OrigY}= 80
	gosub @hoursarrows
	xo%{OrigX}= fn hdigi(di%{digiEdge}) :yo%{OrigY}= 160
	gosub @digihours
return
closesection

section clock draw
£clockdecoration
	s5 = ci{radiantcircle} / 14
	for b7= 0 to ci{radiantcircle} + 0.1 step s5
		v1= (ry%{radius} + 20) * cos(b7)
		v2= (ry%{radius} + 20) * sin(b7)
		x2%= int( xo%{OrigX} + v1 )
		y2%= int( yo%{OrigY} + v2 )
		if b7 = 0 then hplot x2%,y2%
		if b7 > 0 then hplot to x2%,y2%
	next
	s5 = ci{radiantcircle} / 14
	for b7= 0 to ci{radiantcircle} + 0.1 step s5
		v1= (ry%{radius} - 46) * cos(b7)
		v2= (ry%{radius} - 46) * sin(b7)
		x2%= int( xo%{OrigX} + v1 )
		y2%= int( yo%{OrigY} + v2 )
		if b7 = 0 then hplot x2%,y2%
		if b7 > 0 then hplot to x2%,y2%
	next
return

£clockcircle
	s4 = ci{radiantcircle} / 12
	for b6= (s4 * 9) to ( ci{radiantcircle} + 0.1 ) + (s4 * 9) step s4
		v1= (ry%{radius} + 5) * cos(b6)
		v2= (ry%{radius} + 5) * sin(b6)
		x2%= int( xo%{OrigX} + v1 )
		y2%= int( yo%{OrigY} + v2 )
		hplot x2%,y2%
	next
return
closesection

section clock settings
£setclock
	poke 49168,0
	text:home
	print
	input "hour 1/23 ? ";b1
	input "minute 1/59 ? ";b2
	input "second 1/59 ? ";b3
	if b1 > 23 then b1= 23
	if b1 < 0 then b1= 0
	if b2 > 59 then b2= 59
	if b2 < 0 then b2= 0
	if b3 > 59 then b3= 59
	if b3 < 0 then b3= 0
	gosub @hgrscreen
	xo%{OrigX}= 140:yo%{OrigY}= 80
	gosub @clockdecoration
	gosub @clockcircle
	gosub @showhour
	gosub @showminute
	gosub @showseconde
return

£setspeed
	poke 49168,0
	text:home
	print "actual speed: ";de%{delay}
	input "speed 1/1000 ?";de%{delay}
	if de%{delay} <= 0 then de%{delay}= 1
	gosub @hgrscreen
	xo%{OrigX}= 140:yo%{OrigY}= 80
	gosub @clockdecoration
	gosub @clockcircle
	gosub @showhour
	gosub @showminute
	gosub @showseconde
return

£help
	poke 49168,0
	text:home
	vtab(peek(37) + 2):
	s$= "     *** clock  ***    ":gosub @centertext
	print s$
	vtab(peek(37) + 2):
	s$= "     *** by loz ***    ":gosub @centertext
	print s$
	vtab(peek(37) + 2):
	s$= "q-> quit               ":gosub @centertext
	print s$
	vtab(peek(37) + 2):
	s$= "h-> this help          ":gosub @centertext
	print s$
	vtab(peek(37) + 2):
	s$= "t-> set time           ":gosub @centertext
	print s$
	vtab(peek(37) + 2):
	s$= "v-> time speed         ":gosub @centertext
	print s$
	vtab(peek(37) + 2):
	s$= "s-> toggle sound on/off":gosub @centertext
	print s$
	vtab(peek(37) + 2):
	s$= "type enter to continue ":gosub @centertext
	print s$
	get s$
return

£helpbis
	gosub @help
	gosub @hgrscreen
	xo%{OrigX}= 140:yo%{OrigY}= 80
	gosub @clockcircle
	gosub @clockdecoration
	gosub @showhour
	gosub @showminute
	gosub @showseconde
return
closesection

closesection

£hgrscreen
	if peek(33) < 41 and mh%{MaxHauteur} > 159 then hg$= "hgr2"
	if peek(33) < 41 and mh%{MaxHauteur} <= 159 then hg$= "hgr"
	rem * mod 80 colonnes
	if peek(33) > 40 then hg$= "hgr"
	if hg$ = "hgr" then hgr
	if hg$ = "hgr2" then hgr2
return

£splash
	text:home
	vtab(3):print
	vtab(peek(37) + 2)
	s${sentence}= "applesoft basic code":gosub @centertext
	print s${sentence}
return

£credits
	text:home
	gosub @beep
	vtab(3):print
	vtab(peek(37) + 2)
	s${sentence}= "by andres aka loz":gosub @centertext
	print s${sentence}
return

£keyboardcapture
	rem * capture last keyboard entered
	ki%{keyboardInput}= peek(49152)
	rem * reset
	poke 49168,0
	rem * actions
	if ki% = 155{Escape} then goto @endprogram
	if chr$(ki%) = "t" then text
return

£centertext
	t9%{leftSpace}= int( (peek(33) - len(s${sentence}) ) / 2 ) 
	rem * is result is null
	if (t9% < 1) then t9%= 0
	htab(t9%{leftSpace}+1)
return

£beep
if (be%{NbreBeep} < 2) then be%{NbreBeep}= 1
	for b9= 1 to be%{NbreBeep}
		print chr$(7);
	next
return
10 REM - CLOCK7.BAS - 14/01/2012 - 08h34 - BY - ANDRES - AKA - LOZ - COPYLEFT
20 D$= CHR$(4)
30 PI= 3.14159:CI= (2 * PI)
40 ML%= 279:MW%= ML%:MH%= 191
50 IF PEEK(33) = 80 THEN MH%= 159 
60 DEF FN ALEA(X) = INT(RND(PEEK(78)+PEEK(79)*256) * X + 1)
70 BZ%= 3:BE%= 1
80 TEXT:HOME
90 GOSUB 3480
100 GOSUB 3020
110 DEF FN HDIGI(X)= INT( ( ML% - (X * 7.75) ) / 2 )
120 DEF FN TEN(X)= INT(X / 10) * 10
130 DE%= 10
140 SN%= 0
150 RY%= 50:DI%= 10
160 DG%= INT( (DI% * 2) + (DI% / 2) + (DI% / 4) )
170 XO%= 140:YO%= 80
180 HH%= 0:MM%= 0:SS%= 0
190 REM->BEGIN
200 BP%= BP% + 1
210 XO%= 140:YO%= 80
220 HH%= 0:MM%= 0:SS%= 0
230 HCOLOR= 3
240 GOSUB 3410
250 HCOLOR= 3
260 GOSUB 2370
270 GOSUB 2570
280 FOR B1=0 TO 23
290 GOSUB 2230
300 FOR B2=0 TO 59
310 GOSUB 2070
320 IF B1 * 5 = MM% - 1 OR (B1 - 12) * 5 = MM% - 1 THEN GOSUB 2230
330 FOR B3=0 TO 59
340 GOSUB 1920
350 IF SN% = 1 THEN GOSUB 3740
360 KI%= PEEK(49152)
370 IF KI%= 209 THEN GOTO 490
380 IF KI%= 212 THEN GOSUB 2670
390 IF KI%= 214 THEN GOSUB 2880
400 IF KI%= 200 THEN GOSUB 3310
410 IF SN%= 1 AND KI%= 211 THEN SN%= 0:GOTO 440
420 IF KI%= 211 THEN SN%= 1
430 REM->SOUNDEND
440 GOSUB 3630
450 FOR B4= 0 TO DE%
460 NEXT : NEXT : NEXT : NEXT
470 IF (BP% < 32) THEN GOTO 200
480 REM->ENDPROGRAM
490 TEXT:HOME:POKE 49168,0
500 GOSUB 3550
510 END
520 REM->A 
530 X2%= X1%:Y2%= Y1%:RETURN
540 REM->B 
550 X2%= X1% + DI%:Y2%= Y1%:RETURN
560 REM->C 
570 X2%= X1%:Y2%= Y1% + DI%:RETURN
580 REM->D 
590 X2%= X1% + DI%:Y2%= Y1% + DI%:RETURN
600 REM->E 
610 X2%= X1%:Y2%= Y1% + (2 * DI%):RETURN
620 REM->F 
630 X2%= X1% + DI%:Y2%= Y1% + (2 * DI%):RETURN
640 REM->ZERO
650 X1%= XO%:Y1%= YO%
660 GOSUB 530:HPLOT X2%,Y2%
670 GOSUB 550:HPLOT TO X2%,Y2%
680 GOSUB 630:HPLOT TO X2%,Y2%
690 GOSUB 610:HPLOT TO X2%,Y2%
700 GOSUB 530:HPLOT TO X2%,Y2%
710 RETURN
720 REM->ONE
730 X1%= XO%:Y1%= YO%
740 GOSUB 550:HPLOT X2%,Y2%
750 GOSUB 630:HPLOT TO X2%,Y2%
760 RETURN
770 REM->TWO
780 X1%= XO%:Y1%= YO%
790 GOSUB 530:HPLOT X2%,Y2%
800 GOSUB 550:HPLOT TO X2%,Y2%
810 GOSUB 590:HPLOT TO X2%,Y2%
820 GOSUB 570:HPLOT TO X2%,Y2%
830 GOSUB 610:HPLOT TO X2%,Y2%
840 GOSUB 630:HPLOT TO X2%,Y2%
850 RETURN
860 REM->THREE
870 X1%= XO%:Y1%= YO%
880 GOSUB 530:HPLOT X2%,Y2%
890 GOSUB 550:HPLOT TO X2%,Y2%
900 GOSUB 590:HPLOT TO X2%,Y2%
910 GOSUB 570:HPLOT TO X2%,Y2%
920 GOSUB 590:HPLOT TO X2%,Y2%
930 GOSUB 630:HPLOT TO X2%,Y2%
940 GOSUB 610:HPLOT TO X2%,Y2%
950 RETURN
960 REM->FOUR
970 X1%= XO%:Y1%= YO%
980 GOSUB 530:HPLOT X2%,Y2%
990 GOSUB 570:HPLOT TO X2%,Y2%
1000 GOSUB 590:HPLOT TO X2%,Y2%
1010 GOSUB 630:HPLOT TO X2%,Y2%
1020 GOSUB 550:HPLOT TO X2%,Y2%
1030 RETURN
1040 REM->FIVE
1050 X1%= XO%:Y1%= YO%
1060 GOSUB 550:HPLOT X2%,Y2%
1070 GOSUB 530:HPLOT TO X2%,Y2%
1080 GOSUB 570:HPLOT TO X2%,Y2%
1090 GOSUB 590:HPLOT TO X2%,Y2%
1100 GOSUB 630:HPLOT TO X2%,Y2%
1110 GOSUB 610:HPLOT TO X2%,Y2%
1120 RETURN
1130 REM->SIX
1140 X1%= XO%:Y1%= YO%
1150 GOSUB 530:HPLOT X2%,Y2%
1160 GOSUB 610:HPLOT TO X2%,Y2%
1170 GOSUB 630:HPLOT TO X2%,Y2%
1180 GOSUB 590:HPLOT TO X2%,Y2%
1190 GOSUB 570:HPLOT TO X2%,Y2%
1200 RETURN
1210 REM->SEVEN
1220 X1%= XO%:Y1%= YO%
1230 GOSUB 530:HPLOT X2%,Y2%
1240 GOSUB 550:HPLOT TO X2%,Y2%
1250 GOSUB 630:HPLOT TO X2%,Y2%
1260 RETURN
1270 REM->EIGHT
1280 X1%= XO%:Y1%= YO%
1290 GOSUB 530:HPLOT X2%,Y2%
1300 GOSUB 610:HPLOT TO X2%,Y2%
1310 GOSUB 630:HPLOT TO X2%,Y2%
1320 GOSUB 590:HPLOT TO X2%,Y2%
1330 GOSUB 570:HPLOT TO X2%,Y2%
1340 GOSUB 530:HPLOT TO X2%,Y2%
1350 GOSUB 550:HPLOT TO X2%,Y2%
1360 GOSUB 590:HPLOT TO X2%,Y2%
1370 RETURN
1380 REM->NINE
1390 X1%= XO%:Y1%= YO%
1400 GOSUB 630:HPLOT X2%,Y2%
1410 GOSUB 550:HPLOT TO X2%,Y2%
1420 GOSUB 530:HPLOT TO X2%,Y2%
1430 GOSUB 570:HPLOT TO X2%,Y2%
1440 GOSUB 590:HPLOT TO X2%,Y2%
1450 RETURN
1460 REM->DIGISECS
1470 IF SS% < 10 THEN S1%= 1:S2%= SS% + 1
1480 IF SS% >= 10 THEN S1%= INT(SS% / 10) + 1:S2%= SS% - FN TEN(SS%) + 1
1490 ON S1% GOSUB 650, 730, 780, 870, 970, 1050, 1140, 1220, 1280, 1390
1500 XO%= XO% + (DI% + INT(DI% / 4))
1510 ON S2% GOSUB 650, 730, 780, 870, 970, 1050, 1140, 1220, 1280, 1390
1520 RETURN
1530 REM->DIGIMINS
1540 IF MM% < 10 THEN M1%= 1:M2%= MM% + 1
1550 IF MM% >= 10 THEN M1%= INT(MM% / 10) + 1:M2%= MM% - FN TEN(MM%) + 1
1560 ON M1% GOSUB 650, 730, 780, 870, 970, 1050, 1140, 1220, 1280, 1390
1570 XO%= XO% + (DI% + INT(DI% / 4))
1580 ON M2% GOSUB 650, 730, 780, 870, 970, 1050, 1140, 1220, 1280, 1390
1590 RETURN
1600 REM->DIGIHOURS
1610 IF HH% < 10 THEN H1%= 1:H2%= HH% + 1
1620 IF HH% >= 10 THEN H1%= INT(HH% / 10) + 1:H2%= HH% - FN TEN(HH%) + 1
1630 ON H1% GOSUB 650, 730, 780, 870, 970, 1050, 1140, 1220, 1280, 1390
1640 XO%= XO% + (DI% + INT(DI% / 4))
1650 ON H2% GOSUB 650, 730, 780, 870, 970, 1050, 1140, 1220, 1280, 1390
1660 RETURN
1670 REM->SECONDSARROWS
1680 AG= (SS% + 45) * (CI / 60) 
1690 X2= XO% + ( RY% * COS(AG) )
1700 Y2= YO% + ( RY% * SIN(AG) )
1710 X1= XO% + ( (RY%-6) * COS(AG) )
1720 Y1= YO% + ( (RY%-6) * SIN(AG) )
1730 HPLOT X1,Y1 TO X2,Y2
1740 RETURN 
1750 REM->MINUTESARROWS
1760 AG= (MM% + 45) * (CI / 60)
1770 X2= XO% + ( (RY%-10) * COS(AG) )
1780 Y2= YO% + ( (RY%-10) * SIN(AG) )
1790 X1= XO% + ( (RY%-40) * COS(AG) )
1800 Y1= YO% + ( (RY%-40) * SIN(AG) )
1810 HPLOT X1,Y1 TO X2,Y2
1820 RETURN
1830 REM->HOURSARROWS
1840 AG= (HH% + 9) * (CI / 12) 
1850 X2= XO% + ( (RY% - 18) * COS(AG) ) 
1860 Y2= YO% + ( (RY% - 18) * SIN(AG) )
1870 X1= XO% + ( (RY%-40) * COS(AG) )
1880 Y1= YO% + ( (RY%-40) * SIN(AG) )
1890 HPLOT X1,Y1 TO X2,Y2
1900 RETURN
1910 REM->SHOWSECONDE
1920 HCOLOR= 0
1930 XO%= 140:YO%= 80
1940 GOSUB 1680
1950 XO%= FN HDIGI(DI%) :YO%= 160
1960 XO% = XO% + ( DG% * 2 )
1970 GOSUB 1470
1980 HCOLOR= 3
1990 SS%= B3
2000 XO%= 140:YO%= 80
2010 GOSUB 1680
2020 XO%= FN HDIGI(DI%) :YO%= 160
2030 XO% = XO% + ( DG% * 2 )
2040 GOSUB 1470
2050 RETURN
2060 REM->SHOWMINUTE
2070 HCOLOR= 0
2080 XO%= 140:YO%= 80
2090 GOSUB 1760
2100 MM% = 88
2110 XO%= FN HDIGI(DI%) :YO%= 160
2120 XO% = XO% + DG%
2130 GOSUB 1540
2140 HCOLOR= 3
2150 MM%= B2
2160 XO%= 140:YO%= 80
2170 GOSUB 1760
2180 XO%= FN HDIGI(DI%) :YO%= 160
2190 XO% = XO% + DG%
2200 GOSUB 1540
2210 RETURN
2220 REM->SHOWHOUR
2230 HCOLOR= 0
2240 XO%= 140:YO%= 80
2250 GOSUB 1840
2260 HH% = 88
2270 XO%= FN HDIGI(DI%) :YO%= 160
2280 GOSUB 1610
2290 HCOLOR= 3
2300 HH%= B1
2310 XO%= 140:YO%= 80
2320 GOSUB 1840
2330 XO%= FN HDIGI(DI%) :YO%= 160
2340 GOSUB 1610
2350 RETURN
2360 REM->CLOCKDECORATION
2370 S5 = CI / 14
2380 FOR B7= 0 TO CI + 0.1 STEP S5
2390 V1= (RY% + 20) * COS(B7)
2400 V2= (RY% + 20) * SIN(B7)
2410 X2%= INT( XO% + V1 )
2420 Y2%= INT( YO% + V2 )
2430 IF B7 = 0 THEN HPLOT X2%,Y2%
2440 IF B7 > 0 THEN HPLOT TO X2%,Y2%
2450 NEXT
2460 S5 = CI / 14
2470 FOR B7= 0 TO CI + 0.1 STEP S5
2480 V1= (RY% - 46) * COS(B7)
2490 V2= (RY% - 46) * SIN(B7)
2500 X2%= INT( XO% + V1 )
2510 Y2%= INT( YO% + V2 )
2520 IF B7 = 0 THEN HPLOT X2%,Y2%
2530 IF B7 > 0 THEN HPLOT TO X2%,Y2%
2540 NEXT
2550 RETURN
2560 REM->CLOCKCIRCLE
2570 S4 = CI / 12
2580 FOR B6= (S4 * 9) TO ( CI + 0.1 ) + (S4 * 9) STEP S4
2590 V1= (RY% + 5) * COS(B6)
2600 V2= (RY% + 5) * SIN(B6)
2610 X2%= INT( XO% + V1 )
2620 Y2%= INT( YO% + V2 )
2630 HPLOT X2%,Y2%
2640 NEXT
2650 RETURN
2660 REM->SETCLOCK
2670 POKE 49168,0
2680 TEXT:HOME
2690 ?
2700 INPUT "HOUR 1/23 ? ";B1
2710 INPUT "MINUTE 1/59 ? ";B2
2720 INPUT "SECOND 1/59 ? ";B3
2730 IF B1 > 23 THEN B1= 23
2740 IF B1 < 0 THEN B1= 0
2750 IF B2 > 59 THEN B2= 59
2760 IF B2 < 0 THEN B2= 0
2770 IF B3 > 59 THEN B3= 59
2780 IF B3 < 0 THEN B3= 0
2790 GOSUB 3410
2800 XO%= 140:YO%= 80
2810 GOSUB 2370
2820 GOSUB 2570
2830 GOSUB 2230
2840 GOSUB 2070
2850 GOSUB 1920
2860 RETURN
2870 REM->SETSPEED
2880 POKE 49168,0
2890 TEXT:HOME
2900 ? "ACTUAL SPEED: ";DE%
2910 INPUT "SPEED 1/1000 ?";DE%
2920 IF DE% <= 0 THEN DE%= 1
2930 GOSUB 3410
2940 XO%= 140:YO%= 80
2950 GOSUB 2370
2960 GOSUB 2570
2970 GOSUB 2230
2980 GOSUB 2070
2990 GOSUB 1920
3000 RETURN
3010 REM->HELP
3020 POKE 49168,0
3030 TEXT:HOME
3040 VTAB(PEEK(37) + 2):
3050 S$= "     *** CLOCK  ***    ":GOSUB 3690
3060 ? S$
3070 VTAB(PEEK(37) + 2):
3080 S$= "     *** BY LOZ ***    ":GOSUB 3690
3090 ? S$
3100 VTAB(PEEK(37) + 2):
3110 S$= "Q-> QUIT               ":GOSUB 3690
3120 ? S$
3130 VTAB(PEEK(37) + 2):
3140 S$= "H-> THIS HELP          ":GOSUB 3690
3150 ? S$
3160 VTAB(PEEK(37) + 2):
3170 S$= "T-> SET TIME           ":GOSUB 3690
3180 ? S$
3190 VTAB(PEEK(37) + 2):
3200 S$= "V-> TIME SPEED         ":GOSUB 3690
3210 ? S$
3220 VTAB(PEEK(37) + 2):
3230 S$= "S-> TOGGLE SOUND ON/OFF":GOSUB 3690
3240 ? S$
3250 VTAB(PEEK(37) + 2):
3260 S$= "TYPE ENTER TO CONTINUE ":GOSUB 3690
3270 ? S$
3280 GET S$
3290 RETURN
3300 REM->HELPBIS
3310 GOSUB 3020
3320 GOSUB 3410
3330 XO%= 140:YO%= 80
3340 GOSUB 2570
3350 GOSUB 2370
3360 GOSUB 2230
3370 GOSUB 2070
3380 GOSUB 1920
3390 RETURN
3400 REM->HGRSCREEN
3410 IF PEEK(33) < 41 AND MH% > 159 THEN HG$= "HGR2"
3420 IF PEEK(33) < 41 AND MH% <= 159 THEN HG$= "HGR"
3430 IF PEEK(33) > 40 THEN HG$= "HGR"
3440 IF HG$ = "HGR" THEN HGR
3450 IF HG$ = "HGR2" THEN HGR2
3460 RETURN
3470 REM->SPLASH
3480 TEXT:HOME
3490 VTAB(3):?
3500 VTAB(PEEK(37) + 2)
3510 S$= "APPLESOFT BASIC CODE":GOSUB 3690
3520 ? S$
3530 RETURN
3540 REM->CREDITS
3550 TEXT:HOME
3560 GOSUB 3740
3570 VTAB(3):?
3580 VTAB(PEEK(37) + 2)
3590 S$= "BY ANDRES AKA LOZ":GOSUB 3690
3600 ? S$
3610 RETURN
3620 REM->KEYBOARDCAPTURE
3630 KI%= PEEK(49152)
3640 POKE 49168,0
3650 IF KI% = 155 THEN GOTO 490
3660 IF CHR$(KI%) = "T" THEN TEXT
3670 RETURN
3680 REM->CENTERTEXT
3690 T9%= INT( (PEEK(33) - LEN(S$) ) / 2 ) 
3700 IF (T9% < 1) THEN T9%= 0
3710 HTAB(T9%+1)
3720 RETURN
3730 REM->BEEP
3740 IF (BE% < 2) THEN BE%= 1
3750 FOR B9= 1 TO BE%
3760 ? CHR$(7);
3770 NEXT
3780 RETURN

Flight (with paddle)

(plane rot.flv) Flight (with paddle)
(Use faster emulation speed) very slow with a standard apple2
Virtual basic Applesoft basic
rem * control D char
d${Cmd}= chr$(4)
pi= 3.14159:ci{circumference in radians}= (2 * pi)

rem * width max, eight max for screen (279, 191, 159)
ml%{widthMax}= 279:mh%{HeightMax}= 191
if peek(33){mode 80 cols} = 80 then mh%{HeightMax}= 159 

rem * true random number
def fn alea{true random number}(x) = int(rnd(peek(78)+peek(79)*256) * x + 1)

rem * beep and buzz by default
bz%{NbreBuzz}= 3:be%{NbreBeep}= 1

{*** my program flight ***}
section intro
	text:home
	gosub @splash
	vtab(peek(37) + 2):s$= "*** flight ***":gosub @centertext{this subscript is in lib/lib.baz}:print s$:get s$
	
	# global vars
	p2{pi + half}= pi * 1.5
	
	mh%{max height}= 159
	hz{horizon}= 110
	lo{main-loops}= 8
	hl{horizontal-lines}= 279 / lo{main-loops}
	# to reduce top
	vl{vertical-lines}= hl{horizontal-lines} / 3
	vs{h-lines-size}= (mh%{max height} - hz{horizon}) / lo{main-loops}
	
	# rotation
	s{Inc}= (ci{circonference} / 32) {incrementation of circle}

	vtab(22)
closesection
section main program
	£begin {*** forever loop ***}
		gosub @hgrscreen
		
		x= ( pdl(0) * 1.094 ) # pdl return 0-255
		y= ( pdl(1) * 0.623 )
		
		# turn right/left
		if x <> x3 then s = s * -1
		if av{angle of plane} > ci then av = 0
		av = av{angle of plane} + s
		
		x3{store x}= x
		y3{store y}= y

		x1= int(x + 27):y1= int(y)
		 
		# plane
x2= (x1+(22.00*sin(2.36+av))):y2= (y1+(22.00*cos(2.36+av))):gosub @checkxy:hplot x2,y2
x2= (x1+(16.28*sin(2.17+av))):y2= (y1+(16.28*cos(2.17+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(6.00*sin(0.79+av))):y2= (y1+(6.00*cos(0.79+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(21.02*sin(1.91+av))):y2= (y1+(21.02*cos(1.91+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(25.06*sin(1.86+av))):y2= (y1+(25.06*cos(1.86+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(26.57*sin(2.01+av))):y2= (y1+(26.57*cos(2.01+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(44.41*sin(2.22+av))):y2= (y1+(44.41*cos(2.22+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(28.16*sin(2.25+av))):y2= (y1+(28.16*cos(2.25+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(22.00*sin(2.36+av))):y2= (y1+(22.00*cos(2.36+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(21.02*sin(1.91+av))):y2= (y1+(21.02*cos(1.91+av))):gosub @checkxy:hplot x2,y2
x2= (x1+(19.92*sin(2.05+av))):y2= (y1+(19.92*cos(2.05+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(22.20*sin(2.22+av))):y2= (y1+(22.20*cos(2.22+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(25.71*sin(2.12+av))):y2= (y1+(25.71*cos(2.12+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(26.57*sin(2.01+av))):y2= (y1+(26.57*cos(2.01+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(6.00*sin(0.79+av))):y2= (y1+(6.00*cos(0.79+av))):gosub @checkxy:hplot x2,y2
x2= (x1+(3.00*sin(2.36+av))):y2= (y1+(3.00*cos(2.36+av))):gosub @checkxy:hplot to x2,y2
x2= (x1+(44.41*sin(2.22+av))):y2= (y1+(44.41*cos(2.22+av))):gosub @checkxy:hplot x2,y2
x2= (x1+(41.00*sin(2.36+av))):y2= (y1+(41.00*cos(2.36+av))):gosub @checkxy:hplot to x2,y2
		
		hplot 1,hz{horizon} to 279,hz{horizon}
		vp{h-lines-progress}= vp{h-lines-progress} + 1 
		if vp{h-lines-progress} > lo{main-loops} then vp{h-lines-progress}= 0
		
		for b1= 0 to lo{main-loops}
			y1= hz{horizon} + (b1 * vs{h-lines-size}) + (b1 + 1 * vp{h-lines-progress})
			y2= hz{horizon} + (b1 * vs{h-lines-size}) + (b1 + 1 * vp{h-lines-progress})
			x1= 1:x2= 279
			gosub @checkxy
			hplot x1,y1 to x2,y2
		next
		
		for b1= 0 to lo{main-loops}
			x1= x + (b1 * vl{vertical-lines})
			x2= b1 * hl{horizontal-lines}
			y1 = hz{horizon}
			y2 = 159
			gosub @checkxy
			hplot x1,y1 to x2,y2
		next
		
	gosub @longdowntime 
	gosub @keyboardcapture {this subscript is in lib/lib.baz}
	goto @begin {forever loop}
	
	£endprogram
	text:home:poke 49168,0
	gosub @credits
	end
closesection
section subscripts

closesection
£hgrscreen
	if peek(33) < 41 and mh%{MaxHauteur} > 159 then hg$= "hgr2"
	if peek(33) < 41 and mh%{MaxHauteur} <= 159 then hg$= "hgr"
	rem * mod 80 colonnes
	if peek(33) > 40 then hg$= "hgr"
	if hg$ = "hgr" then hgr
	if hg$ = "hgr2" then hgr2
return

£checkxy
	rem * check x,y to prevent overflow
	x1= int(x1):x2= int(x2):y1= int(y1):y2= int(y2)
	if x1 >= 1 and x1 < ml% and x2 >= 1 and x2 < ml% and y1 >= 1 and y1 < mh% and y2 >= 1 and y2 < mh% then return
	if x1 > ml%{widthMax} then x1= ml%{widthMax}
	if x2 > ml%{widthMax} then x2= ml%{widthMax}
	if y1 > mh%{HeightMax} then y1= mh%{HeightMax}
	if y2 > mh%{HeightMax} then y2= mh%{HeightMax}
	if x1 < 1 then x1= 1
	if x2 < 1 then x2= 1
	if y1 < 1 then y1= 1
	if y2 < 1 then y2= 1
return

£splash
	text:home
	vtab(3):print
	vtab(peek(37) + 2)
	s${sentence}= "applesoft basic code":gosub @centertext
	print s${sentence}
return

£credits
	text:home
	gosub @beep
	vtab(3):print
	vtab(peek(37) + 2)
	s${sentence}= "by andres aka loz":gosub @centertext
	print s${sentence}
return

£keyboardcapture
	rem * capture last keyboard entered
	ki%{keyboardInput}= peek(49152)
	rem * reset
	poke 49168,0
	rem * actions
	if ki% = 155{Escape} then goto @endprogram
	if chr$(ki%) = "t" then text
return

£centertext
	t9%{leftSpace}= int( (peek(33) - len(s${sentence}) ) / 2 ) 
	rem * is result is null
	if (t9% < 1) then t9%= 0
	htab(t9%{leftSpace}+1)
return

£beep
if (be%{NbreBeep} < 2) then be%{NbreBeep}= 1
	for b9= 1 to be%{NbreBeep}
		print chr$(7);
	next
return

£longdowntime
	for b9= 1 to 2000:next b9
return

£shortdowntime
	for b9= 1 to 800:next b9
return
10 REM - PLANE-ROT.BAS - 15/04/2011 - 14h44 - BY - ANDRES - AKA - LOZ - COPYLEFT
20 D$= CHR$(4)
30 PI= 3.14159:CI= (2 * PI)
40 ML%= 279:MH%= 191
50 IF PEEK(33) = 80 THEN MH%= 159 
60 DEF FN ALEA(X) = INT(RND(PEEK(78)+PEEK(79)*256) * X + 1)
70 BZ%= 3:BE%= 1
80 TEXT:HOME
90 GOSUB 930
100 VTAB(PEEK(37) + 2):S$= "*** FLIGHT ***":GOSUB 1140:? S$:GET S$
110 P2= PI * 1.5
120 MH%= 159
130 HZ= 110
140 LO= 8
150 HL= 279 / LO
160 VL= HL / 3
170 VS= (MH% - HZ) / LO
180 S= (CI / 32) 
190 VTAB(22)
200 REM->BEGIN 
210 GOSUB 740
220 X= ( PDL(0) * 1.094 )
230 Y= ( PDL(1) * 0.623 )
240 IF X <> X3 THEN S = S * -1
250 IF AV > CI THEN AV = 0
260 AV = AV + S
270 X3= X
280 Y3= Y
290 X1= INT(X + 27):Y1= INT(Y)
300 X2= (X1+(22.00*SIN(2.36+AV))):Y2= (Y1+(22.00*COS(2.36+AV))):GOSUB 810:HPLOT X2,Y2
310 X2= (X1+(16.28*SIN(2.17+AV))):Y2= (Y1+(16.28*COS(2.17+AV))):GOSUB 810:HPLOT TO X2,Y2
320 X2= (X1+(6.00*SIN(0.79+AV))):Y2= (Y1+(6.00*COS(0.79+AV))):GOSUB 810:HPLOT TO X2,Y2
330 X2= (X1+(21.02*SIN(1.91+AV))):Y2= (Y1+(21.02*COS(1.91+AV))):GOSUB 810:HPLOT TO X2,Y2
340 X2= (X1+(25.06*SIN(1.86+AV))):Y2= (Y1+(25.06*COS(1.86+AV))):GOSUB 810:HPLOT TO X2,Y2
350 X2= (X1+(26.57*SIN(2.01+AV))):Y2= (Y1+(26.57*COS(2.01+AV))):GOSUB 810:HPLOT TO X2,Y2
360 X2= (X1+(44.41*SIN(2.22+AV))):Y2= (Y1+(44.41*COS(2.22+AV))):GOSUB 810:HPLOT TO X2,Y2
370 X2= (X1+(28.16*SIN(2.25+AV))):Y2= (Y1+(28.16*COS(2.25+AV))):GOSUB 810:HPLOT TO X2,Y2
380 X2= (X1+(22.00*SIN(2.36+AV))):Y2= (Y1+(22.00*COS(2.36+AV))):GOSUB 810:HPLOT TO X2,Y2
390 X2= (X1+(21.02*SIN(1.91+AV))):Y2= (Y1+(21.02*COS(1.91+AV))):GOSUB 810:HPLOT X2,Y2
400 X2= (X1+(19.92*SIN(2.05+AV))):Y2= (Y1+(19.92*COS(2.05+AV))):GOSUB 810:HPLOT TO X2,Y2
410 X2= (X1+(22.20*SIN(2.22+AV))):Y2= (Y1+(22.20*COS(2.22+AV))):GOSUB 810:HPLOT TO X2,Y2
420 X2= (X1+(25.71*SIN(2.12+AV))):Y2= (Y1+(25.71*COS(2.12+AV))):GOSUB 810:HPLOT TO X2,Y2
430 X2= (X1+(26.57*SIN(2.01+AV))):Y2= (Y1+(26.57*COS(2.01+AV))):GOSUB 810:HPLOT TO X2,Y2
440 X2= (X1+(6.00*SIN(0.79+AV))):Y2= (Y1+(6.00*COS(0.79+AV))):GOSUB 810:HPLOT X2,Y2
450 X2= (X1+(3.00*SIN(2.36+AV))):Y2= (Y1+(3.00*COS(2.36+AV))):GOSUB 810:HPLOT TO X2,Y2
460 X2= (X1+(44.41*SIN(2.22+AV))):Y2= (Y1+(44.41*COS(2.22+AV))):GOSUB 810:HPLOT X2,Y2
470 X2= (X1+(41.00*SIN(2.36+AV))):Y2= (Y1+(41.00*COS(2.36+AV))):GOSUB 810:HPLOT TO X2,Y2
480 HPLOT 1,HZ TO 279,HZ
490 VP= VP + 1 
500 IF VP > LO THEN VP= 0
510 FOR B1= 0 TO LO
520 Y1= HZ + (B1 * VS) + (B1 + 1 * VP)
530 Y2= HZ + (B1 * VS) + (B1 + 1 * VP)
540 X1= 1:X2= 279
550 GOSUB 810
560 HPLOT X1,Y1 TO X2,Y2
570 NEXT
580 FOR B1= 0 TO LO
590 X1= X + (B1 * VL)
600 X2= B1 * HL
610 Y1 = HZ
620 Y2 = 159
630 GOSUB 810
640 HPLOT X1,Y1 TO X2,Y2
650 NEXT
660 GOSUB 1250
670 GOSUB 1080
680 GOTO 210
690 REM->ENDPROGRAM
700 TEXT:HOME:POKE 49168,0
710 GOSUB 1000
720 END
730 REM->HGRSCREEN
740 IF PEEK(33) < 41 AND MH% > 159 THEN HG$= "HGR2"
750 IF PEEK(33) < 41 AND MH% <= 159 THEN HG$= "HGR"
760 IF PEEK(33) > 40 THEN HG$= "HGR"
770 IF HG$ = "HGR" THEN HGR
780 IF HG$ = "HGR2" THEN HGR2
790 RETURN
800 REM->CHECKXY
810 X1= INT(X1):X2= INT(X2):Y1= INT(Y1):Y2= INT(Y2)
820 IF X1 >= 1 AND X1 < ML% AND X2 >= 1 AND X2 < ML% AND Y1 >= 1 AND Y1 < MH% AND Y2 >= 1 AND Y2 < MH% THEN RETURN
830 IF X1 > ML% THEN X1= ML%
840 IF X2 > ML% THEN X2= ML%
850 IF Y1 > MH% THEN Y1= MH%
860 IF Y2 > MH% THEN Y2= MH%
870 IF X1 < 1 THEN X1= 1
880 IF X2 < 1 THEN X2= 1
890 IF Y1 < 1 THEN Y1= 1
900 IF Y2 < 1 THEN Y2= 1
910 RETURN
920 REM->SPLASH
930 TEXT:HOME
940 VTAB(3):?
950 VTAB(PEEK(37) + 2)
960 S$= "APPLESOFT BASIC CODE":GOSUB 1140
970 ? S$
980 RETURN
990 REM->CREDITS
1000 TEXT:HOME
1010 GOSUB 1190
1020 VTAB(3):?
1030 VTAB(PEEK(37) + 2)
1040 S$= "BY ANDRES AKA LOZ":GOSUB 1140
1050 ? S$
1060 RETURN
1070 REM->KEYBOARDCAPTURE
1080 KI%= PEEK(49152)
1090 POKE 49168,0
1100 IF KI% = 155 THEN GOTO 700
1110 IF CHR$(KI%) = "T" THEN TEXT
1120 RETURN
1130 REM->CENTERTEXT
1140 T9%= INT( (PEEK(33) - LEN(S$) ) / 2 ) 
1150 IF (T9% < 1) THEN T9%= 0
1160 HTAB(T9%+1)
1170 RETURN
1180 REM->BEEP
1190 IF (BE% < 2) THEN BE%= 1
1200 FOR B9= 1 TO BE%
1210 ? CHR$(7);
1220 NEXT
1230 RETURN
1240 REM->LONGDOWNTIME
1250 FOR B9= 1 TO 2000:NEXT B9
1260 RETURN
1270 REM->SHORTDOWNTIME
1280 FOR B9= 1 TO 800:NEXT B9
1290 RETURN

Draw (paint program using paddle)

(draw.flv) Draw (paint program using paddle)
(Use faster emulation speed) very slow with a standard apple2
Virtual basic Applesoft basic
rem * control D char
d${Cmd}= chr$(4)
pi= 3.14159:ci{circumference in radians}= (2 * pi)

rem * width max, eight max for screen (279, 191, 159)
ml%{widthMax}= 279:mh%{HeightMax}= 191
if peek(33){mode 80 cols} = 80 then mh%{HeightMax}= 159 

rem * true random number
def fn alea{true random number}(x) = int(rnd(peek(78)+peek(79)*256) * x + 1)

rem * beep and buzz by default
bz%{NbreBuzz}= 3:be%{NbreBeep}= 1

{*** my program draw ***}
section intro
	text:home
	gosub @splash
	vtab(peek(37) + 2):s$= "*** draw ***":gosub @centertext:print s$:get s$
	
	# global vars
	mh%= 159
	lo{loops}= 1000
	x = ml% / 2
	y = mh% / 2
	cs{circle step}= 12
	
	# rem * best colors order 1 green, 5 orange, 2 violet, 6 blue 3 white, 0 black
	rem color list for random
	dim cl(6)
	cl(1)= 3:cl(2)= 1:cl(3)= 5:cl(4)= 6:cl(5)= 2:cl(6)= 0
	rc{randcolors}= 6
	
	gosub @hgrscreen
	hcolor= 3 {defaul color}
	vtab(22):rem choice
	print "d->ot s->quare c->ircle e->star f->grid ";
	print "b->dotcircle a->rand n->normal          ";
	print "g->grow r->reduce colors:0,1,2,3,5,6    ";
	print "z->reset p->save q->uit                ";
	gw{growfactor}= 5
	# trace
closesection
section main program
	£begin {*** main loop ***}
		# bp%= bp%{mainLoop} + 1

		for b1= 1 to lo{loops}
			s1{size} = 1 * gw
			s2{size} = 1 * gw
			
			if rd = 1 then gosub @randomvalues
			
			x= ( pdl(0) * 1.094 ) # pdl return 0-255
			y= ( pdl(1) * 0.623 )
			
			rem * capture last keyboard entered
			# wait 49152,128
			ki%{keyboardInput}= peek(49152)
			# poke 49168,0
			rem * menu actions
			
			if chr$(ki%){keyboardInput} = "a" then rd= 1
			if chr$(ki%){keyboardInput} = "0" then hcolor= 0
			if chr$(ki%){keyboardInput} = "1" then hcolor= 1
			if chr$(ki%){keyboardInput} = "2" then hcolor= 2
			if chr$(ki%){keyboardInput} = "3" then hcolor= 3
			if chr$(ki%){keyboardInput} = "5" then hcolor= 5
			if chr$(ki%){keyboardInput} = "6" then hcolor= 6
			if chr$(ki%){keyboardInput} = "z" then rd= 0:gosub @hgrscreen
			if chr$(ki%){keyboardInput} = "n" then rd= 0
			if chr$(ki%){keyboardInput} = "g" then gosub @grow
			if chr$(ki%){keyboardInput} = "r" then gosub @reduce
			if chr$(ki%){keyboardInput} = "s" then gosub @square
			if chr$(ki%){keyboardInput} = "e" then gosub @star
			if chr$(ki%){keyboardInput} = "d" then gosub @dot
			if chr$(ki%){keyboardInput} = "c" then gosub @circle
			if chr$(ki%){keyboardInput} = "b" then gosub @circleDot
			if chr$(ki%){keyboardInput} = "f" then gosub @grid
			if chr$(ki%){keyboardInput} = "p" then gosub @picturecapture
			if chr$(ki%){keyboardInput} = "w" then gosub @changeRandColor
			if chr$(ki%){keyboardInput} = "q" then gosub @quit
			
			gosub @keyboardcapture {this subscript is in lib/lib.baz}
		next 

		# if (bp%{mainLoop} < 100) then goto @begin
		goto @begin {forever loop}
	£endprogram
	text:home
	gosub @credits
	end
closesection
section subscripts
	£grow
		gw{growfactor}= gw + 1
		wait 49152,128
		poke 49168,0
	return
	£reduce
		gw{growfactor}= gw - 1
		wait 49152,128
		poke 49168,0
	return
	£dot
		x1= x:y1= y
		gosub @checkxy
		hplot x1,y1
	return
	£square
		rem * s1{size} s2{size}
		x= x - (s1 / 2):y= y - (s2 / 2)
		x1= x:y1= y
		gosub @checkxy
		hplot x1,y1
		x1= x+s1:y1= y
		gosub @checkxy
		hplot to x1,y1
		x1= x+s1:y1= y+s2
		gosub @checkxy
		hplot to x1,y1
		x1= x:y1= y+s2
		gosub @checkxy
		hplot to x1,y1
		x1= x:y1= y
		gosub @checkxy
		hplot to x1,y1
	return
	£circle
		ry{radius}= s1 / 2
		s{step}= ci{circle in radiants} / cs{circle step}
		for b2{varloop}= 0.1 to ( ci{circle in radiants}  + 0.5) step s
			v1= ry{radius} * cos(b2)
			v2= ry{radius} * sin(b2)
			x2= x{OrigX} + v1
			y2= y{OrigY} + v2
			if b2 = 0.1 then gosub @checkxy:hplot x2,y2
			if b2 > 0.1 then gosub @checkxy:hplot to x2,y2
		next 
	return
	£circleDot
		ry{radius}= s1 / 2
		s{step}= ci{circle in radiants} / cs{circle step}
		for b2{varloop}= 0.1 to ( ci{circle in radiants}  + 0.5) step s
			v1= ry{radius} * cos(b2)
			v2= ry{radius} * sin(b2)
			x2= x{OrigX} + v1
			y2= y{OrigY} + v2
			gosub @checkxy:hplot x2,y2
		next 
	return
	£star
		ry{radius}= s1 / 2
		s{step}= ci{circle in radiants} / (cs{circle step} * 2)
		for b2{varloop}= 0.1 to ( ci{circle in radiants}  + 0.5) step s
			st= st + 1
			if st > 1 then st= 0
			if st = 1 then st= ry
			v1= (ry{radius} + st) * cos(b2)
			v2= (ry{radius} + st) * sin(b2)
			x2= x{OrigX} + v1
			y2= y{OrigY} + v2
			if b2 = 0.1 then gosub @checkxy:hplot x2,y2
			if b2 > 0.1 then gosub @checkxy:hplot to x2,y2
		next 
	return
	£grid
		g2= gw / 2
		x1= x + (g2 * (fn alea(3) - 1) ) - g2
		y1= y + (g2 * (fn alea(3) - 1) ) - g2
		x2= x + (g2 * (fn alea(3) - 1) ) - g2
		y2= y + (g2 * (fn alea(3) - 1) ) - g2
		gosub @checkxy
		hplot x1,y1 to x2,y2
	return
	£randomvalues
		rem random values
		s1{size}= fn alea(gw)
		s2{size}= fn alea(gw)
		hcolor = cl(fn alea(rc{randcolor}))
		cs{circle step}= fn alea(10) + 6
	return
	£changeRandColor
		rc= rc + 1
		if rc > 6 then rc = 2
		wait 49152,128
		poke 49168,0
	return
	£quit
		goto @endprogram
closesection
£hgrscreen
	if peek(33) < 41 and mh%{MaxHauteur} > 159 then hg$= "hgr2"
	if peek(33) < 41 and mh%{MaxHauteur} <= 159 then hg$= "hgr"
	rem * mod 80 colonnes
	if peek(33) > 40 then hg$= "hgr"
	if hg$ = "hgr" then hgr
	if hg$ = "hgr2" then hgr2
return

£checkxy
	rem * check x,y to prevent overflow
	x1= int(x1):x2= int(x2):y1= int(y1):y2= int(y2)
	if x1 >= 1 and x1 < ml% and x2 >= 1 and x2 < ml% and y1 >= 1 and y1 < mh% and y2 >= 1 and y2 < mh% then return
	if x1 > ml%{widthMax} then x1= ml%{widthMax}
	if x2 > ml%{widthMax} then x2= ml%{widthMax}
	if y1 > mh%{HeightMax} then y1= mh%{HeightMax}
	if y2 > mh%{HeightMax} then y2= mh%{HeightMax}
	if x1 < 1 then x1= 1
	if x2 < 1 then x2= 1
	if y1 < 1 then y1= 1
	if y2 < 1 then y2= 1
return

£splash
	text:home
	vtab(3):print
	vtab(peek(37) + 2)
	s${sentence}= "applesoft basic code":gosub @centertext
	print s${sentence}
return

£credits
	text:home
	gosub @beep
	vtab(3):print
	vtab(peek(37) + 2)
	s${sentence}= "by andres aka loz":gosub @centertext
	print s${sentence}
return

£keyboardcapture
	rem * capture last keyboard entered
	ki%{keyboardInput}= peek(49152)
	rem * reset
	poke 49168,0
	rem * actions
	if ki% = 155{Escape} then goto @endprogram
return

£picturecapture
	rem * to capture screen type "s"
	t9%= fn alea(10000):t9$= "fic"+str$(t9%):print d$;"create cap/";t9$;",tbin"
	rem * hgr screen
	if (mh%{HeightMax} < 160) then t9$= t9$ + ",a$2000,l$1ff8"
	rem * hgr2
	if (mh%{HeightMax} > 159) then t9$= t9$ + ",a$4000,l$1ff8"
	print d$;"bsave cap/";t9$
	wait 49152,128
	poke 49168,0
return

£centertext
	t9%{leftSpace}= int( (peek(33) - len(s${sentence}) ) / 2 ) 
	rem * is result is null
	if (t9% < 1) then t9%= 0
	htab(t9%{leftSpace}+1)
return

£beep
if (be%{NbreBeep} < 2) then be%{NbreBeep}= 1
	for b9= 1 to be%{NbreBeep}
		print chr$(7);
	next
return

£longdowntime
	for b9= 1 to 2000:next b9
return

£shortdowntime
	for b9= 1 to 800:next b9
return
10 REM - DRAW.BAS - 26/03/2011 - 10h01 - BY - ANDRES - AKA - LOZ - COPYLEFT
20 D$= CHR$(4)
30 PI= 3.14159:CI= (2 * PI)
40 ML%= 279:MH%= 191
50 IF PEEK(33) = 80 THEN MH%= 159 
60 DEF FN ALEA(X) = INT(RND(PEEK(78)+PEEK(79)*256) * X + 1)
70 BZ%= 3:BE%= 1
80 TEXT:HOME
90 GOSUB 1780
100 VTAB(PEEK(37) + 2):S$= "*** DRAW ***":GOSUB 2060:? S$:GET S$
110 MH%= 159
120 LO= 1000
130 X = ML% / 2
140 Y = MH% / 2
150 CS= 12
160 REM COLOR LIST FOR RANDOM
170 DIM CL(6)
180 CL(1)= 3:CL(2)= 1:CL(3)= 5:CL(4)= 6:CL(5)= 2:CL(6)= 0
190 RC= 6
200 GOSUB 1590
210 HCOLOR= 3 
220 VTAB(22):REM CHOICE
230 ? "D->OT S->QUARE C->IRCLE E->STAR F->GRID ";
240 ? "B->DOTCIRCLE A->RAND N->NORMAL          ";
250 ? "G->GROW R->REDUCE COLORS:0,1,2,3,5,6    ";
260 ? "Z->RESET P->SAVE Q->UIT                ";
270 GW= 5
280 REM->BEGIN 
290 FOR B1= 1 TO LO
300 S1 = 1 * GW
310 S2 = 1 * GW
320 IF RD = 1 THEN GOSUB 1440
330 X= ( PDL(0) * 1.094 )
340 Y= ( PDL(1) * 0.623 )
350 KI%= PEEK(49152)
360 IF CHR$(KI%) = "A" THEN RD= 1
370 IF CHR$(KI%) = "0" THEN HCOLOR= 0
380 IF CHR$(KI%) = "1" THEN HCOLOR= 1
390 IF CHR$(KI%) = "2" THEN HCOLOR= 2
400 IF CHR$(KI%) = "3" THEN HCOLOR= 3
410 IF CHR$(KI%) = "5" THEN HCOLOR= 5
420 IF CHR$(KI%) = "6" THEN HCOLOR= 6
430 IF CHR$(KI%) = "Z" THEN RD= 0:GOSUB 1590
440 IF CHR$(KI%) = "N" THEN RD= 0
450 IF CHR$(KI%) = "G" THEN GOSUB 640
460 IF CHR$(KI%) = "R" THEN GOSUB 690
470 IF CHR$(KI%) = "S" THEN GOSUB 790
480 IF CHR$(KI%) = "E" THEN GOSUB 1200
490 IF CHR$(KI%) = "D" THEN GOSUB 740
500 IF CHR$(KI%) = "C" THEN GOSUB 970
510 IF CHR$(KI%) = "B" THEN GOSUB 1090
520 IF CHR$(KI%) = "F" THEN GOSUB 1350
530 IF CHR$(KI%) = "P" THEN GOSUB 1980
540 IF CHR$(KI%) = "W" THEN GOSUB 1510
550 IF CHR$(KI%) = "Q" THEN GOSUB 1570
560 GOSUB 1930
570 NEXT 
580 GOTO 290
590 REM->ENDPROGRAM
600 TEXT:HOME
610 GOSUB 1850
620 END
630 REM->GROW
640 GW= GW + 1
650 WAIT 49152,128
660 POKE 49168,0
670 RETURN
680 REM->REDUCE
690 GW= GW - 1
700 WAIT 49152,128
710 POKE 49168,0
720 RETURN
730 REM->DOT
740 X1= X:Y1= Y
750 GOSUB 1660
760 HPLOT X1,Y1
770 RETURN
780 REM->SQUARE
790 X= X - (S1 / 2):Y= Y - (S2 / 2)
800 X1= X:Y1= Y
810 GOSUB 1660
820 HPLOT X1,Y1
830 X1= X+S1:Y1= Y
840 GOSUB 1660
850 HPLOT TO X1,Y1
860 X1= X+S1:Y1= Y+S2
870 GOSUB 1660
880 HPLOT TO X1,Y1
890 X1= X:Y1= Y+S2
900 GOSUB 1660
910 HPLOT TO X1,Y1
920 X1= X:Y1= Y
930 GOSUB 1660
940 HPLOT TO X1,Y1
950 RETURN
960 REM->CIRCLE
970 RY= S1 / 2
980 S= CI / CS
990 FOR B2= 0.1 TO ( CI  + 0.5) STEP S
1000 V1= RY * COS(B2)
1010 V2= RY * SIN(B2)
1020 X2= X + V1
1030 Y2= Y + V2
1040 IF B2 = 0.1 THEN GOSUB 1660:HPLOT X2,Y2
1050 IF B2 > 0.1 THEN GOSUB 1660:HPLOT TO X2,Y2
1060 NEXT 
1070 RETURN
1080 REM->CIRCLEDOT
1090 RY= S1 / 2
1100 S= CI / CS
1110 FOR B2= 0.1 TO ( CI  + 0.5) STEP S
1120 V1= RY * COS(B2)
1130 V2= RY * SIN(B2)
1140 X2= X + V1
1150 Y2= Y + V2
1160 GOSUB 1660:HPLOT X2,Y2
1170 NEXT 
1180 RETURN
1190 REM->STAR
1200 RY= S1 / 2
1210 S= CI / (CS * 2)
1220 FOR B2= 0.1 TO ( CI  + 0.5) STEP S
1230 ST= ST + 1
1240 IF ST > 1 THEN ST= 0
1250 IF ST = 1 THEN ST= RY
1260 V1= (RY + ST) * COS(B2)
1270 V2= (RY + ST) * SIN(B2)
1280 X2= X + V1
1290 Y2= Y + V2
1300 IF B2 = 0.1 THEN GOSUB 1660:HPLOT X2,Y2
1310 IF B2 > 0.1 THEN GOSUB 1660:HPLOT TO X2,Y2
1320 NEXT 
1330 RETURN
1340 REM->GRID
1350 G2= GW / 2
1360 X1= X + (G2 * (FN ALEA(3) - 1) ) - G2
1370 Y1= Y + (G2 * (FN ALEA(3) - 1) ) - G2
1380 X2= X + (G2 * (FN ALEA(3) - 1) ) - G2
1390 Y2= Y + (G2 * (FN ALEA(3) - 1) ) - G2
1400 GOSUB 1660
1410 HPLOT X1,Y1 TO X2,Y2
1420 RETURN
1430 REM->RANDOMVALUES
1440 REM RANDOM VALUES
1450 S1= FN ALEA(GW)
1460 S2= FN ALEA(GW)
1470 HCOLOR = CL(FN ALEA(RC))
1480 CS= FN ALEA(10) + 6
1490 RETURN
1500 REM->CHANGERANDCOLOR
1510 RC= RC + 1
1520 IF RC > 6 THEN RC = 2
1530 WAIT 49152,128
1540 POKE 49168,0
1550 RETURN
1560 REM->QUIT
1570 GOTO 600
1580 REM->HGRSCREEN
1590 IF PEEK(33) < 41 AND MH% > 159 THEN HG$= "HGR2"
1600 IF PEEK(33) < 41 AND MH% <= 159 THEN HG$= "HGR"
1610 IF PEEK(33) > 40 THEN HG$= "HGR"
1620 IF HG$ = "HGR" THEN HGR
1630 IF HG$ = "HGR2" THEN HGR2
1640 RETURN
1650 REM->CHECKXY
1660 X1= INT(X1):X2= INT(X2):Y1= INT(Y1):Y2= INT(Y2)
1670 IF X1 >= 1 AND X1 < ML% AND X2 >= 1 AND X2 < ML% AND Y1 >= 1 AND Y1 < MH% AND Y2 >= 1 AND Y2 < MH% THEN RETURN
1680 IF X1 > ML% THEN X1= ML%
1690 IF X2 > ML% THEN X2= ML%
1700 IF Y1 > MH% THEN Y1= MH%
1710 IF Y2 > MH% THEN Y2= MH%
1720 IF X1 < 1 THEN X1= 1
1730 IF X2 < 1 THEN X2= 1
1740 IF Y1 < 1 THEN Y1= 1
1750 IF Y2 < 1 THEN Y2= 1
1760 RETURN
1770 REM->SPLASH
1780 TEXT:HOME
1790 VTAB(3):?
1800 VTAB(PEEK(37) + 2)
1810 S$= "APPLESOFT BASIC CODE":GOSUB 2060
1820 ? S$
1830 RETURN
1840 REM->CREDITS
1850 TEXT:HOME
1860 GOSUB 2110
1870 VTAB(3):?
1880 VTAB(PEEK(37) + 2)
1890 S$= "BY ANDRES AKA LOZ":GOSUB 2060
1900 ? S$
1910 RETURN
1920 REM->KEYBOARDCAPTURE
1930 KI%= PEEK(49152)
1940 POKE 49168,0
1950 IF KI% = 155 THEN GOTO 600
1960 RETURN
1970 REM->PICTURECAPTURE
1980 T9%= FN ALEA(10000):T9$= "FIC"+STR$(T9%):? D$;"CREATE CAP/";T9$;",TBIN"
1990 IF (MH% < 160) THEN T9$= T9$ + ",A$2000,L$1FF8"
2000 IF (MH% > 159) THEN T9$= T9$ + ",A$4000,L$1FF8"
2010 ? D$;"BSAVE CAP/";T9$
2020 WAIT 49152,128
2030 POKE 49168,0
2040 RETURN
2050 REM->CENTERTEXT
2060 T9%= INT( (PEEK(33) - LEN(S$) ) / 2 ) 
2070 IF (T9% < 1) THEN T9%= 0
2080 HTAB(T9%+1)
2090 RETURN
2100 REM->BEEP
2110 IF (BE% < 2) THEN BE%= 1
2120 FOR B9= 1 TO BE%
2130 ? CHR$(7);
2140 NEXT
2150 RETURN
2160 REM->LONGDOWNTIME
2170 FOR B9= 1 TO 2000:NEXT B9
2180 RETURN
2190 REM->SHORTDOWNTIME
2200 FOR B9= 1 TO 800:NEXT B9
2210 RETURN

Badaboum

(badaboum.flv) Badaboum
(Use faster emulation speed)
Virtual basic Applesoft basic
rem * control D char
d${Cmd}= chr$(4)
pi= 3.14159:ci{circumference in radians}= (2 * pi)

rem * width max, eight max for screen (279, 191, 159)
ml%{widthMax}= 279:mh%{HeightMax}= 191
if peek(33){mode 80 cols} = 80 then mh%{HeightMax}= 159 

rem * true random number
def fn alea{true random number}(x) = int(rnd(peek(78)+peek(79)*256) * x + 1)

rem * beep and buzz by default
bz%{NbreBuzz}= 3:be%{NbreBeep}= 1

{*** stars badaboum ***}
section intro
	text:home
	gosub @splash
	vtab(peek(37) + 2):
	s$= "*** projet badaboum ***":gosub @centertext:print s$ # :get s$
	mh%= 150
finsection
section main program
	gosub @hgrscreen
	p2{pi + half}= pi * 1.5
	xo= ml%{MaxWidth}/2:yo= mh%{MaxHeight}/2
	x1= xo:y1= yo
	ct{SquareEdge}= 105
	rem * colors 0 black, 1 green, 2 violet, 3 white, 4 black, 5 orange, 6 blue
	rem * meilleures couleurs 1 green, 5 orange, puis 2 violet et 6 blue et enfin 3 white, 0 black
	dim cl{colorsList}(4)
	cl(1)= 0:cl(2)= 3:cl(3)= 6:cl(4)= 0
	£beginProgram
		ct= ct - 5
		d2{HalfDiagonal}= sqr( (ct*ct) + (ct*ct) ) / 2 {half diagonal of the grid}
		{*** main loop ***}
		bp%{mainLoop}= bp%{mainLoop} + 1
		mx= fn alea(ci)
		av= fn alea(100)
		s{Inc}= (ci{circonference} / fn alea(12))
		for b1{loop}= 0.1  to ( ci + 0.1 ) step s
			# gosub @hgrscreen
			# {figure fixe}
			gosub @xyAxis
			# x1= xo-(ct/2) :y1= yo-(ct/ 2) {center the fig}
			# ===insert plotter-xy.baz===
			
			{rotation}
			av = av + s
			if av > mx then v1= d2 * sin( av+(p2) )
			v2= d2 * cos( av+(p2) )
			{new values of x1,y1 by circle}
			x1= int( xo+v1 ):y1= int( yo+v2 )
			# hcolor=0
			x2= x1:y2= y1:gosub @checkxy:hplot x2,y2{blind point}
			hcolor = cl{colorsList}(fn alea(4))
			gosub @rotateStartGrid
			# hcolor= 0
			vtab(22)
			print bp%;" ";b1;" ";av
			print v1;" ";v2
			{insert figure code}
			x2= (x1+(66.03*sin(1.74+av))):y2= (y1+(66.03*cos(1.74+av))):gosub @checkxy:hplot x2,y2
			x2= (x1+(74.52*sin(1.66+av))):y2= (y1+(74.52*cos(1.66+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(78.55*sin(1.81+av))):y2= (y1+(78.55*cos(1.81+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(78.75*sin(1.65+av))):y2= (y1+(78.75*cos(1.65+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(88.41*sin(1.70+av))):y2= (y1+(88.41*cos(1.70+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(82.76*sin(1.60+av))):y2= (y1+(82.76*cos(1.60+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(94.75*sin(1.57+av))):y2= (y1+(94.75*cos(1.57+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(82.76*sin(1.55+av))):y2= (y1+(82.76*cos(1.55+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(88.41*sin(1.44+av))):y2= (y1+(88.41*cos(1.44+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(78.75*sin(1.49+av))):y2= (y1+(78.75*cos(1.49+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(78.55*sin(1.33+av))):y2= (y1+(78.55*cos(1.33+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(74.52*sin(1.49+av))):y2= (y1+(74.52*cos(1.49+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(66.03*sin(1.40+av))):y2= (y1+(66.03*cos(1.40+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(70.04*sin(1.54+av))):y2= (y1+(70.04*cos(1.54+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(57.98*sin(1.57+av))):y2= (y1+(57.98*cos(1.57+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(70.04*sin(1.60+av))):y2= (y1+(70.04*cos(1.60+av))):gosub @checkxy:hplot to x2,y2
			x2= (x1+(66.03*sin(1.74+av))):y2= (y1+(66.03*cos(1.74+av))):gosub @checkxy:hplot to x2,y2
			
			gosub @keyboardcapture
			# gosub @longdowntime
		next 

		if (bp%{mainLoop} < 100) then goto @beginProgram
		gosub @hgrscreen
		bp%= 0
		bc%= bc% + 1
		if (bc% > 1) then bc%= 0:av= 0:ct= 105
		goto @beginProgram
	£endprogram
	text:home:poke 49168,0
	list
	gosub @credits
	# print d$;"run tee"
	end
finsection

section subscripts
	{*** subscripts ***}
	£rotateStartGrid
		{spot}
		x2= x1-3:gosub @checkxy:hplot x2,y1 
		x2= x1+3:gosub @checkxy:hplot to x2,y1
		y2= y1-3:gosub @checkxy:hplot x1,y2
		y2= y1+3:gosub @checkxy:hplot to x1,y2
	return
	£xyAxis
		{axis of x , y}
		x2= xo-d2:gosub @checkxy:hplot x2,yo 
		x2= xo+d2:gosub @checkxy:hplot to x2,yo
		y2= yo-d2:gosub @checkxy:hplot xo,y2
		y2= yo+d2:gosub @checkxy:hplot to xo,y2
	return
	£errorhere
		poke 216,0
		xo= 0
	goto @beginProgram
finsection
£hgrscreen
	if peek(33) < 41 and mh%{MaxHauteur} > 159 then hg$= "hgr2"
	if peek(33) < 41 and mh%{MaxHauteur} <= 159 then hg$= "hgr"
	rem * mod 80 colonnes
	if peek(33) > 40 then hg$= "hgr"
	if hg$ = "hgr" then hgr
	if hg$ = "hgr2" then hgr2
return

£checkxy
	rem * check x,y to prevent overflow
	x1= int(x1):x2= int(x2):y1= int(y1):y2= int(y2)
	if x1 >= 1 and x1 < ml% and x2 >= 1 and x2 < ml% and y1 >= 1 and y1 < mh% and y2 >= 1 and y2 < mh% then return
	if x1 > ml%{widthMax} then x1= ml%{widthMax}
	if x2 > ml%{widthMax} then x2= ml%{widthMax}
	if y1 > mh%{HeightMax} then y1= mh%{HeightMax}
	if y2 > mh%{HeightMax} then y2= mh%{HeightMax}
	if x1 < 1 then x1= 1
	if x2 < 1 then x2= 1
	if y1 < 1 then y1= 1
	if y2 < 1 then y2= 1
return


£splash
	text:home
	vtab(3):print
	vtab(peek(37) + 2)
	s${sentence}= "applesoft basic code":gosub @centertext
	print s${sentence}
return

£credits
	text:home
	gosub @beep
	vtab(3):print
	vtab(peek(37) + 2)
	s${sentence}= "by andres aka loz":gosub @centertext
	print s${sentence}
return

£keyboardcapture
	rem * capture last keyboard entered
	ki%{keyboardInput}= peek(49152)
	rem * reset
	poke 49168,0
	rem * actions
	if (ki%{keyboardInput} = 155{Escape}) then goto @endprogram
	if (ki%{keyboardInput} = 212{key T}) then text
return

£centertext
	t9%{leftSpace}= int( (peek(33) - len(s${sentence}) ) / 2 ) 
	rem * is result is null
	if (t9% < 1) then t9%= 0
	htab(t9%{leftSpace}+1)
return

£beep
if (be%{NbreBeep} < 2) then be%{NbreBeep}= 1
	for b9= 1 to be%{NbreBeep}
		print chr$(7);
	next
return

£longdowntime
	for b9= 1 to 2000:next b9
return

£shortdowntime
	for b9= 1 to 800:next b9
return
10 REM - ETOILE-FUSION.BAS - 06/03/2011 - 06h44 - BY - ANDRES - AKA - LOZ - COPYLEFT
20 D$= CHR$(4)
30 PI= 3.14159:CI= (2 * PI)
40 ML%= 279:MH%= 191
50 IF PEEK(33) = 80 THEN MH%= 159 
60 DEF FN ALEA(X) = INT(RND(PEEK(78)+PEEK(79)*256) * X + 1)
70 BZ%= 3:BE%= 1
80 TEXT:HOME
90 GOSUB 1050
100 VTAB(PEEK(37) + 2):
110 S$= "*** PROJET BADABOUM ***":GOSUB 1260:? S$
120 MH%= 150
130 GOSUB 860
140 P2= PI * 1.5
150 XO= ML%/2:YO= MH%/2
160 X1= XO:Y1= YO
170 CT= 105
180 DIM CL(4)
190 CL(1)= 0:CL(2)= 3:CL(3)= 6:CL(4)= 0
200 REM->BEGINPROGRAM
210 CT= CT - 5
220 D2= SQR( (CT*CT) + (CT*CT) ) / 2 
230 BP%= BP% + 1
240 MX= FN ALEA(CI)
250 AV= FN ALEA(100)
260 S= (CI / FN ALEA(12))
270 FOR B1= 0.1  TO ( CI + 0.1 ) STEP S
280 GOSUB 760
290 AV = AV + S
300 IF AV > MX THEN V1= D2 * SIN( AV+(P2) )
310 V2= D2 * COS( AV+(P2) )
320 X1= INT( XO+V1 ):Y1= INT( YO+V2 )
330 X2= X1:Y2= Y1:GOSUB 930:HPLOT X2,Y2
340 HCOLOR = CL(FN ALEA(4))
350 GOSUB 700
360 VTAB(22)
370 ? BP%;" ";B1;" ";AV
380 ? V1;" ";V2
390 X2= (X1+(66.03*SIN(1.74+AV))):Y2= (Y1+(66.03*COS(1.74+AV))):GOSUB 930:HPLOT X2,Y2
400 X2= (X1+(74.52*SIN(1.66+AV))):Y2= (Y1+(74.52*COS(1.66+AV))):GOSUB 930:HPLOT TO X2,Y2
410 X2= (X1+(78.55*SIN(1.81+AV))):Y2= (Y1+(78.55*COS(1.81+AV))):GOSUB 930:HPLOT TO X2,Y2
420 X2= (X1+(78.75*SIN(1.65+AV))):Y2= (Y1+(78.75*COS(1.65+AV))):GOSUB 930:HPLOT TO X2,Y2
430 X2= (X1+(88.41*SIN(1.70+AV))):Y2= (Y1+(88.41*COS(1.70+AV))):GOSUB 930:HPLOT TO X2,Y2
440 X2= (X1+(82.76*SIN(1.60+AV))):Y2= (Y1+(82.76*COS(1.60+AV))):GOSUB 930:HPLOT TO X2,Y2
450 X2= (X1+(94.75*SIN(1.57+AV))):Y2= (Y1+(94.75*COS(1.57+AV))):GOSUB 930:HPLOT TO X2,Y2
460 X2= (X1+(82.76*SIN(1.55+AV))):Y2= (Y1+(82.76*COS(1.55+AV))):GOSUB 930:HPLOT TO X2,Y2
470 X2= (X1+(88.41*SIN(1.44+AV))):Y2= (Y1+(88.41*COS(1.44+AV))):GOSUB 930:HPLOT TO X2,Y2
480 X2= (X1+(78.75*SIN(1.49+AV))):Y2= (Y1+(78.75*COS(1.49+AV))):GOSUB 930:HPLOT TO X2,Y2
490 X2= (X1+(78.55*SIN(1.33+AV))):Y2= (Y1+(78.55*COS(1.33+AV))):GOSUB 930:HPLOT TO X2,Y2
500 X2= (X1+(74.52*SIN(1.49+AV))):Y2= (Y1+(74.52*COS(1.49+AV))):GOSUB 930:HPLOT TO X2,Y2
510 X2= (X1+(66.03*SIN(1.40+AV))):Y2= (Y1+(66.03*COS(1.40+AV))):GOSUB 930:HPLOT TO X2,Y2
520 X2= (X1+(70.04*SIN(1.54+AV))):Y2= (Y1+(70.04*COS(1.54+AV))):GOSUB 930:HPLOT TO X2,Y2
530 X2= (X1+(57.98*SIN(1.57+AV))):Y2= (Y1+(57.98*COS(1.57+AV))):GOSUB 930:HPLOT TO X2,Y2
540 X2= (X1+(70.04*SIN(1.60+AV))):Y2= (Y1+(70.04*COS(1.60+AV))):GOSUB 930:HPLOT TO X2,Y2
550 X2= (X1+(66.03*SIN(1.74+AV))):Y2= (Y1+(66.03*COS(1.74+AV))):GOSUB 930:HPLOT TO X2,Y2
560 GOSUB 1200
570 NEXT 
580 IF (BP% < 100) THEN GOTO 210
590 GOSUB 860
600 BP%= 0
610 BC%= BC% + 1
620 IF (BC% > 1) THEN BC%= 0:AV= 0:CT= 105
630 GOTO 210
640 REM->ENDPROGRAM
650 TEXT:HOME:POKE 49168,0
660 LIST
670 GOSUB 1120
680 END
690 REM->ROTATESTARTGRID
700 X2= X1-3:GOSUB 930:HPLOT X2,Y1
710 X2= X1+3:GOSUB 930:HPLOT TO X2,Y1
720 Y2= Y1-3:GOSUB 930:HPLOT X1,Y2
730 Y2= Y1+3:GOSUB 930:HPLOT TO X1,Y2
740 RETURN
750 REM->XYAXIS
760 X2= XO-D2:GOSUB 930:HPLOT X2,YO
770 X2= XO+D2:GOSUB 930:HPLOT TO X2,YO
780 Y2= YO-D2:GOSUB 930:HPLOT XO,Y2
790 Y2= YO+D2:GOSUB 930:HPLOT TO XO,Y2
800 RETURN
810 REM->ERRORHERE
820 POKE 216,0
830 XO= 0
840 GOTO 210
850 REM->HGRSCREEN
860 IF PEEK(33) < 41 AND MH% > 159 THEN HG$= "HGR2"
870 IF PEEK(33) < 41 AND MH% <= 159 THEN HG$= "HGR"
880 IF PEEK(33) > 40 THEN HG$= "HGR"
890 IF HG$ = "HGR" THEN HGR
900 IF HG$ = "HGR2" THEN HGR2
910 RETURN
920 REM->CHECKXY
930 X1= INT(X1):X2= INT(X2):Y1= INT(Y1):Y2= INT(Y2)
940 IF X1 >= 1 AND X1 < ML% AND X2 >= 1 AND X2 < ML% AND Y1 >= 1 AND Y1 < MH% AND Y2 >= 1 AND Y2 < MH% THEN RETURN
950 IF X1 > ML% THEN X1= ML%
960 IF X2 > ML% THEN X2= ML%
970 IF Y1 > MH% THEN Y1= MH%
980 IF Y2 > MH% THEN Y2= MH%
990 IF X1 < 1 THEN X1= 1
1000 IF X2 < 1 THEN X2= 1
1010 IF Y1 < 1 THEN Y1= 1
1020 IF Y2 < 1 THEN Y2= 1
1030 RETURN
1040 REM->SPLASH
1050 TEXT:HOME
1060 VTAB(3):?
1070 VTAB(PEEK(37) + 2)
1080 S$= "APPLESOFT BASIC CODE":GOSUB 1260
1090 ? S$
1100 RETURN
1110 REM->CREDITS
1120 TEXT:HOME
1130 GOSUB 1310
1140 VTAB(3):?
1150 VTAB(PEEK(37) + 2)
1160 S$= "BY ANDRES AKA LOZ":GOSUB 1260
1170 ? S$
1180 RETURN
1190 REM->KEYBOARDCAPTURE
1200 KI%= PEEK(49152)
1210 POKE 49168,0
1220 IF (KI% = 155) THEN GOTO 650
1230 IF (KI% = 212) THEN TEXT
1240 RETURN
1250 REM->CENTERTEXT
1260 T9%= INT( (PEEK(33) - LEN(S$) ) / 2 ) 
1270 IF (T9% < 1) THEN T9%= 0
1280 HTAB(T9%+1)
1290 RETURN
1300 REM->BEEP
1310 IF (BE% < 2) THEN BE%= 1
1320 FOR B9= 1 TO BE%
1330 ? CHR$(7);
1340 NEXT
1350 RETURN
1360 REM->LONGDOWNTIME
1370 FOR B9= 1 TO 2000:NEXT B9
1380 RETURN
1390 REM->SHORTDOWNTIME
1400 FOR B9= 1 TO 800:NEXT B9
1410 RETURN
pages (1) 2

LoGz CMS http://www.logz.org | Copyleft Licence Art Libre | Crédits | site map |  Vrs? | Vxl?