Prev: E05F Up: Map Next: E0E8
E0A9: Release Bubble
Used by the routine at Handle_Static_Object.
Lets an object (the object of type 54 see Handle_Static_Object) release a bubble every now and then. The bubble takes one of the four bubble records that start at First_Bubble_Record, if one is free. A bubble is only made when the low byte of the frame counter plus the low byte of the address of the object has its low six bits clear.
The record is a copy of the record of the object, with the type 58 and an x position that is 0C more. The room is the room that Sabreman is in.
Input
IX Object record of the object that releases the bubble
Release_Bubble E0A9 LD HL,$8F5A Point HL at the first bubble record.
E0AC LD DE,$0010 Set DE to the size of an object record.
E0AF LD B,$04 Set a counter in B for the four bubble records.
Release_Bubble_Find_Record E0B1 LD A,(HL) Fetch the type of the record.
E0B2 AND A Jump to Release_Bubble_Create if the record is free.
E0B3 JR Z,Release_Bubble_Create
E0B5 ADD HL,DE Move on to the next record.
E0B6 DJNZ Release_Bubble_Find_Record Decrease the record counter and loop back for the next record.
E0B8 RET Return, as all four bubble records are in use.
Release_Bubble_Create E0B9 PUSH IX Point HL at the record of the object, and DE at the free record.
E0BB EX DE,HL Exchange DE and HL.
E0BC POP HL Restore HL from the stack.
E0BD LD A,($5C78) Fetch the low byte of the frame counter.
E0C0 ADD A,L Add the low byte of the address of the record of the object.
E0C1 AND %00111111 Keep only the low six bits.
E0C3 RET NZ Return unless they are zero.
E0C4 LD BC,$000F Set a counter of 0F bytes.
E0C7 PUSH DE Stash the address of the bubble record.
E0C8 LDIR Copy the record of the object to the bubble record, except for the redraw flags.
E0CA POP HL Restore the address of the bubble record to HL.
E0CB LD A,$58 Set the type to 58.
E0CD LD (HL),A
E0CE LD A,(IX+$01) Fetch the x position of the object.
E0D1 ADD A,$0C Add 0C.
E0D3 INC HL Move to the x position.
E0D4 LD (HL),A Set the x position.
E0D5 INC HL Move to the room x.
E0D6 LD A,($8F1C) Fetch the room x of Sabreman.
E0D9 LD (HL),A Set the room x.
E0DA INC HL Move to the room y.
E0DB INC HL
E0DC LD A,($8F1E) Fetch the room y of Sabreman.
E0DF LD (HL),A Set the room y.
E0E0 LD A,$01 A=01 (the value of the redraw flags).
E0E2 LD DE,$000B Set the offset to the redraw flags of the record (0B).
E0E5 ADD HL,DE Move to the redraw flags.
E0E6 LD (HL),A Set the redraw flags to 01 so that the bubble is drawn without being erased first.
E0E7 RET Return.
View the equivalent code in;
Prev: E05F Up: Map Next: E0E8