LADX: generate without rom (#4278)

This commit is contained in:
threeandthreee
2025-07-26 16:16:00 -04:00
committed by GitHub
parent fa49fef695
commit 7a8048a8fd
11 changed files with 317 additions and 290 deletions

View File

@@ -1,7 +1,6 @@
from ..backgroundEditor import BackgroundEditor
from .aesthetics import rgb_to_bin, bin_to_rgb, prepatch
import copy
import pkgutil
CHAR_MAP = {'z': 0x3E, '-': 0x3F, '.': 0x39, ':': 0x42, '?': 0x3C, '!': 0x3D}
def _encode(s):
@@ -18,17 +17,18 @@ def _encode(s):
return result
def setRomInfo(rom, seed, seed_name, settings, player_name, player_id):
def setRomInfo(rom, patch_data):
seed_name = patch_data["seed_name"]
try:
seednr = int(seed, 16)
seednr = int(patch_data["seed"], 16)
except:
import hashlib
seednr = int(hashlib.md5(seed).hexdigest(), 16)
seednr = int(hashlib.md5(str(patch_data["seed"]).encode()).hexdigest(), 16)
if settings.race:
if patch_data["is_race"]:
seed_name = "Race"
if isinstance(settings.race, str):
seed_name += " " + settings.race
if isinstance(patch_data["is_race"], str):
seed_name += " " + patch_data["is_race"]
rom.patch(0x00, 0x07, "00", "01")
else:
rom.patch(0x00, 0x07, "00", "52")
@@ -37,7 +37,7 @@ def setRomInfo(rom, seed, seed_name, settings, player_name, player_id):
#line_2_hex = _encode(seed[16:])
BASE_DRAWING_AREA = 0x98a0
LINE_WIDTH = 0x20
player_id_text = f"Player {player_id}:"
player_id_text = f"Player {patch_data['player']}:"
for n in (3, 4):
be = BackgroundEditor(rom, n)
ba = BackgroundEditor(rom, n, attributes=True)
@@ -45,9 +45,9 @@ def setRomInfo(rom, seed, seed_name, settings, player_name, player_id):
for n, v in enumerate(_encode(player_id_text)):
be.tiles[BASE_DRAWING_AREA + LINE_WIDTH * 5 + 2 + n] = v
ba.tiles[BASE_DRAWING_AREA + LINE_WIDTH * 5 + 2 + n] = 0x00
for n, v in enumerate(_encode(player_name)):
be.tiles[BASE_DRAWING_AREA + LINE_WIDTH * 6 + 0x13 - len(player_name) + n] = v
ba.tiles[BASE_DRAWING_AREA + LINE_WIDTH * 6 + 0x13 - len(player_name) + n] = 0x00
for n, v in enumerate(_encode(patch_data['player_name'])):
be.tiles[BASE_DRAWING_AREA + LINE_WIDTH * 6 + 0x13 - len(patch_data['player_name']) + n] = v
ba.tiles[BASE_DRAWING_AREA + LINE_WIDTH * 6 + 0x13 - len(patch_data['player_name']) + n] = 0x00
for n, v in enumerate(line_1_hex):
be.tiles[0x9a20 + n] = v
ba.tiles[0x9a20 + n] = 0x00