home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1789 < prev    next >
Internet Message Format  |  1990-12-28  |  10KB

  1. From: cadp02@vaxa.strath.ac.uk
  2. Newsgroups: alt.sources,vmsnet.sources.games
  3. Subject: shapes.shar1 (of 2)
  4. Message-ID: <246.26e7ce3d@vaxa.strath.ac.uk>
  5. Date: 7 Sep 90 16:43:41 GMT
  6.  
  7. This is part one of a two part games program that runs on a VAX/VMS.
  8.  
  9. It's a version of the popular arcade game tetris.
  10.  
  11.  
  12. Hope you like it!
  13.  
  14. mail any comments to:-
  15.  
  16.        CADP02@uk.ac.strath.vaxe
  17.  
  18. $!...................... Cut on the dotted line and save ......................
  19. $! VAX/VMS archive file created by VMS_SHAR V-5.04 04-Feb-1988
  20. $! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
  21. $! To unpack, simply save and execute (@) this file.
  22. $!
  23. $! This archive was created by CADP02
  24. $! on Friday 7-SEP-1990 16:33:46.07
  25. $!
  26. $! ATTENTION: To keep each article below 15872 bytes, this program
  27. $! has been transmitted in 2 parts.
  28. $! You should concatenate ALL parts to ONE file and execute (@) that file.
  29. $!
  30. $! It contains the following 5 files:
  31. $! COMPILE.COM INCLUDES.C RAND.FOR README.TXT SHAPES.PAS
  32. $!=============================================================================
  33. $Set Symbol/Scope=(NoLocal,NoGlobal)
  34. $Version=F$GetSYI("VERSION")
  35. $If Version.ges."V4.4" then goto Version_OK
  36. $Write SYS$Output "Sorry, you are running VMS ",Version, -
  37. ", but this procedure requires V4.4 or higher."
  38. $Exit 44
  39. $Version_OK:CR[0,8]=13
  40. $Pass_or_Failed="failed!,passed."
  41. $Goto Start
  42. $Convert_File:
  43. $Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
  44. $No_Error1:Define/User_Mode SYS$Output NL:
  45. $Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
  46. VMS_SHAR_DUMMY.DUMMY
  47. f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
  48. o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
  49. Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
  50. Move_Vertical(1);x:=Erase_Character(1);Append_Line;
  51. Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
  52. ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
  53. x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
  54. If Current_Character='`' then Move_Horizontal(1);else
  55. Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
  56. $Delete VMS_SHAR_DUMMY.DUMMY;*
  57. $Checksum 'File_is
  58. $Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
  59. $Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
  60. $No_Error2:Return
  61. $Start:
  62. $File_is="COMPILE.COM"
  63. $Check_Sum_is=523446877
  64. $Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
  65. X!This command procedure will compile and link the source files for the
  66. X!game Shapes, written and copyrighted by Colin Cowie, Glasgow, Scotland,
  67. X!with certain procedures written and copyrighted by Stephen Macdonald,
  68. X!Glasgow, Scotland.
  69. X!
  70. X!It also defines the symbol "shapes" to run the program.
  71. X!Edit the symbol definition of shapes to point to the location of shapes.exe
  72. X
  73. X$write sys$output "Compiling Shapes.."
  74. X$pascal shapes
  75. X$write sys$output "Compiling Includes.."
  76. X$cc includes
  77. X$write sys$output "Compiling Rand.."
  78. X$fortran rand
  79. X$write sys$output "Linking Shapes,Includes,Rand"
  80. X$link shapes,includes,rand
  81. X$write sys$output "Finished!!"
  82. X
  83. X!The following Line should be entered in your login.com, suitably modified
  84. X$shapes:=="$disk18:[cadp02.pascal.shapes]shapes"
  85. $GoSub Convert_File
  86. $File_is="INCLUDES.C"
  87. $Check_Sum_is=1613696431
  88. $Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
  89. V/*****************************************************************************
  90. X**
  91. XCopyright 1989,1990 by Colin Cowie, Glasgow, Scotland.
  92. X
  93. X                        All Rights Reserved
  94. X
  95. XPermission to use, copy, modify, and distribute this software and its 
  96. Xdocumentation for any purpose and without fee is hereby granted, 
  97. Xprovided that the above copyright notice appear in all copies and that
  98. Xboth that copyright notice and this permission notice appear in
  99. Xsupporting documentation.
  100. V******************************************************************************
  101. X*/
  102. X
  103. X#include <string.h>
  104. X#include <jpidef.h>
  105. X#include <iodef.h>              
  106. X#include <descrip.h>
  107. X
  108. Xtypedef struct
  109. X{
  110. X`009unsigned short`009length ;
  111. X`009char`009`009dtype ;
  112. X`009char`009`009class ;
  113. X`009char`009`009*pntr ;
  114. X}DESCR ;
  115. X
  116. X#define stdescr(name,string) name.length = strlen(string);\
  117. X name.dtype = DSC$K_DTYPE_T; name.class = DSC$K_CLASS_S;\
  118. X name.pntr = string ;
  119. X
  120. X
  121. Xvoid makechan(chan)
  122. Xint *chan;
  123. X{
  124. X  DESCR term;
  125. X  int status;
  126. X  stdescr(term,"TT");
  127. X  status = sys$assign (&term,chan,0,0);
  128. X  if (status != 1) lib$STOP(status);
  129. X}
  130. X
  131. Xvoid readkey(key,chan)
  132. Xint *chan;
  133. Xint *key;
  134. X
  135. X{
  136. X  char inkey;                               
  137. X  int status;                    
  138. X  int func;
  139. X  inkey = (char) 0;
  140. X  func = IO$_READVBLK | IO$M_NOECHO | IO$M_TIMED;
  141. X  status = sys$qiow(0,*chan,func,0,0,0,&inkey,1,0,0,0,0);
  142. X  if (status != 1) lib$STOP(status);
  143. X  *key = (int) inkey;
  144. X}
  145. X
  146. Xvoid waitkey(key,chan)
  147. Xint *chan;
  148. Xint *key;
  149. X
  150. X{
  151. X  char inkey;                               
  152. X  int status;                    
  153. X  int func;
  154. X  inkey = (char) 0;
  155. X  func = IO$_READVBLK | IO$M_NOECHO | IO$M_PURGE;
  156. X  status=sys$qiow(0,*chan,func,0,0,0,&inkey,1,0,0,0,0);
  157. X  if (status != 1) lib$STOP(status);
  158. X  *key = (int) inkey;
  159. X}
  160. X
  161. Xvoid spawn()
  162. X{
  163. X  DESCR userid;
  164. X  stdescr(userid,"Shapes_Refugee");
  165. X  LIB$SPAWN(0,0,0,0,&userid,0,0,0,0,0,0,0);
  166. X}
  167. X
  168. Xparam(word)
  169. Xchar word[5];
  170. X{
  171. X  DESCR inp;
  172. X  int length;
  173. X  stdescr(inp,"    ");
  174. X  LIB$GET_FOREIGN(&inp,0,&length,0);  
  175. X  strcpy(word,inp.pntr);
  176. X}
  177. X
  178. Xvoid usernum(userid)
  179. Xchar userid[8];
  180. X{
  181. X  DESCR u_name;
  182. X  int status;
  183. X  stdescr(u_name,"        ");
  184. X  lib$getjpi(&(JPI$_USERNAME),0,0,0,&u_name,0);
  185. X  strcpy(userid,u_name.pntr);
  186. X}
  187. X
  188. Xvoid waitx(tim)
  189. Xfloat *tim;
  190. X{
  191. X  lib$wait(tim);
  192. X}
  193. $GoSub Convert_File
  194. $File_is="RAND.FOR"
  195. $Check_Sum_is=325473741
  196. $Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
  197. XC---------------------------------------------------------------------
  198. XC RND Function - Designed, Written and Programmed by Stephen Macdonald
  199. XC Code is copyright 1988 Stephen Macdonald CHBS08 Software Consultants
  200. XC---------------------------------------------------------------------
  201. X`009SUBROUTINE Randomise
  202. X`009INTEGER seed
  203. X`009COMMON /seed/seed
  204. X`009CHARACTER date*30
  205. X`009CALL LIB$DATE_TIME(%DESCR(date))
  206. X`009seed=(10000*(ICHAR(date(16:16))-ICHAR('0'))
  207. X     +        +1000*(ICHAR(date(17:17))-ICHAR('0'))
  208. X     +        + 100*(ICHAR(date(19:19))-ICHAR('0'))
  209. X     +        +  10*(ICHAR(date(20:20))-ICHAR('0'))
  210. X     +        +     (ICHAR(date(22:22))-ICHAR('0')))
  211. X`009END
  212. X
  213. X
  214. X`009INTEGER FUNCTION Random(min,max)
  215. X`009INTEGER min,max,seed
  216. X`009REAL rnd,realseed
  217. X`009COMMON /seed/seed
  218. X`009seed=(((seed+1)*75)-1).AND.65535
  219. X`009realseed=seed
  220. X`009rnd=(realseed/65536)*(max-min)+min
  221. X`009random=rnd
  222. X`009END          
  223. XC---------------------------------------------------------------------
  224. XC RND Function - Designed, Written and Programmed by Stephen Macdonald
  225. XC Code is copyright 1988 Stephen Macdonald CHBS08 Software Consultants
  226. XC---------------------------------------------------------------------
  227. $GoSub Convert_File
  228. $File_is="README.TXT"
  229. $Check_Sum_is=307909798
  230. $Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
  231. VThe game Shapes is based on the arcade game tetris, and follows roughly the sa
  232. Xme
  233. Xrules, Full instructions are given in the game itself.
  234. X
  235. VThe game requires a VT100 compatible terminal, and a VAX running VMS version 4
  236. Xor later (at any rate, 4 was the earliest version it was compiled under).
  237. X
  238. XThe source code consists of:-
  239. X
  240. X  Shapes.pas     -    The main source code for the game
  241. X
  242. X  Includes.c     -    Certain system calls, which were easier to write in 'C'
  243. X
  244. X  Rand.for       -    Random number generator, written by a friend, Stephen
  245. X                      Macdonald, and borrowed by me, cos I couldnt be bothered
  246. X
  247. X
  248. XSetting up the game:-
  249. X
  250. XThe game shapes uses 2 data files, one for the high score table, and one for
  251. Xany saved games which might exist. The destinations of these files should be
  252. Xchanged in the source code "Shapes.pas" to point to wherever you want the
  253. Xfiles.
  254. X
  255. XThe actual lines to change are:
  256. X
  257. X  Htablefile='disk18:[cadp02.pascal.shapes]Htable.dat';
  258. X  Savefile='disk18:[cadp02.pascal.shapes]save.dat';
  259. X
  260. X
  261. XTo compile this code, execute the command procedure "compile.com" which is
  262. Xsupplied with this archive (e.g @compile )
  263. X
  264. XAfter compiling the code you need to create 2 empty data files, one for
  265. Xthe saved games, and one for the high score table.
  266. X
  267. XThis is done from within the game itself, by entering the "Cheat" mode.
  268. XTo do this, run the game, and when the menu comes up, type in the string
  269. X"cadp8". This activates the cheat mode.
  270. X
  271. XYou are then asked for a level number. This would be what level you would
  272. Xlike to start at, if you were going to play the game. At the moment we
  273. Xare not interested in that, so type 1 and press return.
  274. X
  275. XYou are now prompted if you would like to reset the saved games file.
  276. XPress y and return.
  277. X
  278. XDo the same for the highscore table file.
  279. X
  280. XBoth files should be on world read and write access if other people are to
  281. Xbe able to play the game.
  282. X
  283. X
  284. XThe game is now ready to play.
  285. X
  286. X
  287. XNotes on the cheat mode:-
  288. X
  289. XBy entering the cheat mode as above, you can reset either , both or none of
  290. Xthe data files for the game, and choose which level to start on. Also,
  291. Vfrom within the game you can choose which shape you would like next by pressin
  292. Xg
  293. Xthe keys 1 to 7 to choose. The appropriate shape will appear in the next shape
  294. Xposition.
  295. X
  296. X
  297. XThats it!! Enjoy!!
  298. X
  299. X
  300. XYou are free to modify the code in any way whatsoever.
  301. XThere are probably major improvements that can be made in the game as it is,
  302. Xso if you make any, or have any comments, mail them to me at:-
  303. X
  304. X                     "CADP02@uk.ac.strath.vaxe"
  305. X
  306. $GoSub Convert_File
  307. $Goto Part4
  308.