L'Empereur/ROM map

From Data Crystal
Revision as of 14:27, 24 January 2024 by Hawk (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Chip tiny.png The following article is a ROM map for L'Empereur.

The notation I use for page numbers is the same as the hex value that is stored to the corresponding RAM bank value for switching. For example, 0xE0 accesses the first half of ROM page 0x00, 0xE1 accesses the second half, and so on. Sometimes the game loads both halves of a page into RAM $8000-$BFFF, or sometimes it loads two halves from different ROM pages into $8000-$9FFF and $A000-$BFFF.

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" in 6502 (without upper-level operations). These routines are prefaced by "20 E3 E2" (JSR $E2E3).

An assembly function that jumps to an upper-level function will be prefaced by "20 82 E3" (JSR $E382) followed by which function to run & how many stack values to pull as parameters.

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

E0:A03A

Prints graphic (5) to tile coordinates (1),(3)

E0:A2CC

Checks if City 1 (1/2) can sail to City 2 (3/4). (5) = whether sea control matters

E0:A327

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.

E0:A39C

Checks if officer (1/2) is player-controlled.

E0:A3E0

Checks if commander of city (1/2) is player-controlled.

E0:A425

Checks if city (1/2) is adjacent to city (3/4) [by either land or sea]

E0:A443

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

E0:A559

Erase Men/Horses/Cannons & Training values for officer (1/2).

E0:A578

Attempts to add officer (1/2) to city (3/4).

Returns 1 if successful. Returns 0 if city is full.

E0:A5B3

Attempts to add officer (1/2) to nation (3/4)'s reserve list.

Returns 1 if successful. Returns 0 if list is full.

E0:A805

Check if nation (3/4) exists. (Parameter 1/2 serves no function)

E0:A8A0

Sets the x,y text coordinates to a position relative to the text window coordinates.

  • Preloaded 01/02 = Relative x-position.
  • Preloaded 03/04 = Relative y-position.
A8B3 A4 EA 7C    / Store $7CEA/$7CEB to M8           /      Text window y-position
A8B6 1D          / Store preloaded 03/04 to MC
A8B7 BB          / Add MC to M8                      /      Advance by relative y-position
A8B8 D0          / Increment M8                      /      +1 (accounts for window border)
A8B9 B3          / Push M8 to metastack              / (+2) Adjusted y-position
A8BA A4 E8 7C    / Store $7CE8/$7CE9 to M8           /      Text window x-position
A8BD 1C          / Store preloaded 01/02 to MC
A8BE BB          / Add M8 to MC                      /      Advance by relative x-position
A8BF D0          / Increment M8                      /      +1 (accounts for window border)
A8C0 B3          / Push M8 to metastack              / (+2) Adjusted x-position
A8C1 E9 BC C3 04 / Run function $C3BC                / (-4) Set text position
A8C5 CF          / Exit

E0:A99D

Erase sprites #(1) to #(1)+(3)

E0:B4E6

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

E0:BC7E

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

E1:86B6

Print graphic (1) to coordinate 16,14.

E1:8A1A

Prints the text "More will have no effect" & waits 3 time units for input before advancing.

E1:8A2C

Prints the text "No [x]", where [x] is entry #(1) in Page F8, Table 3

E1:8BA5

Identifies map location of city (01/02) from table $9F9F

E1:8BB8

Center map on city (1/2) and change banner to nation (3/4)

E1:8C4A

Retrieve text string (1) from Page F7.

E1:8C5B

Retrieve text string (1) from Page F8.

E1:8C6C

Retrieve text string (1) from Page F9 (Table $B076).

E1:8C8E

Retrieve text string (1) from Table 2 of Page F7

E1:8CA8

Retrieve text string (1) from Table 3 of Page F7

E1:8D4B

Print text string (1/2) as an officer quote.

E1:8DF1

Returns the aggression value between nations (1/2) and (3/4) by finding the difference between their Aggression vs. France.

E1:93C7

Sorts the officer list of city (1/2) by criteria (3).

Possible sort types are located in the table $9FE8.

E1:9D13

Finds the officer in a city with the best given stat.

E1:9D73

Checks if France has won the game (captured all cities).

E1:9F9F

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

E1:9FE8

Table used by function $9367 to determine sort type for officer list.

Code Function Sort Criteria
 00   $8E36  
 01   $8E6C
 02   $8EA2    
 03   $8EAB
 04   $8EB4
 05   $8FC0

Page E2 ($A000-$BFFF)

ROM location: 0x04010-0x0600F

E2:A01F

Checks unit type of officer (1/2)

00 = Men (Infantry), 01 = Horses (Cavalry), 02 = Cannons (Artillery)

E2:A0D9

Finds officer with appropriate stat to be acting officer

E2:A3EB

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).

E2:AEFA

Nation ID (01) is destroyed.

E2:B94C

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

E3:A664

Upgrades active city's sufficiency value based on investment by player.

(1) = Sufficiency type (00 = Food, 01 = Mat, 02 = Med)

E3:B209

Checks if city (1/2)'s harbors are frozen over (Baltic in winter).

