Prev: 33945 Up: Map Next: 34122
33952: Show list of objects (window or menu) and handle selection if a menu
Used by the routines at 29488, 29619, 29756, 30145, 30968 and 31537.
Input
B Number of inventory slots to check
DE Points to summary command text (i.e. "DROP THE ", "GIVE THE ", "READ THE ", "WEAR THE " or "UNWEAR THE "), or 0 for no summary text
HL (entry via 33952) Points to full command text (e.g. "DROP WHICH OBJECT?", or "YOU ARE NOW CARRYING")
HL (entry via 33984) Points to "YOU ARE NOW CARRYING" text
IX Points to a character's inventory
Output
A Zero-based index of selected menu item
33952 CALL 54051 Store all registers on the stack
33955 CALL 35723 Play downward scale sound
33958 CALL 54079 Restore all registers from the stack
33961 LD A,(IX+0) Load first object in character's inventory into A
33964 OR A If nothing in first slot...
33965 JP Z,34087 ...jump ahead to 34087 (unused code block - see trivia)
33968 LD A,105 Modify instruction at 34017 with 105, denoting window as a menu rather than information window...
33970 LD (34018),A ...
33973 PUSH BC Store BC (B = number of inventory slots)
33974 PUSH HL Store HL
33975 PUSH IX Store IX
33977 CALL 54322 Print command summary text at DE (e.g. "DROP THE ") in command summary window
33980 POP IX Restore IX
33982 POP HL Restore HL
33983 POP BC Restore BC
This entry point is used by the routine at 33945.
33984 LD C,0 Load C (object counter) with zero
33986 PUSH BC Store BC (B = number of inventory slots)
33987 PUSH IX Store IX (points to start of inventory)
33989 LD A,(IX+0) Load object from character's inventory (slot number C) into A
33992 OR A If nothing in this slot...
33993 JR Z,34000 ...then jump ahead to 34000
33995 INC C Increase count of objects in inventory
33996 INC IX Advance IX to next slot
33998 DJNZ 33989 Loop back to 33989 for next slot
34000 POP IX Restore IX (points to start of inventory)
34002 LD A,C Copy number of objects into A
34003 OR A If number of objects is zero...
34004 JP Z,34096 ...then jump ahead to 34096
34007 LD A,(37123) Load A with y-coordinate of top edge of window 4
34010 ADD A,C Add number of objects to this y-coordinate
34011 ADD A,3 Add an additional 3 to this total (menu window padding)
34013 LD (37124),A Set y-coordinate of bottom edge of window 4 to accommodate list of C objects
34016 PUSH HL Store HL (e.g. pointer to "DROP WHICH OBJECT?" text)
The operand of the instruction at 34017 represents the draw-hand-menu-cursor flag. This is modified by the instructions at 33947 and 33970.
34017 LD A,0 Load A with menu / static window value
34019 CP 105 If this is not 105 (i.e. window is not a menu, but a simple information window)...
34021 JR NZ,34030 ...then skip ahead to 34030
34023 LD A,4 Draw window 4 as a menu window...
34025 CALL 34982 ...
34028 JR 34035 ...and skip over "draw an information window" section
34030 LD A,4 Draw window 4 as an information window...
34032 CALL 34990 ...
34035 POP HL Restore HL (pointer to full command text)...
34036 PUSH IX Store IX (points to start of inventory)
34038 CALL 34762 Print text to screen
34041 POP IX Restore IX (points to start of inventory)
34043 POP BC Restore BC (B = number of remaining inventory slots)
34044 PUSH BC Store BC (B = number of remaining inventory slots)
34045 LD A,(IX+0) Load index of object in current inventory into A
34048 OR A If index is zero (i.e. inventory slot is empty)...
34049 JP Z,34077 ...then skip ahead to 34077
34052 LD B,A Copy index into B
34053 PUSH IX Store IX (pointer to start of inventory)
34055 LD HL,38351 Point HL to text printing instruction to move cursor to start of next character row within window, then right by two characters
34058 PUSH BC Store BC (B = index of an object)
34059 CALL 34762 Print text to screen (i.e. move text printing cursor right by two characters)
34062 POP BC Restore BC (B = index of an object)
34063 CALL 54266 Point HL at object B's name in table of object names...
34066 CALL 34762 ...and print to screen
34069 POP IX Restore IX (pointer to start of inventory)
34071 INC IX Advance IX to next inventory slot
34073 POP BC Restore BC (B = number of remaining inventory slots)
34074 DJNZ 34044 Repeat loop for next object in inventory, decreasing B (number of remaining inventory slots)
34076 PUSH BC Store BC (B = 0)
34077 POP BC Restore BC (B = number of remaining inventory slots
34078 LD A,(34018) If window is a menu, rather than information window...
34081 CP 105 ...
34083 CALL Z,35296 ...process keyboard / joystick input on a menu and load A with selected item index
34086 RET ...and return
This jump point can never be reached, as a separate routine already checks for an empty inventory before code execution reaches this routine - see trivia
34087 LD A,13 Prepare to display window 13
34089 POP HL Remove return address from stack (as we are not returning)
34090 LD HL,44862 Point HL at "YOU HAVE DESTROYED YOURSELF BY DROPPING THE..." text
34093 JP 55364 Display window 13 with text at HL and return to game
34096 PUSH HL Store HL (pointer to "YOU ARE NOW CARRYING" text)
34097 LD A,(37123) Load A with y-coordinate of top edge of window 4
34100 ADD A,4 Add 4 to this y-coordinate
34102 LD (37124),A Set y-coordinate of bottom edge of window 4 to accommodate three rows of text
34105 LD A,4 Draw window 4...
34107 CALL 34990 ...
34110 POP HL Restore HL (pointer to "YOU ARE NOW CARRYING" text)
34111 CALL 34762 ...and print to screen
34114 LD HL,42373 Point HL at "NOTHING AT ALL" text...
34117 CALL 34762 ...and print to screen
34120 POP BC Restore BC (number of inventory slots, PUSHed by instruction at 33986)
34121 RET Return
Prev: 33945 Up: Map Next: 34122