$! ------------------ CUT HERE ----------------------- $ v='f$verify(f$trnlnm("SHARE_VERIFY"))' $! $! This archive created by VMS_SHARE Version 7.2-007 22-FEB-1990 $! On 30-MAY-1992 03:19:32.98 By user MASLIB $! $! 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 2 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. BUILD.COM;1 $! 2. DEFENDER.PAS;1 $! 3. DEFENDER.PIC;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' X$ PASCAL DEFENDER X$ LINK DEFENDER, INTERACT/LIB X$ DELETE *.OBJ;*/NOCONFIRM X$ EXIT $ CALL UNPACK BUILD.COM;1 140579402 $ create 'f' X`5B X Inherit`20 X ( X 'SYS$LIBRARY:STARLET', X 'INTERACT' X ) X`5D X XPROGRAM Defender; X XCONST X max_aliens = 8; XTYPE X pointer = `5Eshot; X shot = record X x_posn : integer; X y_posn : integer; X prev : pointer; X next : pointer; X End; X v_array = varying `5B200`5D of char; XVAR X Screen : array `5B1..40,1..20`5D of integer; X x_alien : array `5B1..max_aliens`5D of integer; X y_alien : array `5B1..max_aliens`5D of integer; X d_alien : array `5B1..max_aliens`5D of integer; X alien_type : array `5B1..max_aliens`5D of char; X alien_alive : array `5B1..max_aliens`5D of boolean; X gun_working : array `5B1..9`5D of boolean; X gun_shot : array `5B1..9`5D of integer; X score : integer; X penality : integer; X command : char; X head_shot : pointer; X this_shot : pointer; X shot_deleted : boolean; X X XPROCEDURE Setup; XVAR X i : integer; X x : integer; X y : integer; XBEGIN X command := ' '; X clear; X qio_write (VT100_inverse); X FOR y := 1 to 24 do X BEGIN X posn (1,y); X qio_write (VT100_wide); X END; X FOR y := 21 to 22 do X BEGIN X posn (1,y); X FOR x := 1 to 40 do X qio_write (' '); X END; X X FOR i := 1 to max_aliens do X alien_alive`5Bi`5D := false; X X FOR i := 1 to 9 do X gun_working`5Bi`5D := true; X X qio_write (VT100_normal); X X FOR x := 1 to 9 do X BEGIN X posn (x*4,21); X qio_write ('`5E'); X posn (x*4,23); X qio_write (dec(x)); X END; X X posn (15,24); X qio_write ('SCORE : 0'); XEND; X X XPROCEDURE Refresh_screen; XVAR X i : integer; X x : integer; X y : integer; XBEGIN X command := ' '; X clear; X qio_write (VT100_inverse); X FOR y := 1 to 24 do X BEGIN X posn (1,y); X qio_write (VT100_wide); X END; X FOR y := 21 to 22 do X BEGIN X posn (1,y); X FOR x := 1 to 40 do X qio_write (' '); X END; X X qio_write (VT100_normal); X X FOR x := 1 to 9 do X BEGIN X posn (x*4,21); X IF gun_working`5Bx`5D then X qio_write ('`5E') X ELSE X qio_write ('*'); X posn (x*4,23); X qio_write (dec(x)); X END; X X posn (15,24); X qio_write ('SCORE : 0'); XEND; X X XPROCEDURE Start_screen; XBEGIN X clear; X show_graphedt ('Defender.pic'); XEND; X X XPROCEDURE Initialize; XBEGIN X image_dir; X score := 1; XEND; X X XPROCEDURE Get_command; XVAR X valid_com : boolean; X input_buffer : v_array; X i : integer; XBEGIN X input_buffer := qio_readln (80); X i := 1; X REPEAT X IF ( i > length(input_buffer) ) then X command := ' ' X ELSE X command := input_buffer`5Bi`5D; X i := i + 1; X X valid_com := true; X IF ( command in `5B'1'..'9'`5D ) then X IF not ( gun_working`5Bord(command)-ord('0')`5D ) or X ( gun_shot`5Bord(command)-ord('0')`5D = 2 ) then X valid_com := false; X UNTIL ( valid_com ); X X IF upper_case(command) = 'W' then X refresh_screen; XEND; X X XPROCEDURE Create_aliens; XVAR X but_not_for_long : integer; X super : integer; X nu : integer; X n : integer; XBEGIN X nu := ( score div 50 ) + 1; X IF ( nu > max_aliens ) then X nu := max_aliens; X IF ( nu > 0 ) then X BEGIN X n := 1; X WHILE ( n < nu ) and ( alien_alive`5Bn`5D ) do X n := n + 1; X IF not ( alien_alive`5Bn`5D ) then X BEGIN X super := random(4); X IF ( super = 1 ) then X BEGIN X alien_alive`5Bn`5D := true; X reset_randomizer; X REPEAT X but_not_for_long := randomize(9); X UNTIL ( gun_working`5Bbut_not_for_long`5D ); X CASE but_not_for_long of X 1 : x_alien`5Bn`5D := 24; X 2 : x_alien`5Bn`5D := 28; X 3 : x_alien`5Bn`5D := 32; X 4 : x_alien`5Bn`5D := 36; X 5 : x_alien`5Bn`5D := 40; X 6 : x_alien`5Bn`5D := 4; X 7 : x_alien`5Bn`5D := 8; X 8 : x_alien`5Bn`5D := 12; X 9 : x_alien`5Bn`5D := 16; X END; X IF ( but_not_for_long > 5 ) then X d_alien`5Bn`5D := 1 X ELSE X d_alien`5Bn`5D := -1; X y_alien`5Bn`5D := 1; X alien_type`5Bn`5D := '$'; X END X ELSE X BEGIN X alien_alive`5Bn`5D := true; X d_alien`5Bn`5D := random(2); X IF ( d_alien`5Bn`5D <> 1 ) then X d_alien`5Bn`5D := -1; X x_alien`5Bn`5D := random (30)+5; X y_alien`5Bn`5D := 1; X alien_type`5Bn`5D := '#'; X END; X posn (x_alien`5Bn`5D,Y_alien`5Bn`5D); X qio_write (alien_type`5Bn`5D); X END; X END; XEND; X X XPROCEDURE Create_shot; XBEGIN X penality := penality + 1; X new (this_shot); X this_shot`5E.next := head_shot; X IF ( head_shot <> nil ) then X head_shot`5E.prev := this_shot; X this_shot`5E.prev := nil; X head_shot := this_shot; X WITH this_shot`5E do X BEGIN X x_posn := (4*(ord(command)-ord('0'))); X y_posn := 20; X END; X gun_shot`5Bord(command)-ord('0')`5D := gun_shot`5Bord(command)-ord('0')`5D V + 1; XEND; X X XPROCEDURE Delete_shot; XVAR X temp : pointer; XBEGIN X gun_shot`5Bthis_shot`5E.x_posn div 4`5D := X gun_shot`5Bthis_shot`5E.x_posn div 4`5D - 1; X IF ( this_shot`5E.prev <> nil ) then X this_shot`5E.prev`5E.next := this_shot`5E.next X ELSE X head_shot := this_shot`5E.next; X IF ( this_shot`5E.next <> nil ) then X this_shot`5E.next`5E.prev := this_shot`5E.prev; X temp := this_shot`5E.next; X dispose (this_shot); X this_shot := temp; X shot_deleted := true; XEND; X X XPROCEDURE Boom ( n : integer ); XVAR X i : integer; XBEGIN X posn (x_alien`5Bn`5D-2,y_alien`5Bn`5D-2); X qio_write ('. . '); X posn (x_alien`5Bn`5D-2,y_alien`5Bn`5D-1); X qio_write (' . .'); X posn (x_alien`5Bn`5D-2,y_alien`5Bn`5D); X qio_write (' . '); X posn (x_alien`5Bn`5D-2,y_alien`5Bn`5D+1); X qio_write (' . '); X posn (x_alien`5Bn`5D-2,y_alien`5Bn`5D+2); X IF ( y_alien`5Bn`5D+2 < 21 ) then X qio_write ('. . '); X FOR i := -2 to 1 do X BEGIN X posn (x_alien`5Bn`5D-2,y_alien`5Bn`5D+i); X qio_write (' '); X END; X posn (x_alien`5Bn`5D-2,y_alien`5Bn`5D+2); X IF ( y_alien`5Bn`5D+2 < 21 ) then X qio_write (' '); X X`7B fix one gun `7D X X reset_randomizer; X REPEAT X i := randomize(9); X UNTIL ( i = 0 ) or_else ( not gun_working`5Bi`5D ); X X IF ( i > 0 ) then X BEGIN X gun_working`5Bi`5D := true; X posn (i*4,21); X qio_write ('`5E'); X END; XEND; X X XPROCEDURE Move; XVAR X n : integer; X out : v_array; XBEGIN X IF ( command in `5B'1'..'9'`5D ) then X create_shot; X X`7B delete shots `7D X out := ''; X this_shot := head_shot; X WHILE ( this_shot <> nil ) do X BEGIN X out := out + get_posn (this_shot`5E.x_posn,this_shot`5E.y_posn) + ' '; X this_shot := this_shot`5E.next; X END; X qio_write (out); X X`7B replace shots `7D X out := ''; X this_shot := head_shot; X WHILE ( this_shot <> nil ) do X BEGIN X this_shot`5E.y_posn := this_shot`5E.y_posn - 1; X IF ( this_shot`5E.y_posn <= 1 ) then X delete_shot X ELSE X BEGIN X shot_deleted := false; X FOR n := 1 to max_aliens do X IF ( this_shot <> nil ) then X IF ( x_alien`5Bn`5D = this_shot`5E.x_posn ) and X ( y_alien`5Bn`5D = this_shot`5E.y_posn ) then X BEGIN X alien_alive`5Bn`5D := false; X delete_shot; X score := score + y_alien`5Bn`5D div 2; X boom (n); X END; X END; X X IF not shot_deleted then X BEGIN X this_shot`5E.y_posn := this_shot`5E.y_posn - 1; X IF ( this_shot`5E.y_posn <= 1 ) then X delete_shot X ELSE X BEGIN X shot_deleted := false; X FOR n := 1 to max_aliens do X IF ( this_shot <> nil ) then X IF ( x_alien`5Bn`5D = this_shot`5E.x_posn ) and X ( y_alien`5Bn`5D = this_shot`5E.y_posn ) then X BEGIN X alien_alive`5Bn`5D := false; X delete_shot; X score := score + y_alien`5Bn`5D div 2; X boom (n); X END; X IF not shot_deleted then X BEGIN X out := get_posn (this_shot`5E.x_posn,this_shot`5E.y_posn) V + '`7C' + out; X this_shot := this_shot`5E.next; X END; X END; X END; X END; X qio_write (out); XEND; X X XPROCEDURE Move_aliens; XVAR X nu : integer; X out: v_array; XBEGIN X FOR nu := 1 to max_aliens do X IF ( alien_alive`5Bnu`5D ) then X BEGIN X out := get_posn (x_alien`5Bnu`5D,y_alien`5Bnu`5D) + ' '; X y_alien`5Bnu`5D := y_alien`5Bnu`5D + 1; X IF ( x_alien`5Bnu`5D = 2 ) then X d_alien`5Bnu`5D := 1; X IF ( x_alien`5Bnu`5D = 39 ) then X d_alien`5Bnu`5D := -1; X x_alien`5Bnu`5D := x_alien`5Bnu`5D + d_alien`5Bnu`5D; X X shot_deleted := false; X this_shot := head_shot; X WHILE ( this_shot <> nil ) and not ( shot_deleted ) do X BEGIN X IF ( x_alien`5Bnu`5D = this_shot`5E.x_posn ) and X ( y_alien`5Bnu`5D = this_shot`5E.y_posn ) then X BEGIN X alien_alive`5Bnu`5D := false; X delete_shot; X score := score + y_alien`5Bnu`5D div 2; X qio_write (out); X boom (nu); X END; X IF not shot_deleted then X this_shot := this_shot`5E.next; X END; X X IF not shot_deleted then X IF ( y_alien`5Bnu`5D = 21 ) then X BEGIN X alien_alive`5Bnu`5D := false; X qio_write ( out ); X IF ( x_alien`5Bnu`5D mod 4 = 0 ) then X BEGIN X gun_working`5Bx_alien`5Bnu`5D div 4`5D := false; X qio_write ( get_posn (x_alien`5Bnu`5D,21) + '*' ); X END; X END X ELSE X qio_write ( out + get_posn (x_alien`5Bnu`5D,y_alien`5Bnu`5D) + a Vlien_type`5Bnu`5D ); X END; XEND; X X XFUNCTION Person_killed : boolean; XVAR X i : integer; X temp : boolean := true; XBEGIN X for i := 1 to 9 do X if gun_working`5Bi`5D then X temp := false; X person_killed := temp; XEND; X X XPROCEDURE Show_score; XBEGIN X score := score - ( penality div 10 ); X penality := penality mod 10; X IF score < 1 then`20 X score := 1; X posn (23,24); X qio_write (dec(score)+' '); XEND; X X XBEGIN X Initialize; X start_screen; X setup; X REPEAT X sleep_start (20); X show_score; X get_command; X move; X create_aliens; X move_aliens; X posn (1,1); +-+-+-+-+-+-+-+- END OF PART 1 +-+-+-+-+-+-+-+-