E3:B2C5

Calculates damages to fleets (1/2) (French) and (3/4) (enemy) during sea battle.

E3:B316

Determines whether Nelson appears in a sea battle.

E3:B3DC

Sea battle (enemy discovers your ships).

E3:B652

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

E5:A05C

Recruiting POWs.

E5:A563

Exporting resources.

E5:A8FD

Set relationship between nations (1) and (3) to (5).

E5:AA0B

Trying to make an alliance.

Page E6 ($A000-$BFFF)

ROM location: 0x0C010-0x0E00F

Page E7 ($A000-$BFFF)

ROM location: 0x0E010-0x1000F

E7:A013

Officer (1/2) becomes a POW of nation (3/4)

E7:A354

Determines whether city resists invasion.

E7:A4E6

Play animation of invading officers moving to target city.

E7:B153

Determine losses to army?

E7:B743

Check if officer (1/2) is captured. (00 = Failure, 01 = Success)

E7:BF1A

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.

E8:A03C

Runs preliminary tests to see if the active city is prepared to invade.

The tests that must be passed are:

Gold <= floor(Soldiers/100) + Officers
Food <= Soldiers
Officers <= 3
A041 A4 AA 78    / Store $78AA/$78AB to M8      / Possible invasion target
A044 A8 D3 7C    / Store M8 to $7CD3/$7CD4      / Set as Target City
A047 A4 D3 7C    / Store $7CD3/$7CD4 to M8
A04A D8 8D A0    / Jump to $A08D if blank       / Return 0
A04D A4 D1 7C    / Store $7CD1/$7CD2 to M8      / Active City 
A050 7E          / Add #$0E to M8
A051 B0          / Replace M8 with 2-byte value / Gold
A052 B3          / Push M8 to stack             / (+2) 
A053 A4 B6 78    / Store $78B6/$78B7 to M8      / Total soldiers
A056 8B 64       / Store #$64 to MC             / 100
A058 B8          / Divide M8 by MC
A059 B3          / Push M8 to stack             / (+2)
A05A A5 B8 78    / Store $78B8 to M8            / # of officers
A05D B4          / Pull 2 meta to MC            / (-2)
A05E BB          / Add MC to M8 
A05F B4          / Pull 2 meta to MC            / (-2)
A060 C7          / Check if M8 <= MC          
A061 D8 8D A0    / Jump to $A08D if not         / Return 0
A064 A4 D1 7C    / Store $7CD1/$7CD2 to M8      / Active city
A067 8F 10       / Add #$10 to M8
A069 B0          / Replace M8 with 2-byte value / Food
A06A B3          / Push M8 to stack             / (+2)
A06B A4 B6 78    / Store $78B6/$78B7 to M8      / Total soldiers
A06E B4          / Pull 2 meta to MC            / (-2)
A06F C7          / Check if M8 <= MC
A070 D8 8D A0    / Jump to $A08D if not         / Return 0
A073 8E 4C B9    / Push #$B94C to stack         / (+2)
A076 8E E2 00    / Push #$00E2 to stack         / (+2)
A079 62          / Push #$0002 to stack         / (+2)
A07A E9 79 DD 06 / Run function $DD79           / (-6) Tallies # of men assigned to officers? (fewer than 3 officers = 0)
A07E B3          / Push M8 to stack             / (+2)
A07F AA D1 7C    / Push $7CD1/$7CD2 to stack    / (+2) Active city
A082 E9 02 D4 02 / Run function $D402           / (-2) Tallies # of men assigned to officers
A086 51
A087 BE          / Divide M8 by 2
A088 B4          / Pull 2 meta to MC            / (-2)
A089 C7          / Check if M8 <= MC            /      Only fails if fewer than 3 officers due to caveat in $B94C
A08A D7 91 A0    / Jump to $A091 if so
A08D 40          / Store #$00 to M8
A08E D6 92 A0    / Jump to $A092
A091 41          / Store #$01 to M8
A092 CF          / Exit

E8:A863

Has to do with CPU commanders making requests to Napoleon.

