Prev: 29955 Up: Map Next: 30101
29960: Draw a graphic in NOP mode
Used by the routines at 28683, 28747, 28882, 28960, 29032, 29089, 29150, 29225, 29291, 29928, 30129, 31370, 32035 and 36275.
Input
A Index of graphic to draw in graphic data lookup table at 42642
B y-coordinate (characters) for printing item
C x-coordinate (characters) for printing item
29960 EX AF,AF' Switch register AF
29961 XOR A Prepare to modify instruction at 30043 to NOP (i.e. A=0)
This entry point is used by the routines at 29950 and 29955.
29962 LD (30043),A Modify instruction at 30043 with new opcode in A
29965 EX AF,AF' Switch back
29966 PUSH HL Store HL, BC and AF...
29967 PUSH BC ...
29968 PUSH AF ...
29969 LD A,C Load x-coordinate to draw item into instruction at 30037
29970 LD (30038),A ...
29973 LD A,B Multiply y-coordinate by 8...
29974 ADD A,A ...
29975 ADD A,A ...
29976 ADD A,A ...
29977 LD L,A ...and load into HL...
29978 LD H,0 ...
29980 ADD HL,HL Double again (so now 16 times y-coordinate, as 8 pixels in a character block, and two bytes per entry in data at 26064)
29981 LD DE,26064 Point DE at table of display file addresses of starts of each pixel row
29984 ADD HL,DE Advance by 16 times y-coordinate to point HL at entry for start of item's current pixel row
29985 PUSH HL Transfer this value into IX...
29986 POP IX ...
29988 POP AF Restore A (graphic index of item to draw)...
29989 LD L,A ...and load into HL...
29990 LD H,0 ...
29992 ADD HL,HL Multiply by four...
29993 ADD HL,HL ...
29994 LD BC,42642 Point BC at start of graphics data lookup table...
29997 ADD HL,BC ...and add offset to point to entry for item of interest
29998 LD C,(HL) Load graphic width into C
29999 INC HL Advance to height
30000 LD B,(HL) Load graphic height into B
30001 INC HL Advance to graphic address
30002 LD A,(HL) Load graphic address into HL...
30003 INC HL ...
30004 LD H,(HL) ...
30005 LD L,A ...
30006 LD A,C Load graphic width into A
30007 CP 255 If width is not set to 255, then...
30009 JR NZ,30014 ...skip to 30014...
30011 LD BC,514 ...else set both height and width to 2
30014 PUSH BC Store width and height
30015 EX DE,HL Swap graphic address into DE
30016 LD A,B Load height into A...
30017 ADD A,A ...and multiply by eight...
30018 ADD A,A ...
30019 ADD A,A ...
30020 LD L,A ...and load into L
30021 LD H,C Load H with graphic width
30022 LD A,C Load A with graphic width
30023 LD (30041),A Load graphic width into instruction at 30040
30026 PUSH HL Transfer width (H) and eight times height (L) from HL to...
30027 POP BC ...B (width) and C (eight times height)
30028 PUSH BC Store B (width) and C (x times height, where x decreases through loop)
30029 LD L,(IX+0) Load HL with display file address to draw item data to screen (stored in IX) from table at 26064...
30032 LD H,(IX+1) ...
30035 LD B,0 Set B to zero
The operand of the instruction at 30037 represents the x-coordinate value stored previously. This is modified by the instruction at 29970.
30037 LD C,0 Load C with x-coordinate of item to draw
30039 ADD HL,BC Increase display file offset with x-coordinate (characters)
The operand of the instruction at 30040 represents the width value stored previously. This is modified by the instruction at 30023.
30040 LD B,0 Load B with width of graphic to draw
30042 LD A,(DE) Load a byte of graphic data into A
The instruction at 30043 represents the graphic blending mode, and can be NOP, XOR (HL) or OR (HL). This is modified by the instruction at 29962.
30043 NOP Blend with graphic data already in display file
30044 LD (HL),A Write resultant graphic data to display file
30045 INC HL Advance display file pointer to draw second column
30046 INC DE Advance to next graphic data byte
30047 DJNZ 30042 Repeat loop (for second column of graphic)
30049 INC IX Advance IX by two (as it is pointing to a table of two-byte addresses)...
30051 INC IX ...
30053 POP BC Restore width and eight times height to BC...
30054 DEC C ...and decrease C (eight times height) to move to next pixel row
30055 JR NZ,30028 Repeat loop for next pixel row
30057 POP DE Restore height (D) and width (E) (characters)
30058 LD A,E Load width into A
30059 LD (30069),A Modify instruction at 30068 with width
30062 POP BC Restore y- and x-coordinates for item being drawn
30063 PUSH BC Store this again
30064 PUSH DE Store width and height
30065 CALL 36569 Update virtual attribute cursor storage location to position (C, B) and point HL to corresponding attribute file address
The operand of the instruction at 30068 represents the width value stored previously. This is modified by the instruction at 30059.
30068 LD B,0 Load B with width of item being drawn
30070 LD A,(23695) Load A with attribute stored at 23695 (this is set by instructions prior to this routine being called)
30073 LD (HL),A Write attribute to current virtual cursor location
30074 PUSH HL Store current virtual cursor location
30075 XOR A Set A to zero
30076 LD DE,22528 Point DE to start of attribute file
30079 SBC HL,DE Load HL with address of virtual attribute cursor location, relative to start of attribute file
30081 LD DE,24539 Point DE at terrain interaction data
30084 ADD HL,DE Add relative address of virtual cursor (attribute) as offset
30085 LD A,(23483) Load stored terrain interaction parameter into terrain interaction table for this attribute file address...
30088 LD (HL),A ...
30089 POP HL Restore current virtual cursor location
30090 INC HL Advance cursor to the right one character
30091 DJNZ 30070 Repeat loop for rest of width
30093 POP DE Restore height (D) and width (E)
30094 POP BC Restore y (B) and x (C) coordinates for item being drawn
30095 INC B Increase y-coordinate
30096 DEC D Decrease "remaining" height
30097 JR NZ,30063 If there is some remaining height to colour, then loop back
30099 POP HL Restore HL
30100 RET Return
Prev: 29955 Up: Map Next: 30101