Prev: ACF9 Up: Map Next: AD8B
AD49: Allocate sprite (RST $28)
Used by the routine at L8018.
Output
IX holds sprite address
allocate_sprite AD49 PUSH HL
AD4A PUSH DE
AD4B PUSH BC
AD4C LD HL,sprite_data Address of sprite data
AD4F LD DE,$000C Size of each sprite
AD52 LD BC,$2000 Number of sprites and sprite index
AD55 LD A,$7E
allocate_sprite_0 AD57 CP (HL)
AD58 JR C,allocate_sprite_1 If >= $7F ($FF from init), sprite is available
AD5A INC C Sprite index++
AD5B ADD HL,DE Advance to next sprite
AD5C DJNZ allocate_sprite_0 Loop for up to 32 sprites
AD5E LD IX,$03E8 Not found, set to address in ROM (?)
AD62 JR allocate_sprite_4 And return
allocate_sprite_1 AD64 PUSH HL Save sprite address
AD65 BIT 7,(HL) Is bit 7 set, i.e. $FF?
AD67 JR Z,allocate_sprite_3 If not, skip recoding in allocation table
AD69 LD HL,allocated_sprites Allocated sprites
AD6C INC (HL) Record one more
AD6D LD A,(HL) Read number back
AD6E ADD A,L Add number to HL
AD6F LD L,A ...
AD70 JP NC,allocate_sprite_2 ...
AD73 INC H ...
allocate_sprite_2 AD74 LD (HL),C Record sprite index in table
allocate_sprite_3 AD75 POP IX IX now holds sprite address
AD77 LD (IX+$07),$00 Init sprite
AD7B LD (IX+$03),$00 Set counter to 0
AD7F LD (IX+$04),$FF Set loaded patten index to none
AD83 LD (IX+$08),$F8 Set y
allocate_sprite_4 AD87 POP BC
AD88 POP DE
AD89 POP HL
AD8A RET
Prev: ACF9 Up: Map Next: AD8B