'===========================================================================
' Subject: ENIGMA CODING PROGRAM              Date: 07-10-96 (00:00)       
'  Author: Paul Kuliniewicz                   Code: QB, QBasic, PDS        
'  Origin: home.aol.com/Borg953             Packet: BINARY.ABC
'===========================================================================
' ***************************************************************************
' ***                       Enigma Coding Program                         ***
' ***************************************************************************
' written by Paul Kuliniewicz
' version 1.0
' WARNING!  ANY TAMPERING WITH THIS FILE MAY CAUSE IT TO MALFUNCTION AND
' DAMAGE ANY FILES YOU WORK WITH!  THE AUTHOR IS NOT RESPONSIBLE FOR DAMAGE
' CAUSED BY EDITING THIS FILE!
' This file is Public Domain.  You may distribute this file as you wish
' freely, as long as the file has not been altered in any way.
' Notice to Windows Users: only run this file in FULL SCREEN!  (this file
' writes and reads directly to and from screen memory.  Running in a window
' may cause unexpected, and possibly dangerous, results)
' *** Prepare for Operation Routine ***
DECLARE SUB CenterText (text$)
DECLARE SUB Shadow (urr%, urc%, llr%, llc%, lrr%, lrc%)
DECLARE SUB LoadImage (showme%())
DECLARE SUB SaveImage (saveme%())
DECLARE SUB StatusLine (message$, sector$)
DECLARE FUNCTION MessWithByte$ (original$)
DECLARE FUNCTION PseudoNOT$ (bit$)
DECLARE FUNCTION MakeBinary$ (convert%)
DECLARE FUNCTION MakeDecimal% (byte$)
DECLARE FUNCTION ConvBlock% (row%, column%, colormem%)
DECLARE FUNCTION ConvColor% (fore%, back%)
DECLARE FUNCTION Character$ ()
CLEAR
ON ERROR GOTO HandleError
KEY OFF
CLS
'$STATIC
DIM mainimage%(0 TO 4001)
DIM screenimage%(0 TO 4001)
DIM mainstatus$(1 TO 6)
DIM helpstatus$(1 TO 6)
FOR counter% = 1 TO 6
  READ mainstatus$(counter%)
NEXT counter%
FOR counter% = 1 TO 6
  READ helpstatus$(counter%)
NEXT counter%
CONST TRUE = -1
CONST FALSE = 0
firsttime% = FALSE
DEF SEG = &HB800
' *** Title Screen Display Routine ***
FOR counter% = ConvBlock%(1, 1, 1) TO ConvBlock%(24, 80, 1) STEP 2
  POKE counter%, ConvColor%(7, 1)
NEXT counter%
FOR counter% = ConvBlock%(25, 1, 1) TO ConvBlock%(25, 80, 1) STEP 2
  POKE counter%, ConvColor%(4, 7)
NEXT counter%
COLOR 7, 1
LOCATE 4, 1
CenterText "EEEEEE    CCCC    PPPPP "
CenterText "EEEEEE   CCCCCC   PPPPPP"
CenterText "EE       CC  CC   PP  PP"
CenterText "EE       CC       PP  PP"
CenterText "EEEEE    CC       PPPPPP"
CenterText "EEEEE    CC       PPPPP "
CenterText "EE       CC       PP    "
CenterText "EE       CC  CC   PP    "
CenterText "EEEEEE   CCCCCC   PP    "
CenterText "EEEEEE    CCCC    PP    "
PRINT
PRINT
CenterText "Enigma Coding Program v1.0"
PRINT
CenterText "1995 Paul Kuliniewicz"
StatusLine "Welcome to the Enigma Coding Program!  Press any key to continue.", "WELCOME"
SLEEP: trash$ = INKEY$
GOTO MainMenu
' *** Main Menu Routine ***
MainMenu:
IF firsttime% = FALSE THEN
  LOCATE 1, 1
  COLOR 4, 7
  PRINT "ÚÄÄÄÄÄMAIN MENUÄÄÄÄÄ¿"
  PRINT "³  1. Code a file   ³"
  PRINT "³  2. Decode a file ³"
  PRINT "³  3. Kill a file   ³"
  PRINT "³  4. Shell to DOS  ³"
  PRINT "³  5. Help          ³"
  PRINT "³  6. Leave ECP     ³"
  PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 2, 22, 9, 2, 9, 22
  SaveImage mainimage%()
  firsttime% = TRUE
