HDMA transfer functions

This commit is contained in:
pikalaxalt 2016-05-04 22:34:09 -04:00
parent 3713b71d9e
commit a613ed915c
27 changed files with 232 additions and 193 deletions

View File

@ -9429,7 +9429,7 @@ InitBattleDisplay: ; 3fb6c
ld [rSVBK], a
ld hl, wDecompressScratch
ld bc, wBackupAttrMap - wDecompressScratch
ld bc, wScratchAttrMap - wDecompressScratch
ld a, " "
call ByteFill

View File

@ -56,7 +56,7 @@ Predef_StartBattle: ; 8c20f
ld a, [wLinkMode]
cp LINK_MOBILE
jr z, .mobile
callba Function6454
callba ReanchorBGMap_NoOAMUpdate
call UpdateSprites
call DelayFrame
call .NonMobile_LoadPokeballTiles

View File

@ -45,7 +45,7 @@ ReturnFromMapSetupScript:: ; b8000
ld [wLandmarkSignTimer], a
call LoadMapNameSignGFX
call InitMapNameFrame
callba Function104303
callba HDMATransfer_OnlyTopFourRows
ret
.dont_do_map_sign
@ -113,7 +113,7 @@ PlaceMapNameSign:: ; b8098 (2e:4098)
jr nz, .skip2
call InitMapNameFrame
call PlaceMapNameCenterAlign
callba Function104303
callba HDMATransfer_OnlyTopFourRows
.skip2
ld a, $80
ld a, $70

View File

@ -2209,7 +2209,7 @@ Function55e0:: ; 55e0
xor a
.loop
ld [hMapObjectIndexBuffer], a
call GetObjectSprite
call DoesObjectHaveASprite
jr z, .ok
call Function565c
.ok
@ -2260,7 +2260,7 @@ Function5629: ; 5629
cp NUM_OBJECT_STRUCTS
ret nc
call GetObjectStruct
call GetObjectSprite
call DoesObjectHaveASprite
ret z
call Function5673
ret
@ -2363,7 +2363,7 @@ Function56a3: ; 56a3
; 56cd
Function56cd: ; 56cd
ld a, [wFollowNotExactPersonX]
ld a, [wPlayerBGMapOffsetX]
ld d, a
ld hl, OBJECT_SPRITE_X_OFFSET
add hl, bc
@ -2392,7 +2392,7 @@ Function56cd: ; 56cd
sub $20
.ok3
ld [hUsedSpriteIndex], a
ld a, [wFollowNotExactPersonY]
ld a, [wPlayerBGMapOffsetY]
ld e, a
ld hl, OBJECT_SPRITE_Y_OFFSET
add hl, bc
@ -2489,7 +2489,7 @@ HandleNPCStep:: ; 576a
xor a
.loop
ld [hMapObjectIndexBuffer], a
call GetObjectSprite
call DoesObjectHaveASprite
jr z, .next
call Function437b
.next
@ -2662,7 +2662,7 @@ Function587a: ; 587a
xor a
.loop
push af
call GetObjectSprite
call DoesObjectHaveASprite
jr z, .next
ld hl, OBJECT_FLAGS2
add hl, bc
@ -2707,7 +2707,7 @@ Function58b9:: ; 58b9
xor a
.loop
push af
call GetObjectSprite
call DoesObjectHaveASprite
jr z, .next
ld hl, OBJECT_FLAGS2
add hl, bc
@ -2817,19 +2817,19 @@ _UpdateSprites:: ; 5920
ret
; 5958
Function5958: ; 5958
ApplyBGMapAnchorToObjects: ; 5958
push hl
push de
push bc
ld a, [wFollowNotExactPersonX]
ld a, [wPlayerBGMapOffsetX]
ld d, a
ld a, [wFollowNotExactPersonY]
ld a, [wPlayerBGMapOffsetY]
ld e, a
ld bc, ObjectStructs
ld a, NUM_OBJECT_STRUCTS
.loop
push af
call GetObjectSprite
call DoesObjectHaveASprite
jr z, .skip
ld hl, OBJECT_SPRITE_X
add hl, bc
@ -2850,8 +2850,8 @@ Function5958: ; 5958
dec a
jr nz, .loop
xor a
ld [wFollowNotExactPersonX], a
ld [wFollowNotExactPersonY], a
ld [wPlayerBGMapOffsetX], a
ld [wPlayerBGMapOffsetY], a
pop bc
pop de
pop hl
@ -2881,7 +2881,7 @@ PRIORITY_HIGH EQU $30
ld hl, wMovementPointer
.loop
push hl
call GetObjectSprite
call DoesObjectHaveASprite
jr z, .skip
ld hl, OBJECT_FACING_STEP
add hl, bc
@ -2986,7 +2986,7 @@ PRIORITY_HIGH EQU $30
add [hl]
add 8
ld e, a
ld a, [wFollowNotExactPersonX]
ld a, [wPlayerBGMapOffsetX]
add e
ld [hFFBF], a
ld hl, OBJECT_SPRITE_Y
@ -2997,7 +2997,7 @@ PRIORITY_HIGH EQU $30
add [hl]
add 12
ld e, a
ld a, [wFollowNotExactPersonY]
ld a, [wPlayerBGMapOffsetY]
add e
ld [hFFC0], a
ld hl, OBJECT_FACING_STEP

