Code Monkey home page Code Monkey logo

ebsrc's Introduction

ebsrc

This is currently a disassembly of the game known as Earthbound in the west and Mother 2 in the east. Hopefully, in the future, it will be able to evolve into a proper decompilation. Contributions are welcome.

Requirements

How to build

  1. Clone the repository - git clone https://github.com/Herringway/ebsrc.git
  2. From the source directory, enter the following commands for the ROM you wish to produce:

US Retail

ebbinex earthbound.yml "path to retail ROM"
make

US Localization Prototype (1995-03-27)

ebbinex earthbound-1995-03-27.yml "path to prototype ROM"
make proto19950327

Mother 2

ebbinex mother2.yml "path to mother 2 ROM"
make mother2

TODO

  • Extract and build assets with a better format.
  • Document all the things!
  • Determine and locate a copy of the version of VUCC used for the original game.
    • Alternatively, attempt to recreate that version using the version of VUCC released with the Virtual Boy SDK
  • Decompile C code.

ebsrc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ebsrc's Issues

Document mother 2's mr saturn VWF

Renders tiles to VRAM $7900-7C00 (96 tiles)
UNKNOWN_C3EF26 - character widths? starts at character 0x10
UNKNOWN_C45DDD - sets up the transfer to VRAM

note that these labels reflect their addresses in earthbound, rather than in mother 2

Improve audio data

Several things to do here.

  • Split sample packs into separate .BRR files
  • Give other audio packs appropriate extensions instead of just .BIN
  • Find an assembler that can handle SPC-700 assembly and assemble the program

RAM is woefully incomplete

Got lots of holes to fill in. This issue can be closed once there's only one .ORG statement remaining among the ram offsets.

Switch to LLVM-MOS?

We would be able to use this for both the SPC700 program and SNES program. This would enable us to use nearly the entire LLVM ecosystem's tools and compilers with very little work. We would be able to extend both programs with higher level languages like D or rust, and have access to more standard tools like objdump.

While LLVM-MOS currently supports the SPC700, it doesn't fully support the 65c816 yet. While it supports the instruction set, it does not yet support the extended addressing modes and 16-bit accum/index modes that the 6502 didn't have. Support for these appear to only be in the planning stages so far.

Recent versions of ca65 fail to assemble ebsrc without the `long_jsr_jmp_rts` feature enabled

See title. When assembling with ca65 V2.19 - Git 494bf10 I get the following errors:

E:\temp\ebsrc-main>ca65 --version
ca65 V2.19 - Git 494bf10

E:\temp\ebsrc-main>make
ca65 -t none --cpu 65816 --bin-include-dir src --include-dir src --include-dir include -D USA -o "src/bankconfig/US/bank00.o" "src/bankconfig/US/bank00.asm"
src/system/reset.asm:117: Error: Illegal addressing mode
src/system/reset_vector.asm:7: Error: Illegal addressing mode
src/system/nmi_vector.asm:3: Error: Illegal addressing mode
src/system/irq_vector.asm:3: Error: Illegal addressing mode
src/overworld/actionscript/run_actionscript_frame.asm:7: Error: Illegal addressing mode
src/overworld/actionscript/fade_in.asm:10: Error: Illegal addressing mode
src/overworld/actionscript/fade_out.asm:10: Error: Illegal addressing mode
src/system/check_hardware.asm:18: Error: Illegal addressing mode
src/system/check_hardware.asm:29: Error: Illegal addressing mode
make: *** [src/bankconfig/US/bank00.o] Error 1

I can edit the Makefile and add --feature long_jsr_jmp_rts to CA65FLAGS to fix the issue.

E:\temp\ebsrc-main>ca65 --version
ca65 V2.19 - Git 494bf10

