Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLX5 committed Aug 23, 2024
1 parent f10c5ba commit 9b65f14
Show file tree
Hide file tree
Showing 6 changed files with 331 additions and 10 deletions.
134 changes: 134 additions & 0 deletions worlds/mmx2/Aesthetics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import struct

from typing import Dict, List

player_palettes = {
"blue": [
"$35D0","$048E","$239D","$091E","$7B6F","$7A8A","$5963","$7E00",
"$7900","$40C4","$42DF","$2597","$1110","$739C","$4E73","$0C63",
],
"gold_armor": [
"$35D0","$048E","$239D","$091E","$7BFF","$1F9F","$09DF","$73DF",
"$0ADE","$055D","$42DF","$2597","$1110","$4FBF","$121D","$0C63",
],
"acid_burst": [
"$35D0","$048E","$239D","$091E","$1F1E","$11F8","$0132","$43F7",
"$1BAC","$1689","$42DF","$2597","$1110","$739C","$4E73","$0C63",
],
"parasitic_bomb": [
"$35D0","$048E","$239D","$091E","$6776","$424E","$2547","$03FF",
"$02D7","$018D","$42DF","$2597","$1110","$739C","$4E73","$0C63",
],
"triad_thunder": [
"$35D0","$048E","$239D","$091E","$4F9A","$274F","$222C","$7E14",
"$5D0E","$3C8C","$42DF","$2597","$1110","$739C","$4E73","$0C63",
],
"spinning_blade": [
"$35D0","$048E","$239D","$091E","$6318","$4210","$2108","$195F",
"$0098","$0010","$42DF","$2597","$1110","$739C","$4E73","$0C63",
],
"ray_splasher": [
"$35D0","$048E","$239D","$091E","$03FF","$02D7","$018D","$1EDE",
"$11B8","$00F2","$42DF","$2597","$1110","$739C","$4E73","$0C63",
],
"gravity_well": [
"$35D0","$048E","$239D","$091E","$531C","$3214","$110C","$7DFE",
"$6518","$5093","$42DF","$2597","$1110","$739C","$4E73","$0C63",
],
"frost_shield": [
"$35D0","$048E","$239D","$091E","$7E3A","$7174","$58EF","$7BAF",
"$6B29","$5264","$42DF","$2597","$1110","$739C","$4E73","$0C63",
],
"tornado_fang": [
"$35D0","$048E","$239D","$091E","$1EDE","$0976","$0050","$73D0",
"$5B08","$3A00","$42DF","$2597","$1110","$739C","$4E73","$0C63",
],
"crystal_hunter": [
"$35D0","$048E","$239D","$091E","$7F3E","$7256","$5DB1","$7B6F",
"$7A8A","$59A5","$42DF","$2597","$1110","$7BDE","$4E73","$0C63",
],
"bubble_splash": [
"$35D0","$048E","$239D","$091E","$773F","$5639","$3D16","$131F",
"$0657","$01B1","$42DF","$2597","$1110","$7BDE","$4E73","$0C63",
],
"silk_shot": [
"$35D0","$048E","$239D","$091E","$5FF4","$3F2C","$1E65","$1E1F",
"$011F","$00F6","$42DF","$2597","$1110","$7BDE","$4E73","$0C63",
],
"spin_wheel": [
"$35D0","$048E","$239D","$091E","$7F7F","$7E59","$75B5","$2B00",
"$2240","$1DC4","$42DF","$2597","$1110","$7BDE","$4E73","$0C63",
],
"sonic_slicer": [
"$35D0","$048E","$239D","$091E","$031F","$021F","$017B","$75AB",
"$590A","$28E8","$42DF","$2597","$1110","$7BDE","$4E73","$0C63",
],
"strike_chain": [
"$35D0","$048E","$239D","$091E","$779C","$62D6","$4E10","$7A7A",
"$75D2","$5CEF","$42DF","$2597","$1110","$7BDE","$4E73","$0C63",
],
"magnet_mine": [
"$35D0","$048E","$239D","$091E","$2FFF","$0F18","$0A52","$4E31",
"$398C","$2908","$42DF","$2597","$1110","$7BDE","$4E73","$0C63",
],
"speed_burner": [
"$35D0","$048E","$239D","$091E","$7F98","$7ACF","$6645","$10DF",
"$0CB7","$0452","$42DF","$2597","$1110","$7BDE","$4E73","$0C63",
],
"homing_torpedo": [
"$35D0","$048E","$22FF","$0059","$5B7F","$46DB","$3657","$4250",
"$35ED","$2168","$42DF","$2597","$1110","$7BDE","$4E73","$14A5",
],
"chameleon_sting": [
"$35D0","$048E","$22FF","$0059","$73D8","$574C","$3EE4","$2AC3",
"$2A44","$1541","$42DF","$2597","$1110","$7BDE","$4E73","$14A5",
],
"rolling_shield": [
"$35D0","$048E","$22FF","$0059","$6BB9","$5714","$46B0","$4E1E",
"$311C","$209A","$42DF","$2597","$1110","$7BDE","$4E73","$14A5",
],
"fire_wave": [
"$35D0","$048E","$22FF","$0059","$3F9F","$229F","$0D9E","$055E",
"$0CFA","$0074","$42DF","$2597","$1110","$7BDE","$4E73","$14A5",
],
"storm_tornado": [
"$35D0","$048E","$22FF","$0059","$731F","$625C","$5A1A","$4973",
"$4953","$3CCE","$42DF","$2597","$1110","$7BDE","$4E73","$14A5",
],
"electric_spark": [
"$35D0","$048E","$22FF","$0059","$6F7B","$5AD6","$5294","$06DF",
"$05F8","$014F","$42DF","$2597","$1110","$7BDE","$4E73","$14A5",
],
"boomerang_cutter": [
"$35D0","$048E","$22FF","$0059","$6BB9","$5714","$46B0","$49CE",
"$418C","$2908","$42DF","$2597","$1110","$7BDE","$4E73","$14A5",
],
"shotgun_ice": [
"$35D0","$048E","$239D","$091E","$2B9F","$1ABD","$11B5","$7F87",
"$766A","$79C7","$42DF","$2597","$1110","$7BDE","$4210","$0C63",
],
}

