First Commit

Upload literally everything from the pokecrystal16 expand-move-ID branch
This commit is contained in:
Zeta_Null 2023-09-10 12:35:35 -04:00
commit 2f8a41f833
4618 changed files with 480386 additions and 0 deletions

46
engine/link/init_list.asm Normal file
View file

@ -0,0 +1,46 @@
InitList:
; This entire function is useless.
ld a, [wInitListType]
cp INIT_ENEMYOT_LIST
jr nz, .check_party_ot_name
ld hl, wOTPartyCount
ld a, ENEMY_OT_NAME
jr .done
.check_party_ot_name
cp INIT_PLAYEROT_LIST
jr nz, .check_mon_name
ld hl, wPartyCount
ld a, PARTY_OT_NAME
jr .done
.check_mon_name
cp INIT_MON_LIST
jr nz, .check_item_name
ld hl, wCurMartCount
ld a, MON_NAME
jr .done
.check_item_name
cp INIT_BAG_ITEM_LIST
jr nz, .check_ob_item_name
ld hl, wNumItems
ld a, ITEM_NAME
jr .done
.check_ob_item_name
ld hl, wCurMartCount
ld a, ITEM_NAME
.done
ld [wNamedObjectType], a
ld a, l
ld [wListPointer], a
ld a, h
ld [wListPointer + 1], a
ld bc, ItemAttributes
ld a, c
ld [wItemAttributesPointer], a
ld a, b
ld [wItemAttributesPointer + 1], a
ret

3044
engine/link/link.asm Normal file

File diff suppressed because it is too large Load diff

93
engine/link/link_2.asm Normal file
View file

@ -0,0 +1,93 @@
LinkMonStatsScreen:
ld a, [wMenuCursorY]
dec a
ld [wCurPartyMon], a
call LowVolume
predef StatsScreenInit
ld a, [wCurPartyMon]
inc a
ld [wMenuCursorY], a
call ClearScreen
call ClearBGPalettes
call MaxVolume
farcall LoadTradeScreenBorderGFX
farcall Link_WaitBGMap
farcall InitTradeSpeciesList
farcall SetTradeRoomBGPals
call WaitBGMap2
ret
Link_WaitBGMap:
call WaitBGMap
call WaitBGMap2
ret
LinkTextbox2:
ld h, d
ld l, e
push bc
push hl
call .PlaceBorder
pop hl
pop bc
ld de, wAttrmap - wTilemap
add hl, de
inc b
inc b
inc c
inc c
ld a, PAL_BG_TEXT
.row
push bc
push hl
.col
ld [hli], a
dec c
jr nz, .col
pop hl
ld de, SCREEN_WIDTH
add hl, de
pop bc
dec b
jr nz, .row
ret
.PlaceBorder:
push hl
ld a, $76
ld [hli], a
inc a
call .PlaceRow
inc a
ld [hl], a
pop hl
ld de, SCREEN_WIDTH
add hl, de
.loop
push hl
ld a, $79
ld [hli], a
ld a, " "
call .PlaceRow
ld [hl], $7a
pop hl
ld de, SCREEN_WIDTH
add hl, de
dec b
jr nz, .loop
ld a, $7b
ld [hli], a
ld a, $7c
call .PlaceRow
ld [hl], $7d
ret
.PlaceRow:
ld d, c
.row_loop
ld [hli], a
dec d
jr nz, .row_loop
ret

342
engine/link/link_trade.asm Normal file
View file

