This is an old revision of the document!
Space Invaders Bunker
The following (edited) code snippet is from Richard Degler's disassembly [.zip] of the Bally Arcade Space Invaders prototype. The LOOP section demonstrates writing a single pattern (the bunker graphic) to the screen multiple times using the WRITP UPI routine. The BUNKER section shows the referenced pattern block.
; [...] ; Write Four Player "Protective Bunkers" ; --------------------------------------- ; The Four Bunker's X,Y Coordinate's are: ; Bunker 1 (Left-Most): 10, 65 ; Bunker 2 (Middle-Left): 50, 65 ; Bunker 3 (Middle-Right): 90, 65 ; Bunker 4 (Right-Most): 130, 65 ; LD B,$04 ; 4 for 4 writes LD E,$0A ; 10 for LEFTmost X LOOP: LD HL,BUNKER ; point at Player's BUNKER XOR A ; Magic Register = 0 for PLOP LD D,$41 ; 65 for all Y Coordinate's PUSH DE ; store DE for X Coordinate PUSH BC SYSTEM WRITP ; UPI WRITe with Pattern size lookup ; POP BC POP DE ; restore DE for X Coordinate LD A,E ; old X + 40 ADD A,$28 LD E,A ; X Coordinate for Next Bunker DJNZ LOOP ; (-$12) to run 4 times ; [...] ; Player's BUNKER color Pattern BUNKER: DB $05 ; WIDTH = 5 Bytes DB $0D ; HEIGHT = 13 Rows ; DB $03,$FF,$FF,$FF,$C0 ; . . . 3 3 3 3 3 3 3 3 3 3 3 3 3 3 . . . DB $0F,$FF,$FF,$FF,$F0 ; . . 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 . . DB $3F,$FF,$FF,$FF,$FC ; . 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 . DB $FF,$FF,$FF,$FF,$FF ; 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 DB $FF,$FF,$FF,$FF,$FF ; 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 DB $FF,$FF,$FF,$FF,$FF ; 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 DB $FF,$FF,$FF,$FF,$FF ; 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 DB $FF,$FF,$FF,$FF,$FF ; 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 DB $FF,$FF,$FF,$FF,$FF ; 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 DB $FF,$F0,$00,$0F,$FF ; 3 3 3 3 3 3 . . . . . . . . 3 3 3 3 3 3 DB $FF,$C0,$00,$03,$FF ; 3 3 3 3 3 . . . . . . . . . . 3 3 3 3 3 DB $FF,$00,$00,$00,$FF ; 3 3 3 3 . . . . . . . . . . . . 3 3 3 3 DB $FF,$00,$00,$00,$FF ; 3 3 3 3 . . . . . . . . . . . . 3 3 3 3 ; [...]
Code Discussion
WRITP is squarely in the middle of the screen writing routine hierarchy, meaning that it some preprocessing to execute properly.
[pattern block requirements]
XOR A
is a more efficient way to perform
LD A,0
, though the former does change flags.