Skip to content

Commit

Permalink
Use ClearMemory_Bank2 instead of ClearNBytesFromHL
Browse files Browse the repository at this point in the history
  • Loading branch information
Sha0den committed Sep 24, 2024
1 parent 915e498 commit 0285528
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/engine/duel/ai/common.asm
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ CopyListWithFFTerminatorFromHLToDE_Bank8:
jr CopyListWithFFTerminatorFromHLToDE_Bank8

; zeroes a bytes starting from hl.
; this function is identical to 'ClearNBytesFromHL' in Bank $2,
; as well as ClearMemory_Bank5' and 'ClearMemory_Bank6'.
; this function is identical to 'ClearMemory_Bank2',
; 'ClearMemory_Bank5' and 'ClearMemory_Bank6'.
; preserves all registers
; input:
; a = number of bytes to clear
Expand Down
4 changes: 2 additions & 2 deletions src/engine/duel/ai/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,8 @@ CheckEnergyNeededForAttackAfterDiscard:
ret

; zeroes a bytes starting from hl.
; this function is identical to 'ClearNBytesFromHL' in Bank $2,
; as well as ClearMemory_Bank6' and 'ClearMemory_Bank8'.
; this function is identical to 'ClearMemory_Bank2',
; 'ClearMemory_Bank6' and 'ClearMemory_Bank8'.
; preserves all registers
; input:
; a = number of bytes to clear
Expand Down
4 changes: 2 additions & 2 deletions src/engine/input_name.asm
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Deck4Data:
db $ff

; zeroes a bytes starting from hl.
; this function is identical to 'ClearNBytesFromHL' in Bank $2,
; as well as ClearMemory_Bank5' and 'ClearMemory_Bank8'.
; this function is identical to 'ClearMemory_Bank2',
; 'ClearMemory_Bank5' and 'ClearMemory_Bank8'.
; preserves all registers
; input:
; a = number of bytes to clear
Expand Down
6 changes: 3 additions & 3 deletions src/engine/menus/card_album.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ CreateCardSetList:
push af
ld a, DECK_SIZE
ld hl, wFilteredCardList
call ClearNBytesFromHL
call ClearMemory_Bank2
ld a, DECK_SIZE
ld hl, wOwnedCardsCountList
call ClearNBytesFromHL
call ClearMemory_Bank2
xor a
ld [wOwnedPhantomCardFlags], a
pop af
Expand Down Expand Up @@ -913,7 +913,7 @@ CardAlbum:
; set all Card Sets as available
ld a, NUM_CARD_SETS
ld hl, wUnavailableAlbumCardSets
call ClearNBytesFromHL
call ClearMemory_Bank2

; check whether player has had promotional cards
call EnableSRAM
Expand Down
23 changes: 14 additions & 9 deletions src/engine/menus/deck_configuration.asm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ DrawDecksScreen:
; mark all decks as invalid
ld a, NUM_DECKS
ld hl, wDecksValid
call ClearNBytesFromHL
call ClearMemory_Bank2

; for each deck, check if it has cards and if so
; mark is as valid in wDecksValid
Expand Down Expand Up @@ -708,11 +708,11 @@ DismantleDeck:
or a
jr z, .done_dismantle
ld a, NAME_BUFFER_LENGTH
call ClearNBytesFromHL
call ClearMemory_Bank2
call GetPointerToDeckCards
call AddDeckToCollection
ld a, DECK_SIZE
call ClearNBytesFromHL
call ClearMemory_Bank2
.done_dismantle
call DisableSRAM
add sp, $2
Expand Down Expand Up @@ -1050,10 +1050,10 @@ CreateFilteredCardList:
push af
ld a, DECK_SIZE
ld hl, wOwnedCardsCountList
call ClearNBytesFromHL
call ClearMemory_Bank2
ld a, DECK_SIZE
ld hl, wFilteredCardList
call ClearNBytesFromHL
call ClearMemory_Bank2
pop af

; loops all cards in collection
Expand Down Expand Up @@ -1175,10 +1175,15 @@ IsCardInAnyDeck:
or a
ret