First section is repeated twice for no apparent reason
A868 A4 D1 7C    / Store $7CD1/$7CD2 to M8      / Active City
A86B 72          / Add #$02 to M8
A86C B0          / Replace M8 with 2-byte value / Active City - Commander
A86D 2B          / Store M8 to storage 1/2
A86E A4 D1 7C    / Store $7CD1/$7CD2 to M8      / Active City - Commander
A871 72          / Add #$02 to M8
A872 B0          / Replace M8 with 2-byte value / Active City - Commander
A873 2B          / Store M8 to storage 1/2
A874 8C 05 60    / Store #$6005 to MC           
A877 C0          / Check if M8 = MC             / Check if commander is Napoleon
A878 D7 87 A8    / Jump to $A887 if so          / Exit 
A87B A5 EC 6F    / Store $6FEC to $0008         / Settings
A87E 8C 80 00    / Store #$0080 to MC
A881 DA          / M8 AND MC
A882 50          / Store #$00 to MC
A883 C1          / Check if M8 != MC            / Check if autoplay on
A884 D8 88 A8    / Jump to $A888 if not
A887 CF          / Exit
A888 AA D1 7C    / Push $7CD1/$7CD2 to stack    / (+2)
A88B E9 D2 C2 02 / Run function $C2D2           / (-2) Retrieve nation
A88F 8C 68 70    / Store #$7068 to MC
A892 C1          / Check if M8=MC               /      Check if city is French
A893 D8 BE A8    / Jump to $A8BE if not
A896 40          / Store #$00 to M8
A897 2B          / Store M8 to storage 1/2
A898 62          / Push #$02 to stack           / (+2)
A899 E9 D1 D7 02 / Run function $D7D1           / (-2) RNG 00-01
A89D B3          / Push M8 to stack             / (+2)
A89E A5 08 60    / Store $6008 to M8            /      Napoleon's city
A8A1 8B 1B       / Store #$1B to MC             /      Paris
A8A3 C1          / Check if M8 != MC            /      Check if Napoleon is away from Paris
A8A4 D8 AB A8    / Jump to $A8AB if not
A8A7 43          / Store #$03 to M8
A8A8 D6 AC A8    / Jump to $A8AC
A8AB 40          / Store #$00 to M8
A8AC B4          / Pull 2 meta to MC            / (-2)
A8AD BB          / Add MC to M8
A8AE A2 FD FF    / Store $0008 to storage 03
A8B1 A5 70 62    / Store $7062 to M8            /      ???
A8B4 D8 C4 A8    / Jump to $A8C4 if zero
A8B7 A0 FD FF    / Store meta 03 to $0008
A8BA D0          / Increment M8
A8BB D6 C1 A8    / Jump to $A8C1
A8BE AC AE A7    / Run function $A7AE
A8C1 A2 FD FF    / Store $0008 to storage 03
A8C4 A0 FD FF    / Store storage 3 to $0008
A8C7 8C FF 00    / Store #$00FF to MC
A8CA C1          / Check if M8 != MC
A8CB D8 DE A8    / Jump to $A8DE if not         / Exit
A8CE A0 FD FF    / Store meta 3 to $0008
A8D1 B3          / Push M8 to stack             / (+2)
A8D2 3B          / Push meta 1/2 to stack       / (+2)
A8D3 8E A5 A1    / Push #$A1A5 to stack         / (+2)
A8D6 8E E2 00    / Push #$00E2 to stack         / (+2)
A8D9 62          / Push #$0002 to stack         / (+2)
A8DA E9 79 DD 0A / Run function $DD79           / (-A)
A8DE CF          / Exit

E8:A8DF

A8E4 AA D1 7C    / Push $7CD1/$7CD2 to stack    / (+2) Active city
A8E7 E9 DB BA 02 / Run function $BADB           / (-2) Determines several values used later in the function, including a possible invasion target.
A8EB AA D1 7C    / Push $7CD1/$7CD2 to stack    / (+2) Active city
A8EE 8E 8C B2    / Push #$B28C to stack         / (+2)
A8F1 8E E2 00    / Push #$00E2 to stack         / (+2)
A8F4 62          / Push #$0002 to stack         / (+2)
A8F5 E9 79 DD 08 / Run function $DD79           / (-8) 
A8F9 A4 D1 7C    / Store $7CD1/$7CD2 to M8      /      Active city
A8FC 75          / Add #$05 to M8
A8FD B0          / Replace M8 with 2-byte value /      Population
A8FE A8 B4 78    / Store M8 to $78B4/$78B5
A901 A4 D1 7C    / Store $7CD1/$7CD2 to M8      /      Active City
A904 8F 14       / Add #$14 to M8
A906 B0          / Replace M8 with 2-byte value /      
A907 B3          / Push M8 to stack             / (+2) Soldier reserves
A908 AA D1 7C    / Push $7CD1/$7CD2 to stack    / (+2) Active City
A90B E9 02 D4 02 / Run function $D402           / (-2) Tally # of men assigned to officers
A90F B4          / Pull 2 meta values to MC     / (-2)
A910 BB          / Add MC to M8                 /      Total soldiers
A911 A8 B6 78    / Store M8 to $78B6/$78B7
A914 A4 D1 7C    / Store $7CD1/$7CD2 to M8      /      Active city
A917 72          / Add #$02 to M8
A918 B0          / Replace M8 with 2-byte value /      Commander
A919 B3          / Push M8 to stack             / (+2)
A91A E9 3B D4 02 / Run function $D43B           / (-2) Tally officers
A91E A9 B8 78    / Store $0008 to $78B8
A921 A4 D1 7C    / Store $7CD1/$7CD2 to M8      /      Active City
A924 7E          / Add #$0E to M8
A925 B0          / Replace M8 with 2-byte value /      Gold
A926 A8 E8 78    / Store M8 to $78E8/$78E9
A929 A4 D1 7C    / Store $7CD1/$7CD2 to M8      /      Active City
A92C 8F 10       / Add #$10 to M8
A92E B0          / Replace M8 with 2-byte value /      Food
A92F A8 EA 78    / Store M8 to $78EA/$78EB
A932 A4 D1 7C    / Store $7CD1/$7CD2 to M8      /      Active City
A935 8F 12       / Add #$12 to M8
A937 B0          / Replace M8 with 2-byte value /      Materials
A938 A8 EC 78    / Store M8 to $78EC/$78ED

