Decoded: Rogue (1980) by Toy, Arnold, Wichman
DOS version (1983) by Mel Sibony and Jon Lane
Source file: ARMOR.C
Beginner friendly, line-by-line code walkthrough by MaiZure

ARMOR.C is holds functions used in armor item management

Original code:
https://britzl.github.io/roguearchive/

Original code with line numbers
http://www.maizure.org/projects/decoded-rogue/ARMOR_linenum.txt




1     COMMENT
2     COMMENT
3     COMMENT
4     COMMENT
5     COMMENT
6     BLANK
7     Includes main game header file
8     Includes console management header
9     BLANK
10    COMMENT
11    COMMENT
12    COMMENT
13    COMMENT
14    Declares and defines wear with no arguments

WEAR ARMOR

15    BLOCK START - wear, puts on armor if possible
16    Declares a pointer to the armor object to be worn
17    Declares a string pointer for the armor name
18    BLANK
19    If the player is already wear armor...
20    Send a failure message to the player
21    Continue the failure message to the player
22    No valid command issued, don't process turn
23    End function -- returns to command listening
24    End check for if player is already wearing armor
25    If the player chose to wear non-existent armor
26    Then there's nothing to do, return
27    If the player chose to wear non-armor
28    Print a failure message
29    Return to command listener
30    End check for non-armor type
31    If we made it this far, then we're successful - pass time
32    Set the armor to a known type (reveals armor type)
33    Get the name of the armor
34    Set the armor to worn
35    Print a successful message to the player
36    BLOCK END - wear
37    BLANK
38    COMMENT
39    COMMENT
40    COMMENT
41    COMMENT
42    Declares and defines take_off with no arguments

TAKE OFF ARMOR

43    BLOCK START - take_off, take off worn armor, if possible
44    Declares a pointer to an object (used for current armor worn)
45    BLANK
46    If the player isn't wearing armor...
47    Don't process time passing
48    Send a failure message to the player
49    Return from function
50    Otherwise, the player is weaing armor
51    If the armor can't be taken off (eg, cursed)...
52    Return failure
53    Otherwise, the armor can be removed, so do it
54    Print success message and return the armor to inventory
55    BLOCK END - take_off
56    BLANK
57    COMMENT
58    COMMENT
59    COMMENT
60    COMMENT
61    Declares and defiens waste_time with no arguments
62    BLOCK START - waste_time, processes timers and background daemons
63    Force daemon processing
64    Force timer processing
65    BLOCK END - waste_time
66    EOF