def get_palette_bytes(palette: Dict[str, List]) -> bytearray:
output_data = bytearray()
for hexcol in palette:
if hexcol.startswith("$"):
hexcol = hexcol.replace("$", "")
colint = int(hexcol, 16)
output_data.extend(bytearray(struct.pack("H", colint)))
else:
if hexcol.startswith("#"):
hexcol = hexcol.replace("#", "")
colint = int(hexcol, 16)
col = ((colint & 0xFF0000) >> 16, (colint & 0xFF00) >> 8, colint & 0xFF)
col = tuple(x for x in col)
byte_data = rgb888_to_bgr555(col[0], col[1], col[2])
output_data.extend(bytearray(byte_data))
return output_data

def rgb888_to_bgr555(red, green, blue) -> bytes:
red = red >> 3
green = green >> 3
blue = blue >> 3
outcol = (blue << 10) + (green << 5) + red
return struct.pack("H", outcol)
137 changes: 136 additions & 1 deletion worlds/mmx2/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from Options import Choice, Range, Toggle, DefaultOnToggle, OptionDict, OptionSet, OptionGroup, DeathLink, PerGameCommonOptions, StartInventoryPool
from schema import Schema, And, Use, Optional

from .Rom import action_buttons, action_names
from .Rom import action_buttons, action_names, x_palette_set_offsets
from .Weaknesses import boss_weaknesses, weapons_chaotic