; zeroes a bytes starting from hl.
; this function is identical to 'ClearMemory_Bank5',
; 'ClearMemory_Bank6' and 'ClearMemory_Bank8'.
; preserves all registers
; hl = start of bytes to set to $0
; a = number of bytes to set to $0
ClearNBytesFromHL:
; input:
; a = number of bytes to clear
; hl = where to begin erasing
ClearMemory_Bank2:
push af
push bc
push hl
Expand Down Expand Up @@ -2981,7 +2986,7 @@ GetCardTypeIconPalette:
PrepareToBuildDeckConfigurationToSend:
ld hl, wCurDeckCards
ld a, wCurDeckCardsEnd - wCurDeckCards
call ClearNBytesFromHL
call ClearMemory_Bank2
ld a, $ff
ld [wCurDeck], a
ld hl, .text
Expand Down
18 changes: 9 additions & 9 deletions src/engine/menus/deck_machine.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ HandleDeckMissingCardsList:

ld a, NUM_FILTERS
ld hl, wCardFilterCounts
call ClearNBytesFromHL
call ClearMemory_Bank2
ld a, DECK_SIZE
ld [wTotalCardCount], a
ld hl, wCardFilterCounts
Expand Down Expand Up @@ -341,7 +341,7 @@ ShowReceivedCardsList:
Func_b088:
ld a, CARD_COLLECTION_SIZE - 1
ld hl, wTempCardCollection
call ClearNBytesFromHL
call ClearMemory_Bank2
ld de, wDuelTempList
call .Func_b0b2
ld a, $ff
Expand Down Expand Up @@ -379,10 +379,10 @@ Func_b088:
push af
ld a, DECK_SIZE
ld hl, wOwnedCardsCountList
call ClearNBytesFromHL
call ClearMemory_Bank2
ld a, DECK_SIZE
ld hl, wFilteredCardList
call ClearNBytesFromHL
call ClearMemory_Bank2
pop af
ld hl, $0
ld de, $0
Expand Down Expand Up @@ -828,7 +828,7 @@ GetSavedDeckPointers:
ld a, NUM_DECK_SAVE_MACHINE_SLOTS
add NUM_DECK_SAVE_MACHINE_SLOTS ; add a is better
ld hl, wMachineDeckPtrs
call ClearNBytesFromHL
call ClearMemory_Bank2
ld de, wMachineDeckPtrs
ld hl, sSavedDecks
ld bc, DECK_STRUCT_SIZE
Expand Down Expand Up @@ -1376,7 +1376,7 @@ TryDeleteSavedDeck:
call CopyDeckName
pop hl
ld a, DECK_STRUCT_SIZE
call ClearNBytesFromHL
call ClearMemory_Bank2
call DisableSRAM
xor a
ld [wTxRam2 + 0], a
Expand Down Expand Up @@ -1481,7 +1481,7 @@ HandleDismantleDeckToMakeSpace:
call AddDeckToCollection
pop hl
ld a, DECK_STRUCT_SIZE
call ClearNBytesFromHL
call ClearMemory_Bank2
call DisableSRAM

; redraw deck screen
Expand Down Expand Up @@ -1674,7 +1674,7 @@ TryBuildDeckMachineDeck:
call AddDeckToCollection
pop hl
ld a, DECK_STRUCT_SIZE
call ClearNBytesFromHL
call ClearMemory_Bank2
ret

; collects cards missing from player's collection
Expand Down Expand Up @@ -2132,7 +2132,7 @@ HandleAutoDeckMenu:
.CreateAutoDeckPointerList
ld a, 2 * NUM_DECK_MACHINE_SLOTS
ld hl, wMachineDeckPtrs
call ClearNBytesFromHL
call ClearMemory_Bank2
ld de, wMachineDeckPtrs
ld hl, sAutoDecks
ld bc, DECK_STRUCT_SIZE
Expand Down
6 changes: 3 additions & 3 deletions src/engine/menus/deck_selection.asm
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ OpenDeckConfirmationMenu:

ld a, NUM_FILTERS
ld hl, wCardFilterCounts
call ClearNBytesFromHL
call ClearMemory_Bank2
ld a, DECK_SIZE
ld [wTotalCardCount], a
ld hl, wCardFilterCounts
Expand Down Expand Up @@ -244,7 +244,7 @@ DeckSelectionSubMenu:
call CopyDeckFromSRAM
ld a, 20
ld hl, wCurDeckName
call ClearNBytesFromHL
call ClearMemory_Bank2
ld de, wCurDeckName
call GetPointerToDeckName
call CopyListFromHLToDEInSRAM
Expand Down Expand Up @@ -290,7 +290,7 @@ DeckSelectionSubMenu:
.get_input_deck_name
ld a, 20
ld hl, wCurDeckName
call ClearNBytesFromHL
call ClearMemory_Bank2
ld de, wCurDeckName
call GetPointerToDeckName
call CopyListFromHLToDEInSRAM
Expand Down

0 comments on commit 0285528

Please sign in to comment.