A93B A4 AA 78    / Store $78AA/$78AB to M8      /      Check if there is an invasion target
A93E D7 47 A9    / Jump to $A947 if positive    /      Store #$00 if so
A941 A4 A8 78    / Store $78A8/$78A9 to M8      /      Check if there is an invasion threat
A944 D8 4B A9    / Jump to $A94B if zero        /      Store #$01 if not
A947 40          / Store #$00 to M8
A948 D6 4C A9    / Jump to $A94C
A94B 41          / Store #$01 to M8
A94C A2 FF FF    / Store $0008 to storage 1     /      #$01 = invasion threat, else #$00
... 
A94F A4 B6 78    / Store $78B6/$78B7 to M8      /      Active City - Total soldiers
A952 8B 64       / Store #$64 to MC
A954 B8          / Divide M8 by MC              /      Soldiers/100
A955 B3          / Push M8 to stack             / (+2)
A956 A4 D1 7C    / Store $7CD1/$7CD2 to M8
A959 8F 1A       / Add #$1A to M8
A95B D3          / Replace M8 with 1-byte value /      Active City - Fleet
A95C B3          / Push M8 to stack             / (+2)
A95D A5 B8 78    / Store $78B8 to $0008         /      Assigned soldiers
A960 B4          / Pull 2 meta to MC            / (-2)
A961 BB          / Add MC to M8                 /      Assigned Soldiers + Fleet
A962 5A          / Store #$0A to MC
A963 B5          / Multiply M8 by MC            /      10*(Assigned Soldiers+Fleet)
A964 B4          / Pull 2 meta to MC            / (-2)
A965 BB          / Add MC to M8                 /      10*(Assigned Soldiers+Fleet)+(Total Soldiers/100)
A966 A8 EE 78    / Store M8 to $78EE/$78EF
A969 A0 FF FF    / Store meta 01 to $0008
A96C D8 73 A9    / Jump to $A973 if zero        /      No invasion threat
A96F 44          / Store #$04 to M8
A970 D6 74 A9    / Jump to $A974

A973 48          / Store #$08 to M8             
A974 B3          / Push M8 to stack             / (+2) #$04 (invasion threat) or #$08 (no invasion threat)
A975 A5 E9 6F    / Store $6FE9 to $0008         /      Season
A978 B3          / Push M8 to stack             / (+2)
A979 45          / Store #$05 to M8
A97A B4          / Pull 2 meta to MC            / (-2)
A97B BC          / Subtract MC from M8 
A97C 53          / Store #$03 to MC
A97D DA          / M8 AND MC
A97E D0          / Increment M8
Results in the following values:
Summer = 01, Spring = 02, Winter = 03, Fall = 04
A97F B3          / Push M8 to stack             / (+2)
A980 AA B4 78    / Push $78B4/$78B5 to stack    / (+2) Active City - Population
A983 E9 CA DD 06 / Run function $DDCA           / (-6) (Population * Season Multiplier) / (4 or 8)
A987 A6 B6 78    / Store $78B6/$78B7 to MC      / Active City - Soldiers
A98A BB          / Add MC to M8
A98B A8 F0 78    / Store M8 to $78F0/$78F1
A98E A5 EA 6F    / Store $6FEA to $0008         / Scenario
A991 53          / Store #$03 to MC
A992 C9          / Check if M8 >= MC            / Scenario 3/4
A993 D8 C1 A9    / Jump to $A9C1 if not
A996 8E F4 01    / Push #$01F4 to stack         / (+2) 500
A999 E9 D1 D7 02 / Run function $D7D1           / (-2) RNG 000-499
A99D 50          / Store #$00 to MC
A99E C0          / Check if M8=MC
A99F A2 FF FF    / Store $0008 to storage 01    /      1/500 chance of being flagged
A9A2 A4 D1 7C    / Store $7CD1/$7CD2 to M8
A9A5 74          / Add #$04 to M8
A9A6 D3          / Replace M8 with 1-byte value /      Active City - Nation
A9A7 D7 B8 A9    / Jump to $A9B8 if not zero    /      If not French
A9AA A5 E8 6F    / Store $6FE8 to $0008         /      Month
A9AD 53          / Store #$03 to MC
A9AE BA          / MC AND M8
A9AF 52          / Store #$02 to MC
A9B0 C0          / Check if M8=MC               /      Feb,May,Aug,Nov
A9B1 D8 B8 A9    / Jump to $A9B8 if not
A9B4 41          / Store #$01 to M8
A9B5 A2 FF FF    / Store $0008 to storage 01
A9B8 A0 FF FF    / Store storage 01 to $0008
A9BB D8 C1 A9    / Jump to $A9C1 if zero
A9BE AC 63 A8    / Run function $A863          / Function that runs during Scenarios 3/4. There is a 1/500 chance it will run on a city's turn, with the exception of the months of Feb/May/Aug/Nov where it is guaranteed to run for every French city.
A9C1 AC 94 A6    / Run function $A694
A9C4 41          / Store #$01 to M8
A9C5 40          / Exit