ELSE
  LoadImage mainimage%()
END IF
min% = 2
max% = 7
oldarrow% = 2
newarrow% = 2
choice% = 1
entered% = FALSE
DO
  POKE ConvBlock%(oldarrow%, 3, 0), ASC(" ")
  POKE ConvBlock%(newarrow%, 3, 0), ASC("¯")
  StatusLine mainstatus$(choice%), "MENU"
  pressed$ = Character$
  oldarrow% = newarrow%
  IF LEN(pressed$) = 2 AND RIGHT$(pressed$, 1) = CHR$(72) THEN
    IF choice% = 1 THEN
      newarrow% = max%
      choice% = 6
    ELSE
      newarrow% = newarrow% - 1
      choice% = choice% - 1
    END IF
  ELSEIF LEN(pressed$) = 2 AND RIGHT$(pressed$, 1) = CHR$(80) THEN
    IF choice% = 6 THEN
      newarrow% = min%
      choice% = 1
    ELSE
      newarrow% = newarrow% + 1
      choice% = choice% + 1
    END IF
  ELSEIF pressed$ = CHR$(13) THEN
    entered% = TRUE
  END IF
LOOP UNTIL entered% = TRUE
ON choice% GOTO Code, Decode, Delete, DOS, Help, Quit
' *** Coding Routine ***
Code:
COLOR 4, 7
LOCATE 3, 3: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄCODEÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
LOCATE 4, 3: PRINT "³ Enter the file (and path, if needed) you wish to code. ³"
LOCATE 5, 3: PRINT "³ >                                                      ³"
LOCATE 6, 3: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 4, 61, 7, 4, 7, 61
SaveImage screenimage%()
StatusLine "Type in the file name to code.", "CODE"
LOCATE 5, 6
LINE INPUT "", filename$
LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄCODEÄÄÄÄÄÄÄÄÄÄÄÄ¿"
LOCATE 6, 5: PRINT "³ Coding file.  Please wait. ³"
LOCATE 7, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 6, 35, 8, 6, 8, 35
Tinker:
StatusLine "Please wait.  Accessing Disk.", "CODE"
info$ = SPACE$(10000)
OPEN filename$ FOR BINARY AS #1
IF LOF(1) = 0 THEN
  CLOSE #1
  KILL filename$
  ERROR 53
END IF
trash$ = MessWithByte$("NEW")
length& = LOF(1)
FOR counter& = 1 TO length& - (length& MOD 10000) STEP 10000
  GET #1, counter&, info$
  FOR count% = 1 TO LEN(info$)
    MID$(info$, count%, 1) = MessWithByte$(MID$(info$, count%, 1))
  NEXT count%
  PUT #1, counter&, info$
NEXT counter&
info$ = SPACE$(length& MOD 10000)
GET #1, (length& - (length& MOD 10000)) + 1, info$
FOR count% = 1 TO LEN(info$)
  MID$(info$, count%, 1) = MessWithByte$(MID$(info$, count%, 1))
NEXT count%
PUT #1, (length& - (length& MOD 10000)) + 1, info$
CLOSE #1
IF choice% = 2 THEN GOTO AllDone
LoadImage screenimage%()
LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄCODEÄÄÄÄÄÄÄ¿"
LOCATE 6, 5: PRINT "³ Coding finished. ³"
LOCATE 7, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 6, 25, 8, 6, 8, 25
StatusLine "Press any key to continue.", "CODE"
SLEEP: trash$ = INKEY$
GOTO MainMenu
' *** Decoding Routine ***
Decode:
COLOR 4, 7
LOCATE 3, 3: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄDECODEÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
LOCATE 4, 3: PRINT "³ Enter the file (and path, if needed) you wish to decode. ³"
LOCATE 5, 3: PRINT "³ >                                                        ³"
LOCATE 6, 3: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 4, 63, 7, 4, 7, 63
SaveImage screenimage%()
StatusLine "Type in the file name to decode.", "DECODE"
LOCATE 5, 6
LINE INPUT "", filename$
LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄDECODEÄÄÄÄÄÄÄÄÄÄÄÄ¿"
LOCATE 6, 5: PRINT "³ Decoding file.  Please wait. ³"
LOCATE 7, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 6, 37, 8, 6, 8, 37
StatusLine "Please wait.  Accessing disk.", "DECODE"
GOTO Tinker
info$ = SPACE$(10000)
OPEN filename$ FOR BINARY AS #1
IF LOF(1) = 0 THEN
  CLOSE #1
  KILL filename$
  ERROR 53
