Page 1 of 1

Commodore 64 Hiding BASIC Code technique ..

Posted: Sat Apr 02, 2016 4:46 pm
by Colin Appleby
This is how the program Madam FiFi Whore House hides the Basic listing. Very cleaver indeed.

Here is a little gem that you may find interesting. Did you ever wish that you could `hide' parts of a program, while leaving it all in BASIC and copyable ? Well here is a simple and effective way to do just that!

Simply load your program into memory, and place five colons (:::::) in front of every statement that you wish to hide, after the line number and before the BASIC line itself. Then just key in the following statements and exe-cute them via a `goto.' List the program and you will see that your secret code has vanished! To make the lines reappear, just ` goto' the line number you assigned to the second half of the statements below.

Try this little trick on the small program below just to see it work, it's fun and only costs you a little more space for the five colons and the extra statements.

10 rem "simple program"
20 print"this line will not be protected"
30 print"this line will not be protected either" 40 :::::print"but this line will. . . ." 50 :::::print"and this one too......
55 stop: rem "assume that this is the logical end of the program
60 rem "the coding from 60000-60020 will make the lines vanish
70 rem "the coding from 60030-60050 will make the lines reappear
60000 :::::fori = 1024 to 15000
60010 :::::ifpeek(i) = 58andpeek(i + 2) = thenpokei,0:i = i + 5
60020 :::::next:stop
60030 :::::fori = 1024 to 15000
60040 :::::ifpeek(i) = Oandpeek(i + 1) = 58andpeek(i + 2) = 58thenpokei,58:i = 1 + 5 60050 :::::next:stop

NOTE . . . the value of 15000 in lines 60000 and 60030 just needs to be any value large enough so that it is larger than the number of bytes of your code to ensure that the search for the five colons continues through your entire program.

Thanks for this great programming technique from the guys at commodore.ca

Regards

Colin

Re: Commodore 64 Hiding BASIC Code technique ..

Posted: Tue Apr 05, 2016 1:58 pm
by Gunness
That's funny :) I used to remember a few of these tricks to stop people listing the program. There's another one, PRINT SHIFT+L or something along those lines, which breaks off LIST when it reaches the line with the command.
I wonder whether the five colon trick is intentional or a side effect of some weird BASIC bug :D

Re: Commodore 64 Hiding BASIC Code technique ..

Posted: Tue Apr 05, 2016 2:23 pm
by dave
Gunness wrote:That's funny :) I used to remember a few of these tricks to stop people listing the program. There's another one, PRINT SHIFT+L or something along those lines, which breaks off LIST when it reaches the line with the command.
I wonder whether the five colon trick is intentional or a side effect of some weird BASIC bug :D
The code at 60000 is basically converting the colons to NULs. I think the colons are used as they're basically no operations in BASIC.

On the BBC the trick was to embedded VDU codes to change the mode or to disable the screen in REM statements.

Re: Commodore 64 Hiding BASIC Code technique ..

