Prev: AA27 Up: Map Next: AA94
AA37: Build Carried Item Graphic
Used by the routines at RunFrame and BeginLife.
Builds the graphic of the item that is carried by the ship in the buffer at ShipWorkArea_Carried (six bytes to a row) and clears the part of the screen beside the ship where the item will be drawn. Each byte of the sprite of the item is looked up in the shift table at CopyGameDown and combined with the buffer using XOR.
BuildCarriedItemGraphic AA37 LD HL,$AF7B The sprite tables.
AA3A LD A,($C904) The item the ship is about to pick up.
AA3D AND %00001111 Keep the bits of A that are set in 0F.
AA3F LD C,A C=A.
AA40 CALL GetTableEntry Call GetTableEntry.
AA43 EX DE,HL Swap DE and HL.
AA44 LD A,(DE) Read DE.
AA45 LD B,A B=A.
AA46 LD ($5C1F),A The width of the carried item.
AA49 INC DE Advance DE.
AA4A LD A,(DE) Read DE.
AA4B LD ($5C20),A Update the segments still to draw.
AA4E LD C,A C=A.
AA4F LD HL,$F6BA The carried picture in the ship work area.
BuildCarriedItemGraphic_Row AA52 PUSH HL Stash HL on the stack.
BuildCarriedItemGraphic_Column AA53 PUSH BC Stash BC on the stack.
AA54 LD B,$FC B=FC.
AA56 INC DE Advance DE.
AA57 LD A,(DE) Read DE.
AA58 LD C,A C=A.
AA59 LD A,(BC) Read BC.
AA5A XOR (HL) Flip the bits of A that are set in the byte at HL.
AA5B LD (HL),A Write A where HL points.
AA5C INC B Advance B.
AA5D INC HL Advance HL.
AA5E LD A,(BC) Read BC.
AA5F XOR (HL) Flip the bits of A that are set in the byte at HL.
AA60 LD (HL),A Write A where HL points.
AA61 POP BC Bring BC back off the stack.
AA62 DJNZ BuildCarriedItemGraphic_Column Decrease B and jump to BuildCarriedItemGraphic_Column until none remain.
AA64 POP HL Bring HL back off the stack.
AA65 LD A,($5C1F) The width of the carried item.
AA68 LD B,A B=A.
AA69 LD A,$06 A=06.
AA6B CALL AddAToHL Call AddAToHL.
AA6E DEC C Step C back.
AA6F JR NZ,BuildCarriedItemGraphic_Row Jump to BuildCarriedItemGraphic_Row if the zero flag is clear.
AA71 LD HL,($C902) Fetch the word at C902 into HL.
AA74 CALL GetScreenAddress Call GetScreenAddress.
AA77 LD A,($5C20) The segments still to draw.
AA7A LD B,A B=A.
AA7B INC L Advance L.
BuildCarriedItemGraphic_Clear AA7C LD (HL),$00 Store 00 at the address in HL.
AA7E INC L Advance L.
AA7F LD (HL),$00 Store 00 at the address in HL.
AA81 INC L Advance L.
AA82 LD (HL),$00 Store 00 at the address in HL.
AA84 INC L Advance L.
AA85 LD (HL),$00 Store 00 at the address in HL.
AA87 DEC L Step L back.
AA88 DEC L Step L back.
AA89 DEC L Step L back.
AA8A CALL MoveUpARow Call MoveUpARow.
AA8D DJNZ BuildCarriedItemGraphic_Clear Decrease B and jump to BuildCarriedItemGraphic_Clear until none remain.
AA8F LD A,($5C3C) The scroll-in flag.
AA92 AND A Return if A is not zero.
AA93 RET NZ
Continue on to AttachItemToShip.
Prev: AA27 Up: Map Next: AA94