FirenX / emu-coop

Lua scripts for turning 1-player games into 2-player games using inventory sharing.
9 stars 3 forks source link

Implementation of LTTP + SM Randomizer? #11

Open mysterypaint opened 6 years ago

mysterypaint commented 6 years ago

Are there any plans to incorporate the LTTP + SM randomizer on https://alttsm.speedga.me/? I would absolutely love to play that version of randomizer with a few of my friends.

Ionshard commented 6 years ago

Hopefully this is relatively easy to do, all current memory locations should be visible via the source code (https://github.com/tewtal/alttp_sm_combo_randomizer/blob/master/app/Region/SuperMetroid/Brinstar/Blue.php)

mysterypaint commented 6 years ago

It also seems that the memory for Super Metroid (unsure about ALTTP?) has been re-mapped.

This might prove useful, too: https://github.com/tewtal/alttp_sm_combo_randomizer_rom

EDIT: Here's some notes I took so far on the data,

--- Super Metroid --- 7E:05E7 - 7E:05E8 Often used to check bits for completed tasks/picked up items

7E:0998 - 7E:0999 Game state. 01 = Title screen, 04 = menus, 05 = Load area, 06 = Loading game, 07 = Samus being electrified in save capsule, 08 = normal gameplay, 0C = pausing, 0F = paused, 12 = unpausing, 15, 17, 18, 19, 1A = Dead or dying, 23 = Timer up. 24 = blackout and gameover (Ceres explodes if not escaping Zebes). 2A = intro demos

7E:D7C0 - 7E:DE1B RAM that is saved to SRAM

$A0 is a mirror bank maybe the sram is what is called sxxxx in the ram search $A0 is $20

$7E is WRAM, not SRAM

; Repoint all vectors so we can control in software what game to run ; SRAM $a26000 toggles the game and interrupt vectors ; 0 = ALTTP ; 1 = SM

total also said, in a previous log on the ALttP+SM Randomizer Server on 6/24/18 in #development:

"any coop thing will be quite tricky to do since when there's a game switch it pretty much switches out all RAM"

"and things can't be tracked only from SRAM either so you have to constantly detect what game is running and use different offsets"

There are also a couple of links I'm keeping track of, particularly the first one:

https://github.com/Skarsnik/Magic2snes/blob/master/examples/smalttptracker/engine.js https://en.wikibooks.org/wiki/Super_NES_Programming/SNES_memory_map https://www.cs.umb.edu/~bazz/snes/cartridges/lorom.html


I was also wondering how the script should handle dying in Super Metroid, and rolling back the save. I discussed it a bit with some others on the IRC and they brought up 4 different ideas:

1) Do not grant items between players until the game is saved 2) Take the item away immediately, killing the LttP player 3) Save items picked up regardless of where and when 4) Items picked up in Super Metroid save upon room transitions

We think option 1 is the most authentic, but option 4 will prevent SM runners from going out of their way to save the game while also preventing death abuse to save time with backtracking.