Herringway / ebsrc

Source code recreation for the game Earthbound
133 stars 8 forks source link

Documenting finds from Catador on Slack #9

Closed stochaztic closed 3 years ago

stochaztic commented 4 years ago

Don't want these finds from Catador to be lost to the Slack pay-up-or-lose-your-history "feature", so documenting them in this issue until you're able to add them to ebsrc. Most of this is straight copy-and-paste from Catador, so there may be other things we already know that make this more complete.

UNKNOWN_C07C8A is strcat:

$C07C8A = char FAR* strcat(char FAR *dst, char FAR *src)
dst = $0E (far pointer)
src = $12 (far pointer)
returns "dst" in $06 (far pointer)
Note: "FAR" denotes a far pointer, i.e 24-bit pointer (address with bank),
 interally handled as a 32-bit number with the highest byte ignored

Movement speed related functions:

C02D8F - Adjust X position based on movement speed.
  This fetches the movement speed from $7E4DD6,
  applies a multiplier when appropriate and then adds to the X position.
C03017 - Adjust Y position based on movement speed.
  This fetches the movement speed from $7E4F96,
  applies a multiplier when appropriate and then adds to the Y position.
By "speed", I mean a 16.16 fixed point number
C02D8F is currently named "ADJUST_POSITION" in ebsrc
C03017 is currently named "UNKNOWN_C03017" in ebsrc

(The arrays(?) of data at 7E4DD6 and 7E4F96 are weirdly complicated in how they are loaded and used and I admittedly don't get them at all.)

Arguments for above functions:

Arguments for these routines are as follow:
A   - Direction
X   - Surface Flags (see below)
$0E - Current X position (for C02D8F) or Y position (for C03017)
  as a 16.16 fixed point number (32-bit)
Surface flags:
0001 -> Foreground lower-body obscurity?
0002 -> Foreground upper-body obscurity?
0004 -> Sunstroke area
0008 -> Shallow water
000C -> Deep water (0004 + 0008 combined)
0010 -> Ladder/Stairs?
0020 -> ???
0040 -> ??? (blocks movement??)
0080 -> Solid tile

Inline constants in the asm used by above functions. ebsrc currently has these using the MOVE_INT_CONSTANT macro, so they might not need changed, maybe just defined somewhere.

Horizontal movement speed multipliers:
C02E00 - Shallow water multiplier (fraction) \ Default: 8000 0000
C02E05 - Shallow water multiplier (int)      / (0.5 pixels)
C02E9B - Deep water multiplier (fraction) \ Default: 547A 0000
C02EA0 - Deep water multiplier (int)      / (~0.33 pixels)
C02F89 - Skip sandwich multiplier (fraction) \ Default: 8000 0001
C02F8E - Skip sandwich multiplier (int)      / (1.5 pixels)
Vertical movement speed multipliers:
C03088 - Shallow water multiplier (fraction) \ Default: 8000 0000
C0308C - Shallow water multiplier (int)      / (0.5 pixels)
C03123 - Deep water multiplier (fraction) \ Default: 547A 0000
C03128 - Deep water multiplier (int)      / (~0.33 pixels)
C03211 - Skip sandwich multiplier (fraction) \ Default: 8000 0001
C03216 - Skip sandwich multiplier (int)      / (1.5 pixels)

Partial explanation of data in UNKNOWN_C3DFE8: This references the existing enum WALKING_STYLE. h.s discovered value 10, currently labeled "SLOWEST", is the Deep Darkness walking style.

C3E0BC: Movement speeds. One for each "walk style" (14 of them in total). 
C3E0F4: DIAGONAL movement speeds. One for each "walk style" (14 of them in total).

The speeds are 32-bit numbers, represented as 16.16 fixed point numbers
  (low 16-bits = fractional part, high 16-bits = integer part)

; Movement speeds. One for each "walk style"
C3/E0BC: 00 60 01 00 ; #0
C3/E0C0: 00 60 01 00 ; #1
C3/E0C4: 00 60 01 00 ; #2
C3/E0C8: CC CC 01 00 ; #3
C3/E0CC: 00 00 01 00 ; #4
C3/E0D0: 00 00 00 00 ; #5
C3/E0D4: 00 00 01 00 ; #6
C3/E0D8: CC CC 00 00 ; #7
C3/E0DC: CC CC 00 00 ; #8
C3/E0E0: 00 00 00 00 ; #9
C3/E0E4: 00 80 00 00 ; #10
C3/E0E8: 00 00 00 00 ; #11
C3/E0EC: CC CC 00 00 ; #12
C3/E0F0: CC CC 00 00 ; #13
; Diagonal movement speeds. One for each "walk style"
C3/E0F4: E6 F8 00 00 ; #0
C3/E0F8: E6 F8 00 00 ; #1
C3/E0FC: E6 F8 00 00 ; #2
C3/E100: D5 45 01 00 ; #3
C3/E104: 05 B5 00 00 ; #4
C3/E108: 00 00 00 00 ; #5
C3/E10C: 05 B5 00 00 ; #6
C3/E110: D0 90 00 00 ; #7
C3/E114: D0 90 00 00 ; #8
C3/E118: 00 00 00 00 ; #9
C3/E11C: 82 5A 00 00 ; #10
C3/E120: 00 00 00 00 ; #11
C3/E124: D0 90 00 00 ; #12
C3/E128: D0 90 00 00 ; #13

Normal:
0001.6000 = 1.375
0001.CCCC = ~1.8
0001.0000 = 1.0
0000.CCCC = ~0.8
0000.8000 = 0.5
Diagonal:
0000.F8E6 = ~0.97226
0001.45D5 = ~1.27278
0000.B505 = ~0.7071
0000.90D0 = ~0.56567
0000.5A82 = ~0.35354
PhoenixBound commented 4 years ago

I have a few more of these saved as text files. Probably should've posted about them sooner... better late than never.

And before I forget, walking style 10 is lost underworld, not deep darkness.

unknown_30x2_table_12_13.txt (I vouch for "pause/resume" rather than "disallow/allow" in the disassembly, but tomato tomahto)

photos.txt (Apparently this stuff was already in JHack, but some of it isn't in ebsrc)

This was probably also known already, but 7E0030 consists of two flags to copy over palettes from 7E0200 to CGRAM. I know there are a handful of places where it's accessed as UNKNOWN_7E002F+1.

When $0030 = 0x00, no colors are updated
When $0030 = 0x08, only BG colors are updated
When $0030 = 0x10, only sprite colors are updated
When $0030 = 0x18, all colors are updated
Other values are illegal and may bring chaos to your game

party_order_update.txt - includes comments tracing through UNKNOWN_C034D6. data0 through 7 refer to the 30x2 tables modified by the movement code [0E], I think. (Side note: the offsets to those tables are currently just raw bytes). Probably a lot of other stuff related to movement codes have been discovered/named recently, but that's probably worth a separate issue at that point, and I don't have a text file collecting all of it into one place.

mushroom_overworld_data.txt - data at UNKNOWN_C3E178 and a few RAM addresses

Herringway commented 4 years ago

GITHUB WHY DON'T I GET NOTIFICATIONS FOR ISSUES ON MY OWN REPOS

thanks for the info. I'm not sure how best to represent the decimal values, though...

Herringway commented 4 years ago

@PhoenixBound - the top 3 bits of the photo party values are flags representing visible statuses

$20 - unconscious
$40 - diamondized
$80 - mushroomized
Herringway commented 4 years ago

some parts of code use $7E0030 to skip checks for gamepad input, while others use it as an offset to a table at $7E8F92 containing VRAM DMA transfer parameters