summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Huderle <huderlem@gmail.com>2015-03-14 13:18:41 -0700
committerMarcus Huderle <huderlem@gmail.com>2015-03-14 13:18:41 -0700
commit3c6d4b7d7ec93f5ace4dd7dfcac704c0f3a50e96 (patch)
tree1986fb4fb510d2d8e673acc6c68503bbd5785e80
parentbc491702b9aaa5b42db349c944248186d841ebe1 (diff)
Dump MoveBallPosition routine.
-rwxr-xr-xmain.asm56
-rwxr-xr-xwram.asm41
2 files changed, 84 insertions, 13 deletions
diff --git a/main.asm b/main.asm
index a67768b..97b8893 100755
--- a/main.asm
+++ b/main.asm
@@ -2797,7 +2797,53 @@ Func_208c: ; 0x208c
scf
ret
-INCBIN "baserom.gbc",$20ab,$30db - $20ab
+INCBIN "baserom.gbc",$20ab,$219c - $20ab
+
+MoveBallPosition: ; 0x219c
+; Updates the ball's position according to its velocity
+ ld a, [wBallXPos]
+ ld [wPreviousBallXPos], a
+ ld a, [wBallXPos + 1]
+ ld [wPreviousBallXPos + 1], a
+ ld a, [wBallYPos]
+ ld [wPreviousBallYPos], a
+ ld a, [wBallYPos + 1]
+ ld [wPreviousBallYPos + 1], a
+ ld de, wBallXVelocity + 1
+ ld hl, wBallXPos
+ call AddVelocityToPosition
+ ld de, wBallYVelocity + 1
+ ld hl, wBallYPos
+ ; fall through
+
+AddVelocityToPosition: ; 0x21c3
+ ld a, [de]
+ bit 7, a
+ jr nz, .asm_21d1
+ cp $5
+ jr c, .asm_21da
+ ld bc, $04ff
+ jr .asm_21de
+.asm_21d1
+ cp $fc
+ jr nc, .asm_21da
+ ld bc, $fb01
+ jr .asm_21de
+.asm_21da
+ ld b, a
+ dec de
+ ld a, [de]
+ ld c, a
+.asm_21de
+ ld a, [hl]
+ add c
+ ld [hli], a
+ ld a, [hl]
+ adc b
+ ld [hl], a
+ ret
+
+INCBIN "baserom.gbc",$21e5,$30db - $21e5
Func_30db: ; 0x30db
ld a, $86
@@ -7158,12 +7204,12 @@ Func_17e81: ; 0x17e81
ld a, [wBallRotation]
add [hl]
ld [wBallRotation], a
- ld a, [wBallXPos]
+ ld a, [wBallXPos + 1]
inc a
ld hl, hBoardXShift
sub [hl]
ld b, a
- ld a, [wBallYPos]
+ ld a, [wBallYPos + 1]
inc a
sub $10
ld hl, hBoardYShift
@@ -7205,9 +7251,9 @@ Func_17e81: ; 0x17e81
and $7
add $0
call LoadOAMData
- ld a, [wBallXPos]
+ ld a, [wBallXPos + 1]
ld [$d4c5], a
- ld a, [wBallYPos]
+ ld a, [wBallYPos + 1]
ld [$d4c6], a
ld a, [wBallRotation]
ld [$d4c7], a
diff --git a/wram.asm b/wram.asm
index 2adfe52..d61be27 100755
--- a/wram.asm
+++ b/wram.asm
@@ -13,18 +13,43 @@ wOAMBuffer:: ; d000
; buffer for OAM data. Copied to OAM by DMA
ds 4 * 40
- ds $414
+ ds $413
-wBallXPos:: ; 0xd4b4
+wBallXPos:: ; 0xd4b3
; x coordinate of the center of the pokeball
- ds 1
- ds 1
-wBallYPos:: ; 0xd4b6
+; little-endian word
+; Most-significant byte is the pixel, and least-significant byte is fraction of a pixel
+ ds 2
+
+wBallYPos:: ; 0xd4b5
; y coordinate of the center of the pokeball
- ds 1
- ds 1
+; little-endian word
+; Most-significant byte is the pixel, and least-significant byte is fraction of a pixel
+ ds 2
+
+wPreviousBallXPos:: ; 0xd4b7
+; x coordinate of the center of the pokeball in the previous frame
+; little-endian word
+; Most-significant byte is the pixel, and least-significant byte is fraction of a pixel
+ ds 2
+
+wPreviousBallYPos:: ; 0xd4b9
+; y coordinate of the center of the pokeball in the previous frame
+; little-endian word
+; Most-significant byte is the pixel, and least-significant byte is fraction of a pixel
+ ds 2
+
+wBallXVelocity:: ; 0xd4bb
+; little-endian word
+; This is added to wBallXPos every frame.
+ ds 2
+
+wBallYVelocity:: ; 0xd4bd
+; little-endian word
+; This is added to wBallYPos every frame.
+ ds 2
- ds $b
+ ds 4
wBallSpin:: ; 0xd4c3
ds 1