E8:AA9B

Decides whether or not active city invades.

  • Storage 05/06: Active City - Commander
  • Storage 13/14: Active City - Adjusted strength
  • Storage 17: Active City - # of officers
  • Storage 19: Threshold for invasion
    • #$43 normally, #$0A if RNG check for Courageous commander succeeds
AAA0 A5 B8 78    / Store $78B8 to $0008         / Active City - # of officers
AAA3 A2 EF FF    / Store $0008 to storage 17
AAA6 A4 AA 78    / Store $78AA/$78AB to M8      / Possible target
AAA9 A8 D3 7C    / Store M8 to $7CD3/$7CD4      / Set as Target city
AAAC A4 D1 7C    / Store $7CD1/$7CD2 to M8      / Active City
AAAF 72          / Add #$02 to M8
AAB0 B0          / Replace M8 with 2-byte value / Active City - Commander
AAB1 29          / Store M8 to storage 05/06
AAB2 AA D1 7C    / Push $7CD1/$7CD2 to stack    / (+2)
AAB5 E9 02 D4 02 / Run function $D402           / (-2) # of assigned men
AAB9 25          / Store M8 to storage 13/14

AABA A5 B2 78    / Store $78B2 to $0008         / ???
AABD 51          / Store #$01 to MC
AABE C8          / Check if M8 > MC
AABF D8 CB AA    / Jump to $AACB if not
AAC2 61          / Push #$01 to stack           / (+2)
AAC3 DE F2 FF    / Store address of storage 14
AAC6 B3          / Push M8 to stack             / (+2)
AAC7 E9 6E DE 04 / Run function $DE6E           / (-4) Reduce men by 1?
AACB A4 D3 7C    / Store $7CD3/$7CD4 to M8
AACE 8F 10       / Add #$10 to M8
AAD0 B0          / Replace M8 with 2-byte value / Target City - Food
AAD1 D8 10 AB    / Jump to $AB10 if zero
AAD4 8D 10       / Push #$10 to stack           / (+2)
AAD6 60          / Push #$00 to stack           / (+2)
AAD7 39          / Push storage 05/06 to stack  / (+2) Active City - Commander
AAD8 E9 7A D1 04 / Run function $D17A           / (-4) Get personality traits
AADC B3          / Push M8 to stack             / (+2)
AADD E9 60 D4 04 / Run function $D460           / (-4) Check for Courage trait
AAE1 D8 F7 AA    / Jump to $AAF7 if zero
AAE4 A5 EA 6F    / Store $6FEA to $0008         / Scenario
AAE7 B3          / Push M8 to stack             / (+2)
AAE8 8D 64       / Push #$64 to stack           / (+2)
AAEA E9 D1 D7 02 / Run function $D7D1           / (-2) RNG 00-99
AAEE B4          / Pull 2 meta to MC            / (-2)
AAEF C6          / Check if M8 < MC
AAF0 D8 F7 AA    / Jump to $AAF7 if not
AAF3 4A          / Store #$0A to M8
AAF4 D6 F9 AA    / Jump to $AAF9
AAF7 89 43       / Store #$43 to M8
AAF9 A2 ED FF    / Store $0008 to storage 19
AAFC A0 ED FF    / Store storage 19 to $0008
AAFF B3          / Push M8 to stack             / (+2)
AB00 AA AE 78    / Push $78AE/$78AF to stack    / (+2)
AB03 E9 0F DE 04 / Run function $DE0F           / (-4) Take % of value
AB07 B3          / Push M8 to stack             / (+2)
AB08 DE F2 FF    / Store address of meta 14     /      Strength
AB0B B3          / Push M8 to stack             / (+2)
AB0C E9 6E DE 04 / Run function $DE6E           / (-4) Reduce strength by %
AB10 A4 B0 78    / Store $78B0/$78B1 to M8      / 
AB13 55 
AB14 B5          / Multiply M8 by 5
AB15 52
AB16 BE          / Divide M8 by 4
AB17 B3          / Push M8 to stack             / (+2)
AB18 A4 D1 7C    / Store $7CD1/$7CD2 to M8
AB1B 8F 14       / Add #$14 to M8
AB1D B0          / Replace M8 with 2-byte value / Active City - Soldier reserves
AB1E 51
AB1F BE          / Divide M8 by 2
AB20 15          / Store meta 13/14 to MC
AB21 BB          / Add MC to M8 
AB22 B4          / Pull 2 meta to MC            / (-2)
AB23 C7          / Check if M8 <= MC
AB24 D8 34 AB    / Jump to $AB34 if not
...

E8:B08D

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

E8:B0CD

Improves sufficiency value (1) of active city. (00 = Food, 01 = Material)

E8:B16D

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]

E8:B1AB

Active city spends gold to purchase horses (up to 9999).

