Prev: 54406 Up: Map Next: 54505
54411: Draw a graphic with lookup index A at character coordinates (C, B)
Used by the routines at 28390 and 30145.
Input
A Index of graphic to draw in graphic data lookup table at 55950
B y-coordinate (characters) for printing item
C x-coordinate (characters) for printing item
D (entry at 54414) Graphic height (characters)
E (entry at 54414) Graphic width (characters)
54411 LD DE,1026 Set D (height) to 4 and E to 2 (width)
This entry point is used by the routines at 30145, 34990 and 54406.
54414 PUSH HL Store HL
54415 PUSH DE Store DE
54416 PUSH AF Store AF
54417 LD A,C Load x-coordinate to draw item into instruction at 54477...
54418 LD (54478),A ...
54421 LD A,B Multiply y-coordinate by 8...
54422 ADD A,A ...
54423 ADD A,A ...
54424 ADD A,A ...
54425 LD L,A ...and load into HL...
54426 LD H,0 ...
54428 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 26240)
54429 LD DE,26240 Point DE at table of display file addresses of start of each pixel row
54432 ADD HL,DE Advance by 16 times y-coordinate to point HL at entry for start of item's current pixel row
54433 PUSH HL Transfer this value into IX...
54434 POP IX ...
54436 POP AF Restore A (graphic index of item to draw)...
54437 LD L,A ...and load into HL...
54438 LD H,0 ...
54440 ADD HL,HL Multiply by four (as there are two WORD entries for each graphic in the table at 55950)...
54441 ADD HL,HL ...
54442 LD BC,55950 Point BC at start of graphics data lookup table at 55950...
54445 ADD HL,BC ...and add offset to point to entry for item of interest
54446 LD E,(HL) Load graphic data address for this graphic into DE...
54447 INC HL ...
54448 LD D,(HL) ...
54449 INC HL ...
54450 CALL 55735 Load next value in table (address of graphic data for this object's mask) into HL
54453 POP BC Restore BC (B = height, C = width)
54454 LD A,B Load height into A...
54455 ADD A,A ...and multiply by eight...
54456 ADD A,A ...
54457 ADD A,A ...
54458 EX AF,AF' Swap A and A'
54459 LD B,C Copy graphic width into B...
54460 LD A,C ...and A'...
54461 LD (54481),A ...and modify instruction at 54480 with this value also
54464 EX AF,AF' Swap A and A'
54465 EX DE,HL Swap DE (now pointer to object's mask graphic data) and HL (now pointer to object's graphic data)
54466 EXX Switch registers
54467 LD C,A Load C with eight times graphic's height
54468 PUSH BC Store BC (C = remaining number of pixel rows to draw, initially eight times graphic's height)
54469 LD L,(IX+0) Load HL' with display file address of start of pixel row at object's y-coordinate...
54472 LD H,(IX+1) ...
54475 LD B,0 Set B' to zero
The operand of the instruction at 54477 represents the x-coordinate at which to draw the item. This is modified by the instruction at 54418.
54477 LD C,0 Set C' to x-coordinate of item
54479 ADD HL,BC Add x-coordinate as offset to address of start of pixel row in HL' (HL' now points at display file address to begin drawing)
The operand of the instruction at 54480 represents the width of the graphic to draw. This is modified by the instruction at 54461.
54480 LD B,0 Load B with graphic width
54482 EXX Switch registers
54483 LD A,(DE) Load graphic data byte from graphic mask data into A
54484 EXX Switch registers
54485 AND (HL) Modify mask data by AND-ing with contents of display file allowing scenery in background to show; set pixels are transparent
54486 EXX Switch registers
54487 OR (HL) Modify modified mask data by OR-ing with object graphic data byte from graphic data
54488 INC HL Advance HL to next byte in object graphic data
54489 INC DE Advance DE to next byte in object graphic mask data
54490 EXX Switch registers
54491 LD (HL),A Load masked graphic data byte into display file
54492 INC HL Advance HL to next byte in display file
54493 DJNZ 54482 Loop back to 54482 for next column of object graphic data
54495 INC IX Advance IX by two bytes to next address in table of addresses of starts of pixel rows...
54497 INC IX ...
54499 POP BC Restore BC (C = remaining number of pixel rows to draw)
54500 DEC C Decrease remaining number pixel rows to draw
54501 JR NZ,54468 If not zero (i.e. still need to draw at least one more pixel row of graphic data) then loop back to 54468
54503 POP HL Restore HL
54504 RET Return
Prev: 54406 Up: Map Next: 54505