@ -0,0 +1,342 @@
LinkCommsBorderGFX:
INCBIN "gfx/trade/border_tiles.2bpp"
__LoadTradeScreenBorderGFX:
ld de, LinkCommsBorderGFX
ld hl, vTiles2
lb bc, BANK(LinkCommsBorderGFX), 70
call Get2bpp
ret
LoadMobileTradeBorderTilemap:
ld hl, MobileTradeBorderTilemap
decoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call CopyBytes
ret
TestMobileTradeBorderTilemap: ; unreferenced
; Loads the mobile trade border graphics and tilemap,
; with a placeholder SCGB_DIPLOMA layout, and exits
; after pressing A or B. Possibly used for testing.
call LoadStandardMenuHeader
call ClearBGPalettes
call ClearTilemap
call ClearSprites
farcall __LoadTradeScreenBorderGFX ; useless to farcall
farcall LoadMobileTradeBorderTilemap ; useless to farcall
ld b, SCGB_DIPLOMA
call GetSGBLayout
call SetPalettes
call WaitBGMap
call JoyWaitAorB
call ExitMenu
ret
MobileTradeBorderTilemap:
INCBIN "gfx/trade/border_mobile.tilemap"
CableTradeBorderTopTilemap:
INCBIN "gfx/trade/border_cable_top.tilemap"
CableTradeBorderBottomTilemap:
INCBIN "gfx/trade/border_cable_bottom.tilemap"
_LinkTextbox:
ld h, d
ld l, e
push bc
push hl
call .PlaceBorder
pop hl
pop bc
ld de, wAttrmap - wTilemap
add hl, de
inc b
inc b
inc c
inc c
ld a, PAL_BG_TEXT
.row
push bc
push hl
.col
ld [hli], a
dec c
jr nz, .col
pop hl
ld de, SCREEN_WIDTH
add hl, de
pop bc
dec b
jr nz, .row
ret
.PlaceBorder
push hl
ld a, $30
ld [hli], a
inc a
call .PlaceRow
inc a
ld [hl], a
pop hl
ld de, SCREEN_WIDTH
add hl, de
.loop
push hl
ld a, $33
ld [hli], a
ld a, " "
call .PlaceRow
ld [hl], $34
pop hl
ld de, SCREEN_WIDTH
add hl, de
dec b
jr nz, .loop
ld a, $35
ld [hli], a
ld a, $36
call .PlaceRow
ld [hl], $37
ret
.PlaceRow
ld d, c
.row_loop
ld [hli], a
dec d
jr nz, .row_loop
ret
InitTradeSpeciesList:
call _LoadTradeScreenBorderGFX
call LoadCableTradeBorderTilemap
farcall InitMG_Mobile_LinkTradePalMap
farcall PlaceTradePartnerNamesAndParty
hlcoord 10, 17
ld de, .CancelString
call PlaceString
ret
.CancelString:
db "CANCEL@"
_LoadTradeScreenBorderGFX:
call __LoadTradeScreenBorderGFX
ret
LinkComms_LoadPleaseWaitTextboxBorderGFX:
ld de, LinkCommsBorderGFX + $30 tiles
ld hl, vTiles2 tile $76
lb bc, BANK(LinkCommsBorderGFX), 8
call Get2bpp
ret
LoadTradeRoomBGPals:
farcall _LoadTradeRoomBGPals
ret
LoadCableTradeBorderTilemap:
call LoadMobileTradeBorderTilemap
ld hl, CableTradeBorderTopTilemap
decoord 0, 0
ld bc, 2 * SCREEN_WIDTH
call CopyBytes
ld hl, CableTradeBorderBottomTilemap
decoord 0, 16
ld bc, 2 * SCREEN_WIDTH
call CopyBytes
ret
LinkTextbox:
call _LinkTextbox
ret
PrintWaitingTextAndSyncAndExchangeNybble:
call LoadStandardMenuHeader
call .PrintWaitingText
farcall WaitLinkTransfer
call ExitMenu
call WaitBGMap2
ret
.PrintWaitingText:
hlcoord 4, 10
ld b, 1
ld c, 10
predef LinkTextboxAtHL
hlcoord 5, 11
ld de, .Waiting
call PlaceString
call WaitBGMap
call WaitBGMap2
ld c, 50
jp DelayFrames
.Waiting:
db "WAITING..!@"
LinkTradeMenu:
call .MenuAction
call .GetJoypad
ret
.GetJoypad:
push bc
push af
ldh a, [hJoyLast]
and D_PAD
ld b, a
ldh a, [hJoyPressed]
and BUTTONS
or b
ld b, a
pop af
ld a, b
pop bc
ld d, a
ret
.MenuAction:
ld hl, w2DMenuFlags2
res 7, [hl]
ldh a, [hBGMapMode]
push af
call .loop
pop af
ldh [hBGMapMode], a
ret
.loop
call .UpdateCursor
call .UpdateBGMapAndOAM
call .loop2
jr nc, .done
farcall _2DMenuInterpretJoypad
jr c, .done
ld a, [w2DMenuFlags1]
bit 7, a
jr nz, .done
call .GetJoypad
ld b, a
ld a, [wMenuJoypadFilter]
and b
jr z, .loop
.done
ret
.UpdateBGMapAndOAM:
ldh a, [hOAMUpdate]
push af
ld a, $1
ldh [hOAMUpdate], a
call WaitBGMap
pop af
ldh [hOAMUpdate], a
xor a
ldh [hBGMapMode], a
ret
.loop2
call UpdateTimeAndPals
call .TryAnims
ret c
ld a, [w2DMenuFlags1]
bit 7, a
jr z, .loop2
and a
ret
.UpdateCursor:
ld hl, wCursorCurrentTile
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [hl]
cp $1f
jr nz, .not_currently_selected
ld a, [wCursorOffCharacter]
ld [hl], a
push hl
push bc
ld bc, MON_NAME_LENGTH
add hl, bc
ld [hl], a
pop bc
pop hl
.not_currently_selected
ld a, [w2DMenuCursorInitY]
ld b, a
ld a, [w2DMenuCursorInitX]
ld c, a
call Coord2Tile
ld a, [w2DMenuCursorOffsets]
swap a
and $f
ld c, a
ld a, [wMenuCursorY]
ld b, a
xor a
dec b
jr z, .skip
.loop3
add c
dec b
jr nz, .loop3
.skip
ld c, SCREEN_WIDTH
call AddNTimes
ld a, [w2DMenuCursorOffsets]
and $f
ld c, a
ld a, [wMenuCursorX]
ld b, a
xor a
dec b
jr z, .skip2
.loop4
add c
dec b
jr nz, .loop4
.skip2
ld c, a
add hl, bc
ld a, [hl]
cp $1f
jr z, .cursor_already_there
ld [wCursorOffCharacter], a
ld [hl], $1f
push hl
push bc
ld bc, MON_NAME_LENGTH
add hl, bc
ld [hl], $1f
pop bc
pop hl
.cursor_already_there
ld a, l
ld [wCursorCurrentTile], a
ld a, h
ld [wCursorCurrentTile + 1], a
ret
.TryAnims:
ld a, [w2DMenuFlags1]
bit 6, a
jr z, .skip_anims
farcall PlaySpriteAnimationsAndDelayFrame
.skip_anims
call JoyTextDelay
call .GetJoypad
and a
ret z
scf
ret

