aboutsummaryrefslogtreecommitdiff
path: root/bunny.gbasm
diff options
context:
space:
mode:
authorAstatin <[email protected]>2024-08-04 14:09:15 +0900
committerAstatin <astatin@redacted>2024-08-04 14:09:15 +0900
commit0cb98aa2abb54e0a922ed9e3280e6b67aff5ba6a (patch)
tree6bd7029d130f85ecac7c2aef79b7beb383a2d2c0 /bunny.gbasm
parent6b0db29bfccbdce4ea4a438f2ccb921173f96afa (diff)
Add grid & hops to the bunny
Diffstat (limited to 'bunny.gbasm')
-rw-r--r--bunny.gbasm59
1 files changed, 53 insertions, 6 deletions
diff --git a/bunny.gbasm b/bunny.gbasm
index b2e6ca3..62ee751 100644
--- a/bunny.gbasm
+++ b/bunny.gbasm
@@ -6,11 +6,18 @@ Initialize_Bunny:
RET
Move_Bunny:
+ LD A, ($83)
+ CP $00
+ JR NZ, =Move_Bunny.check_direction
+
LD A, ($82)
+ LD ($83), A
CP $00
- JR Z, =Display_Bunny
+ JR Z, =Move_Bunny.end
Move_Bunny.check_direction:
+ LD ($85), A
+
DEC A
LD B, $01
BIT 0, A
@@ -26,31 +33,68 @@ Move_Bunny:
LD A, ($81)
ADD B
LD ($81), A
- JP =Move_Bunny.end
+ JP =Move_Bunny.check_end_of_movement
Move_Bunny.vertical_move:
LD A, ($80)
ADD B
LD ($80), A
+ Move_Bunny.check_end_of_movement:
+ AND $0f
+ LD ($84), A
+ JR NZ, =Move_Bunny.end
+ LD ($83), A
+
Move_Bunny.end:
RET
-Display_Bunny: ; X position in B, Y position in C
+Display_Bunny: ; X position in $81, Y position in $80
LD A, ($81)
LD B, A
+
LD A, ($80)
LD C, A
+ LD A, ($84)
+
+ SUB $08
+ BIT 7, A
+ JR Z, =Display_Bunny.Hop_ABS1_end
+
+ ; Adding hop animation to Y
+ XOR $ff
+ INC A
+ Display_Bunny.Hop_ABS1_end:
+ SUB $04
+ BIT 7, A
+ JR Z, =Display_Bunny.Hop_ABS2_end
+ XOR $ff
+ INC A
+ Display_Bunny.Hop_ABS2_end:
+ ADD C
+
+ LD C, A
+ ; X flip
+ LD A, ($85)
+ CP $02
+ LD E, $01
+ LD D, $00
+ JR NZ, =Display_Bunny.Write_OBJ
+ LD D, $20
+ LD E, $03
+
+ Display_Bunny.Write_OBJ:
; First OBJ (left)
LD HL, $FE00
LD A, C
LD (HL+), A
LD A, B
LD (HL+), A
- LD A, $01
+ LD A, E
+ LD (HL+), A
+ LD A, D
LD (HL+), A
- INC HL
; Second OBJ
LD A, B
@@ -61,6 +105,9 @@ Display_Bunny: ; X position in B, Y position in C
LD (HL+), A
LD A, B
LD (HL+), A
- LD A, $03
+ LD A, E
+ XOR $02
+ LD (HL+), A
+ LD A, D
LD (HL+), A
RET