Skip to content

Commit

Permalink
Fixed eggs and turning into tail
Browse files Browse the repository at this point in the history
Made some changes to ensure that new eggs always spawn instantly.
Added checks to the part of the turning routine that prevents Snek from turning into her own body to allow Snek to turn towards her tail if she's not growing.
  • Loading branch information
LeonarthCG committed Aug 20, 2018
1 parent 3beeb0c commit 4d31d87
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 4 deletions.
Binary file modified ASM/Egg/makeEgg.elf
Binary file not shown.
3 changes: 3 additions & 0 deletions ASM/Egg/makeEgg.s
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add r0,#20
strb r0,[r1,#0x14]

@choose a tile from the list
rngFailsafe:
ldr r0,=rng
mov lr,r0
.short 0xF800
Expand All @@ -31,6 +32,8 @@ swi #6 @divide random number by length/2 +1
lsl r1,#1
ldr r3,=#0x02005000
ldrh r0,[r3,r1]
cmp r0,#0
beq rngFailsafe @just in case

@store coords
ldr r3,=#0x02000000
Expand Down
Binary file modified ASM/Snake/moveSnake.elf
Binary file not shown.
3 changes: 3 additions & 0 deletions ASM/Snake/moveSnake.s
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ add r0,#1
strb r2,[r4,r0]
mov r0,#0
strh r0,[r4,#0x1A]
ldrh r0,[r4,#0x16]
sub r0,#1
strh r0,[r4,#0x16]
b End

End:
Expand Down
Binary file modified ASM/Snake/turnSnake.elf
Binary file not shown.
93 changes: 89 additions & 4 deletions ASM/Snake/turnSnake.s
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.thumb

push {lr}
push {r4-r7}
ldr r1,=#0x02000000

@check game over
ldrb r0,[r1,#0xD]
cmp r0,#0xF0
bhi End
bhi EndTrampolin

@get button presses
ldrb r0,[r1,#5]
Expand Down Expand Up @@ -53,7 +54,7 @@ beq store
mov r3,#3
cmp r0,#0x10
beq store
b End
b EndTrampolin

store:
@one final check, check if the snake is going to be turning towards the screen
Expand All @@ -68,7 +69,25 @@ ldrb r2,[r2,#1]
cmp r0,#0x10
bne notright
cmp r1,#0x1D
beq End
beq EndTrampolin
@check if turning towards tail and not growing
ldr r4,=#0x02000000
ldrh r5,[r4,#0xE]
ldrh r6,[r4]
cmp r5,r6
bne growing1
ldrh r5,[r4,#0x20]
ldrh r6,[r4]
lsl r6,#1
add r6,#0x20
sub r6,#2
ldrh r6,[r4,r6]
mov r7,#0x1
add r6,r7
cmp r6,r5
bne growing1
b notright
growing1:
@check if bonk
push {r0-r3}
ldr r3,=bonkSnake
Expand All @@ -90,7 +109,26 @@ notright:
cmp r0,#0x20
bne notleft
cmp r1,#0
beq End
beq EndTrampolin

@check if turning towards tail and not growing
ldr r4,=#0x02000000
ldrh r5,[r4,#0xE]
ldrh r6,[r4]
cmp r5,r6
bne growing2
ldrh r5,[r4,#0x20]
ldrh r6,[r4]
lsl r6,#1
add r6,#0x20
sub r6,#2
ldrh r6,[r4,r6]
mov r7,#0x1
sub r6,r7
cmp r6,r5
bne growing2
b notleft
growing2:
@check if bonk
push {r0-r3}
ldr r3,=bonkSnake
Expand All @@ -108,11 +146,37 @@ sub r0,#1
cmp r0,#1
beq turnBonk
pop {r0-r3}

b noTrampolin
EndTrampolin:
b End
noTrampolin:

notleft:
cmp r0,#0x40
bne notup
cmp r2,#2
beq End

@check if turning towards tail and not growing
ldr r4,=#0x02000000
ldrh r5,[r4,#0xE]
ldrh r6,[r4]
cmp r5,r6
bne growing3
ldrh r5,[r4,#0x20]
ldrh r6,[r4]
lsl r6,#1
add r6,#0x20
sub r6,#2
ldrh r6,[r4,r6]
ldr r7,=#0x100
sub r6,r7
cmp r6,r5
bne growing3
b notup
growing3:

@check if bonk
push {r0-r3}
ldr r3,=bonkSnake
Expand All @@ -135,6 +199,26 @@ cmp r0,#0x80
bne notdown
cmp r2,#0x13
beq End

@check if turning towards tail and not growing
ldr r4,=#0x02000000
ldrh r5,[r4,#0xE]
ldrh r6,[r4]
cmp r5,r6
bne growing4
ldrh r5,[r4,#0x20]
ldrh r6,[r4]
lsl r6,#1
add r6,#0x20
sub r6,#2
ldrh r6,[r4,r6]
ldr r7,=#0x100
add r6,r7
cmp r6,r5
bne growing4
b notdown
growing4:

@check if bonk
push {r0-r3}
ldr r3,=bonkSnake
Expand All @@ -160,6 +244,7 @@ End:
ldr r0,=#0x02000000 @clear button presses
mov r1,#0 @this is to stop the infinite zig-zag the snake does if you hold up/down and left/right and release
strb r1,[r0,#5] @zig-zag can still be performed by holding down both keys, if you really really want to do that
pop {r4-r7}
pop {r0}
bx r0

Expand Down
Binary file modified rom.gba
Binary file not shown.

0 comments on commit 4d31d87

Please sign in to comment.