diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/engine/bank1.asm | 209 | ||||
| -rw-r--r-- | src/engine/bank2.asm | 2 | ||||
| -rw-r--r-- | src/engine/bank3.asm | 6 | ||||
| -rw-r--r-- | src/engine/bank4.asm | 6 | ||||
| -rw-r--r-- | src/engine/home.asm | 80 | ||||
| -rw-r--r-- | src/text/text1.asm | 2 | ||||
| -rw-r--r-- | src/text/text_offsets.asm | 2 | ||||
| -rw-r--r-- | src/wram.asm | 2 | 
8 files changed, 280 insertions, 29 deletions
| diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 3550b53..746c934 100644 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -321,10 +321,12 @@ HandleTurn: ; 4225 (1:4225)  Func_4262:  	call Func_4b2c  	call Func_100b +;	fallthrough  Func_4268:  	ld a, $06  	call $51e7 +;	fallthrough  ; print the main interface during a duel, including background, Pokemon, HUDs and a text box.  ; the bottom text box changes depending on whether the turn belongs to the player (show the duel menu), @@ -466,7 +468,7 @@ Func_434e: ; 434e (1:434e)  	call CreateHandCardList  	jr c, .no_cards_in_hand  	call Func_559a -	ld a, $09 +	ld a, START + A_BUTTON  	ld [wcbd6], a  	jp $55f0  .no_cards_in_hand @@ -477,18 +479,19 @@ Func_434e: ; 434e (1:434e)  ; triggered by pressing B + START in the duel menu  DuelMenuShortcut_OpponentActivePokemon: ; 4364 (1:4364)  	call SwapTurn -	call Func_4376 +	call OpenActivePokemonScreen  	call SwapTurn  	jp DuelMainInterface  ; 0x4370  ; triggered by pressing START in the duel menu  DuelMenuShortcut_PlayerActivePokemon: ; 4370 (1:4370) -	call Func_4376 +	call OpenActivePokemonScreen  	jp DuelMainInterface  ; 0x4376 -Func_4376: ; 4376 (1:4376) +; draw the turn holder's active Pokemon screen if it exists +OpenActivePokemonScreen: ; 4376 (1:4376)  	ld a, DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable  	cp -1 @@ -499,7 +502,7 @@ Func_4376: ; 4376 (1:4376)  	xor a  	ld [hli], a  	ld [hl], a -	call $576a +	call Func_576a  	ret  ; 0x438e @@ -656,12 +659,12 @@ UseEnergyCard: ; 4477 (1:4477)  	ld a, [wAlreadyPlayedEnergy]  	or a  	jr z, .play_energy_set_played -	ldtx hl, OnlyOneEnergyCardText +	ldtx hl, MayOnlyAttachOneEnergyCardText  	call DrawWideTextBox_WaitForInput  	jp Func_4436  .already_played_energy -	ldtx hl, OnlyOneEnergyCardText +	ldtx hl, MayOnlyAttachOneEnergyCardText  	call DrawWideTextBox_WaitForInput  .asm_44d2 @@ -1001,10 +1004,10 @@ _CheckIfEnoughEnergies: ; 48ac (1:48ac)  .next_energy_type_pair  	ld a, [de]  	swap a -	call _CheckIfEnoughEnergiesOfType +	call CheckIfEnoughEnergiesOfType  	jr c, .not_usable_or_not_enough_energies  	ld a, [de] -	call _CheckIfEnoughEnergiesOfType +	call CheckIfEnoughEnergiesOfType  	jr c, .not_usable_or_not_enough_energies  	inc de  	dec c @@ -1032,7 +1035,7 @@ _CheckIfEnoughEnergies: ; 48ac (1:48ac)  ; given the amount of energies of a specific type required for an attack in the  ; lower nybble of register a, test if the pokemon card has enough energies of that type  ; to use the move. Return carry if not enough energy, nc if enough energy. -_CheckIfEnoughEnergiesOfType: ; 4900 (1:4900) +CheckIfEnoughEnergiesOfType: ; 4900 (1:4900)  	and $f  	push af  	push hl @@ -1640,7 +1643,7 @@ OpenDiscardPileScreen: ; 5550 (1:5550)  	jr c, .discard_pile_empty  	call Func_559a  	call Func_556d -	ld a, $09 +	ld a, START + A_BUTTON  	ld [wcbd6], a  	call $55f0  	or a @@ -1696,7 +1699,7 @@ Func_559a: ; 559a (1:559a)  	ld [hli], a  	ld [hl], a  	ld [wcbde], a -	ld a, $08 +	ld a, START  	ld [wcbd6], a  	ld hl, wcbda  	ld [hl], $aa @@ -1729,7 +1732,185 @@ Func_559a: ; 559a (1:559a)  	ret  ; 0x55f0 -	INCROM $55f0,  $5aeb +	INCROM $55f0,  $576a + +Func_576a: ; 576a (1:576a) +	ld a, B_BUTTON +	ld [wcbd7], a +	ld a, $01 +	jr Func_5779 + +Func_5773: ; 5773 (1:5773) +	ld a, B_BUTTON +	ld [wcbd7], a +	xor a +;	fallthrough + +Func_5779: ; 5779 (1:5779) +	ld [wcbd1], a +	call $5990 +	call EmptyScreen +	call Func_3b31 +	call LoadDuelCardSymbolTiles +	ld de, v0Tiles1 + $20 tiles +	call $59ca +	call $5a0e +	call $59f5 +	call $5a34 +	ld de, $3830 +	call $5999 +	lb de, 6, 4 +	call $5a56 +	xor a +	ld [wCardPageNumber], a +.asm_57a7 +	call Func_5898 +	jr c, .asm_57cc +	call EnableLCD +.asm_57af +	call DoFrame +	ldh a, [hButtonsPressed2] +	ld b, a +	ld a, [wcbd7] +	and b +	jr nz, .asm_57cc +	ldh a, [hButtonsPressed] +	and START + A_BUTTON +	jr nz, .asm_57a7 +	ldh a, [hButtonsPressed] +	and D_RIGHT + D_LEFT +	jr z, .asm_57af +	call Func_57cd +	jr .asm_57af +.asm_57cc +	ret +; 0x57cd + +Func_57cd: ; 57cd (1:57cd) +	bit D_LEFT_F, a +	jr nz, .left +;.right +	call Func_5898 +	call c, Func_589c +	ret +.left +	call Func_5892 +	call c, Func_589c +	ret +; 0x57df + +	INCROM $57df,  $5892 + +Func_5892: ; 5892 (1:5892) +	call Func_5911 +	jr nc, Func_589c +	ret + +Func_5898: ; 5898 (1:5898) +	call Func_58e2 +	ret c +;	fallthrough + +Func_589c: ; 589c (1:589c) +	ld a, [wCardPageNumber] +	ld hl, CardPagePointerTable +	call JumpToFunctionInTable +	call EnableLCD +	or a +	ret +; 0x58aa + +Func_58aa: ; 58aa (1:58aa) +	ldh a, [hCurrentMenuItem] +	call GetCardInDuelTempList +	call LoadCardDataToBuffer1_FromCardID +	ld de, v0Tiles1 + $20 tiles +	call $59ca +	ld de, $c0c +	call $59f5 +	call $5a34 +	ret +; 0x58c2 + +CardPagePointerTable: ; 58c2 (1:58c2) +	dw DrawDuelMainScene +	dw $5b7d +	dw $5d1f +	dw $5d27 +	dw $5d2f +	dw $5d37 +	dw $5d54 +	dw DrawDuelMainScene +	dw DrawDuelMainScene +	dw $5e28 +	dw $5e28 +	dw DrawDuelMainScene +	dw DrawDuelMainScene +	dw $5e1c +	dw $5e22 +	dw DrawDuelMainScene +; 0x58e2 + +Func_58e2: ; 58e2 (1:58e2) +	ld a, [wCardPageNumber] +	or a +	jr nz, .asm_58ff +	ld a, [wLoadedCard1Type] +	ld b, a +	ld a, $09 +	bit TYPE_ENERGY_F, b +	jr nz, .set_card_page_nc +	ld a, $0d +	bit TYPE_TRAINER_F, b +	jr nz, .set_card_page_nc +	ld a, $01 +.set_card_page_nc +	ld [wCardPageNumber], a +	or a +	ret +.asm_58ff +	ld hl, wCardPageNumber +	inc [hl] +	ld a, [hl] +	call Func_5930 +	jr c, .set_card_page_c +	or a +	ret nz +	jr .asm_58ff +.set_card_page_c +	ld [wCardPageNumber], a +	ret +; 0x5911 + +Func_5911: ; 5911 (1:5911) +	ld hl, wCardPageNumber +	dec [hl] +	ld a, [hl] +	call Func_5930 +	jr c, .asm_591f +	or a +	ret nz +	jr Func_5911 +.asm_591f +	ld [wCardPageNumber], a +.asm_5922 +	call Func_5930 +	or a +	jr nz, .asm_592e +	ld hl, wCardPageNumber +	dec [hl] +	jr .asm_5922 +.asm_592e +	scf +	ret +; 0x5930 + +Func_5930: ; 5930 (1:5930) +	ld hl, $5936 +	jp JumpToFunctionInTable +; 0x5936 + +	INCROM $5936,  $5aeb  Func_5aeb: ; 5aeb (1:5aeb)  	INCROM $5aeb, $5fdd @@ -1835,7 +2016,7 @@ _OpenPlayAreaScreen: ; 600e (1:600e)  	jr z, .asm_6022  	call GetCardIDFromDeckIndex  	call LoadCardDataToBuffer1_FromCardID -	call $576a +	call Func_576a  	jr .asm_6022  .asm_6091  	ld a, [wcbd2] diff --git a/src/engine/bank2.asm b/src/engine/bank2.asm index 9f7ecef..eb5747a 100644 --- a/src/engine/bank2.asm +++ b/src/engine/bank2.asm @@ -43,7 +43,7 @@ Func_8d56: ; 8d56 (2:4d56)  	xor a  	ld [wTileMapFill], a  	call EmptyScreen -	call InitSpritePositions +	call ZeroObjectPositions  	ld a, $1  	ld [wVBlankOAMCopyToggle], a  	call LoadDuelHUDTiles diff --git a/src/engine/bank3.asm b/src/engine/bank3.asm index 343568f..5458ce9 100644 --- a/src/engine/bank3.asm +++ b/src/engine/bank3.asm @@ -11,7 +11,7 @@ LoadMap: ; c000 (3:4000)  	ld [wMatchStartTheme], a  	farcall Func_10a9b  	call Func_c1a4 -	call InitSpritePositions +	call ZeroObjectPositions  	xor a  	ld [wTileMapFill], a  	call LoadDuelHUDTiles @@ -341,7 +341,7 @@ Unknown_c27c: ; c27c (3:427c)  Func_c280: ; c280 (3:4280)  	call Func_c228  	call Func_3ca0 -	call InitSpritePositions +	call ZeroObjectPositions  	ld hl, wVBlankOAMCopyToggle  	inc [hl]  	call EnableLCD @@ -370,7 +370,7 @@ Func_c2a3: ; c2a3 (3:42a3)  	call Func_2275  	farcall Func_12ba7  	call Func_3ca0 -	call InitSpritePositions +	call ZeroObjectPositions  	ld a, $1  	ld [wVBlankOAMCopyToggle], a  	call EnableLCD diff --git a/src/engine/bank4.asm b/src/engine/bank4.asm index 4aff798..61e8751 100644 --- a/src/engine/bank4.asm +++ b/src/engine/bank4.asm @@ -18,7 +18,7 @@ Func_10000: ; 10000 (4:4000)  .asm_10025  	call Func_1288c -	call InitSpritePositions +	call ZeroObjectPositions  	ld a, $1  	ld [wVBlankOAMCopyToggle], a  	ret @@ -155,7 +155,7 @@ BoosterPack_1031b: ; 1031b (4:431b)  	call Func_2c73  	call DisableLCD  	call Func_1288c -	call InitSpritePositions +	call ZeroObjectPositions  	ld a, $1  	ld [wVBlankOAMCopyToggle], a  	ld a, $4 @@ -1081,7 +1081,7 @@ Unknown_1229f: ; 1229f (4:629f)  ; is selected, there is no need to come back to the menu.  ; the only exception is after returning from Card Pop!  _GameLoop: ; 126d1 (4:66d1) -	call InitSpritePositions +	call ZeroObjectPositions  	ld hl, wVBlankOAMCopyToggle  	inc [hl]  	farcall Func_70018 diff --git a/src/engine/home.asm b/src/engine/home.asm index ed5eaf6..0e6a6ac 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -1563,12 +1563,82 @@ Func_08ef: ; 08ef (0:08ef)  	jr .asm_93c  ; 0x950 -	INCROM $0950, $099c +; set attributes for [hl] sprites starting from wOAM + [wOAMOffset] / 4 +; return carry if reached end of wOAM before finishing +SetManyObjectsAttributes: ; 950 (0:950) +	push hl +	ld a, [wOAMOffset] +	ld c, a +	ld b, HIGH(wOAM) +	cp 40 * 4 +	jr nc, .beyond_oam +	pop hl +	ld a, [hli] ; [hl] = how many obj? +.copy_obj_loop +	push af +	ld a, [hli] +	add e +	ld [bc], a ; Y Position <- [hl + 1 + 4*i] + e +	inc bc +	ld a, [hli] +	add d +	ld [bc], a ; X Position <- [hl + 2 + 4*i] + d +	inc bc +	ld a, [hli] +	ld [bc], a ; Tile/Pattern Number <- [hl + 3 + 4*i] +	inc bc +	ld a, [hli] +	ld [bc], a ; Attributes/Flags <- [hl + 4 + 4*i] +	inc bc +	ld a, c +	cp 40 * 4 +	jr nc, .beyond_oam +	pop af +	dec a +	jr nz, .copy_obj_loop +	or a +.done +	ld hl, wOAMOffset +	ld [hl], c +	ret +.beyond_oam +	pop hl +	scf +	jr .done +; 0x97f + +; for the sprite at wOAM + [wOAMOffset] / 4, set its attributes from registers e, d, c, b +; return carry if [wOAMOffset] > 40 * 4 (beyond the end of wOAM) +SetOneObjectAttributes: ; 97f (0:97f) +	push hl +	ld a, [wOAMOffset] +	ld l, a +	ld h, HIGH(wOAM) +	cp 40 * 4 +	jr nc, .beyond_oam +	ld [hl], e ; Y Position +	inc hl +	ld [hl], d ; X Position +	inc hl +	ld [hl], c ; Tile/Pattern Number +	inc hl +	ld [hl], b ; Attributes/Flags +	inc hl +	ld a, l +	ld [wOAMOffset], a +	pop hl +	or a +	ret +.beyond_oam +	pop hl +	scf +	ret +; 0x99c  ; set the Y Position and X Position of all sprites in wOAM to $00 -InitSpritePositions: ; 099c (0:099c) +ZeroObjectPositions: ; 099c (0:099c)  	xor a -	ld [wcab5], a +	ld [wOAMOffset], a  	ld hl, wOAM  	ld c, 40  	xor a @@ -3589,7 +3659,7 @@ ResetStatusConditions: ; 1461 (0:1461)  	ld h, a  	xor a  	ld l, DUELVARS_ARENA_CARD_STATUS -	ld [hl], a +	ld [hl], a ; NO_STATUS  	ld l, DUELVARS_ARENA_CARD_SUBSTATUS1  	ld [hl], a  	ld l, DUELVARS_ARENA_CARD_SUBSTATUS2 @@ -9644,7 +9714,7 @@ Func_3b31: ; 3b31 (0:3b31)  	ld [wDoFrameFunction], a  	ld [wcad4], a  .asm_3b45 -	call InitSpritePositions +	call ZeroObjectPositions  	ld a, $1  	ld [wVBlankOAMCopyToggle], a  	pop af diff --git a/src/text/text1.asm b/src/text/text1.asm index f2285f9..df9c6b3 100644 --- a/src/text/text1.asm +++ b/src/text/text1.asm @@ -255,7 +255,7 @@ UnableToRetreatText: ; 366c5 (d:66c5)  	text "Unable to Retreat."  	done -OnlyOneEnergyCardText: ; 366d9 (d:66d9) +MayOnlyAttachOneEnergyCardText: ; 366d9 (d:66d9)  	text "You may only attach 1 Energy card"  	line "per turn."  	done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index cbf0359..a93e69e 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -63,7 +63,7 @@ TextOffsets:: ; 34000 (d:4000)  	textpointer Text003b                                ; 0x003b  	textpointer NoSelectableAttackText                  ; 0x003c  	textpointer UnableToRetreatText                     ; 0x003d -	textpointer OnlyOneEnergyCardText                   ; 0x003e +	textpointer MayOnlyAttachOneEnergyCardText                   ; 0x003e  	textpointer Text003f                                ; 0x003f  	textpointer Text0040                                ; 0x0040  	textpointer DiscardDescription                      ; 0x0041 diff --git a/src/wram.asm b/src/wram.asm index ee4c1ab..145a0ab 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -333,7 +333,7 @@ wInitialA:: ; cab3  wConsole:: ; cab4  	ds $1 -wcab5:: ; cab5 +wOAMOffset:: ; cab5  	ds $1  wTileMapFill:: ; cab6 | 
