View Page Source

Back to Page
Revision 5 (current)
Edited by OmnipotentEntity on 7/8/2023 6:38 PM
!!Memory Addresses

Memory addresses less than 0x100 tend to be used for temporary or scratch calculations.

||Address||Type||Notes||
|0x03B4|u16|RNG State|
|0x0480|u16|Camera X Coord|
|0x0482|u16|Camera Y Coord|
|0x048E|u8|Room ID Number|
|0x0490|u8|HP Regen Counter|
|0x0491|u8|MP Regen Counter|
|0x0492|u16|Room Max Allowed X Coordinate|
|0x0494|u16|Room Max Allowed Y Coordinate|
|0x04E0|Story Flags|Story Flags (Bosses)|
|0x04E1|Story Flags|Story Flags (Followers and Ella)|
|0x04E2|Story Flags|Story Flag (General #1)|
|0x04E3|Story Flags|Story Flag (General #2)|
|0x04E4|Story Flags|Story Flag (General #3)|
|0x04E5|Story Flags|Story Flag (General #4)|
|0x04E6|Story Flags|Story Flag (General #5)|
|0x0500|Sprite Data|Nasir's Data|
|0x0540-0x0D3F|Sprite Data|NPC and Enemy Data|


!!Story Flags

Each of 0x04E0-0x04E6 are bitfields which represent current Story Progress.

||Address||Mask||Purpose||
|0x04E0|0x01|Thor Bird Defeated|
|0x04E0|0x02|Green Evil Spirit Defeated|
|0x04E0|0x04|Battler Defeated|
|0x04E0|0x08|Thimale Defeated|
|0x04E0|0x10|Duma Defeated|
|0x04E0|0x20|Eardon Defeated|
|0x04E0|0x40|Natela Defeated|
|0x04E0|0x80|Samson Defeated|
|0x04E1|0x01|Giles is Following|
|0x04E1|0x02|Thor is Following|
|0x04E1|0x04|Unused?|
|0x04E1|0x08|Unused?|
|0x04E1|0x10|Unused?|
|0x04E1|0x20|Unused?|
|0x04E1|0x40|Unused?|
|0x04E1|0x80|Ella Defeated|
|0x04E2|0x01|Voloh - Speak with Elf at Entrance|
|0x04E2|0x02|Atland - Speak with Mayor in House (put these on)|
|0x04E2|0x04|Atland - Speak with Chaplain after scene (Go talk to Mayor in his house)|
|0x04E2|0x08|Atland - Speak with Mayor's Wife in House (Mayor's at Worship Site)|
|0x04E2|0x10|Phantom Hill - Watch Wizard Fight|
|0x04E2|0x20|Atland - Speak with Mayor in Chapel (triggers scene)|
|0x04E2|0x40|Voloh - Thor Escort Finished|
|0x04E2|0x80|Atland - Giles Escord Finished|
|0x04E3|0x01|Poper - Speak with Basement Sage #6|
|0x04E3|0x02|Poper - Speak with Basement Sage #5|
|0x04E3|0x04|Poper - Speak with Basement Sage #4|
|0x04E3|0x08|Poper - Speak with Basement Sage #3|
|0x04E3|0x10|Poper - Speak with Basement Sage #2|
|0x04E3|0x20|Poper - Speak with Basement Sage #1|
|0x04E3|0x40|Poper - Speak with Chaplain to unlock Basement|
|0x04E3|0x80|Phantom Hill - Speak with Zerah after Wizard Fight|
|0x04E4|0x01|Atland - Speak with Injured Man|
|0x04E4|0x02|Phillips Castle - Teleport Elves in Jail|
|0x04E4|0x04|Denegul - Speak with Thor to start fetch quest|
|0x04E4|0x08|Siegfried Castle - Watch Lagoon Castle Cutscene|
|0x04E4|0x10|Poper - Sick Kid Scene|
|0x04E4|0x20|Poper - Speak with Final Basement Sage|
|0x04E4|0x40|Dwarf Cave - Ella/Princess Cutscene|
|0x04E4|0x80|Lagoon Castle - Rescue Princess|
|0x04E5|0x01|Phillips Castle - Unlocked Entrance|
|0x04E5|0x02|Siegfried Castle - Unlock Upstairs|
|0x04E5|0x04|Siegfried Castle - Unlock Boss Door|
|0x04E5|0x08|Phillips Castle - Unlocked Basement Prison Door|
|0x04E5|0x10|Philips Castle - Unlocked Roof|
|0x04E5|0x20|Gold Cave - Unlock Boss Door|
|0x04E5|0x40|Denegul - Thor Fetch Quest turned in|
|0x04E5|0x80|Atland - Speak with Mayor outside of Gold Cave|
|0x04E6|0x01|Eardon - Boss text seen|
|0x04E6|0x02|Unused?|
|0x04E6|0x04|Unused?|
|0x04E6|0x08|Lagoon Castle - Talk to Princess?|
|0x04E6|0x10|Unused?|
|0x04E6|0x20|Unused?|
|0x04E6|0x40|Elf Field - Thor is walking to Tablet|
|0x04E6|0x80|Elf Field - Thor gives you tablet|

!!Sprite Data

Sprite data is stored in more or less the same sort of structure between Nasir and NPCs and Enemies and so on.  It's a 0x40 length record.

||Offset||Type||Notes||
|0x00|Bitfield|Contains information about the status of a sprite|
|0x02|u16|X Coordinate|
|0x04|u16|Y Coordinate|
|0x06|u16|X Movement (How much in the X direction is the sprite moving under its own power (if moving up and down, does not count ejections to the left and right))|
|0x08|u16|Y Movement (See above)|
|0x0A|u8|Facing direction|
|0x0B|u8|Direction move attempted in|
|0x0C|u16|X Coordinate relative to Camera|
|0x0E|u16|Y Coordinate relative to Camera|
|0x10|u8|Walking animation counter (counts up to a certain point)|
|0x11|u8|Walking animation frame (changes the frame of animation once the above counter resets)|
|0x12|u8|Stun Counter|
|0x13|Bitfield|Stun bits (still needs investigation, 1 when damaged, 2 when pushed by shield)|
|0x14|Fixed point 16 bits|Nasir Jump Displacement (Z displacement, low byte in subpixels, high byte in pixels)|
|0x16|Fixed point 16 bits|Nasir Jump Velocity (Same layout)|
|0x18|u8|Sprite Type (see enum)|
|0x19|u8|Movement Direction Result|
|0x1A|u8|Unused by Nasir, used by NPC/Enemy update subroutines, Unknown|
|0x1B|u8|Sprite ID, determines which NPC/Enemy it is|
|0x1C|u8|Current Hitbox ID|
|0x1D|u8|Nasir Sword Animation Frame|
|0x1E|u8|Nasir Shield Animation Frame|
|0x1F|u8|Nasir Jump Animation Frame|
|0x20|u16|Current HP (some enemies have more than 255 HP)|
|0x22|u16|Current MP|
|0x24|u16|Attack|
|0x26|u16|Defense|
|0x28|u16|Gold (for enemies, this is the amount they give you)|
|0x2A|u16|Exp (for enemies, this is the amount they give you)|
|0x2C|u8|Level (for enemies, this controls different forms, for instance, Samson's Helmet)|
|0x2D|u8|Unknown (Unused by Nasir, only read by part of the sprite update code.)|
|0x2E|u8|Unknown (ibid)|
|0x2F|u8|Magic Projectile Active|
|0x30|u16|Respawn Position X (Enemies)|
|0x30|u8|Equipped Sword ID (Nasir)|
|0x31|u8|Equipped Armor ID (Nasir)|
|0x32|u16|Respawn Position Y (Enemies)|
|0x32|u8|Equipped Shield ID (Nasir)|
|0x33|u8|Equipped Ring ID (Nasir)|
|0x34|u8|Equipped Magic Staff ID|
|0x35|u8|Equipped Magic Crystal ID|
|0x36|u8|Equipped Item ID|
|0x37|u8|Equipped Magic ID ((Staff << 2) + Crystal)|
|0x3E|u8|Command (the direction you told Nasir to go?)|
|0x34-0x3F|u8/u16|Enemy data used in AI Routines, unless noted, not used by Nasir.|

!!Enums

!Sprite Types

||ID||Type||
|0|Player|
|1|Friendly NPC|
|2|Enemy|
|3|Boss|
|4|Unknown/Unused|
|5|Door|

!Directions

||ID||Description||
|0|Right|
|1|Down|
|2|Left|
|3|Up|
|-1|No Direction|

!Command

||Bitmask||Description||
|0x0000|None|
|0x0020|Use Item|
|0x0080|Jump|
|0x0100|Go Right|
|0x0200|Go Left|
|0x0400|Go Down|
|0x0800|Go Up|
|0x1000|Pause|
|0x4000|Open Chest|
|0x8000|Use Sword|

!Item IDs

Only some key items listed, work in progress.

||ID||Description||
|0x26|Samson's Key|
|0x27|Key of Phillips|
|0x28|Key of Prison|
|0x29|Mint|
|0x2A|Duma's Key|
|0x2B|Key of Siegfried|
|0x2C|Movable Mantle|
|0x2E|Freezing Pot|
|0x2F|Thor's Pendant|
|0x30|Powerful Mirror|
|0x31|Moon Stone|
|0x32|Angel's Bell|
|0x33|Truth Fire|
|0x34|Fur Mantle|
|0x35|Statue|

!Enemy IDs

Resistances are listed in the form of 4 numbers, 0-F, which is a bitmask that determines which spells effect the enemy.  Level 1 spells check the first bit, level 2 check the second and so on.  So if an enemy has a 0, then no spells affect it, if the enemy has an F then all spells affect it, E then spells Level 2 or higher affect it, C level 3 or higher.  The order is given by Lightning, Water, Wind, Fire.  So FC0E is fully vulnerable to jLightning and will take damage from level 2 or better Fire spells, vulnerable to level 3 or better Water Spells, and completely immune from Wind spells.

||Name||Location||ID||HP||Atk||Def||Gold||Exp||Resistances||
|Cril|Gold Mine|0|14|20|15|3|2|FFFF|
|Dro|Gold Mine|1|12|15|10|2|1|F0FF|
|Chiphon|Gold Mine|2|24|30|26|4|3|0000|
|Tick|Elf Field|3|44|28|30|3|4|FFFF|
|Bune|Elf Field|4|12|35|40|3|5|FFFF|
|Savage|Philips Castle|5|50|45|38|5|6|FF0F|
|Gregory|Philips Castle|6|60|40|25|5|5|EEEE|
|Revie|Philips Castle|7|54|50|20|5|4|F0FF|
|Roputo|Philips Castle|8|60|55|42|3|6|FFFF|
|Crud|Philips Castle|9|68|60|0|5|6|000F|
|Hauru|Philips Castle|10|64|65|45|5|7|FFFF|
|Rock|Dwarf Field|11|74|90|106|10|10|F0F0|
|Hunter Wolf|Dwarf Field|12|74|84|98|5|9|FFFF|
|Magie|Dwarf Cave|13|58|96|0|10|32|0FF0|
|Bizarl|Dwarf Cave|14|100|102|122|10|20|FFF0|
|Nondietto|Hobbit Valley|15|110|108|130|6|30|FFFF|
|Zudabvou|Hobbit Valley|16|94|114|138|5|22|FFFF|
|Gustavu|Siegfried Castle|17|120|157|184|7|30|CCCC|
|Elumerutergie|Siegfried Castle|18|44|150|175|1|35|FFF0|
|Mikky|Siegfried Castle|19|144|165|194|7|40|FFFF|
|Angelassu|Siegfried Castle|20|130|172|204|8|52|FFFF|
|Revock|Siegfried Castle|21|110|180|213|8|60|FFFF|
|Kiezer|Siegfried Castle|22|134|187|223|9|80|CCCC|
|Helliones|Ice Cave|23|144|195|232|10|80|F0FF|
|Oruton|Phantom Hill|24|150|210|252|5|90|FFFF|
|Sagiterl|Lagoon Castle|25|184|247|300|7|200|FF0F|
|Nuter|Ice Cave|26|100|202|242|2|120|F0FF|
|D Cline|Lagoon Castle|27|170|240|290|7|160|FFFF|
|Killerknight Dame|Lagoon Castle|28|190|255|309|8|250|0000|
|Edoger|Lagoon Castle|29|210|262|389|7|300|F00F|
|Sadowiee|Secret Place|30|200|277|338|5|350|F0FF|
|Flyokuto|Lagoon Castle|31|160|217|261|7|130|FFFF|
|Brol|Lagoon Castle|32|174|225|271|5|140|FFFF|
|Foolisharukan|Lagoon Castle|33|144|232|280|7|150|FFFF|
|Bishamon|Lagoon Castle|34|255|270|328|8|350|0000|
|Exellian|Secret Place|35|230|285|348|10|400|0000|
|Thimale Guardian|Ice Cave Boss Room|36|40|225|226|0|0|F00F|
|Evil Spirit Shell|Secret Place Boss Room #1|37|1280|307|264|0|0|0000|
|Beast Zerah|Secret Place Boss Room #2|38|500|285|384|0|0|0000|

!Boss IDs

||Name||ID||HP||Attack||Def||Gold||Exp||
|Samson|0|96|24|65|100|64|
|Natela|1|100|55|98|500|250|
|Eardon|2|150|130|266|2800|500|
|Doma|3|240|140|210|300|800|
|Doma Hand #1|4|0|240|210|0|0|
|Doma Hand #2|5|0|240|210|0|0|
|Thimale|6|256|150|226|1000|1500|
|Battler|7|256|195|558|1000|3000|
|Battler Egg #1|8|0|295|298|0|0|
|Battler Egg #2|9|0|295|298|0|0|
|Green Evil Spirit|10|256|312|454|0|0|
|Thor|11|256|205|214|0|0|
|Thor Bird|12|256|355|550|0|0|
|Thor Orbs|13|0|205|314|0|0|
|Ella|14|256|205|482|1000|2000|
|Red Evil Spirit|15|256|312|560|0|0|

!Rooms

||Room ID (hex)||Room ID (dec)||Description||
|0|0|Atland|
|1|1|WorshipSite|
|2|2|GoldCaveEntrance|
|3|3|GoldCaveB1|
|4|4|GoldCaveHallway1|
|5|5|GoldCaveB2|
|6|6|GoldCaveHallway2|
|7|7|GoldCaveOutdoors|
|8|8|ElfField|
|9|9|Voloh|
|$A|10|PhillipsCastleEntrance|
|$B|11|PhillipsCastle1F|
|$C|12|PhillipsCastle2F|
|$D|13|PhillipsCastleBasement|
|$E|14|PhillipsCastleWarp|
|$F|15|DwarfDesertWarp|
|$10|16|DwarfDesert|
|$11|17|Denegul|
|$12|18|DwarfCaveCorridor1|
|$13|19|DwarfCaveCorridor2|
|$14|20|DwarfCave1|
|$15|21|DwarfCave2|
|$16|22|SilentTerrence|
|$17|23|DwarfCaveFoyer|
|$18|24|HobbitValley|
|$19|25|Poper|
|$1A|26|PoperHouse|
|$1B|27|PoperChurch|
|$1C|28|PoperChurchBasement|
|$1D|29|SiegfriedCastleEntrance|
|$1E|30|SiegfriedCastle1F|
|$1F|31|SiegfriedCastle1FStairs|
|$20|32|SiegfriedCastle2F|
|$21|33|SiegfriedCastle3F|
|$22|34|SiegfriedCastleBasement|
|$23|35|GnomeTree|
|$24|36|Lilaty|
|$25|37|GnomePlain|
|$26|38|IceCave|
|$27|39|NymphSpring|
|$28|40|PhantomHill|
|$29|41|PhantomHillSummit|
|$2A|42|Clouds|
|$2B|43|LagoonCastleEntrance|
|$2C|44|LagoonCastle1F|
|$2D|45|LagoonCastle1F_Hallway1|
|$2E|46|LagoonCastle1F_Hallway2|
|$2F|47|LagoonCastle2F|
|$30|48|LagoonCastle2F_Hallway1|
|$31|49|LagoonCastle2F_Hallway2|
|$32|50|LagoonCastle3F|
|$33|51|LagoonCastle3F_Hallway1|
|$34|52|LagoonCastle3F_Hallway2|
|$35|53|LagoonCastle4F|
|$36|54|LagoonCastle4F_Hallway1|
|$37|55|LagoonCastle4F_Hallway2|
|$38|56|LagoonCastle5F|
|$39|57|LagoonCastle5F_Hallway1|
|$3A|58|LagoonCastle5F_Hallway2|
|$3B|59|LagoonCastleDock|
|$3C|60|SecretPlaceEntrance|
|$3D|61|SecretPlaceCottage|
|$3E|62|SecretPlace|
|$3F|63|Unused|
|$40|64|SamsonsRoom|
|$41|65|NatelaRoom|
|$42|66|EardonsRoom|
|$43|67|DumasRoom|
|$44|68|ThimalesRoom|
|$45|69|BattlersRoom|
|$46|70|EvilSpiritsRoom1|
|$47|71|EvilSpiritsRoom2|
|$48|72|EllasRoom|
|$49|73|KingAndQueensChamber|
|$4A|74|FeliciasChamber|

!!Other Info

!Room Sprite Data

Room Sprite Data is located at ROM address 0x859552, in a packed array of 0xFFFF terminated lists.  Each entry is formatted as this structure

||Offset||Type||Description||
|0x00|u8|Sprite Type|
|0x01|u8|Sprite ID|
|0x02|u16|X Coordinate|
|0x04|u16|Y Coordinate|
|0x06|u8|Initial Direction|
|0x07|u8|Initial Status|
|0x08|u8|Initial Animation?|

It is referenced by a mostly unexplored Room Metadata struct, that has the 24-bit pointer at offset 0x2B.  Room Metadata is stored in the ROM at 0x85B2DF, and each entry is 0x38 bytes long.

!RNG

Nasir's attempted movement direction gets mixed in with the RNG at 0x81814B by simply adding it to 0x03B5, giving the player a way of controlling the RNG a little bit.  However, these numbers are rather small (-1, 0, 1, 2, 3), additionally, because Manhattan geometry, there are several different equivalent paths to go to a specific point; however, they will all add the same amount overall.  The ways to change this are via an delay, and via cutting a corner more or less.

Every time an RNG value is needed 0x809848 ("GetNextRNG") is called.

This function does roughly the following:

{{acc = $3B5 + 1;
$3B4 = acc;
$3B5 = 5 * acc;
$3B4 = $3B5 * 16 | $3B5 / 16; // nibble swap
return $3B4;
}}

!Nasir Level Data

||Level||HP||MP||Attack||Defense||Experience Required to Reach||Additional Experience Required to reach next level||
|1|10|3|10|5|0|10|
|2|17|8|13|10|10|30|
|3|23|10|17|16|40|50|
|4|28|12|22|19|90|80|
|5|36|19|26|23|170|110|
|6|43|22|30|26|280|120|
|7|54|27|34|31|400|160|
|8|63|30|38|36|560|190|
|9|68|34|41|40|750|220|
|10|75|38|47|43|970|260|
|11|89|46|53|49|1230|300|
|12|96|57|58|53|1530|350|
|13|119|63|61|57|1880|410|
|14|126|76|65|62|2290|520|
|15|142|81|69|68|2810|740|
|16|148|93|76|75|3550|630|
|17|153|114|83|79|4180|870|
|18|160|123|89|83|5050|950|
|19|169|138|96|90|6000|1180|
|20|174|145|117|101|7180|1410|
|21|180|151|124|110|8590|1690|
|22|184|157|135|124|10280|1970|
|23|187|162|142|137|12250|2210|
|24|192|171|148|142|14460|2780|
|25|201|179|157|150|17240|3230|
|26|208|185|163|161|20470|3730|
|27|210|192|176|172|24200|4170|
|28|213|199|183|184|28370|4690|
|29|219|213|189|193|33060|4980|
|30|221|219|211|203|38040|5200|
|31|228|227|224|212|43240|5560|
|32|231|236|237|223|48800|5910|
|33|239|240|243|231|54710|6120|
|34|248|245|247|243|60830|4705|
|35|255|255|255|255|65535|0|