Note that most functions in this game are essentially written in a higher-level computer language than 6502. By using a jump table, more complex operations are able to be identified by single hex codes. These functions are prefaced by "20 09 E5 ## ##" (JSR $E509) and terminated by the operation "CF". (## ## indicates how many memory spaces need to be dedicated to the new function, written as an inverse. A function that requires no new memory space will say "00 00", while one that requires 16 spaces will say "F0 FF".
Sometimes one of these functions will jump to a subroutine which is written "normally" (without upper-level operations). These routines are prefaced by "20 E3 E2 ## ## ##" (JSR $E2E3).
A list of these operations is located here. This same system seems to be used by the other MMC5 Koei games.
Page E0 ($A000-$BFFF)
ROM location: 0x00010-0x0200F
Prints graphic (5) to tile coordinates (1),(3)
Checks if City 1 (1/2) can sail to City 2 (3/4). (5) = whether sea control matters
Checks if it's safe to sail from City (1/2). Returns 0 if city is landlocked or sea is controlled by a hostile nation; otherwise, returns 1.
Checks if officer (1/2) is player-controlled.
Checks if commander of city (1/2) is player-controlled.
Checks if city (1/2) is adjacent to city (3/4) [by either land or sea]
Tallies & makes a list at (3/4) of nations meeting criteria (5).
Code Criteria Child function 0C Living $A805 0D Allied with (01/02) $A80F
Check if nation (3/4) exists. (Parameter 1/2 serves no function)
Verifies checksum when loading game(?)
Erase sprites #(1) to #(1)+(3)
Tallies nation (1)'s (3):
00 = Number of cities 01 = Avg. food sufficiency? 02 = Avg. material sufficiency? 08 = Number of cities set as supply bases 0B = Number of centers of power
Determines which nation has control of sea (1/2).
00 = Baltic, 01 = North, 02 = Atlantic, 03 = Mediterranean
Page E1 ($8000-$9FFF)
ROM location: 0x02010-0x0400F
Print graphic (1) to coordinate 16,14.
Prints the text "More will have no effect" & waits 3 time units for input before advancing.
Prints the text "No [x]", where [x] is entry #(1) in Page F8, Table 3
Identifies map location of city (01/02) from table $9F9F
Center map on city (1/2) and change banner to nation (3/4)
Retrieve text string (1) from Page F7.
Retrieve text string (1) from Page F8.
Retrieve text string (1) from Page F9 (Table $B076).
Retrieve text string (1) from Table 2 of Page F7
Retrieve text string (1) from Table 3 of Page F7
Print text string (1/2) as an officer quote.
Returns the difference in French aggression values between nations (1/2) and (3/4).
Finds the officer in a city with the best given stat.
Checks if France has won the game (captured all cities).
Table of cities by their map locations.
01 = Northwest, 02 = Northeast, 03 = Southwest, 04 = Southeast
01 DUBLIN 01 02 EDINBURGH 01 03 LIVERPOOL 01 04 BRISTOL 01 05 LONDON 01 06 CHRISTIANIA 01 07 STOCKHOLM 02 08 COPENHAGEN 01 09 AMSTERDAM 01 10 LUBECK 01 11 BERLIN 01 12 WARSAW 02 13 KONIGSBERG 02 14 STPETERSBURG 02 15 MINSK 02 16 SMOLENSK 02 17 MOSCOW 02 18 KIEV 02 19 KLAUSENBURG 04 20 BUCHAREST 04 21 BUDAPEST 04 22 VIENNA 04 23 PRAGUE 02 24 MUNICH 03 25 FRANKFURT 01 26 LILLE 01 27 ST.MALO 03 28 PARIS 03 29 BORDEAUX 03 30 LYON 03 31 MARSEILLES 03 32 MILAN 03 33 FLORENCE 04 34 VENICE 04 35 SARAJEVO 04 36 BELGRADE 04 37 ROME 04 38 NAPLES 04 39 ISTANBUL 04 40 ATHENS 04 41 CORUNNA 03 42 LISBON 03 43 GIBRALTAR 03 44 MADRID 03 45 SARAGOSSA 03 46 BARCELONA 03
Page E2 ($A000-$BFFF)
ROM location: 0x04010-0x0600F
Checks unit type of officer (1/2)
00 = Men (Infantry), 01 = Horses (Cavalry), 02 = Cannons (Artillery)
Finds officer with appropriate stat to be acting officer
Check if city has permission to attack. If a CPU officer is requesting an expedition, it prints that screen & awaits player input.
If autoplay is on, current city is not French, or Scenario is 1/2, return 1 (auto success).
Return 0 if player denies expedition. Return 1 if player grants expedition.
Return 2 if player attempted to deny expedition but officer disobeyed (Can randomly happen if officer has Simple trait).
Tallies number of men assigned to officers in active city. If city has fewer than three officers, returns 0.
Page E3 ($A000-$BFFF)
ROM location: 0x06010-0x0800F
Upgrades active city's sufficiency value based on investment by player.
(1) = Sufficiency type (00 = Food, 01 = Mat, 02 = Med)
Checks if city (1/2)'s harbors are frozen over (Baltic in winter).
Calculates damages to fleets (1/2) (French) and (3/4) (enemy) during sea battle.
Determines whether Nelson appears in a sea battle.
Sea battle (enemy discovers your ships).
Check if supply shipment is raided by Cossack soldiers or guerrillas.
Page E4 ($A000-$BFFF)
ROM location: 0x08010-0x0A00F
Page E5 ($A000-$BFFF)
ROM location: 0x0A010-0x0C00F
Set relationship between nations (1) and (3) to (5).
Trying to make an alliance.
Page E6 ($A000-$BFFF)
ROM location: 0x0C010-0x0E00F
Page E7 ($A000-$BFFF)
ROM location: 0x0E010-0x1000F
Officer (1/2) becomes a POW of nation (3/4)
Determines whether city resists invasion.
Play animation of invading officers moving to target city.
Determine losses to army?
Check if officer (1/2) is captured. (00 = Failure, 01 = Success)
Data table of the proper settings of the 4 lower bits of Napoleon's status based on the current Scenario
1 = 05 2 = 05 3 = 06 4 = 07 5 = 07 (Scenario 5 is not in the NES version; this is leftover data from being ported)
Page E8 ($A000-$BFFF)
ROM location: 0x10010-0x1200F
Contains functions pertaining to CPU actions during the city phase.
Main function for all CPU city actions.
A8E4 AA D1 7C / Push $7CD1/$7CD2 to stack / (+2) Active city A8E7 E9 DB BA 02 / Run function $BADB / (-2)
Toggles supply status flags for the active city based on command (1).
00: Turn on flag #$40: Food supply low 01: Turn off flag #$40: Food supply high 02: Turn on flag #$80: Material supply low Else: Turn off flag #$80: Material supply high
Improves sufficiency value (1) of active city. (00 = Food, 01 = Material)
Spends the amount of gold specified in $78BC/$78BD to recruit soldiers.
[X] gold = Soldier reserves increased and population decreased by [X/3] Food decreased by [X/5]
Active city spends gold to purchase horses (up to 9999).
Page E9 ($A000-$BFFF)
ROM location: 0x12010-0x1400F
Checks if nations (1/2) and (3/4) are in good standing.
Returns 00 if hostile or neutral w/ difference in aggression 5 or more Returns 01 if friendly/allied or neutral w/ difference in aggression 4 or less
Checks if nations (1/2) and (3/4) are in bad standing.
Returns 00 if friendly or difference in aggression 75 or less Returns 01 if not friendly & difference in aggression 76 or more
Checks if nations (1/2) and (3/4) are friendly.
Checks if nations (1/2) and (3/4) are hostile.
Returns #$00 if no. Returns #$20 if yes.
Checks if nations (1/2) and (3/4) are on good terms and if so, attempts friendship?
Prints text "Press any button".
Display acting officer as active nation's envoy.
Prints text "[Active nation] .. [text string (01)] .. [Target nation]"
Set diplomatic status of Active and Target nations to (01).
Page EA ($8000-$9FFF)
ROM location: 0x14010-0x1600F
ROM location: 0x16010-0x1800F
ROM location: 0x18010-0x1A00F
Page ED ($8000-$9FFF)
ROM location: 0x1A010-0x1C00F
ROM location: 0x1C010-0x1E00F
Page EF ($8000-$9FFF)
ROM location: 0x1E010-0x2000F
ROM location: 0x20010-0x2200F
ROM location: 0x22010-0x2400F
Start-of-Month Phase main loop
Month advance + Start-of-Month prep
Load event icon (1)
Nation (1/2) becomes a satellite of nation (3/4)
Print death text of officer (1/2)
Officer (1/2) dies of old age.
Officer age-up & random deaths
Check if two nations are adjacent by land.
Nation (1/2) requests protection from France
ROM location: 0x24010-0x2600F
Check for protection requests
Tick down alliance timers
ROM location: 0x26010-0x2800F
ROM location: 0x28010-0x2A00F
ROM location: 0x2A010-0x2C00F
ROM location: 0x2C010-0x2E00F
ROM location: 0x2E010-0x3000F
ROM location: 0x30010-0x3200F
ROM location: 0x32010-0x3400F
Page FA ($A000-$BFFF)
ROM location: 0x34010-0x3600F
Table of Nations
$A004 + #$0A x (Nation code) = Beginning of nation data starting with name and ending with hidden stat.
Table of Cities
$A09A + #$20 x (City code) = Beginning of city data starting with name and ending with hidden stat.
Table of Officers
$A650 + #$11 x (Officer code) = Beginning of officer data starting with name and ending with hidden stat.
See Notes for more detail on hidden stats.
ROM location: 0x36010-0x3800F
ROM location: 0x38010-0x3A00F
ROM location: 0x3A010-0x3C00F
Page FE ($C000-$DFFF)
ROM location: 0x3C010-0x3E00F
Main game loop. Executes all game functions then waits until interrupt
C008 61 / Push #$01 to stack / (+2) C009 E9 6F CF 02 / Run function $CF6F / (-2) C00D 8D 1F / Push #$1F to stack / (+2) C00F 60 / Push #$00 to stack / (+2) C010 E9 C9 CF 04 / Run function $CFC9 / (-4) C014 8D 14 / Push #$14 to stack / (+2) C016 67 / Push #$07 to stack / (+2) C017 E9 BC C3 04 / Run function $C3BC / (-4) C01B AA 00 60 / Push $6000/$6001 to stack / (+2) C01E 8E 16 DF / Push #$DF16 to stack / (+2) C021 E9 27 C6 04 / Run function $C627 / (-4) C025 61 / Push #$01 to stack / (+2) C026 64 / Push #$04 to stack / (+2) C027 E9 1E EF 04 / Run function $EF1E / (-4) C02B B3 / Push M8 to stack / (+2) C02C 8E 22 DF / Push #$DF22 to stack / (+2) C02F E9 27 C6 04 / Run function $C627 / (-4) C033 62 / Push #$02 to stack / (+2) C034 64 / Push #$04 to stack / (+2) C035 E9 1E EF 04 / Run function $EF1E / (-4) C039 B3 / Push M8 to stack / (+2) C03A 8E 2A DF / Push #$DF2A to stack / (+2) C03D E9 27 C6 04 / Run function $C627 / (-4) C041 D6 41 C0 / Jump to $C041 / Stall until interrupt C044 CF / Exit
Wait for (1) frames
Wait for 6*(1) frames
Wait (1) time units for input before advancing message automatically
Time unit = 5*(message speed) frames
Officer gains 1 EXP.
Parameter 1/2 = Officer address
C237 0C / Store parameter 1/2 to M8 / Officer address C238 76 / Add #$06 to M8 / Officer exp address C239 2B / Store M8 to storage 1/2 C23A 0B / Store storage 1/2 to M8 C23B B3 / Push M8 to stack / (+2) C23C D3 / Replace M8 with 1-byte value / Officer exp (old) C23D D0 / Increment M8 / +1 exp C23E D4 / Pull 2 meta, store $0008 / (-2) Update exp C23F 0B / Store meta 01/02 to M8 C240 D3 / Replace M8 with 1-byte val / Officer exp (new) C241 8B 64 / Store #$64 to MC C243 C9 / Check if M8 >= MC / Check if 100+ C244 D8 4F C2 / Jump to $C24F if not / Exit C247 3B / Push storage 1/2 to stack / (+2) C248 40 / Store #$00 to M8 C249 D4 / Pull 2 meta, store $0008 / (-2) Roll EXP over to 00 C24A 3C / Push params 1/2 to stack / (+2) C24B E9 D6 C1 02 / Run function $C1D6 / (-2) Officer Levels Up C24F CF / Exit
Retrieve city of officer (1/2)
Retrieve nation of city (1/2)
Print text string (1/2)
Print text string (1/2), replacing %s with (3/4) [and %d with (5/6)]
Advances random number generator then checks for controller input (1)
0 = both controllers (1 then 2), 1 = controller 1, 2 = controller 2
Reduce value at address (1/2) by (3/4)%. Returns difference
Checks if BGM is on, and plays audio (1) if so?
Retrieve name of nation (1/2).
Retrieve name of officer (1/2).
Retrieve list of cities adjacent by land to (1/2).
Retrieve hidden stat (3) for city (1/2).
Retrieve hidden stat (1) for officer (1/2).
00 = Personality traits
Change to screen template (1)
Reduce value at address (1/2) by (3/4)%
Tally # of men assigned to officers in city (1/2).
Tally # of officers in city (1/2).
Isolate flags (3) in (1). (bitwise AND)
Generate random number from #$0000-#$7FFF
Update RNG seed (done after $D69D)
Generate random number between #$00 and #$(1/2)
Find smaller of values (1/2) and (3/4)
Find larger of values (1/2) and (3/4)
Take ratio (3)/(5) of value (1)
Find (3)% of (1)
Add (3/4) to 2-byte value (1/2) up to a max of (5/6)
Add (3/4) to 1-byte value (1/2) up to a max of (5/6)
Reduce 2-byte value at (1/2) by (3) to a minimum of zero
Reduce 1-byte value at (1/2) by (3) to a minimum of zero
Page FF ($E000-$FFFF)
ROM location: 0x3E010-0x4000F
Initialized PRG bank switches on power-on.
Prep for assembly functions.
20 E3 E2 XX XX
BEFORE FUNCTION RUN (Preserve values?)
0F:E2E3:68 PLA 0F:E2E4:85 08 STA $0008 ; XX\ 0F:E2E6:68 PLA ; | Values stored after JSR 0F:E2E7:85 09 STA $0009 ; XX/ 0F:E2E9:18 CLC 0F:E2EA:68 PLA 0F:E2EB:69 01 ADC #$01 0F:E2ED:85 00 STA $0000 ;\ 0F:E2EF:68 PLA ; \ 0F:E2F0:69 00 ADC #$00 ; / Return address 0F:E2F2:85 01 STA $0001 ;/ 0F:E2F4:A0 07 LDY #$07 0F:E2F6:38 SEC 0F:E2F7:A5 02 LDA $0002 ;\ 0F:E2F9:E9 09 SBC #$09 ; \ 0F:E2FB:85 0C STA $000C ; \ 0F:E2FD:A5 03 LDA $0003 ; | Augmented stack address 0F:E2FF:E9 00 SBC #$00 / 0F:E301:85 0D STA $000D ; / 0F:E303:B9 00 00 LDA $0000,Y 0F:E306:91 0C STA ($0C),Y ; Store values $0000-$0007 onto stack 0F:E308:88 DEY ; for later retrieval 0F:E309:10 F8 BPL $E303
0F:E30B:A0 01 LDY #$01 0F:E30D:38 SEC 0F:E30E:A5 0C LDA $000C ; Augmented stack address 0F:E310:85 04 STA $0004 ; 0F:E312:F1 08 SBC ($08),Y ; Adjust for # of storage needed 0F:E314:85 06 STA $0006 ; 0F:E316:A5 0D LDA $000D ; 0F:E318:85 05 STA $0005 ; 0F:E31A:E9 00 SBC #$00 0F:E31C:85 07 STA $0007 0F:E31E:B1 08 LDA ($08),Y 0F:E320:A0 08 LDY #$08 0F:E322:91 04 STA ($04),Y 0F:E324:A8 TAY 0F:E325:F0 09 BEQ $E330 0F:E327:88 DEY 0F:E328:B9 80 00 LDA $0080,Y 0F:E32B:91 06 STA ($06),Y 0F:E32D:88 DEY 0F:E32E:10 F8 BPL $E328 0F:E330:A0 02 LDY #$02 0F:E332:18 CLC 0F:E333:A5 06 LDA $0006 0F:E335:71 08 ADC ($08),Y 0F:E337:85 02 STA $0002 0F:E339:C8 INY 0F:E33A:A5 07 LDA $0007 0F:E33C:71 08 ADC ($08),Y 0F:E33E:85 03 STA $0003 0F:E340:C6 07 DEC $0007 0F:E342:18 CLC 0F:E343:A5 08 LDA $0008 ; 0F:E345:69 04 ADC #$04 ; 0F:E347:85 08 STA $0008 ; 0F:E349:90 02 BCC $E34D ; 0F:E34B:E6 09 INC $0009 ; Advance to function 0F:E34D:A9 E3 LDA #$E3 ; 0F:E34F:48 PHA ; 0F:E350:A9 5A LDA #$5A ; Set return address to next part of this function 0F:E352:48 PHA ; 0F:E353:A9 00 LDA #$00 0F:E355:AA TAX 0F:E356:A0 01 LDY #$01 0F:E358:6C 08 00 JMP ($0008)
AFTER FUNCTION RUN (Restore values?)
0F:E35B:E6 07 INC $0007 0F:E35D:A0 08 LDY #$08 0F:E35F:B1 04 LDA ($04),Y 0F:E361:A8 TAY 0F:E362:F0 09 BEQ $E36D 0F:E364:88 DEY 0F:E365:B1 06 LDA ($06),Y 0F:E367:99 80 00 STA $0080,Y 0F:E36A:88 DEY 0F:E36B:10 F8 BPL $E365 0F:E36D:A5 04 LDA $0004 0F:E36F:85 0C STA $000C 0F:E371:A5 05 LDA $0005 0F:E373:85 0D STA $000D 0F:E375:A0 07 LDY #$07 0F:E377:B1 0C LDA ($0C),Y 0F:E379:99 00 00 STA $0000,Y 0F:E37C:88 DEY 0F:E37D:10 F8 BPL $E377 0F:E37F:6C 00 00 JMP ($0000)
Prep for higher-level functions.
Runs a subroutine based on operation code (1)
02 - Set Bank (3) to page (5) and run it from the beginning 03 - Set $5113,(3) to (5) (01 = Bank 0 ($8000-$9FFF), etc) 10 - Store controller input (3) to $66 (00 = C1, 01 = C2) 11 - Wait for (3/4) frames 18 - Check current music track ? 19 - Play music track (3)?
Multiply M8 by MC.
Divide M8 by MC (0=clear prev result?)
Store (5) (3) times beginning at address (1/2)