END IF
trash$ = MessWithByte$("NEW")
length& = LOF(1)
FOR counter& = 1 TO length% - (length& MOD 10000) STEP 10000
  GET #1, counter&, info$
  FOR count% = 1 TO LEN(info$)
    MID$(info$, count%, 1) = MessWithByte$(MID$(info$, count%, 1))
  NEXT count%
  PUT #1, counter&, info$
NEXT counter&
info$ = SPACE$(length& MOD 10000)
GET #1, (length& - (length& MOD 10000)) + 1, info$
FOR count% = 1 TO LEN(info$)
  MID$(info$, count%, 1) = MessWithByte$(MID$(info$, count%, 1))
NEXT count%
PUT #1, (length& - (length& MOD 10000)) + 1, info$
CLOSE #1
AllDone:
LoadImage screenimage%()
LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄDECODEÄÄÄÄÄÄÄ¿"
LOCATE 6, 5: PRINT "³ Decoding finished. ³"
LOCATE 7, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 6, 27, 8, 6, 8, 27
StatusLine "Press any key to continue.", "DECODE"
SLEEP: trash$ = INKEY$
GOTO MainMenu
' *** Killing Routine ***
Delete:
COLOR 4, 7
LOCATE 3, 3: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄKILLÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
LOCATE 4, 3: PRINT "³ Enter the file (and path, if needed) you wish to kill. ³"
LOCATE 5, 3: PRINT "³ >                                                      ³"
LOCATE 6, 3: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 4, 61, 7, 4, 7, 61
SaveImage screenimage%()
StatusLine "Type in the file to kill.", "KILL"
LOCATE 5, 6
LINE INPUT "", filename$
LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄDANGERÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
LOCATE 6, 5: PRINT "³ KILLING A FILE WILL TOTALLY DESTROY IT BEYOND ALL HOPE OF ³"
LOCATE 7, 5: PRINT "³ REPAIR!  NOT EVEN AN UNDELETE PROGRAM CAN SAVE IT!  ARE   ³"
LOCATE 8, 5: PRINT "³ YOU SURE YOU WANT TO DO THIS?  (Y/N)                      ³"
LOCATE 9, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 6, 66, 10, 6, 10, 66
StatusLine "Press Y for YES or N for NO.", "KILL"
DO
  rusure$ = UCASE$(Character$)
LOOP UNTIL rusure$ = "Y" OR rusure$ = "N"
IF rusure$ = "N" THEN GOTO MainMenu
LoadImage screenimage%()
LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄWARNINGÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
LOCATE 6, 5: PRINT "³ THERE IS NO WAY TO RECOVER THIS FILE IF YOU KILL  ³"
LOCATE 7, 5: PRINT "³ IT.  ARE YOU ABSOLUTELY SURE YOU WANT TO DO THIS? ³"
LOCATE 8, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 6, 58, 9, 6, 9, 58
StatusLine "Press Y for YES or N for NO.", "KILL"
DO
  rusure$ = UCASE$(Character$)
LOOP UNTIL rusure$ = "Y" OR rusure$ = "N"
IF rusure$ = "N" THEN GOTO MainMenu
LoadImage screenimage%()
LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄKILLÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
LOCATE 6, 5: PRINT "³ Killing file.  Please wait. ³"
LOCATE 7, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 6, 36, 8, 6, 8, 36
StatusLine "Please wait.  Accessing disk.", "KILL"
info$ = STRING$(10000, 0)
OPEN filename$ FOR BINARY AS #1
IF LOF(1) = 0 THEN
  CLOSE #1
  KILL filename$
  ERROR 53
END IF
length& = LOF(1)
FOR counter& = 1 TO length& - (length% MOD 10000) STEP 10000
  PUT #1, counter&, info$