E8:BADB

Plans out potential targets for active city (e.g. most suitable invasion target/most likely invasion thread)

20 E3 E2 00 F1 FF
04:BAE1:8E AA 78  STX $78AA ; Reset invasion target from previous turn
04:BAE4:8E AB 78  STX $78AB ;
04:BAE7:8E A8 78  STX $78A8 ; Reset invasion threat(?) from previous turn
04:BAEA:8E A9 78  STX $78A9 ;
04:BAED:8E AE 78  STX $78AE ; Reset ? from previous turn
04:BAF0:8E AF 78  STX $78AF ;
04:BAF3:A9 04     LDA #$04
04:BAF5:85 18     STA $0018
04:BAF7:86 19     STX $0019
04:BAF9:A9 03     LDA #$03
04:BAFB:85 14     STA $0014
04:BAFD:86 15     STX $0015
04:BAFF:A2 18     LDX #$18
04:BB01:20 DF E3  JSR $E3DF
04:BB04:A2 14     LDX #$14
04:BB06:20 DF E3  JSR $E3DF
04:BB09:A9 B9     LDA #$B9
04:BB0B:48        PHA
04:BB0C:A9 4C     LDA #$4C
04:BB0E:48        PHA
04:BB0F:8A        TXA
04:BB10:48        PHA
04:BB11:A9 E2     LDA #$E2
04:BB13:48        PHA
04:BB14:8A        TXA
04:BB15:48        PHA
04:BB16:A9 02     LDA #$02
04:BB18:48        PHA
04:BB19:20 82 E3  JSR $E382
04:BB1C:79 DD 08  ADC $08DD,Y
04:BB1F:A2 14     LDX #$14
04:BB21:20 04 E4  JSR $E404
04:BB24:A0 08     LDY #$08
04:BB26:A2 14     LDX #$14
04:BB28:A9 18     LDA #$18
04:BB2A:20 C1 E1  JSR $E1C1
04:BB2D:A2 14     LDX #$14
04:BB2F:20 04 E4  JSR $E404
04:BB32:A0 18     LDY #$18
04:BB34:A2 14     LDX #$14
04:BB36:A9 10     LDA #$10
04:BB38:20 FE E1  JSR $E1FE
04:BB3B:A5 10     LDA $0010
04:BB3D:8D B0 78  STA $78B0
04:BB40:A5 11     LDA $0011
04:BB42:8D B1 78  STA $78B1
04:BB45:8A        TXA
04:BB46:A0 F2     LDY #$F2
04:BB48:91 06     STA ($06),Y
04:BB4A:8E B2 78  STX $78B2
04:BB4D:4C 5C BB  JMP $BB5C
04:BB50:18        CLC
04:BB51:A9 01     LDA #$01
04:BB53:A0 F2     LDY #$F2
04:BB55:71 06     ADC ($06),Y
04:BB57:91 06     STA ($06),Y
04:BB59:8A        TXA
04:BB5A:69 00     ADC #$00
04:BB5C:A0 F2     LDY #$F2
04:BB5E:B1 06     LDA ($06),Y
04:BB60:85 18     STA $0018
04:BB62:86 19     STX $0019
04:BB64:A5 18     LDA $0018
04:BB66:C9 02     CMP #$02
04:BB68:A5 19     LDA $0019
04:BB6A:E9 00     SBC #$00
04:BB6C:90 03     BCC $BB71
04:BB6E:4C CA BE  JMP $BECA
04:BB71:B1 06     LDA ($06),Y
04:BB73:85 18     STA $0018
04:BB75:86 19     STX $0019
04:BB77:A5 18     LDA $0018
04:BB79:C9 01     CMP #$01
04:BB7B:D0 04     BNE $BB81
04:BB7D:A5 19     LDA $0019
04:BB7F:C9 00     CMP #$00
04:BB81:F0 03     BEQ $BB86
04:BB83:4C 55 BC  JMP $BC55
04:BB86:8A        TXA
04:BB87:48        PHA
04:BB88:A9 FF     LDA #$FF
04:BB8A:48        PHA
04:BB8B:8A        TXA
04:BB8C:48        PHA
04:BB8D:A9 03     LDA #$03
04:BB8F:48        PHA
04:BB90:A0 0C     LDY #$0C
04:BB92:B1 04     LDA ($04),Y
04:BB94:48        PHA
04:BB95:88        DEY
04:BB96:B1 04     LDA ($04),Y
04:BB98:48        PHA
04:BB99:20 82 E3  JSR $E382
...

Page E9 ($A000-$BFFF)

ROM location: 0x12010-0x1400F

E9:A013

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

E9:A068

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

E9:A09F

Checks if nations (1/2) and (3/4) are friendly.

E9:A0F6

Checks if nations (1/2) and (3/4) are hostile.

Returns #$00 if no. Returns #$20 if yes.

E9:A119

Checks if nations (1/2) and (3/4) are on good terms and if so, attempts friendship?

E9:AC4A

Prints text "Press any button".

E9:AC57

Display acting officer as active nation's envoy.

