Decoded: Rogue (1980) by Toy, Arnold, Wichman DOS version (1983) by Mel Sibony and Jon Lane Source file: FAKEDOS.C Beginner friendly, line-by-line code walkthrough by MaiZure FAKEDOS.C gives you bad workers a way to have fun and avoid the man. Fake DOS shell! Original code: https://britzl.github.io/roguearchive/ Original code with line numbers http://www.maizure.org/projects/decoded-rogue/FAKEDOS_linenum.txt 1 COMMENT 2 COMMENT 3 COMMENT 4 BLANK 5 Include the game header 6 Include the console management header 7 BLANK 8 Declare a function pointer to the strip blank function (in STRINGS.C) 9 BLANK FAKE DOS PROMPT 10 Define fakedos with no arguments 11 BLOCK START - fakedos, imitates the DOS prompt (launch with ! key) 12 Declare a buffer to hold the command line input 13 Declare string pointers for the directory and the stripped input 14 BLANK 15 Save the game's current console output 16 Clear the screen 17 Move the cursor to the top left 18 Display the blinking cursor 19 Get the current drive letter and offset by 'A' (ex. C drive returns 0x02 but to display C, we have to add 0x40, 'A') 20 Loop while input doesn't match 'rogue' or bit 7 isn't asserted 21 Clear the command line 22 Print a prompt using the current drive letter 23 Get input from the user 24 Strip all spaces 25 Remove the end of line characters from input 26 Redo loop until the boss is gone (type 'rogue')! 27 Input the current drive letter to ensure proper drive is saved on exit 28 Disable the blinking cursor 29 Restore the game's console output 30 BLOCK END - fakedos 31 BLANK 32 COMMENT 33 COMMENT 34 COMMENT FAKE DOS INTERPRETER 35 Define dodos with one argument 36 Argument 1 is a string representing the user command line input 37 BLOCK START - dodos, process command line input 38 If the first byte is unprintable or the user typed 'rogue'... 39 Return false - this ends the fake DOS prompt and returns to the game 40 If the 2nd char is : and 3rd is NULL, assume we're changing drives so... 41 Subtract away the drive 'letter' to get the base number 42 BLANK 43 Print out a blank line 44 If the input isn't a letter or the drive doesn't exist... 45 Print out an error message 46 Otherwise if there was some user input... 47 Print ou good old BCOFN 48 Return true to keep the fake DOS alive 49 BLOCK END - dodos 50 EOF˙