Prev: 8269 Up: Map Next: 84D3
826E: Background, draw column
Used by the routines at _873a and 8BB6.
Bg_DrawColumn 826E LD A,(Level_Char)
8271 LD L,$06
8273 CP $69
8275 JR C,Bg_DrawColumn_0
8277 LD L,$07
Bg_DrawColumn_0 8279 SUB $61
827B RLA
827C RLA
827D RLA
827E AND $38
8280 OR $46
8282 LD H,A
8283 LD ($82EF),HL Update some code to use the new value.
8286 LD ($830B),HL
8289 LD ($A41A),HL
828C LD ($A49C),HL
828F XOR A
8290 LD (PathIndex),A
8293 LD DE,(Position_NS) Get both positions of player.
8297 LD HL,(Position_EW)
829A LD A,(Stage_Compass) Using the compass work out which way a path should run
829D AND $01
829F JR NZ,Bg_DrawColumn_1
82A1 LD IX,(CurrentArea_PathsEWptr) Get the start of the E/W paths, use the N/S position.
82A5 JR Bg_DrawColumn_2
Bg_DrawColumn_1 82A7 LD IX,(CurrentArea_PathsNSptr) Get the start of the N/S paths, use the E/W position.
82AB EX DE,HL
Bg_DrawColumn_2 82AC LD A,(Hero_ThroughDoor)
82AF AND A
82B0 JR Z,Bg_DrawColumn_5
Going through a door.
82B2 LD A,(Stage_Compass)
82B5 LD BC,$0006
82B8 CP $02
82BA JR C,Bg_DrawColumn_3
82BC LD BC,$FFFA
Bg_DrawColumn_3 82BF LD A,(Hero_LastDir)
82C2 CP $02
82C4 JR Z,Bg_DrawColumn_4
82C6 ADD HL,BC
82C7 JR Bg_DrawColumn_5
Bg_DrawColumn_4 82C9 AND A
82CA SBC HL,BC
Bg_DrawColumn_5 82CC LD C,L
82CD LD B,H
Is position on path?
Bg_DrawColumn_6 82CE PUSH DE First check if inscreen position is on the axis of path.
82CF LD L,(IX+$00)
82D2 LD H,(IX+$01)
82D5 AND A
82D6 SBC HL,DE
82D8 JR NC,Bg_DrawColumn_7
82DA LD DE,$0004
82DD AND A
82DE ADC HL,DE
82E0 JP M,Bg_DrawColumn_9
82E3 JR Bg_DrawColumn_8
Bg_DrawColumn_7 82E5 LD DE,$0004
82E8 SCF
82E9 SBC HL,DE
82EB JR NC,Bg_DrawColumn_11
Bg_DrawColumn_8 82ED BIT 2,(IX+$06)
82F1 JR Z,Bg_DrawColumn_10
82F3 LD L,(IX+$02) Now see if the other position (left/right) is within the two ends of the path.
82F6 LD H,(IX+$03)
82F9 SCF
82FA SBC HL,BC
82FC JR NC,Bg_DrawColumn_9
82FE LD L,(IX+$04)
8301 LD H,(IX+$05)
8304 AND A
8305 SBC HL,BC
8307 JR NC,Bg_DrawColumn_13
Bg_DrawColumn_9 8309 BIT 2,(IX+$06)
830D JR Z,Bg_DrawColumn_10
830F LD HL,PathIndex Increase path index
8312 INC (HL)
Next path in list...
Bg_DrawColumn_10 8313 LD DE,$000A
8316 ADD IX,DE
8318 POP DE
8319 JR Bg_DrawColumn_6
Path found...
Bg_DrawColumn_11 831B POP DE
831C LD DE,(Position_NS)
8320 LD HL,(Position_EW)
8323 LD A,(Stage_Compass)
8326 BIT 0,A
8328 JR Z,Bg_DrawColumn_12
832A EX DE,HL
Bg_DrawColumn_12 832B LD ($BE09),DE
832F LD (PathPosHalfway),HL
8332 LD A,$06
8334 LD (PathHalfLength),A
8337 LD A,$E9
8339 LD (CurrentPathInfo),A
833C LD DE,$0004
833F AND A
8340 SBC HL,DE
8342 LD ($BE0B),HL
8345 ADD HL,DE
8346 ADD HL,DE
8347 LD ($BE0D),HL
834A LD IX,$BE09
834E LD (PathPtr),IX
8352 LD (Path__),A
8355 JP Bg_DrawColumn_26
Path found...
Bg_DrawColumn_13 8358 POP DE
8359 LD (PathPtr),IX
835D LD A,(Stage_Compass)
8360 LD (Path__),A
8363 LD (PathPtrCopy),IX
8367 LD (Path__Copy),A
836A LD L,(IX+$04) Calculate halfway point along path.
836D LD H,(IX+$05)
8370 LD E,(IX+$02)
8373 LD D,(IX+$03)
8376 AND A
8377 SBC HL,DE
8379 SRL H
837B RR L
837D LD A,L
837E ADD HL,DE
837F LD (PathPosHalfway),HL
8382 ADD A,$02
8384 LD (PathHalfLength),A
8387 LD DE,CurrentPathInfo
838A LD HL,$BE26
838D LD BC,$0007
8390 LDIR
8392 LD A,(Stage_Compass)
8393 LD B,A Correct position on path axis.
8394 CP L
8395 LD L,(IX+$00)
8398 LD H,(IX+$01)
839B BIT 0,A
839D JR Z,Bg_DrawColumn_14
839F LD (Position_EW),HL
83A2 LD HL,($BD70)
83A5 LD DE,($BD72)
83A9 JR Bg_DrawColumn_15
Bg_DrawColumn_14 83AB LD (Position_NS),HL
83AE LD HL,($BD6C)
83B1 LD DE,($BD6E)
Bg_DrawColumn_15 83B5 BIT 1,A
83B7 JR Z,Bg_DrawColumn_16
83B9 EX DE,HL
Search through path info based on index.
Bg_DrawColumn_16 83BA LD A,(PathIndex)
83BD AND A
83BE JR Z,Bg_DrawColumn_18
83C0 LD B,A
83C1 LD D,$00
Bg_DrawColumn_17 83C3 LD A,(HL) Calculate size of data for this path.
83C4 RLCA
83C5 RLCA
83C6 RLCA
83C7 OR $01
83C9 AND $07
83CB LD E,A
83CC ADD HL,DE Skip onto next path using size.
83CD DJNZ Bg_DrawColumn_17
Bg_DrawColumn_18 83CF EX DE,HL
83D0 LD A,(_be1c)
83D3 AND A
83D4 JR NZ,Bg_DrawColumn_19
83D6 LD HL,(_be21)
83D9 AND A
83DA SBC HL,DE
83DC JR NZ,Bg_DrawColumn_19
83DE LD DE,$BE23
Copy path info in current store
Bg_DrawColumn_19 83E1 EX DE,HL
83E2 LD A,(HL)
83E3 AND $3F
83E5 ADD A,$DD
83E7 LD DE,CurrentPathInfo
83EA LD (DE),A
83EB LD A,(HL)
83EC AND $C0
83EE JR Z,Bg_DrawColumn_20
83F0 RLCA
83F1 RLCA
83F2 RLCA
83F3 LD C,A
83F4 LD B,$00
83F6 INC HL
83F7 INC DE
83F8 LDIR
Bg_DrawColumn_20 83FA LD A,(_bd74)
83FD AND A
83FE JP NZ,Bg_DrawColumn_26
8401 LD HL,Str_SignFormatLevel Str_SignFormat is a formatted string.
8404 LD A,(Level_Char) Update string with the current level.
8407 OR $80
8409 LD (HL),A
840A INC HL Now update it with the sector number.
840B INC HL
840C LD A,(IX+$08)
840F LD (HL),A
8410 INC HL
8411 LD A,(IX+$09) and the area.
8414 LD (HL),A
8415 LD A,$8F
8417 LD HL,Str_SignFormat Update the sign showing level and sector.
841A LD B,$05
841C CALL String_DrawToSign
841F LD A,(IX+$09)
8422 AND $7F
8424 CP $35
8426 JP NC,Bg_DrawColumn_26
8429 CALL _84d3
842C LD A,(Level_Char) level *10
842F SUB $61
8431 LD B,A
8432 RLCA
8433 RLCA
8434 ADD A,B
8435 RLCA
8436 LD B,A
8437 LD A,(IX+$08) plus offset
843A AND $7F
843C SUB $60
843E ADD A,B
843F LD E,A
8440 LD D,$00
8442 LD HL,_bda5
8445 ADD HL,DE
8446 LD A,(Hero_ThroughDoor)
8449 AND A
844A JR NZ,Bg_DrawColumn_25
844C LD A,(_bd0c_central_)
844F CP $03
8451 JR Z,Bg_DrawColumn_25
8453 LD DE,Stat_Percent
8456 CP $02
8458 JR NZ,Bg_DrawColumn_21
845A INC DE
845B INC DE
Bg_DrawColumn_21 845C RRCA
845D RRCA
845E AND $80
8460 XOR (HL)
8461 JP M,Bg_DrawColumn_25
8464 RRCA
8465 RRCA
8466 RRCA
8467 RRCA
8468 AND $07
846A EX DE,HL
846B ADD A,(HL)
846C DAA
846D LD (HL),A
846E JR NC,Bg_DrawColumn_22
8470 INC HL
8471 INC (HL)
Bg_DrawColumn_22 8472 EX DE,HL
8473 LD A,(HL)
8474 AND $0F
8476 LD (HL),A
8477 LD A,(Level_Char)
847A CP $68
847C JR NZ,Bg_DrawColumn_25
847E LD A,(IX+$08)
8481 AND $7F
8483 CP $65
8485 JR NZ,Bg_DrawColumn_23
8487 LD A,(_bd0c_central_)
848A CP $01
848C JR NZ,Bg_DrawColumn_25
848E JR Bg_DrawColumn_24
Bg_DrawColumn_23 8490 CP $69
8492 JR NZ,Bg_DrawColumn_25
8494 LD A,(_bd0c_central_)
8497 CP $02
8499 JR NZ,Bg_DrawColumn_25
Bg_DrawColumn_24 849B INC A
849C LD (_bd0c_central_),A
Bg_DrawColumn_25 849F BIT 2,(HL)
84A1 CALL NZ,Warning_Herald
84A4 BIT 3,(HL)
84A6 CALL NZ,_85f4
84A9 LD A,(HL)
84AA AND $03
84AC CALL NZ,Warning_Sept
84AF LD A,(IX+$08)
84B2 AND $7F
84B4 LD ($BD65),A
Bg_DrawColumn_26 84B7 LD DE,$0022
84BA LD L,(IX+$02)
84BD LD H,(IX+$03)
84C0 AND A
84C1 SBC HL,DE
84C3 LD ($BE14),HL
84C6 LD L,(IX+$04)
84C9 LD H,(IX+$05)
84CC ADD HL,DE
84CD LD ($BE18),HL
84D0 JP Level_TextPrint
Prev: 8269 Up: Map Next: 84D3