mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-04-09 05:44:44 -07:00
Merge remote-tracking branch 'yenatch/merge-kanzure-again' into master
This commit is contained in:
commit
c61b3d42ad
@ -6850,7 +6850,7 @@ Function0x365d7: ; 365d7
|
||||
ld a, $5
|
||||
call Function0x3661d
|
||||
|
||||
ld hl, $6d45
|
||||
ld hl, BadgeStatBoosts
|
||||
call CallBankF
|
||||
|
||||
call SwitchTurn
|
||||
@ -8385,7 +8385,7 @@ BattleCommand98: ; 36f25
|
||||
; doubleflyingdamage
|
||||
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
||||
call CleanGetBattleVarPair
|
||||
bit 6, a ; flying
|
||||
bit SUBSTATUS_FLYING, a
|
||||
ret z
|
||||
jr DoubleDamage
|
||||
; 36f2f
|
||||
@ -8395,7 +8395,7 @@ BattleCommand99: ; 36f2f
|
||||
; doubleundergrounddamage
|
||||
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
||||
call CleanGetBattleVarPair
|
||||
bit 5, a ; underground
|
||||
bit SUBSTATUS_UNDERGROUND, a
|
||||
ret z
|
||||
|
||||
; fallthrough
|
||||
@ -10623,11 +10623,7 @@ BattleCommand6d: ; 37be8
|
||||
ld a, [AttackMissed]
|
||||
and a
|
||||
ret nz
|
||||
|
||||
ld a, $3e
|
||||
ld hl, $7ced
|
||||
rst FarCall
|
||||
|
||||
callba GetHiddenPower
|
||||
ret
|
||||
; 37bf4
|
||||
|
||||
|
108
battle/hidden_power.asm
Normal file
108
battle/hidden_power.asm
Normal file
@ -0,0 +1,108 @@
|
||||
GetHiddenPower: ; fbced
|
||||
; Override Hidden Power's type and power based on the actor's DVs.
|
||||
|
||||
ld hl, BattleMonDVs
|
||||
ld a, [hBattleTurn]
|
||||
and a
|
||||
jr z, .GotDVs
|
||||
ld hl, EnemyMonDVs
|
||||
.GotDVs
|
||||
|
||||
|
||||
; Power:
|
||||
|
||||
; Take the top bit from...
|
||||
|
||||
; Atk
|
||||
ld a, [hl]
|
||||
swap a
|
||||
and 8
|
||||
ld b, a
|
||||
; Def
|
||||
ld a, [hli]
|
||||
and 8
|
||||
srl a
|
||||
or b
|
||||
ld b, a
|
||||
; Spd
|
||||
ld a, [hl]
|
||||
swap a
|
||||
and 8
|
||||
srl a
|
||||
srl a
|
||||
or b
|
||||
ld b, a
|
||||
; Spc
|
||||
ld a, [hl]
|
||||
and 8
|
||||
srl a
|
||||
srl a
|
||||
srl a
|
||||
or b
|
||||
ld b, a
|
||||
|
||||
; * 5
|
||||
add a
|
||||
add a
|
||||
add b
|
||||
ld b, a
|
||||
|
||||
; + (Spc & 3)
|
||||
ld a, [hld]
|
||||
and 3
|
||||
add b
|
||||
|
||||
; / 2
|
||||
srl a
|
||||
|
||||
; + 30
|
||||
add 30
|
||||
; + 1
|
||||
inc a
|
||||
ld d, a
|
||||
|
||||
|
||||
; Type:
|
||||
|
||||
; Def & 3
|
||||
ld a, [hl]
|
||||
and 3
|
||||
ld b, a
|
||||
|
||||
; + (Atk & 3) << 2
|
||||
ld a, [hl]
|
||||
and 3 << 4
|
||||
swap a
|
||||
add a
|
||||
add a
|
||||
or b
|
||||
|
||||
; Skip Normal
|
||||
inc a
|
||||
|
||||
; Skip type 6 (unused)
|
||||
cp 6
|
||||
jr c, .GotType
|
||||
inc a
|
||||
|
||||
; Skip unused types between Steel and Fire
|
||||
cp STEEL + 1
|
||||
jr c, .GotType
|
||||
add FIRE - (STEEL + 1)
|
||||
|
||||
|
||||
.GotType
|
||||
push af
|
||||
ld a, BATTLE_VARS_MOVE_TYPE
|
||||
call GetBattleVarPair
|
||||
pop af
|
||||
ld [hl], a
|
||||
|
||||
ld a, d
|
||||
push af
|
||||
callba BattleCommand06
|
||||
pop af
|
||||
ld d, a
|
||||
ret
|
||||
; fbd54
|
||||
|
519
battle/moves/move_descriptions.asm
Normal file
519
battle/moves/move_descriptions.asm
Normal file
File diff suppressed because it is too large
Load Diff
@ -36,6 +36,12 @@ dn: MACRO
|
||||
db \1 << 4 + \2
|
||||
ENDM
|
||||
|
||||
dt: MACRO ; three-byte (big-endian)
|
||||
db (\1 >> 16) & $ff
|
||||
db (\1 >> 8) & $ff
|
||||
db \1 & $ff
|
||||
ENDM
|
||||
|
||||
bigdw: MACRO ; big-endian word
|
||||
dw ((\1)/$100) + (((\1)&$ff)*$100)
|
||||
ENDM
|
||||
@ -221,8 +227,23 @@ PREDEF_FLAG EQU $03
|
||||
PREDEF_FILLPP EQU $05
|
||||
PREDEF_ADDPARTYMON EQU $06
|
||||
PREDEF_FILLSTATS EQU $0C
|
||||
PREDEF_PRINT_MOVE_DESCRIPTION EQU $11
|
||||
PREDEF_UPDATE_PLAYER_HUD EQU $12
|
||||
PREDEF_FILL_BOX EQU $13
|
||||
PREDEF_UPDATE_ENEMY_HUD EQU $15
|
||||
PREDEF_FILL_IN_EXP_BAR EQU $17
|
||||
PREDEF_FILLMOVES EQU $1B
|
||||
PREDEF_GETUNOWNLETTER EQU $2D
|
||||
PREDEF_GET_GENDER EQU $24
|
||||
PREDEF_STATS_SCREEN EQU $25
|
||||
PREDEF_DRAW_PLAYER_HP EQU $26
|
||||
PREDEF_DRAW_ENEMY_HP EQU $27
|
||||
PREDEF_GET_TYPE_NAME EQU $29
|
||||
PREDEF_PRINT_MOVE_TYPE EQU $2A
|
||||
PREDEF_PRINT_TYPE EQU $2B
|
||||
PREDEF_GET_UNOWN_LETTER EQU $2D
|
||||
PREDEF_LOAD_SGB_LAYOUT EQU $31
|
||||
PREDEF_CHECK_CONTEST_MON EQU $33
|
||||
PREDEF_PARTYMON_ITEM_NAME EQU $3B
|
||||
PREDEF_DECOMPRESS EQU $40
|
||||
|
||||
|
||||
@ -247,6 +268,20 @@ D_UP EQU %01000000
|
||||
D_DOWN EQU %10000000
|
||||
|
||||
|
||||
; screen
|
||||
HP_BAR_LENGTH EQU 6
|
||||
HP_BAR_LENGTH_PX EQU 48
|
||||
EXP_BAR_LENGTH EQU 8
|
||||
EXP_BAR_LENGTH_PX EQU 64
|
||||
|
||||
SCREEN_WIDTH EQU 20
|
||||
SCREEN_HEIGHT EQU 18
|
||||
SCREEN_WIDTH_PX EQU 160
|
||||
SCREEN_HEIGHT_PX EQU 144
|
||||
|
||||
TILE_WIDTH EQU 8
|
||||
|
||||
|
||||
; movement
|
||||
STEP_SLOW EQU 0
|
||||
STEP_WALK EQU 1
|
||||
|
@ -149,7 +149,7 @@ SFX_POKEFLUTE EQU $26
|
||||
SFX_ELEVATOR_END EQU $27
|
||||
SFX_THROW_BALL EQU $28
|
||||
SFX_BALL_POOF EQU $29
|
||||
SFX_UNKNOWN_3A EQU $2a
|
||||
SFX_UNKNOWN_2A EQU $2a
|
||||
SFX_RUN EQU $2b
|
||||
SFX_SLOT_MACHINE_START EQU $2c
|
||||
SFX_FANFARE EQU $2d
|
||||
@ -254,7 +254,7 @@ SFX_MORNING_SUN EQU $8f
|
||||
SFX_LEVEL_UP EQU $90
|
||||
SFX_KEY_ITEM EQU $91
|
||||
SFX_FANFARE_2 EQU $92
|
||||
SFX_REGISTER_PHONE_# EQU $93
|
||||
SFX_REGISTER_PHONE_NUMBER EQU $93
|
||||
SFX_3RD_PLACE EQU $94
|
||||
SFX_GET_EGG_FROM_DAYCARE_MAN EQU $95
|
||||
SFX_GET_EGG_FROM_DAYCARE_LADY EQU $96
|
||||
|
367
engine/decompress.asm
Normal file
367
engine/decompress.asm
Normal file
@ -0,0 +1,367 @@
|
||||
FarDecompress: ; b40
|
||||
; Decompress graphics data at a:hl to de
|
||||
|
||||
; put a away for a sec
|
||||
ld [$c2c4], a
|
||||
; save bank
|
||||
ld a, [hROMBank]
|
||||
push af
|
||||
; bankswitch
|
||||
ld a, [$c2c4]
|
||||
rst Bankswitch
|
||||
|
||||
; what we came here for
|
||||
call Decompress
|
||||
|
||||
; restore bank
|
||||
pop af
|
||||
rst Bankswitch
|
||||
ret
|
||||
; b50
|
||||
|
||||
|
||||
Decompress: ; b50
|
||||
; Pokemon Crystal uses an lz variant for compression.
|
||||
|
||||
; This is mainly used for graphics, but the intro's
|
||||
; tilemaps also use this compression.
|
||||
|
||||
; This function decompresses lz-compressed data at hl to de.
|
||||
|
||||
|
||||
; Basic rundown:
|
||||
|
||||
; A typical control command consists of:
|
||||
; -the command (bits 5-7)
|
||||
; -the count (bits 0-4)
|
||||
; -and any additional params
|
||||
|
||||
; $ff is used as a terminator.
|
||||
|
||||
|
||||
; Commands:
|
||||
|
||||
; 0: literal
|
||||
; literal data for some number of bytes
|
||||
; 1: iterate
|
||||
; one byte repeated for some number of bytes
|
||||
; 2: alternate
|
||||
; two bytes alternated for some number of bytes
|
||||
; 3: zero (whitespace)
|
||||
; 0x00 repeated for some number of bytes
|
||||
|
||||
; Repeater control commands have a signed parameter used to determine the start point.
|
||||
; Wraparound is simulated:
|
||||
; Positive values are added to the start address of the decompressed data
|
||||
; and negative values are subtracted from the current position.
|
||||
|
||||
; 4: repeat
|
||||
; repeat some number of bytes from decompressed data
|
||||
; 5: flipped
|
||||
; repeat some number of flipped bytes from decompressed data
|
||||
; ex: $ad = %10101101 -> %10110101 = $b5
|
||||
; 6: reverse
|
||||
; repeat some number of bytes in reverse from decompressed data
|
||||
|
||||
; If the value in the count needs to be larger than 5 bits,
|
||||
; control code 7 can be used to expand the count to 10 bits.
|
||||
|
||||
; A new control command is read in bits 2-4.
|
||||
; The new 10-bit count is split:
|
||||
; bits 0-1 contain the top 2 bits
|
||||
; another byte is added containing the latter 8
|
||||
|
||||
; So, the structure of the control command becomes:
|
||||
; 111xxxyy yyyyyyyy
|
||||
; | | | |
|
||||
; | | our new count
|
||||
; | the control command for this count
|
||||
; 7 (this command)
|
||||
|
||||
; For more information, refer to the code below and in extras/gfx.py .
|
||||
|
||||
; save starting output address
|
||||
ld a, e
|
||||
ld [$c2c2], a
|
||||
ld a, d
|
||||
ld [$c2c3], a
|
||||
|
||||
.loop
|
||||
; get next byte
|
||||
ld a, [hl]
|
||||
; done?
|
||||
cp $ff ; end
|
||||
ret z
|
||||
|
||||
; get control code
|
||||
and %11100000
|
||||
|
||||
; 10-bit param?
|
||||
cp $e0 ; LZ_HI
|
||||
jr nz, .normal
|
||||
|
||||
|
||||
; 10-bit param:
|
||||
|
||||
; get next 3 bits (%00011100)
|
||||
ld a, [hl]
|
||||
add a
|
||||
add a ; << 3
|
||||
add a
|
||||
|
||||
; this is our new control code
|
||||
and %11100000
|
||||
push af
|
||||
|
||||
; get param hi
|
||||
ld a, [hli]
|
||||
and %00000011
|
||||
ld b, a
|
||||
|
||||
; get param lo
|
||||
ld a, [hli]
|
||||
ld c, a
|
||||
|
||||
; read at least 1 byte
|
||||
inc bc
|
||||
jr .readers
|
||||
|
||||
|
||||
.normal
|
||||
; push control code
|
||||
push af
|
||||
; get param
|
||||
ld a, [hli]
|
||||
and %00011111
|
||||
ld c, a
|
||||
ld b, $0
|
||||
; read at least 1 byte
|
||||
inc c
|
||||
|
||||
.readers
|
||||
; let's get started
|
||||
|
||||
; inc loop counts since we bail as soon as they hit 0
|
||||
inc b
|
||||
inc c
|
||||
|
||||
; get control code
|
||||
pop af
|
||||
; command type
|
||||
bit 7, a ; 80, a0, c0
|
||||
jr nz, .repeatertype
|
||||
|
||||
; literals
|
||||
cp $20 ; LZ_ITER
|
||||
jr z, .iter
|
||||
cp $40 ; LZ_ALT
|
||||
jr z, .alt
|
||||
cp $60 ; LZ_ZERO
|
||||
jr z, .zero
|
||||
; else $00
|
||||
|
||||
; 00 ; LZ_LIT
|
||||
; literal data for bc bytes
|
||||
.loop1
|
||||
; done?
|
||||
dec c
|
||||
jr nz, .next1
|
||||
dec b
|
||||
jp z, .loop
|
||||
|
||||
.next1
|
||||
ld a, [hli]
|
||||
ld [de], a
|
||||
inc de
|
||||
jr .loop1
|
||||
|
||||
|
||||
; 20 ; LZ_ITER
|
||||
; write byte for bc bytes
|
||||
.iter
|
||||
ld a, [hli]
|
||||
|
||||
.iterloop
|
||||
dec c
|
||||
jr nz, .iternext
|
||||
dec b
|
||||
jp z, .loop
|
||||
|
||||
.iternext
|
||||
ld [de], a
|
||||
inc de
|
||||
jr .iterloop
|
||||
|
||||
|
||||
; 40 ; LZ_ALT
|
||||
; alternate two bytes for bc bytes
|
||||
|
||||
; next pair
|
||||
.alt
|
||||
; done?
|
||||
dec c
|
||||
jr nz, .alt0
|
||||
dec b
|
||||
jp z, .altclose0
|
||||
|
||||
; alternate for bc
|
||||
.alt0
|
||||
ld a, [hli]
|
||||
ld [de], a
|
||||
inc de
|
||||
dec c
|
||||
jr nz, .alt1
|
||||
; done?
|
||||
dec b
|
||||
jp z, .altclose1
|
||||
.alt1
|
||||
ld a, [hld]
|
||||
ld [de], a
|
||||
inc de
|
||||
jr .alt
|
||||
|
||||
; skip past the bytes we were alternating
|
||||
.altclose0
|
||||
inc hl
|
||||
.altclose1
|
||||
inc hl
|
||||
jr .loop
|
||||
|
||||
|
||||
; 60 ; LZ_ZERO
|
||||
; write 00 for bc bytes
|
||||
.zero
|
||||
xor a
|
||||
|
||||
.zeroloop
|
||||
dec c
|
||||
jr nz, .zeronext
|
||||
dec b
|
||||
jp z, .loop
|
||||
|
||||
.zeronext
|
||||
ld [de], a
|
||||
inc de
|
||||
jr .zeroloop
|
||||
|
||||
|
||||
; repeats
|
||||
; 80, a0, c0
|
||||
; repeat decompressed data from output
|
||||
.repeatertype
|
||||
push hl
|
||||
push af
|
||||
; get next byte
|
||||
ld a, [hli]
|
||||
; absolute?
|
||||
bit 7, a
|
||||
jr z, .absolute
|
||||
|
||||
; relative
|
||||
; a = -a
|
||||
and %01111111 ; forget the bit we just looked at
|
||||
cpl
|
||||
; add de (current output address)
|
||||
add e
|
||||
ld l, a
|
||||
ld a, $ff ; -1
|
||||
adc d
|
||||
ld h, a
|
||||
jr .repeaters
|
||||
|
||||
.absolute
|
||||
; get next byte (lo)
|
||||
ld l, [hl]
|
||||
; last byte (hi)
|
||||
ld h, a
|
||||
; add starting output address
|
||||
ld a, [$c2c2]
|
||||
add l
|
||||
ld l, a
|
||||
ld a, [$c2c3]
|
||||
adc h
|
||||
ld h, a
|
||||
|
||||
.repeaters
|
||||
pop af
|
||||
cp $80 ; LZ_REPEAT
|
||||
jr z, .repeat
|
||||
cp $a0 ; LZ_FLIP
|
||||
jr z, .flip
|
||||
cp $c0 ; LZ_REVERSE
|
||||
jr z, .reverse
|
||||
|
||||
; e0 -> 80
|
||||
|
||||
; 80 ; LZ_REPEAT
|
||||
; repeat some decompressed data
|
||||
.repeat
|
||||
; done?
|
||||
dec c
|
||||
jr nz, .repeatnext
|
||||
dec b
|
||||
jr z, .cleanup
|
||||
|
||||
.repeatnext
|
||||
ld a, [hli]
|
||||
ld [de], a
|
||||
inc de
|
||||
jr .repeat
|
||||
|
||||
|
||||
; a0 ; LZ_FLIP
|
||||
; repeat some decompressed data w/ flipped bit order
|
||||
.flip
|
||||
dec c
|
||||
jr nz, .flipnext
|
||||
dec b
|
||||
jp z, .cleanup
|
||||
|
||||
.flipnext
|
||||
ld a, [hli]
|
||||
push bc
|
||||
ld bc, $0008
|
||||
|
||||
.fliploop
|
||||
rra
|
||||
rl b
|
||||
dec c
|
||||
jr nz, .fliploop
|
||||
ld a, b
|
||||
pop bc
|
||||
ld [de], a
|
||||
inc de
|
||||
jr .flip
|
||||
|
||||
|
||||
; c0 ; LZ_REVERSE
|
||||
; repeat some decompressed data in reverse
|
||||
.reverse
|
||||
dec c
|
||||
jr nz, .reversenext
|
||||
|
||||
dec b
|
||||
jp z, .cleanup
|
||||
|
||||
.reversenext
|
||||
ld a, [hld]
|
||||
ld [de], a
|
||||
inc de
|
||||
jr .reverse
|
||||
|
||||
|
||||
.cleanup
|
||||
; get type of repeat we just used
|
||||
pop hl
|
||||
; was it relative or absolute?
|
||||
bit 7, [hl]
|
||||
jr nz, .next
|
||||
|
||||
; skip two bytes for absolute
|
||||
inc hl
|
||||
; skip one byte for relative
|
||||
.next
|
||||
inc hl
|
||||
jp .loop
|
||||
; c2f
|
||||
|
225
engine/init.asm
Normal file
225
engine/init.asm
Normal file
@ -0,0 +1,225 @@
|
||||
Reset: ; 150
|
||||
di
|
||||
call CleanSoundRestart
|
||||
xor a
|
||||
ld [$ffde], a
|
||||
call ClearPalettes
|
||||
xor a
|
||||
ld [rIF], a
|
||||
ld a, 1 ; VBlank int
|
||||
ld [rIE], a
|
||||
ei
|
||||
|
||||
ld hl, $cfbe
|
||||
set 7, [hl]
|
||||
|
||||
ld c, 32
|
||||
call DelayFrames
|
||||
|
||||
jr Init
|
||||
; 16e
|
||||
|
||||
|
||||
_Start: ; 16e
|
||||
cp $11
|
||||
jr z, .asm_175
|
||||
xor a
|
||||
jr .asm_177
|
||||
|
||||
.asm_175
|
||||
ld a, $1
|
||||
|
||||
.asm_177
|
||||
ld [hCGB], a
|
||||
ld a, $1
|
||||
ld [$ffea], a
|
||||
; 17d
|
||||
|
||||
|
||||
Init: ; 17d
|
||||
|
||||
di
|
||||
|
||||
xor a
|
||||
ld [rIF], a
|
||||
ld [rIE], a
|
||||
ld [rRP], a
|
||||
ld [rSCX], a
|
||||
ld [rSCY], a
|
||||
ld [rSB], a
|
||||
ld [rSC], a
|
||||
ld [rWX], a
|
||||
ld [rWY], a
|
||||
ld [rBGP], a
|
||||
ld [rOBP0], a
|
||||
ld [rOBP1], a
|
||||
ld [rTMA], a
|
||||
ld [rTAC], a
|
||||
ld [$d000], a
|
||||
|
||||
ld a, %100 ; Start timer at 4096Hz
|
||||
ld [rTAC], a
|
||||
|
||||
.wait
|
||||
ld a, [rLY]
|
||||
cp 145
|
||||
jr nz, .wait
|
||||
|
||||
xor a
|
||||
ld [rLCDC], a
|
||||
|
||||
; Clear WRAM bank 0
|
||||
ld hl, $c000
|
||||
ld bc, $d000 - $c000
|
||||
.asm_1b1
|
||||
ld [hl], 0
|
||||
inc hl
|
||||
dec bc
|
||||
ld a, b
|
||||
or c
|
||||
jr nz, .asm_1b1
|
||||
|
||||
ld sp, Stack - 1
|
||||
|
||||
; Clear HRAM
|
||||
ld a, [hCGB]
|
||||
push af
|
||||
ld a, [$ffea]
|
||||
push af
|
||||
xor a
|
||||
ld hl, $ff80
|
||||
ld bc, $ffff - $ff80
|
||||
call ByteFill
|
||||
pop af
|
||||
ld [$ffea], a
|
||||
pop af
|
||||
ld [hCGB], a
|
||||
|
||||
call ClearWRAM
|
||||
ld a, 1
|
||||
ld [rSVBK], a
|
||||
call ClearVRAM
|
||||
call ClearSprites
|
||||
call Function270
|
||||
|
||||
|
||||
ld a, BANK(LoadPushOAM)
|
||||
rst Bankswitch
|
||||
|
||||
call LoadPushOAM
|
||||
|
||||
xor a
|
||||
ld [$ffde], a
|
||||
ld [hSCX], a
|
||||
ld [hSCY], a
|
||||
ld [rJOYP], a
|
||||
|
||||
ld a, $8 ; HBlank int enable
|
||||
ld [rSTAT], a
|
||||
|
||||
ld a, $90
|
||||
ld [hWY], a
|
||||
ld [rWY], a
|
||||
|
||||
ld a, 7
|
||||
ld [hWX], a
|
||||
ld [rWX], a
|
||||
|
||||
ld a, %11100011
|
||||
; LCD on
|
||||
; Win tilemap 1
|
||||
; Win on
|
||||
; BG/Win tiledata 0
|
||||
; BG Tilemap 0
|
||||
; OBJ 8x8
|
||||
; OBJ on
|
||||
; BG on
|
||||
ld [rLCDC], a
|
||||
|
||||
ld a, $ff
|
||||
ld [$ffcb], a
|
||||
|
||||
callba Function9890
|
||||
|
||||
ld a, $9c
|
||||
ld [$ffd7], a
|
||||
|
||||
xor a
|
||||
ld [hBGMapAddress], a
|
||||
|
||||
callba StartClock
|
||||
|
||||
xor a
|
||||
ld [MBC3LatchClock], a
|
||||
ld [MBC3SRamEnable], a
|
||||
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
jr z, .asm_22b
|
||||
call Function2ff7
|
||||
.asm_22b
|
||||
|
||||
xor a
|
||||
ld [rIF], a
|
||||
ld a, %1111 ; VBlank, LCDStat, Timer, Serial interrupts
|
||||
ld [rIE], a
|
||||
ei
|
||||
|
||||
call DelayFrame
|
||||
|
||||
ld a, $30
|
||||
call Predef
|
||||
|
||||
call CleanSoundRestart
|
||||
xor a
|
||||
ld [CurMusic], a
|
||||
jp GameInit
|
||||
; 245
|
||||
|
||||
|
||||
ClearVRAM: ; 245
|
||||
; Wipe VRAM banks 0 and 1
|
||||
|
||||
ld a, 1
|
||||
ld [rVBK], a
|
||||
call .clear
|
||||
|
||||
xor a
|
||||
ld [rVBK], a
|
||||
.clear
|
||||
ld hl, VTiles0
|
||||
ld bc, $2000
|
||||
xor a
|
||||
call ByteFill
|
||||
ret
|
||||
; 25a
|
||||
|
||||
ClearWRAM: ; 25a
|
||||
; Wipe swappable WRAM banks (1-7)
|
||||
|
||||
ld a, 1
|
||||
.asm_25c
|
||||
push af
|
||||
ld [rSVBK], a
|
||||
xor a
|
||||
ld hl, $d000
|
||||
ld bc, $1000
|
||||
call ByteFill
|
||||
pop af
|
||||
inc a
|
||||
cp 8
|
||||
jr nc, .asm_25c
|
||||
ret
|
||||
; 270
|
||||
|
||||
Function270: ; 270
|
||||
ld a, $0
|
||||
call GetSRAMBank
|
||||
ld hl, $a000
|
||||
ld bc, $0020
|
||||
xor a
|
||||
call ByteFill
|
||||
call CloseSRAM
|
||||
ret
|
||||
; 283
|
||||
|
@ -103,7 +103,7 @@ Joypad: ; 935
|
||||
; For example, soft reset:
|
||||
and BUTTON_A | BUTTON_B | SELECT | START
|
||||
cp BUTTON_A | BUTTON_B | SELECT | START
|
||||
jp z, $0150 ; reset
|
||||
jp z, Reset
|
||||
|
||||
ret
|
||||
; 984
|
||||
|
829
engine/movement.asm
Normal file
829
engine/movement.asm
Normal file
File diff suppressed because it is too large
Load Diff
@ -485,11 +485,11 @@ Script_verbosegiveitem: ; 0x96f60
|
||||
; item (ItemLabelByte)
|
||||
; quantity (DecimalParam)
|
||||
|
||||
call $77ca
|
||||
call Script_giveitem
|
||||
call CurItemName
|
||||
ld de, StringBuffer1
|
||||
ld a, $1
|
||||
call $76c8
|
||||
call Function976c8
|
||||
ld b, BANK(GiveItemScript)
|
||||
ld de, GiveItemScript
|
||||
jp ScriptCall
|
||||
@ -535,7 +535,7 @@ Script_verbosegiveitem2: ; 0x96f8e
|
||||
.asm_96f98
|
||||
ld [$d106], a
|
||||
call GetScriptByte
|
||||
call $769e
|
||||
call Unknown_0x9769e
|
||||
ld a, [de]
|
||||
ld [$d10c], a
|
||||
ld hl, $d892
|
||||
@ -548,7 +548,7 @@ Script_verbosegiveitem2: ; 0x96f8e
|
||||
call CurItemName
|
||||
ld de, StringBuffer1
|
||||
ld a, $1
|
||||
call $76c8
|
||||
call Function976c8
|
||||
ld b, BANK(GiveItemScript)
|
||||
ld de, GiveItemScript
|
||||
jp ScriptCall
|
||||
@ -1021,6 +1021,9 @@ Script_applymovement: ; 0x971f3
|
||||
call GetScriptByte
|
||||
call Unknown_0x971e3
|
||||
ld c, a
|
||||
; 971fa
|
||||
|
||||
Function971fa: ; 971fa
|
||||
push bc
|
||||
ld a, c
|
||||
ld a, $1
|
||||
@ -1028,7 +1031,7 @@ Script_applymovement: ; 0x971f3
|
||||
rst $8
|
||||
pop bc
|
||||
push bc
|
||||
call $7221
|
||||
call Unknown_0x97221
|
||||
pop bc
|
||||
call GetScriptByte
|
||||
ld l, a
|
||||
@ -1058,7 +1061,7 @@ Script_applymovement2: ; 0x97228
|
||||
|
||||
ld a, [$ffe0]
|
||||
ld c, a
|
||||
jp $71fa
|
||||
jp Function971fa
|
||||
; 0x9722e
|
||||
|
||||
Script_faceplayer: ; 0x9722e
|
||||
@ -1079,7 +1082,7 @@ Script_faceplayer: ; 0x9722e
|
||||
ld e, a
|
||||
ld a, [$ffe0]
|
||||
ld d, a
|
||||
call $728b
|
||||
call Unknown_0x9728b
|
||||
ret
|
||||
; 0x97248
|
||||
|
||||
@ -1114,7 +1117,7 @@ Script_faceperson: ; 0x97248
|
||||
add a
|
||||
ld e, a
|
||||
ld d, c
|
||||
call $728b
|
||||
call Unknown_0x9728b
|
||||
ret
|
||||
; 0x97274
|
||||
|
||||
@ -1135,7 +1138,7 @@ Script_spriteface: ; 0x97274
|
||||
add a
|
||||
add a
|
||||
ld e, a
|
||||
call $728b
|
||||
call Unknown_0x9728b
|
||||
ret
|
||||
; 0x9728b
|
||||
|
||||
@ -1161,7 +1164,7 @@ Unknown_0x9728b: ; 0x9728b
|
||||
ld hl, $d0ed
|
||||
bit 6, [hl]
|
||||
jr nz, .asm_972b5 ; 0x972b0 $3
|
||||
call $72bc
|
||||
call Unknown_0x972bc
|
||||
.asm_972b5
|
||||
call $1ad2
|
||||
ret
|
||||
@ -1173,7 +1176,7 @@ Unknown_0x9728b: ; 0x9728b
|
||||
|
||||
Unknown_0x972bc: ; 0x972bc
|
||||
call $217a
|
||||
ld hl, $c4a0
|
||||
ld hl, TileMap
|
||||
ld bc, $0168
|
||||
.asm_972c5
|
||||
res 7, [hl]
|
||||
@ -1211,7 +1214,7 @@ Script_appear: ; 0x972dd
|
||||
call $1956
|
||||
ld a, [$ffaf]
|
||||
ld b, $0
|
||||
call $730b
|
||||
call Unknown_0x9730b
|
||||
ret
|
||||
; 0x972ee
|
||||
|
||||
@ -1229,7 +1232,7 @@ Script_disappear: ; 0x972ee
|
||||
call $199f
|
||||
ld a, [$ffaf]
|
||||
ld b, $1
|
||||
call $730b
|
||||
call Unknown_0x9730b
|
||||
ld a, $1
|
||||
ld hl, $5920
|
||||
rst $8
|
||||
@ -1543,9 +1546,7 @@ Script_returnafterbattle: ; 0x97459
|
||||
jr z, .asm_9748e ; 0x97481 $b
|
||||
ld b, $24
|
||||
ld de, $4255
|
||||
ld a, $25
|
||||
ld hl, $7c4f
|
||||
rst $8
|
||||
callba Function97c4f
|
||||
.asm_9748e
|
||||
jp Script_reloadmap
|
||||
; 0x97491
|
||||
@ -1978,7 +1979,7 @@ Script_random: ; 0x97640
|
||||
and a
|
||||
ret z
|
||||
ld c, a
|
||||
call $7673
|
||||
call Unknown_0x97673
|
||||
and a
|
||||
jr z, .asm_9765f ; 0x9764d $10
|
||||
ld b, a
|
||||
@ -2027,7 +2028,7 @@ Script_checkcode: ; 0x9767d
|
||||
; variable_id (SingleByteParam)
|
||||
|
||||
call GetScriptByte
|
||||
call $769e
|
||||
call Unknown_0x9769e
|
||||
ld a, [de]
|
||||
ld [$c2dd], a
|
||||
ret
|
||||
@ -2039,7 +2040,7 @@ Script_writevarcode: ; 0x97688
|
||||
; variable_id (SingleByteParam)
|
||||
|
||||
call GetScriptByte
|
||||
call $769e
|
||||
call Unknown_0x9769e
|
||||
ld a, [$c2dd]
|
||||
ld [de], a
|
||||
ret
|
||||
@ -2052,7 +2053,7 @@ Script_writecode: ; 0x97693
|
||||
; value (SingleByteParam)
|
||||
|
||||
call GetScriptByte
|
||||
call $769e
|
||||
call Unknown_0x9769e
|
||||
call GetScriptByte
|
||||
ld [de], a
|
||||
ret
|
||||
@ -2096,9 +2097,12 @@ Script_pokenamemem: ; 0x976ae
|
||||
Unknown_976c0: ; 0x976c0
|
||||
call GetScriptByte
|
||||
cp $3
|
||||
jr c, .asm_976c8 ; 0x976c5 $1
|
||||
jr c, .asm_976c8
|
||||
xor a
|
||||
.asm_976c8
|
||||
; 976c8
|
||||
|
||||
Function976c8: ; 976c8
|
||||
ld hl, StringBuffer3
|
||||
ld bc, 19
|
||||
call AddNTimes
|
||||
@ -2197,8 +2201,8 @@ Script_readmoney: ; 0x97732
|
||||
; account (SingleByteParam)
|
||||
; memory (SingleByteParam)
|
||||
|
||||
call $7771
|
||||
call $7861
|
||||
call Unknown_0x97771
|
||||
call Unknown_0x97861
|
||||
ld hl, StringBuffer1
|
||||
ld bc, $4306
|
||||
call $3198
|
||||
@ -2211,7 +2215,7 @@ Script_readcoins: ; 0x97747
|
||||
; parameters:
|
||||
; memory (SingleByteParam)
|
||||
|
||||
call $7771
|
||||
call Unknown_0x97771
|
||||
ld hl, StringBuffer1
|
||||
ld de, $d855
|
||||
ld bc, $4206
|
||||
@ -2225,7 +2229,7 @@ Script_RAM2MEM: ; 0x9775c
|
||||
; parameters:
|
||||
; memory (SingleByteParam)
|
||||
|
||||
call $7771
|
||||
call Unknown_0x97771
|
||||
ld de, $c2dd
|
||||
ld hl, StringBuffer1
|
||||
ld bc, $4103
|
||||
@ -2372,8 +2376,8 @@ Script_givemoney: ; 0x97829
|
||||
; account (SingleByteParam)
|
||||
; money (MoneyByteParam)
|
||||
|
||||
call $7861
|
||||
call $786d
|
||||
call Unknown_0x97861
|
||||
call Unknown_0x9786d
|
||||
ld a, $5
|
||||
ld hl, $5fd7
|
||||
rst $8
|
||||
@ -2386,8 +2390,8 @@ Script_takemoney: ; 0x97836
|
||||
; account (SingleByteParam)
|
||||
; money (MoneyByteParam)
|
||||
|
||||
call $7861
|
||||
call $786d
|
||||
call Unknown_0x97861
|
||||
call Unknown_0x9786d
|
||||
ld a, $5
|
||||
ld hl, $5ffa
|
||||
rst $8
|
||||
@ -2400,8 +2404,8 @@ Script_checkmoney: ; 0x97843
|
||||
; account (SingleByteParam)
|
||||
; money (MoneyByteParam)
|
||||
|
||||
call $7861
|
||||
call $786d
|
||||
call Unknown_0x97861
|
||||
call Unknown_0x9786d
|
||||
ld a, $5
|
||||
ld hl, $600b
|
||||
rst $8
|
||||
@ -2451,7 +2455,7 @@ Script_givecoins: ; 0x97881
|
||||
; parameters:
|
||||
; coins (CoinByteParam)
|
||||
|
||||
call $78a0
|
||||
call Function978a0
|
||||
ld a, $5
|
||||
ld hl, $606f
|
||||
rst $8
|
||||
@ -2463,7 +2467,7 @@ Script_takecoins: ; 0x9788b
|
||||
; parameters:
|
||||
; coins (CoinByteParam)
|
||||
|
||||
call $78a0
|
||||
call Function978a0
|
||||
ld a, $5
|
||||
ld hl, $608f
|
||||
rst $8
|
||||
@ -2475,11 +2479,14 @@ Script_checkcoins: ; 0x97895
|
||||
; parameters:
|
||||
; coins (CoinByteParam)
|
||||
|
||||
call $78a0
|
||||
call Function978a0
|
||||
ld a, $5
|
||||
ld hl, $60a1
|
||||
rst $8
|
||||
jr Unknown_9784f ; 0x9789e $af
|
||||
jr Unknown_9784f
|
||||
; 978a0
|
||||
|
||||
Function978a0: ; 978a0
|
||||
call GetScriptByte
|
||||
ld [$ffc4], a
|
||||
call GetScriptByte
|
||||
@ -2718,7 +2725,7 @@ Script_setbit2: ; 0x979bb
|
||||
call GetScriptByte
|
||||
ld d, a
|
||||
ld b, $1
|
||||
call $79ee
|
||||
call Unknown_0x979ee
|
||||
ret
|
||||
; 0x979c9
|
||||
|
||||
@ -2732,7 +2739,7 @@ Script_clearbit2: ; 0x979c9
|
||||
call GetScriptByte
|
||||
ld d, a
|
||||
ld b, $0
|
||||
call $79ee
|
||||
call Unknown_0x979ee
|
||||
ret
|
||||
; 0x979d7
|
||||
|
||||
@ -2746,7 +2753,7 @@ Script_checkbit2: ; 0x979d7
|
||||
call GetScriptByte
|
||||
ld d, a
|
||||
ld b, $2
|
||||
call $79ee
|
||||
call Unknown_0x979ee
|
||||
ld a, c
|
||||
and a
|
||||
jr z, .asm_979ea ; 0x979e6 $2
|
||||
@ -2897,9 +2904,7 @@ Script_writecmdqueue: ; 0x97a8b
|
||||
ld d, a
|
||||
ld a, [ScriptBank]
|
||||
ld b, a
|
||||
ld a, $25
|
||||
ld hl, $7e31
|
||||
rst $8
|
||||
callba Function97e31
|
||||
ret
|
||||
; 0x97a9e
|
||||
|
||||
@ -2912,9 +2917,7 @@ Script_delcmdqueue: ; 0x97a9e
|
||||
ld [$c2dd], a
|
||||
call GetScriptByte
|
||||
ld b, a
|
||||
ld a, $25
|
||||
ld hl, $7e5c
|
||||
rst $8
|
||||
callba Function97e5c
|
||||
ret c
|
||||
ld a, $1
|
||||
ld [$c2dd], a
|
||||
@ -2976,16 +2979,12 @@ Script_warpcheck: ; 0x97af6
|
||||
|
||||
call $224a
|
||||
ret nc
|
||||
ld a, $25
|
||||
ld hl, $66d0
|
||||
rst $8
|
||||
callba Function966d0
|
||||
ret
|
||||
; 0x97b01
|
||||
|
||||
Unknown_0x97b01: ; 0x97b01
|
||||
ld a, $25
|
||||
ld hl, $66d0
|
||||
rst $8
|
||||
callba Function966d0
|
||||
ret
|
||||
; 0x97b08
|
||||
|
||||
@ -3005,7 +3004,7 @@ Script_newloadmap: ; 0x97b08
|
||||
Script_reloadandreturn: ; 0x97b16
|
||||
; script command 0x92
|
||||
|
||||
call $7b08
|
||||
call Script_newloadmap
|
||||
jp Script_end
|
||||
; 0x97b1c
|
||||
|
||||
@ -3203,8 +3202,9 @@ Script_credits: ; 0x97bf3
|
||||
ld hl, $6455
|
||||
rst $8
|
||||
; fallthrough
|
||||
|
||||
DisplayCredits:
|
||||
call $7bc0
|
||||
call Script_resetfuncs
|
||||
ld a, $3
|
||||
call $261b
|
||||
call StopScript
|
||||
|
1229
engine/text.asm
Normal file
1229
engine/text.asm
Normal file
File diff suppressed because it is too large
Load Diff
@ -71,31 +71,31 @@ VBlank0: ; 2b1
|
||||
; advance rng
|
||||
ld a, [rDIV]
|
||||
ld b, a
|
||||
ld a, [$ffe1]
|
||||
ld a, [hRandomAdd]
|
||||
adc b
|
||||
ld [$ffe1], a
|
||||
ld [hRandomAdd], a
|
||||
|
||||
ld a, [rDIV]
|
||||
ld b, a
|
||||
ld a, [$ffe2]
|
||||
ld a, [hRandomSub]
|
||||
sbc b
|
||||
ld [$ffe2], a
|
||||
ld [hRandomSub], a
|
||||
|
||||
; save bank
|
||||
ld a, [$ff9d] ; current bank
|
||||
ld a, [hROMBank] ; current bank
|
||||
ld [$ff8a], a
|
||||
|
||||
; scroll x
|
||||
ld a, [$ffcf]
|
||||
ld a, [hSCX]
|
||||
ld [rSCX], a
|
||||
; scroll y
|
||||
ld a, [$ffd0]
|
||||
ld a, [hSCY]
|
||||
ld [rSCY], a
|
||||
; window y
|
||||
ld a, [$ffd2]
|
||||
ld a, [hWY]
|
||||
ld [rWY], a
|
||||
; window x + 7
|
||||
ld a, [$ffd1]
|
||||
ld a, [hWX]
|
||||
ld [rWX], a
|
||||
|
||||
; some time management is in order
|
||||
@ -123,7 +123,7 @@ VBlank0: ; 2b1
|
||||
|
||||
.doneframeaction
|
||||
; oam update off?
|
||||
ld a, [$ffd8]
|
||||
ld a, [hOAMUpdate]
|
||||
and a
|
||||
jr nz, .vblankoccurred
|
||||
|
||||
@ -146,12 +146,12 @@ VBlank0: ; 2b1
|
||||
xor a
|
||||
ld [VBlankOccurred], a
|
||||
|
||||
; dec $cfb1 until 0
|
||||
ld a, [$cfb1]
|
||||
; dec OverworldDelay until 0
|
||||
ld a, [OverworldDelay]
|
||||
and a
|
||||
jr z, .textdelay
|
||||
dec a
|
||||
ld [$cfb1], a
|
||||
ld [OverworldDelay], a
|
||||
|
||||
.textdelay
|
||||
; dec text delay counter until 0
|
||||
@ -172,7 +172,7 @@ VBlank0: ; 2b1
|
||||
rst Bankswitch ; restore bank
|
||||
|
||||
;
|
||||
ld a, [$ff98]
|
||||
ld a, [hSeconds]
|
||||
ld [$ffe3], a
|
||||
|
||||
ret
|
||||
@ -183,7 +183,7 @@ VBlank2: ; 325
|
||||
; sound only
|
||||
|
||||
; save bank
|
||||
ld a, [$ff9d]
|
||||
ld a, [hROMBank]
|
||||
ld [$ff8a], a
|
||||
|
||||
; update sound
|
||||
@ -211,15 +211,15 @@ VBlank1: ; 337
|
||||
; sound / lcd stat
|
||||
|
||||
; save bank
|
||||
ld a, [$ff9d]
|
||||
ld a, [hROMBank]
|
||||
ld [$ff8a], a
|
||||
|
||||
; scroll x
|
||||
ld a, [$ffcf]
|
||||
ld a, [hSCX]
|
||||
ld [rSCX], a
|
||||
|
||||
; scroll y
|
||||
ld a, [$ffd0]
|
||||
ld a, [hSCY]
|
||||
ld [rSCY], a
|
||||
|
||||
; time-sensitive fns
|
||||
@ -291,7 +291,7 @@ UpdatePals: ; 37f
|
||||
; update pals for either dmg or cgb
|
||||
|
||||
; check cgb
|
||||
ld a, [$ffe6]
|
||||
ld a, [hCGB]
|
||||
and a
|
||||
jp nz, UpdateCGBPals
|
||||
|
||||
@ -319,18 +319,18 @@ VBlank3: ; 396
|
||||
; sound / lcd stat
|
||||
|
||||
; save bank
|
||||
ld a, [$ff9d]
|
||||
ld a, [hROMBank]
|
||||
ld [$ff8a], a
|
||||
|
||||
; scroll x
|
||||
ld a, [$ffcf]
|
||||
ld a, [hSCX]
|
||||
ld [rSCX], a
|
||||
; scroll y
|
||||
ld a, [$ffd0]
|
||||
ld a, [hSCY]
|
||||
ld [rSCY], a
|
||||
|
||||
; any pals to update?
|
||||
ld a, [$ffe5]
|
||||
ld a, [hCGBPalUpdate]
|
||||
and a
|
||||
call nz, ForceUpdateCGBPals
|
||||
jr c, .vblankoccurred
|
||||
@ -404,7 +404,7 @@ VBlank4: ; 3df
|
||||
; sound
|
||||
|
||||
; save bank
|
||||
ld a, [$ff9d]
|
||||
ld a, [hROMBank]
|
||||
ld [$ff8a], a
|
||||
|
||||
call UpdateBGMap
|
||||
@ -451,11 +451,11 @@ VBlank5: ; 400
|
||||
;
|
||||
|
||||
; save bank
|
||||
ld a, [$ff9d]
|
||||
ld a, [hROMBank]
|
||||
ld [$ff8a], a
|
||||
|
||||
; scroll x
|
||||
ld a, [$ffcf]
|
||||
ld a, [hSCX]
|
||||
ld [rSCX], a
|
||||
|
||||
; if we can update pals, skip this part
|
||||
@ -509,7 +509,7 @@ VBlank6: ; 436
|
||||
; sound
|
||||
|
||||
; save bank
|
||||
ld a, [$ff9d]
|
||||
ld a, [hROMBank]
|
||||
ld [$ff8a], a
|
||||
|
||||
; inc frame counter
|
||||
|
@ -270,6 +270,7 @@ jap_chars.update({
|
||||
0xE1: "ゅ",
|
||||
0xE2: "ょ",
|
||||
0xE3: "ー",
|
||||
0xE9: "ァ",
|
||||
})
|
||||
|
||||
#some of the japanese characters can probably fit into the english table
|
||||
|
@ -1993,7 +1993,7 @@ movement_command_bases = {
|
||||
0x45: "accelerate_last",
|
||||
0x46: ["step_sleep", ["duration", DecimalParam]],
|
||||
0x47: "step_end",
|
||||
0x49: "hide_person",
|
||||
0x49: "remove_person",
|
||||
|
||||
# do these next two have any params ??
|
||||
0x4C: "teleport_from",
|
||||
|
128
extras/sym.py
128
extras/sym.py
@ -1,54 +1,100 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# coding: utf-8
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
# from crystal import load_rom
|
||||
# from gbz80disasm import load_labels
|
||||
|
||||
|
||||
def make_sym_from_json(filename = '../pokecrystal.sym', j = 'labels.json'):
|
||||
# todo: delete and remake labels.json at runtime
|
||||
with open(filename, 'w') as sym:
|
||||
for label in json.load(open(j)):
|
||||
sym.write('{0:x}:{1:x} {2}\n'.format(label['bank'], label['address']%0x4000 + (0x4000 if label['bank'] else 0), label['label']))
|
||||
|
||||
|
||||
def make_sym_from_mapfile(filename = '../pokecrystal.sym', mapfile = '../mapfile.txt'):
|
||||
# todo: sort label definitions by address
|
||||
|
||||
output = ''
|
||||
# get label definitions
|
||||
with open(mapfile,'r') as map:
|
||||
labels = json.load(open(j))
|
||||
for label in labels:
|
||||
output += '{0:x}:{1:x} {2}\n'.format(label['bank'], label['address'], label['label'])
|
||||
with open(filename, 'w') as sym:
|
||||
sym.write(output)
|
||||
|
||||
|
||||
def make_json_from_mapfile(filename = 'labels.json', mapfile = '../pokecrystal.map'):
|
||||
output = []
|
||||
labels = filter_wram_addresses(read_mapfile(mapfile))
|
||||
with open(filename, 'w') as out:
|
||||
out.write(json.dumps(labels))
|
||||
|
||||
|
||||
def read_mapfile(filename = '../pokecrystal.map'):
|
||||
"""
|
||||
Scrape label addresses from an rgbds mapfile.
|
||||
"""
|
||||
|
||||
labels = []
|
||||
|
||||
with open(filename,'r') as map:
|
||||
lines = map.readlines()
|
||||
for line in lines:
|
||||
# bank #
|
||||
if 'Bank #' in line:
|
||||
cur_bank = int(line.lstrip('Bank #').strip(':\n').strip(' (HOME)'))
|
||||
|
||||
# label definition
|
||||
elif '=' in line:
|
||||
thing = line.split('=')
|
||||
spacing = ' ' * 11 # arbitrary
|
||||
addr = int(thing[0].lstrip(spacing)[1:5],16)
|
||||
|
||||
# rgbds doesn't support wram banks yet,
|
||||
# so this hack is applied instead
|
||||
if addr > 0xbfff: # 0xc000+ (wram only)
|
||||
cur_bank = 0
|
||||
if addr > 0xcfff: # 0xd000+ (wram only)
|
||||
cur_bank = 1
|
||||
|
||||
# convert to sym format (bank:addr label)
|
||||
label = thing[1].strip('\n')
|
||||
output += hex(cur_bank)[2:] + ':' + hex(addr)[2:] + ' ' + label + '\n'
|
||||
|
||||
|
||||
for line in lines:
|
||||
# bank #
|
||||
if 'Bank #' in line:
|
||||
cur_bank = int(line.lstrip('Bank #').strip(':\n').strip(' (HOME)'))
|
||||
|
||||
# label definition
|
||||
elif '=' in line:
|
||||
address, label = line.split('=')
|
||||
address = int(address.lstrip().replace('$','0x'), 16)
|
||||
label = label.strip()
|
||||
|
||||
# rgbds doesn't support ram banks yet
|
||||
bank = cur_bank
|
||||
offset = address
|
||||
if 0x8000 <= address < 0xa000:
|
||||
bank = 0
|
||||
elif 0xa000 <= address < 0xc000:
|
||||
bank = 0
|
||||
elif 0xc000 <= address < 0xd000:
|
||||
bank = 0
|
||||
elif 0xd000 <= address < 0xe000:
|
||||
bank = 0
|
||||
else:
|
||||
offset += (bank * 0x4000 - 0x4000) if bank > 0 else 0
|
||||
|
||||
labels += [{
|
||||
'label': label,
|
||||
'bank': bank,
|
||||
'address': offset,
|
||||
'offset': offset,
|
||||
'local_address': address,
|
||||
}]
|
||||
|
||||
return labels
|
||||
|
||||
def filter_wram_addresses(labels):
|
||||
filtered_labels = []
|
||||
for label in labels:
|
||||
if label['local_address'] < 0x8000:
|
||||
filtered_labels += [label]
|
||||
return filtered_labels
|
||||
|
||||
|
||||
def make_sym_from_mapfile(filename = '../pokecrystal.sym'):
|
||||
# todo: sort label definitions by address
|
||||
|
||||
output = ''
|
||||
labels = read_mapfile()
|
||||
|
||||
# convert to sym format (bank:addr label)
|
||||
for label in labels:
|
||||
output += '%.2x:%.4x %s\n' % (label['bank'], label['address'], label['label'])
|
||||
|
||||
# dump contents to symfile
|
||||
with open(filename, 'w') as sym:
|
||||
sym.write(output)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# default behavior: generate sym file from rgbds mapfile
|
||||
try: make_sym_from_mapfile()
|
||||
# if no mapfile exists, generate from labels.json
|
||||
except: make_sym_from_json()
|
||||
#if os.path.exists('../pokecrystal.sym'):
|
||||
# sys.exit()
|
||||
#elif os.path.exists('../pokecrystal.map'):
|
||||
# make_sym_from_mapfile()
|
||||
#elif os.path.exists('labels.json'):
|
||||
# make_sym_from_json()
|
||||
make_json_from_mapfile()
|
||||
|
||||
|
BIN
gfx/frames/1.1bpp
Normal file
BIN
gfx/frames/1.1bpp
Normal file
Binary file not shown.
BIN
gfx/frames/2.1bpp
Normal file
BIN
gfx/frames/2.1bpp
Normal file
Binary file not shown.
BIN
gfx/frames/3.1bpp
Normal file
BIN
gfx/frames/3.1bpp
Normal file
Binary file not shown.
BIN
gfx/frames/4.1bpp
Normal file
BIN
gfx/frames/4.1bpp
Normal file
Binary file not shown.
BIN
gfx/frames/5.1bpp
Normal file
BIN
gfx/frames/5.1bpp
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user