Decoded: Rogue (1980) by Toy, Arnold, Wichman DOS version (1983) by Mel Sibony and Jon Lane Source file: STRINGS.C Beginner friendly, line-by-line code walkthrough by MaiZure STRINGS.C provides common string handling functions used throughout Rogue. Original code: https://britzl.github.io/roguearchive/ Original code with line numbers http://www.maizure.org/projects/decoded-rogue/STRINGS_linenum.txt 1 BLANK 2 BLANK 3 Bring in a character array from elsewhere (Aztec C provided...not in Rogue) 4 BLANK 5 Returns true if input is a letter. Masks AzC char table first two bits 6 Returns true if input is upper case. Masks AzC char table first bit 7 Returns true if input is lower case. Masks AzC char table second bit 8 Returns true if input is a digit. Masks AzC char table third bit 9 Returns true if input is a space. Masks AzC char table fifth bit 10 Returns true if input is printable. Masks AzC char table (5 of 8 bits) 11 BLANK CONVERT TO PRINTABLE ASCII 12 Defines toascii with one argument - an integer, technically 13 BLOCK START - toascii 14 Return the bottom 7 bits of the input 15 BLOCK END - toascii, converts input byte to a printable ASCII character 16 BLANK TO UPPER CASE 17 Defines toupper with one argument 18 Argument 1 is a character 19 BLOCK START - toupper, converts input from lower to upper case 20 Returns upper case by subtracting the difference between upper and lower cases. I guess this was before we realized we can just set bit 5 to 0 :) 21 BLOCK END - toupper 22 BLANK TO LOWER CASE 23 Defines tolower with one argument 24 Argument 1 is an input character 25 BLOCK START - tolower, converts input from upper to lower case 26 Returns lower case by adding the difference between cases (if it is upper) 27 BLOCK END - tolower 28 BLANK COPY STRINGS 29 Defines stccpy with three arguments 30 Arguments 1 and 2 are the destination and source strings 31 Argument 3 is the length of the string 32 BLOCK START - stccpy, copies strings 33 While there is still work to do... 34 Copy the strings 35 Null-terminate the string 36 COMMENT 37 COMMENT 38 COMMENT 39 COMMENT 40 Return a pointer to the *END* of the string...interesting...in 1984 41 BLOCK END - stccpy 42 BLANK 43 BLANK 44 COMMENT 45 COMMENT 46 COMMENT SKIPS SPACES 47 stpblk returns a char pointer 48 Define stpblk with one argument 49 Argument 1 is a string (designed to be reentrant, could be in the middle ) 50 BLOCK START - stpblk, skips blanks from a string 51 While there is a space in the string 52 Advance the pointer 53 Return the string pointer 54 BLOCK END - stpblk 55 BLANK SKIP CERTAIN CHARACTERS 56 Defines stpbrk with two arguments 57 Both arguments are pointers to a string and a char to be skipped 58 BLOCK START - stpbrk, skips characters in a string 59 While the desired character is at the pointer.. 60 Skip it! 61 If the string is still valid reutnr it, otherwise null pointer 62 BLOCK END - stpbrk 63 BLANK 64 BLANK 65 COMMENT 66 COMMENT 67 COMMENT REMOVE TRAILING WHITE SPACE 68 Defines endblk with one argument 69 Argument 1 is a string 70 BLOCK START - endblk, nullterms the input string without a break/space 71 Declare a local pointer to a character 72 BLANK 73 Find the last character based on length 74 While there are useless characters at this point 75 Replace all characters with zero 76 Return the patched up string pointer 77 BLOCK END - endblk 78 BLANK 79 COMMENT 80 COMMENT 81 COMMENT CONVERT STRING TO LOWER CASE 82 Defines lcase with one agument 83 Argument 1 is an input string 84 BLOCK START - lcase, converts a string to lower case 85 While there is an upper case letter under the string, convert.. 86 ..and advance the pointer 87 BLOCK END - lcase 88 EOF˙