Skip to content

Commit

Permalink
First version of title screen + general improvements
Browse files Browse the repository at this point in the history
Added a functional title screen, improved snake controls hopefully, added a black border on top, improved egg generation and egg generation speed greatly and added a black bar on the top to avoid confusion until a hud is made.
  • Loading branch information
LeonarthCG committed Aug 14, 2018
1 parent d22fb95 commit 56d489a
Show file tree
Hide file tree
Showing 44 changed files with 530 additions and 132 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.db
Event Assembler/
*.sav
ToDo.txt
Binary file modified ASM/Egg/eatEgg.elf
Binary file not shown.
2 changes: 1 addition & 1 deletion ASM/Egg/eatEgg.s
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bne End
mov r3,#0
strh r3,[r0,#0x6] @destroy egg
ldrh r3,[r0,#0xE]
add r3,#1 @add size
add r3,#4 @add size
strh r3,[r0,#0xE]

End:
Expand Down
Binary file modified ASM/Egg/makeEgg.elf
Binary file not shown.
38 changes: 2 additions & 36 deletions ASM/Egg/makeEgg.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

push {lr}

@check if egg exists
ldr r0,=#0x02000000
ldrh r0,[r0,#6] @egg coords
cmp r0,#0
Expand All @@ -15,42 +16,7 @@ mov r1,#1
and r0,r1
ldr r1,=#0x02000000
add r0,#20
str r0,[r1,#0x14]

@make a list of all tiles that are available
mov r0,#0
mov r1,#2
mov r2,#0 @ammount of tiles in the list*2
b loopnoadd
loop:
add r0,#1
loopnoadd:
cmp r0,#0x1E
bne dontincreasey
mov r0,#0
add r1,#1
dontincreasey:
cmp r1,#0x14
beq endloop
@check if the coords conflict with the body, if they do, do not add them to the list
push {r0-r2}
ldr r2,=bonkSnake
mov lr,r2
.short 0xF800
mov r3,r0
pop {r0-r2}
cmp r3,#1
beq loop
ldr r3,=#0x02005000
strb r0,[r3,r2]
add r2,#1
strb r1,[r3,r2]
add r2,#1
b loop
endloop:

ldr r0,=#0x02000000
strh r2,[r0,#0x16] @save length
strb r0,[r1,#0x14]

@choose a tile from the list
ldr r0,=rng
Expand Down
Binary file added ASM/Egg/makeEggMap.elf
Binary file not shown.
42 changes: 42 additions & 0 deletions ASM/Egg/makeEggMap.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.thumb

push {lr}

@make a list of all tiles that are available
mov r0,#0
mov r1,#2
mov r2,#0 @ammount of tiles in the list*2
b loopnoadd
loop:
add r0,#1
loopnoadd:
cmp r0,#0x1E
bne dontincreasey
mov r0,#0
add r1,#1
dontincreasey:
cmp r1,#0x14
beq endloop
@check if the coords conflict with the body, if they do, do not add them to the list
push {r0-r2}
ldr r2,=bonkSnake
mov lr,r2
.short 0xF800
mov r3,r0
pop {r0-r2}
cmp r3,#1
beq loop
ldr r3,=#0x02005000
strb r0,[r3,r2]
add r2,#1
strb r1,[r3,r2]
add r2,#1
b loop
endloop:

ldr r0,=#0x02000000
strh r2,[r0,#0x16] @save length

End:
pop {r0}
bx r0
Binary file added ASM/Egg/updateEggMap.elf
Binary file not shown.
42 changes: 42 additions & 0 deletions ASM/Egg/updateEggMap.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.thumb
push {lr}

@update egg map
ldr r2,=#0x02000000
ldrh r0,[r2,#0x1A] @previous tail position
ldrh r1,[r2] @size
lsl r1,#1
sub r1,#2
add r1,#0x20
ldrh r1,[r2,r1] @current head position
cmp r0,r1
beq End

@find head position in egg buffer
ldr r3,=#0x02005000
headloop:
ldrh r2,[r3]
cmp r2,r1
beq endheadloop
add r3,#2
b headloop
endheadloop:

cmp r0,#0
bne endremoveloop
removeloop:
ldrh r2,[r3,#2]
strh r2,[r3]
add r3,#2
ldrh r2,[r3]
cmp r2,#0
beq endremoveloop
b removeloop
endremoveloop:

@add the tile the tail was previously in
strh r0,[r3]

End:
pop {r0}
bx r0
Binary file removed ASM/Snake/cleanSnake.elf
Binary file not shown.
17 changes: 0 additions & 17 deletions ASM/Snake/cleanSnake.s

This file was deleted.

Binary file modified ASM/Snake/moveSnake.elf
Binary file not shown.
30 changes: 17 additions & 13 deletions ASM/Snake/moveSnake.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ push {lr}
push {r4,r5}

ldr r4,=#0x02000000
ldrh r0,[r4,#0x20]
strh r0,[r4,#0x1A]
ldrb r0,[r4,#0xD]
cmp r0,#0xF0
bhi EndTrampolin
Expand All @@ -15,15 +17,6 @@ ldr r3,=#540
cmp r0,r3
beq gameOverWinTrampolin

b skipTrampolin
EndTrampolin:
b End
gameOverTrampolin:
b gameOver
gameOverWinTrampolin:
b gameOverWin
skipTrampolin:

mov r3,r5
add r3,#0x20
ldrh r0,[r5]
Expand All @@ -37,25 +30,25 @@ ldrb r3,[r5,#2]
cmp r3,#0
bne dontcheckleft
cmp r1,#0
beq gameOver
beq gameOverTrampolin
dontcheckleft:

cmp r3,#3
bne dontcheckright
cmp r1,#0x1D
beq gameOver
beq gameOverTrampolin
dontcheckright:

cmp r3,#1
bne dontcheckup
cmp r2,#2
beq gameOver
beq gameOverTrampolin
dontcheckup:

cmp r3,#2
bne dontcheckdown
cmp r2,#0x13
beq gameOver
beq gameOverTrampolin
dontcheckdown:

ldrh r0,[r5]
Expand Down Expand Up @@ -88,6 +81,15 @@ ldrb r1,[r4] @head x
ldrb r2,[r4,#1] @head y
ldrb r3,[r5,#2] @facing

b skipTrampolin
EndTrampolin:
b End
gameOverTrampolin:
b gameOver
gameOverWinTrampolin:
b gameOverWin
skipTrampolin:

cmp r3,#0
bne dontmoveleft
cmp r1,#0
Expand Down Expand Up @@ -197,6 +199,8 @@ pop {r0-r3}
strb r1,[r4,r0]
add r0,#1
strb r2,[r4,r0]
mov r0,#0
strh r0,[r4,#0x1A]
b End

End:
Expand Down
Binary file modified ASM/Snake/startSnake.elf
Binary file not shown.
4 changes: 3 additions & 1 deletion ASM/Snake/startSnake.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ sub r0,#1
strh r0,[r1,#2]
sub r0,#1
strh r0,[r1,#4]
sub r0,#1
strh r0,[r1,#6]

@set starting size of snake
mov r0,#3
mov r0,#4
ldr r1,=#0x02000000
strh r0,[r1]
strh r0,[r1,#0xE]
Expand Down
Binary file modified ASM/Snake/turnSnake.elf
Binary file not shown.
10 changes: 10 additions & 0 deletions ASM/Snake/turnSnake.s
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ mov r2,#0xF
add r0,r2
mvn r0,r0

ldr r2,=#0x04000130
ldrb r2,[r2]
mov r3,r2
mvn r2,r2
lsr r3,#4
cmp r3,#0xF
beq nobuttons
mov r0,r2
nobuttons:

@get current facing and remove that and the opposite from the button presses
ldrb r3,[r1,#2]
mov r2,#0x30
Expand Down
Binary file modified ASM/boot.elf
Binary file not shown.
70 changes: 47 additions & 23 deletions ASM/boot.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,61 @@ bx r0
.thumb

toThumb:
ldr r0,=#0x04000200
mov r1,#1
strb r1,[r0,#8] @set Master Interrupt Control to 1, enabling interrupts

ldr r0,=#0x04000200
mov r1,#1
strh r1,[r0] @set first bit of REG_IE (enable irq v-blank)

ldr r0,=#0x04000004
mov r2,#8
strh r2,[r0] @set 3rd bit of DISPSTAT (enable irq v-blank)

ldr r0,=#0x03007FFC
ldr r1,=interrupt
str r1,[r0] @set the interrupt routine

ldr r0,=#0x04000000
mov r1,#0
strb r1,[r0]
strb r1,[r0] @set video mode

mov r1,#1
strb r1,[r0,#1]
mov r1,#0xFF
mov r2,#0x50
strb r1,[r0,r2] @activate bg blending

@enable timer
ldr r1,=#0x102
mov r2,#0x83
strb r2,[r0,r1]
mov r1,#0x10
add r2,#4
strb r1,[r0,r2] @start with a black screen

@set background 0 to 256 colors mode
@mov r1,#0x80
@strb r1,[r0,#8]
mov r1,#3
strb r1,[r0,#1] @turn on bg layers 0 and 1

mov r1,#0x1F
strb r1,[r0,#9]
@enable timer 0, 1 and 2
ldr r1,=#0x100
ldr r2,=#0xEEDB
strh r2,[r0,r1] @start time for counter 0, 4389 until overflow
add r1,#2
mov r2,#0x81
strh r2,[r0,r1] @speed = 16.78MHz/64
add r1,#2
mov r2,#0x84
add r1,#2
strh r2,[r0,r1] @count up when the previous one overflows
@this, if my math is right, should be 16.78MHz/64/4389 = 59.73Hz, the refresh rate of the console
add r1,#4
mov r2,#0x80
strh r2,[r0,r1] @used for the first rng seed

ldr r0,=snekIMG
ldr r1,=#0x06000000
ldr r3,=loadData
mov lr,r3
.short 0xF800
@set the offset for the bg map
mov r1,#0x1F
strb r1,[r0,#9] @set the offset for the bg map 0
mov r1,#0x1E
strb r1,[r0,#11] @set the offset for the bg map 1

ldr r0,=snekPAL
ldr r1,=#0x05000000
ldr r3,=loadData
mov lr,r3
.short 0xF800
swi #5

ldr r0,=mainLoop
ldr r0,=titlescreenLoop
mov lr,r0
.short 0xF800
Binary file modified ASM/copyBuffers.elf
Binary file not shown.
2 changes: 1 addition & 1 deletion ASM/copyBuffers.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ loop1:
mov r6,r7
lsl r6,#2
mov r2,#0
ldr r3,=#0x5000
ldr r3,=#0x500
ldr r0,=#0x02000000
add r0,#0x10
ldrb r0,[r0,r7]
Expand Down
Binary file added ASM/fadeIn.elf
Binary file not shown.
Loading

0 comments on commit 56d489a

Please sign in to comment.