Compare commits
7 Commits
a019fa6478
...
4468721621
| Author | SHA1 | Date | |
|---|---|---|---|
| 4468721621 | |||
| becff60e05 | |||
| 1edd600272 | |||
| 78dd5c65fc | |||
| ec81a900ef | |||
| ea8498f402 | |||
| f52a6c02c6 |
28
Utils.py
28
Utils.py
@@ -8,6 +8,7 @@ import urllib.parse
|
||||
import urllib.request
|
||||
import xml.etree.ElementTree as ET
|
||||
from collections import defaultdict
|
||||
from hashlib import md5
|
||||
from itertools import count
|
||||
from math import factorial
|
||||
from pathlib import Path
|
||||
@@ -102,31 +103,13 @@ def close_console():
|
||||
pass
|
||||
|
||||
|
||||
def make_new_base2current(old_rom='Zelda no Densetsu - Kamigami no Triforce (Japan).sfc', new_rom='working.sfc'):
|
||||
import hashlib
|
||||
import json
|
||||
from collections import OrderedDict
|
||||
with open(old_rom, 'rb') as stream:
|
||||
old_rom_data = bytearray(stream.read())
|
||||
def get_new_romhash(new_rom='working.sfc'):
|
||||
with open(new_rom, 'rb') as stream:
|
||||
new_rom_data = bytearray(stream.read())
|
||||
# extend to 2 mb
|
||||
old_rom_data.extend(bytearray([0x00] * (2097152 - len(old_rom_data))))
|
||||
|
||||
out_data = OrderedDict()
|
||||
for idx, old in enumerate(old_rom_data):
|
||||
new = new_rom_data[idx]
|
||||
if old != new:
|
||||
out_data[idx] = [int(new)]
|
||||
for offset in reversed(list(out_data.keys())):
|
||||
if offset - 1 in out_data:
|
||||
out_data[offset-1].extend(out_data.pop(offset))
|
||||
with open('data/base2current.json', 'wt') as outfile:
|
||||
json.dump([{key: value} for key, value in out_data.items()], outfile, separators=(",", ":"))
|
||||
|
||||
basemd5 = hashlib.md5()
|
||||
basemd5 = md5()
|
||||
basemd5.update(new_rom_data)
|
||||
return "New Rom Hash: " + basemd5.hexdigest()
|
||||
return basemd5.hexdigest()
|
||||
|
||||
|
||||
def kth_combination(k, l, r):
|
||||
@@ -787,12 +770,11 @@ class bidict(dict):
|
||||
class HexInt(int): pass
|
||||
|
||||
def hex_representer(dumper, data):
|
||||
import yaml
|
||||
return yaml.ScalarNode('tag:yaml.org,2002:int', f"{data:#0{4}x}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(make_new_base2current())
|
||||
print("New Rom Hash:", get_new_romhash())
|
||||
# read_entrance_data(old_rom=sys.argv[1])
|
||||
# room_palette_data(old_rom=sys.argv[1])
|
||||
# extract_data_from_us_rom(sys.argv[1])
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
"""Setlist class definitions."""
|
||||
import random as random_
|
||||
from collections import Hashable, MutableSequence, MutableSet, Sequence, Set
|
||||
from collections import (
|
||||
Hashable,
|
||||
MutableSequence,
|
||||
MutableSet,
|
||||
Sequence,
|
||||
Set,
|
||||
)
|
||||
|
||||
from . import _util
|
||||
|
||||
|
||||
@@ -471,10 +471,6 @@ vanilla_sheets = [
|
||||
(0x00, 0x00, 0x00, 0x00), (0x00, 0x00, 0x00, 0x00), (0x00, 0x00, 0x00, 0x00), (0x00, 0x00, 0x00, 0x00),
|
||||
(0x00, 0x00, 0x00, 0x00), (0x00, 0x00, 0x00, 0x00), (0x00, 0x00, 0x00, 0x00), (0x00, 0x00, 0x00, 0x00),
|
||||
(0x00, 0x00, 0x00, 0x00), (0x00, 0x00, 0x00, 0x08), (0x5D, 0x49, 0x00, 0x52), (0x55, 0x49, 0x42, 0x43),
|
||||
# (0x61, 0x62, 0x63, 0x50), (0x61, 0x62, 0x63, 0x50), (0x61, 0x62, 0x63, 0x50), (0x61, 0x62, 0x63, 0x50),
|
||||
# (0x61, 0x62, 0x63, 0x50), (0x61, 0x62, 0x63, 0x50), (0x61, 0x56, 0x57, 0x50), (0x61, 0x62, 0x63, 0x50),
|
||||
# (0x61, 0x62, 0x63, 0x50), (0x61, 0x56, 0x57, 0x50), (0x61, 0x56, 0x63, 0x50), (0x61, 0x56, 0x57, 0x50),
|
||||
# (0x61, 0x56, 0x33, 0x50), (0x61, 0x56, 0x57, 0x50), (0x61, 0x62, 0x63, 0x50), (0x61, 0x62, 0x63, 0x50)
|
||||
]
|
||||
|
||||
required_boss_sheets = {EnemySprite.ArmosKnight: 9, EnemySprite.Lanmolas: 11, EnemySprite.Moldorm: 12,
|
||||
|
||||
Reference in New Issue
Block a user