View File

@ -296,7 +296,7 @@ Function241d5: ; 241d5
call Place2DMenuCursor
.loop
call Move2DMenuCursor
call Function10402d ; BUG: This function is in another bank.
call HDMATransferTileMapToWRAMBank3 ; BUG: This function is in another bank.
; Pointer in current bank (9) is bogus.
call .loop2
jr nc, .done

View File

@ -320,7 +320,7 @@ IsNPCAtCoord: ; 7041
xor a
.loop
ld [hObjectStructIndexBuffer], a
call GetObjectSprite
call DoesObjectHaveASprite
jr z, .next
ld hl, OBJECT_FLAGS1
@ -490,7 +490,7 @@ Function7113: ; unreferenced
xor a
.loop
ld [hObjectStructIndexBuffer], a
call GetObjectSprite
call DoesObjectHaveASprite
jr z, .next
ld hl, OBJECT_MOVEMENTTYPE
add hl, bc

View File

@ -474,7 +474,7 @@ CopyTempObjectToObjectStruct: ; 8286
sub [hl]
and $f
swap a
ld hl, wFollowNotExactPersonY
ld hl, wPlayerBGMapOffsetY
sub [hl]
ld hl, OBJECT_SPRITE_Y
add hl, de
@ -492,7 +492,7 @@ CopyTempObjectToObjectStruct: ; 8286
sub [hl]
and $f
swap a
ld hl, wFollowNotExactPersonX
ld hl, wPlayerBGMapOffsetX
sub [hl]
ld hl, OBJECT_SPRITE_X
add hl, de
@ -660,7 +660,7 @@ FollowNotExact:: ; 839e
sub [hl]
and $f
swap a
ld hl, wFollowNotExactPersonX
ld hl, wPlayerBGMapOffsetX
sub [hl]
ld hl, OBJECT_SPRITE_X
add hl, de
@ -673,7 +673,7 @@ FollowNotExact:: ; 839e
sub [hl]
and $f
swap a
ld hl, wFollowNotExactPersonY
ld hl, wPlayerBGMapOffsetY
sub [hl]
ld hl, OBJECT_SPRITE_Y
add hl, de

View File

@ -26,12 +26,12 @@ _HandlePlayerStep:: ; d497 (3:5497)
ld d, a
ld a, [wPlayerStepVectorY]
ld e, a
ld a, [wFollowNotExactPersonX]
ld a, [wPlayerBGMapOffsetX]
sub d
ld [wFollowNotExactPersonX], a
ld a, [wFollowNotExactPersonY]
ld [wPlayerBGMapOffsetX], a
ld a, [wPlayerBGMapOffsetY]
sub e
ld [wFollowNotExactPersonY], a
ld [wPlayerBGMapOffsetY], a
ret
ScrollScreen:: ; d4d2 (3:54d2)

View File

@ -3054,7 +3054,7 @@ Script_loadbytec2cf: ; 97b27
Script_closetext: ; 97b2f
; script command 0x49
call Function2e20
call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
call CloseText
ret
; 97b36

View File

@ -5,7 +5,7 @@ StartMenu:: ; 125cd
ld de, SFX_MENU
call PlaySFX
callba Function6454
callba ReanchorBGMap_NoOAMUpdate
ld hl, StatusFlags2
bit 2, [hl] ; bug catching contest
@ -22,8 +22,8 @@ StartMenu:: ; 125cd
call MenuFunc_1e7f
call .DrawBugContestStatusBox
call Function2e31
call Function2e20
callba Function64bf
call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
callba LoadFonts_NoOAMUpdate
call .DrawBugContestStatus
call UpdateTimePals
jr .Select

View File

@ -129,7 +129,7 @@ StatsScreen_WaitAnim: ; 4dd3a (13:5d3a)
.finish
ld hl, wcf64
res 5, [hl]
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
ret
StatsScreen_SetJumptableIndex: ; 4dd62 (13:5d62)
@ -149,7 +149,7 @@ MonStatsInit: ; 4dd72 (13:5d72)
res 6, [hl]
call ClearBGPalettes
call ClearTileMap
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
call StatsScreen_CopyToTempMon
ld a, [CurPartySpecies]
cp EGG
@ -1014,7 +1014,7 @@ EggStatsScreen: ; 4e33a
call DelayFrame
hlcoord 0, 0
call PrepMonFrontpic
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
call StatsScreen_AnimateEgg
ld a, [TempMonHappiness]

