diff options
author | mid-kid <esteve.varela@gmail.com> | 2018-03-13 13:07:16 +0100 |
---|---|---|
committer | mid-kid <esteve.varela@gmail.com> | 2018-03-13 13:21:40 +0100 |
commit | baa0dc5a963a79843b37888bcfe1d2dfe833ade9 (patch) | |
tree | 968c86105bd67a3121d8f3f20018bfc59191f4c9 /engine/overworld/map_object_action.asm | |
parent | 12070ca50067d3abe36a730190f88ee43f2cace9 (diff) |
Organize the engine/ directory
This is an informed attempt at reorganizing the engine/ directory by
creating categorized subdirectories, in order to make it easier to
navigate and find things.
The directories created are as follows:
* engine/game: Contains all "minigames", things like the unown puzzle
and slot machine.
* engine/gfx: Contains all handling of graphics. From loading palettes
to playing animations.
* engine/link: Contains all multiplayer functionality.
* engine/menu: Contains all generic/misc. menus and menu code.
Other, more specialized menus are in their own subdirectories (pokedex,
pokegear, party menu, etc).
* engine/overworld: Contains all handling of the overworld. From loading
and connecting maps to wild encounters and the scripting engine.
* engine/pokegear: In the same vein as engine/pokedex, except it could
use some more splitting up.
* engine/pokemon: Contains everything related to manipulating pokemon
data. From the pokemon storage system to evolution and mail.
* engine/printer: Contains everything related to printing things as well
as the printer communication.
* engine/title: Contains intro sequences, title screens and credits.
Diffstat (limited to 'engine/overworld/map_object_action.asm')
-rwxr-xr-x | engine/overworld/map_object_action.asm | 313 |
1 files changed, 313 insertions, 0 deletions
diff --git a/engine/overworld/map_object_action.asm b/engine/overworld/map_object_action.asm new file mode 100755 index 000000000..c82cd80a2 --- /dev/null +++ b/engine/overworld/map_object_action.asm @@ -0,0 +1,313 @@ +ObjectActionPairPointers: ; 445f +; entries correspond to OBJECT_ACTION_* constants + dw SetFacingStanding, SetFacingStanding + dw SetFacingStandAction, SetFacingCurrent + dw SetFacingStepAction, SetFacingCurrent + dw SetFacingBumpAction, SetFacingCurrent + dw SetFacingCounterclockwiseSpin, SetFacingCurrent + dw SetFacingCounterclockwiseSpin2, SetFacingStanding + dw SetFacingFish, SetFacingFish + dw SetFacingShadow, SetFacingStanding + dw SetFacingEmote, SetFacingEmote + dw SetFacingBigDollSym, SetFacingBigDollSym + dw SetFacingBounce, SetFacingFreezeBounce + dw SetFacingWeirdTree, SetFacingCurrent + dw SetFacingBigDollAsym, SetFacingBigDollAsym + dw SetFacingBigDoll, SetFacingBigDoll + dw SetFacingBoulderDust, SetFacingStanding + dw SetFacingGrassShake, SetFacingStanding + dw SetFacingSkyfall, SetFacingCurrent +; 44a3 + +SetFacingStanding: ; 44a3 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], STANDING + ret +; 44aa + +SetFacingCurrent: ; 44aa + call GetSpriteDirection + or FACING_STEP_DOWN_0 ; useless + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 44b5 + +SetFacingStandAction: ; 44b5 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld a, [hl] + and 1 + jr nz, SetFacingStepAction + jp SetFacingCurrent +; 44c1 + +SetFacingStepAction: ; 44c1 + ld hl, OBJECT_FLAGS1 + add hl, bc + bit SLIDING, [hl] + jp nz, SetFacingCurrent + + ld hl, OBJECT_STEP_FRAME + add hl, bc + ld a, [hl] + inc a + and %00001111 + ld [hl], a + + rrca + rrca + and %00000011 + ld d, a + + call GetSpriteDirection + or FACING_STEP_DOWN_0 ; useless + or d + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 44e4 + +SetFacingSkyfall: ; 44e4 + ld hl, OBJECT_FLAGS1 + add hl, bc + bit SLIDING, [hl] + jp nz, SetFacingCurrent + + ld hl, OBJECT_STEP_FRAME + add hl, bc + ld a, [hl] + add 2 + and %00001111 + ld [hl], a + + rrca + rrca + and %00000011 + ld d, a + + call GetSpriteDirection + or FACING_STEP_DOWN_0 ; useless + or d + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 4508 + +SetFacingBumpAction: ; 4508 + ld hl, OBJECT_FLAGS1 + add hl, bc + bit SLIDING, [hl] + jp nz, SetFacingCurrent + + ld hl, OBJECT_STEP_FRAME + add hl, bc + inc [hl] + + ld a, [hl] + rrca + rrca + rrca + and %00000011 + ld d, a + + call GetSpriteDirection + or FACING_STEP_DOWN_0 ; useless + or d + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 4529 + +SetFacingCounterclockwiseSpin: ; 4529 + call CounterclockwiseSpinAction + ld hl, OBJECT_FACING + add hl, bc + ld a, [hl] + or FACING_STEP_DOWN_0 ; useless + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 4539 + +SetFacingCounterclockwiseSpin2: ; 4539 + call CounterclockwiseSpinAction + jp SetFacingStanding +; 453f + +CounterclockwiseSpinAction: ; 453f +; Here, OBJECT_STEP_FRAME consists of two 2-bit components, +; using only bits 0,1 and 4,5. +; bits 0,1 is a timer (4 overworld frames) +; bits 4,5 determines the facing - the direction is counterclockwise. + ld hl, OBJECT_STEP_FRAME + add hl, bc + ld a, [hl] + and %11110000 + ld e, a + + ld a, [hl] + inc a + and %00001111 + ld d, a + cp 4 + jr c, .ok + + ld d, 0 + ld a, e + add $10 + and %00110000 + ld e, a + +.ok + ld a, d + or e + ld [hl], a + + swap e + ld d, 0 + ld hl, .Directions + add hl, de + ld a, [hl] + ld hl, OBJECT_FACING + add hl, bc + ld [hl], a + ret +; 456a + +.Directions: ; 456a + db OW_DOWN, OW_RIGHT, OW_UP, OW_LEFT +; 456e + +SetFacingFish: ; 456e + call GetSpriteDirection + rrca + rrca + add FACING_FISH_DOWN + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 457b + +SetFacingShadow: ; 457b + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_SHADOW + ret +; 4582 + +SetFacingEmote: ; 4582 emote + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_EMOTE + ret +; 4589 + +SetFacingBigDollSym: ; 4589 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_BIG_DOLL_SYM + ret +; 4590 + +SetFacingBounce: ; 4590 + ld hl, OBJECT_STEP_FRAME + add hl, bc + ld a, [hl] + inc a + and %00001111 + ld [hl], a + and %00001000 + jr z, SetFacingFreezeBounce + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_STEP_UP_0 + ret +; 45a4 + +SetFacingFreezeBounce: ; 45a4 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_STEP_DOWN_0 + ret +; 45ab + +SetFacingWeirdTree: ; 45ab + ld hl, OBJECT_STEP_FRAME + add hl, bc + ld a, [hl] + inc a + ld [hl], a + and %00001100 + rrca + rrca + add FACING_WEIRD_TREE_0 + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], a + ret +; 45be + +SetFacingBigDollAsym: ; 45be + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], FACING_BIG_DOLL_ASYM + ret +; 45c5 + +SetFacingBigDoll: ; 45c5 + ld a, [wVariableSprites + SPRITE_BIG_DOLL - SPRITE_VARS] + ld d, FACING_BIG_DOLL_SYM ; symmetric + cp SPRITE_BIG_SNORLAX + jr z, .ok + cp SPRITE_BIG_LAPRAS + jr z, .ok + ld d, FACING_BIG_DOLL_ASYM ; asymmetric + +.ok + ld hl, OBJECT_FACING_STEP + add hl, bc + ld [hl], d + ret +; 45da + +SetFacingBoulderDust: ; 45da + ld hl, OBJECT_STEP_FRAME + add hl, bc + inc [hl] + ld a, [hl] + + ld hl, OBJECT_FACING_STEP + add hl, bc + and 2 + ld a, FACING_BOULDER_DUST_1 + jr z, .ok + inc a ; FACING_BOULDER_DUST_2 +.ok + ld [hl], a + ret +; 45ed + +SetFacingGrassShake: ; 45ed + ld hl, OBJECT_STEP_FRAME + add hl, bc + inc [hl] + ld a, [hl] + ld hl, OBJECT_FACING_STEP + add hl, bc + and 4 + ld a, FACING_GRASS_1 + jr z, .ok + inc a ; FACING_GRASS_2 + +.ok + ld [hl], a + ret +; 4600 |