class EnergyLink(DefaultOnToggle):
Expand Down Expand Up @@ -274,6 +274,119 @@ class LogicHelmetCheckpoints(Toggle):
"""
display_name = "Helmet Checkpoints In Logic"

class BasePalette(Choice):
"""
Base class for palettes
"""
option_blue = 0
option_gold_armor = 1
option_charge_blue = 2
option_charge_pink = 3
option_charge_red = 4
option_charge_green = 5
option_acid_burst = 6
option_parasitic_bomb = 7
option_triad_thunder = 8
option_spinning_blade = 9
option_ray_splasher = 10
option_gravity_well = 11
option_frost_shield = 12
option_tornado_fang = 13
option_crystal_hunter = 14
option_bubble_splash = 15
option_silk_shot = 16
option_spin_wheel = 17
option_sonic_slicer = 18
option_strike_chain = 19
option_magnet_mine = 20
option_speed_burner = 21
option_homing_torpedo = 22
option_chameleon_sting = 23
option_rolling_shield = 24
option_fire_wave = 25
option_storm_tornado = 26
option_electric_spark = 27
option_boomerang_cutter = 28
option_shotgun_ice = 29


class PaletteDefault(BasePalette):
"""
Which color to use for X's default color
"""
display_name = "X Palette"
default = 0

class PaletteCrystalHunter(BasePalette):
"""
Which color to use for X's Crystal Hunter
"""
display_name = "Crystal Hunter Palette"
default = 14

class PaletteBubbleSplash(BasePalette):
"""
Which color to use for X's Bubble Splash
"""
display_name = "Bubble Splash Palette"
default = 15

class PaletteSilkShot(BasePalette):
"""
Which color to use for X's Silk Shot
"""
display_name = "Silk Shot Palette"
default = 16

class PaletteSpinWheel(BasePalette):
"""
Which color to use for X's Spin Wheel
"""
display_name = "Spin Wheel Palette"
default = 17

class PaletteSonicSlicer(BasePalette):
"""
Which color to use for X's Sonic Slicer
"""
display_name = "Sonic Slicer Palette"
default = 18

class PaletteStrikeChain(BasePalette):
"""
Which color to use for X's Strike Chain
"""
display_name = "Strike Chain Palette"
default = 19

class PaletteMagnetMine(BasePalette):
"""
Which color to use for X's Magnet Mine
"""
display_name = "Magnet Mine Palette"
default = 20

class PaletteSpeedBurner(BasePalette):
"""
Which color to use for X's Speed Burner
"""
display_name = "Speed Burner Palette"
default = 21

class SetPalettes(OptionDict):
"""
Allows you to create colors for each weapon X has. Includes charge levels and Gold Armor customization.
This will override the option preset
Each one expects 16 values which are mapped to X's colors.
The values can be in SNES RGB (bgr555) with the $ prefix or PC RGB (rgb888) with the # prefix.
"""
display_name = "Set Custom Palettes"
schema = Schema({
Optional(color_set): list for color_set in x_palette_set_offsets.keys()
})
default = {}

mmx2_option_groups = [
OptionGroup("Gameplay Options", [
StartingLifeCount,
Expand Down Expand Up @@ -302,6 +415,18 @@ class LogicHelmetCheckpoints(Toggle):
BaseBossRematchCount,
BaseBundleUnlock,
]),
OptionGroup("Aesthetic", [
SetPalettes,
PaletteDefault,
PaletteCrystalHunter,
PaletteBubbleSplash,
PaletteSilkShot,
PaletteSpinWheel,
PaletteSonicSlicer,
PaletteStrikeChain,
PaletteMagnetMine,
PaletteSpeedBurner,
]),
]

@dataclass
Expand Down Expand Up @@ -333,3 +458,13 @@ class MMX2Options(PerGameCommonOptions):
base_heart_tank_count: BaseHeartTankCount
base_sub_tank_count: BaseSubTankCount
x_hunters_medal_count: XHuntersMedalCount
player_palettes: SetPalettes
palette_default: PaletteDefault
palette_crystal_hunter: PaletteCrystalHunter
palette_bubble_splash: PaletteBubbleSplash
palette_silk_shot: PaletteSilkShot
palette_spin_wheel: PaletteSpinWheel
palette_sonic_slicer: PaletteSonicSlicer
palette_strike_chain: PaletteStrikeChain
palette_magnet_mine: PaletteMagnetMine
palette_speed_burner: PaletteSpeedBurner
Loading

0 comments on commit 9b65f14

Please sign in to comment.