Prev: 57520 Up: Map Next: 57589
57538: Setup game graphics
Input
A Graphic number - offset for graphics address pointer table at 38851. Calculated offset is ((A-1)*2) + 38851.
Room graphics are prepared using this routine when Maroc moves into a new room/screen.
The routine is also called to prepare any additional graphics required as and when needed (e.g. a creature entering the room, the warlock appearing, or to draw the arrow on the spell menu if fire is pressed).
57538 LD B,A Transfer offset value to B register
Calculate graphics address pointer using offset, using table at 38851
57539 LD HL,(60266) Pointer to graphics address list at 38851
57542 DEC A Address pointers are 2 bytes long, so get offset value, subtract 1...
57543 LD D,0
57545 RLA ...multiply by 2
57546 RL D
57548 AND 254 Address pointers are 2 bytes long, so filter out bit 0 (1) to ensure it's an even number
57550 LD E,A
57551 ADD HL,DE Add the calculated offset to the base table address, to get the right graphics address pointer
57552 LD (60082),HL ...and store. Initially corner vertical wall section at 38885/40463.
Calculate a second graphics pointer offset, that will point to the flipped/mirrored graphic's address.
57555 LD A,(60240) Offset byte for address pointer for store of mirrored graphic
57558 DEC A Address pointers are 2 bytes long, so get offset value, subtract 1...
57559 RLA ...multiply by 2
57560 AND 30 Keep bits 1-4 (no bit 0). Address pointers are 2 bytes long, so filter out bit 0 (1) just to make sure it's an even number.
57562 LD E,A Put offset in DE
57563 LD D,0
57565 ADD HL,DE Add this to HL address graphic pointer
57566 LD (60241),HL ...and store.
Point DE register pair to graphics data (HL = pointer at address table at 38851)
57569 LD HL,(60082) Get graphics address pointer (with first offset pointing to the 'standard' graphics address)
57572 LD E,(HL) Point DE to the actual graphics address data e.g. 39248, 40463.
57573 INC HL
57574 LD D,(HL)
57575 DEC HL
Pre-graphics byte - see Graphic properties
57576 DEC DE Get pre-graphics byte
57577 LD A,(DE)
57578 INC DE
57579 LD (60239),A ...and store.
The next routine checks if the graphic has a 'mirrored' version. If so, this is constructed in the following routine at 57589.
If bit 5 (32) is set, it indicates that the graphic is 'flippable' - for example, graphics for the background right-hand side wall, which can be flipped to create the background left-hand side wall.
57582 LD C,A Store the byte in the C register, used in the following 'flip' routine
57583 AND 32 If bit 5 is NOT set, no need to generate 'flipped' graphics.
57585 CP 0
57587 JR Z,57705 In which case, jump straight to the RET command at the end of the following flip/reflect routine
Prev: 57520 Up: Map Next: 57589