E9:AC9A

Prints text "[Active nation] .. [text string (01)] .. [Target nation]"

E9:ADD5

Set diplomatic status of Active and Target nations to (01).

Page EA ($8000-$9FFF)

ROM location: 0x14010-0x1600F

Page EB

ROM location: 0x16010-0x1800F

Page EC

ROM location: 0x18010-0x1A00F

Page ED ($8000-$9FFF)

ROM location: 0x1A010-0x1C00F

Page EE

ROM location: 0x1C010-0x1E00F

Page EF ($8000-$9FFF)

ROM location: 0x1E010-0x2000F

Page F0

ROM location: 0x20010-0x2200F

Page F1

ROM location: 0x22010-0x2400F

F1:80A9

Start-of-Month Phase main loop

F1:81D7

Month advance + Start-of-Month prep

F1:8370

Load event icon (1)

F1:94DA

Nation (1/2) becomes a satellite of nation (3/4)

F1:9918

Print death text of officer (1/2)

F1:9952

Officer (1/2) dies of old age.

F1:9A37

Officer age-up & random deaths

F1:9E3E

Check if two nations are adjacent by land.

F1:9ED4

Nation (1/2) requests protection from France

Page F2

ROM location: 0x24010-0x2600F

F2:A07E

Check for protection requests

F2:A29D

Advance from Scenario 1 to Scenario 2; Napoleon becomes Commander-in-Chief.

F2:A757

Advance from Scenario 2 to Scenario 3

F2:A84E

Advance from Scenario 3 to Scenario 4

F2:A8D3

Advances to the next Scenario if the conditions have been met.

Capture requirements for Scenario advancement:

Scenario  Cities controlled  Centers-of-Power controlled
  1->2          09                           00
  2->3          12                           04
  3->4          18                           08

F2:B463

Reduce every nation's alliance timer by 1. (Performed every year)

Page F3

ROM location: 0x26010-0x2800F

Page F4

ROM location: 0x28010-0x2A00F

Page F5

ROM location: 0x2A010-0x2C00F

Page F6

ROM location: 0x2C010-0x2E00F

Page F7

ROM location: 0x2E010-0x3000F

Page F8

ROM location: 0x30010-0x3200F

Page F9

ROM location: 0x32010-0x3400F

Page FA ($A000-$BFFF)

ROM location: 0x34010-0x3600F

FA:A004

Table of Nations

$A004 + #$0A x (Nation code) = Beginning of nation data starting with name and ending with hidden stat.

Note that Italy is a leftover unused nation in code.

Hidden stats:

France   01
Holland  00
Bavaria  00
Denmark  00
Turkey   01
Italy    00 
Venice   00
Naples   00
Portugal 00
Sweden   00
Spain    80
Prussia  00
Russia   81
Austria  01
England  80

0x80 flag is set for Spain, Russia and England to indicate that they are the greatest enemies of France. This gives a special innate bonus to them in multiple functions dictating diplomacy/trade.

FA:A09A

Table of Cities

$A09A + #$20 x (City code) = Beginning of city data starting with name and ending with hidden stat.

FA:A650

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.

Page FB

ROM location: 0x36010-0x3800F

Page FC

ROM location: 0x38010-0x3A00F

Page FD

ROM location: 0x3A010-0x3C00F

Page FE ($C000-$DFFF)

ROM location: 0x3C010-0x3E00F

FE:C003

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

FE:C045

Wait for (1) frames

FE:C052

Wait for 6*(1) frames

FE:C062

Wait (1) time units for input before advancing message automatically

Time unit = 5*(message speed) frames

FE:C1D6

Officer (1/2) gains a level (random stat goes up).

FE:C232

Officer (1/2) gains 1 EXP.

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

FE:C250

Officer (1/2) gains (3) EXP.

C255 A0 0D 00    / Store preloaded 03 to $0008       /      Loop counter = amount of experience to gain
C258 D6 64 C2    / Jump to $C264
C25B 3C          / Push preloaded 01/02 to metastack / (+2) Officer address
C25C E9 32 C2 02 / Run function $C232                / (-2) Officer gains 1 exp
C260 A0 FF FF    / Store $0008 to meta 01
C263 D1          / Decrement M8                      /      Tick down counter
C264 A2 FF FF    / Store $0008 to meta 01
C267 A0 FF FF    / Store meta 01 to $0008
C26A D7 5B C2    / Jump to $C25B if positive         /      Loop until all experience is gained
C26D CF          / Exit

FE:C26E

Retrieve city of officer (1/2)

FE:C28D

Retrieves the portrait ID for officer (1/2)

FE:C2D2

Retrieve nation of city (1/2)

FE:C30B

Retrieves address of officer list (1)

List # Address
     0   $7BC9
     1   $7C49
     2   $7CA1

FE:C35A

Removes officer (1/2) from nation (3/4)'s Reserve Officer list

FE:C368

Removes officer (1/2) from nation (3/4)'s POW Officer list

FE:C3BC

Sets x,y coordinates of text to (1/2),(3/4)

FE:C3E9

Print text string (1/2)

