From 77d0e5ff84cc61ae625da19f184094241eddd4dc Mon Sep 17 00:00:00 2001 From: xCrystal Date: Wed, 1 Apr 2015 16:16:43 +0200 Subject: Rename battle files and split move effects Part 3 b.asm, b_2.asm, c.asm, and d.asm --- engine/battle/b.asm | 18 ---- engine/battle/b_2.asm | 129 ------------------------ engine/battle/c.asm | 58 ----------- engine/battle/d.asm | 23 ----- engine/battle/display_effectiveness.asm | 18 ++++ engine/battle/link_battle_versus_text.asm | 23 +++++ engine/battle/moveEffects/mist_effect.asm | 21 ++++ engine/battle/moveEffects/one_hit_ko_effect.asm | 36 +++++++ engine/battle/moveEffects/pay_day_effect.asm | 43 ++++++++ engine/battle/scale_sprites.asm | 85 ++++++++++++++++ main.asm | 10 +- 11 files changed, 232 insertions(+), 232 deletions(-) delete mode 100755 engine/battle/b.asm delete mode 100755 engine/battle/b_2.asm delete mode 100755 engine/battle/c.asm delete mode 100755 engine/battle/d.asm create mode 100644 engine/battle/display_effectiveness.asm create mode 100644 engine/battle/link_battle_versus_text.asm create mode 100644 engine/battle/moveEffects/mist_effect.asm create mode 100644 engine/battle/moveEffects/one_hit_ko_effect.asm create mode 100644 engine/battle/moveEffects/pay_day_effect.asm create mode 100644 engine/battle/scale_sprites.asm diff --git a/engine/battle/b.asm b/engine/battle/b.asm deleted file mode 100755 index 17f0bd5b..00000000 --- a/engine/battle/b.asm +++ /dev/null @@ -1,18 +0,0 @@ -DisplayEffectiveness: ; 2fb7b (b:7b7b) - ld a, [wDamageMultipliers] - and a, $7F - cp a, $0A - ret z - ld hl, SuperEffectiveText - jr nc, .done - ld hl, NotVeryEffectiveText -.done - jp PrintText - -SuperEffectiveText: ; 2fb8e (b:7b8e) - TX_FAR _SuperEffectiveText - db "@" - -NotVeryEffectiveText: ; 2fb93 (b:7b93) - TX_FAR _NotVeryEffectiveText - db "@" diff --git a/engine/battle/b_2.asm b/engine/battle/b_2.asm deleted file mode 100755 index 4a49bb10..00000000 --- a/engine/battle/b_2.asm +++ /dev/null @@ -1,129 +0,0 @@ -; scales both uncompressed sprite chunks by two in every dimension (creating 2x2 output pixels per input pixel) -; assumes that input sprite chunks are 4x4 tiles, and the rightmost and bottommost 4 pixels will be ignored -; resulting in a 7*7 tile output sprite chunk -ScaleSpriteByTwo: ; 2fe40 (b:7e40) - ld de, S_SPRITEBUFFER1 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped - ld hl, S_SPRITEBUFFER0 + SPRITEBUFFERSIZE - 1 ; end of destination buffer - call ScaleLastSpriteColumnByTwo ; last tile column is special case - call ScaleFirstThreeSpriteColumnsByTwo ; scale first 3 tile columns - ld de, S_SPRITEBUFFER2 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped - ld hl, S_SPRITEBUFFER1 + SPRITEBUFFERSIZE - 1 ; end of destination buffer - call ScaleLastSpriteColumnByTwo ; last tile column is special case - -ScaleFirstThreeSpriteColumnsByTwo: ; 2fe55 (b:7e55) - ld b, $3 ; 3 tile columns -.columnLoop - ld c, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows -.columnInnerLoop - push bc - ld a, [de] - ld bc, -(7*8)+1 ; $ffc9, scale lower nybble and seek to previous output column - call ScalePixelsByTwo - ld a, [de] - dec de - swap a - ld bc, 7*8+1-2 ; $37, scale upper nybble and seek back to current output column and to the next 2 rows - call ScalePixelsByTwo - pop bc - dec c - jr nz, .columnInnerLoop - dec de - dec de - dec de - dec de - ld a, b - ld bc, -7*8 ; $ffc8, skip one output column (which has already been written along with the current one) - add hl, bc - ld b, a - dec b - jr nz, .columnLoop - ret - -ScaleLastSpriteColumnByTwo: ; 2fe7d (b:7e7d) - ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows - ld [H_SPRITEINTERLACECOUNTER], a ; $ff8b - ld bc, -1 ; $ffff -.columnInnerLoop - ld a, [de] - dec de - swap a ; only high nybble contains information - call ScalePixelsByTwo - ld a, [H_SPRITEINTERLACECOUNTER] ; $ff8b - dec a - ld [H_SPRITEINTERLACECOUNTER], a ; $ff8b - jr nz, .columnInnerLoop - dec de ; skip last 4 rows of new column - dec de - dec de - dec de - ret - -; scales the given 4 bits in a (4x1 pixels) to 2 output bytes (8x2 pixels) -; hl: destination pointer -; bc: destination pointer offset (added after the two bytes have been written) -ScalePixelsByTwo: ; 2fe97 (b:7e97) - push hl - and $f - ld hl, DuplicateBitsTable - add l - ld l, a - jr nc, .noCarry - inc h -.noCarry - ld a, [hl] - pop hl - ld [hld], a ; write output byte twice to make it 2 pixels high - ld [hl], a - add hl, bc ; add offset - ret - -; repeats each input bit twice -DuplicateBitsTable: ; 2fea8 (b:7ea8) - db $00, $03, $0c, $0f - db $30, $33, $3c, $3f - db $c0, $c3, $cc, $cf - db $f0, $f3, $fc, $ff - -PayDayEffect_ ; 2feb8 (b:7eb8) - xor a - ld hl, wcd6d - ld [hli], a - ld a, [H_WHOSETURN] - and a - ld a, [wBattleMonLevel] - jr z, .asm_2fec8 - ld a, [wEnemyMonLevel] -.asm_2fec8 - add a - ld [H_DIVIDEND + 3], a - xor a - ld [H_DIVIDEND], a - ld [H_DIVIDEND + 1], a - ld [H_DIVIDEND + 2], a - ld a, $64 - ld [H_DIVISOR], a - ld b, $4 - call Divide - ld a, [H_QUOTIENT + 3] - ld [hli], a - ld a, [H_REMAINDER] - ld [H_DIVIDEND + 3], a - ld a, $a - ld [H_DIVISOR], a - ld b, $4 - call Divide - ld a, [H_QUOTIENT + 3] - swap a - ld b, a - ld a, [H_REMAINDER] - add b - ld [hl], a - ld de, wTotalPayDayMoney + 2 - ld c, $3 - predef AddBCDPredef - ld hl, CoinsScatteredText - jp PrintText - -CoinsScatteredText: ; 2ff04 (b:7f04) - TX_FAR _CoinsScatteredText - db "@" diff --git a/engine/battle/c.asm b/engine/battle/c.asm deleted file mode 100755 index b7c20ef6..00000000 --- a/engine/battle/c.asm +++ /dev/null @@ -1,58 +0,0 @@ -MistEffect_: ; 33f2b (c:7f2b) - ld hl, W_PLAYERBATTSTATUS2 - ld a, [$fff3] - and a - jr z, .asm_33f36 - ld hl, W_ENEMYBATTSTATUS2 -.asm_33f36 - bit ProtectedByMist, [hl] ; is mon protected by mist? - jr nz, .asm_33f4a - set ProtectedByMist, [hl] ; mon is now protected by mist - callab PlayCurrentMoveAnimation - ld hl, ShroudedInMistText - jp PrintText -.asm_33f4a - ld hl, PrintButItFailedText_ - ld b, BANK(PrintButItFailedText_) - jp Bankswitch - -ShroudedInMistText: ; 33f52 (c:7f52) - TX_FAR _ShroudedInMistText - db "@" - -OneHitKOEffect_: ; 33f57 (c:7f57) - ld hl, W_DAMAGE - xor a - ld [hli], a - ld [hl], a ; set the damage output to zero - dec a - ld [wCriticalHitOrOHKO], a - ld hl, wBattleMonSpeed + 1 - ld de, wEnemyMonSpeed + 1 - ld a, [H_WHOSETURN] ; $fff3 - and a - jr z, .asm_33f72 - ld hl, wEnemyMonSpeed + 1 - ld de, wBattleMonSpeed + 1 -.asm_33f72 - ld a, [de] - dec de - ld b, a - ld a, [hld] - sub b - ld a, [de] - ld b, a - ld a, [hl] - sbc b - jr c, .asm_33f8a - ld hl, W_DAMAGE - ld a, $ff - ld [hli], a - ld [hl], a - ld a, $2 - ld [wCriticalHitOrOHKO], a - ret -.asm_33f8a - ld a, $1 - ld [W_MOVEMISSED], a - ret diff --git a/engine/battle/d.asm b/engine/battle/d.asm deleted file mode 100755 index 7320da29..00000000 --- a/engine/battle/d.asm +++ /dev/null @@ -1,23 +0,0 @@ -; display "[player] VS [enemy]" text box with pokeballs representing their parties next to the names -DisplayLinkBattleVersusTextBox: ; 372d6 (d:72d6) - call LoadTextBoxTilePatterns - hlCoord 3, 4 - ld b, $7 - ld c, $c - call TextBoxBorder - hlCoord 4, 5 - ld de, wPlayerName - call PlaceString - hlCoord 4, 10 - ld de, wLinkEnemyTrainerName - call PlaceString -; place bold "VS" tiles between the names - hlCoord 9, 8 - ld a, $69 - ld [hli], a - ld [hl], $6a - xor a - ld [wUpdateSpritesEnabled], a - callab SetupPlayerAndEnemyPokeballs - ld c, 150 - jp DelayFrames diff --git a/engine/battle/display_effectiveness.asm b/engine/battle/display_effectiveness.asm new file mode 100644 index 00000000..17f0bd5b --- /dev/null +++ b/engine/battle/display_effectiveness.asm @@ -0,0 +1,18 @@ +DisplayEffectiveness: ; 2fb7b (b:7b7b) + ld a, [wDamageMultipliers] + and a, $7F + cp a, $0A + ret z + ld hl, SuperEffectiveText + jr nc, .done + ld hl, NotVeryEffectiveText +.done + jp PrintText + +SuperEffectiveText: ; 2fb8e (b:7b8e) + TX_FAR _SuperEffectiveText + db "@" + +NotVeryEffectiveText: ; 2fb93 (b:7b93) + TX_FAR _NotVeryEffectiveText + db "@" diff --git a/engine/battle/link_battle_versus_text.asm b/engine/battle/link_battle_versus_text.asm new file mode 100644 index 00000000..7320da29 --- /dev/null +++ b/engine/battle/link_battle_versus_text.asm @@ -0,0 +1,23 @@ +; display "[player] VS [enemy]" text box with pokeballs representing their parties next to the names +DisplayLinkBattleVersusTextBox: ; 372d6 (d:72d6) + call LoadTextBoxTilePatterns + hlCoord 3, 4 + ld b, $7 + ld c, $c + call TextBoxBorder + hlCoord 4, 5 + ld de, wPlayerName + call PlaceString + hlCoord 4, 10 + ld de, wLinkEnemyTrainerName + call PlaceString +; place bold "VS" tiles between the names + hlCoord 9, 8 + ld a, $69 + ld [hli], a + ld [hl], $6a + xor a + ld [wUpdateSpritesEnabled], a + callab SetupPlayerAndEnemyPokeballs + ld c, 150 + jp DelayFrames diff --git a/engine/battle/moveEffects/mist_effect.asm b/engine/battle/moveEffects/mist_effect.asm new file mode 100644 index 00000000..adee1dfd --- /dev/null +++ b/engine/battle/moveEffects/mist_effect.asm @@ -0,0 +1,21 @@ +MistEffect_: ; 33f2b (c:7f2b) + ld hl, W_PLAYERBATTSTATUS2 + ld a, [$fff3] + and a + jr z, .asm_33f36 + ld hl, W_ENEMYBATTSTATUS2 +.asm_33f36 + bit ProtectedByMist, [hl] ; is mon protected by mist? + jr nz, .asm_33f4a + set ProtectedByMist, [hl] ; mon is now protected by mist + callab PlayCurrentMoveAnimation + ld hl, ShroudedInMistText + jp PrintText +.asm_33f4a + ld hl, PrintButItFailedText_ + ld b, BANK(PrintButItFailedText_) + jp Bankswitch + +ShroudedInMistText: ; 33f52 (c:7f52) + TX_FAR _ShroudedInMistText + db "@" diff --git a/engine/battle/moveEffects/one_hit_ko_effect.asm b/engine/battle/moveEffects/one_hit_ko_effect.asm new file mode 100644 index 00000000..84418e33 --- /dev/null +++ b/engine/battle/moveEffects/one_hit_ko_effect.asm @@ -0,0 +1,36 @@ +OneHitKOEffect_: ; 33f57 (c:7f57) + ld hl, W_DAMAGE + xor a + ld [hli], a + ld [hl], a ; set the damage output to zero + dec a + ld [wCriticalHitOrOHKO], a + ld hl, wBattleMonSpeed + 1 + ld de, wEnemyMonSpeed + 1 + ld a, [H_WHOSETURN] ; $fff3 + and a + jr z, .asm_33f72 + ld hl, wEnemyMonSpeed + 1 + ld de, wBattleMonSpeed + 1 +.asm_33f72 + ld a, [de] + dec de + ld b, a + ld a, [hld] + sub b + ld a, [de] + ld b, a + ld a, [hl] + sbc b + jr c, .asm_33f8a + ld hl, W_DAMAGE + ld a, $ff + ld [hli], a + ld [hl], a + ld a, $2 + ld [wCriticalHitOrOHKO], a + ret +.asm_33f8a + ld a, $1 + ld [W_MOVEMISSED], a + ret diff --git a/engine/battle/moveEffects/pay_day_effect.asm b/engine/battle/moveEffects/pay_day_effect.asm new file mode 100644 index 00000000..75a005ed --- /dev/null +++ b/engine/battle/moveEffects/pay_day_effect.asm @@ -0,0 +1,43 @@ +PayDayEffect_ ; 2feb8 (b:7eb8) + xor a + ld hl, wcd6d + ld [hli], a + ld a, [H_WHOSETURN] + and a + ld a, [wBattleMonLevel] + jr z, .asm_2fec8 + ld a, [wEnemyMonLevel] +.asm_2fec8 + add a + ld [H_DIVIDEND + 3], a + xor a + ld [H_DIVIDEND], a + ld [H_DIVIDEND + 1], a + ld [H_DIVIDEND + 2], a + ld a, $64 + ld [H_DIVISOR], a + ld b, $4 + call Divide + ld a, [H_QUOTIENT + 3] + ld [hli], a + ld a, [H_REMAINDER] + ld [H_DIVIDEND + 3], a + ld a, $a + ld [H_DIVISOR], a + ld b, $4 + call Divide + ld a, [H_QUOTIENT + 3] + swap a + ld b, a + ld a, [H_REMAINDER] + add b + ld [hl], a + ld de, wTotalPayDayMoney + 2 + ld c, $3 + predef AddBCDPredef + ld hl, CoinsScatteredText + jp PrintText + +CoinsScatteredText: ; 2ff04 (b:7f04) + TX_FAR _CoinsScatteredText + db "@" diff --git a/engine/battle/scale_sprites.asm b/engine/battle/scale_sprites.asm new file mode 100644 index 00000000..dae4ad42 --- /dev/null +++ b/engine/battle/scale_sprites.asm @@ -0,0 +1,85 @@ +; scales both uncompressed sprite chunks by two in every dimension (creating 2x2 output pixels per input pixel) +; assumes that input sprite chunks are 4x4 tiles, and the rightmost and bottommost 4 pixels will be ignored +; resulting in a 7*7 tile output sprite chunk +ScaleSpriteByTwo: ; 2fe40 (b:7e40) + ld de, S_SPRITEBUFFER1 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped + ld hl, S_SPRITEBUFFER0 + SPRITEBUFFERSIZE - 1 ; end of destination buffer + call ScaleLastSpriteColumnByTwo ; last tile column is special case + call ScaleFirstThreeSpriteColumnsByTwo ; scale first 3 tile columns + ld de, S_SPRITEBUFFER2 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped + ld hl, S_SPRITEBUFFER1 + SPRITEBUFFERSIZE - 1 ; end of destination buffer + call ScaleLastSpriteColumnByTwo ; last tile column is special case + +ScaleFirstThreeSpriteColumnsByTwo: ; 2fe55 (b:7e55) + ld b, $3 ; 3 tile columns +.columnLoop + ld c, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows +.columnInnerLoop + push bc + ld a, [de] + ld bc, -(7*8)+1 ; $ffc9, scale lower nybble and seek to previous output column + call ScalePixelsByTwo + ld a, [de] + dec de + swap a + ld bc, 7*8+1-2 ; $37, scale upper nybble and seek back to current output column and to the next 2 rows + call ScalePixelsByTwo + pop bc + dec c + jr nz, .columnInnerLoop + dec de + dec de + dec de + dec de + ld a, b + ld bc, -7*8 ; $ffc8, skip one output column (which has already been written along with the current one) + add hl, bc + ld b, a + dec b + jr nz, .columnLoop + ret + +ScaleLastSpriteColumnByTwo: ; 2fe7d (b:7e7d) + ld a, 4*8 - 4 ; $1c, 4 tiles minus 4 unused rows + ld [H_SPRITEINTERLACECOUNTER], a ; $ff8b + ld bc, -1 ; $ffff +.columnInnerLoop + ld a, [de] + dec de + swap a ; only high nybble contains information + call ScalePixelsByTwo + ld a, [H_SPRITEINTERLACECOUNTER] ; $ff8b + dec a + ld [H_SPRITEINTERLACECOUNTER], a ; $ff8b + jr nz, .columnInnerLoop + dec de ; skip last 4 rows of new column + dec de + dec de + dec de + ret + +; scales the given 4 bits in a (4x1 pixels) to 2 output bytes (8x2 pixels) +; hl: destination pointer +; bc: destination pointer offset (added after the two bytes have been written) +ScalePixelsByTwo: ; 2fe97 (b:7e97) + push hl + and $f + ld hl, DuplicateBitsTable + add l + ld l, a + jr nc, .noCarry + inc h +.noCarry + ld a, [hl] + pop hl + ld [hld], a ; write output byte twice to make it 2 pixels high + ld [hl], a + add hl, bc ; add offset + ret + +; repeats each input bit twice +DuplicateBitsTable: ; 2fea8 (b:7ea8) + db $00, $03, $0c, $0f + db $30, $33, $3c, $3f + db $c0, $c3, $cc, $cf + db $f0, $f3, $fc, $ff diff --git a/main.asm b/main.asm index 1c7f15f9..838c4c39 100755 --- a/main.asm +++ b/main.asm @@ -5307,7 +5307,7 @@ FossilKabutopsPic:: INCBIN "pic/bmon/fossilkabutops.pic" SECTION "Battle (bank B)", ROMX, BANK[$B] -INCLUDE "engine/battle/b.asm" +INCLUDE "engine/battle/display_effectiveness.asm" TrainerInfoTextBoxTileGraphics: INCBIN "gfx/trainer_info.2bpp" BlankLeaderNames: INCBIN "gfx/blank_leader_names.2bpp" @@ -5315,7 +5315,8 @@ CircleTile: INCBIN "gfx/circle_tile.2bpp" BadgeNumbersTileGraphics: INCBIN "gfx/badge_numbers.2bpp" INCLUDE "engine/items/tmhm.asm" -INCLUDE "engine/battle/b_2.asm" +INCLUDE "engine/battle/scale_sprites.asm" +INCLUDE "engine/battle/moveEffects/pay_day_effect.asm" INCLUDE "engine/game_corner_slots2.asm" @@ -5385,7 +5386,8 @@ OldManPic:: INCBIN "pic/trainer/oldman.pic" SECTION "Battle (bank C)", ROMX, BANK[$C] -INCLUDE "engine/battle/c.asm" +INCLUDE "engine/battle/moveEffects/mist_effect.asm" +INCLUDE "engine/battle/moveEffects/one_hit_ko_effect.asm" SECTION "Pics 5", ROMX, BANK[PICS_5] @@ -5449,7 +5451,7 @@ VictreebelPicBack:: INCBIN "pic/monback/victreebelb.pic" SECTION "Battle (bank D)", ROMX, BANK[$D] INCLUDE "engine/titlescreen2.asm" -INCLUDE "engine/battle/d.asm" +INCLUDE "engine/battle/link_battle_versus_text.asm" INCLUDE "engine/slot_machine.asm" INCLUDE "engine/overworld/pewter_guys.asm" INCLUDE "engine/multiply_divide.asm" -- cgit v1.2.3