Prev: AE54 Up: Map Next: AF6B
AE94: Upload sprite patterns
Fill VDP RAM from $2100 to $3868 with sprite patterns that may be rotated and flipped. One new pattern is generated with each call. Builds a table of VDP addresses in sprite_pattern_vdp_addrs_table. Used by the routine at start_screen.
upload_sprite_patterns AE94 LD A,(sprite_type_processed) Get sprite type
AE97 CP $FF If maxed out
AE99 RET Z Then return
AE9A LD HL,(upload_destination) Get destination address (only used locally)
AE9D LD A,H Is it zero?
AE9E OR L ...
AE9F JR NZ,upload_sprite_patterns_0 No - skip ahead
AEA1 LD HL,$2100 Yes - set it to $2100
AEA4 LD (upload_destination),HL ...
AEA7 LD HL,sprite_pattern_vdp_addrs_table Set source to sprite_pattern_vdp_addrs_table (pointer to a RAM block)
AEAA LD (upload_source),HL ...
upload_sprite_patterns_0 AEAD LD A,(transformation_processed) Get transformation processed
AEB0 LD HL,pattern_processed OR with pattern processed
AEB3 OR (HL) ...
AEB4 JR NZ,upload_sprite_patterns_1 If any is non-zero skip ahead
AEB6 LD HL,(upload_source) HL = sprite_pattern_vdp_addrs_table initially. Table for storing VDP addresses.
AEB9 LD DE,(upload_destination) DE = $2100 initially. Destination in VDP RAM.
AEBD LD (HL),E Write destination address to word pointer to table.
AEBE INC HL ...
AEBF LD (HL),D ...
AEC0 INC HL ...
AEC1 LD (upload_source),HL Save updated pointer, e.g. $72E0
upload_sprite_patterns_1 AEC4 LD A,(sprite_type_processed) Get sprite type
AEC7 LD HL,graphics_pointer_offsets_table Table of 29 offsets into table at graphics_pointers_table
AECA RST $08 Add A to HL
AECB LD E,(HL) Load DE with offset
AECC LD D,$00 ...
AECE LD HL,graphics_pointers_table Table of pointers to graphics
AED1 ADD HL,DE Add offset
AED2 LD (graphics_pointer_address),HL Save address of pointer (control word)
AED5 LD A,(pattern_processed) Get pattern being processed
AED8 INC A Increment
AED9 ADD A,A Double
AEDA RST $08 Add A to HL, so HL not points to a pattern pointer in graphics_pointers_table
AEDB LD E,(HL) Set DE = pointer to graphics
AEDC INC HL ...
AEDD LD D,(HL) ...
AEDE EX DE,HL Now HL points to graphics
AEDF LD A,(transformation_processed) Get transformation processed
AEE2 AND $03 0, 1, 2, 3
AEE4 ADD A,A 0, 2, 4, 6
AEE5 ADD A,A 0, 4, 8, 12
AEE6 ADD A,A 0, 8, 16, 24
AEE7 RST $08 Add A to HL
AEE8 LD DE,buffer Buffer
AEEB LD (pattern_address),DE Store as source address
AEEF LD BC,$0008 Copy 8 bytes
AEF2 LDIR of graphics data info buffer
AEF4 LD HL,(graphics_pointer_address) Get address of graphics pointer (control word)
AEF7 INC HL To MSB
AEF8 LD A,(HL) Get MSB (transformation)
AEF9 OR A Is it 0, i.e. no transformation
AEFA JR Z,upload_sprite_patterns_3 Then skip ahead
AEFC LD IX,transformation_processed Pointer to transformation
AF00 BIT 2,(IX+$00) Is bit 2 set?
AF04 JR Z,upload_sprite_patterns_2 If not, skip ahead
AF06 CALL rotate Rotate left
upload_sprite_patterns_2 AF09 BIT 3,(IX+$00) Is bit 3 set?
AF0D JR NZ,upload_sprite_patterns_3 If not, skip ahead
AF0F CALL flip_vertical Upside down
AF12 CALL flip_horizontal Mirror
upload_sprite_patterns_3 AF15 LD HL,(pattern_address) Source for writing to VDP RAM
AF18 LD DE,(upload_destination) Destination
AF1C LD BC,$0008 8 bytes
AF1F CALL $1FDF WRITE_VRAM
AF22 LD HL,(upload_destination) Get destination address
AF25 LD BC,$0008 Add 8
AF28 ADD HL,BC ...
AF29 LD (upload_destination),HL Write back
upload_next_pattern AF2C LD IX,(graphics_pointer_address) Get address of graphics pointer (control word)
AF30 LD A,(pattern_processed) Get pattern processed
AF33 INC A Increment it
AF34 CP (IX+$00) When it reaches LSB of control word (pattern count)
AF37 JR NC,upload_next_transformation Then move to next transformation
AF39 LD (pattern_processed),A Otherwise store new value
AF3C SCF Set carry flag
AF3D RET
upload_next_transformation AF3E XOR A
AF3F LD (pattern_processed),A Set pattens processed zero
AF42 LD A,(IX+$01) Get transformation
AF45 OR A Is it zero?
AF46 JR Z,upload_next_sprite_type Then move to next sprite type
AF48 LD A,(transformation_processed) Get transformation processed
AF4B INC A Increment it
AF4C CP $10 When it reaches 16
AF4E JR NC,upload_next_sprite_type Then move to next sprite type
AF50 LD (transformation_processed),A Otherwise store new value
AF53 SCF Set carry flag
AF54 RET
upload_next_sprite_type AF55 XOR A
AF56 LD (transformation_processed),A Set transformation processed to zero
AF59 LD A,(sprite_type_processed) Increment sprite type processed
AF5C INC A ...
AF5D LD (sprite_type_processed),A ...
AF60 LD HL,$001D If it's < $1D (29), which is the last sprite type
AF63 CP L ...
AF64 RET C Then return with carry
AF65 LD A,$FF Else set it to $FF (done)
AF67 LD (sprite_type_processed),A ...
AF6A RET
Prev: AE54 Up: Map Next: AF6B