View File

@ -250,7 +250,7 @@ Function104770: ; 104770 (41:4770)
ld [wBGMapAnchor], a
ld [hSCY], a
ld [hSCX], a
callba Function5958
callba ApplyBGMapAnchorToObjects
ld a, [rVBK]
push af
ld a, $1

View File

@ -99,7 +99,7 @@ AnimateFrontpic: ; d008e
.loop
call SetUpPokeAnim
push af
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
pop af
jr nc, .loop
ret
@ -288,9 +288,9 @@ Functiond01a9: ; d01a9
ld a, $2
ld [rSVBK], a
call Functiond04bd
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
call Functiond0536
callba Function104047
callba HDMATransferAttrMapToWRAMBank3
pop af
ld [rSVBK], a
ret
@ -880,7 +880,7 @@ Functiond0504: ; d0504
xor a
ld [hBGMapMode], a
call Functiond051b
callba Function104047
callba HDMATransferAttrMapToWRAMBank3
pop af
ld [rSVBK], a
ret

View File

@ -570,7 +570,7 @@ LoadEDTile:: ; 323d
; 323f
; XXX
callba Function104000
callba HDMATransferAttrMapAndTileMapToWRAMBank3
ret
; 3246

View File

@ -636,7 +636,7 @@ GetObjectStruct:: ; 1ae5
ret
; 1af1
GetObjectSprite:: ; 1af1
DoesObjectHaveASprite:: ; 1af1
ld hl, OBJECT_SPRITE
add hl, bc
ld a, [hl]

View File

@ -3,12 +3,12 @@ RefreshScreen:: ; 2dba
call ClearWindowData
ld a, [hROMBank]
push af
ld a, BANK(Function6454) ; and BANK(Function64bf)
ld a, BANK(ReanchorBGMap_NoOAMUpdate) ; and BANK(LoadFonts_NoOAMUpdate)
rst Bankswitch
call Function6454
call Function2e20
call Function64bf
call ReanchorBGMap_NoOAMUpdate
call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
call LoadFonts_NoOAMUpdate
pop af
rst Bankswitch
@ -36,7 +36,7 @@ CloseText:: ; 2dcf
xor a
ld [hBGMapMode], a
call OverworldTextModeSwitch
call Function2e20
call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
xor a
ld [hBGMapMode], a
call Function2e31
@ -52,26 +52,26 @@ OpenText:: ; 2e08
call ClearWindowData
ld a, [hROMBank]
push af
ld a, BANK(Function6454) ; and BANK(Function64bf)
ld a, BANK(ReanchorBGMap_NoOAMUpdate) ; and BANK(LoadFonts_NoOAMUpdate)
rst Bankswitch
call Function6454 ; clear bgmap
call ReanchorBGMap_NoOAMUpdate ; clear bgmap
call SpeechTextBox
call Function2e20 ; anchor bgmap
call Function64bf ; load font
call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap ; anchor bgmap
call LoadFonts_NoOAMUpdate ; load font
pop af
rst Bankswitch
ret
; 2e20
Function2e20:: ; 2e20
_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap:: ; 2e20
ld a, [hOAMUpdate]
push af
ld a, $1
ld [hOAMUpdate], a
callba Function104110
callba OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
pop af
ld [hOAMUpdate], a

View File

