| Prev: 68C5 | Up: Map | Next: 6927 |
68E9: Initialize bridge state for current player
|
Clears the top attribute row, removes any active tank shell, and calculates the starting bridge index based on the current player's saved progress.
Bridge progression algorithm: The game has 48 unique bridge sections (1-48). Each bridge has 64 terrain fragments. When a player's progress exceeds 48, the algorithm calculates a wraparound: new_bridge = ((progress - 48) mod 15) + 33. This creates an infinite loop through bridges 33-48 (15 bridges) after completing all 48.
|
||||
| init_current_bridge | 68E9 | LD HL,$5800 | Initialize to clear top attribute row (32 bytes). | |
| 68EC | LD B,$20 | |||
| clear_top_attributes_loop | 68EE | LD (HL),$00 | Clear byte, advance pointer, loop 32 times. | |
| 68F0 | INC HL | |||
| 68F1 | DJNZ clear_top_attributes_loop | |||
| 68F3 | CALL remove_tank_shell | Clear tank shell and helicopter missile state. | ||
| 68F6 | LD ($5F73),HL | |||
| 68F9 | LD A,($5F6A) | Load current player's bridge progress (swaps for player 2). | ||
| 68FC | LD B,A | |||
| 68FD | LD A,($923D) | |||
| 6900 | CP $02 | |||
| 6902 | CALL Z,get_player_2_bridge | |||
| 6905 | LD A,B | Check if progress exceeds initial section threshold (48). | ||
| 6906 | DEC A | |||
| 6907 | LD DE,$0030 | |||
| 690A | LD H,$00 | |||
| 690C | LD L,A | |||
| 690D | OR A | |||
| 690E | SBC HL,DE | |||
| 6910 | JP M,finalize_bridge_index | |||
| 6913 | LD E,$0F | Load section size (15) for division. | ||
| divide_progress_loop | 6915 | OR A | Divide excess progress by 15 to find wraparound offset. | |
| 6916 | SBC HL,DE | |||
| 6918 | JP P,divide_progress_loop | |||
| 691B | ADD HL,DE | |||
| 691C | LD E,$21 | |||
| finalize_bridge_index | 691E | ADD HL,DE | Calculate final bridge index and fill river attributes. | |
| 691F | LD A,L | |||
| 6920 | INC A | |||
| 6921 | LD ($5EF0),A | |||
| 6924 | JP fill_river_attributes | |||
| Prev: 68C5 | Up: Map | Next: 6927 |