NEXT counter&
info$ = SPACE$(length& MOD 10000)
PUT #1, (length& - (length& MOD 10000)) + 1, info$
CLOSE #1
KILL filename$
LoadImage screenimage%()
LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄKILLÄÄÄÄÄÄÄÄ¿"
LOCATE 6, 5: PRINT "³ Killing finished. ³"
LOCATE 7, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 6, 26, 8, 6, 8, 26
StatusLine "Press any key to continue.", "KILL"
SLEEP: trash$ = INKEY$
GOTO MainMenu
' *** DOS Shell Routine ***
DOS:
COLOR 4, 7
LOCATE 3, 3: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄSHELLÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
LOCATE 4, 3: PRINT "³ Initiating DOS Shell.  Type EXIT to  ³"
LOCATE 5, 3: PRINT "³ return to the Enigma Coding Program. ³"
LOCATE 6, 3: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 4, 43, 7, 4, 7, 43
StatusLine "Press any key to shell to DOS.", "SHELL"
SLEEP: trash$ = INKEY$
COLOR 7, 0
CLS
SHELL
COLOR 4, 7
GOTO MainMenu
' *** Help Routine ***
Help:
LoadImage mainimage%()
COLOR 4, 7
LOCATE 3, 3: PRINT "ÚÄÄÄÄÄHELP MENUÄÄÄÄÄ¿"
LOCATE 4, 3: PRINT "³  1. Overview      ³"
LOCATE 5, 3: PRINT "³  2. Coding files  ³"
LOCATE 6, 3: PRINT "³  3. Killing files ³"
LOCATE 7, 3: PRINT "³  4. Shell to DOS  ³"
LOCATE 8, 3: PRINT "³  5. Disclaimer    ³"
LOCATE 9, 3: PRINT "³  6. Exit Help     ³"
LOCATE 10, 3: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 4, 24, 11, 4, 11, 24
min% = 4
max% = 9
oldarrow% = 4
newarrow% = 4
helped% = 1
entered% = FALSE
DO
  POKE ConvBlock%(oldarrow%, 5, 0), ASC(" ")
  POKE ConvBlock%(newarrow%, 5, 0), ASC("¯")
  StatusLine helpstatus$(helped%), "HELP"
  pressed$ = Character$
  oldarrow% = newarrow%
  IF LEN(pressed$) = 2 AND RIGHT$(pressed$, 1) = CHR$(72) THEN
    IF helped% = 1 THEN
      newarrow% = max%
      helped% = 6
    ELSE
      newarrow% = newarrow% - 1
      helped% = helped% - 1
    END IF
  ELSEIF LEN(pressed$) = 2 AND RIGHT$(pressed$, 1) = CHR$(80) THEN
    IF helped% = 6 THEN
      newarrow% = min%
      helped% = 1
    ELSE
      newarrow% = newarrow% + 1
      helped% = helped% + 1
    END IF
  ELSEIF pressed$ = CHR$(13) THEN
    entered% = TRUE
  END IF
LOOP UNTIL entered% = TRUE
SELECT CASE helped%
CASE 1
  LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄOVERVIEWÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 6, 5: PRINT "³ The Enigma Coding Program is a useful file safety device ³"
  LOCATE 7, 5: PRINT "³ for coding, decoding, and killing files.  This program   ³"
  LOCATE 8, 5: PRINT "³ can code files in a way that only it can decode.  Also,  ³"
  LOCATE 9, 5: PRINT "³ to completely destroy files, you can kill them.  All     ³"
  LOCATE 10, 5: PRINT "³ this comes with an easy-to-use, window-based interface.  ³"
  LOCATE 11, 5: PRINT "³ The other options in the Help Menu will give you details ³"
  LOCATE 12, 5: PRINT "³ about these particular operations.  Please read the dis- ³"
  LOCATE 13, 5: PRINT "³ claimer before using this program.                       ³"
  LOCATE 14, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 6, 65, 15, 6, 15, 65
CASE 2
  LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄCODINGÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 6, 5: PRINT "³ The Enigma Coding Program can code files so other people ³"
  LOCATE 7, 5: PRINT "³ can't use them.  This process works with any file, whe-  ³"
  LOCATE 8, 5: PRINT "³ ther it's an *.EXE, *.BAT, *.WMF, *.INI, etc.  To code a ³"
  LOCATE 9, 5: PRINT "³ file, choose Code a File from the Main Menu and follow   ³"
  LOCATE 10, 5: PRINT "³ the simple instructions.  To decode a file, choose De-   ³"
  LOCATE 11, 5: PRINT "³ code a File from the Main Menu and follow the similar    ³"
  LOCATE 12, 5: PRINT "³ instructions.                                            ³"
  LOCATE 13, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 6, 65, 14, 6, 14, 65