1923
engine/link/mystery_gift.asm Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,153 @@
StageDataForMysteryGift:
ld de, wMysteryGiftStaging
ld a, GS_VERSION + 1
ld [de], a
inc de ; wMysteryGiftStaging+1
ld a, BANK(sGameData)
call OpenSRAM
ld hl, sPlayerData + wPlayerID - wPlayerData
ld a, [hli]
ld [de], a
ld b, a
inc de ; wMysteryGiftStaging+2
ld a, [hl]
ld [de], a
ld c, a
inc de ; wMysteryGiftStaging+3
push bc
ld hl, sPlayerData + wPlayerName - wPlayerData
ld bc, NAME_LENGTH
call CopyBytes
push de ; wMysteryGiftStaging+14
ld hl, sPokemonData + wPokedexCaught - wPokemonData
ld bc, wEndPokedexCaught - wPokedexCaught
call CountSetBits16
ld a, b
add a, -1
sbc a
or c
pop de
pop bc
ld [de], a
inc de ; wMysteryGiftStaging+15
call CloseSRAM
call Random
and 1
ld [de], a
inc de ; wMysteryGiftStaging+16
call .RandomSample
ld [de], a
inc de ; wMysteryGiftStaging+17
ld a, c
ld c, b
ld b, a
call .RandomSample
ld [de], a
inc de ; wMysteryGiftStaging+18
ld a, BANK(sBackupMysteryGiftItem)
call OpenSRAM
ld a, [sBackupMysteryGiftItem]
ld [de], a
inc de
ld a, [sNumDailyMysteryGiftPartnerIDs]
ld [de], a
ld a, wMysteryGiftPlayerDataEnd - wMysteryGiftPlayerData
ld [wUnusedMysteryGiftStagedDataLength], a
call CloseSRAM
ld hl, wMysteryGiftStaging
ld de, wMysteryGiftPlayerData
ld bc, wMysteryGiftPlayerDataEnd - wMysteryGiftPlayerData
jp CopyBytes
.RandomSample:
push de
call Random
cp 10 percent
jr c, .tenpercent
call Random
and %111
ld d, a
rl d
ld e, $80
.loop
rlc e
dec a
jr nz, .loop
ld a, e
and c
jr z, .skip
ld a, $1
.skip
add d
jr .done
.tenpercent
call Random
cp 20 percent - 1
jr c, .twopercent
call Random
and %011
ld d, a
rl d
ld e, $80
.loop2
rlc e
dec a
jr nz, .loop2
ld a, e
and b
jr z, .skip2
ld a, $1
.skip2
add d
add $10
jr .done
.twopercent
call Random
cp 20 percent - 1
jr c, .pointfourpercent
ld a, b
swap a
and $7
add $18
jr .done
.pointfourpercent
ld a, b
and $80
ld a, $20
jr z, .done
ld a, $21
.done
pop de
ret
MysteryGiftGetItem:
ld a, c
cp MysteryGiftItems.End - MysteryGiftItems
jr nc, MysteryGiftFallbackItem
ld hl, MysteryGiftItems
ld b, 0
add hl, bc
ld c, [hl]
ret
MysteryGiftGetDecoration:
ld a, c
cp MysteryGiftDecos.End - MysteryGiftDecos
jr nc, MysteryGiftFallbackItem
ld hl, MysteryGiftDecos
ld b, 0
add hl, bc
ld c, [hl]
ret
MysteryGiftFallbackItem:
ld c, DECO_POLKADOT_BED ; GREAT_BALL
ret
INCLUDE "data/items/mystery_gift_items.asm"
INCLUDE "data/decorations/mystery_gift_decos.asm"