Posted: Tue Apr 05, 2016 8:36 pm
by Colin Appleby
Has anyone got a FULL listing of the original Madam FIFI program in any format, possibly for the Commodore 64.
This is what I have managed to extract from the code but without line numbers or program logic:
PRINT "ASS PRESENTS "
PRINT "MADAM FIFI "
PRINT "HAVE FUN! HEHEHE... "
PRINT "MADAM FIFI'S WHORE-HOUSE ÁDVENTURE"
PRINT "DO YOU NEED THE INSTRUCTIONS"
PRINT "FRONT ROOM,WAITING ROOM,BATHROOM,OFFICE,BALCONY,ALLEY,BAR BRICK FIREPLACE,HIDDEN CORRIDOR,SECRET PASSAGE,TURKISH BATH CHAMBER ! RAFT,MASSAGE ROOM STOREROOM,LOFT,SAUNA,FIFI'S APARTMENT,SITTING ROOM,S&M CHAMBER"
PRINT "MONEY" ­
PRINT "NORTH,SOUTH,EAST,WEST,UP,DOWN,SLEDGEHAMMER,WATCH,LEATHER WHIP"
PRINT "DIRTY MAGAZINE,3,SWITCHBLADE,4,OAR,6,KEY,99,BEER,7,BODY OIL"
13,SUITCASE,14,BUCKET,14,TORCH,8,NAILS,15,CURTAIN,16,RAFT,11,RUSTY GATE,17,BEDROOM DOOR
18,FIRE IN THE FIREPLACE,2,TOILET,3,SIGN,1,RAILING,5,BRICK FIREPLACE
2,RAT,19,WINE,2,CHEDDAR CHEESE,2
PRINT " ,,3,2,,,,,1,,,,,,4,1,,,,,5,3,,,,,,4,,,,7,,,5,,6,,,,4,,,2,,,,,13,,,,3,11,8,,19,,,,10,,,,,,11,,,,,14,9,,,,,,13,,,2,,,,,,,16,,,,,,,,16 ú ,,,,,17,,,,,,,10,13,, 9 "
PRINT "YOU ARE IN THE "
PRINT "ÉT'S ÄARK! YOU CAN'T SEE"
PRINT "YOU SEE "
PRINT "NOTHING INTERESTING."
PRINT "OBVIOUS EXITS ARE: "
PRINT "--------------------------------------"
PRINT "THAT DO YOU WANT TO DO";
PRINT "QUIT"
PRINT "IT'S MIDNIGHT! THE WHORE-HOUSE IS CLOSED"
PRINT "AND THE PIMP THROWS YOU OUT!"
PRINT "YOU HAVE BEEN SCALDED TO DEATH IN THE HOT"
PRINT "TURKISH BATHS! "
PRINT "YOU ARE CARRYING: "
PRINT "NOTHING"
GOTO 320,490,680,810,870,950,1040,1100,1150,1210,1240 ,
PRINT "I DON'T KNOW HOW TO DO THAT"
PRINT "I DON'T KNOW THAT WORD"
PRINT "YOU CAN'T GO THAT WAY"
PRINT "YOU SEE NOTHING SPECIAL"
PRINT "YOU HAVE BURNED TO DEATH! "
PRINT "CLIMBED DOWN ×HIP"
PRINT "YOU FELL AND DIED "
PRINT "YOU CAN'T GO THERE"
PRINT "SUITCASE"
PRINT "IT'S A LITTLE TOO HIGH"
PRINT "YOU CAN'T CARRY ANY MORE"
PRINT "YOU CAN'T DO THAT"
PRINT "IT'S NAILED TO THE LOFT"
PRINT "AHA! - A HOLE IN THE WALL"
PRINT "YOU HAVE NO HAMMER"
PRINT "THE CURTAIN IS LOOSE"
PRINT "THE RAT HAS IT"
PRINT "YOU CAN'T GET IT"
PRINT "I DON'T SEE ANY "
PRINT "YOU GOT THE "
PRINT "THE WHORE-HOUSE CLOSES AT MIDNIGHT'"
PRINT "A KEY IS IN IT'S MOUTH!"
PRINT "YOU DON'T HAVE IT"
PRINT "THE DIRTY mAGAZINE READS:
PRINT "NOT ALL EXITS ARE OBVIOUS."
PRINT "SMOLDERING ASHES"
PRINT "OKAY, THE "O$(S)" IS ON THE "D$(L)" FLOOR"
PRINT "BROKEN FIREPLACE"
PRINT "NOTHING HAPPENED"
PRINT "THE BEDROOM DOOR IS LOCKED ... "
PRINT "FIFI IN HER BED"
PRINT "TOO MUCH RUST ... "
PRINT "OPEN GATE"
PRINT "WHIP TIED TO THE RAILING"
PRINT "AHA! - YOU HAVE REVEALED A DOORWAY"V$²"WITH"
PRINT "YOU FAILED! FIFI LEAVES AND"
PRINT "YOU LOSE YOUR HARD-ON! "
PRINT "CONGRATULATIONS!"
PRINT "YOU JUST GOT SCREWED BY FIFI!!"
PRINT "THE GATE SQUEAKS OPEN"
PRINT "OPEN GATE"
PRINT "YOU HAVE ROWED TO THE "
PRINT "WOULD YOU LIKE TO TRY AGAIN"
PRINT "WHAT"
PRINT "WHORE-HOUSE HAS A CONCEALED GOAL."
PRINT "YOU LEARN WHAT THE GOAL IS"
PRINT "BY EXPLORING YOUR SURROUNDINGS."
PRINT "THE COMPUTER WILL ACT AS YOUR EYES"
PRINT "AND HANDS.IT WILL ACCEPT SHORT"
PRINT "PHRASES AS COMMANDS AND ASSUMES"
PRINT "THAT THE FIRST WORD IS A VERB AND"
PRINT "THE LAST WORD IS THE OBJECT."
PRINT "FOR EXAMPLE: READ THE SIGN."
PRINT "THE COMPUTER HAS A VOCABULARY OF ABOUT"
PRINT "WORDS. SOME OF THE MORE IMPORTANT"
PRINT "WORDS YOU SHOULD KNOW BEFORE"
PRINT "YOU START PLAYING ARE: get <OBJECT>,"
PRINT "DROP <OBJECT>, LOOK <OBJECT>"
PRINT "OR JUST LOOK, GO <DIRECTION> OR <PLACE>"
PRINT "AND INVENTORY TELLS WHAT"
PRINT "YOU ARE CARRYING). THE COMPUTER"
PRINT "KNOWS THE ABBREVIATIONS: E, W, N,"
PRINT "S, U AND D FOR GO EAST, GO WEST, ETC."
PRINT "PRESS <RETURN>";
PRINT "THE COMPUTER'S VOCABULARY IS GOOD,"
PRINT "BUT LIMITED. IF YOU ARE HAVING" “
PRINT "TROUBLE DOING SOMETHING, TRY"
PRINT "RE-PHRASING THE COMMAND OR YOU MAY"
PRINT "NEED SOME OBJECT TO ACCOMPLISH"
PRINT "THE TASK." "
PRINT "--- GOOD LUCK! ---"

REGARDS
COLIN

Re: Commodore 64 Hiding BASIC Code technique ..

Posted: Tue Apr 05, 2016 9:47 pm
by Alex
Interesting post but there is a small error in the above code. To make the listing visible:
-load the program
-Enter the following 3 lines:
60030 :::::FOR I=1024 TO 15000
60040 :::::IFPEEK(I)=0ANDPEEK(I+1)=58AND PEEK(I+2)=58THEN POKE I,58:I=I+5
60050 :::::NEXT:STOP

(note the 2 essential differences in line 60040 compared to the lines above)
-start the program with GOTO 60030
-When it is finished (this will take some time), you can list the game.

Re: Commodore 64 Hiding BASIC Code technique ..

Posted: Wed Apr 06, 2016 11:36 pm
by dave
I ran it through the C64 BASIC detokeniser I wrote a good few years ago and it had some strange effects...

I may see whether I can fix this, or not...