CASE 3
  LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄKILLINGÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 6, 5: PRINT "³ The Enigma Coding Program can wipe out files.  This is   ³"
  LOCATE 7, 5: PRINT "³ not the same as erasing!  When you kill a file, all the  ³"
  LOCATE 8, 5: PRINT "³ bytes in the file are assigned the null (0) value before ³"
  LOCATE 9, 5: PRINT "³ being deleted.  Even an undelete program will only bring ³"
  LOCATE 10, 5: PRINT "³ back a bunch of null characters.  To kill a file, choose ³"
  LOCATE 11, 5: PRINT "³ Kill a File from the Main Menu and follow the simple     ³"
  LOCATE 12, 5: PRINT "³ instructions.                                            ³"
  LOCATE 13, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 6, 65, 14, 6, 14, 65
CASE 4
  LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄSHELLINGÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 6, 5: PRINT "³ The Enigma Coding Program allows you to temporarily use  ³"
  LOCATE 7, 5: PRINT "³ DOS while the program is running.  While in the shell,   ³"
  LOCATE 8, 5: PRINT "³ you can execute any commands you normally can.  When you ³"
  LOCATE 9, 5: PRINT "³ are finished, type EXIT to end the shell.  To execute    ³"
  LOCATE 10, 5: PRINT "³ the shell, choose Shell to DOS from the Main Menu.       ³"
  LOCATE 11, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 6, 65, 12, 6, 12, 65
CASE 5
  LOCATE 5, 5: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄDISCLAIMERÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 6, 5: PRINT "³ DO NOT TAMPER WITH OR EDIT THIS FILE IN ANY WAY!  DOING  ³"
  LOCATE 7, 5: PRINT "³ SO MAY CAUSE THIS PROGRAM TO MALFUNCTION AND DAMAGE ANY  ³"
  LOCATE 8, 5: PRINT "³ AND ALL FILES YOU WORK WITH!  THE AUTHOR IS NOT RESPON-  ³"
  LOCATE 9, 5: PRINT "³ SIBLE FOR ANY DAMAGE DUE TO ANY EDITING!  YOU ARE FREE   ³"
  LOCATE 10, 5: PRINT "³ TO COPY AND DISTRIBUTE THIS PROGRAM TO ANYONE YOU WISH,  ³"
  LOCATE 11, 5: PRINT "³ AS LONG AS THE FILE IS UNALTERED IN ANY CONCEIVABLE WAY! ³"
  LOCATE 12, 5: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 6, 65, 13, 6, 13, 65
END SELECT
IF helped% = 6 THEN GOTO MainMenu
StatusLine "Press any key to return to the Help Menu.", "HELP"
SLEEP: trash$ = INKEY$
GOTO Help
' *** Exit Program Routine ***
Quit:
COLOR 4, 7
LOCATE 3, 3: PRINT "ÚÄÄÄÄÄÄÄBYEÄÄÄÄÄÄÄÄ¿"
LOCATE 4, 3: PRINT "³ Have a nice day! ³"
LOCATE 5, 3: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
Shadow 4, 23, 6, 4, 6, 23
StatusLine "Press any key to exit ECP.", "BYE"
SLEEP: trash$ = INKEY$
SYSTEM
' *** Error Handler Routine ***
HandleError:
COLOR 4, 7
RESET
SELECT CASE ERR
CASE 52
  RESUME MainMenu
CASE 53
  LOCATE 7, 7: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄERRORÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 8, 7: PRINT "³ That file could not be found on the ³"
  LOCATE 9, 7: PRINT "³ indicated drive and directory.      ³"
  LOCATE 10, 7: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 8, 46, 11, 8, 11, 46
CASE 61
  LOCATE 7, 7: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄERRORÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 8, 7: PRINT "³ There is not enough free space on that drive. ³"
  LOCATE 9, 7: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 8, 56, 10, 8, 10, 56
CASE 64
  LOCATE 7, 7: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄERRORÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 8, 7: PRINT "³ That file name contains invalid DOS characters. ³"
  LOCATE 9, 7: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 8, 58, 10, 8, 10, 58
CASE 70
  LOCATE 7, 7: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄERRORÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 8, 7: PRINT "³ That disk is write-protected. ³"
  LOCATE 9, 7: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 8, 40, 10, 8, 10, 40
CASE 71
  LOCATE 7, 7: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄERRORÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 8, 7: PRINT "³ That disk drive is open or there is no disk inside. ³"
  LOCATE 9, 7: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 8, 62, 10, 8, 10, 62
