Routines |
Prev: DB06 | Up: Map | Next: DB98 |
Used by the routine at D794.
|
||||||||
Calculates and puts missile data into room object sets at 7C00 for missiles fired by Maroc at creatures, and vice versa. Also calculates trajectory based on origin/target co-ordinates.
First, calculate the address pointer to the missile set (table at 6CDC) using the missile number:
|
||||||||
DB1F | LD C,A | Temp store missile number in C register | ||||||
DB20 | LD HL,($EBC1) | Address pointer to missile data table at 6CDC | ||||||
DB23 | DEC A | Offset needed is 0-8 (not 1-9) so decrement missile number | ||||||
DB24 | LD D,$00 | Store offset in DE register pair | ||||||
DB26 | LD E,A | |||||||
DB27 | LD B,$08 | 8 bytes in each missile data set | ||||||
DB29 | ADD HL,DE | |||||||
DB2A | DJNZ $DB29 | Continue adding until HL is pointing at the start of this missile's data set in the table at 6CDC | ||||||
DB2C | LD ($EB9B),HL | Store missile table address pointer | ||||||
DB2F | INC HL | |||||||
DB30 | LD A,(HL) | Get missile properties byte (second byte in missile data set at 6CDC) | ||||||
DB31 | LD ($EB9E),A | ...and copy into the missile data buffer (starts from EB91) | ||||||
DB34 | DEC HL | |||||||
DB35 | EX DE,HL | Swap (start of) data set pointer into DE register pair | ||||||
DB36 | LD HL,($EB72) | Address pointer to next data bank at 7C00 | ||||||
DB39 | LD A,($EB9A) | Item type. 5 = missile fired by creature/warlock, or 8 = missile fired by Maroc | ||||||
DB3C | LD (HL),A | Put in first byte of room item data set at 7C00 | ||||||
DB3D | INC HL | |||||||
DB3E | LD (HL),E | Store address pointer to start of missile table at 6CDC in bytes 2 & 3 of room item data set (at 7C00) | ||||||
DB3F | INC HL | |||||||
DB40 | LD (HL),D | |||||||
DB41 | INC HL | |||||||
DB42 | LD (HL),C | Store missile number (table at 6CDC) as byte 4 of room item data set (at 7C00) | ||||||
DB43 | INC HL | |||||||
DB44 | LD B,$04 | Copy 4 bytes of data to room item (missile) data set at 7C00: | ||||||
DB46 | LD DE,$EB94 | |||||||
DB49 | LD A,(DE) | |||||||
DB4A | LD (HL),A | |||||||
DB4B | INC DE | |||||||
DB4C | INC HL | |||||||
DB4D | DJNZ $DB49 | |||||||
DB4F | LD (HL),$40 | 9th data byte in room item data sets at 7C00 - this is 64 for 'standard' room items (rather than 254/255 for 'tunnel' room items) | ||||||
DB51 | INC HL | Advance address pointer one byte along | ||||||
Calculate difference between positions of missile origin and target, in 2-pixel steps. Then store this calculation in the missile data set in the room sets at 7C00.
Horizontal position difference (between origin and target) calculation:
|
||||||||
DB52 | LD A,($EB95) | Horizontal position of missile origin (half-character steps) | ||||||
DB55 | LD C,A | |||||||
DB56 | LD A,($EB98) | Horizontal position of target (half-character steps) | ||||||
DB59 | SUB C | Subtract to get the difference | ||||||
DB5A | ADD A,A | Double the difference to get the horizontal difference (either positive or negative) in 2-pixel increments | ||||||
DB5B | LD (HL),A | ...and store in data set (byte 10 of data set) | ||||||
DB5C | INC HL | |||||||
Vertical position difference (between origin and target) calculation:
|
||||||||
DB5D | LD A,($EB97) | Vertical screen position of missile origin (in pixels) | ||||||
DB60 | LD C,A | |||||||
DB61 | LD A,($EB99) | Vertical screen position of missile target (in pixels) | ||||||
DB64 | SUB C | Subtract to get the difference | ||||||
DB65 | SRA A | Halve to get difference in 2-pixel increments | ||||||
DB67 | LD (HL),A | ...and store in data set (byte 11 of data set) | ||||||
DB68 | INC HL | |||||||
Finally, copy missile graphics properties and pointers into room data set at 7C00.
|
||||||||
DB69 | LD A,$01 | Missile graphic frame offset (frame 1 = no offset) | ||||||
DB6B | LD ($EB50),A | |||||||
DB6E | LD DE,($EB9B) | Retrieve address pointer to missile data table at 6CDC | ||||||
DB72 | LD A,(DE) | Get graphic number for the missile graphics for use in the following CALL | ||||||
DB73 | LD ($EB72),HL | Temp store for address pointer current position in the data at 7C00 | ||||||
DB76 | CALL $E0C2 | Set up missile graphics | ||||||
DB79 | LD HL,($EB72) | Retrieve data set address pointer stored before the CALL | ||||||
DB7C | LD A,($EB9E) | Missile properties byte | ||||||
DB7F | LD (HL),A | Store as 12th byte of room item data set | ||||||
DB80 | INC HL | |||||||
DB81 | LD A,($EB4F) | Missile pre-graphics data byte | ||||||
DB84 | LD (HL),A | Store as 13th byte of set | ||||||
DB85 | INC HL | |||||||
DB86 | LD A,$11 | Graphic frame offset. Only bits 0-3 will be used to calculate the graphics animation frame, so the value is effectively 1 (= no offset). Stored in 14th byte of set at 7C00 | ||||||
DB88 | LD (HL),A | |||||||
DB89 | INC HL | |||||||
DB8A | LD DE,($EB51) | Missile graphics address pointer (table at 97C3) | ||||||
DB8E | LD (HL),E | Store as the last two byes in the data set | ||||||
DB8F | INC HL | |||||||
DB90 | LD (HL),D | |||||||
DB91 | INC HL | |||||||
DB92 | LD (HL),$FF | Put end-of-data marker at start of next data set... | ||||||
DB94 | LD ($EB72),HL | ...and store data set pointer | ||||||
DB97 | RET |
Prev: DB06 | Up: Map | Next: DB98 |