Change Starting Health

Go down

20220106

Post 

Change Starting Health Empty Change Starting Health




When you load up your save file, you will start with roughly half of your hearts. This is actually controlled by a table of sorts, which can easily be edited.

First off, there are 2 sections of the code that reference this table. They are at hex address x4F53E and x73CC3, and they are both identical.
Code:

AF 6C F3 7E     ;LDA $7E/F36C (Load "a" with the player's Max Health)
4A                   ;LSR (Divide it by 2)
4A                   ;LSR (Divide it by 2 again)
4A                   ;LSR (Divide it by 2 again)
                       ;(The goal here is to convert "health" to heart containers. Each heart container covers $08 health, so we need to divide by 8)
AA                   ;TAX (Transfer "a" to "x")
BF AC F4 09     ;LDA,x 09/F4AC (Load "a" with the value at address 09/F4AC, but shifted "x" bytes to the right.)
8F 6D F3 7E     ;STA $7E/F36D (Save "a" as the player's Current Health)

The table that it looks up has the following data:
Code:

x4F4AC (rom address 09/F4AC)
18 18 18 18 18 20 20 28 28 30 30 38 38 38 40 40 40 48 48 48 50

In short, it means, "If the player has 0-4 heart containers, start them with $18 health (3 full hearts). If the player has 5-6 hearts, start them with $20 health (4 full hearts)..." and so on. There are values all the way up to 20 heart containers.

There are 2 ways to edit this. If you want to create a custom table, edit the values at x4F4AC. Full hearts will end in a an 8 or 0 digit. Half hearts will end in a 4 or C digit.

If you just want full health at startup, you have 2 options.

The first option is to make the lookup table equal to full health at that heart value. At x4F4AC, paste in this table:
Code:
18 18 18 18 20 28 30 38 40 48 50 58 60 68 70 78 80 88 90 98 A0

The second option is to remove all the complicated lookups entirely.
Code:

x4F53E and x73CC3
AF 6C F3 7E     ;LDA $7E/F36C (Load "a" with the player's Max Health)
80 06          ;BRA +$06 (Branch forward 6 bytes)
EA EA EA     ;NOP (do nothing)
EA EA EA     ;NOP (do nothing)
8F 6D F3 7E     ;STA $7E/f36D (Save "a" as the player's Current Health)

Either solution will work.
PowerPanda
PowerPanda

Change Starting Health Image213

Since : 2019-11-05

Back to top Go down

Share this post on: redditgoogle
- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum