Prev: 56826 Up: Map Next: 57069
56847: 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 56847 LD HL,41187 HL=Buffer_Image.
Clear down the buffer ready for the new image to be generated.
56850 LD BC,2880 BC=2880.
56853 LD (HL),0 Write 0 to *HL.
56855 PUSH HL DE=Buffer_Image+1 (using the stack).
56856 POP DE
56857 INC DE
56858 LDIR Clear 2880 bytes of data in Buffer_Image.
56860 LD A,128 Write 128 to *Line_Counter.
56862 LD (57065),A
GeneratePicture_0 56865 LD A,128
56867 LD HL,57065
56870 SUB (HL)
56871 LD B,20
56873 LD D,0
56875 LD E,A
56876 LD HL,41187
GeneratePicture_1 56879 ADD HL,DE
56880 DJNZ GeneratePicture_1
56882 LD (57067),HL
56885 LD A,(IX+0)
56888 INC IX
56890 CP 201
56892 JR Z,GeneratePicture_7
56894 CP 202
56896 JR Z,GeneratePicture_2
56898 PUSH IX
56900 POP DE
56901 EX DE,HL
56902 LD BC,20
56905 LDIR
56907 PUSH HL
56908 POP IX
56910 JR GeneratePicture_Next
GeneratePicture_2 56912 PUSH IX
56914 POP DE
GeneratePicture_3 56915 LD A,(DE)
56916 CP 0
56918 JR Z,GeneratePicture_4
56920 LD (HL),A
56921 INC HL
56922 INC DE
56923 JR GeneratePicture_3
GeneratePicture_4 56925 INC DE
56926 LD A,(DE)
56927 CP 0
56929 JR Z,GeneratePicture_6
56931 LD B,A
56932 XOR A
GeneratePicture_5 56933 LD (HL),A
56934 INC HL
56935 DJNZ GeneratePicture_5
56937 INC DE
56938 JR GeneratePicture_3
GeneratePicture_6 56940 INC DE
56941 PUSH DE
56942 POP IX
56944 JR GeneratePicture_Next
GeneratePicture_7 56946 LD B,(IX+1)
56949 LD A,(IX+0)
56952 LD (57066),A
GeneratePicture_8 56955 PUSH BC
56956 LD A,(57066)
56959 CP 201
56961 JR Z,GeneratePicture_9
56963 CP 202
56965 JR Z,GeneratePicture_9
56967 CP 203
56969 JR NZ,GeneratePicture_10
GeneratePicture_9 56971 POP BC
56972 JR GeneratePicture_Next
GeneratePicture_10 56974 AND 248
56976 LD D,A
56977 RRCA
56978 RRCA
56979 RRCA
56980 LD E,A
56981 LD A,(57066)
56984 SUB D
56985 LD D,0
56987 ADD HL,DE
56988 LD B,A
56989 INC B
56990 LD A,(HL)
56991 AND A
56992 PUSH BC
GeneratePicture_11 56993 RLA
56994 DJNZ GeneratePicture_11
56996 SCF
56997 POP BC
GeneratePicture_12 56998 RRA
56999 DJNZ GeneratePicture_12
57001 LD (HL),A
57002 LD HL,57066
57005 INC (HL)
57006 LD HL,(57067)
57009 POP BC
57010 DJNZ GeneratePicture_8
57012 INC IX
57014 INC IX
57016 JP GeneratePicture_7
Has all the image been decompressed now? If not, loop back again.
GeneratePicture_Next 57019 LD HL,57065 HL=Line_Counter.
57022 DEC (HL) Decrease *HL by one.
57023 JP NZ,GeneratePicture_0 Jump to GeneratePicture_0 until *HL is zero.
57026 INC IX Move IX to the start of the attribute data.
57028 LD B,16 Set a counter in B to process 16 rows of attribute data.
57030 LD HL,43747 Store the start of Buffer_Image_Attributes in HL.
GeneratePicture_Attributes_Loop 57033 PUSH BC Stash the attribute row counter and the image attributes buffer pointer on the stack.
57034 PUSH HL
57035 LD A,0 Initialise the column counter in A.
GeneratePicture_Attribute_Row 57037 LD C,(IX+0) Load the attribute value into C.
57040 INC IX Load the repeat length into B.
57042 LD B,(IX+0)
57045 INC IX Move IX to the next attribute/ repeat length pair.
57047 ADD A,B Add the repeat length to the column counter.
GeneratePicture_Attribute_Run 57048 LD (HL),C Write the attribute to the image attributes buffer.
57049 INC HL Increment the image attributes buffer pointer by one.
57050 DJNZ GeneratePicture_Attribute_Run Decrease the repeat counter by one and loop back to GeneratePicture_Attribute_Run until counter is zero.
57052 CP 20 Jump to GeneratePicture_Attribute_Row if 20 columns have been processed.
57054 JR NZ,GeneratePicture_Attribute_Row
57056 POP HL Restore the start of the current attribute row from the stack.
57057 LD BC,20 Move HL to the next row in the attribute buffer.
57060 ADD HL,BC
57061 POP BC Restore the attribute row counter from the stack.
57062 DJNZ GeneratePicture_Attributes_Loop Decrease the attribute row counter by one and loop back to 57534 until counter is zero.
57064 RET Return.
Variables specifically for this routine.
Line_Counter 57065 DEFB 0
Operation_Code 57066 DEFB 201
Buffer_Position 57067 DEFW 43727
Prev: 56826 Up: Map Next: 57069