CASE 72
  LOCATE 7, 7: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄERRORÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 8, 7: PRINT "³ That disk's surface is physically flawed. ³"
  LOCATE 9, 7: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 8, 52, 10, 8, 10, 52
CASE 75
  LOCATE 7, 7: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄERRORÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 8, 7: PRINT "³ You can't code, decode, or kill a path. ³"
  LOCATE 9, 7: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 8, 50, 10, 8, 10, 50
CASE 76
  LOCATE 7, 7: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄERRORÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 8, 7: PRINT "³ That path can't be found on this drive. ³"
  LOCATE 9, 7: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 8, 50, 10, 8, 10, 50
CASE ELSE
  LOCATE 7, 7: PRINT "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄERRORÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"
  LOCATE 8, 7: PRINT "³ Unidentified error";
  PRINT USING " ### "; ERR;
  PRINT "reported!  Please contact the ³"
  LOCATE 9, 7: PRINT "³ author via e-mail at Borg953@aol.com.  Unfortunatly, ³"
  LOCATE 10, 7: PRINT "³ ECP cannot recover.                                  ³"
  LOCATE 11, 7: PRINT "ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"
  Shadow 8, 63, 12, 8, 12, 63
  StatusLine "Press any key to abort ECP.", "ERROR"
  SLEEP: trash$ = INKEY$
  SYSTEM
END SELECT
StatusLine "Press any key to return.", "ERROR"
SLEEP: trash$ = INKEY$
IF choice% >= 1 AND choice% <= 3 THEN LoadImage screenimage%()
SELECT CASE choice%
CASE 1
  RESUME Code
CASE 2
  RESUME Decode
CASE 3
  RESUME Delete
CASE ELSE
  RESUME MainMenu
END SELECT
' *** Data for Main Menu Status Line ***
DATA "Code a file with the ECP technique."
DATA "Decode a file coded with the ECP technique."
DATA "Totally destroy a file."
DATA "Use DOS without exiting ECP."
DATA "Additional help with ECP."
DATA "Returns you to your operating system."
' *** Data for Help Menu Status Line ***
DATA "Read the overview of ECP."
DATA "Read about coding and decoding files."
DATA "Read about killing files."
DATA "Read about the DOS Shell."
DATA "Read very important warnings."
DATA "Return to the Main Menu."
' *** End of file "ECP.BAS" ***

SUB CenterText (text$)
  blanks% = INT((80 - LEN(text$)) / 2)
  PRINT TAB(blanks%); text$
END SUB

FUNCTION Character$
  DO
    justpushed$ = INKEY$
  LOOP UNTIL justpushed$ <> CHR$(0)
  Character$ = justpushed$
END FUNCTION

FUNCTION ConvBlock% (row%, column%, colormem%)
  ConvBlock% = (((column% * 2) - 2) + ((row% * 160) - 160)) + colormem%
END FUNCTION

FUNCTION ConvColor% (fore%, back%)
  ConvColor% = fore% + (back% * 16)
END FUNCTION

SUB LoadImage (showme%())
  FOR counter% = 0 TO 4001
    POKE counter%, showme%(counter%)
  NEXT counter%
END SUB

FUNCTION MakeBinary$ (convert%)
  equiv$ = HEX$(convert%)
  IF convert% <= 15 THEN equiv$ = "0" + equiv$
  FOR counter% = 1 TO LEN(equiv$)
    onepart$ = MID$(equiv$, counter%, 1)
    IF onepart$ = "0" THEN
      result$ = result$ + "0000"
    ELSEIF onepart$ = "1" THEN
      result$ = result$ + "0001"
    ELSEIF onepart$ = "2" THEN
      result$ = result$ + "0010"
    ELSEIF onepart$ = "3" THEN
      result$ = result$ + "0011"
    ELSEIF onepart$ = "4" THEN
      result$ = result$ + "0100"
    ELSEIF onepart$ = "5" THEN
      result$ = result$ + "0101"
    ELSEIF onepart$ = "6" THEN
      result$ = result$ + "0110"
    ELSEIF onepart$ = "7" THEN
      result$ = result$ + "0111"
    ELSEIF onepart$ = "8" THEN
      result$ = result$ + "1000"
    ELSEIF onepart$ = "9" THEN
      result$ = result$ + "1001"
    ELSEIF onepart$ = "A" THEN
      result$ = result$ + "1010"
    ELSEIF onepart$ = "B" THEN
      result$ = result$ + "1011"
    ELSEIF onepart$ = "C" THEN
      result$ = result$ + "1100"
    ELSEIF onepart$ = "D" THEN
      result$ = result$ + "1101"
    ELSEIF onepart$ = "E" THEN
      result$ = result$ + "1110"
    ELSEIF onepart$ = "F" THEN
      result$ = result$ + "1111"
    END IF
  NEXT counter%
  MakeBinary$ = result$