@ -53,7 +53,7 @@ INCLUDE "engine/map_objects.asm"
INCLUDE "engine/intro_menu.asm"
Function6454:: ; 6454
ReanchorBGMap_NoOAMUpdate:: ; 6454
call DelayFrame
ld a, [hOAMUpdate]
push af
@ -64,7 +64,8 @@ Function6454:: ; 6454
push af
xor a
ld [hBGMapMode], a
call .Function6473
call .ReanchorBGMap
pop af
ld [hBGMapMode], a
@ -74,7 +75,7 @@ Function6454:: ; 6454
set 6, [hl]
ret
.Function6473:
.ReanchorBGMap:
xor a
ld [hFFC6], a
ld [hBGMapMode], a
@ -82,8 +83,8 @@ Function6454:: ; 6454
ld [hWY], a
call OverworldTextModeSwitch
ld a, VBGMap1 / $100
call .Function64b9
call Function2e20
call .LoadBGMapAddrIntoHRAM
call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
callba LoadOW_BGPal7
callba ApplyPals
ld a, $1
@ -91,9 +92,9 @@ Function6454:: ; 6454
xor a
ld [hBGMapMode], a
ld [hWY], a
callba Function64db ; no need to farcall
callba HDMATransfer_FillBGMap0WithTile60 ; no need to farcall
ld a, VBGMap0 / $100
call .Function64b9
call .LoadBGMapAddrIntoHRAM
xor a
ld [wBGMapAnchor], a
ld a, VBGMap0 / $100
@ -101,28 +102,28 @@ Function6454:: ; 6454
xor a
ld [hSCX], a
ld [hSCY], a
call Function5958
call ApplyBGMapAnchorToObjects
ret
.Function64b9: ; 64b9
.LoadBGMapAddrIntoHRAM: ; 64b9
ld [hBGMapAddress + 1], a
xor a
ld [hBGMapAddress], a
ret
Function64bf:: ; 64bf
LoadFonts_NoOAMUpdate:: ; 64bf
ld a, [hOAMUpdate]
push af
ld a, $1
ld [hOAMUpdate], a
call .Function64cd
call .LoadGFX
pop af
ld [hOAMUpdate], a
ret
.Function64cd:
.LoadGFX:
call LoadFontsExtra
ld a, $90
ld [hWY], a
@ -130,7 +131,7 @@ Function64bf:: ; 64bf
call LoadStandardFont
ret
Function64db: ; 64db
HDMATransfer_FillBGMap0WithTile60: ; 64db
ld a, [rSVBK]
push af
ld a, $6
@ -138,7 +139,7 @@ Function64db: ; 64db
ld a, $60
ld hl, wDecompressScratch
ld bc, wBackupAttrMap - wDecompressScratch
ld bc, wScratchAttrMap - wDecompressScratch
call ByteFill
ld a, wDecompressScratch / $100
ld [rHDMA1], a
@ -3354,7 +3355,7 @@ Function4e906: ; 4e906
ld a, $6
ld [rSVBK], a
ld hl, wDecompressScratch
ld bc, wBackupAttrMap - wDecompressScratch
ld bc, wScratchAttrMap - wDecompressScratch
ld a, " "
call ByteFill
hlbgcoord 0, 0

View File

@ -47,7 +47,7 @@ Function17a6a8: ; 17a6a8 (5e:66a8)
call Function17aba0
callba Function106464
call Function17ac0c
callba Function104000
callba HDMATransferAttrMapAndTileMapToWRAMBank3
call Function17abcf
callba LoadOW_BGPal7
callba Function49420
@ -169,7 +169,7 @@ Function17a78f: ; 17a78f (5e:678f)
bit 7, [hl]
res 7, [hl]
jr nz, .asm_17a79f
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
ret
.asm_17a79f

View File

