Prev: 52695 Up: Map Next: 52913
52849: Maroc is trading items with a warlock
Used by the routine at 52695.
Maroc successfully trading an item with a warlock
52849 LD A,(60334) Object number (if any) from table at 29551 that has been offered to the warlock
52852 LD D,A Temp store in D register
52853 CP 0
52855 JR Z,52948 If nothing has been offered, jump out to next routine handling warlock missiles
Maroc has offered an object to the warlock in a trade for the warlock's item.
  • If the item is of sufficient value (if bits 5-7 of the item's value byte >= warlock number) the warlock will accept the trade
  • Otherwise it will fire a missile at Maroc
  • Higher value items are needed to successfully trade with more powerful warlocks
Alternatively Maroc can destroy the warlock to obtain its held object, if he has a powerful enough spell.
52857 LD A,(60230) Warlock number (1-7) - table at 27772
52860 LD C,A Temp store in C register
52861 LD A,(60335) Single byte containing both the object's attribute/colour and its 'value'
52864 RRA The trade-based value of this object is stored in bits 5-7
52865 RRA
52866 RRA
52867 RRA ...now shifted to bits 0-2
52868 AND 7 Keep a value between 0-7
52870 CP C Compare against warlock number. If it's greater, it's accepted as a trade for their carried object/spell
52871 JR C,52913 Carry here means the item value isn't high enough, so it's not accepted
Item accepted by warlock - traded for carried item:
52873 LD A,(60328) Number of item held by warlock (from table at 29551)
52876 LD (60334),A
52879 LD A,D Retrieve the object number (from table at 29551) that Maroc has offered
52880 LD (60328),A ...and store in the warlock's working data buffer
52883 LD HL,(60228) Address pointer to warlock data set in table at 27772
52886 INC HL
52887 INC HL
52888 INC HL
52889 LD (HL),A ...and store this object number as the warlock's held object
52890 LD A,(60238) Get the warlock's properties byte
52893 AND %00001111 Filter out/clear bits 4-7
52895 OR %01000101 Set bit 6 (warlock ready for materialization routine) and bits 0 & 2 (item is visible and moving)
52897 LD (60238),A ...and restore properties byte
52900 LD A,1 Graphics frame offset (1 = no offset)
52902 LD (60240),A
52905 LD A,91 Graphics address for materialization graphics at 39031
52907 CALL 57538 Set up graphics
52910 JP 53885
Prev: 52695 Up: Map Next: 52913