Prev: 92D2 Up: Map Next: 9434
92E5: BG: Draw correct part of a background item at a given column.
Used by the routine at Bg_DrawColumn.
Input
IX 5 byte data struct ptr.
Output
Prepares and Draws the background furniture by walking through the description string until it finds the correct item in the expected column.
Any objects that require preperation is handle here, such as adding the street name to a sign.
Bg_CalcAndDraw 92E5 LD (Data_Stack),SP
92E9 BIT 7,(IX+$01)
92ED JR NZ,Bg_CalcAndDraw_1
92EF LD A,(IX+$04)
92F2 LD B,$02
92F4 AND A
92F5 JP P,Bg_CalcAndDraw_0
92F8 LD B,$00
92FA JR Z,Bg_CalcAndDraw_0
92FC NEG
92FE LD B,$FE
Bg_CalcAndDraw_0 9300 SUB B
9301 LD (Bg_DoorNumber),A
9304 LD A,B
9305 LD ($92D5),A
9308 PUSH IX Get start of next block.
930A POP HL
930B LD DE,$0005
930E ADD HL,DE
930F LD (_NextBlock),HL
9312 LD A,(IX+$05)
9315 RRA
9316 RRA
9317 RRA
9318 RRA
9319 AND $0F
931B LD E,A
931C LD D,$00
931E ADD HL,DE
931F LD (_NextSignText),HL
Bg_CalcAndDraw_1 9322 LD E,(IX+$00) Get map position of path.
9325 LD D,(IX+$01)
9328 RES 7,D
932A LD A,(Camera_Compass) Based on compass get position for correct axis.
932D BIT 0,A
932F JR Z,Bg_CalcAndDraw_2
9331 LD HL,(Coords_NS)
9334 JR Bg_CalcAndDraw_3
Bg_CalcAndDraw_2 9336 LD HL,(Coords_EW)
Bg_CalcAndDraw_3 9339 BIT 1,A Workout difference between hero and path start. Camera and direction set calculations.
933B JR Z,Bg_CalcAndDraw_4
933D EX DE,HL
Bg_CalcAndDraw_4 933E LD A,(Hero_LastDirection)
9341 CP $02
9343 JR Z,Bg_CalcAndDraw_5
9345 EX DE,HL
Bg_CalcAndDraw_5 9346 AND A
9347 SBC HL,DE
9349 LD E,(IX+$02) Length?
934C LD D,$00
934E CP $02
9350 JR Z,Bg_CalcAndDraw_6
9352 AND A
9353 SBC HL,DE
9355 EX DE,HL
9356 LD HL,$0020
9359 AND A
935A SBC HL,DE
935C JR Bg_CalcAndDraw_7
Bg_CalcAndDraw_6 935E ADD HL,DE
935F LD DE,$0022
9362 AND A
9363 SBC HL,DE
Bg_CalcAndDraw_7 9365 SRL H Half the length to match 1 column of an item.
9367 RR L
9369 LD (Bg_ColumnsLeft),HL
936C XOR A
936D LD (_92d8_ReverseBit),A
9370 LD A,(IX+$03)
9373 BIT 7,(IX+$01)
9377 JR Z,Bg_CalcAndDraw_8
9379 SUB $04 Calculate number of items to scan through.
937B LD C,A
937C LD DE,$0004
937F JR Bg_CalcAndDraw_9
Bg_CalcAndDraw_8 9381 SUB $06 Calculate number of items to scan through.
9383 LD C,A
9384 LD A,(IX+$05) Calculate start of description string.
9387 RRA
9388 RRA
9389 RRA
938A RRA
938B AND $0F
938D LD E,A
938E LD D,$00
9390 LD A,(IX+$05)
9393 AND $0F
9395 LD L,A
9396 LD H,D
9397 ADD HL,DE
9398 LD DE,$0006
939B ADD HL,DE
939C EX DE,HL
Bg_CalcAndDraw_9 939D ADD IX,DE Offset IX to start of description string.
939F LD B,$01 Set loop to draw 1 column.
93A1 JR Bg_CalcAndDraw_11
_
Bg_CalcAndDraw_10 93A3 LD IX,($92D9)
93A7 LD A,($92DB)
93AA LD C,A
Walk description string.
Bg_CalcAndDraw_11 93AB PUSH BC Get index of object to draw and run a function based on upper bit and value.
93AC LD A,(IX+$00)
93AF BIT 7,A Handle if a control code.
93B1 JP Z,Bg_StrCtrlCodes
93B4 CP $FF
93B6 JP Z,Bg_DrawEmptyCol
93B9 CP $DD Handle sub-string code.
93BB JP NC,Bg_UseInnerStr
93BE CP $82
93C0 JP C,Bg_NextSignText
93C3 CP $92
93C5 JR C,Bg_CalcAndDraw_12
93C7 CP $96
93C9 JP C,Bg_NextDoorNumber
This entry point is used by the routines at Bg_NextDoorNumber and Bg_NextSignText.
Bg_CalcAndDraw_12 93CC LD L,(IX+$00) Get item index and calculate address for bitmap's width.
93CF LD H,$00
93D1 ADD HL,HL
93D2 ADD HL,HL
93D3 LD DE,Bitmap_PtrTableOffWidth
93D6 ADD HL,DE
93D7 LD A,(HL) Get width and store.
93D8 LD E,A
93D9 RES 7,E Remove flag bit.
93DB LD D,$00 Convert into 16bit.
93DD LD HL,(Bg_ColumnsLeft) Decrease object width from columns left.
93E0 AND A
93E1 SBC HL,DE
93E3 JR C,Bg_CalcAndDraw_16
This entry point is used by the routines at Bg_DrawEmptyCol and Bg_StrCtrlCodes.
Bg_CalcAndDraw_13 93E5 LD (Bg_ColumnsLeft),HL
93E8 POP BC
This entry point is used by the routines at Bg_StrCtrlCodes and Bg_UseInnerStr.
Bg_CalcAndDraw_14 93E9 DJNZ Bg_CalcAndDraw_10
Entry point used by sub-string draw.
ENTRY
C Bytes in sub string
IX Ptr to sub-string
Bg_CalcAndDraw_15 93EB LD B,$01
93ED XOR A Clear the reverse draw flag.
93EE LD (_92d8_ReverseBit),A
93F1 DEC C Decrease the number of bytes left in string, ending if done.
93F2 RET Z
93F3 INC IX Move onto next byte in string.
93F5 JR Bg_CalcAndDraw_11
__
Bg_CalcAndDraw_16 93F7 LD D,A
93F8 LD A,(_92d8_ReverseBit) See if bit needs reversing.
93FB XOR D
93FC BIT 7,A
93FE JR Z,Bg_CalcAndDraw_17
9400 LD L,(IX+$00)
9403 CALL Bitmap_Reverse
Bg_CalcAndDraw_17 9406 LD A,(IX+$00)
9409 CP $82 Shop window with a sign.
940B JP C,Bg_BlitOneWord
940E CP $86 Picture frame.
9410 JP C,Gallery_DrawPicture
9413 CP $8F Street sign.
9415 JP Z,Bg_BlitTwoWord
9418 CP $92 Basic object.
941A JR C,Bg_BlitItemColumn
941C CP $96 Door.
941E JP C,Bg_BlitDoor
9421 CP $9E Shop-keeper.
9423 JP Z,BgTable_StoreShopKeeper
9426 CP $C6 Torch.
9428 JP Z,Bg_TorchAdd
942B CP $A4
942D JR C,Bg_BlitItemColumn
942F CP $A6 Shop counter.
9431 JP C,BgTable_Store
Prev: 92D2 Up: Map Next: 9434