-+-+-+-+-+-+-+-+ START OF PART 7 -+-+-+-+-+-+-+-+ X helpdis : unsigned; X Xbegin X smg$create_virtual_display(18,45,helpdis,smg$m_border); X smg$label_border(helpdis,'Instructions'); X smg$paste_virtual_display(helpdis,pasty,round(sheight/2)-7,round(swidth/2) V-22); X smg$put_line(helpdis,'The object of the game is to eat as many of'); X smg$put_line(helpdis,'shrooms ('+mushseg+') without running into any of th Ve'); X smg$put_line(helpdis,'obstacles. * obstacles are *'); X smg$put_line(helpdis,' walls ('+wallseg+')'); X smg$put_line(helpdis,' house (`5E)'); X smg$put_line(helpdis,' yourself ('+wormseg+')',2); X smg$put_line(helpdis,'After you have eaten every shroom ('+mushseg+') anot Vher'); X smg$put_line(helpdis,'level will be loaded. There are 20 levels'); X smg$put_line(helpdis,'total, so you may want to use `5EZ (save). '); X smg$put_line(helpdis,'Now go get stoned!',2); X smg$put_line(helpdis,'for more detailed instructions refer to the'); X smg$put_line(helpdis,'help file (maslib help shroom.) They''re'); X smg$put_line(helpdis,'several features within this game that cannot'); X smg$put_line(helpdis,'easily be discussed here...',2); X smg$put_line(helpdis,' Hit a key to continue..'); X smg$read_keystroke(keyboard,temp,,); X temp := smg$k_trm_lowercase_i; X smg$delete_virtual_display(helpdis); Xend; X Xprocedure options; `7Bnote: SMG$MENU SUCKS THE DOG! *sigh*`7D X Xvar X optdis : unsigned; X position : integer; X a : array `5B1..9`5D of char; X Xbegin X writeln (chr(27),'`5B?25h'); X for position := 1 to 9 do X a`5Bposition`5D := chr(32); X a`5B1`5D := wallseg; X a`5B2`5D := mushseg; X a`5B3`5D := wormseg; X if not (ord (a`5B4`5D) > smg$k_trm_delete) then X begin X a`5B4`5D := chr(up); X a`5B5`5D := chr(left); X a`5B6`5D := chr(right); X a`5B7`5D := chr(down); X end X else X begin X a`5B4`5D := chr(32); X a`5B5`5D := chr(32); X a`5B6`5D := chr(32); X a`5B7`5D := chr(32); X end; X X if a`5B4`5D = chr (smg$k_trm_up) then a`5B8`5D := '*'; X if a`5B4`5D = chr (smg$k_trm_kp8) then a`5B9`5D := '*'; X`7Bend keyboard predefined definitions`7D X smg$create_virtual_display(9,53,optdis,smg$m_border); X smg$paste_virtual_display(optdis,pasty,round(sheight/2)-3,round(swidth/2)- V25,); X smg$label_border(optdis,'Options'); X smg$put_chars(optdis,'UP/DOWN keys to change selections',1,1,,smg$m_bold); X smg$put_chars(optdis,' Wall character :',4,1); X smg$put_chars(optdis,' Shroom character :',5,1); X smg$put_chars(optdis,' Worm Character :',6,1); X smg$put_chars(optdis,'Use Keypad and Return. `5EZ to exit',9,1,,smg$m_bold V); X smg$draw_rectangle(optdis,1,40,7,46); X smg$draw_rectangle(optdis,3,35,5,51); X smg$put_chars(optdis,' (arrow keys) ',8,36); X smg$put_chars(optdis,'(numeric keypad) ',9,36); X position := 1; X repeat X smg$begin_pasteboard_update (pasty); X smg$put_chars (optdis,a`5B1`5D,4,24); X smg$put_chars (optdis,a`5B2`5D,5,24); X smg$put_chars (optdis,a`5B3`5D,6,24); X smg$put_chars (optdis,a`5B4`5D,2,43); X smg$put_chars (optdis,a`5B5`5D,4,37); X smg$put_chars (optdis,a`5B6`5D,4,49); X smg$put_chars (optdis,a`5B7`5D,6,43); X smg$put_chars (optdis,a`5B8`5D,8,35); X smg$put_chars (optdis,a`5B9`5D,9,35); X if position = 8 then X begin X smg$put_chars(optdis,' (arrow keys) ',8,36,,smg$m_bold); X end X else X smg$put_chars(optdis,' (arrow keys) ',8,36); X if position = 9 then X begin X smg$put_chars(optdis,'(numeric keypad) ',9,36,,smg$m_bold); X end X else X smg$put_chars(optdis,'(numeric keypad) ',9,36); X smg$end_pasteboard_update (pasty); X if position = 1 then smg$set_cursor_abs (optdis,4,24); X if position = 2 then smg$set_cursor_abs (optdis,5,24); X if position = 3 then smg$set_cursor_abs (optdis,6,24); X if position = 4 then smg$set_cursor_abs (optdis,2,43); X if position = 5 then smg$set_cursor_abs (optdis,4,37); X if position = 6 then smg$set_cursor_abs (optdis,4,49); X if position = 7 then smg$set_cursor_abs (optdis,6,43); X if position = 8 then smg$set_cursor_abs (optdis,8,43); X if position = 9 then smg$set_cursor_abs (optdis,9,43); X smg$read_keystroke(keyboard,temp,,); X if (temp > smg$k_trm_space) and (temp < smg$k_trm_delete) or (temp = smg V$k_trm_ctrlm) then X begin X if not ((position = 9) or (position = 8)) then X begin X if not (temp = smg$k_trm_ctrlm) then a`5Bposition`5D := chr(temp); X if not (temp = smg$k_trm_ctrlm ) and ((position > 3) and (position < V 8)) then X begin X a`5B8`5D := ' '; X a`5B9`5D := ' '; X end; X end X else X begin X a`5B4`5D := ' '; X a`5B5`5D := ' '; X a`5B6`5D := ' '; X a`5B7`5D := ' '; X if position = 8 then X begin X a`5B8`5D := '*'; X a`5B9`5D := ' '; X end X else X begin X a`5B8`5D := ' '; X a`5B9`5D := '*'; X end; `20 X end; X end; X if temp = smg$k_trm_down then position := position + 1; X if temp = smg$k_trm_up then position := position - 1; X if position > 9 then position := 1; X if position < 1 then position := 9; X until temp = smg$k_trm_ctrlz; X X`7Breturn to the program with new values....`7D X wallseg := a`5B1`5D; X mushseg := a`5B2`5D; X wormseg := a`5B3`5D; X up := ord(a`5B4`5D); X left := ord(a`5B5`5D); X right := ord(a`5B6`5D); X down := ord(a`5B7`5D); X if a`5B8`5D = '*' then X begin X up := smg$k_trm_up; X left := smg$k_trm_left; X right := smg$k_trm_right; X down := smg$k_trm_down; X end; X if a`5B9`5D = '*' then X begin X up := smg$k_trm_kp8; X left := smg$k_trm_kp4; X right := smg$k_trm_kp6; X down := smg$k_trm_kp2; X end; X smg$delete_virtual_display (optdis); X temp := smg$k_trm_lowercase_o; X writeln (chr(27),'`5B?25l'); Xend; `7Bif ANYBODY can make this routine significantly shorter, send it to m Ve!`7D X Xprocedure difficulty; X Xvar X diff : integer; X lev : unsigned; X Xbegin X smg$create_virtual_display(6,14,lev,smg$m_border); X smg$paste_virtual_display(lev,pasty,round(sheight/2)-2,round(swidth/2)-5,) V; X smg$label_border(lev,'LEVEL'); X diff := 1; X repeat X smg$begin_pasteboard_update(pasty); X smg$put_chars(lev,' easy ',2,2); X smg$put_chars(lev,' difficult ',3,2); X smg$put_chars(lev,' expert ',4,2); X smg$put_chars(lev,' impossible ',5,2); `20 X if diff = 1 then smg$put_chars(lev,' easy ',2,2,,smg$m_reverse); X if diff = 2 then smg$put_chars(lev,' difficult ',3,2,,smg$m_reverse); X if diff = 3 then smg$put_chars(lev,' expert ',4,2,,smg$m_reverse); X if diff = 4 then smg$put_chars(lev,' impossible ',5,2,,smg$m_reverse); X smg$end_pasteboard_update(pasty); X smg$read_keystroke(keyboard,temp,,); X if temp = smg$k_trm_up then diff := diff - 1; X if temp = smg$k_trm_down then diff := diff + 1; X if diff > 4 then diff := 1; X if diff < 1 then diff := 4; X until temp = smg$k_trm_ctrlm; X smg$delete_virtual_display(lev); X w.level := (diff-1)*5; Xend; X Xprocedure startup; `7Bsubprocedures: options, help, levels`7D X Xvar X start : unsigned; X select : integer; X Xbegin X select := 1; X smg$create_virtual_display(5,14,start,smg$m_border); X smg$paste_virtual_display(start,pasty,round(sheight/2)-2,round(swidth/2)-5 V,); X smg$label_border( start,'Select'); X repeat X smg$begin_pasteboard_update (pasty); X smg$put_chars(start,'Start Game!',2,2); X smg$put_chars(start,' Options ',3,2); X smg$put_chars(start,' HELP! ',4,2); X if select = 1 then smg$put_chars(start,'Start Game!',2,2,,smg$m_reverse) V; X if select = 2 then smg$put_chars(start,' Options ',3,2,,smg$m_reverse) V; X if select = 3 then smg$put_chars(start,' HELP! ',4,2,,smg$m_reverse) V; X smg$end_pasteboard_update (pasty); X smg$read_keystroke(keyboard,temp,,); X if temp = smg$k_trm_up then select := select - 1; X if temp = smg$k_trm_down then select := select + 1; X if select > 3 then select := 1; X if select < 1 then select := 3; X if (select = 2) and (temp = smg$k_trm_ctrlm) then options; X if (select = 3) and (temp = smg$k_trm_ctrlm) then instruct; X until (select = 1) and (temp = smg$k_trm_ctrlm); X smg$delete_virtual_display (start); Xend; X Xprocedure center (var a : packed30); X Xvar X left : integer; X right : integer; X b : packed30; X c : integer; X d : integer; X Xbegin X b := ' '; X left := 0; X right := 0; `7Bstring length`7D X repeat X left := left + 1; X until not (a`5Bleft`5D = chr(32)) or (left = 30); X left := left - 1; X if not ((left = 29) and (a`5Bleft+1`5D = chr(32))) then X begin X repeat X right := right + 1; X until not (a`5B31-right`5D = chr(32)); X right := right - 1; X c := trunc ((left+right)/2); X for d := left+1 to 30-right do X b`5Bd-left+c`5D := a`5Bd`5D; X a := b; X end; Xend; X Xprocedure save; `7Bsave a game for later play`7D X Xbegin X smg$put_chars(stat,'Attempting to write to save file...',1,1,smg$m_erase_t Vo_eol); X s_game := prefix + 'saves.dat;'; X loop := 0; X repeat X loop := loop + 1; X lib$wait (0.05); X Open(wf,s_game,history:=unknown, X access_method:=keyed,record_type:=fixed,organization:=indexed, X sharing:=readwrite,error := continue) X until (status (wf) = 0) or (loop = 100); X if not (loop = 100) then`20 X begin X if lastkey = up then w.last := 'u'; X if lastkey = left then w.last := 'l'; X if lastkey = down then w.last := 'd'; `20 X if lastkey = right then w.last := 'r'; X if not ((lastkey = up) or (lastkey = left) or (lastkey = down) or (lastk Vey = right)) then w.last := '?'; X write (wf,w); X close (wf); X smg$put_chars (stat,' Game has been successfully saved, see y Vou next time ',1,1,,smg$m_blink+smg$m_reverse); X end X else X smg$put_chars (stat,' An error has occured! Your game has b Veen lost, sorry ',1,1,,smg$m_blink+smg$m_reverse); Xend; X Xprocedure recall; `7Brecall a game for current play`7D X Xvar X notify : unsigned;`20 X X Xbegin X s_game := prefix + 'saves.dat;'; X loop := 0; X repeat X loop := loop + 1; X lib$wait(0.05); X Open(wf,s_game,history:=unknown, X access_method:=keyed,record_type:=fixed,organization:=indexed, X sharing:=readwrite,error:=continue); X until (status (wf) = 0) or (loop = 100); X if not (loop=100) then X begin X repeat X findk (wf,0,w.user,error := continue); X until (status(wf) = 0); X if not (UFB (wf)) then `7Bi.e if there is a saved game`7D X begin X STORED := True; X SHOW := False; X w.score := wf`5E.score; X w.lives := wf`5E.lives; X w.x := wf`5E.x; X w.y := wf`5E.y; X w.mushx := wf`5E.mushx; X w.mushy := wf`5E.mushy; X w.cur := wf`5E.cur; X w.point := wf`5E.point; X w.lengw := wf`5E.lengw; X w.level := wf`5E.level; X if wf`5E.last = 'u' then lastkey := up; X if wf`5E.last = 'l' then lastkey := left; X if wf`5E.last = 'r' then lastkey := right; X if wf`5E.last = 'd' then lastkey := down; X if wf`5E.last = '?' then lastkey := 1000; X `7Bdelete old record; no cheating here!`7D X delete (wf,error := continue); X smg$create_virtual_display(2,39,notify,smg$m_border); X smg$paste_virtual_display(notify,pasty,round(sheight/2)-1,round(swidth V/2)-21,); X smg$put_chars(notify,'You have a saved game, I retrieved it..',1,1); X smg$put_chars(notify,'Go to `5BO`5Dptions or `5BS`5Dtart? (def `5BS`5D V)',2,1); X smg$read_keystroke(keyboard,temp,,); X if (temp = smg$k_trm_uppercase_o) or (temp = smg$k_trm_lowercase_o) th Ven options; X smg$delete_virtual_display (notify); X for loop := 1 to buf do `7Bredraw worm`7D X begin X w.histx`5Bloop`5D := wf`5E.histx`5Bloop`5D; X w.histy`5Bloop`5D := wf`5E.histy`5Bloop`5D;`20 X if not (w.histx`5Bloop`5D = 0) and not (w.histy `5Bloop`5D = 0) then X begin X smg$put_chars (display,wormseg,w.histy`5Bloop`5D,w.histx`5Bloop`5D V); X bump `5Bw.histx`5Bloop`5D,w.histy`5Bloop`5D`5D := True; X end; X end; X bump `5Bround(swidth/2),round(sheight/2)`5D := True; X smg$put_chars (display,'`5E',round(sheight/2),round(swidth/2)); X if lastkey = up then smg$put_chars(display,'`5E',w.y,w.x); X if lastkey = down then smg$put_chars(display,'v',w.y,w.x); X if lastkey = left then smg$put_chars(display,'<',w.y,w.x); X if lastkey = right then smg$put_chars(display,'>',w.y,w.x); X end; X close (wf); X end X else X begin X smg$put_chars (stat,' The save file could not be opened! Pos Vsible corruption? ',1,1,,smg$m_bold+smg$m_blink+smg$m_reverse); X lib$wait(10); X smg$put_chars (stat,'I will put you on level one anyhow....',1,1,smg$m V_erase_to_eol); X lib$wait(2); X smg$erase_display(stat); X end; Xend; X Xprocedure highscore; `7Bthis is a second attempt, using record format instea Vd`7D X `7Bthis is spaghetti code, but the hell with it!`7D Xconst X history = 50; `7Bhow far back to log games & highscore`7D X `7Bif you change this number: delete the highscore file!`7D Xtype X rhigh = record X user : packed12; X score : integer; X alias : packed30; `7Bsignature name`7D X games : integer; X level : integer; X end; X Xvar X`7Breal variables`7D X games : integer; X highdisp : unsigned; `7Bscreen variable`7D X high_r : array `5B1..history`5D of rhigh; X player : rhigh; X high_f : file of rhigh; `7Bfile variable`7D X DEJAVU : boolean; `7Bchecks to see if your old score is better than new` V7D X POST : boolean; `7Btells if you got on the high score list`7D X count : integer; `7Bsee's how many in the top 10 you beat`7D X Xbegin X player.score := w.score; X player.level := w.level; X DEJAVU := False; X POST := False; X high := prefix + 'high.dat'; +-+-+-+-+-+-+-+- END OF PART 7 +-+-+-+-+-+-+-+-