Dragon Warrior (NES) - RAM

From ROM Detectives Wiki
Jump to navigation Jump to search
Label-Main.svgLabel-RAM.svgLabel-ROM.svgLabel-Text.svgLabel-Lua.svg


USA

USA

Dragon Warrior - NES - USA.png

Memory Addresses

0000 - Used for manipulating variables (doing damage, gaining xp and gp, etc.)
0047 - Controller 1 poll

008E - Map X Pos
008F - Map Y Pos

0094 - Random number byte 1
0095 - Random number byte 2

00B5-00B8 - First 4 characters of player's name
00B9 - Loaded with #FA at game load, and doesn't seem to change
00BA - Experience: x1
00BB - Experience: x256
00BC - Gold: x1
00BD - Gold: x256
00BE - Equipment (See Equipment List below)
00BF - Magic Keys
00C0 - Herbs (00-09)
00C1 - Items 2/1 (See Item List below)
00C2 - Items 4/3
00C3 - Items 6/5
00C4 - Items 8/7
00C5 - Hit Points
00C6 - Magic Points
00C7 - Level
00C8 - Strength place holder for Status (The following don't save to the character)
00C9 - Agility place holder for Status
00CA - Max HP place holder for Status
00CB - Max MP place holder for Status
00CC - Attack Power place holder for Status
00CD - Defense Power place holder for Status
00CE - Spells Bit Flag (Gets overwritten from battery)
	01 - Heal
	02 - Hurt
	04 - Sleep
	08 - Radiant
	10 - Stopspell
	20 - Outside
	40 - Return
	80 - Repel
00CF - Misc Player Variables Bit Flag
	01 - Healmore spell
	02 - Hurtmore spell
	04 - 
	08 - 
	10 - Dragon Scale
	20 - Fighter's Ring
	40 - Cursed Belt
	80 - Cursed Necklace
00D0 - Vision distance in the dark (Dark = 1, Torch = 3, Radiant = 7/5/3) - Note: Max value = 7, greater values do not reveal more, just graphical glitches

00D1 - Used for palette shifting while scrolling vertically
00D2 - Cursor X
00D3 - Cursor Y

00D7 - Last chosen menu item (00-09, FF - None)
00D8 - Highlighted menu item Col 1 (00-03)
00D9 - Highlighted menu item Col 2 (00-09)
00DA - Radiant Spell Countdown
00DB - Fairy Water / Repel Countdown (Even for fairy water, odd for repel)

00DE - Monster Injury Flash Countdown
00DF - Carrying Princess (08 - No, 09 - Yes)
00E0 - Tile walking on
	00 - Grass
	01 - Desert
	02 - Hills
	03 - Stairs Up
	04 - Tiles
	05 - Stairs Down
	06 - Swamp
	07 - Town
	08 - Cave
	09 - Castle
	0A - Bridge
	0B - Forest
	0C - Chest
	0D - Force Field

00E2 - Enemy HP

00E5 - Message Speed (00 - Fast, 01 - Normal, 02 - Slow) - Note: Can increase beyond normal means for -really- slow text

00E6-00FF - Sound Variables

0110-01FF - Stack
0200-02FF - Sprite Memory
0400-07BF - Tile layout for screen menus

E344 - Initial Chest Gold (78)

Item List

Items are stored in memory addresses 00C1-00C4 with two items stored in each byte. Item 1 is right nybble, item 2 is the left nybble. So if you wanted item 1 to be a torch, and item 2 to be wings, you would set memory address 00C1 to 31.

1 - Torch
2 - Fairy Water
3 - Wings
4 - Dragon's Scale
5 - Fairy Flute
6 - Fighter's Ring
7 - Erdrick's Token
8 - Gwaelin's Love
9 - Cursed Belt
A - Silver Harp
B - Death Necklace
C - Stones of Sunlight
D - Staff of Rain
E - Rainbow Drop
F - Herb

Equipment List

The designers of the equipment didn't base it on the usual bit flag (using powers of 2) for each item. However, since you can't have more than one type of equipment at a time, they were able to fit all of the items in a single byte. Simply take one item from each list, add them together, and the sum is the equipment value.

00 - Nothing

01 - Small Shield
02 - Large Shield
03 - Silver Shield

04 - Clothes
08 - Leather Armor
0C - Chain Mail
10 - Half Plate Armor
14 - Full Plate Armor
18 - Magic Armor
1C - Erdrick's Armor

20 - Bamboo Pole
40 - Club
60 - Copper Sword
80 - Hand Axe
A0 - Broad Sword
C0 - Flame Sword
E0 - Erdrick's Sword

Code

Swamp Damage

This subroutine is called when the player takes damage from swamps.

CDDF:A5 C5     LDA $00C5        ; Load Hit Points into A.
CDE1:38        SEC              ; Set Carry Flag
CDE2:E9 02     SBC #$02         ; Subtract #02 from A.
CDE4:B0 02     BCS $CDE8        ; If A didn't go below #00, goto CDE8
CDE6:A9 00     LDA #$00         ; A went below #00, set it to #00.
CDE8:85 C5     STA $00C5        ; Store A into Hit Points.
CDEA:20 74 FF  JSR $FF74

Barrier Damage

This subroutine is called when the player takes damage from barriers.

CE44:A5 C5     LDA $00C5        ; Load Hit Points into A.
CE46:38        SEC              ; Set the Carry Flag.
CE47:E9 07     SBC #$0F         ; Subtract #0F from A.
CE49:B0 04     BCS $CE4F        ; If A didn't go below #00, goto CE4F
CE4B:A9 00     LDA #$00         ; A went below #00, set it to #00.
CE4D:F0 00     BEQ $CE4F        ; If A is equal to #00, goto CE4F (Compiler mistake?)
CE4F:85 C5     STA $00C5        ; Store A into Hit Points.

Get Initial Attack Damage

Takes the player's attack power and subtracts a pseudo-random amount and stores the result in A.

E649:A5 CC     LDA $00CC        ; Load Attack Power.
E64B:38        SEC              ; 
E64C:E5 41     SBC $0041        ; Subtract $0041 ?
E64E:4C 64 E6  JMP $E664        ; Goto Modify Attack Damage.

Modify Attack Damage

Takes whatever is in A and does that amount of damage to the enemy.

E664:85 00     STA $0000
E666:A9 00     LDA #$00
E668:85 01     STA $0001
E66A:24 DF     BIT $00DF
E66C:70 2C     BVS $E69A
E66E:20 5B C5  JSR $C55B

Damage Player

Called when the player is to take damage. The amount of damage is stored in $0000.

ED25:A9 00     LDA #$00         ; Clear A.
ED27:85 01     STA $0001        ; Clear $0001.
ED29:A5 C5     LDA $00C5        ; Load Hit Points into A.
ED2B:38        SEC              ; 
ED2C:E5 00     SBC $0000        ; Subtract damage from Hit Points.
ED2E:B0 02     BCS $ED32        ; If result > 0 (carry is set)...
ED30:A9 00     LDA #$00         ; Load A with 0.
ED32:85 C5     STA $00C5        ; Store A into Hit Points.


Japan

Japan

Dragon Warrior - NES - Japan.png


USA (Rev 1)

USA

Dragon Warrior (Rev 1) - NES - USA.png