mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
Merge remote-tracking branch 'yenatch/master'
Also merge pull request #145.
This commit is contained in:
commit
4eebcf0ae2
21
Makefile
21
Makefile
@ -11,16 +11,9 @@ TEXTFILES = \
|
||||
text/common_3.tx \
|
||||
main.tx
|
||||
|
||||
PNG_PICS = $(shell find gfx/pics/ -type f -name 'front.png')
|
||||
PNG_ANIMS = $(shell find gfx/pics/ -type f -name 'tiles.png')
|
||||
PNG_TRAINERS = gfx/trainers/*.png
|
||||
PNG_GFX = $(PNG_PICS) $(PNG_ANIMS) $(PNG_TRAINERS), $(filter-out $(shell find gfx/ -type f -name '*.png'))
|
||||
|
||||
LZ_PICS = $(shell find gfx/pics/ -type f -name 'front.lz')
|
||||
LZ_ANIMS = $(shell find gfx/pics/ -type f -name 'tiles.lz')
|
||||
LZ_TRAINERS = gfx/trainers/*.lz
|
||||
LZ_GFX = $(filter-out $(LZ_PICS) $(LZ_ANIMS) $(LZ_TRAINERS), $(shell find gfx/ -type f -name '*.lz'))
|
||||
|
||||
PNG_GFX = $(shell find gfx/ -type f -name '*.png')
|
||||
LZ_GFX = $(shell find gfx/ -type f -name '*.lz')
|
||||
TWOBPP_GFX = $(shell find gfx/ -type f -name '*.2bpp')
|
||||
|
||||
all: pokecrystal.gbc
|
||||
cmp baserom.gbc $<
|
||||
@ -39,11 +32,11 @@ pokecrystal.gbc: pokecrystal.o
|
||||
pngs:
|
||||
cd extras && python gfx.py mass-decompress && python gfx.py dump-pngs
|
||||
|
||||
lzs: $(LZ_PICS) $(LZ_ANIMS) $(LZ_TRAINERS) $(LZ_GFX)
|
||||
lzs: $(LZ_GFX) $(TWOBPP_GFX)
|
||||
|
||||
gfx/pics/%/front.lz: gfx/pics/%/front.png gfx/pics/%/tiles.2bpp
|
||||
python extras/gfx.py png-to-lz --front $< $(@D)/tiles.2bpp
|
||||
gfx/pics/%/tiles.2bpp:
|
||||
python extras/gfx.py png-to-lz --front $^
|
||||
gfx/pics/%/tiles.2bpp: gfx/pics/%/tiles.png
|
||||
python extras/gfx.py png-to-2bpp $<
|
||||
gfx/pics/%/back.lz: gfx/pics/%/back.png
|
||||
python extras/gfx.py png-to-lz --vert $<
|
||||
@ -51,4 +44,6 @@ gfx/trainers/%.lz: gfx/trainers/%.png
|
||||
python extras/gfx.py png-to-lz --vert $<
|
||||
.png.lz:
|
||||
python extras/gfx.py png-to-lz $<
|
||||
.png.2bpp:
|
||||
python extras/gfx.py png-to-lz $<
|
||||
|
||||
|
282
battle_constants.asm
Normal file
282
battle_constants.asm
Normal file
@ -0,0 +1,282 @@
|
||||
MAX_LEVEL EQU 100
|
||||
NUM_MOVES EQU 4
|
||||
|
||||
; move struct
|
||||
MOVE_LENGTH EQU 7
|
||||
MOVE_ANIM EQU 0
|
||||
MOVE_EFFECT EQU 1
|
||||
MOVE_POWER EQU 2
|
||||
MOVE_TYPE EQU 3
|
||||
MOVE_ACC EQU 4
|
||||
MOVE_PP EQU 5
|
||||
MOVE_CHANCE EQU 6
|
||||
|
||||
; stat constants
|
||||
NUM_STATS EQU 6
|
||||
STAT_HP EQU 1
|
||||
STAT_ATK EQU 2
|
||||
STAT_DEF EQU 3
|
||||
STAT_SPD EQU 4
|
||||
STAT_SATK EQU 5
|
||||
STAT_SDEF EQU 6
|
||||
STAT_MIN_NORMAL EQU 5
|
||||
STAT_MIN_HP EQU 10
|
||||
|
||||
; shiny dvs
|
||||
ATKDEFDV_SHINY EQU $EA
|
||||
SPDSPCDV_SHINY EQU $AA
|
||||
|
||||
; battle classes
|
||||
WILD_BATTLE EQU 1
|
||||
TRAINER_BATTLE EQU 2
|
||||
|
||||
; battle types
|
||||
BATTLETYPE_NORMAL EQU $00
|
||||
BATTLETYPE_TUTORIAL EQU $03
|
||||
BATTLETYPE_FISH EQU $04
|
||||
BATTLETYPE_ROAMING EQU $05
|
||||
BATTLETYPE_SHINY EQU $07
|
||||
BATTLETYPE_TREE EQU $08
|
||||
BATTLETYPE_FORCEITEM EQU $0a
|
||||
BATTLETYPE_SUICUNE EQU $0c
|
||||
|
||||
; battle variables
|
||||
BATTLE_VARS_SUBSTATUS1 EQU 0
|
||||
BATTLE_VARS_SUBSTATUS2 EQU 1
|
||||
BATTLE_VARS_SUBSTATUS3 EQU 2
|
||||
BATTLE_VARS_SUBSTATUS4 EQU 3
|
||||
BATTLE_VARS_SUBSTATUS5 EQU 4
|
||||
BATTLE_VARS_SUBSTATUS1_OPP EQU 5
|
||||
BATTLE_VARS_SUBSTATUS2_OPP EQU 6
|
||||
BATTLE_VARS_SUBSTATUS3_OPP EQU 7
|
||||
BATTLE_VARS_SUBSTATUS4_OPP EQU 8
|
||||
BATTLE_VARS_SUBSTATUS5_OPP EQU 9
|
||||
BATTLE_VARS_STATUS EQU 10
|
||||
BATTLE_VARS_STATUS_OPP EQU 11
|
||||
BATTLE_VARS_MOVE_ANIM EQU 12
|
||||
BATTLE_VARS_MOVE_EFFECT EQU 13
|
||||
BATTLE_VARS_MOVE_POWER EQU 14
|
||||
BATTLE_VARS_MOVE_TYPE EQU 15
|
||||
BATTLE_VARS_MOVE EQU 16
|
||||
BATTLE_VARS_LAST_COUNTER_MOVE EQU 17
|
||||
BATTLE_VARS_LAST_COUNTER_MOVE_OPP EQU 18
|
||||
BATTLE_VARS_LAST_MOVE EQU 19
|
||||
BATTLE_VARS_LAST_MOVE_OPP EQU 20
|
||||
|
||||
; status
|
||||
SLP EQU 7 ; 7 turns
|
||||
PSN EQU 3
|
||||
BRN EQU 4
|
||||
FRZ EQU 5
|
||||
PAR EQU 6
|
||||
|
||||
; substatus
|
||||
SUBSTATUS_IN_LOVE EQU 7
|
||||
SUBSTATUS_ENCORED EQU 6
|
||||
SUBSTATUS_ENDURE EQU 5
|
||||
SUBSTATUS_PERISH EQU 4
|
||||
SUBSTATUS_IDENTIFIED EQU 3
|
||||
SUBSTATUS_PROTECT EQU 2
|
||||
SUBSTATUS_CURSE EQU 1
|
||||
SUBSTATUS_NIGHTMARE EQU 0
|
||||
|
||||
SUBSTATUS_CURLED EQU 0
|
||||
|
||||
SUBSTATUS_CONFUSED EQU 7
|
||||
SUBSTATUS_FLYING EQU 6
|
||||
SUBSTATUS_UNDERGROUND EQU 5
|
||||
SUBSTATUS_CHARGED EQU 4
|
||||
SUBSTATUS_FLINCHED EQU 3
|
||||
SUBSTATUS_ROLLOUT EQU 1
|
||||
SUBSTATUS_BIDE EQU 0
|
||||
|
||||
SUBSTATUS_LEECH_SEED EQU 7
|
||||
SUBSTATUS_RAGE EQU 6
|
||||
SUBSTATUS_RECHARGE EQU 5
|
||||
SUBSTATUS_SUBSTITUTE EQU 4
|
||||
SUBSTATUS_FOCUS_ENERGY EQU 2
|
||||
SUBSTATUS_MIST EQU 1
|
||||
SUBSTATUS_UNLEASH EQU 0
|
||||
|
||||
SUBSTATUS_CANT_RUN EQU 7
|
||||
SUBSTATUS_DESTINY_BOND EQU 6
|
||||
SUBSTATUS_LOCK_ON EQU 5
|
||||
SUBSTATUS_TOXIC EQU 0
|
||||
|
||||
; environmental
|
||||
SCREENS_REFLECT EQU 4
|
||||
SCREENS_LIGHT_SCREEN EQU 3
|
||||
SCREENS_SAFEGUARD EQU 2
|
||||
SCREENS_SPIKES EQU 0
|
||||
|
||||
; weather
|
||||
WEATHER_RAIN EQU 1
|
||||
WEATHER_SUN EQU 2
|
||||
WEATHER_SANDSTORM EQU 3
|
||||
WEATHER_RAIN_END EQU 4
|
||||
WEATHER_SUN_END EQU 5
|
||||
WEATHER_SANDSTORM_END EQU 6
|
||||
|
||||
; move animations are 1:1 with move ids
|
||||
ANIM_CONFUSED EQU $103
|
||||
ANIM_SLEEP EQU $104
|
||||
ANIM_INLOVE EQU $10a
|
||||
|
||||
; move effects
|
||||
EFFECT_NORMAL_HIT EQU $00
|
||||
EFFECT_SLEEP EQU $01
|
||||
EFFECT_POISON_HIT EQU $02
|
||||
EFFECT_LEECH_HIT EQU $03
|
||||
EFFECT_BURN_HIT EQU $04
|
||||
EFFECT_FREEZE_HIT EQU $05
|
||||
EFFECT_PARALYZE_HIT EQU $06
|
||||
EFFECT_EXPLOSION EQU $07
|
||||
EFFECT_DREAM_EATER EQU $08
|
||||
EFFECT_MIRROR_MOVE EQU $09
|
||||
EFFECT_ATTACK_UP EQU $0a
|
||||
EFFECT_DEFENSE_UP EQU $0b
|
||||
EFFECT_SPEED_UP EQU $0c
|
||||
EFFECT_SP_ATTACK_UP EQU $0d
|
||||
EFFECT_SP_DEFENSE_UP EQU $0e
|
||||
EFFECT_ACCURACY_UP EQU $0f
|
||||
EFFECT_EVASION_UP EQU $10
|
||||
EFFECT_ALWAYS_HIT EQU $11
|
||||
EFFECT_ATTACK_DOWN EQU $12
|
||||
EFFECT_DEFENSE_DOWN EQU $13
|
||||
EFFECT_SPEED_DOWN EQU $14
|
||||
EFFECT_SP_ATTACK_DOWN EQU $15
|
||||
EFFECT_SP_DEFENSE_DOWN EQU $16
|
||||
EFFECT_ACCURACY_DOWN EQU $17
|
||||
EFFECT_EVASION_DOWN EQU $18
|
||||
EFFECT_HAZE EQU $19
|
||||
EFFECT_BIDE EQU $1a
|
||||
EFFECT_RAMPAGE EQU $1b
|
||||
EFFECT_WHIRLWIND EQU $1c
|
||||
EFFECT_MULTI_HIT EQU $1d
|
||||
EFFECT_CONVERSION EQU $1e
|
||||
EFFECT_FLINCH_HIT EQU $1f
|
||||
EFFECT_HEAL EQU $20
|
||||
EFFECT_TOXIC EQU $21
|
||||
EFFECT_PAY_DAY EQU $22
|
||||
EFFECT_LIGHT_SCREEN EQU $23
|
||||
EFFECT_TRI_ATTACK EQU $24
|
||||
EFFECT_UNUSED_25 EQU $25 ; unused
|
||||
EFFECT_OHKO EQU $26
|
||||
EFFECT_RAZOR_WIND EQU $27
|
||||
EFFECT_SUPER_FANG EQU $28
|
||||
EFFECT_STATIC_DAMAGE EQU $29
|
||||
EFFECT_BIND EQU $2a
|
||||
EFFECT_UNUSED_2B EQU $2b ; unused
|
||||
EFFECT_DOUBLE_HIT EQU $2c
|
||||
EFFECT_JUMP_KICK EQU $2d
|
||||
EFFECT_MIST EQU $2e
|
||||
EFFECT_FOCUS_ENERGY EQU $2f
|
||||
EFFECT_RECOIL_HIT EQU $30
|
||||
EFFECT_CONFUSE EQU $31
|
||||
EFFECT_ATTACK_UP_2 EQU $32
|
||||
EFFECT_DEFENSE_UP_2 EQU $33
|
||||
EFFECT_SPEED_UP_2 EQU $34
|
||||
EFFECT_SP_ATTACK_UP_2 EQU $35
|
||||
EFFECT_SP_DEFENSE_UP_2 EQU $36
|
||||
EFFECT_ACCURACY_UP_2 EQU $37
|
||||
EFFECT_EVASION_UP_2 EQU $38
|
||||
EFFECT_TRANSFORM EQU $39
|
||||
EFFECT_ATTACK_DOWN_2 EQU $3a
|
||||
EFFECT_DEFENSE_DOWN_2 EQU $3b
|
||||
EFFECT_SPEED_DOWN_2 EQU $3c
|
||||
EFFECT_SP_ATTACK_DOWN_2 EQU $3d
|
||||
EFFECT_SP_DEFENSE_DOWN_2 EQU $3e
|
||||
EFFECT_ACCURACY_DOWN_2 EQU $3f
|
||||
EFFECT_EVASION_DOWN_2 EQU $40
|
||||
EFFECT_REFLECT EQU $41
|
||||
EFFECT_POISON EQU $42
|
||||
EFFECT_PARALYZE EQU $43
|
||||
EFFECT_ATTACK_DOWN_HIT EQU $44
|
||||
EFFECT_DEFENSE_DOWN_HIT EQU $45
|
||||
EFFECT_SPEED_DOWN_HIT EQU $46
|
||||
EFFECT_SP_ATTACK_DOWN_HIT EQU $47
|
||||
EFFECT_SP_DEFENSE_DOWN_HIT EQU $48
|
||||
EFFECT_ACCURACY_DOWN_HIT EQU $49
|
||||
EFFECT_EVASION_DOWN_HIT EQU $4a
|
||||
EFFECT_SKY_ATTACK EQU $4b
|
||||
EFFECT_CONFUSE_HIT EQU $4c
|
||||
EFFECT_TWINEEDLE EQU $4d
|
||||
EFFECT_UNUSED_4E EQU $4e ; unused
|
||||
EFFECT_SUBSTITUTE EQU $4f
|
||||
EFFECT_HYPER_BEAM EQU $50
|
||||
EFFECT_RAGE EQU $51
|
||||
EFFECT_MIMIC EQU $52
|
||||
EFFECT_METRONOME EQU $53
|
||||
EFFECT_LEECH_SEED EQU $54
|
||||
EFFECT_SPLASH EQU $55
|
||||
EFFECT_DISABLE EQU $56
|
||||
EFFECT_LEVEL_DAMAGE EQU $57
|
||||
EFFECT_PSYWAVE EQU $58
|
||||
EFFECT_COUNTER EQU $59
|
||||
EFFECT_ENCORE EQU $5a
|
||||
EFFECT_PAIN_SPLIT EQU $5b
|
||||
EFFECT_SNORE EQU $5c
|
||||
EFFECT_CONVERSION2 EQU $5d
|
||||
EFFECT_LOCK_ON EQU $5e
|
||||
EFFECT_SKETCH EQU $5f
|
||||
EFFECT_DEFROST_OPPONENT EQU $60
|
||||
EFFECT_SLEEP_TALK EQU $61
|
||||
EFFECT_DESTINY_BOND EQU $62
|
||||
EFFECT_REVERSAL EQU $63
|
||||
EFFECT_SPITE EQU $64
|
||||
EFFECT_FALSE_SWIPE EQU $65
|
||||
EFFECT_HEAL_BELL EQU $66
|
||||
EFFECT_PRIORITY_HIT EQU $67
|
||||
EFFECT_TRIPLE_KICK EQU $68
|
||||
EFFECT_THIEF EQU $69
|
||||
EFFECT_MEAN_LOOK EQU $6a
|
||||
EFFECT_NIGHTMARE EQU $6b
|
||||
EFFECT_FLAME_WHEEL EQU $6c
|
||||
EFFECT_CURSE EQU $6d
|
||||
EFFECT_UNUSED_6E EQU $6e ; unused
|
||||
EFFECT_PROTECT EQU $6f
|
||||
EFFECT_SPIKES EQU $70
|
||||
EFFECT_FORESIGHT EQU $71
|
||||
EFFECT_PERISH_SONG EQU $72
|
||||
EFFECT_SANDSTORM EQU $73
|
||||
EFFECT_ENDURE EQU $74
|
||||
EFFECT_ROLLOUT EQU $75
|
||||
EFFECT_SWAGGER EQU $76
|
||||
EFFECT_FURY_CUTTER EQU $77
|
||||
EFFECT_ATTRACT EQU $78
|
||||
EFFECT_RETURN EQU $79
|
||||
EFFECT_PRESENT EQU $7a
|
||||
EFFECT_FRUSTRATION EQU $7b
|
||||
EFFECT_SAFEGUARD EQU $7c
|
||||
EFFECT_SACRED_FIRE EQU $7d
|
||||
EFFECT_MAGNITUDE EQU $7e
|
||||
EFFECT_BATON_PASS EQU $7f
|
||||
EFFECT_PURSUIT EQU $80
|
||||
EFFECT_RAPID_SPIN EQU $81
|
||||
EFFECT_UNUSED_82 EQU $82 ; unused
|
||||
EFFECT_UNUSED_83 EQU $83 ; unused
|
||||
EFFECT_MORNING_SUN EQU $84
|
||||
EFFECT_SYNTHESIS EQU $85
|
||||
EFFECT_MOONLIGHT EQU $86
|
||||
EFFECT_HIDDEN_POWER EQU $87
|
||||
EFFECT_RAIN_DANCE EQU $88
|
||||
EFFECT_SUNNY_DAY EQU $89
|
||||
EFFECT_STEEL_WING EQU $8a
|
||||
EFFECT_METAL_CLAW EQU $8b
|
||||
EFFECT_ANCIENTPOWER EQU $8c
|
||||
EFFECT_FAKE_OUT EQU $8d
|
||||
EFFECT_BELLY_DRUM EQU $8e
|
||||
EFFECT_PSYCH_UP EQU $8f
|
||||
EFFECT_MIRROR_COAT EQU $90
|
||||
EFFECT_SKULL_BASH EQU $91
|
||||
EFFECT_TWISTER EQU $92
|
||||
EFFECT_EARTHQUAKE EQU $93
|
||||
EFFECT_FUTURE_SIGHT EQU $94
|
||||
EFFECT_GUST EQU $95
|
||||
EFFECT_STOMP EQU $96
|
||||
EFFECT_SOLARBEAM EQU $97
|
||||
EFFECT_THUNDER EQU $98
|
||||
EFFECT_TELEPORT EQU $99
|
||||
EFFECT_BEAT_UP EQU $9a
|
||||
EFFECT_FLY EQU $9b
|
||||
EFFECT_DEFENSE_CURL EQU $9c
|
3791
constants.asm
3791
constants.asm
File diff suppressed because it is too large
Load Diff
252
extras/gfx.py
252
extras/gfx.py
@ -1184,18 +1184,25 @@ def dmg2rgb(word):
|
||||
alpha = 255
|
||||
return ((red<<3)+0b100, (green<<3)+0b100, (blue<<3)+0b100, alpha)
|
||||
|
||||
def rgb_to_dmg(color):
|
||||
word = (color['r'] / 8)
|
||||
word += (color['g'] / 8) << 5
|
||||
word += (color['b'] / 8) << 10
|
||||
return word
|
||||
|
||||
|
||||
def png_pal(filename):
|
||||
palette = []
|
||||
palette.append((255,255,255,255))
|
||||
with open(filename, 'rb') as pal_data:
|
||||
words = pal_data.read()
|
||||
dmg_pals = []
|
||||
for word in range(len(words)/2):
|
||||
dmg_pals.append(ord(words[word*2]) + ord(words[word*2+1])*0x100)
|
||||
for word in dmg_pals:
|
||||
palette.append(dmg2rgb(word))
|
||||
palette.append((000,000,000,255))
|
||||
white = (255,255,255,255)
|
||||
black = (000,000,000,255)
|
||||
for word in dmg_pals: palette += [dmg2rgb(word)]
|
||||
if white not in dmg_pals and len(palette) < 4: palette = [white] + palette
|
||||
if black not in dmg_pals and len(palette) < 4: palette += [black]
|
||||
return palette
|
||||
|
||||
|
||||
@ -1262,6 +1269,9 @@ def to_png(filein, fileout=None, pal_file=None, height=None, width=None):
|
||||
|
||||
lines = to_lines(flatten(image), width)
|
||||
|
||||
if pal_file == None:
|
||||
if os.path.exists(os.path.splitext(fileout)[0]+'.pal'):
|
||||
pal_file = os.path.splitext(fileout)[0]+'.pal'
|
||||
|
||||
if pal_file == None:
|
||||
palette = None
|
||||
@ -1303,17 +1313,13 @@ def to_2bpp(filein, fileout=None, palout=None):
|
||||
greyscale = info[3]['greyscale']
|
||||
|
||||
|
||||
# commented out for the moment
|
||||
|
||||
padding = { 'left': 0,
|
||||
'right': 0,
|
||||
'top': 0,
|
||||
'bottom': 0, }
|
||||
|
||||
#if width % 8 != 0:
|
||||
# padding['left'] = int(ceil((width / 8 + 8 - width) / 2))
|
||||
# padding['right'] = int(floor((width / 8 + 8 - width) / 2))
|
||||
|
||||
#if height % 8 != 0:
|
||||
# padding['top'] = int(ceil((height / 8 + 8 - height) / 2))
|
||||
# padding['bottom'] = int(floor((height / 8 + 8 - height) / 2))
|
||||
@ -1322,7 +1328,7 @@ def to_2bpp(filein, fileout=None, palout=None):
|
||||
# turn the flat values into something more workable
|
||||
|
||||
pixel_length = 4 # rgba
|
||||
image = []
|
||||
image = []
|
||||
|
||||
# while we're at it, let's size up the palette
|
||||
|
||||
@ -1331,53 +1337,53 @@ def to_2bpp(filein, fileout=None, palout=None):
|
||||
for line in rgba:
|
||||
newline = []
|
||||
for pixel in range(len(line)/pixel_length):
|
||||
i = pixel*pixel_length
|
||||
i = pixel * pixel_length
|
||||
color = { 'r': line[i ],
|
||||
'g': line[i+1],
|
||||
'b': line[i+2],
|
||||
'a': line[i+3], }
|
||||
newline.append(color)
|
||||
if color not in palette: palette.append(color)
|
||||
newline += [color]
|
||||
if color not in palette: palette += [color]
|
||||
image.append(newline)
|
||||
|
||||
# pad out any small palettes
|
||||
hues = {
|
||||
'white': { 'r': 0xff, 'g': 0xff, 'b': 0xff, 'a': 0xff },
|
||||
'black': { 'r': 0x00, 'g': 0x00, 'b': 0x00, 'a': 0xff },
|
||||
'grey': { 'r': 0x55, 'g': 0x55, 'b': 0x55, 'a': 0xff },
|
||||
'gray': { 'r': 0xaa, 'g': 0xaa, 'b': 0xaa, 'a': 0xff },
|
||||
}
|
||||
while len(palette) < 4:
|
||||
for hue in hues.values():
|
||||
if not any(color is hue for color in palette):
|
||||
palette += [hue]
|
||||
if len(palette) >= 4: break
|
||||
|
||||
# sort by luminance, because we can
|
||||
assert len(palette) <= 4, 'Palette should be 4 colors, is really ' + str(len(palette))
|
||||
|
||||
# sort by luminance
|
||||
def luminance(color):
|
||||
# this is actually in reverse, thanks to dmg/cgb palette ordering
|
||||
rough = { 'r': 4.7,
|
||||
'g': 1.4,
|
||||
'b': 13.8, }
|
||||
return sum(color[key] * -rough[key] for key in rough.keys())
|
||||
palette = sorted(palette, key=luminance)
|
||||
|
||||
palette = sorted(palette, key = lambda x:luminance(x))
|
||||
|
||||
# no palette fixing for now
|
||||
|
||||
assert len(palette) <= 4, 'Palette should be 4 colors, is really ' + str(len(palette))
|
||||
|
||||
|
||||
# spit out new palette (disabled for now)
|
||||
|
||||
def rgb_to_dmg(color):
|
||||
word = (color['r'] / 8) << 10
|
||||
word += (color['g'] / 8) << 5
|
||||
word += (color['b'] / 8)
|
||||
return word
|
||||
|
||||
palout = None
|
||||
|
||||
# spit out a new .pal file
|
||||
# disable this if it causes problems with paletteless images
|
||||
if palout == None:
|
||||
if os.path.exists(os.path.splitext(fileout)[0]+'.pal'):
|
||||
palout = os.path.splitext(fileout)[0]+'.pal'
|
||||
if palout != None:
|
||||
output = []
|
||||
for color in palette[1:3]:
|
||||
for color in palette:
|
||||
word = rgb_to_dmg(color)
|
||||
output.append(word>>8)
|
||||
output.append(word&0xff)
|
||||
output += [word & 0xff]
|
||||
output += [word >> 8]
|
||||
to_file(palout, output)
|
||||
|
||||
|
||||
# create a new map consisting of quaternary color ids
|
||||
|
||||
# create a new map of quaternary color ids
|
||||
map = []
|
||||
if padding['top']: map += [0] * (width + padding['left'] + padding['right']) * padding['top']
|
||||
for line in image:
|
||||
@ -1388,12 +1394,9 @@ def to_2bpp(filein, fileout=None, palout=None):
|
||||
if padding['bottom']: map += [0] * (width + padding['left'] + padding['right']) * padding['bottom']
|
||||
|
||||
# split it into strips of 8, and make them planar
|
||||
|
||||
num_columns = width / 8
|
||||
num_rows = height / 8
|
||||
|
||||
tile = 8 * 8
|
||||
|
||||
image = []
|
||||
for row in range(num_rows):
|
||||
for column in range(num_columns):
|
||||
@ -1437,10 +1440,7 @@ def mass_to_colored_png(debug=False):
|
||||
for name in files:
|
||||
if debug: print os.path.splitext(name), os.path.join(root, name)
|
||||
if os.path.splitext(name)[1] == '.2bpp':
|
||||
if os.path.splitext(name)[0]+'.pal' in files:
|
||||
to_png(os.path.join(root, name), None, os.path.join(root, os.path.splitext(name)[0]+'.pal'))
|
||||
else:
|
||||
to_png(os.path.join(root, name))
|
||||
to_png(os.path.join(root, name))
|
||||
os.utime(os.path.join(root, name), None)
|
||||
|
||||
# only monster and trainer pics for now
|
||||
@ -1458,7 +1458,7 @@ def mass_to_colored_png(debug=False):
|
||||
for name in files:
|
||||
if debug: print os.path.splitext(name), os.path.join(root, name)
|
||||
if os.path.splitext(name)[1] == '.2bpp':
|
||||
to_png(os.path.join(root, name), None, os.path.join(root, name[:-5]+'.pal'))
|
||||
to_png(os.path.join(root, name))
|
||||
os.utime(os.path.join(root, name), None)
|
||||
|
||||
|
||||
@ -1518,101 +1518,107 @@ def dump_tileset_pngs():
|
||||
tileset_filename = "../gfx/tilesets/" + str(tileset_id).zfill(2) + ".lz"
|
||||
lz_to_png_by_file(tileset_filename)
|
||||
|
||||
if __name__ == "__main__":
|
||||
def decompress_frontpic(lz_file):
|
||||
"""
|
||||
Convert the pic portion of front.lz to front.2bpp
|
||||
"""
|
||||
lz = open(lz_file, 'rb').read()
|
||||
to_file(Decompressed(lz).pic, os.path.splitext(filein)[0] + '.2bpp')
|
||||
|
||||
def decompress_frontpic_anim(lz_file):
|
||||
"""
|
||||
Convert the animation tile portion of front.lz to tiles.2bpp
|
||||
"""
|
||||
lz = open(lz_file, 'rb').read()
|
||||
to_file(Decompressed(lz).animtiles, 'tiles.2bpp')
|
||||
|
||||
def expand_pic_palettes():
|
||||
"""
|
||||
Add white and black to palette files with fewer than 4 colors.
|
||||
|
||||
Pokemon Crystal only defines two colors for a pic palette to
|
||||
save space, filling in black/white at runtime.
|
||||
Instead of managing palette files of varying length, black
|
||||
and white are added to pic palettes and excluded from incbins.
|
||||
"""
|
||||
for root, dirs, files in os.walk('../gfx/'):
|
||||
if 'gfx/pics' in root or 'gfx/trainers' in root:
|
||||
for name in files:
|
||||
if os.path.splitext(name)[1] == '.pal':
|
||||
filename = os.path.join(root, name)
|
||||
palette = bytearray(open(filename, 'rb').read())
|
||||
w = bytearray([0xff, 0x7f])
|
||||
b = bytearray([0x00, 0x00])
|
||||
if len(palette) == 4:
|
||||
with open(filename, 'wb') as out:
|
||||
out.write(w + palette + b)
|
||||
|
||||
if __name__ == "__main__":
|
||||
debug = False
|
||||
|
||||
if sys.argv[1] == 'dump-pngs':
|
||||
argv = [None] * 5
|
||||
for i, arg in enumerate(sys.argv):
|
||||
argv[i] = arg
|
||||
|
||||
if argv[1] == 'dump-pngs':
|
||||
mass_to_colored_png()
|
||||
|
||||
elif sys.argv[1] == 'lz-to-png':
|
||||
lz_to_png_by_file(sys.argv[2])
|
||||
elif argv[1] == 'front-to-2bpp':
|
||||
decompress_frontpic(argv[2])
|
||||
|
||||
elif sys.argv[1] == 'png-to-lz':
|
||||
elif argv[1] == 'anim-from-front':
|
||||
decompress_frontpic_anim(argv[2])
|
||||
|
||||
elif argv[1] == 'lz-to-2bpp':
|
||||
name = os.path.splitext(argv[3])[0]
|
||||
lz = open(name+'.lz', 'rb').read()
|
||||
if argv[2] == '--vert':
|
||||
to_file(name+'.2bpp', Decompressed(lz, 'vert').output)
|
||||
else:
|
||||
to_file(name+'.2bpp', Decompressed(lz).output)
|
||||
|
||||
elif argv[1] == 'lz-to-png':
|
||||
if argv[2] == '--vert':
|
||||
name = os.path.splitext(argv[3])[0]
|
||||
lz = open(name+'.lz', 'rb').read()
|
||||
to_file(name+'.2bpp', Decompressed(lz, 'vert').output)
|
||||
pic = open(name+'.2bpp', 'rb').read()
|
||||
to_file(name+'.png', to_png(pic))
|
||||
else:
|
||||
lz_to_png_by_file(argv[2])
|
||||
|
||||
elif argv[1] == 'png-to-lz':
|
||||
# python gfx.py png-to-lz [--front anim(2bpp) | --vert] [png]
|
||||
|
||||
# python gfx.py png-to-lz --front [anim(2bpp)] [png]
|
||||
if sys.argv[2] == '--front':
|
||||
|
||||
# front.png and tiles.png are combined before compression,
|
||||
# so we have to pass in things like anim file and pic size
|
||||
name = os.path.splitext(sys.argv[4])[0]
|
||||
|
||||
if argv[2] == '--front':
|
||||
# front.2bpp and tiles.2bpp are combined before compression,
|
||||
# so we have to pass in the anim file and pic size
|
||||
name = os.path.splitext(argv[4])[0]
|
||||
to_2bpp(name+'.png', name+'.2bpp')
|
||||
pic = open(name+'.2bpp', 'rb').read()
|
||||
anim = open(sys.argv[3], 'rb').read()
|
||||
anim = open(argv[3], 'rb').read()
|
||||
size = int(sqrt(len(pic)/16)) # assume square pic
|
||||
to_file(name+'.lz', Compressed(pic + anim, 'vert', size).output)
|
||||
|
||||
|
||||
# python gfx.py png-to-lz --vert [png]
|
||||
elif sys.argv[2] == '--vert':
|
||||
|
||||
# others are vertically oriented (frontpics are always vertical)
|
||||
|
||||
name = os.path.splitext(sys.argv[3])[0]
|
||||
|
||||
elif argv[2] == '--vert':
|
||||
name = os.path.splitext(argv[3])[0]
|
||||
to_2bpp(name+'.png', name+'.2bpp')
|
||||
pic = open(name+'.2bpp', 'rb').read()
|
||||
to_file(name+'.lz', Compressed(pic, 'vert').output)
|
||||
|
||||
|
||||
# python gfx.py png-to-lz [png]
|
||||
else:
|
||||
png_to_lz(argv[2])
|
||||
|
||||
# standard usage
|
||||
elif argv[1] == 'png-to-2bpp':
|
||||
to_2bpp(argv[2])
|
||||
|
||||
png_to_lz(sys.argv[2])
|
||||
elif argv[1] == '2bpp-to-lz':
|
||||
if argv[2] == '--vert':
|
||||
filein = argv[3]
|
||||
fileout = argv[4]
|
||||
compress_file(filein, fileout, 'vert')
|
||||
else:
|
||||
filein = argv[2]
|
||||
fileout = argv[3]
|
||||
compress_file(filein, fileout)
|
||||
|
||||
elif sys.argv[1] == 'png-to-2bpp':
|
||||
to_2bpp(sys.argv[2])
|
||||
|
||||
|
||||
elif sys.argv[1] == 'de':
|
||||
# python gfx.py de [addr] [fileout] [mode]
|
||||
|
||||
rom = load_rom()
|
||||
|
||||
addr = int(sys.argv[2],16)
|
||||
fileout = sys.argv[3]
|
||||
mode = sys.argv[4]
|
||||
decompress_from_address(addr, fileout, mode)
|
||||
if debug: print 'decompressed to ' + sys.argv[3] + ' from ' + hex(int(sys.argv[2],16)) + '!'
|
||||
|
||||
elif sys.argv[1] == 'lz':
|
||||
# python gfx.py lz [filein] [fileout] [mode]
|
||||
filein = sys.argv[2]
|
||||
fileout = sys.argv[3]
|
||||
mode = sys.argv[4]
|
||||
compress_file(filein, fileout, mode)
|
||||
if debug: print 'compressed ' + filein + ' to ' + fileout + '!'
|
||||
|
||||
elif sys.argv[1] == 'lzf':
|
||||
# python gfx.py lzf [id] [fileout]
|
||||
compress_monster_frontpic(int(sys.argv[2]), sys.argv[3])
|
||||
|
||||
elif sys.argv[1] == 'un':
|
||||
# python gfx.py un [address] [num_tiles] [filename]
|
||||
rom = load_rom()
|
||||
get_uncompressed_gfx(int(sys.argv[2],16), int(sys.argv[3]), sys.argv[4])
|
||||
|
||||
elif sys.argv[1] == 'pal':
|
||||
# python gfx.py pal [address] [length]
|
||||
rom = load_rom()
|
||||
print grab_palettes(int(sys.argv[2],16), int(sys.argv[3]))
|
||||
|
||||
elif sys.argv[1] == 'png':
|
||||
|
||||
if '.2bpp' in sys.argv[2]:
|
||||
if sys.argv[4] == 'greyscale':
|
||||
to_png(sys.argv[2], sys.argv[3])
|
||||
else:
|
||||
to_png(sys.argv[2], sys.argv[3], sys.argv[4])
|
||||
|
||||
elif '.png' in sys.argv[2]:
|
||||
to_2bpp(sys.argv[2], sys.argv[3])
|
||||
|
||||
elif sys.argv[1] == 'mass-decompress':
|
||||
mass_decompress()
|
||||
if debug: print 'decompressed known gfx to pokecrystal/gfx/!'
|
||||
elif argv[1] == '2bpp-to-png':
|
||||
to_png(argv[2])
|
||||
|
||||
|
2
gbhw.asm
2
gbhw.asm
@ -10,6 +10,8 @@ MBC3RTC EQU $a000
|
||||
SRAM_DISABLE EQU $00
|
||||
SRAM_ENABLE EQU $0a
|
||||
|
||||
NUM_SRAM_BANKS EQU 4
|
||||
|
||||
RTC_S EQU $08 ; Seconds 0-59 (0-3Bh)
|
||||
RTC_M EQU $09 ; Minutes 0-59 (0-3Bh)
|
||||
RTC_H EQU $0a ; Hours 0-23 (0-17h)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user