View file

@ -0,0 +1,24 @@
PlaceWaitingText::
hlcoord 3, 10
ld b, 1
ld c, 11
ld a, [wBattleMode]
and a
jr z, .notinbattle
call Textbox
jr .proceed
.notinbattle
predef LinkTextboxAtHL
.proceed
hlcoord 4, 11
ld de, .Waiting
call PlaceString
ld c, 50
jp DelayFrames
.Waiting:
db "Waiting...!@"

View file

@ -0,0 +1,160 @@
; These functions seem to be related to backwards compatibility
ValidateOTTrademon:
ld a, [wCurOTTradePartyMon]
ld hl, wOTPartyMon1Species
call GetPartyLocation
push hl
ld a, [wCurOTTradePartyMon]
inc a
ld c, a
ld b, 0
ld hl, wOTPartyCount
add hl, bc
ld a, [hl]
pop hl
cp EGG
jr z, .matching_or_egg
cp [hl]
jr nz, .abnormal
.matching_or_egg
ld b, h
ld c, l
ld hl, MON_LEVEL
add hl, bc
ld a, [hl]
cp MAX_LEVEL + 1
jr nc, .abnormal
ld a, [wLinkMode]
cp LINK_TIMECAPSULE
jr nz, .normal
ld hl, wOTPartySpecies
ld a, [wCurOTTradePartyMon]
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
ld [wCurSpecies], a
; Magnemite and Magneton's types changed
; from Electric to Electric/Steel.
call GetPokemonIndexFromID
push bc
ld bc, MAGNEMITE
call .compare
if MAGNETON == (MAGNEMITE + 1)
inc bc
else
ld bc, MAGNETON
endc
call nz, .compare
pop bc
jr z, .normal
call GetBaseData
ld hl, wLinkOTPartyMonTypes
add hl, bc
add hl, bc
ld a, [wBaseType1]
cp [hl]
jr nz, .abnormal
inc hl
ld a, [wBaseType2]
cp [hl]
jr nz, .abnormal
.normal
and a
ret
.abnormal
scf
ret
.compare
ld a, h
cp b
ret nz
ld a, l
cp c
ret
CheckAnyOtherAliveMonsForTrade:
ld a, [wCurTradePartyMon]
ld d, a
ld a, [wPartyCount]
ld b, a
ld c, 0
.loop
ld a, c
cp d
jr z, .next
push bc
ld a, c
ld hl, wPartyMon1HP
call GetPartyLocation
pop bc
ld a, [hli]
or [hl]
jr nz, .done
.next
inc c
dec b
jr nz, .loop
ld a, [wCurOTTradePartyMon]
ld hl, wOTPartyMon1HP
call GetPartyLocation
ld a, [hli]
or [hl]
jr nz, .done
scf
ret
.done
and a
ret
PlaceTradePartnerNamesAndParty:
hlcoord 4, 0
ld de, wPlayerName
call PlaceString
ld a, $14
ld [bc], a
hlcoord 4, 8
ld de, wOTPlayerName
call PlaceString
ld a, $14
ld [bc], a
hlcoord 7, 1
ld de, wPartySpecies
call .PlaceSpeciesNames
hlcoord 7, 9
ld de, wOTPartySpecies
.PlaceSpeciesNames:
ld c, 0
.loop
ld a, [de]
cp -1
ret z
ld [wNamedObjectIndex], a
push bc
push hl
push de
push hl
ld a, c
ldh [hProduct], a
call GetPokemonName
pop hl
call PlaceString
pop de
inc de
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
pop bc
inc c
jr .loop
INCLUDE "data/pokemon/gen1_base_special.asm"

View file

@ -0,0 +1,39 @@
ConvertMon_2to1:
; Takes the Gen 2 Pokemon number stored in wTempSpecies,
; finds it in the Pokered_MonIndices table,
; and returns its index in wTempSpecies.
push bc
push hl
ld a, [wTempSpecies]
ld b, a
ld c, 0
ld hl, Pokered_MonIndices
.loop
inc c
ld a, [hli]
cp b
jr nz, .loop
ld a, c
ld [wTempSpecies], a
pop hl
pop bc
ret
ConvertMon_1to2:
; Takes the Gen 1 Pokemon number stored in wTempSpecies
; and returns the corresponding value from Pokered_MonIndices in wTempSpecies.
push bc
push hl
ld a, [wTempSpecies]
dec a
ld hl, Pokered_MonIndices
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
ld [wTempSpecies], a
pop hl
pop bc
ret
INCLUDE "data/pokemon/gen1_order.asm"