![]() |
Routines |
| Prev: 57614 | Up: Map | Next: 57861 |
|
Used by the routine at LoadMapObjects.
Puts the objects of one column of the map in free slots of the map objects. An object is skipped if the current player has destroyed it (bit 7 of its byte in the table at MapTable is set, or bit 6 for player two), if it is not on one of the two rows that are on the screen or if there is already a slot for it. It is put in the first free slot of the first three slots, or in the fourth if none of them is free. Its column, row, position and kind are set from the tables. The slot holds the index of the object in offsets 24 and 25 so that the object can be marked as destroyed later.
|
||||||||||||||
| AddMapObjects | 57620 | AND A | Return if A is zero. | |||||||||||
| 57621 | RET Z | |||||||||||||
| AddMapObjects_Next2 | 57622 | PUSH BC | Stash BC on the stack. | |||||||||||
| 57623 | BIT 7,(HL) | Jump to AddMapObjects_Skip if bit 7 of the byte at the address in HL is set. | ||||||||||||
| 57625 | JP NZ,AddMapObjects_Skip | |||||||||||||
| 57628 | LD A,(IX+1) | Read offset 1 of IX. | ||||||||||||
| 57631 | AND %00011111 | Keep the bits of A that are set in 31. | ||||||||||||
| 57633 | LD E,A | E=A. | ||||||||||||
| 57634 | LD A,(52824) | The map row. | ||||||||||||
| 57637 | CP E | Jump to AddMapObjects_Search if A is E. | ||||||||||||
| 57638 | JR Z,AddMapObjects_Search | |||||||||||||
| 57640 | INC A | Advance A. | ||||||||||||
| 57641 | CP E | Jump to AddMapObjects_Skip if A is not E. | ||||||||||||
| 57642 | JP NZ,AddMapObjects_Skip | |||||||||||||
| AddMapObjects_Search | 57645 | LD IY,43019 | The map object slots. | |||||||||||
| 57649 | LD B,4 | B=4. | ||||||||||||
| AddMapObjects_Search2 | 57651 | LD A,(IY+0) | Read offset 0 of IY. | |||||||||||
| 57654 | INC A | Advance A. | ||||||||||||
| 57655 | JR Z,AddMapObjects_Next | Jump to AddMapObjects_Next if the zero flag is set. | ||||||||||||
| 57657 | LD A,(IY+1) | Read offset 1 of IY. | ||||||||||||
| 57660 | CP C | Jump to AddMapObjects_Next if A is not C. | ||||||||||||
| 57661 | JR NZ,AddMapObjects_Next | |||||||||||||
| 57663 | LD A,(IY+4) | Read offset 4 of IY. | ||||||||||||
| 57666 | CP E | Jump to AddMapObjects_Skip if A is E. | ||||||||||||
| 57667 | JP Z,AddMapObjects_Skip | |||||||||||||
| AddMapObjects_Next | 57670 | LD A,E | A=E. | |||||||||||
| 57671 | LD DE,26 | DE=26. | ||||||||||||
| 57674 | ADD IY,DE | IY gains DE. | ||||||||||||
| 57676 | LD E,A | E=A. | ||||||||||||
| 57677 | DJNZ AddMapObjects_Search2 | Decrease B and jump to AddMapObjects_Search2 until none remain. | ||||||||||||
| AddMapObjects_Free | 57679 | LD IY,43019 | The map object slots. | |||||||||||
| 57683 | LD B,3 | B=3. | ||||||||||||
| AddMapObjects_SearchSecond | 57685 | LD A,(IY+0) | Read offset 0 of IY. | |||||||||||
| 57688 | INC A | Advance A. | ||||||||||||
| 57689 | JR Z,AddMapObjects_Fill | Jump to AddMapObjects_Fill if the zero flag is set. | ||||||||||||
| 57691 | LD A,E | A=E. | ||||||||||||
| 57692 | LD DE,26 | DE=26. | ||||||||||||
| 57695 | ADD IY,DE | IY gains DE. | ||||||||||||
| 57697 | LD E,A | E=A. | ||||||||||||
| 57698 | DJNZ AddMapObjects_SearchSecond | Decrease B and jump to AddMapObjects_SearchSecond until none remain. | ||||||||||||
| AddMapObjects_Fill | 57700 | PUSH IX | Stash IX on the stack. | |||||||||||
| 57702 | PUSH IY | Stash IY on the stack. | ||||||||||||
| 57704 | POP IX | Bring IX back off the stack. | ||||||||||||
| 57706 | POP IY | Bring IY back off the stack. | ||||||||||||
| 57708 | CALL FreeObjectSlot | Call FreeObjectSlot. | ||||||||||||
| 57711 | PUSH IX | Stash IX on the stack. | ||||||||||||
| 57713 | PUSH IY | Stash IY on the stack. | ||||||||||||
| 57715 | POP IX | Bring IX back off the stack. | ||||||||||||
| 57717 | POP IY | Bring IY back off the stack. | ||||||||||||
| 57719 | LD (IY+4),E | Write E to offset 4 of IY. | ||||||||||||
| 57722 | LD (IY+0),13 | Store 13 at offset 0 of IY. | ||||||||||||
| 57726 | LD A,(HL) | Read HL. | ||||||||||||
| 57727 | AND %00111111 | Keep the bits of A that are set in 63. | ||||||||||||
| 57729 | LD (IY+19),A | Write A to offset 19 of IY. | ||||||||||||
| 57732 | PUSH HL | Stash HL on the stack. | ||||||||||||
| 57733 | LD HL,57861 | The object attributes. | ||||||||||||
| 57736 | CALL AddAToHL | Call AddAToHL. | ||||||||||||
| 57739 | LD A,(HL) | Read HL. | ||||||||||||
| 57740 | LD (IY+13),A | Write A to offset 13 of IY. | ||||||||||||
| 57743 | LD HL,57597 | The object kinds. | ||||||||||||
| 57746 | LD A,(IY+19) | Read offset 19 of IY. | ||||||||||||
| 57749 | CALL AddAToHL | Call AddAToHL. | ||||||||||||
| 57752 | LD A,(HL) | Read HL. | ||||||||||||
| 57753 | AND %11100000 | Keep the bits of A that are set in 224. | ||||||||||||
| 57755 | SRL A | Shift A right. | ||||||||||||
| 57757 | SRL A | Shift A right. | ||||||||||||
| 57759 | SRL A | Shift A right. | ||||||||||||
| 57761 | SRL A | Shift A right. | ||||||||||||
| 57763 | LD (IY+24),A | Write A to offset 24 of IY. | ||||||||||||
| 57766 | BIT 4,(HL) | Jump to AddMapObjects_Position if bit 4 of the byte at the address in HL is clear. | ||||||||||||
| 57768 | JR Z,AddMapObjects_Position | |||||||||||||
| 57770 | LD A,(HL) | Read HL. | ||||||||||||
| 57771 | AND %00001111 | Keep the bits of A that are set in 15. | ||||||||||||
| 57773 | LD HL,57614 | The special object states. | ||||||||||||
| 57776 | CALL AddAToHL | Call AddAToHL. | ||||||||||||
| 57779 | LD A,(HL) | Read HL. | ||||||||||||
| 57780 | LD (IY+19),A | Write A to offset 19 of IY. | ||||||||||||
| 57783 | INC HL | Advance HL. | ||||||||||||
| 57784 | LD A,(HL) | Read HL. | ||||||||||||
| 57785 | LD (IY+20),A | Write A to offset 20 of IY. | ||||||||||||
| 57788 | LD (IY+21),128 | Store 128 at offset 21 of IY. | ||||||||||||
| 57792 | LD (IY+0),27 | Store 27 at offset 0 of IY. | ||||||||||||
| AddMapObjects_Position | 57796 | POP HL | Bring HL back off the stack. | |||||||||||
| 57797 | LD DE,(52794) | Fetch the word at ScratchValues into DE. | ||||||||||||
| 57801 | LD A,D | A=D. | ||||||||||||
| 57802 | OR (IY+24) | Set the bits of A that are set in the byte at offset 24 of IY. | ||||||||||||
| 57805 | LD (IY+24),A | Write A to offset 24 of IY. | ||||||||||||
| 57808 | LD (IY+25),E | Write E to offset 25 of IY. | ||||||||||||
| 57811 | LD (IY+1),C | Write C to offset 1 of IY. | ||||||||||||
| 57814 | LD A,(IX+0) | Read offset 0 of IX. | ||||||||||||
| 57817 | AND %11111100 | Keep the bits of A that are set in 252. | ||||||||||||
| 57819 | DEC A | Step A back. | ||||||||||||
| 57820 | LD (IY+5),A | Write A to offset 5 of IY. | ||||||||||||
| 57823 | LD A,(IX+0) | Read offset 0 of IX. | ||||||||||||
| 57826 | AND %00000011 | Keep the bits of A that are set in 3. | ||||||||||||
| 57828 | ADD A,A | Double A. | ||||||||||||
| 57829 | ADD A,A | Double A. | ||||||||||||
| 57830 | ADD A,A | Double A. | ||||||||||||
| 57831 | LD E,A | E=A. | ||||||||||||
| 57832 | LD A,(IX+1) | Read offset 1 of IX. | ||||||||||||
| 57835 | AND %11100000 | Keep the bits of A that are set in 224. | ||||||||||||
| 57837 | OR E | Set the bits of A that are set in E. | ||||||||||||
| 57838 | LD (IY+2),A | Write A to offset 2 of IY. | ||||||||||||
| AddMapObjects_Skip | 57841 | INC IX | Advance IX. | |||||||||||
| 57843 | INC IX | Advance IX. | ||||||||||||
| 57845 | INC HL | Advance HL. | ||||||||||||
| 57846 | LD DE,(52794) | Fetch the word at ScratchValues into DE. | ||||||||||||
| 57850 | INC DE | Advance DE. | ||||||||||||
| 57851 | LD (52794),DE | The next object in the column. | ||||||||||||
| 57855 | POP BC | Bring BC back off the stack. | ||||||||||||
| 57856 | DEC B | Step B back. | ||||||||||||
| 57857 | JP NZ,AddMapObjects_Next2 | Jump to AddMapObjects_Next2 if the zero flag is clear. | ||||||||||||
| 57860 | RET | Return. | ||||||||||||
| Prev: 57614 | Up: Map | Next: 57861 |