Link

Combat

Table of contents

  1. Initialize
  2. Work Out Which Combat Map to Load

Initialize

Print **** COMBAT ****

6FB0    20 21 08    JSR $0821       ; PRINT

6FB3    8D 8D                                                   ^M^M
6FB5    AA AA AA AA A0 C3 CF CD C2 C1 D4 A0 AA AA AA AA         **** COMBAT ****
6FC5    8D 8D 00                                                ^M^M^@

Store the value of $C0 in $E6 (we’ll come back later to work out what these are)

6FC8    A5 C0       LDA $C0
6FCA    85 E6       STA $E6

Zero out the $EFXX page (the onscreen map?)

6FCC    A2 00       LDX #$00
6FCE    8A          TXA

6FCF    9D 00 EF    STA $EF00,X
6FD2    CA          DEX
6FD3    D0 FA       BNE $6FCF

Work Out Which Combat Map to Load

if $0E >= 0x14 and $C8 is NOT a ship (0x10 - 0x13), go to $7004

otherwise continue

6FD5    A5 0E       LDA $0E
6FD7    C9 14       CMP #$14
6FD9    90 0A       BCC $6FE5

6FDB    A5 C8       LDA $C8
6FDD    C9 14       CMP #$14
6FDF    B0 23       BCS $7004

6FE1    C9 10       CMP #$10
6FE3    90 1F       BCC $7004

So, $0E is less than 0x14 OR $C8 is a ship.

If $C0 == 0x80, set $E6 to be 0xC8 and load combat map CONT (two ships)

otherwise continue

6FE5    A5 C0       LDA $C0
6FE7    C9 80       CMP #$80
6FE9    D0 09       BNE $6FF4

6FEB    A9 C8       LDA #$C8
6FED    85 E6       STA $E6
6FEF    A9 D4       LDA #$D4        ; 'T'
6FF1    4C 6D 70    JMP $706D

($0E is less than 0x14 OR $C8 is a ship) ($C0 is NOT 0x80)

If $C3 is less than 0x03 (i.e. it’s water), load combat map CONP (ship at sea)

otherwise load combat map CONE (ship with land to north).

6FF4    A5 C3       LDA $C3
6FF6    C9 03       CMP #$03
6FF8    90 05       BCC $6FFF

6FFA    A9 C5       LDA #$C5        ; 'E'
6FFC    4C 6D 70    JMP $706D

6FFF    A9 D0       LDA #$D0        ; 'P'
7001    4C 6D 70    JMP $706D

We get to $7004 if $0E >= 0x14 and $C8 is NOT a ship (0x10 - 0x13).

If $C0 is 0x80, set $E6 to 0xC8 and load combat map CONI (ship with land to south) otherwise (if $C0 is NOT 0x80) if $C3 is less than 0x03 (i.e. it’s water), load combat map CONO (coastal) otherwise ($C3 is NOT water) go to next section and choose map based on $C8.

7004    A5 C0       LDA $C0
7006    C9 80       CMP #$80
7008    D0 09       BNE $7013

700A    A9 C8       LDA #$C8
700C    85 E6       STA $E6
700E    A9 C9       LDA #$C9        ; 'I'
7010    4C 6D 70    JMP $706D

7013    A5 C3       LDA $C3
7015    C9 03       CMP #$03
7017    B0 05       BCS $701E

7019    A9 CF       LDA #$CF        ; 'O'
701B    4C 6D 70    JMP $706D

To summarize the above

$0E < 0x14 OR $C8 is a ship $C0 == 0x80 $C3 < 0x03 CON_ map
y y   T two ships
y n y P ship at sea
y n n E ship with land to north
n y   I ship with land to south
n n y O coastal
n n n   see next table

Choose map based on value in $C8

$C8 tile CON_ map
0x03 swamp S swamp
0x05 light forest B grass 1
0x06 heavy forest F forest
0x07 hills H hills
0x16 cobblestone D cobblestone
0x3E brick paving C brick
0x17 bridge 1 R bridge
0x19 bridge 2 R bridge
0x1A bridge 3 R bridge
0x3F bridge 4 R bridge
  otherwise G grass 2
701E    A5 C8       LDA $C8

7020    C9 03       CMP #$03        ; if == 0x03
7022    D0 05       BNE $7029
7024    A9 D3       LDA #$D3        ; 'S'
7026    4C 6D 70    JMP $706D

7029    C9 05       CMP #$05        ; if == 0x05
702B    D0 05       BNE $7032
702D    A9 C2       LDA #$C2        ; 'B'
702F    4C 6D 70    JMP $706D

7032    C9 06       CMP #$06        ; if == 0x06
7034    D0 05       BNE $703B
7036    A9 C6       LDA #$C6        ; 'F'
7038    4C 6D 70    JMP $706D

703B    C9 07       CMP #$07        ; if == 0x07
703D    D0 05       BNE $7044
703F    A9 C8       LDA #$C8        ; 'H'
7041    4C 6D 70    JMP $706D

7044    C9 16       CMP #$16        ; if == 0x16
7046    D0 05       BNE $704D
7048    A9 C4       LDA #$C4        ; 'D'
704A    4C 6D 70    JMP $706D

704D    C9 3E       CMP #$3E        ; if == 0x3E
704F    D0 05       BNE $7056       ;
7051    A9 C3       LDA #$C3        ; 'C'
7053    4C 6D 70    JMP $706D

7056    C9 17       CMP #$17        ; if == 0x17
7058    F0 0C       BEQ $7066
705A    C9 19       CMP #$19        ; if == 0x19
705C    F0 08       BEQ $7066
705E    C9 1A       CMP #$1A        ; if == 0x1A
7060    F0 04       BEQ $7066
7062    C9 3F       CMP #$3F        ; if == 0x3F
7064    D0 05       BNE $706B

7066    A9 D2       LDA #$D2        ; 'R'
7068    4C 6D 70    JMP $706D

706B    A9 C7       LDA #$C7        ; otherwise 'G'