Prev: A3DB Up: Map Next: A4E7
A3FE: Collect Bottle
Used by the routine at TestGroupObjects.
Handles the player collecting a bottle, if the flag at BottleFlag is set. The score is increased, the bottle is shown as an empty cup, and the number of bottles left is decreased. If there are none left then the exit is opened.
CollectBottle A3FE LD A,($DEFC) Fetch the flag from BottleFlag.
A401 AND A Test it.
A402 RET Z Return if it is not set.
A403 XOR A Clear the flag...
A404 LD ($DEFC),A ...and store it.
A407 LD BC,$0200 Set the amount to add to the score.
A40A CALL AddScore Call AddScore to add it to the score.
A40D LD HL,$6000 Set the value of 6000.
A410 LD ($A59F),HL Store it in A59F, which sets the target of the first gauge.
A413 LD HL,$6808 Set the position of the picture.
A416 LD DE,$64BC Point DE at EmptyCupPicture.
A419 CALL DrawPicture Call DrawPicture to draw the picture.
A41C LD A,$04 Set the value 04...
A41E LD ($AB7D),A ...in AB7D.
A421 LD A,($B55C) Fetch the byte of the player entity at B55C.
A424 AND %11110000 Keep the upper four bits.
A426 OR %00000100 Add the value 04.
A428 LD ($B55C),A Store it again.
A42B LD A,($DEE0) Fetch the number of bottles left from BottlesLeft.
A42E DEC A Decrease it by one.
A42F LD ($DEE0),A Store it.
A432 JR NZ,CollectBottle_Count Jump to CollectBottle_Count if there are some left.
A434 LD ($E1B6),A Set the units digit of the count on the panel to zero.
A437 LD C,A Set C to zero, so that the player is not placed.
A438 CALL StartLevel_FindData Call 86FB to find the data of the level.
A43B CALL ShowExitMessage Call ShowExitMessage to show that the exit is open.
A43E JR CollectBottle_Print Jump to CollectBottle_Print.
CollectBottle_Count A440 LD B,A Copy the number of bottles left into B.
A441 XOR A Set A to zero.
CollectBottle_Convert A442 ADD A,$01 Add one.
A444 DAA Convert it to binary coded decimal.
A445 DJNZ CollectBottle_Convert Jump back until the number has been converted.
A447 LD B,A Keep the result in B.
A448 AND %00001111 Keep the units.
A44A LD ($E1B6),A Store it as the units digit of the count on the panel.
A44D LD A,B Fetch the result.
A44E RRA Move the tens digit...
A44F RRA ...down...
A450 RRA ...to the lower...
A451 RRA ...four bits.
A452 AND %00001111 Keep the tens.
A454 LD ($E1B5),A Store it as the tens digit of the count on the panel.
CollectBottle_Print A457 LD DE,$E1B1 Point DE at the text of the count on the panel.
A45A CALL PrintText Call PrintText to print it.
A45D RES 0,(IX+$01) Reset bit 0 of the type of the object in IX.
A461 SET 1,(IX+$01) Set bit 1 of the type of the object in IX.
A465 LD ($C13C),IX Store the address of the object at C13C.
A469 LD ($A495),IX Store the address of the object at A495 the operand of the instruction at A494.
A46D LD IY,$DEE1 Point IY at BottleStates.
A471 LD IX,($5CFE) Fetch the address of the level data from LevelHeaderAddress.
A475 LD B,(IX-$01) Fetch the number of entries in the list of the level.
CollectBottle_NextEntry A478 PUSH BC Save the count of entries.
A479 PUSH IX Save the address of the entry.
A47B CALL FindGroupObjects Call FindGroupObjects to find the objects in the group of the entry.
A47E LD A,B Fetch the number of objects.
A47F AND A Test it.
A480 JR Z,CollectBottle_NextGroup Jump to CollectBottle_NextGroup if there are no objects.
CollectBottle_NextObject A482 LD A,(IX+$01) Fetch the type of the next object.
A485 AND %10001111 Keep bit 7 and bits 0-3.
A487 CP $81 Jump to CollectBottle_Match if it is a bottle of type 01.
A489 JR Z,CollectBottle_Match
A48B CP $82 Jump to CollectBottle_Skip unless it is a bottle of type 02.
A48D JR NZ,CollectBottle_Skip
CollectBottle_Match A48F INC IY Move onto the saved state of the next bottle.
A491 PUSH IX Copy the address of the object into DE (using the stack).
A493 POP DE
A494 LD HL,$0000 Set HL to the address of the bottle that was collected.
A497 AND A Clear the carry flag.
A498 SBC HL,DE Compare the two addresses.
A49A JR NZ,CollectBottle_Skip Jump to CollectBottle_Skip if this is not the bottle that was collected.
A49C LD (IY-$01),$82 Set the saved state of the bottle to 82.
A4A0 POP IX Discard the address of the entry.
A4A2 POP BC Discard the count of entries.
A4A3 JR CollectBottle_Finish Jump to CollectBottle_Finish.
CollectBottle_Skip A4A5 INC IX Move onto the next object...
A4A7 INC IX ...which is three bytes...
A4A9 INC IX ...along.
A4AB DJNZ CollectBottle_NextObject Jump back until all of the objects have been looked at.
CollectBottle_NextGroup A4AD POP IX Restore the address of the entry.
A4AF INC IX Move onto the next entry...
A4B1 INC IX ...which is two bytes along.
A4B3 POP BC Restore the count of entries.
A4B4 DJNZ CollectBottle_NextEntry Jump back until all of the entries have been looked at.
CollectBottle_Finish A4B6 LD A,$01 A is 01.
A4B8 LD ($B1B2),A Store it in the byte at B1B2.
A4BB LD ($C653),A Store it in the byte at C653.
A4BE LD A,($5CF0) Fetch the value from DrawingFlags.
A4C1 AND %00000111 Use bits 0-2.
A4C3 LD ($C65D),A Store it in the byte at C65D.
A4C6 LD HL,$7F10 Set the value 7F10.
A4C9 LD ($B1B3),HL Store it at B1B3.
A4CC LD HL,$80A0 Set the value 80A0.
A4CF LD ($B1B5),HL Store it at B1B5.
A4D2 LD DE,$C646 Point DE at DrawOverlappedBlock.
A4D5 LD HL,$C13B Point HL at DrawChosenObject.
A4D8 CALL DrawLevelObjects_Start Call DrawLevelObjects_Start.
A4DB LD A,$08 A is 08.
A4DD LD ($C794),A Store it in the byte at C794.
A4E0 LD ($C7A6),A Store it in the byte at C7A6.
A4E3 CALL PlayBuzzSweep Call PlayBuzzSweep to play a sound.
A4E6 RET Return.
Prev: A3DB Up: Map Next: A4E7