END FUNCTION

FUNCTION MakeDecimal% (byte$)
  result% = 0
  IF LEFT$(byte$, 1) = "1" THEN result% = result% + 128
  IF MID$(byte$, 2, 1) = "1" THEN result% = result% + 64
  IF MID$(byte$, 3, 1) = "1" THEN result% = result% + 32
  IF MID$(byte$, 4, 1) = "1" THEN result% = result% + 16
  IF MID$(byte$, 5, 1) = "1" THEN result% = result% + 8
  IF MID$(byte$, 6, 1) = "1" THEN result% = result% + 4
  IF MID$(byte$, 7, 1) = "1" THEN result% = result% + 2
  IF RIGHT$(byte$, 1) = "1" THEN result% = result% + 1
  MakeDecimal% = result%
END FUNCTION

FUNCTION MessWithByte$ (original$)
  STATIC style%
  IF original$ = "NEW" THEN
    style% = 0
    EXIT FUNCTION
  END IF
  style% = style% + 1
  IF style% > 20 THEN style% = 1
  decimal% = ASC(original$)
  base2$ = MakeBinary$(decimal%)
  bit1$ = LEFT$(base2$, 1)
  bit2$ = MID$(base2$, 2, 1)
  bit3$ = MID$(base2$, 3, 1)
  bit4$ = MID$(base2$, 4, 1)
  bit5$ = MID$(base2$, 5, 1)
  bit6$ = MID$(base2$, 6, 1)
  bit7$ = MID$(base2$, 7, 1)
  bit8$ = RIGHT$(base2$, 1)
  SELECT CASE style%
      CASE 1
        bit1$ = PseudoNOT$(bit1$)
        bit4$ = PseudoNOT$(bit4$)
        bit6$ = PseudoNOT$(bit6$)
        bit7$ = PseudoNOT$(bit7$)
      CASE 2
        bit2$ = PseudoNOT$(bit2$)
        bit3$ = PseudoNOT$(bit3$)
        bit5$ = PseudoNOT$(bit5$)
        bit8$ = PseudoNOT$(bit8$)
      CASE 3
        SWAP bit1$, bit2$
        SWAP bit3$, bit4$
        SWAP bit5$, bit6$
        SWAP bit7$, bit8$
      CASE 4
        SWAP bit1$, bit8$
        SWAP bit2$, bit7$
        SWAP bit4$, bit5$
      CASE 5
        bit1$ = PseudoNOT$(bit1$)
        bit2$ = PseudoNOT$(bit2$)
        bit3$ = PseudoNOT$(bit3$)
        bit4$ = PseudoNOT$(bit4$)
        SWAP bit5$, bit8$
        SWAP bit6$, bit7$
      CASE 6
      CASE 7
        bit1$ = PseudoNOT$(bit1$)
        SWAP bit2$, bit3$
        bit4$ = PseudoNOT$(bit4$)
        bit5$ = PseudoNOT$(bit5$)
        SWAP bit6$, bit7$
        bit8$ = PseudoNOT$(bit8$)
      CASE 8
        SWAP bit1$, bit3$
        SWAP bit2$, bit4$
      CASE 9
        bit1$ = PseudoNOT$(bit1$)
        bit2$ = PseudoNOT$(bit2$)
        bit3$ = PseudoNOT$(bit3$)
        bit4$ = PseudoNOT$(bit4$)
        bit5$ = PseudoNOT$(bit5$)
        bit6$ = PseudoNOT$(bit6$)
        bit7$ = PseudoNOT$(bit7$)
        bit8$ = PseudoNOT$(bit8$)
      CASE 10
        SWAP bit1$, bit5$
        SWAP bit2$, bit6$
        SWAP bit3$, bit7$
        SWAP bit4$, bit8$
      CASE 11
        bit1$ = PseudoNOT$(bit1$)
        SWAP bit2$, bit3$
        bit4$ = PseudoNOT$(bit4$)
        bit5$ = PseudoNOT$(bit5$)
        SWAP bit6$, bit8$
        bit7$ = PseudoNOT$(bit7$)
      CASE 12
        SWAP bit1$, bit3$
        SWAP bit2$, bit6$
        bit4$ = PseudoNOT$(bit4$)
        SWAP bit5$, bit8$
        bit7$ = PseudoNOT$(bit7$)
      CASE 13
        SWAP bit1$, bit6$
        bit2$ = PseudoNOT$(bit2$)
        SWAP bit3$, bit8$
        bit4$ = PseudoNOT$(bit4$)
        bit5$ = PseudoNOT$(bit5$)
        bit7$ = PseudoNOT$(bit7$)
      CASE 14
        SWAP bit2$, bit7$
        SWAP bit4$, bit5$
      CASE 15
        bit1$ = PseudoNOT$(bit1$)
        SWAP bit2$, bit4$
        bit3$ = PseudoNOT$(bit3$)
        bit7$ = PseudoNOT$(bit7$)
        bit8$ = PseudoNOT$(bit8$)
      CASE 16
        SWAP bit1$, bit6$
        SWAP bit2$, bit7$
        SWAP bit3$, bit8$
        SWAP bit4$, bit5$
      CASE 17
        bit1$ = PseudoNOT$(bit1$)
        SWAP bit2$, bit4$
        bit3$ = PseudoNOT$(bit3$)
        bit5$ = PseudoNOT$(bit5$)
        SWAP bit6$, bit8$
        bit7$ = PseudoNOT$(bit7$)
      CASE 18
        SWAP bit1$, bit2$
        bit3$ = PseudoNOT$(bit3$)
        SWAP bit4$, bit8$
        SWAP bit5$, bit7$
        bit6$ = PseudoNOT$(bit6$)
      CASE 19
        SWAP bit1$, bit5$
        bit2$ = PseudoNOT$(bit2$)
        bit3$ = PseudoNOT$(bit3$)
        SWAP bit4$, bit6$
        bit7$ = PseudoNOT$(bit7$)
        bit8$ = PseudoNOT$(bit8$)
      CASE 20
        SWAP bit1$, bit8$
        bit2$ = PseudoNOT$(bit2$)
        bit3$ = PseudoNOT$(bit3$)
        bit4$ = PseudoNOT$(bit4$)
        bit5$ = PseudoNOT$(bit5$)
        bit6$ = PseudoNOT$(bit6$)
        bit7$ = PseudoNOT$(bit7$)
      END SELECT
  base2$ = bit1$ + bit2$ + bit3$ + bit4$ + bit5$ + bit6$ + bit7$ + bit8$
  decimal% = MakeDecimal%(base2$)
  MessWithByte$ = CHR$(decimal%)
