$! ------------------ CUT HERE ----------------------- $ v='f$verify(f$trnlnm("SHARE_VERIFY"))' $! $! This archive created by VMS_SHARE Version 7.2-007 22-FEB-1990 $! On 20-MAY-1992 19:46:37.21 By user MASMUMMY $! $! This VMS_SHARE Written by: $! Andy Harper, Kings College London UK $! $! Acknowledgements to: $! James Gray - Original VMS_SHARE $! Michael Bednarek - Original Concept and implementation $! $!+ THIS PACKAGE DISTRIBUTED IN 5 PARTS, TO KEEP EACH PART $! BELOW 30 BLOCKS $! $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER $! AND EXECUTE AS A COMMAND PROCEDURE ( @name ) $! $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING: $! 1. MAKEFILE.;1 $! 2. O.OPT;1 $! 3. PLAY.C;1 $! 4. READSCREEN.C;1 $! 5. SAVE.C;1 $! 6. SAVE.SCORE;1 $! 7. SCORE.C;1 $! 8. SCREEN.1;1 $! 9. SCREEN.10;1 $! 10. SCREEN.11;1 $! 11. SCREEN.12;1 $! 12. SCREEN.13;1 $! 13. SCREEN.14;1 $! 14. SCREEN.15;1 $! 15. SCREEN.16;1 $! 16. SCREEN.17;1 $! 17. SCREEN.18;1 $! 18. SCREEN.19;1 $! 19. SCREEN.2;1 $! 20. SCREEN.20;1 $! 21. SCREEN.21;1 $! 22. SCREEN.22;1 $! 23. SCREEN.23;1 $! 24. SCREEN.24;1 $! 25. SCREEN.25;1 $! 26. SCREEN.26;1 $! 27. SCREEN.27;1 $! 28. SCREEN.28;1 $! 29. SCREEN.29;1 $! 30. SCREEN.3;1 $! 31. SCREEN.30;1 $! 32. SCREEN.31;1 $! 33. SCREEN.32;1 $! 34. SCREEN.33;1 $! 35. SCREEN.34;1 $! 36. SCREEN.35;1 $! 37. SCREEN.36;1 $! 38. SCREEN.37;1 $! 39. SCREEN.38;1 $! 40. SCREEN.39;1 $! 41. SCREEN.4;1 $! 42. SCREEN.40;1 $! 43. SCREEN.41;1 $! 44. SCREEN.42;1 $! 45. SCREEN.43;1 $! 46. SCREEN.44;1 $! 47. SCREEN.45;1 $! 48. SCREEN.46;1 $! 49. SCREEN.47;1 $! 50. SCREEN.48;1 $! 51. SCREEN.49;1 $! 52. SCREEN.5;1 $! 53. SCREEN.50;1 $! 54. SCREEN.6;1 $! 55. SCREEN.7;1 $! 56. SCREEN.8;1 $! 57. SCREEN.9;1 $! 58. SHOWSCREEN.C;1 $! 59. SOK.C;1 $! 60. SOK.SCORE;1 $! 61. SOKOBAN.H;1 $! $set="set" $set symbol/scope=(nolocal,noglobal) $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID")) $e="write sys$error ""%UNPACK"", " $w="write sys$output ""%UNPACK"", " $ if f$trnlnm("SHARE_LOG") then $ w = "!" $ ve=f$getsyi("version") $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START $ e "-E-OLDVER, Must run at least VMS 4.4" $ v=f$verify(v) $ exit 44 $UNPACK: SUBROUTINE ! P1=filename, P2=checksum $ if f$search(P1) .eqs. "" then $ goto file_absent $ e "-W-EXISTS, File ''P1' exists. Skipped." $ delete 'f'* $ exit $file_absent: $ if f$parse(P1) .nes. "" then $ goto dirok $ dn=f$parse(P1,,,"DIRECTORY") $ w "-I-CREDIR, Creating directory ''dn'." $ create/dir 'dn' $ if $status then $ goto dirok $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped." $ delete 'f'* $ exit $dirok: $ w "-I-PROCESS, Processing file ''P1'." $ if .not. f$verify() then $ define/user sys$output nl: $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1' PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET( SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:= CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b)); LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION( BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1); IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE; MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1; ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")= 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF"; POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r); ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1; COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE, "output_file"));ENDPROCEDURE;Unpacker;QUIT; $ delete/nolog 'f'* $ CHECKSUM 'P1' $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT $ e "-E-CHKSMFAIL, Checksum of ''P1' failed." $ ENDSUBROUTINE $START: $ create 'f' XWS = write sys$output X Xall: sok.exe X $(WS) "All done." X Xsok.exe: sok.obj play.obj readscreen.obj save.obj score.obj showscreen.obj X $(WS) "Linking." X link sok,play,readscreen,save,score,showscreen,o/opt X Xsok.obj: sokoban.h sok.c X $(WS) "Compiling sok.c" X cc sok X Xplay.obj: sokoban.h play.c X $(WS) "Compiling play.c" X cc play X Xreadscreen.obj: sokoban.h readscreen.c X $(WS) "Compiling readscreen.c" X cc readscreen X Xsave.obj: sokoban.h save.c X $(WS) "Compiling save.c" X cc save X Xscore.obj: sokoban.h score.c X $(WS) "Compiling score.c" X cc score X Xshowscreen.obj: sokoban.h showscreen.c X $(WS) "Compiling showscreen.c" X cc showscreen X Xinstall: X $(WS) "Installing." X rename sok.exe `5B-`5D $ CALL UNPACK MAKEFILE.;1 894896695 $ create 'f' Xsys$share:vaxcrtl.exe/share $ CALL UNPACK O.OPT;1 1392527948 $ create 'f' X#include X#include X#include unixlib X#include "sokoban.h" X X/* defining the types of move */ X#define MOVE `09`091 X#define PUSH `09`092 X#define SAVE `09`093 X#define UNSAVE `09`094 X#define STOREMOVE `095 X#define STOREPUSH `096 X X/* defines for control characters */ X#define CNTL_L`09`09'\014' X#define CNTL_K`09`09'\013' X#define CNTL_I`09`09'\011' X#define CNTL_J`09`09'\012' X#define CNTL_R`09`09'\022' X#define CNTL_U`09`09'\025' X Xextern char map`5BMAXROW+1`5D`5BMAXCOL+1`5D; Xextern short rows, columns, level, moves, pushes, savepack, packets; Xextern short scorelevel, scoremoves, scorepushes; Xextern POS ppos; X Xstatic POS tpos1,`09`09 /* testpos1: 1 pos. over/under/left/right */ X tpos2,`09`09 /* testpos2: 2 pos. " */ X lastppos,`09`09 /* the last player position (for undo) */ X lasttpos1, lasttpos2; /* last test positions (for undo) V */ Xstatic char lppc, ltp1c, ltp2c; /* the char for the above pos. (for undo) V */ Xstatic short action, lastaction; X X/** For the temporary save **/ Xstatic char tmp_map`5BMAXROW+1`5D`5BMAXCOL+1`5D; Xstatic short tmp_pushes, tmp_moves, tmp_savepack; Xstatic POS tmp_ppos; X Xshort play() `7B X X short c; X short ret; X short undolock = 1;`09`09/* locked for undo */ X char quit_flag; X X showscreen(); X tmpsave(); X ret = 0; X while( ret == 0) `7B X switch( (c = getch())) `7B X`09 case 'q': /* quit the game `09`09`09`09`09*/ X`09 `09 move( MAXROW+2,0); X`09`09 printw("Quit and save game?"); X`09`09 if (toupper(quit_flag = getch())=='N') X`09 ret = E_ENDGAME;`20 X`09 `09 else if (toupper(quit_flag)=='Y') X`09`09`09 if( (ret = savegame()) == 0) X`09`09 ret = E_SAVED; X`09`09 move( MAXROW+2,0); X`09`09 deleteln(); X`09 break; X case 26 : ret = E_ENDGAME; X break; X case 'b': /* boost priority -- super slow on VMS */ X `09`09 sys$setpri(0,0,4,0); X break; X`09 case 's': /* save the games`09`09`09`09`09*/ X`09`09 if( (ret = savegame()) == 0) X`09`09`09 ret = E_SAVED; X`09`09 break; X`09 case '?': /* show the help file`09`09`09`09*/ X`09`09 showhelp(); X`09`09 showscreen(); X`09`09 break; X`09 case CNTL_R: /* refresh the screen `09`09`09`09*/ X`09`09 clear(); X`09`09 showscreen(); X`09`09 break; X`09 case 'c': /* temporary save`09`09`09`09`09*/ X`09`09 tmpsave(); X`09`09 break; X`09 case CNTL_U: /* reset to temporary save `09`09`09*/ X`09`09 tmpreset(); X`09`09 undolock = 1; X`09`09 showscreen(); X`09`09 break; X`09 case 'U': /* undo this level `09`09`09`09*/ X`09`09 moves = pushes = 0; X`09`09 if( (ret = readscreen()) == 0) `7B X`09`09 showscreen(); X`09`09`09 undolock = 1; X`09`09 `7D X`09`09 break; X`09 case 'u': /* undo last move `09`09`09`09*/ X`09`09 if( ! undolock) `7B X`09`09 undomove(); X`09`09 undolock = 1; X`09`09 `7D X`09`09 break; X`09 case 'i': /* up `09`09`09`09`09`09*/ X`09 case 'I': /* run up `09`09`09`09`09*/ X`09 case CNTL_I: /* run up, stop before object `09`09`09*/ X`09 case 'k': /* down `09`09`09`09`09`09*/ X`09 case 'K': /* run down `09`09`09`09`09*/ X`09 case CNTL_K: /* run down, stop before object `09`09`09*/ X`09 case 'l': /* right `09`09`09`09`09`09*/ X`09 case 'L': /* run right `09`09`09`09`09*/ X`09 case CNTL_L: /* run right, stop before object `09`09`09*/ X`09 case 'j': /* left `09`09`09`09`09`09*/ X`09 case 'J': /* run left `09`09`09`09`09*/ X`09 case CNTL_J: /* run left, stop before object `09`09`09*/ X`09`09 do `7B X`09`09 if( (action = testmove( c)) != 0) `7B X`09`09`09 lastaction = action; X`09`09 lastppos.x = ppos.x; lastppos.y = ppos.y; X`09`09 lppc = map`5Bppos.x`5D`5Bppos.y`5D; X`09`09 lasttpos1.x = tpos1.x; lasttpos1.y = tpos1.y;`20 X`09`09 ltp1c = map`5Btpos1.x`5D`5Btpos1.y`5D; X`09`09 lasttpos2.x = tpos2.x; lasttpos2.y = tpos2.y;`20 X`09`09 ltp2c = map`5Btpos2.x`5D`5Btpos2.y`5D; X`09`09 domove( lastaction);`20 X`09`09 undolock = 0; X`09`09 `7D X`09`09 `7D while( (action != 0) && (! islower( c)) X`09`09`09 && (packets != savepack)); X`09`09 break; X`09 default: helpmessage(); break; X `7D X if( (ret == 0) && (packets == savepack)) `7B X`09 scorelevel = level; X`09 scoremoves = moves; X`09 scorepushes = pushes; X`09 break; X `7D X `7D X return( ret); X`7D X Xtestmove( action) Xregister short action; X`7B X register short ret; X register char tc; X register short stop_at_object; X X if( (stop_at_object = iscntrl( action))) action = action + 'A' - 1; X action = (isupper( action)) ? tolower( action) : action; X if( (action == 'i') `7C`7C (action == 'k')) `7B X tpos1.x = (action == 'i') ? ppos.x-1 : ppos.x+1; X tpos2.x = (action == 'i') ? ppos.x-2 : ppos.x+2; X tpos1.y = tpos2.y = ppos.y; X `7D X else `7B X tpos1.y = (action == 'j') ? ppos.y-1 : ppos.y+1; X tpos2.y = (action == 'j') ? ppos.y-2 : ppos.y+2; X tpos1.x = tpos2.x = ppos.x; X `7D X tc = map`5Btpos1.x`5D`5Btpos1.y`5D; X if( (tc == packet.obj_intern) `7C`7C (tc == save.obj_intern)) `7B X if( ! stop_at_object) `7B X if( map`5Btpos2.x`5D`5Btpos2.y`5D == ground.obj_intern) X ret = (tc == save.obj_intern) ? UNSAVE : PUSH; X else if( map`5Btpos2.x`5D`5Btpos2.y`5D == store.obj_intern) X ret = (tc == save.obj_intern) ? STOREPUSH : SAVE; X else ret = 0; X `7D X else ret = 0; X `7D X else if( tc == ground.obj_intern) X ret = MOVE; X else if( tc == store.obj_intern) X ret = STOREMOVE; X else ret = 0; X return( ret); X`7D X Xdomove( moveaction)`20 Xregister short moveaction; X`7B X map`5Bppos.x`5D`5Bppos.y`5D = (map`5Bppos.x`5D`5Bppos.y`5D == player.obj_ Vintern)`20 X`09`09`09 ? ground.obj_intern`20 X`09`09`09 : store.obj_intern; X switch( moveaction) `7B X case MOVE: map`5Btpos1.x`5D`5Btpos1.y`5D = player.obj_intern; `09 Vbreak; X case STOREMOVE: map`5Btpos1.x`5D`5Btpos1.y`5D = playerstore.obj_intern V; `09break; X case PUSH: map`5Btpos2.x`5D`5Btpos2.y`5D = map`5Btpos1.x`5D`5Btpo Vs1.y`5D; X`09`09 map`5Btpos1.x`5D`5Btpos1.y`5D = player.obj_intern;`09 X`09`09 pushes++;`09`09`09`09`09`09break; X case UNSAVE: map`5Btpos2.x`5D`5Btpos2.y`5D = packet.obj_intern; X`09`09 map`5Btpos1.x`5D`5Btpos1.y`5D = playerstore.obj_intern;`09`09 X`09`09 pushes++; savepack--;`09`09`09 `09break; X case SAVE: map`5Btpos2.x`5D`5Btpos2.y`5D = save.obj_intern; X`09`09 map`5Btpos1.x`5D`5Btpos1.y`5D = player.obj_intern;`09`09`09 X`09`09 savepack++; pushes++;`09`09`09`09break; X case STOREPUSH: map`5Btpos2.x`5D`5Btpos2.y`5D = save.obj_intern; X`09`09 map`5Btpos1.x`5D`5Btpos1.y`5D = playerstore.obj_intern;`09`09 X`09`09 pushes++;`09`09`09`09`09`09break; X `7D X moves++; X dispmoves(); disppushes(); dispsave(); X mapchar( map`5Bppos.x`5D`5Bppos.y`5D, ppos.x, ppos.y); X mapchar( map`5Btpos1.x`5D`5Btpos1.y`5D, tpos1.x, tpos1.y); X mapchar( map`5Btpos2.x`5D`5Btpos2.y`5D, tpos2.x, tpos2.y); X move( MAXROW+1, 0); X refresh(); X ppos.x = tpos1.x; ppos.y = tpos1.y; X`7D X Xundomove() `7B X X map`5Blastppos.x`5D`5Blastppos.y`5D = lppc; X map`5Blasttpos1.x`5D`5Blasttpos1.y`5D = ltp1c; X map`5Blasttpos2.x`5D`5Blasttpos2.y`5D = ltp2c; X ppos.x = lastppos.x; ppos.y = lastppos.y; X switch( lastaction) `7B X case MOVE: moves--;`09`09`09`09break; X case STOREMOVE: moves--;`09`09`09`09break; X case PUSH: moves--; pushes--;`09`09break; X case UNSAVE: moves--; pushes--; savepack++;`09break; X case SAVE: moves--; pushes--; savepack--;`09break; X case STOREPUSH: moves--; pushes--;`09`09break; X `7D X dispmoves(); disppushes(); dispsave(); X mapchar( map`5Bppos.x`5D`5Bppos.y`5D, ppos.x, ppos.y); X mapchar( map`5Blasttpos1.x`5D`5Blasttpos1.y`5D, lasttpos1.x, lasttpos1.y) V; X mapchar( map`5Blasttpos2.x`5D`5Blasttpos2.y`5D, lasttpos2.x, lasttpos2.y) V; X move( MAXROW+1, 0); X refresh(); X`7D X Xtmpsave() `7B X X register short i, j; X X for( i = 0; i < rows; i++) for( j = 0; j < columns; j++) X tmp_map`5Bi`5D`5Bj`5D = map`5Bi`5D`5Bj`5D; X tmp_pushes = pushes; X tmp_moves = moves; X tmp_savepack = savepack; X tmp_ppos.x = ppos.x; tmp_ppos.y = ppos.y; X`7D X Xtmpreset() `7B X X register short i, j; X X for( i = 0; i < rows; i++) for( j = 0; j < columns; j++) X map`5Bi`5D`5Bj`5D = tmp_map`5Bi`5D`5Bj`5D; X pushes = tmp_pushes; X moves = tmp_moves; X savepack = tmp_savepack; X ppos.x = tmp_ppos.x; ppos.y = tmp_ppos.y; X`7D $ CALL UNPACK PLAY.C;1 439308415 $ create 'f' X#include X#include unixlib X#include "sokoban.h" X Xextern char *malloc(); Xextern FILE *fopen(); X Xextern short level, packets, savepack, rows, columns; Xextern char map`5BMAXROW+1`5D`5BMAXCOL+1`5D; Xextern POS ppos; X +-+-+-+-+-+-+-+- END OF PART 1 +-+-+-+-+-+-+-+-