@ -1,52 +1,52 @@
Function104000:: ; 104000
HDMATransferAttrMapAndTileMapToWRAMBank3:: ; 104000
ld hl, .Function
jp CallInSafeGFXMode
.Function:
decoord 0, 0, AttrMap
ld hl, wBackupAttrMap
ld hl, wScratchAttrMap
call CutAndPasteAttrMap
decoord 0, 0
ld hl, wDecompressScratch
ld hl, wScratchTileMap
call CutAndPasteTilemap
ld a, $0
ld [rVBK], a
ld hl, wDecompressScratch
call Function10419d
ld hl, wScratchTileMap
call HDMATransferToWRAMBank3
ld a, $1
ld [rVBK], a
ld hl, wBackupAttrMap
call Function10419d
ld hl, wScratchAttrMap
call HDMATransferToWRAMBank3
ret
; 10402d
Function10402d:: ; 10402d
HDMATransferTileMapToWRAMBank3:: ; 10402d
ld hl, .Function
jp CallInSafeGFXMode
.Function:
decoord 0, 0
ld hl, wDecompressScratch
ld hl, wScratchTileMap
call CutAndPasteTilemap
ld a, $0
ld [rVBK], a
ld hl, wDecompressScratch
call Function10419d
ld hl, wScratchTileMap
call HDMATransferToWRAMBank3
ret
; 104047
Function104047: ; 104047
HDMATransferAttrMapToWRAMBank3: ; 104047
ld hl, .Function
jp CallInSafeGFXMode
.Function:
decoord 0, 0, AttrMap
ld hl, wBackupAttrMap
ld hl, wScratchAttrMap
call CutAndPasteAttrMap
ld a, $1
ld [rVBK], a
ld hl, wBackupAttrMap
call Function10419d
ld hl, wScratchAttrMap
call HDMATransferToWRAMBank3
ret
; 104061
@ -56,63 +56,67 @@ ReloadMapPart:: ; 104061
.Function:
decoord 0, 0, AttrMap
ld hl, wBackupAttrMap
ld hl, wScratchAttrMap
call CutAndPasteAttrMap
decoord 0, 0
ld hl, wDecompressScratch
ld hl, wScratchTileMap
call CutAndPasteTilemap
call DelayFrame
di
ld a, [rVBK]
push af
ld a, $1
ld [rVBK], a
ld hl, wBackupAttrMap
call Function1041ad
ld hl, wScratchAttrMap
call HDMATransfer_Wait127Scanlines_toBGMap
ld a, $0
ld [rVBK], a
ld hl, wDecompressScratch
call Function1041ad
ld hl, wScratchTileMap
call HDMATransfer_Wait127Scanlines_toBGMap
pop af
ld [rVBK], a
ei
ret
Function104099: ; 104099
Mobile_ReloadMapPart: ; 104099
ld hl, ReloadMapPart ; useless
ld hl, .Function
jp CallInSafeGFXMode
.Function:
decoord 0, 0, AttrMap
ld hl, wBackupAttrMap
ld hl, wScratchAttrMap
call CutAndPasteAttrMap
decoord 0, 0
ld hl, wDecompressScratch
ld hl, wScratchTileMap
call CutAndPasteTilemap
call DelayFrame
di
ld a, [rVBK]
push af
ld a, $1
ld [rVBK], a
ld hl, wBackupAttrMap
call Function1041c1
ld hl, wScratchAttrMap
call HDMATransfer_NoDI
ld a, $0
ld [rVBK], a
ld hl, wDecompressScratch
call Function1041c1
ld hl, wScratchTileMap
call HDMATransfer_NoDI
pop af
ld [rVBK], a
ei
ret
; 1040d4
Function1040d4: ; 1040d4
ld hl, .Function
; XXX
ld hl, .unreferenced_1040da
jp CallInSafeGFXMode
.Function:
.unreferenced_1040da
ld a, $1
ld [rVBK], a
ld a, $3
@ -132,31 +136,34 @@ Function1040d4: ; 1040d4
ret
; 1040fb
Function1040fb: ; 1040fb
ld hl, .Function
; XXX
ld hl, .unreferenced_104101
jp CallInSafeGFXMode
.Function:
.unreferenced_104101
ld a, $1
ld [rVBK], a
ld a, $3
ld [rSVBK], a
ld hl, w3_d800
call Function10419d
call HDMATransferToWRAMBank3
ret
; 104110
Function104110:: ; 104110
OpenAndCloseMenu_HDMATransferTileMapAndAttrMap:: ; 104110
; OpenText
ld hl, .Function
jp CallInSafeGFXMode
.Function:
; Transfer AttrMap and Tilemap to BGMap
; Fill vBGAttrs with $00
; Fill vBGTiles with " "
decoord 0, 0, AttrMap
ld hl, wBackupAttrMap
ld hl, wScratchAttrMap
call CutAndPasteAttrMap
decoord 0, 0
ld hl, wDecompressScratch
ld hl, wScratchTileMap
call CutAndPasteTilemap
call DelayFrame
@ -165,38 +172,42 @@ Function104110:: ; 104110
push af
ld a, $1
ld [rVBK], a
ld hl, wBackupAttrMap
call Function1041b7
ld hl, wScratchAttrMap
call HDMATransfer_Wait123Scanlines_toBGMap
ld a, $0
ld [rVBK], a
ld hl, wDecompressScratch
call Function1041b7
ld hl, wScratchTileMap
call HDMATransfer_Wait123Scanlines_toBGMap
pop af
ld [rVBK], a
ei
ret
; 104148
Function104148: ; 104148 (41:4148)
Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap: ; 104148 (41:4148)
ld hl, .Function
jp CallInSafeGFXMode
.Function:
; Transfer AttrMap and Tilemap to BGMap
; Fill vBGAttrs with $00
; Fill vBGTiles with $ff
decoord 0, 0, AttrMap
ld hl, wBackupAttrMap
ld hl, wScratchAttrMap
call CutAndPasteAttrMap
ld c, $ff
decoord 0, 0
ld hl, wDecompressScratch
ld hl, wScratchTileMap
call CutAndPasteMap
ld a, $1
ld [rVBK], a
ld hl, wBackupAttrMap
call Function1041ad
ld hl, wScratchAttrMap
call HDMATransfer_Wait127Scanlines_toBGMap
ld a, $0
ld [rVBK], a
ld hl, wDecompressScratch
call Function1041ad
ld hl, wScratchTileMap
call HDMATransfer_Wait127Scanlines_toBGMap
ret
; 104177
@ -233,8 +244,8 @@ CallInSafeGFXMode: ; 104177
; 10419d
Function10419d: ; 10419d (41:419d)
call Function10424e
HDMATransferToWRAMBank3: ; 10419d (41:419d)
call _LoadHDMAParameters
ld a, $23
ld [hDMATransfer], a
@ -246,60 +257,76 @@ WaitDMATransfer: ; 104a14
jr nz, .loop
ret
Function1041ad: ; 1041ad (41:41ad)
HDMATransfer_Wait127Scanlines_toBGMap: ; 1041ad (41:41ad)
; HDMA transfer from hl to [hBGMapAddress]
; hBGMapAddress -> de
; 2 * SCREEN_HEIGHT -> c
ld a, [hBGMapAddress + 1]
ld d, a
ld a, [hBGMapAddress]
ld e, a
ld c, $24
jr Function104209
ld c, 2 * SCREEN_HEIGHT
jr HDMATransfer_Wait127Scanlines
Function1041b7: ; 1041b7 (41:41b7)
HDMATransfer_Wait123Scanlines_toBGMap: ; 1041b7 (41:41b7)
; HDMA transfer from hl to [hBGMapAddress]
; hBGMapAddress -> de
; $24 -> c
; 2 * SCREEN_HEIGHT -> c
; $7b --> b
ld a, [hBGMapAddress + 1]
ld d, a
ld a, [hBGMapAddress]
ld e, a
ld c, $24
jr asm_104205
ld c, 2 * SCREEN_HEIGHT
jr HDMATransfer_Wait123Scanlines
; 1041c1 (41:41c1)
Function1041c1: ; 1041c1
HDMATransfer_NoDI: ; 1041c1
; HDMA transfer from hl to [hBGMapAddress]
; [hBGMapAddress] --> de
; 2 * SCREEN_HEIGHT --> c
ld a, [hBGMapAddress + 1]
ld d, a
ld a, [hBGMapAddress]
ld e, a
ld c, $24
ld c, 2 * SCREEN_HEIGHT
; [rHDMA1, rHDMA2] = hl & $fff0
ld a, h
ld [rHDMA1], a
ld a, l
and $f0
ld [rHDMA2], a
; [rHDMA3, rHDMA4] = de & $1ff0
ld a, d
and $1f
ld [rHDMA3], a
ld a, e
and $f0
ld [rHDMA4], a
; b = c | %10000000
ld a, c
dec c
or $80
ld b, a
; d = $7f - c + 1
ld a, $7f
sub c
ld d, a
; while [rLY] >= d: pass
.loop1
ld a, [rLY]
cp d
jr nc, .loop1
; while not [rSTAT] & 3: pass
.loop2
ld a, [rSTAT]
and $3
jr z, .loop2
; load the 5th byte of HDMA
ld a, b
ld [rHDMA5], a
; wait until rLY advances (c + 1) times
ld a, [rLY]
inc c
ld hl, rLY
@ -314,49 +341,58 @@ Function1041c1: ; 1041c1
ret
; 104205
asm_104205:
HDMATransfer_Wait123Scanlines:
ld b, $7b
jr asm_10420b
jr _continue_HDMATransfer
Function104209:
; LY magic
HDMATransfer_Wait127Scanlines:
ld b, $7f
asm_10420b:
_continue_HDMATransfer:
; a lot of waiting around for hardware registers
; [rHDMA1, rHDMA2] = hl & $fff0
ld a, h
ld [rHDMA1], a
ld a, l
and $f0 ; high nybble
ld [rHDMA2], a
; [rHDMA3, rHDMA4] = de & $1ff0
ld a, d
and $1f ; lower 5 bits
ld [rHDMA3], a
ld a, e
and $f0 ; high nybble
ld [rHDMA4], a
; e = c | %10000000
ld a, c
dec c
or $80 ; set 7, a
or $80
ld e, a
; d = b - c + 1
ld a, b
sub c
ld d, a
; while [rLY] >= d: pass
.ly_loop
ld a, [rLY]
cp d
jr nc, .ly_loop
di
; while [rSTAT] & 3: pass
.rstat_loop_1
ld a, [rSTAT]
and $3
jr nz, .rstat_loop_1
; while not [rSTAT] & 3: pass
.rstat_loop_2
ld a, [rSTAT]
and $3
jr z, .rstat_loop_2
; load the 5th byte of HDMA
ld a, e
ld [rHDMA5], a
; wait until rLY advances (c + 1) times
ld a, [rLY]
inc c
ld hl, rLY
@ -374,7 +410,7 @@ asm_10420b:
; 10424e
Function10424e: ; 10424e (41:424e)
_LoadHDMAParameters: ; 10424e (41:424e)
ld a, h
ld [rHDMA1], a
ld a, l
@ -415,7 +451,7 @@ CutAndPasteMap: ; 104265 (41:4265)
; load the original value of c into hl 12 times
ld a, [hMapObjectIndexBuffer]
ld b, 12
ld b, BG_MAP_WIDTH - SCREEN_WIDTH
.loop3
ld [hli], a
dec b
@ -441,7 +477,7 @@ _Get2bpp:: ; 104284
push bc
push hl
; Copy c tiles of the 2bpp from b:de to wDecompressScratch
; Copy c tiles of the 2bpp from b:de to wScratchTileMap
ld a, b ; bank
ld l, c ; number of tiles
ld h, $0
@ -452,7 +488,7 @@ endr
ld c, l
ld h, d ; address
ld l, e
ld de, wDecompressScratch
ld de, wScratchTileMap
call FarCopyBytes
pop hl
@ -464,8 +500,8 @@ endr
ld d, h
ld e, l
ld hl, wDecompressScratch
call Function104209
ld hl, wScratchTileMap
call HDMATransfer_Wait127Scanlines
; restore the previous bank
pop af
@ -519,7 +555,7 @@ endr
ld b, h
ld h, d
ld l, e
ld de, wDecompressScratch
ld de, wScratchTileMap
call FarCopyBytesDouble_DoubleBankSwitch
pop hl
@ -531,41 +567,41 @@ endr
ld d, h
ld e, l
ld hl, wDecompressScratch
call Function104209
ld hl, wScratchTileMap
call HDMATransfer_Wait127Scanlines
pop af
ld [rSVBK], a
ret
; 104303
Function104303: ; 104303
ld hl, Function104309
HDMATransfer_OnlyTopFourRows: ; 104303
ld hl, .Function
jp CallInSafeGFXMode
; 104309
Function104309:
ld hl, wDecompressScratch
.Function:
ld hl, wScratchTileMap
decoord 0, 0
call Function10433a
ld hl, wDecompressScratch + $80
call .Copy
ld hl, wScratchTileMap + $80
decoord 0, 0, AttrMap
call Function10433a
call .Copy
ld a, $1
ld [rVBK], a
ld c, $8
ld hl, wDecompressScratch + $80
ld hl, wScratchTileMap + $80
debgcoord 0, 0, VBGMap1
call Function104209
call HDMATransfer_Wait127Scanlines
ld a, $0
ld [rVBK], a
ld c, $8
ld hl, wDecompressScratch
ld hl, wScratchTileMap
debgcoord 0, 0, VBGMap1
call Function104209
call HDMATransfer_Wait127Scanlines
ret
Function10433a: ; 10433a (41:433a)
.Copy: ; 10433a (41:433a)
ld b, 4
.outer_loop
ld c, SCREEN_WIDTH
@ -576,7 +612,7 @@ Function10433a: ; 10433a (41:433a)
dec c
jr nz, .inner_loop
ld a, l
add $20 - SCREEN_WIDTH
add BG_MAP_WIDTH - SCREEN_WIDTH
ld l, a
ld a, h
adc $0

