Prev: DDFA Up: Map Next: DEED
DE0F: Generate Picture
Used by the routine at Game_Initialisation.
Input
IX Pointer to level graphics data
IX will point to one of:
Address Level
GraphicsData_Level_01 Level 01
GeneratePicture DE0F LD HL,$A0E3 HL=Buffer_Image.
Clear down the buffer ready for the new image to be generated.
DE12 LD BC,$0B40 BC=0B40.
DE15 LD (HL),$00 Write 00 to *HL.
DE17 PUSH HL DE=Buffer_Image+01 (using the stack).
DE18 POP DE
DE19 INC DE
DE1A LDIR Clear 0B40 bytes of data in Buffer_Image.
DE1C LD A,$80 Write 80 to *Line_Counter.
DE1E LD ($DEE9),A
GeneratePicture_0 DE21 LD A,$80
DE23 LD HL,$DEE9
DE26 SUB (HL)
DE27 LD B,$14
DE29 LD D,$00
DE2B LD E,A
DE2C LD HL,$A0E3
GeneratePicture_1 DE2F ADD HL,DE
DE30 DJNZ GeneratePicture_1
DE32 LD ($DEEB),HL
DE35 LD A,(IX+$00)
DE38 INC IX
DE3A CP $C9
DE3C JR Z,GeneratePicture_7
DE3E CP $CA
DE40 JR Z,GeneratePicture_2
DE42 PUSH IX
DE44 POP DE
DE45 EX DE,HL
DE46 LD BC,$0014
DE49 LDIR
DE4B PUSH HL
DE4C POP IX
DE4E JR GeneratePicture_Next
GeneratePicture_2 DE50 PUSH IX
DE52 POP DE
GeneratePicture_3 DE53 LD A,(DE)
DE54 CP $00
DE56 JR Z,GeneratePicture_4
DE58 LD (HL),A
DE59 INC HL
DE5A INC DE
DE5B JR GeneratePicture_3
GeneratePicture_4 DE5D INC DE
DE5E LD A,(DE)
DE5F CP $00
DE61 JR Z,GeneratePicture_6
DE63 LD B,A
DE64 XOR A
GeneratePicture_5 DE65 LD (HL),A
DE66 INC HL
DE67 DJNZ GeneratePicture_5
DE69 INC DE
DE6A JR GeneratePicture_3
GeneratePicture_6 DE6C INC DE
DE6D PUSH DE
DE6E POP IX
DE70 JR GeneratePicture_Next
GeneratePicture_7 DE72 LD B,(IX+$01)
DE75 LD A,(IX+$00)
DE78 LD ($DEEA),A
GeneratePicture_8 DE7B PUSH BC
DE7C LD A,($DEEA)
DE7F CP $C9
DE81 JR Z,GeneratePicture_9
DE83 CP $CA
DE85 JR Z,GeneratePicture_9
DE87 CP $CB
DE89 JR NZ,GeneratePicture_10
GeneratePicture_9 DE8B POP BC
DE8C JR GeneratePicture_Next
GeneratePicture_10 DE8E AND $F8
DE90 LD D,A
DE91 RRCA
DE92 RRCA
DE93 RRCA
DE94 LD E,A
DE95 LD A,($DEEA)
DE98 SUB D
DE99 LD D,$00
DE9B ADD HL,DE
DE9C LD B,A
DE9D INC B
DE9E LD A,(HL)
DE9F AND A
DEA0 PUSH BC
GeneratePicture_11 DEA1 RLA
DEA2 DJNZ GeneratePicture_11
DEA4 SCF
DEA5 POP BC
GeneratePicture_12 DEA6 RRA
DEA7 DJNZ GeneratePicture_12
DEA9 LD (HL),A
DEAA LD HL,$DEEA
DEAD INC (HL)
DEAE LD HL,($DEEB)
DEB1 POP BC
DEB2 DJNZ GeneratePicture_8
DEB4 INC IX
DEB6 INC IX
DEB8 JP GeneratePicture_7
Has all the image been decompressed now? If not, loop back again.
GeneratePicture_Next DEBB LD HL,$DEE9 HL=Line_Counter.
DEBE DEC (HL) Decrease *HL by one.
DEBF JP NZ,GeneratePicture_0 Jump to GeneratePicture_0 until *HL is zero.
DEC2 INC IX Move IX to the start of the attribute data.
DEC4 LD B,$10 Set a counter in B to process 10 rows of attribute data.
DEC6 LD HL,$AAE3 Store the start of Buffer_Image_Attributes in HL.
GeneratePicture_Attributes_Loop DEC9 PUSH BC Stash the attribute row counter and the image attributes buffer pointer on the stack.
DECA PUSH HL
DECB LD A,$00 Initialise the column counter in A.
GeneratePicture_Attribute_Row DECD LD C,(IX+$00) Load the attribute value into C.
DED0 INC IX Load the repeat length into B.
DED2 LD B,(IX+$00)
DED5 INC IX Move IX to the next attribute/ repeat length pair.
DED7 ADD A,B Add the repeat length to the column counter.
GeneratePicture_Attribute_Run DED8 LD (HL),C Write the attribute to the image attributes buffer.
DED9 INC HL Increment the image attributes buffer pointer by one.
DEDA DJNZ GeneratePicture_Attribute_Run Decrease the repeat counter by one and loop back to GeneratePicture_Attribute_Run until counter is zero.
DEDC CP $14 Jump to GeneratePicture_Attribute_Row if 14 columns have been processed.
DEDE JR NZ,GeneratePicture_Attribute_Row
DEE0 POP HL Restore the start of the current attribute row from the stack.
DEE1 LD BC,$0014 Move HL to the next row in the attribute buffer.
DEE4 ADD HL,BC
DEE5 POP BC Restore the attribute row counter from the stack.
DEE6 DJNZ GeneratePicture_Attributes_Loop Decrease the attribute row counter by one and loop back to E0BE until counter is zero.
DEE8 RET Return.
Variables specifically for this routine.
Line_Counter DEE9 DEFB $00
Operation_Code DEEA DEFB $C9
Buffer_Position DEEB DEFW $AACF
Prev: DDFA Up: Map Next: DEED