E:\temp\ebsrc-main>make
ca65 -t none --cpu 65816 --feature long_jsr_jmp_rts --bin-include-dir src --include-dir src --include-dir include -D USA -o "src/bankconfig/US/bank00.o" "src/bankconfig/US/bank00.asm"
ca65 -t none --cpu 65816 --feature long_jsr_jmp_rts --bin-include-dir src --include-dir src --include-dir include -D USA -o "src/bankconfig/US/bank01.o" "src/bankconfig/US/bank01.asm"
ca65 -t none --cpu 65816 --feature long_jsr_jmp_rts --bin-include-dir src --include-dir src --include-dir include -D USA -o "src/bankconfig/US/bank02.o" "src/bankconfig/US/bank02.asm"
[[ ... ]]
ca65 -t none --cpu 65816 --feature long_jsr_jmp_rts --bin-include-dir src --include-dir src --include-dir include -D USA -o "src/bankconfig/US/bank2f.o" "src/bankconfig/US/bank2f.asm"
ca65 -t none --cpu 65816 --feature long_jsr_jmp_rts --bin-include-dir src --include-dir src --include-dir include -D USA -o "src/bankconfig/US/ram.o" "src/bankconfig/US/ram.asm"
ca65 -t none --cpu 65816 --feature long_jsr_jmp_rts --bin-include-dir src --include-dir src --include-dir include -D USA -o "src/bankconfig/US/sram.o" "src/bankconfig/US/sram.asm"
ld65 -C snes.cfg --mapfile "earthbound.map" -o "earthbound.sfc" src/bankconfig/US/bank00.o src/bankconfig/US/bank01.o src/bankconfig/US/bank02.o src/bankconfig/US/bank03.o src/bankconfig/US/bank04.o src/bankconfig/US/bank05.o src/bankconfig/US/bank06.o src/bankconfig/US/bank07.o src/bankconfig/US/bank08.o src/bankconfig/US/bank09.o src/bankconfig/US/bank0a.o src/bankconfig/US/bank0b.o src/bankconfig/US/bank0c.o src/bankconfig/US/bank0d.o src/bankconfig/US/bank0e.o src/bankconfig/US/bank0f.o src/bankconfig/US/bank10.o src/bankconfig/US/bank11.o src/bankconfig/US/bank12.o src/bankconfig/US/bank13.o src/bankconfig/US/bank14.o src/bankconfig/US/bank15.o src/bankconfig/US/bank16.o src/bankconfig/US/bank17.o src/bankconfig/US/bank18.o src/bankconfig/US/bank19.o src/bankconfig/US/bank1a.o src/bankconfig/US/bank1b.o src/bankconfig/US/bank1c.o src/bankconfig/US/bank1d.o src/bankconfig/US/bank1e.o src/bankconfig/US/bank1f.o src/bankconfig/US/bank20.o src/bankconfig/US/bank21.o src/bankconfig/US/bank22.o src/bankconfig/US/bank23.o src/bankconfig/US/bank24.o src/bankconfig/US/bank25.o src/bankconfig/US/bank26.o src/bankconfig/US/bank27.o src/bankconfig/US/bank28.o src/bankconfig/US/bank29.o src/bankconfig/US/bank2a.o src/bankconfig/US/bank2b.o src/bankconfig/US/bank2c.o src/bankconfig/US/bank2d.o src/bankconfig/US/bank2e.o src/bankconfig/US/bank2f.o src/bankconfig/US/ram.o src/bankconfig/US/sram.o

I've confirmed that the two ROMs built with this feature both match the source ROMs:

$ sha256sum *.sfc
a8fe2226728002786d68c27ddddf0b90a894db52e4dfe268fdf72a68cae5f02e  clean-eb.sfc
1f8cfd13177d86b0eb2c8adcf9e1a4f0ec8966fa1583072b65a1b1c0e7961a5d  clean-m2.sfc
a8fe2226728002786d68c27ddddf0b90a894db52e4dfe268fdf72a68cae5f02e  earthbound.sfc
1f8cfd13177d86b0eb2c8adcf9e1a4f0ec8966fa1583072b65a1b1c0e7961a5d  mother2.sfc

It looks like this behaviour may have been modified here: cc65/cc65@ccf3994

I think we should add this flag to the Makefile. I'll open a PR.

initial_stats.asm is a table

.BYTE $00, $00, $00, $00, $00, $00, $01, $00, $00, $00, $67, $02, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00, $00, $00, $91, $5B, $8C, $8F, $07, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $0F, $00, $70, $17, $D0, $6E, $00, $00, $00, $00, $00, $00, $00, $00

This data is the data for the other three heroes, in exactly the same format as Ness's data above (first four bytes of each entry still unknown to me).

