home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG013.ARC
/
HUSTLE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
11KB
|
424 lines
program HUSTLE;
{ Converted from hustle.mwb |o Turb Pascal
for the MicroBee, and further developed
with sound effects by Bob Burt, 30/1/85
Demonstrates graphics and sound procedures
developed by Bob Burt
Colour procedures added 29/6/85 }
var
high_score : integer; {highest score }
count : integer; {loop counter }
x,y : integer; {coordinates for head on screen}
change_x,change_y : integer; {direction of head }
start_head : integer; {start of head }
tail_end : integer; {end of tail }
target : integer; {target position }
x_tar,y_tar : integer; {coordinates for target posn }
dwell : integer; {target duration on screen }
value : integer; {value of demolished target }
total_targets : integer; {number of targets hit }
time : integer; {total time elapsed }
game_over : boolean; {game over flag }
total_score : integer; {total score for current game }
rating : integer; {targets hit versus time }
speed : byte; {speed of game }
head : integer; {absolute position of head }
tail_lag : integer; {lag in tail }
ch,reply : char; {instruction characters }
g : array[0..800,0..1] of integer; {record of head/tail components}
s : byte; {variable to set/reset a dot }
dotset : integer; {variable to get screen pos }
{of dot to be pointed to }
data : array[0..1,0..3] of byte; {screen_table array }
mask : byte; {mask for screen table }
interval : integer; {variables }
set_tone,up_down : byte; { used }
duration,duration2 : byte; { by }
one_many,timbre : byte; { sound }
compare,counter : byte; { generator }
{$I colinit.pro}
{$I lores80.pro}
{$I normal.pro }
{$I draw2.pro }
{$I gensnd.pro }
{$I initsnd.pro}
procedure run_into_something; forward;
procedure attention; forward;
procedure gobbled_up; forward;
procedure pop_up; forward;
procedure screen_table; forward;
procedure clear_col;
var
col_ram : integer;
begin
port[8] := 78; {colour RAM on, RGB guns full}
for col_ram := $F800 to $FFFF do
mem[col_ram] := 2; {default green on black}
port[8] := 14; {PCG RAM on, RGB guns full}
gotoxy(78,23)
end; {procedure clear_col}
procedure point(x,y : byte);
begin
mem[addr(draw2)+98] := x;
mem[addr(draw2)+99] := y;
draw2
end; {procedure point}
procedure sets(s : byte);
begin
mem[addr(draw2)+100] := s
end; {procedure sets}
procedure border;
begin
sets(0);
for count := 1 to 158 do
begin
point(count,0);
point(count,63);
point(count,71)
end;
for count := 0 to 71 do
begin
point(0,count);
point(159,count)
end;
for count := 64 to 70 do
begin
point(23,count);
point(47,count);
point(73,count);
point(116,count)
end
end; {procedure border}
procedure frame;
begin
sets(0);
for count := 33 to 110 do
begin
point(count,15);
point(count,70)
end;
for count := 16 to 69 do
begin
point(33,count);
point(110,count)
end
end; {procedure frame}
procedure play_game;
begin
delay(speed);
if keypressed then
begin
read(kbd,ch);
if ((ch =',') or (ch = '<')) and (change_x <> 1) then
begin
change_x := -1;
change_y := 0
end
else
if ((ch = '.') or (ch = '>')) and (change_x <> -1) then
begin
change_x := 1;
change_y := 0
end
else
if ((ch = 'A') or (ch = 'a')) and (change_y <> 1) then
begin
change_x := 0;
change_y := -1
end
else
if ((ch = 'Z') or (ch = 'z')) and (change_y <> -1) then
begin
change_x := 0;
change_y := 1
end;
end; {keypressed}
x := x + change_x; y := y + change_y;
if start_head < 800 then
start_head := start_head + 1
else
begin
start_head := 0;
time := time + 800
end; {else}
if tail_lag >= 0 then
begin
if tail_end < 800 then
tail_end := tail_end + 1
else
tail_end := 0;
sets(1);
point(g[tail_end,0],g[tail_end,1])
end; {tail_lag >= 0}
if tail_lag < 0 then
tail_lag := tail_lag + 1;
dotset := (y div 3)*80 + (x div 2) - 4096; {equivalent of 'point'}
mask := data[(x mod 2),(y mod 3)]; { in }
if mem[dotset] and mask = mask then { MicroWorld Basic }
run_into_something;
if not game_over then
begin
sets(0); point(x,y);
g[start_head,0] := x; g[start_head,1] := y;
if dwell = 0 then
begin
x_tar := (target mod 80) + 1; y_tar := (target div 80) + 1;
gotoxy(x_tar,y_tar);
writeln(chr(128),chr(128),chr(128));
gotoxy(78,23);
dwell := -1;
end; {dwell = 0}
if dwell <= 0 then
begin
randomize;
if random >= 0.9 then
begin
repeat
target := random(21)*80 + random(80) - 4096
until (mem[target]=128)and(mem[target+1]=128)and(mem[target+2]=128);
pop_up;
mem[target] := 183;
mem[target+1] := 179;
mem[target+2] := 187;
target := target + 4096;
dwell := random(100) + 80
end {random}
end; {dwell <= 0}
if dwell > 0 then
dwell := dwell - 1
end {not game_over}
end; {procedure play_game}
procedure run_into_something;
begin
head := (y div 3)*80 + (x div 2);
game_over := not((head=target)or(head=target+1)or(head=target+2));
if not game_over then
begin
value := random(9) + 1;
total_score := total_score + value;
tail_lag := tail_lag - value*2;
total_targets := total_targets + 1;
rating := (total_targets)*1000 div (time + start_head);
gobbled_up;
dwell := -1;
x_tar := (target mod 80) + 1;
y_tar := (target div 80) + 1;
for count := 1 to 8 do
begin
gotoxy(x_tar,y_tar);
write(value,chr(128));
delay(100);
gotoxy(x_tar,y_tar);
write(chr(183),chr(179),chr(187))
end;
gotoxy(x_tar,y_tar);
write(chr(128),chr(128),chr(128));
gotoxy(8,23);
color(5,2,0);
write(((time + start_head) div 100) + 1);
gotoxy(20,23);
write(total_score);
gotoxy(33,23);
write(rating,' ');
if speed = 10 then speed := 20;
speed := speed - 1;
gotoxy(76,23);
write(speed,' ');
color(2,0,0);
gotoxy(78,23)
end {not game_over}
end; {procedure run_into_something}
procedure end_of_game;
begin
attention;
clear_col;
lores80;
frame;
gotoxy(28,9);
color(3,3,0);
write(' G A M E O V E R ');
gotoxy(28,13);
color(4,6,0);
write('Your Score is : ');
color(6,4,0); write(' ',total_score);
if total_score > high_score then high_score := total_score;
gotoxy(27,16);
color(6,1,0);
write('Your Rating is : ');
color(6,6,0); write(' ',rating);
gotoxy(26,19);
color(7,2,0);
write('Highest Score is : ');
color(2,7,0); write(' ',high_score);
repeat
gotoxy(24,22);
color(2,5,0);
write('Do you want to play again? ');
gotoxy(51,22);
attention;
color(5,2,0); read(reply);
until (reply='Y') or (reply='y') or (reply='N') or (reply='n');
gotoxy(78,23);
clear_col
end; {procedure end_of_game}
procedure initialise;
begin
x := 60; y := 24; {position of head on screen}
change_x := 1; change_y := 0;
start_head := 0; tail_end := 0;
head := 0; tail_lag := -3;
target := 0; dwell := -1;
value := 0; total_targets := 0;
time := 0; game_over := false;
total_score := 0; rating := 0;
speed := 25
end; {procedure initialise}
procedure record_score;
begin
gotoxy(3,23);
color(2,5,0);
write('Time');
gotoxy(14,23);
write('Score');
gotoxy(26,23);
write('Rating');
gotoxy(40,23);
write('High Score :');
color(5,2
,0);
write(' ',high_score);
gotoxy(63,23);
color(2,5,0);
write('Speed Factor ');
color(2,0,0);
end; {procedure record_score}
procedure hustle;
begin
colinit; {initialise colour procedure}
set_tone := 200; up_down := 5;
duration := 1; duration2 := 0;
one_many := 32;
timbre := 65; compare := 0;
lowvideo;
color(4,0,0);
gotoxy(29,6); write(' H ');
initsnd; gensnd;
gotoxy(32,6); color(2,0,0); write(' U ');
initsnd; gensnd;
gotoxy(35,6); color(3,0,0); write(' S ');
initsnd; gensnd;
gotoxy(38,6); color(6,0,0); write(' T ');
initsnd; gensnd;
gotoxy(41,6); color(1,0,0); write(' L ');
initsnd; gensnd;
gotoxy(44,6); color(5,0,0); write(' E ');
normvideo;
gotoxy(26,10); color(3,3,0); write('To move UP Press ');
lowvideo; write(' A '); normvideo;
gotoxy(26,12); color(4,6,0); write('To move DOWN Press ');
lowvideo; write(' Z '); normvideo;
gotoxy(26,14); color(6,1,0); write('To move LEFT Press ');
lowvideo; write(' < '); normvideo;
gotoxy(26,16); color(7,2,0); write('To move RIGHT Press ');
lowvideo; write(' > '); normvideo;
screen_table;
gotoxy(24,19); color(2,5,0); write('Press any key to start game ');
repeat until keypressed;
gotoxy(78,23)
end; {procedure hustle}
procedure attention;
begin
up_down := 5; compare := 1;
for count := 1 to 20 do
begin
set_tone := count*2 + 5;
duration := 20 - (count div 2);
initsnd; gensnd;
delay(15)
end
end; {procedure attention}
procedure gobbled_up;
begin
set_tone := 60;
duration := 1;
for count := 1 to 3 do
begin
initsnd; gensnd;
delay(200)
end
end; {procedure gobbled_up}
procedure pop_up;
begin
set_tone := 80;
duration := 1;
initsnd; gensnd
end; {procedure pop_up}
procedure screen_table;
begin
mask := 1;
for y := 0 to 2 do
for x := 0 to 1 do
begin
data[x,y] := mask;
mask := mask*2
end
end; {procedure screen_table}
begin {main}
clrscr;
hustle;
clear_col;
high_score := 0;
repeat
initialise;
lores80;
border;
record_score;
repeat
play_game;
until game_over;
end_of_game
until (reply <> 'Y') and (reply <> 'y');
clrscr;
normal
end. {main}