forked from ArchipelagoMW/Archipelago
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
331 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.