From 259d01cee6e62003223fb86faae4b9d79a168684 Mon Sep 17 00:00:00 2001 From: andwhyisit Date: Sat, 24 Jun 2023 20:50:09 +1000 Subject: [PATCH 1/6] More paint shop code disassembled. --- game/src/shop/paint.asm | 491 ++++++++++++++++++++++++++++++++++- game/src/shop/paint_core.asm | 179 +++++++++---- 2 files changed, 623 insertions(+), 47 deletions(-) diff --git a/game/src/shop/paint.asm b/game/src/shop/paint.asm index e8506be6..48aa8dd5 100644 --- a/game/src/shop/paint.asm +++ b/game/src/shop/paint.asm @@ -1,6 +1,495 @@ INCLUDE "game/src/common/constants.asm" -SECTION "Paint Shop Helper Functions 1", ROMX[$69FE], BANK[$16] +SECTION "Paint Shop Helper Functions 1", ROMX[$6090], BANK[$16] +GetCurrentMedalAndTypeForPaintShopMedarotStatusScreen:: + xor a + ld [W_MedarotStatusSelectedOption], a + ld a, [W_MedarotSelectionScreenSelectedOption] + call GetMedarotSlotAddressForPaintShopSelectionScreen + ld hl, M_MedarotType + add hl, de + ld a, [hl] + ld [W_MedarotStatusTinpetType], a + ld hl, 2 + add hl, de + ld a, [hl] + call PaintShopGetMedalAddressForCurrentMedarot + ld a, b + ld [W_MedarotCurrentMedal], a + ret + +SECTION "Paint Shop Helper Functions 2", ROMX[$6101], BANK[$16] +PaintShopDeductMedarotEquipmentFromInventoryForStatus:: + ; This function is unused. + ld a, [W_MedarotSelectionScreenSelectedOption] + call GetMedarotSlotAddressForPaintShopSelectionScreen + ld hl, M_MedarotEquipState + add hl, de + ld [hl], M_MedarotType + ld hl, M_MedarotMedal + add hl, de + ld a, [hl] + cp $1E + jr z, .noMedal + call PaintShopGetMedalAddressForCurrentMedarot + ld hl, M_MedarotEquipState + add hl, de + ld a, [hl] + and $BF + ld [hl], a + +.noMedal + ld a, 7 + rst 8 + ld a, [W_MedarotCurrentHeadPart] + cp $97 + jr nc, .noHeadPart + ld hl, $D000 + ld a, [W_MedarotCurrentHeadPart] + call .deductPartFromInventory + +.noHeadPart + ld a, 7 + rst 8 + ld a, [W_MedarotCurrentLeftArmPart] + cp $97 + jr nc, .noLeftArmPart + ld hl, $D12E + ld a, [W_MedarotCurrentLeftArmPart] + call .deductPartFromInventory + +.noLeftArmPart + ld a, 7 + rst 8 + ld a, [W_MedarotCurrentRightArmPart] + cp $97 + jr nc, .noRightArmPart + ld hl, $D25C + ld a, [W_MedarotCurrentRightArmPart] + call .deductPartFromInventory + +.noRightArmPart + ld a, 7 + rst 8 + ld a, [W_MedarotCurrentLegPart] + cp $97 + ret nc + ld hl, $D38A + ld a, [W_MedarotCurrentLegPart] + jp .deductPartFromInventory + +.deductPartFromInventory + ld b, 0 + ld c, a + sla c + rl b + add hl, bc + inc hl + dec [hl] + ret + +MedarotPaintShopSelectionScreenEmptySlotCheck:: + ld a, [W_MedarotSelectionScreenSelectedOption] + call GetMedarotSlotAddressForPaintShopSelectionScreen + ld a, [de] + or a + jr z, PaintShopMedarotsPlayBzztSound + ld a, 3 + call ScheduleSoundEffect + ld a, 1 + ret + +PaintShopMedarotsPlayBzztSound:: + ld a, 5 + call ScheduleSoundEffect + xor a + ret + +PaintShopMedarotActionViabilityCheck:: + ld a, [W_ShopPasswordSelectionXAxis] + cp 0 + ret z + ld a, [W_MedarotCurrentPalette] + cp 0 + jr z, .medarotHasDefaultPalette + xor a + ret + +.medarotHasDefaultPalette + ld a, 5 + call ScheduleSoundEffect + ld a, 1 + ret + +PaintShopGetPaletteIndexForSelectedMedarot:: + ld a, [W_MedarotSelectionScreenSelectedOption] + call GetMedarotSlotAddressForPaintShopSelectionScreen + ld a, [de] + or a + jr z, .emptySlot + ld a, [W_MedarotCurrentPalette] + or a + jr nz, .useDefinedPalette + +.useHeadPartPalette + ld a, [W_MedarotCurrentHeadPart] + ld b, 0 + ld c, a + ld hl, $40 + add hl, bc + ld b, h + ld c, l + ret + +.useDefinedPalette + dec a + ld b, 0 + ld c, a + ld hl, $370 + add hl, bc + ld b, h + ld c, l + ret + +.emptySlot + ld bc, $40 + ret + +AnimatedSelectedMedarotSpriteForPaintShopSelectionScreen:: + ld a, [W_MedarotSelectionScreenSelectedOption] + call PaintShopGetSelectedMedarotMetaspriteAddress + jp $33B7 + +PaintShopDrawCurrentMedarot:: + push bc + ld a, [W_MedarotSelectionScreenSelectedOption] + call GetMedarotSlotAddressForPaintShopSelectionScreen + ld a, [de] + or a + jr nz, .slotNotEmpty + pop bc + ld e, 7 + ld a, 0 + jp WrapDecompressTilemap0 + +.slotNotEmpty + ld hl, M_MedarotHead + add hl, de + ld a, [hli] + ld [W_MedarotCurrentHeadPart], a + ld a, [hli] + ld [W_MedarotCurrentLeftArmPart], a + ld a, [hli] + ld [W_MedarotCurrentRightArmPart], a + ld a, [hli] + ld [W_MedarotCurrentLegPart], a + ld hl, M_MedarotPalette + add hl, de + ld a, [hl] + ld [W_MedarotCurrentPalette], a + call $34F5 + ld de, $8800 + call $34FA + pop bc + ld e, 3 + ld a, 0 + jp WrapDecompressTilemap0 + +GetMedarotSlotAddressForPaintShopSelectionScreen:: + ld c, a + ld a, 5 + rst 8 + ld hl, $D000 + ld b, 0 + ld a, 4 + jp MultiplyBCByTwoToThePowerOfAAndAddToHL + +MapCurrentMedarotNameForPaintShopSelectionScreen:: + ld a, [W_MedarotSelectionScreenSelectedOption] + push bc + call GetMedarotSlotAddressForPaintShopSelectionScreen + pop bc + ld a, [de] + cp 2 + jr nc, .hasName + call OffsetToMappingAddressForPaintShopMedarotScreens + ld b, 8 + jp PaintShopMedarotsMapDashes + +.hasName + call OffsetToMappingAddressForPaintShopMedarotScreens + push hl + ld b, 8 + ld c, 1 + push de + call $25E5 + pop de + ld hl, M_MedarotMedal + add hl, de + ld a, [hl] + call PaintShopGetMedalAddressForCurrentMedarot + ld hl, M_MedalNickname + add hl, de + ld b, h + ld c, l + ld a, 8 + call GetTileBasedCentringOffset + pop hl + ld b, 0 + ld c, a + add hl, bc + push hl + ld hl, M_MedalNickname + add hl, de + ld b, h + ld c, l + pop hl + jp PutStringVariableLength + +PaintShopGetMedalAddressForCurrentMedarot:: + ld c, a + ld b, 0 + ld de, $D120 + +.loop + ld a, [de] + and $80 + jr z, .nextMedalSlot + ld hl, M_MedalType + add hl, de + ld a, [hl] + cp c + ret z + +.nextMedalSlot + ld hl, M_MedalSlotLength + add hl, de + ld d, h + ld e, l + inc b + ld a, b + cp $1E + jr nz, .loop + ret + +PaintShopMedarotsMapDashes:: + push de + push hl + +.loop + ld a, $EE + di + push af + rst $20 + pop af + ld [hli], a + ei + dec b + jr nz, .loop + pop hl + pop de + ret + +OffsetToMappingAddressForPaintShopMedarotScreens:: + ld h, 0 + ld l, c + sla l + rl h + sla l + rl h + sla l + rl h + sla l + rl h + sla l + rl h + ld c, b + ld b, 0 + add hl, bc + ld bc, $9800 + add hl, bc + ret + +SECTION "Paint Shop Helper Functions 3", ROMX[$64F6], BANK[$16] +PaintShopDisplayMedarotSelectorArrow:: + call PaintShopPlaceMedarotSelectorArrow + ld a, $36 + ld b, 0 + ld de, $C0C0 + jp $33B2 + +PaintShopPlaceMedarotSelectorArrow:: + ld a, 1 + ld [W_OAM_SpritesReady], a + ld a, 1 + ld [$C0C0], a + ld a, 0 + ld [$C0C1], a + ld a, 7 + ld [$C0C5], a + ld hl, .table + ld a, [W_MedarotSelectionScreenSelectedOption] + ld b, 0 + ld c, a + sla c + rl b + add hl, bc + ld a, [hli] + ld [$C0C3], a + ld a, [hl] + ld [$C0C4], a + ret + +.table + db $0E, $1A + db $0D, $30 + db $0C, $46 + db $24, $1A + db $24, $30 + db $24, $46 + db $3A, $1A + db $3B, $30 + db $3C, $46 + +MedarotPaintShopSelectionScreenDirectionalInputHandler:: + ld a, [W_JPInput_TypematicBtns] + and M_JPInputRight | M_JPInputLeft | M_JPInputUp | M_JPInputDown + jr nz, .directionalButtonPressed + call .noDirectionalInput + ret + +.directionalButtonPressed + ld a, [W_JPInput_TypematicBtns] + and M_JPInputUp + jr z, .upNotPressed + ld a, [W_MedarotSelectionScreenSelectedOption] + call PaintShopGetSelectedMedarotMetaspriteAddress + call PaintShopCancelMedarotSpriteAnimation + ld a, [W_MedarotSelectionScreenSelectedOption] + ld hl, .upPressTable + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + ld [W_MedarotSelectionScreenSelectedOption], a + ld a, 2 + call ScheduleSoundEffect + ld a, 8 + ld [W_MedarotSelectionDirectionalInputWaitTimer], a + ret + +.upNotPressed + ld a, [W_JPInput_TypematicBtns] + and M_JPInputDown + jr z, .downNotPressed + ld a, [W_MedarotSelectionScreenSelectedOption] + call PaintShopGetSelectedMedarotMetaspriteAddress + call PaintShopCancelMedarotSpriteAnimation + ld a, [W_MedarotSelectionScreenSelectedOption] + ld hl, .downPressTable + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + ld [W_MedarotSelectionScreenSelectedOption], a + ld a, 2 + call ScheduleSoundEffect + ld a, 8 + ld [W_MedarotSelectionDirectionalInputWaitTimer], a + ret + +.downNotPressed + ld a, [W_JPInput_TypematicBtns] + and M_JPInputLeft + jr z, .leftNotPressed + ld a, [W_MedarotSelectionScreenSelectedOption] + call PaintShopGetSelectedMedarotMetaspriteAddress + call PaintShopCancelMedarotSpriteAnimation + ld a, [W_MedarotSelectionScreenSelectedOption] + ld hl, .leftPressTable + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + ld [W_MedarotSelectionScreenSelectedOption], a + ld a, 2 + call ScheduleSoundEffect + ld a, 8 + ld [W_MedarotSelectionDirectionalInputWaitTimer], a + ret + +.leftNotPressed + ld a, [W_JPInput_TypematicBtns] + and M_JPInputRight + ret z + ld a, [W_MedarotSelectionScreenSelectedOption] + call PaintShopGetSelectedMedarotMetaspriteAddress + call PaintShopCancelMedarotSpriteAnimation + ld a, [W_MedarotSelectionScreenSelectedOption] + ld hl, .rightPressTable + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + ld [W_MedarotSelectionScreenSelectedOption], a + ld a, 2 + call ScheduleSoundEffect + ld a, 8 + ld [W_MedarotSelectionDirectionalInputWaitTimer], a + ret + +.upPressTable + db 2,0,1,5,3,4,8,6,7 + +.downPressTable + db 1,2,0,4,5,3,7,8,6 + +.leftPressTable + db 6,7,8,0,1,2,3,4,5 + +.rightPressTable + db 3,4,5,6,7,8,0,1,2 + +.noDirectionalInput + ld a, [W_MedarotSelectionDirectionalInputWaitTimer] + cp $80 + ret z + ld a, [W_MedarotSelectionDirectionalInputWaitTimer] + dec a + ld [W_MedarotSelectionDirectionalInputWaitTimer], a + ret nz + ld bc, $A01 + call PaintShopDrawCurrentMedarot + ld bc, $B0B + call MapCurrentMedarotNameForPaintShopSelectionScreen + call PaintShopUpdateSelectedMedarotPalette + ld a, $80 + ld [W_MedarotSelectionDirectionalInputWaitTimer], a + ret + +PaintShopUpdateSelectedMedarotPalette:: + call PaintShopGetPaletteIndexForSelectedMedarot + ld a, 3 + call CGBLoadSingleBGPPaletteIndex + ld a, 1 + ld [W_CGBPaletteStagedBGP], a + ret + +PaintShopCancelMedarotSpriteAnimation:: + ld hl, 9 + add hl, de + ld a, [hl] + ld b, 0 + jp $33B2 + +PaintShopGetSelectedMedarotMetaspriteAddress:: + ld hl, $C1E0 + ld b, 0 + ld c, a + ld a, 5 + jp MultiplyBCByTwoToThePowerOfAAndAddToHL + +SECTION "Paint Shop Helper Functions 4", ROMX[$69FE], BANK[$16] PaintShopMapMoney:: push hl push bc diff --git a/game/src/shop/paint_core.asm b/game/src/shop/paint_core.asm index 70676e4f..84deca45 100644 --- a/game/src/shop/paint_core.asm +++ b/game/src/shop/paint_core.asm @@ -8,52 +8,52 @@ PaintShopStateMachine:: jp hl .table - dw PaintShopDrawingState - dw PaintShopMappingState - dw PaintShopDisplayMoneyAndSpritesState - dw $69C6 - dw $69AD - dw PaintShopPrintOpeningMessageState - dw PaintShopInputHandlerState - dw PaintShopDoNothingState - dw $69D8 - dw $69AD - dw PaintShopMedarotSelectionForPaintingDrawingState - dw $6029 - dw $605C - dw $69AD - dw $6884 - dw $60AF - dw PaintShopDoNothingState - dw PaintShopDoNothingState - dw PaintShopDoNothingState - dw $69AD - dw PaintShopDoNothingState - dw $69D8 - dw $69AD - dw $62BE - dw $6076 - dw $69AD - dw $68AB - dw $63B2 - dw $69B8 - dw PaintShopDoNothingState - dw $64A7 - dw $64E8 - dw $69D8 - dw $69AD - dw $69EA - dw $69D8 - dw $69AD - dw $676A - dw $69C6 - dw $69AD - dw $6855 - dw $6868 - dw $68D5 - dw $68FC - dw $696D - dw $6989 + dw PaintShopDrawingState ; 00 + dw PaintShopMappingState ; 01 + dw PaintShopDisplayMoneyAndSpritesState ; 02 + dw $69C6 ; 03 + dw $69AD ; 04 + dw PaintShopPrintOpeningMessageState ; 05 + dw PaintShopInputHandlerState ; 06 + dw PaintShopDoNothingState ; 07 + dw $69D8 ; 08 + dw $69AD ; 09 + dw PaintShopMedarotSelectionForPaintingDrawingState ; 0A + dw PaintShopMedarotsSelectionScreenMappingState ; 0B + dw PaintShopMedarotsSelectionScreenPrepareFadeInState ; 0C + dw $69AD ; 0D + dw $6884 ; 0E + dw PaintShopMedarotsSelectionScreenInputHandlerState ; 0F + dw PaintShopDoNothingState ; 10 + dw PaintShopDoNothingState ; 11 + dw PaintShopDoNothingState ; 12 + dw $69AD ; 13 + dw PaintShopDoNothingState ; 14 + dw $69D8 ; 15 + dw $69AD ; 16 + dw $62BE ; 17 + dw PaintShopPaintSelectorPrepareFadeInState ; 18 + dw $69AD ; 19 + dw $68AB ; 1A + dw $63B2 ; 1B + dw $69B8 ; 1C + dw PaintShopDoNothingState ; 1D + dw $64A7 ; 1E + dw $64E8 ; 1F + dw $69D8 ; 20 + dw $69AD ; 21 + dw $69EA ; 22 + dw $69D8 ; 23 + dw $69AD ; 24 + dw $676A ; 25 + dw $69C6 ; 26 + dw $69AD ; 27 + dw $6855 ; 28 + dw $6868 ; 29 + dw $68D5 ; 2A + dw $68FC ; 2B + dw $696D ; 2C + dw $6989 ; 2D PaintShopIncSubStateIndex:: ld a, [W_CoreSubStateIndex] @@ -288,3 +288,90 @@ PaintShopMedarotSelectionForPaintingDrawingState:: call $33C6 call WrapInitiateMainScript jp IncSubStateIndex + +PaintShopMedarotsSelectionScreenMappingState:: + ld a, 0 + ld [$C0E0], a + ld bc, 0 + ld e, $44 + ld a, 0 + call WrapDecompressTilemap0 + ld bc, 0 + ld e, $44 + ld a, 0 + call WrapDecompressAttribmap0 + call $6658 + ld bc, $A01 + call PaintShopDrawCurrentMedarot + ld bc, $B0B + call MapCurrentMedarotNameForPaintShopSelectionScreen + call PaintShopDisplayMedarotSelectorArrow + ld a, $80 + ld [W_MedarotSelectionDirectionalInputWaitTimer], a + jp IncSubStateIndex + +PaintShopMedarotsSelectionScreenPrepareFadeInState:: + ld hl, $29 + ld bc, $16 + ld d, $FF + ld e, $FF + ld a, $E + call WrapSetupPalswapAnimation + call PaintShopGetPaletteIndexForSelectedMedarot + ld a, 3 + call WrapRestageDestinationBGPalettesForFade + jp IncSubStateIndex + +PaintShopPaintSelectorPrepareFadeInState:: + ld hl, $35 + ld bc, $25 + ld d, $FF + ld e, $FF + ld a, $E + call WrapSetupPalswapAnimation + call PaintShopGetPaletteIndexForSelectedMedarot + ld a, 3 + call WrapRestageDestinationBGPalettesForFade + jp IncSubStateIndex + +SECTION "Paint Shop State Machine 2", ROMX[$60AF], BANK[$16] +PaintShopMedarotsSelectionScreenInputHandlerState:: + ld de, $C0C0 + call $33B7 + call PaintShopPlaceMedarotSelectorArrow + call MedarotPaintShopSelectionScreenDirectionalInputHandler + call AnimatedSelectedMedarotSpriteForPaintShopSelectionScreen + ld a, [W_MedarotSelectionDirectionalInputWaitTimer] + cp $80 + ret nz + ldh a, [H_JPInputChanged] + and M_JPInputA + jr z, .aNotPressed + call MedarotPaintShopSelectionScreenEmptySlotCheck + or a + ret z + call PaintShopMedarotActionViabilityCheck + cp 1 + ret z + ld a, $CD + ld [$C0E2], a + ld a, 5 + ld [$C0E5], a + ld a, 1 + ld [W_OAM_SpritesReady], a + call GetCurrentMedalAndTypeForPaintShopMedarotStatusScreen + ld a, $15 + ld [W_CoreSubStateIndex], a + ret + +.aNotPressed + ldh a, [H_JPInputChanged] + and M_JPInputB + ret z + ld a, 4 + call ScheduleSoundEffect + xor a + ld [W_MedarotSelectionScreenSelectedOption], a + ld a, $23 + ld [W_CoreSubStateIndex], a + ret From e8a84403d8ae8e15aa52da71b0b61c0ff67ac57f Mon Sep 17 00:00:00 2001 From: andwhyisit Date: Sun, 25 Jun 2023 20:53:35 +1000 Subject: [PATCH 2/6] The paint shop is now fully disassembled. --- game/src/shop/paint.asm | 204 ++++++++++- game/src/shop/paint_core.asm | 657 +++++++++++++++++++++++++++++++++-- 2 files changed, 827 insertions(+), 34 deletions(-) diff --git a/game/src/shop/paint.asm b/game/src/shop/paint.asm index 48aa8dd5..b1c5f169 100644 --- a/game/src/shop/paint.asm +++ b/game/src/shop/paint.asm @@ -310,7 +310,16 @@ OffsetToMappingAddressForPaintShopMedarotScreens:: add hl, bc ret -SECTION "Paint Shop Helper Functions 3", ROMX[$64F6], BANK[$16] +SECTION "Paint Shop Helper Functions 3", ROMX[$649A], BANK[$16] +PrintCurrentPaintNumber:: + ld a, [W_ShopPasswordSelectionYAxis] + inc a + ld hl, $9966 + ld b, 0 + call $3504 + ret + +SECTION "Paint Shop Helper Functions 4", ROMX[$64F6], BANK[$16] PaintShopDisplayMedarotSelectorArrow:: call PaintShopPlaceMedarotSelectorArrow ld a, $36 @@ -489,7 +498,198 @@ PaintShopGetSelectedMedarotMetaspriteAddress:: ld a, 5 jp MultiplyBCByTwoToThePowerOfAAndAddToHL -SECTION "Paint Shop Helper Functions 4", ROMX[$69FE], BANK[$16] +PaintShopMedarotsSelectionScreenDisplayMedarotSprites:: + ld a, 1 + ld [W_OAM_SpritesReady], a + ld a, 5 + rst 8 + ld de, $D000 + xor a + ld [$C4F4], a + +.loop + ld a, [de] + or a + jr nz, .slotNotEmpty + call $66A0 ; .displayEmptySlot + jr .nextMedarotSlot + +.slotNotEmpty + cp 3 + jr z, .slotMedarotFullyEquipped + call $66E0 ; .displayUnequippedTinpetSlot + jr .nextMedarotSlot + +.slotMedarotFullyEquipped + call $6721 ; .displayEquippedMedarotSlot + +.nextMedarotSlot + ld hl, M_MedarotSlotLength + add hl, de + ld d, h + ld e, l + ld a, [$C4F4] + inc a + ld [$C4F4], a + cp 9 + jr nz, .loop + ret + +.spritePositionTable + db $0A, $24 + db $09, $3A + db $08, $50 + db $20, $24 + db $20, $3A + db $20, $50 + db $36, $24 + db $37, $3A + db $38, $50 + +.displayEmptySlot + push de + ld de, $C1E0 + ld b, 9 + call $3423 + ld a, $11 + ld [de], a + ld hl, 1 + add hl, de + ld [hl], $44 + call .getMedarotSpritePosition + ld hl, 3 + add hl, de + ld a, b + ld [hli], a + ld a, c + ld [hl], a + ld a, 0 + ld b, 0 + call $33B2 + ld hl, 5 + add hl, de + ld a, 4 + ld [hl], a + pop de + ret + +.getMedarotSpritePosition + ld a, [$C4F4] + ld hl, .spritePositionTable + ld b, 0 + ld c, a + sla c + rl b + add hl, bc + ld a, [hli] + ld b, a + ld a, [hl] + ld c, a + ret + +.displayUnequippedTinpetSlot + ld hl, 1 + add hl, de + ld a, [hl] + ld [$C4EE], a + push de + ld de, $C1E0 + ld b, 9 + call $3423 + ld a, $11 + ld [de], a + ld hl, 1 + add hl, de + ld [hl], $44 + call .getMedarotSpritePosition + ld hl, 3 + add hl, de + ld a, b + ld [hli], a + ld a, c + ld [hl], a + ld hl, 5 + add hl, de + ld a, 1 + ld [hl], a + ld a, [$C4EE] + or a + jr z, .useBluePalette + ld a, 5 + ld [hl], a + +.useBluePalette + ld a, [$C4EE] + add 1 + ld b, 0 + call $33B2 + pop de + ret + +.displayEquippedMedarotSlot + ld hl, 6 + add hl, de + ld a, [hl] + push de + ld [W_ListItemIndexForBuffering], a + ld a, 3 + call $34FF + ld de, $C1E0 + ld b, 9 + call $3423 + ld a, $11 + ld [de], a + ld hl, 1 + add hl, de + ld [hl], $44 + call .getMedarotSpritePosition + ld hl, 3 + add hl, de + ld a, b + ld [hli], a + ld a, c + ld [hl], a + ld a, [$C553] + sub $50 + sla a + add 3 + ld b, 0 + call $33B2 + ld a, [$C553] + sub $50 + add $2D + call $34B7 + ld hl, 5 + add hl, de + ld [hl], a + pop de + ret + +SECTION "Paint Shop Helper Functions 5", ROMX[$6838], BANK[$16] +PaintShopPlayerHasPaintedMedarots:: + ld a, 5 + rst 8 + ld hl, $D000 + ld de, M_MedarotPalette + add hl, de + ld d, 0 + ld b, 9 + +.mathLoop + push bc + ld a, [hl] + add d + ld d, a + ld bc, $10 + add hl, bc + pop bc + dec b + jp nz, .mathLoop + + ld a, d + ret + +SECTION "Paint Shop Helper Functions 6", ROMX[$69FE], BANK[$16] PaintShopMapMoney:: push hl push bc diff --git a/game/src/shop/paint_core.asm b/game/src/shop/paint_core.asm index 84deca45..032126dd 100644 --- a/game/src/shop/paint_core.asm +++ b/game/src/shop/paint_core.asm @@ -11,49 +11,49 @@ PaintShopStateMachine:: dw PaintShopDrawingState ; 00 dw PaintShopMappingState ; 01 dw PaintShopDisplayMoneyAndSpritesState ; 02 - dw $69C6 ; 03 - dw $69AD ; 04 + dw PaintShopPrepareFadeInState ; 03 + dw PaintShopDoFadeState ; 04 dw PaintShopPrintOpeningMessageState ; 05 dw PaintShopInputHandlerState ; 06 dw PaintShopDoNothingState ; 07 - dw $69D8 ; 08 - dw $69AD ; 09 + dw PaintShopPrepareFadeOutState ; 08 + dw PaintShopDoFadeState ; 09 dw PaintShopMedarotSelectionForPaintingDrawingState ; 0A dw PaintShopMedarotsSelectionScreenMappingState ; 0B dw PaintShopMedarotsSelectionScreenPrepareFadeInState ; 0C - dw $69AD ; 0D - dw $6884 ; 0E + dw PaintShopDoFadeState ; 0D + dw PaintShopMedarotSelectionWelcomeMessageState ; 0E dw PaintShopMedarotsSelectionScreenInputHandlerState ; 0F dw PaintShopDoNothingState ; 10 dw PaintShopDoNothingState ; 11 dw PaintShopDoNothingState ; 12 - dw $69AD ; 13 + dw PaintShopDoFadeState ; 13 dw PaintShopDoNothingState ; 14 - dw $69D8 ; 15 - dw $69AD ; 16 - dw $62BE ; 17 + dw PaintShopPrepareFadeOutState ; 15 + dw PaintShopDoFadeState ; 16 + dw PaintShopPaintingScreenInitState ; 17 dw PaintShopPaintSelectorPrepareFadeInState ; 18 - dw $69AD ; 19 - dw $68AB ; 1A - dw $63B2 ; 1B - dw $69B8 ; 1C + dw PaintShopDoFadeState ; 19 + dw PaintShopPaintSelectorWelcomeMessageState ; 1A + dw PaintShopPaintSelectionInputHandlerState ; 1B + dw PaintShopPaintingSwitchVisiblePaletteState ; 1C dw PaintShopDoNothingState ; 1D - dw $64A7 ; 1E - dw $64E8 ; 1F - dw $69D8 ; 20 - dw $69AD ; 21 - dw $69EA ; 22 - dw $69D8 ; 23 - dw $69AD ; 24 - dw $676A ; 25 - dw $69C6 ; 26 - dw $69AD ; 27 - dw $6855 ; 28 - dw $6868 ; 29 - dw $68D5 ; 2A - dw $68FC ; 2B - dw $696D ; 2C - dw $6989 ; 2D + dw PaintShopPaintRemovalState ; 1E + dw PaintShopPaintRemovalUnusedState ; 1F + dw PaintShopPrepareFadeOutState ; 20 + dw PaintShopDoFadeState ; 21 + dw PaintShopExitState ; 22 + dw PaintShopPrepareFadeOutState ; 23 + dw PaintShopDoFadeState ; 24 + dw PaintShopRestoreMainMenuState ; 25 + dw PaintShopPrepareFadeInState ; 26 + dw PaintShopDoFadeState ; 27 + dw PaintShopShowMessageAfterExitToMainMenuState ; 28 + dw PaintShopTutorialState ; 29 + dw PaintShopPrintMessageAndExitPaintingScreenState ; 2A + dw PaintShopPaintingYNState ; 2B + dw PaintShopNotEnoughMoneyMessageState ; 2C + dw PaintShopNoPaintedMedarotsMessageState ; 2D PaintShopIncSubStateIndex:: ld a, [W_CoreSubStateIndex] @@ -235,7 +235,7 @@ PaintShopInputHandlerState:: ret .restoreColourSelected - call $6838 + call PaintShopPlayerHasPaintedMedarots cp 0 jr z, .nothingToRestore ld a, 1 @@ -300,7 +300,7 @@ PaintShopMedarotsSelectionScreenMappingState:: ld e, $44 ld a, 0 call WrapDecompressAttribmap0 - call $6658 + call PaintShopMedarotsSelectionScreenDisplayMedarotSprites ld bc, $A01 call PaintShopDrawCurrentMedarot ld bc, $B0B @@ -375,3 +375,596 @@ PaintShopMedarotsSelectionScreenInputHandlerState:: ld a, $23 ld [W_CoreSubStateIndex], a ret + +SECTION "Paint Shop State Machine 3", ROMX[$62BE], BANK[$16] +PaintShopPaintingScreenInitState:: + ld bc, 2 + call $33C6 + ld bc, $3A + call WrapLoadMaliasGraphics + ld bc, $3B + call WrapLoadMaliasGraphics + ld bc, $3C + call WrapLoadMaliasGraphics + ld bc, $11 + call WrapLoadMaliasGraphics + ld bc, $13 + call WrapLoadMaliasGraphics + ld bc, 0 + ld e, $8A + ld a, 1 + call WrapDecompressAttribmap0 + ld bc, $C06 + ld e, $9B + ld a, 1 + call WrapDecompressAttribmap0 + ld bc, 0 + ld e, $8C + ld a, 1 + call WrapDecompressTilemap0 + ld bc, $101 + ld e, 3 + ld a, 0 + call WrapDecompressTilemap0 + ld a, 1 + ld [$C100], a + ld a, $22 + ld [$C101], a + ld a, $A3 + ld [$C102], a + ld a, 0 + ld [$C105], a + ld a, $60 + ld [$C103], a + ld a, $18 + ld [$C104], a + ld a, 1 + ld [$C120], a + ld a, $22 + ld [$C121], a + ld a, 0 + ld [$C125], a + ld a, $A5 + ld [$C122], a + ld a, 8 + ld [$C123], a + ld a, $59 + ld [$C124], a + ld a, 1 + ld [W_OAM_SpritesReady], a + ld a, 0 + ld [$C0A0], a + ld [$C0C0], a + ld [$C1E0], a + ld [$C200], a + ld [$C220], a + ld [$C240], a + ld [$C260], a + ld [$C280], a + ld [$C2A0], a + ld [$C2C0], a + ld [$C2E0], a + ld a, 1 + ld [W_OAM_SpritesReady], a + ld a, 0 + ld b, a + ld a, $9E + ld de, $C100 + call $33B2 + ld a, 0 + ld b, a + ld a, $9F + ld de, $C120 + call $33B2 + ld bc, $D01 + ld hl, W_PlayerMoolah + call PaintShopMapMoney + call WrapInitiateMainScript + ld a, 5 + rst 8 + call PaintShopGetPaletteIndexForSelectedMedarot + ld hl, 7 + add hl, de + ld a, [hl] + dec a + ld [W_ShopPasswordSelectionYAxis], a + ld a, h + ld [$C7C4], a + ld a, l + ld [$C7C5], a + call PrintCurrentPaintNumber + jp IncSubStateIndex + +PaintShopPaintSelectionInputHandlerState:: + ld de, $C100 + call $33B7 + ld de, $C120 + call $33B7 + ld a, [W_JPInput_TypematicBtns] + and M_JPInputRight + jr z, .rightNotPressed + ld a, 2 + call ScheduleSoundEffect + ld a, [W_ShopPasswordSelectionYAxis] + cp $F + jr z, .loopToStart + inc a + ld [W_ShopPasswordSelectionYAxis], a + call PrintCurrentPaintNumber + jp .updateMedarotPalette + +.loopToStart + ld a, [W_MedarotCurrentPalette] + cp 0 + jr nz, .isPaintedDuringRightButtonPress + ld a, $FF + ld [W_ShopPasswordSelectionYAxis], a + call PrintCurrentPaintNumber + jp .updateMedarotPalette + +.isPaintedDuringRightButtonPress + ld a, 0 + ld [W_ShopPasswordSelectionYAxis], a + call PrintCurrentPaintNumber + jp .updateMedarotPalette + +.rightNotPressed + ld a, [W_JPInput_TypematicBtns] + and M_JPInputLeft + jr z, .leftNotPressed + ld a, 2 + call ScheduleSoundEffect + ld a, [W_MedarotCurrentPalette] + cp 0 + jr nz, .isPaintedDuringLeftButtonPress + ld a, [W_ShopPasswordSelectionYAxis] + cp $FF + jr z, .loopToEnd + dec a + ld [W_ShopPasswordSelectionYAxis], a + call PrintCurrentPaintNumber + jp .updateMedarotPalette + +.isPaintedDuringLeftButtonPress + ld a, [W_ShopPasswordSelectionYAxis] + cp 0 + jr z, .loopToEnd + dec a + ld [W_ShopPasswordSelectionYAxis], a + call PrintCurrentPaintNumber + jp .updateMedarotPalette + +.loopToEnd + ld a, $F + ld [W_ShopPasswordSelectionYAxis], a + call PrintCurrentPaintNumber + jp .updateMedarotPalette + +.leftNotPressed + ldh a, [H_JPInputChanged] + and M_JPInputSelect + jr z, .selectNotPressed + ret + +.selectNotPressed + ldh a, [H_JPInputChanged] + and M_JPInputA + jr z, .aNotPressed + ld a, [W_MedarotCurrentPalette] + ld b, a + ld a, [W_ShopPasswordSelectionYAxis] + inc a + cp b + jr z, .paletteUnchanged + ld a, 3 + call ScheduleSoundEffect + call WrapInitiateMainScript + ld a, $2B + ld [W_CoreSubStateIndex], a + ret + +.paletteUnchanged + ld a, 5 + call ScheduleSoundEffect + ret + +.aNotPressed + ldh a, [H_JPInputChanged] + and M_JPInputB + ret z + ld a, 4 + call ScheduleSoundEffect + ld a, 7 + ld [W_CoreSubStateIndex], a + ret + +.updateMedarotPalette + ld a, [W_ShopPasswordSelectionYAxis] + cp $FF + jr z, .showDefaultPalette + ld bc, $370 + ld a, [W_ShopPasswordSelectionYAxis] + ld l, a + ld h, 0 + add hl, bc + ld b, h + ld c, l + ld a, 3 + call CGBLoadSingleBGPPaletteIndex + ld a, 1 + ld [W_CGBPaletteStagedBGP], a + jp IncSubStateIndex + +.showDefaultPalette + call PaintShopUpdateSelectedMedarotPalette + jp IncSubStateIndex + +SECTION "Paint Shop State Machine 4", ROMX[$64A7], BANK[$16] +PaintShopPaintRemovalState:: + ld de, $C100 + call $33B7 + ld a, 1 + call $35DA + ld a, [$C771] + or a + ret z + cp 1 + jp z, .yesSelected + ld a, 7 + ld [W_CoreSubStateIndex], a + ret + +.yesSelected + ld a, 5 + rst 8 + ld a, [W_MedarotSelectionScreenSelectedOption] + ld bc, $10 + ld hl, $D000 + M_MedarotPalette + +.mathLoop + cp 0 + jr z, .exitMathLoop + dec a + add hl, bc + jr .mathLoop + +.exitMathLoop + xor a + ld [hl], a + call WrapInitiateMainScript + xor a + ld [W_MedarotCurrentPalette], a + call PaintShopUpdateSelectedMedarotPalette + ld a, $2A + ld [W_CoreSubStateIndex], a + ret + +PaintShopPaintRemovalUnusedState:: + call $34E6 + ld a, [W_PaletteAnimRunning] + or a + ret nz + ld a, $2A + ld [W_CoreSubStateIndex], a + ret + +SECTION "Paint Shop State Machine 5", ROMX[$676A], BANK[$16] +PaintShopRestoreMainMenuState:: + ld bc, 2 + call $33C6 + ld bc, $3A + call WrapLoadMaliasGraphics + ld bc, $3B + call WrapLoadMaliasGraphics + ld bc, $3C + call WrapLoadMaliasGraphics + ld bc, $11 + call WrapLoadMaliasGraphics + ld bc, $13 + call WrapLoadMaliasGraphics + ld bc, 0 + ld e, $89 + ld a, 1 + call WrapDecompressAttribmap0 + ld bc, $C06 + ld e, $9B + ld a, 1 + call WrapDecompressAttribmap0 + ld bc, 0 + ld e, $8B + ld a, 1 + call WrapDecompressTilemap0 + ld a, 1 + ld [$C0E0], a + ld a, 0 + ld [$C0E1], a + ld a, $B4 + ld [$C0E2], a + ld a, 7 + ld [$C0E5], a + ld a, 7 + ld [$C0E3], a + ld a, 1 + ld [$C100], a + ld a, $22 + ld [$C101], a + ld a, $A3 + ld [$C102], a + ld a, 0 + ld [$C105], a + ld a, $60 + ld [$C103], a + ld a, $18 + ld [$C104], a + ld a, 0 + ld b, a + ld a, $36 + ld de, $C0E0 + call $33B2 + ld a, 0 + ld b, a + ld a, $9E + ld de, $C100 + call $33B2 + ld a, 1 + ld [W_OAM_SpritesReady], a + call PaintShopUpdateMainMenuCursorPosition + ld a, 0 + ld [$C0A0], a + ld [$C0C0], a + ld [$C1E0], a + ld [$C200], a + ld [$C220], a + ld [$C240], a + ld [$C260], a + ld [$C280], a + ld [$C2A0], a + ld [$C2C0], a + ld [$C2E0], a + ld a, 1 + ld [W_OAM_SpritesReady], a + ld bc, $D01 + ld hl, W_PlayerMoolah + call PaintShopMapMoney + call WrapInitiateMainScript + jp IncSubStateIndex + +SECTION "Paint Shop State Machine 6", ROMX[$6855], BANK[$16] +PaintShopShowMessageAfterExitToMainMenuState:: + ld bc, $A1 + ld a, 2 + call WrapMainScriptProcessor + ld a, [W_MainScriptExitMode] + or a + ret z + ld a, 6 + ld [W_CoreSubStateIndex], a + ret + +PaintShopTutorialState:: + ld de, $C100 + call $33B7 + ld bc, $AC + ld a, 2 + call WrapMainScriptProcessor + ld a, [W_MainScriptExitMode] + or a + ret z + call WrapInitiateMainScript + ld a, $28 + ld [W_CoreSubStateIndex], a + ret + +PaintShopMedarotSelectionWelcomeMessageState:: + ld a, [W_ShopPasswordSelectionXAxis] + cp 1 + jr z, .removingPaint + ld bc, $A4 + ld a, 2 + call WrapMainScriptProcessor + ld a, [W_MainScriptExitMode] + or a + ret z + jp IncSubStateIndex + +.removingPaint + ld bc, $AA + ld a, 2 + call WrapMainScriptProcessor + ld a, [W_MainScriptExitMode] + or a + ret z + jp IncSubStateIndex + +PaintShopPaintSelectorWelcomeMessageState:: + ld a, [W_ShopPasswordSelectionXAxis] + cp 1 + jr z, .removingPaint + ld bc, $A6 + ld a, 2 + call WrapMainScriptProcessor + ld a, [W_MainScriptExitMode] + or a + ret z + jp IncSubStateIndex + +.removingPaint + ld bc, $AB + ld a, 2 + call WrapMainScriptProcessor + ld a, [W_MainScriptExitMode] + or a + ret z + ld a, $1E + ld [W_CoreSubStateIndex], a + ret + +PaintShopPrintMessageAndExitPaintingScreenState:: + ld de, $C100 + call $33B7 + ld bc, $A9 + ld a, 2 + call WrapMainScriptProcessor + ld a, [W_MainScriptExitMode] + or a + ret z + ld a, 0 + ld [$C120], a + ld a, 1 + ld [W_OAM_SpritesReady], a + xor a + ld [W_MedarotSelectionScreenSelectedOption], a + ld a, $23 + ld [W_CoreSubStateIndex], a + ret + +PaintShopPaintingYNState:: + ld de, $C100 + call $33B7 + ld bc, $A8 + ld a, 2 + call WrapMainScriptProcessor + ld a, [W_MainScriptExitMode] + or a + ret z + ld a, 1 + call $35DA + ld a, [$C771] + or a + ret z + cp 1 + jp z, .yesSelected + call WrapInitiateMainScript + ld a, $1A + ld [W_CoreSubStateIndex], a + ret + +.yesSelected + +; Apply palette. + + ld a, 5 + rst 8 + ld a, [$C7C4] + ld h, a + ld a, [$C7C5] + ld l, a + ld a, [W_ShopPasswordSelectionYAxis] + inc a + ld [hl], a + +; Deduct cost. + + ld a, [W_PlayerMoolah] + ld h, a + ld a, [W_PlayerMoolah + 1] + ld l, a + sub $A + ld l, a + jp nc, .noDecH + ld a, h + sub 1 + ld h, a + +.noDecH + ld a, h + ld [W_PlayerMoolah], a + ld a, l + ld [W_PlayerMoolah + 1], a + ld bc, $D01 + ld hl, W_PlayerMoolah + +; Refresh player money. + + call PaintShopMapMoney + ld a, [W_ShopPasswordSelectionYAxis] + inc a + ld [W_MedarotCurrentPalette], a + +; Refresh medarot palette. + + call PaintShopUpdateSelectedMedarotPalette + call WrapInitiateMainScript + ld a, $2A + ld [W_CoreSubStateIndex], a + ret + +PaintShopNotEnoughMoneyMessageState:: + ld de, $C100 + call $33B7 + ld bc, $A2 + ld a, 2 + call WrapMainScriptProcessor + ld a, [W_MainScriptExitMode] + or a + ret z + call WrapInitiateMainScript + ld a, $28 + ld [W_CoreSubStateIndex], a + ret + +PaintShopNoPaintedMedarotsMessageState:: + ld de, $C100 + call $33B7 + ld bc, $A3 + ld a, 2 + call WrapMainScriptProcessor + ld a, [W_MainScriptExitMode] + or a + ret z + call WrapInitiateMainScript + ld a, $28 + ld [W_CoreSubStateIndex], a + ret + +PaintShopUnusedPaletteRelatedState:: + ld a, 2 + call WrapSetupPalswapAnimation + jp PaintShopIncSubStateIndex + +PaintShopDoFadeState:: + call $34E6 + ld a, [W_PaletteAnimRunning] + or a + ret nz + jp PaintShopIncSubStateIndex + +PaintShopPaintingSwitchVisiblePaletteState:: + call $34E6 + ld a, [W_PaletteAnimRunning] + or a + ret nz + ld a, $1B + ld [W_CoreSubStateIndex], a + ret + +PaintShopPrepareFadeInState:: + ld hl, $35 + ld bc, $25 + ld d, $FF + ld e, $FF + ld a, $E + call WrapSetupPalswapAnimation + jp PaintShopIncSubStateIndex + +PaintShopPrepareFadeOutState:: + ld hl, 1 + ld bc, 1 + ld d, $FF + ld e, $FF + ld a, $E + call WrapSetupPalswapAnimation + jp PaintShopIncSubStateIndex + +PaintShopExitState:: + ld a, 0 + call $1554 + jp $36A3 + +PaintShopUnusedState:: + ld a, [W_CoreStateIndex] + inc a + ld [W_CoreStateIndex], a + xor a + ld [W_CoreSubStateIndex], a + ret From ddc9455814aeab14c62c54a12220df8bbfa75da6 Mon Sep 17 00:00:00 2001 From: andwhyisit Date: Sat, 1 Jul 2023 15:55:32 +1000 Subject: [PATCH 3/6] Minigames partial disassembly. --- Makefile | 1 + game/src/minigames/core.asm | 196 ++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 game/src/minigames/core.asm diff --git a/Makefile b/Makefile index 18f9ae5d..9251215a 100644 --- a/Makefile +++ b/Makefile @@ -84,6 +84,7 @@ titlemenu\ pausemenu\ townmap\ shop\ +minigames\ tutorial\ battle\ nameentry\ diff --git a/game/src/minigames/core.asm b/game/src/minigames/core.asm new file mode 100644 index 00000000..eacfb7fe --- /dev/null +++ b/game/src/minigames/core.asm @@ -0,0 +1,196 @@ +INCLUDE "game/src/common/constants.asm" + +SECTION "Minigame A State Machine 1", ROMX[$4000], BANK[$14] +MinigameAStateMachine:: + ld a, [$C824] + inc a + ld [$C824], a + ld a, [W_CoreSubStateIndex] + ld hl, .table + rst $30 + jp hl + +.table + dw MinigameADrawingState + dw MinigameAMappingState + dw MinigameAPrepareFadeInState + dw MinigameADoFadeInState + dw $410C + dw $4134 + dw $4160 + dw $41BA + dw $41CC + dw $41F0 + +MinigameADrawingState:: + call $343B + ld hl, $C820 + xor a + ld b, 0 + +.clearLoop + ld [hli], a + dec b + jr nz, .clearLoop + + ld a, $40 + ld [$C830], a + ld a, 0 + ld [W_ShadowREG_WX], a + ld a, $78 + ld [W_ShadowREG_WY], a + ld a, $E3 + ld [W_ShadowREG_LCDC], a + ld a, 1 + ld [$C840], a + ld a, $10 + ld [$C826], a + ld a, 0 + ld [$C827], a + ld bc, 4 + call WrapLoadMaliasGraphics + ld bc, $20 + call WrapLoadMaliasGraphics + ld bc, $21 + call WrapLoadMaliasGraphics + ld bc, $22 + call WrapLoadMaliasGraphics + ld bc, $23 + call WrapLoadMaliasGraphics + ld bc, $24 + call WrapLoadMaliasGraphics + call .setMetaspritePointerTableIndices + jp IncSubStateIndex + +.setMetaspritePointerTableIndices + call $3413 + ld b, $1E + ld hl, $C0A1 + ld de, $20 + ld a, $11 + +.writeLoop + ld [hl], a + add hl, de + dec b + jr nz, .writeLoop + ret + +MinigameAMappingState:: + ld bc, 0 + ld e, 0 + ld a, 1 + call WrapDecompressTilemap0 + ld bc, 0 + ld e, 0 + ld a, 1 + call WrapDecompressAttribmap0 + ld bc, 0 + ld e, 1 + ld a, 1 + call WrapDecompressTilemap1 + ld bc, 0 + ld e, 1 + ld a, 1 + call WrapDecompressAttribmap1 + ld b, 0 + ld c, 0 + ld hl, $9824 + call $4374 + call $43A1 + ld a, 1 + ld [$C0C0], a + ld [$C0E0], a + call $44BC + call $587C + ld a, 1 + ld [W_OAM_SpritesReady], a + jp IncSubStateIndex + +MinigameAPrepareFadeInState:: + ld hl, $20 + ld bc, $14 + ld d, $FF + ld e, $FF + ld a, $E + call WrapSetupPalswapAnimation + ld a, 1 + ld [W_OAM_SpritesReady], a + jp IncSubStateIndex + +MinigameADoFadeInState:: + call $4404 + call $41AB + ld a, 1 + ld [W_OAM_SpritesReady], a + call $34E6 + ld a, [W_PaletteAnimRunning] + or a + ret nz + xor a + ld [$C835], a + jp IncSubStateIndex + +SECTION "Minigame B State Machine 1", ROMX[$5F7C], BANK[$14] +MinigameBStateMachine:: + ld a, [W_CoreSubStateIndex] + ld hl, .table + rst $30 + jp hl + +.table + dw MinigameBDrawingState + dw MinigameBMappingState + dw $5FF5 + dw $6090 + dw $6061 + dw $6085 + dw $60C7 + dw $60FC + dw $6073 + dw $6085 + dw $6234 + dw $61B9 + dw $61E2 + dw $620B + dw $6234 + dw $6234 + +MinigameBDrawingState:: + call $343B + ld c, $FF + ld hl, $C820 + call $69FB ; Clear loop function. + ld a, [$C91F] + or a + jp nz, .notLessThanOne + inc a + +.notLessThanOne + cp 6 + jp c, .notGreaterThanFive + ld a, 5 + +.notGreaterThanFive + ld [$C820], a + call $3413 + ld bc, $26 + call WrapLoadMaliasGraphics + ld bc, $27 + call WrapLoadMaliasGraphics + ld bc, $28 + call WrapLoadMaliasGraphics + jp IncSubStateIndex + +MinigameBMappingState:: + ld bc, 0 + ld e, 3 + ld a, 1 + call WrapDecompressTilemap0 + ld bc, 0 + ld e, 3 + ld a, 1 + call WrapDecompressAttribmap0 + ld a, 1 + ld [$C4D9], a + jp IncSubStateIndex From 8d22aaea908732c5d804936dfde767451aec46f9 Mon Sep 17 00:00:00 2001 From: VariantXYZ Date: Sun, 9 Jul 2023 22:42:32 -0700 Subject: [PATCH 4/6] Identify Paint Shop bubble text and shopkeeper avatar tilesets --- game/src/version/tileset_table.asm | 20 +++++++++--------- ...3A0D.malias => PaintShopBubbleText.malias} | Bin ...alias => PaintShopShopkeeperAvatar.malias} | Bin ...ias.png => PaintShopBubbleText.malias.png} | Bin ...g => PaintShopShopkeeperAvatar.malias.png} | Bin scripts/res/meta_tileset_index.tbl | 4 ++-- scripts/res/meta_tileset_names.tbl | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) rename gfx/prebuilt/tilesets/{Tileset3A0D.malias => PaintShopBubbleText.malias} (100%) rename gfx/prebuilt/tilesets/{Tileset3A0B.malias => PaintShopShopkeeperAvatar.malias} (100%) rename gfx/tilesets/{Tileset3A0D.malias.png => PaintShopBubbleText.malias.png} (100%) rename gfx/tilesets/{Tileset3A0B.malias.png => PaintShopShopkeeperAvatar.malias.png} (100%) diff --git a/game/src/version/tileset_table.asm b/game/src/version/tileset_table.asm index c401f06e..9274a3fc 100644 --- a/game/src/version/tileset_table.asm +++ b/game/src/version/tileset_table.asm @@ -66,8 +66,8 @@ TilesetSourceAddressTable:: TilesetTableEntry Tileset3A05 ; 38 (3A05) TilesetTableEntry Tileset3A07 ; 39 (3A07) TilesetTableEntry Tileset3A09 ; 3A (3A09) - TilesetTableEntry Tileset3A0B ; 3B (3A0B) - TilesetTableEntry Tileset3A0D ; 3C (3A0D) + TilesetTableEntry PaintShopShopkeeperAvatar ; 3B (3A0B) + TilesetTableEntry PaintShopBubbleText ; 3C (3A0D) TilesetTableEntry Tileset3A0F ; 3D (3A0F) TilesetTableEntry Tileset3A11 ; 3E (3A11) TilesetTableEntry Tileset3A13 ; 3F (3A13) @@ -582,8 +582,8 @@ TilesetInfoTable:: dbwb BANK(Tileset3A05), $8300, $0 ; 038 dbwb BANK(Tileset3A07), $8000, $1 ; 039 dbwb BANK(Tileset3A09), $9000, $0 ; 03A - dbwb BANK(Tileset3A0B), $9560, $0 ; 03B - dbwb BANK(Tileset3A0D), $8400, $0 ; 03C + dbwb BANK(PaintShopShopkeeperAvatar), $9560, $0 ; 03B + dbwb BANK(PaintShopBubbleText), $8400, $0 ; 03C dbwb BANK(Tileset3A0F), $8300, $0 ; 03D dbwb BANK(Tileset3A11), $8000, $0 ; 03E dbwb BANK(Tileset3A13), $8B60, $0 ; 03F @@ -1230,13 +1230,13 @@ SECTION "Tileset Data Tileset3A09", ROMX[$4E96], BANK[$3B] Tileset3A09:: INCBIN "./build/tilesets/Tileset3A09.malias" -SECTION "Tileset Data Tileset3A0B", ROMX[$4F4D], BANK[$3B] -Tileset3A0B:: - INCBIN "./build/tilesets/Tileset3A0B.malias" +SECTION "Tileset Data PaintShopShopkeeperAvatar", ROMX[$4F4D], BANK[$3B] +PaintShopShopkeeperAvatar:: + INCBIN "./build/tilesets/PaintShopShopkeeperAvatar.malias" -SECTION "Tileset Data Tileset3A0D", ROMX[$51BB], BANK[$3B] -Tileset3A0D:: - INCBIN "./build/tilesets/Tileset3A0D.malias" +SECTION "Tileset Data PaintShopBubbleText", ROMX[$51BB], BANK[$3B] +PaintShopBubbleText:: + INCBIN "./build/tilesets/PaintShopBubbleText.malias" SECTION "Tileset Data Tileset3A0F", ROMX[$52B5], BANK[$3B] Tileset3A0F:: diff --git a/gfx/prebuilt/tilesets/Tileset3A0D.malias b/gfx/prebuilt/tilesets/PaintShopBubbleText.malias similarity index 100% rename from gfx/prebuilt/tilesets/Tileset3A0D.malias rename to gfx/prebuilt/tilesets/PaintShopBubbleText.malias diff --git a/gfx/prebuilt/tilesets/Tileset3A0B.malias b/gfx/prebuilt/tilesets/PaintShopShopkeeperAvatar.malias similarity index 100% rename from gfx/prebuilt/tilesets/Tileset3A0B.malias rename to gfx/prebuilt/tilesets/PaintShopShopkeeperAvatar.malias diff --git a/gfx/tilesets/Tileset3A0D.malias.png b/gfx/tilesets/PaintShopBubbleText.malias.png similarity index 100% rename from gfx/tilesets/Tileset3A0D.malias.png rename to gfx/tilesets/PaintShopBubbleText.malias.png diff --git a/gfx/tilesets/Tileset3A0B.malias.png b/gfx/tilesets/PaintShopShopkeeperAvatar.malias.png similarity index 100% rename from gfx/tilesets/Tileset3A0B.malias.png rename to gfx/tilesets/PaintShopShopkeeperAvatar.malias.png diff --git a/scripts/res/meta_tileset_index.tbl b/scripts/res/meta_tileset_index.tbl index 82242893..cd07829a 100644 --- a/scripts/res/meta_tileset_index.tbl +++ b/scripts/res/meta_tileset_index.tbl @@ -57,8 +57,8 @@ 038=Tileset3A05 039=Tileset3A07 03A=Tileset3A09 -03B=Tileset3A0B -03C=Tileset3A0D +03B=PaintShopShopkeeperAvatar +03C=PaintShopBubbleText 03D=Tileset3A0F 03E=Tileset3A11 03F=Tileset3A13 diff --git a/scripts/res/meta_tileset_names.tbl b/scripts/res/meta_tileset_names.tbl index ba63ccc5..3c4531f9 100644 --- a/scripts/res/meta_tileset_names.tbl +++ b/scripts/res/meta_tileset_names.tbl @@ -46,8 +46,8 @@ 3A05=Tileset3A05 3A07=Tileset3A07 3A09=Tileset3A09 -3A0B=Tileset3A0B -3A0D=Tileset3A0D +3A0B=PaintShopShopkeeperAvatar +3A0D=PaintShopBubbleText 3A0F=Tileset3A0F 3A11=Tileset3A11 3A13=Tileset3A13 From 841607c15ca7622f8085fba2c6d5a929f2a68698 Mon Sep 17 00:00:00 2001 From: VariantXYZ Date: Sun, 9 Jul 2023 22:53:21 -0700 Subject: [PATCH 5/6] Identify PaintShopMainScreen tilemap --- game/src/version/tilemap_table.asm | 2 +- gfx/tilemaps/{018B.txt => PaintShopMainScreen.txt} | 0 scripts/res/meta_tilemap_files.tbl | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename gfx/tilemaps/{018B.txt => PaintShopMainScreen.txt} (100%) diff --git a/game/src/version/tilemap_table.asm b/game/src/version/tilemap_table.asm index 64cb569c..bb2c7eaf 100644 --- a/game/src/version/tilemap_table.asm +++ b/game/src/version/tilemap_table.asm @@ -1093,7 +1093,7 @@ Tilemap01_89:: Tilemap01_8A:: INCBIN "./build/tilemaps/018A.map" Tilemap01_8B:: - INCBIN "./build/tilemaps/018B.map" + INCBIN "./build/tilemaps/PaintShopMainScreen.map" Tilemap01_8C:: INCBIN "./build/tilemaps/018C.map" Tilemap01_8D:: diff --git a/gfx/tilemaps/018B.txt b/gfx/tilemaps/PaintShopMainScreen.txt similarity index 100% rename from gfx/tilemaps/018B.txt rename to gfx/tilemaps/PaintShopMainScreen.txt diff --git a/scripts/res/meta_tilemap_files.tbl b/scripts/res/meta_tilemap_files.tbl index c4a1e5fd..e3aaf518 100644 --- a/scripts/res/meta_tilemap_files.tbl +++ b/scripts/res/meta_tilemap_files.tbl @@ -288,7 +288,7 @@ 01_88=0188 01_89=ShopPasswordScreen 01_8A=018A -01_8B=018B +01_8B=PaintShopMainScreen 01_8C=018C 01_8D=018D 01_8E=018E From c9f14dd07182950c7188f55c0af1bf537ec8be18 Mon Sep 17 00:00:00 2001 From: VariantXYZ Date: Sun, 9 Jul 2023 22:56:52 -0700 Subject: [PATCH 6/6] Identify PaintShopPaintSelectScreen tilemap --- game/src/version/tilemap_table.asm | 2 +- gfx/tilemaps/{018C.txt => PaintShopPaintSelectScreen.txt} | 0 scripts/res/meta_tilemap_files.tbl | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename gfx/tilemaps/{018C.txt => PaintShopPaintSelectScreen.txt} (100%) diff --git a/game/src/version/tilemap_table.asm b/game/src/version/tilemap_table.asm index bb2c7eaf..33aae3b8 100644 --- a/game/src/version/tilemap_table.asm +++ b/game/src/version/tilemap_table.asm @@ -1095,7 +1095,7 @@ Tilemap01_8A:: Tilemap01_8B:: INCBIN "./build/tilemaps/PaintShopMainScreen.map" Tilemap01_8C:: - INCBIN "./build/tilemaps/018C.map" + INCBIN "./build/tilemaps/PaintShopPaintSelectScreen.map" Tilemap01_8D:: INCBIN "./build/tilemaps/018D.map" Tilemap01_8E:: diff --git a/gfx/tilemaps/018C.txt b/gfx/tilemaps/PaintShopPaintSelectScreen.txt similarity index 100% rename from gfx/tilemaps/018C.txt rename to gfx/tilemaps/PaintShopPaintSelectScreen.txt diff --git a/scripts/res/meta_tilemap_files.tbl b/scripts/res/meta_tilemap_files.tbl index e3aaf518..dabb22d5 100644 --- a/scripts/res/meta_tilemap_files.tbl +++ b/scripts/res/meta_tilemap_files.tbl @@ -289,7 +289,7 @@ 01_89=ShopPasswordScreen 01_8A=018A 01_8B=PaintShopMainScreen -01_8C=018C +01_8C=PaintShopPaintSelectScreen 01_8D=018D 01_8E=018E 01_8F=018F