Prev: AF00 Up: Map Next: AF84
AF01: Draw Wally.
Input
Output
Wally_Draw AF01 PUSH AF
AF02 PUSH BC
AF03 LD HL,(Wally_X)
AF06 LD (BitmapX),HL
AF09 LD A,($F188)
AF0C OR A
AF0D JR Z,Wally_Draw_1
AF0F LD A,(Wally_Frame)
AF12 LD C,A
AF13 CP $10
AF15 JR NC,Wally_Draw_0
AF17 ADD A,$3E
AF19 JR Wally_Draw_2
Wally_Draw_0 AF1B ADD A,$2F
AF1D JR Wally_Draw_2
Wally_Draw_1 AF1F LD A,(Wally_Frame)
AF22 LD C,A
Wally_Draw_2 AF23 CALL Bitmap16Draw
AF26 LD A,H
AF27 ADD A,$10
AF29 LD (BitmapY),A
AF2C LD A,C
AF2D INC A
AF2E CALL Bitmap16Draw
AF31 PUSH DE
AF32 LD HL,(Wally_X) Get current position.
AF35 LD A,L Store pixel X (mod 8).
AF36 AND $07
AF38 LD (Wally_ShiftValue),A
AF3B SRL L Now get which character cell X represents.
AF3D SRL L
AF3F SRL L
AF41 LD A,H Get Y's pixel offset and store.
AF42 AND $07
AF44 LD (Wally_CharAligned),A
AF47 JR NZ,Wally_Draw_3
AF49 LD D,$04 If character cell aligned used '4' for number of cells down.
AF4B JR Wally_Draw_4
Wally_Draw_3 AF4D LD D,$05 If not character cell aligned used '5' for number of cells down.
Wally_Draw_4 AF4F LD A,H Convert position into ATTR table address for the first cell holding background colour.
AF50 AND $F8
AF52 LD H,A
AF53 LD A,D
AF54 LD E,L
AF55 LD D,$58
AF57 LD L,H
AF58 LD H,$00
AF5A ADD HL,HL
AF5B ADD HL,HL
AF5C ADD HL,DE
AF5D LD BC,Wally_BgColour Table holding the colours behind Wally.
AF60 LD DE,$001E
Wally_Draw_5 AF63 PUSH AF
AF64 LD A,(HL) Get current ATTR colour, store in Wally's table, then set colour to Yellow.
AF65 LD (BC),A
AF66 LD (HL),$46
AF68 INC BC Do again for the next column.
AF69 INC HL
AF6A LD A,(HL)
AF6B LD (BC),A
AF6C LD (HL),$46
AF6E INC HL
AF6F INC BC
AF70 LD A,(Wally_ShiftValue) If wally is offset from a character cell we need to add an extra column.
AF73 OR A
AF74 JR Z,Wally_Draw_6
AF76 LD A,(HL)
AF77 LD (BC),A
AF78 LD (HL),$46
Wally_Draw_6 AF7A INC BC Move on to the next line in the table.
AF7B ADD HL,DE
AF7C POP AF
AF7D DEC A
AF7E JR NZ,Wally_Draw_5
AF80 POP DE
AF81 POP BC
AF82 POP AF
AF83 RET
Prev: AF00 Up: Map Next: AF84