Prev: 45802 Up: Map Next: 45963
45809: Show list of objects (window or menu) and handle selection if a menu
Used by the routines at 41748, 41924, 42257, 42638, 43494, 43636, 44337, 44635 and 45095.
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 45809) Points to full command text (e.g. "DROP WHICH OBJECT?", or "YOU ARE NOW CARRYING")
HL (entry via 45834) Points to "YOU ARE NOW CARRYING" text
IX Points to a character's inventory
Output
A Zero-based index of selected menu item
45809 CALL 62959 Store all registers on the stack
45812 CALL 47930 Play downward scale sound
45815 CALL 62987 Restore all registers from the stack
45818 LD A,105 Modify instruction at 45867 with 105, denoting window as a menu rather than information window...
45820 LD (45868),A ...
45823 PUSH BC Store BC (B = number of inventory slots)
45824 PUSH HL Store HL
45825 PUSH IX Store IX
45827 CALL 63388 Print command summary text at DE (e.g. "DROP THE ") in command summary window
45830 POP IX Restore IX
45832 POP HL Restore HL
45833 POP BC Restore BC
This entry point is used by the routine at 45802.
45834 LD C,0 Load C (object counter) with zero
45836 PUSH BC Store BC (B = number of inventory slots)
45837 PUSH IX Store IX (points to start of inventory)
45839 LD A,(IX+0) Load object from character's inventory (slot number C) into A
45842 OR A If nothing in this slot...
45843 JR Z,45850 ...then jump ahead to 45850
45845 INC C Increase count of objects in inventory
45846 INC IX Advance IX to next slot
45848 DJNZ 45839 Loop back to 45839 for next slot
45850 POP IX Restore IX (points to start of inventory)
45852 LD A,C Copy number of objects into A
45853 OR A If number of objects is zero...
45854 JP Z,45937 ...then jump ahead to 45937
45857 LD A,(49068) Load A with y-coordinate of top edge of window 4
45860 ADD A,C Add number of objects to this y-coordinate
45861 ADD A,3 Add an additional 3 to this total (menu window padding)
45863 LD (49069),A Set y-coordinate of bottom edge of window 4 to accommodate list of C objects
45866 PUSH HL Store HL (e.g. pointer to "DROP WHICH OBJECT?" text)
The operand of the instruction at 45867 represents the draw-hand-menu-cursor flag. This is modified by the instructions at 45804 and 45820.
45867 LD A,0 Load A with menu / static window value
45869 CP 105 If this is not 105 (i.e. window is not a menu, but a simple information window)...
45871 JR NZ,45880 ...then skip ahead to 45880
45873 LD A,4 Draw window 4 as a menu window...
45875 CALL 47185 ...
45878 JR 45885 ...and skip over "draw an information window" section
45880 LD A,4 Draw window 4 as an information window...
45882 CALL 47193 ...
45885 POP HL Restore HL (pointer to full command text)...
45886 PUSH IX Store IX (points to start of inventory)
45888 CALL 46902 Print text to screen
45891 POP IX Restore IX (points to start of inventory)
45893 POP BC Restore BC (B = number of remaining inventory slots)
45894 PUSH BC Store BC (B = number of remaining inventory slots)
45895 LD A,(IX+0) Load index of object in current inventory into A
45898 OR A If index is zero (i.e. inventory slot is empty)...
45899 JP Z,45927 ...then skip ahead to 45927
45902 LD B,A Copy index into B
45903 PUSH IX Store IX (pointer to start of inventory)
45905 LD HL,50753 Point HL to text printing instruction to move cursor to start of next character row within window, then right by two characters
45908 PUSH BC Store BC (B = index of an object)
45909 CALL 46902 Print text to screen (i.e. move text printing cursor right by two characters)
45912 POP BC Restore BC (B = index of an object)
45913 CALL 63332 Point HL at object B's name in table of object names...
45916 CALL 46902 ...and print to screen
45919 POP IX Restore IX (pointer to start of inventory)
45921 INC IX Advance IX to next inventory slot
45923 POP BC Restore BC (B = number of remaining inventory slots)
45924 DJNZ 45894 Repeat loop for next object in inventory, decreasing B (number of remaining inventory slots)
45926 PUSH BC Store BC (B = 0)
45927 POP BC Restore BC (B = number of remaining inventory slots
45928 LD A,(45868) If window is a menu, rather than information window...
45931 CP 105 ...
45933 CALL Z,47502 ...process keyboard / joystick input on a menu and load A with selected item index
45936 RET ...and return
45937 PUSH HL Store HL (pointer to "YOU ARE NOW CARRYING" text)
45938 LD A,(49068) Load A with y-coordinate of top edge of window 4
45941 ADD A,4 Add 4 to this y-coordinate
45943 LD (49069),A Set y-coordinate of bottom edge of window 4 to accommodate three rows of text
45946 LD A,4 Draw window 4...
45948 CALL 47193 ...
45951 POP HL Restore HL (pointer to "YOU ARE NOW CARRYING" text)
45952 CALL 46902 ...and print to screen
45955 LD HL,56565 Point HL at "NOTHING AT ALL" text...
45958 CALL 46902 ...and print to screen
45961 POP BC Restore BC (number of inventory slots, PUSHed by instruction at 45836)
45962 RET Return
Prev: 45802 Up: Map Next: 45963