END FUNCTION

FUNCTION PseudoNOT$ (bit$)
  IF bit$ = "1" THEN
    PseudoNOT$ = "0"
  ELSE
    PseudoNOT$ = "1"
  END IF
END FUNCTION

SUB SaveImage (saveme%())
  FOR counter% = 0 TO 4001
    saveme%(counter%) = PEEK(counter%)
  NEXT counter%
END SUB

SUB Shadow (urr%, urc%, llr%, llc%, lrr%, lrc%)
  FOR counter% = ConvBlock%(urr%, urc%, 1) TO ConvBlock%(lrr%, lrc%, 1) STEP 160
    POKE counter%, ConvColor%(8, 0)
  NEXT counter%
  FOR counter% = ConvBlock%(llr%, llc%, 1) TO ConvBlock%(lrr%, lrc%, 1) STEP 2
    POKE counter%, ConvColor%(8, 0)
  NEXT counter%
END SUB

SUB StatusLine (message$, sector$)
  display$ = SPACE$(72)
  area$ = SPACE$(7)
  LSET display$ = message$
  RSET area$ = sector$
  total$ = display$ + "³" + area$
  FOR counter% = 1 TO 80
    POKE ConvBlock%(25, counter%, 1), ConvColor%(7, 4)
  NEXT counter%
  FOR counter% = 1 TO 80
    POKE ConvBlock%(25, counter%, 0), ASC(MID$(total$, counter%, 1))
  NEXT counter%
END SUB