View File

@ -359,7 +359,7 @@ Function48304: ; 48304 (12:4304)
ld a, $29
.asm_4833f
ld [wMenuScrollPosition], a
callba Function104148
callba Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
.asm_48348
call ScrollingMenu
ld de, $629
@ -385,7 +385,7 @@ Function48304: ; 48304 (12:4304)
ld [wd003], a
.asm_48377
call Function48187
callba Function104148
callba Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
jp Function4840c
Function48383: ; 48383 (12:4383)

View File

@ -2201,7 +2201,7 @@ Function89d75: ; 89d75 (22:5d75)
push hl
call Function8923c
call _hl_
callba Function104148
callba Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
pop hl
jr asm_89d90

View File

@ -202,7 +202,7 @@ Function100144: ; 100144
ret z
res 2, [hl]
res 6, [hl]
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
ret
; 100163
@ -445,12 +445,12 @@ Function100301: ; 100301
; 100320
Function100320: ; 100320
callba Function104099
callba Mobile_ReloadMapPart
ret
; 100327
Function100327: ; 100327
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
ret
; 100327
@ -1821,7 +1821,7 @@ Function100b45: ; 100b45
call Mobile_SetOverworldDelay
callba MobileMenuJoypad
push bc
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
call Function100e2d
pop bc
jr c, .asm_100b6b
@ -1882,7 +1882,7 @@ MobileMoveSelectionScreen: ; 100b9f
call Mobile_SetOverworldDelay
callba MobileMenuJoypad
push bc
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
call Function100e2d
pop bc
jr c, .b_button
@ -2016,7 +2016,7 @@ Mobile_PartyMenuSelect: ; 100cb5
callba MobileMenuJoypad
push bc
callba PlaySpriteAnimations
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
call Function100dfd
pop bc
jr c, .done
@ -2070,7 +2070,7 @@ MobileBattleMonMenu: ; 100d22
callba MobileMenuJoypad
push bc
callba PlaySpriteAnimations
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
call Function100dfd
pop bc
jr c, .asm_100d54
@ -3074,7 +3074,7 @@ Function1013c0: ; 1013c0
; 1013d6
Function1013d6: ; 1013d6
callba Function104000
callba HDMATransferAttrMapAndTileMapToWRAMBank3
ret
; 1013dd
@ -5182,7 +5182,7 @@ Function10224b: ; 10224b
.asm_10225e
res 1, [hl]
res 2, [hl]
callba Function104099
callba Mobile_ReloadMapPart
scf
ret
; 10226a
@ -6809,7 +6809,7 @@ Function102d9a: ; 102d9a
hlcoord 0, 0, AttrMap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call ByteFill
callba Function104000
callba HDMATransferAttrMapAndTileMapToWRAMBank3
ret
; 102db7
@ -7390,7 +7390,7 @@ Function103309: ; 103309
ld [wd1ee], a
call Function1034be
call UpdateSprites
callba Function104000
callba HDMATransferAttrMapAndTileMapToWRAMBank3
ld a, $01
ld [wd1f0], a
call Function10339a
@ -7404,7 +7404,7 @@ Function103362: ; 103362
call Function1033af
call Function10339a
call Function10342c
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
ld a, [Buffer2]
bit 7, a
jr z, .asm_103362