(BTW, not sure if GitHub issues is the best format for sharing discoveries or improvements with you--let me know if you'd prefer something else.)

Add offsets to the ASM source files?

Sorry to post this as an issue, but I've been trying for a long time to add offsets to all of the lines. For example:

MENU_SETUP_SELECTED: JSL $c1f3c2 // $c1f872
UNKNOWN7: LDA #$0000 // $c1f876
JSL $c1f497 // $c1f879
CMP #$0000 // $c1f87d

I can only find the comments for the beginning of the routines.

Documenting finds from Catador on Slack

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

Unable to build with ca65 v2.19 - String constant expected

Hello,
I have just tried building for the first time, but I'm receiving this error:

$ make
ca65 -t none --cpu 65816 --bin-include-dir src --include-dir src -D USA --create-dep "src/bankconfig/US/bank00-1.dep" "src/bankconfig/US/bank00-1.asm"
src/macros.asm:19: Error: String constant expected
mingw32-make: *** [Makefile:40: src/bankconfig/US/bank00-1.dep] Error 1
$ ca65 --version
ca65.exe V2.19 - Git 0ae1aad

I am not sure who is at fault here, but a string constant should not be expected at that spot, so I'm guessing there's an issue with the ca65 version I am using. Can you confirm which version works for you?
Thanks,
cooprocks123e

Can't compress data in a bit-exact way

No utilities compress data in the same way the original developers did. We're gonna need a utility that does if we want to continue being able to produce bit-exact images.

Missing non-@Optional flyoverTextTable in node

When I try to extract the assets on the latest version of ebbinex:

siryul.common.DeserializeException@/home/user/.dub/packages/siryul/0.8.11/siryul/source/siryul/common.d(647): earthbound.yml (line 0, column 0): Missing non-@Optional flyoverTextTable in node
----------------
/home/user/.dlang/dmd-2.106.0/linux/bin64/../../src/phobos/std/exception.d:460 pure @safe bool std.exception.enforce!(bool).enforce(bool, lazy object.Throwable) [0x55fbdb9e5f9c]
/home/user/.dub/packages/siryul/0.8.11/siryul/source/siryul/common.d:647 @safe void siryul.common.deserialize!(common.DumpDoc, siryul.dyaml.YAML.Node).deserialize(siryul.dyaml.YAML.Node, out common.DumpDoc, std.typecons.BitFlags!(siryul.common.DeSiryulize, 0).BitFlags) [0x55fbdba24008]
/home/user/.dub/packages/siryul/0.8.11/siryul/source/siryul/dyaml.d:23 @safe common.DumpDoc siryul.dyaml.YAML.parseInput!(common.DumpDoc, 0, immutable(char)[]).parseInput(immutable(char)[], immutable(char)[]) [0x55fbdba23983]
/home/user/.dub/packages/siryul/0.8.11/siryul/source/siryul/siryul.d:30 @safe common.DumpDoc siryul.siryul.fromFile!(common.DumpDoc, siryul.dyaml.YAML, 0).fromFile(immutable(char)[]) [0x55fbdba23797]
source/app.d:34 _Dmain [0x55fbdb9c0bdb]

Some things I've identified. More to come later.

Miscellaneous
C01000 - This is a redirect to HIDE HP PP WINDOWS

Control Code Stuff (courtesy of https://datacrystal.romhacking.net/wiki/EarthBound/Control_Codes)
C102D0 - Pauses an actionscript
C1AA18 - Shows the wallet window
C226C5 - Sets whether a present is open or closed
C226E6 - Gets the event flag of the TPT entry the player is currently interacting with
C23008 - Creates a backup of the current party
C2307B - Restores the backup
C3FB09 - Returns whether the current action user is an ally or enemy

Event data
C3098B - Part of actionscript 265

Some event tasks are identified here: https://gist.github.com/CataLatas/76700c2781bcfade26953ef4cc827862
(maybe add a subfolder in data/events for event tasks?)

define MovTask_Anim8 = 0xC3A09F // Animate with 8 frame delay
define MovTask_Anim24 = 0xC3A0B2 // Animate with 24 frame delay
define MovTask_Anim12 = 0xC3A0C5 // Animate with 12 frame delay
define MovTask_Anim_Var4 = 0xC3A12E // Animate with [VAR4] frame delay
define MovTask_Anim8_Toggle_DestroyIfFar = 0xC3A15E // Animate with 8 frame delay (togglable via VAR4) and destroy if far
define MovTask_Anim12_24_DestroyIfFar = 0xC3A17B // Animate with 12 then 24 frame delay and destroy if far
define MovTask_Anim24_DestroyIfFar = 0xC3A18F // Animate with 24 frame delay and destroy if far
define MovTask_Anim9_DestroyIfFar = 0xC3A1B7 // Animate with 9 frame delay and destroy if far
define MovTask_Anim6_DestroyIfFar = 0xC3A1CB // Animate with 6 frame delay and destroy if far
define MovTask_Anim16_DestroyIfFar = 0xC3A1F3 // Animate with 16 frame delay and destroy if far
define MovTask_HandleCollision = 0xC3A262 // Handle collisions. Doesn't need to be used by stationary entities
define MovTask_DestroyIfFar = 0xC3A2B8 // Destroy if far

define MovTask_EnemyTouch1 = 0xC3A434 // Start battle with enemy on touch
define MovTask_EnemyTouch2 = 0xC3A448 // Very similar to above, I don't actually know what's different

define MovTask_PartyLook = 0xC3AFA3 // Party members look at ENTITY

define MovTask_DestroyIfFar_UnsetFlag_10 = 0xC3B431 // Destroy if far and unset event flag 10

define MovTask_ButterflyTouch = 0xC3DEED // Butterfly effect on touch

define MovTask_CallNpcScriptOnTouch = 0xC36D18 // Call NPC primary text script on touch

Null events - C36BEA and C3A07F
Null event tasks - C3A271 and C3A272

I'll add more comments here if I identify anything else.

Improve build process

changes to most files aren't detected automatically. it would be nice to be able to autogenerate dependencies for the makefile...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.