* add p cc
[mascara-docs.git] / i86 / mikeos-4.1.2 / programs / example.bas
blob6fe6216f7d4eb6eb9e7372fa09ea0e8ecc42f951
1 rem *** MikeOS BASIC demo ***
3 cls
5 print "Which program do you want to run?"
6 print ""
7 print "1 - Hex dumper"
8 print "2 - MikeTron"
9 print ""
11 startloop:
12 waitkey x
13 if x = '1' then goto runhex
14 if x = '2' then goto runmiketron
15 goto startloop
19 runhex:
21 rem *** Hex dumper ***
23 print "Enter a filename to make a hex dump from:"
24 input $1
26 x = RAMSTART
28 load $1 x
29 if r = 1 then goto hexerror
31 hexloop:
32 peek a x
33 print hex a ;
34 print " " ;
35 x = x + 1
36 s = s - 1
37 if s = 0 then goto hexfinish
38 goto hexloop
40 hexfinish:
41 print ""
42 end
44 hexerror:
45 print "Could not load file! Does it exist?"
46 end
50 runmiketron:
52 rem *** MikeTron ***
54 cls
56 print "You control a vehicle leaving a trail behind it."
57 print ""
58 print "It is always moving, and if it crosses any part"
59 print "of the trail or border (+ characters), the game"
60 print "is over. Use the Q and A keys to change the direction"
61 print "to up and down, and O and P for left and right."
62 print "See how long you can survive! Score at the end."
63 print ""
64 print "NOTE: May perform at wrong speed in emulators!"
65 print ""
66 print "Hit a key to begin..."
68 waitkey x
71 cls
72 cursor off
75 rem *** Draw border around screen ***
77 gosub setupscreen
80 rem *** Start in the middle of the screen ***
82 x = 40
83 y = 12
85 move x y
88 rem *** Movement directions: 1 - 4 = up, down, left, right ***
89 rem *** We start the game moving right ***
91 d = 4
94 rem *** S = score variable ***
96 s = 0
99 mainloop:
100 print "+" ;
102 pause 1
104 getkey k
106 if k = 'q' then d = 1
107 if k = 'a' then d = 2
108 if k = 'o' then d = 3
109 if k = 'p' then d = 4
111 if d = 1 then y = y - 1
112 if d = 2 then y = y + 1
113 if d = 3 then x = x - 1
114 if d = 4 then x = x + 1
116 move x y
118 curschar c
119 if c = '+' then goto finish
121 s = s + 1
122 goto mainloop
125 finish:
126 cursor on
129 print "Your score was: " ;
130 print s
131 print "Press Esc to finish"
133 escloop:
134 waitkey x
135 if x = 27 then end
136 goto escloop
139 setupscreen:
140 move 0 0
141 for x = 0 to 78
142 print "+" ;
143 next x
145 move 0 24
146 for x = 0 to 78
147 print "+" ;
148 next x
150 move 0 0
151 for y = 0 to 24
152 move 0 y
153 print "+" ;
154 next y
156 move 78 0
157 for y = 0 to 24
158 move 78 y
159 print "+" ;
160 next y
162 return