View File

@ -445,7 +445,7 @@ Function1082db: ; 1082db
.loop
callba PlaySpriteAnimations
callba SetUpPokeAnim
callba Function10402d
callba HDMATransferTileMapToWRAMBank3
jr nc, .loop
ret
; 1082f0

View File

@ -7380,7 +7380,7 @@ Function117a94: ; 0x117a94
call ClearBGPalettes
call ClearSprites
callba Function172e78
callba Function104000
callba HDMATransferAttrMapAndTileMapToWRAMBank3
ret
; 0x117ab4
@ -7401,7 +7401,7 @@ Function117acd: ; 0x117acd
bit 7, a
jr nz, .asm_117ae2
call Function117ae9
callba Function104000
callba HDMATransferAttrMapAndTileMapToWRAMBank3
jr Function117acd
.asm_117ae2

View File

@ -4647,7 +4647,7 @@ Function17f555: ; 17f555
ld a, [wc303]
bit 7, a
jr nz, .quit
callba Function104000
callba HDMATransferAttrMapAndTileMapToWRAMBank3
jr .loop
.quit
@ -4716,7 +4716,7 @@ Function17f5c3: ; 17f5c3
Function17f5d2: ; 17f5d2
call Function17f5e4
callba Function104000
callba HDMATransferAttrMapAndTileMapToWRAMBank3
call SetPalettes
ld a, $1
ld [wc303], a