FE:C627

Print text string (1/2), replacing %s with (3/4) [and %d with (5/6)]

FE:C65F

Advances random number generator then checks for controller input (1)

0 = both controllers (1 then 2), 1 = controller 1, 2 = controller 2

FE:CD85

Reduce value at address (1/2) by (3/4)%. Returns difference

FE:CD9F

Checks if BGM is on, and plays audio (1) if so?

FE:D019

Retrieve name of nation (1/2).

FE:D085

Retrieve name of officer (1/2).

FE:D0E6

Retrieve list of cities adjacent by land to (1/2).

FE:D10B

Retrieve hidden stat (3) for city (1/2).

FE:D17A

Retrieve hidden stat (1) for officer (1/2).

00 = Personality traits

FE:D27F

Change to screen template (1)

FE:D3B6

Reduce value at address (1/2) by (3/4)%

FE:D402

Tally # of men assigned to officers in city (1/2).

FE:D43B

Tally # of officers in city (1/2).

FE:D460

Isolate flags (3) in (1). (bitwise AND)

FE:D69D

Generate random number from #$0000-#$7FFF

FE:D7B0

Update RNG seed (done after $D69D)

FE:D7D1

Generate random number between #$00 and #$(1/2)

FE:DCD6

Find smaller of values (1/2) and (3/4)

FE:DCF6

Find larger of values (1/2) and (3/4)

FE:DDCA

Take ratio (3)/(5) of value (1)

FE:DE0F

Find (3)% of (1)

FE:DE2C

Add (3/4) to 2-byte value (1/2) up to a max of (5/6)

FE:DE2B

Add (3/4) to 1-byte value (1/2) up to a max of (5/6)

FE:DE6E

Reduce 2-byte value at (1/2) by (3) to a minimum of zero

FE:DE77

Reduce 1-byte value at (1/2) by (3) to a minimum of zero

Page FF ($E000-$FFFF)

ROM location: 0x3E010-0x4000F

FF:E075

Sets up starting values for Scenario (1/2)+1

FF:E155

Initialized PRG bank switches on power-on.

FF:E2E3

Prep when going from a higher-level function to an assembly function.

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)

FF:E382

Prep when going from an assembly function to a higher-level function.

0F:E382:68        PLA
0F:E383:85 00     STA $0000
0F:E385:68        PLA
0F:E386:85 01     STA $0001
0F:E388:38        SEC
0F:E389:A0 03     LDY #$03
0F:E38B:A5 02     LDA $0002
0F:E38D:F1 00     SBC ($00),Y
0F:E38F:85 02     STA $0002
0F:E391:B0 02     BCS $E395
0F:E393:C6 03     DEC $0003
0F:E395:B1 00     LDA ($00),Y
0F:E397:AA        TAX
0F:E398:A0 00     LDY #$00
0F:E39A:18        CLC
0F:E39B:A5 00     LDA $0000
0F:E39D:69 03     ADC #$03
0F:E39F:91 02     STA ($02),Y
0F:E3A1:98        TYA
0F:E3A2:C8        INY
0F:E3A3:CA        DEX
0F:E3A4:65 01     ADC $0001
0F:E3A6:91 02     STA ($02),Y
0F:E3A8:D0 03     BNE $E3AD
0F:E3AA:68        PLA
0F:E3AB:91 02     STA ($02),Y
0F:E3AD:C8        INY
0F:E3AE:CA        DEX
0F:E3AF:D0 F9     BNE $E3AA
0F:E3B1:A0 01     LDY #$01
0F:E3B3:B1 00     LDA ($00),Y
0F:E3B5:85 08     STA $0008
0F:E3B7:C8        INY
0F:E3B8:B1 00     LDA ($00),Y
0F:E3BA:85 09     STA $0009
0F:E3BC:20 DC E3  JSR $E3DC
0F:E3BF:A0 01     LDY #$01
0F:E3C1:B1 02     LDA ($02),Y
0F:E3C3:99 00 00  STA $0000,Y
0F:E3C6:48        PHA
0F:E3C7:88        DEY
0F:E3C8:10 F7     BPL $E3C1
0F:E3CA:18        CLC
0F:E3CB:C8        INY
0F:E3CC:A5 02     LDA $0002
0F:E3CE:71 00     ADC ($00),Y
0F:E3D0:85 02     STA $0002
0F:E3D2:90 02     BCC $E3D6
0F:E3D4:E6 03     INC $0003
0F:E3D6:A9 00     LDA #$00
0F:E3D8:AA        TAX
0F:E3D9:A0 01     LDY #$01
0F:E3DB:60        RTS -----------------------------------------

FF:E3DC

Jump to address specified in $E382

0F:E3DC:6C 08 00  JMP ($0008)

FF:E509

Prep when going from one higher-level function to another.

FF:EF1E

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)?

FF:EFCB

Multiply M8 by MC.

Possibly unused

FF:F027

Divide M8 by MC (0=clear prev result?)

FF:F218

Blank $000A/$000B.

FF:F423

Store (5) (3) times beginning at address (1/2)