View File

@ -280,7 +280,7 @@ Function4a149: ; 4a149 (12:6149)
call ClearBox
hlcoord 1, 14
call PlaceString
callba Function104148
callba Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
call SetPalettes
call StaticMenuJoypad
ld hl, wMenuCursorY
@ -403,7 +403,7 @@ Function4a28a: ; 4a28a (12:628a)
hlcoord 14, 1
ld de, String_4a34b
call PlaceString
callba Function104148
callba Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
call Function4a118
call ScrollingMenuJoypad
push af
@ -432,7 +432,7 @@ Function4a28a: ; 4a28a (12:628a)
ld b, 3
ld c, 4
call TextBox
callba Function104148
callba Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
ld hl, DeletePassword_YesNo_MenuDataHeader
call LoadMenuDataHeader
call VerticalMenu
@ -455,7 +455,7 @@ Function4a28a: ; 4a28a (12:628a)
call ExitMenu
.quit
call Call_ExitMenu
callba Function104148
callba Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
xor a
ret
; 4a346 (12:6346)

View File

@ -1504,9 +1504,9 @@ wSeerCaughtData:: ds 1
wSeerCaughtGender:: ds 1
ds wSeerAction - @
wBufferMonNick:: ds PKMN_NAME_LENGTH
wBufferMonOT:: ds NAME_LENGTH
wBufferMon:: party_struct wBufferMon
wBufferMonNick:: ds PKMN_NAME_LENGTH ; d002
wBufferMonOT:: ds NAME_LENGTH ; d00d
wBufferMon:: party_struct wBufferMon ; d018
ds 8
wMonOrItemNameBuffer::
ds wBufferMonNick - @
@ -1820,8 +1820,8 @@ wPrevMapGroup:: ds 1
wPrevMapNumber:: ds 1
; d14c
wFollowNotExactPersonX:: ds 1 ; used in FollowNotExact
wFollowNotExactPersonY:: ds 1 ; used in FollowNotExact
wPlayerBGMapOffsetX:: ds 1 ; used in FollowNotExact; unit is pixels
wPlayerBGMapOffsetY:: ds 1 ; used in FollowNotExact; unit is pixels
; Player movement
wPlayerStepVectorX:: ds 1 ; d14e
@ -2923,7 +2923,7 @@ w3_d742:: battle_tower_struct w3_d742
ds -$22
wBTChoiceOfLvlGroup::
w3_d800:: ; ds BG_MAP_WIDTH * SCREEN_HEIGHT ($240)
w3_d800:: ; ds BG_MAP__WIDTH * SCREEN_HEIGHT ($240)
ds $69
w3_d869:: ds $17
w3_d880:: ds 1
@ -3049,8 +3049,10 @@ w5_dc3e:: ds $c
SECTION "WRAM 6", WRAMX, BANK [6]
wDecompressScratch:: ds $400
wBackupAttrMap:: ds $200
wDecompressScratch::
wScratchTileMap::
ds BG_MAP_WIDTH * BG_MAP_HEIGHT
wScratchAttrMap:: ds $200
w6_d600:: ds $200
w6_d800::