Skip to content

Commit

Permalink
Speed options
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonarthCG committed Aug 21, 2018
1 parent a2c0077 commit 19d4f07
Show file tree
Hide file tree
Showing 17 changed files with 229 additions and 10 deletions.
Binary file modified ASM/boot.elf
Binary file not shown.
3 changes: 2 additions & 1 deletion ASM/boot.s
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ bne dontset0
mov r1,#0
strb r1,[r0]
strb r1,[r0,#1]
strb r1,[r0,#2]
strb r1,[r0,#3]
mov r1,#1
strb r1,[r0,#2]
dontset0:

swi #5
Expand Down
Binary file added ASM/changeSpeed.elf
Binary file not shown.
112 changes: 112 additions & 0 deletions ASM/changeSpeed.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
.thumb
push {lr}

@if no buttons are being pressed, unset the holding byte and draw speed
ldr r3,=#0x04000130
ldrb r3,[r3]
mov r2,#0x30
and r2,r3
cmp r2,#0x10
beq buttons
cmp r2,#0x20
beq buttons
b resetCounter
buttons:

@check the counter and if it was reached unset the holding byte
ldr r3,=#0x02000000
ldrb r2,[r3]
cmp r2,#17
blo dontUnset
mov r2,#0
strb r2,[r3]
strb r2,[r3,#1]
dontUnset:

@save button being pressed, unless holding byte is set
ldr r3,=#0x02000000
ldrb r2,[r3,#1]
cmp r2,#0
bne getSpeed
ldr r1,=#0x04000130
ldrb r1,[r1]
mov r2,#0x30
and r2,r1
cmp r2,#0
beq getSpeed
strb r2,[r3,#2]
strb r2,[r3,#1]

@change to the appropiate speed if possible
getSpeed:
ldr r3,=#0x0E000000
ldrb r0,[r3,#2]
ldr r1,=#0x02000000
ldrb r3,[r1]
cmp r3,#0
bne End
ldrb r3,[r1,#2]
cmp r3,#0x10
bne higher
cmp r0,#0
beq drawSpeed
sub r0,#1
b drawSpeed
higher:
cmp r0,#3
beq drawSpeed
add r0,#1
b drawSpeed

drawSpeed:
push {r0}
lsl r0,#2
ldr r2,=speedTSAs
ldr r0,[r0,r2]
ldr r1,=bgTilemaps
ldr r2,=#0x3CC
add r1,r2
ldr r3,=loadData
mov lr,r3
.short 0xF800
pop {r0}

End:
@change the speed in the save
ldr r3,=#0x0E000000
strb r0,[r3,#2]

@draw the speed
ldr r1,=speedTSAs
lsl r0,#2
ldr r0,[r1,r0]
ldr r1,=bgTilemaps
ldr r1,[r1,#8]
ldr r2,=#0x3CC
add r1,r2
ldr r3,=loadData
mov lr,r3
.short 0xF800

@add to counter if holding byte is set
ldr r3,=#0x02000000
ldrb r2,[r3,#1]
cmp r2,#0
beq noHolding
ldrb r2,[r3]
add r2,#1
strb r2,[r3]

noHolding:
pop {r0}
bx r0

resetCounter:
ldr r3,=#0x02000000
mov r2,#0
strb r2,[r3]
strb r2,[r3,#1]
strb r2,[r3,#2]
ldr r3,=#0x0E000000
ldrb r0,[r3,#2]
b End
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 @@ -24,9 +24,9 @@ beq next
loop2:
ldr r6,[r0,r2]
str r6,[r1,r2]
add r2,#4
cmp r2,r3
beq next
add r2,#4
b loop2
next:
add r7,#1
Expand Down
Binary file modified ASM/mainLoop.elf
Binary file not shown.
18 changes: 17 additions & 1 deletion ASM/mainLoop.s
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ ldr r1,[r1,#4]
ldr r2,=#0x200
.short 0xF800

ldr r0,=fillDest
mov lr,r0
mov r0,#0
ldr r1,=bgTilemaps
ldr r1,[r1,#12]
ldr r2,=#0x200
.short 0xF800

ldr r0,=fillDest
mov lr,r0
mov r0,#0
Expand Down Expand Up @@ -69,6 +77,10 @@ mov r1,#0x1E
ldr r2,=#0xFFFD
strh r2,[r0,r1]

@move bg 2 to the center
mov r1,#0
strh r1,[r0,#0x18]

ldr r0,=snekIMG
ldr r1,=#0x06000000
ldr r3,=loadData
Expand Down Expand Up @@ -105,8 +117,12 @@ ldr r3,=loadData
mov lr,r3
.short 0xF800

@change speed
ldr r0,=#0x02000000
mov r1,#8
ldr r1,=#0x0E000000
ldrb r1,[r1,#2]
ldr r2,=speedSpeeds
ldrb r1,[r2,r1]
strb r1,[r0,#3] @speed

ldr r0,=startSnake
Expand Down
Binary file modified ASM/titlescreenLoop.elf
Binary file not shown.
61 changes: 54 additions & 7 deletions ASM/titlescreenLoop.s
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
.thumb

@reset ram
ldr r0,=fillDest
mov lr,r0
mov r0,#0 @value to fill with
ldr r1,=#0x02000000 @destination
ldr r2,=#0x20 @size in words
.short 0xF800

@turn on bg layers
ldr r0,=#0x04000000
mov r1,#3
strb r1,[r0,#1] @turn on bg layers 0 and 1
mov r1,#0xF
strb r1,[r0,#1]

@set background 0 to 256 colors mode, and change priority
mov r1,#0x81
strb r1,[r0,#8]


@set background 1 starting tile block
@set background 1, 2 and 3 starting tile block
ldr r0,=#0x04000000
mov r1,#0x08
strb r1,[r0,#10]
strb r1,[r0,#12]
strb r1,[r0,#14]

@move bg 2 to the right
ldr r1,=#0xFFFC
strh r1,[r0,#0x18]

ldr r0,=titlescreenIMG
ldr r1,=#0x06000000
Expand All @@ -39,6 +53,16 @@ ldr r3,=loadData
mov lr,r3
.short 0xF800

ldr r0,=presstartIMG
ldrh r0,[r0,#2]
lsl r0,#2
ldr r1,=#0x06009800
add r1,r0
ldr r0,=speedIMG
ldr r3,=loadData
mov lr,r3
.short 0xF800

ldr r0,=fillDest
mov lr,r0
ldr r0,=#0x00C000C0
Expand All @@ -47,15 +71,35 @@ ldr r1,[r1,#4]
ldr r2,=#0x200
.short 0xF800

ldr r0,=fillDest
mov lr,r0
ldr r0,=#0x00C000C0
ldr r1,=bgTilemaps
ldr r1,[r1,#8]
ldr r2,=#0x200
.short 0xF800

ldr r0,=fillDest
mov lr,r0
ldr r0,=#0x00C000C0
ldr r1,=bgTilemaps
ldr r1,[r1,#12]
ldr r2,=#0x200
.short 0xF800

ldr r0,=presstartTSA
ldr r1,=bgTilemaps
ldr r1,[r1,#4]
ldr r2,=#0x38C
ldr r2,=#0x34C
add r1,r2
ldr r3,=loadData
mov lr,r3
.short 0xF800

ldr r0,=changeSpeed
mov lr,r0
.short 0xF800

ldr r0,=fadeIn
mov lr,r0
.short 0xF800
Expand All @@ -66,6 +110,9 @@ strh r1,[r0,#0x18]

titlescreen:
swi #5
ldr r0,=changeSpeed
mov lr,r0
.short 0xF800
@check if the press start should turn on/off
ldr r0,=#0x02000000
ldrh r2,[r0,#0x18]
Expand All @@ -78,10 +125,10 @@ ldrb r3,[r1,#1]
and r3,r2
cmp r3,#2
beq setnodisplay
mov r2,#3
mov r2,#0xF
b afterjump
setnodisplay:
mov r2,#1
mov r2,#0xD
afterjump:
strb r2,[r1,#1]
mov r2,#0
Expand Down
Binary file added Graphics/fast.tsa.bin
Binary file not shown.
Binary file added Graphics/normal.tsa.bin
Binary file not shown.
Binary file added Graphics/slow.tsa.bin
Binary file not shown.
Binary file added Graphics/speed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Graphics/tas.tsa.bin
Binary file not shown.
43 changes: 43 additions & 0 deletions ROM Buildfile.event
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ ALIGN 4
makeTileAttribute:
#inctext lyn "ASM\makeTileAttribute.elf" //piece together the short for the tile based on the attributes

ALIGN 4
changeSpeed:
#inctext lyn "ASM\changeSpeed.elf" //draws speed option to titlescreen and handles changing between options

ALIGN 4
loadData:
#inctext lyn "ASM\loadData.elf" //load data from source to destination
Expand Down Expand Up @@ -154,6 +158,20 @@ WORD $0600F000
WORD $0600E800
WORD $0600E000

ALIGN 4
speedTSAs:
POIN slowTSA
POIN normalTSA
POIN fastTSA
POIN tasTSA

ALIGN 4
speedSpeeds:
BYTE 16
BYTE 8
BYTE 4
BYTE 1

ALIGN 4
snekIMG:
SHORT 0 440
Expand Down Expand Up @@ -194,11 +212,36 @@ presstartIMG:
SHORT 0 256
#incext png2dmp "Graphics\pressstart.png"

ALIGN 4
speedIMG:
SHORT 0 416
#incext png2dmp "Graphics\speed.png"

ALIGN 4
presstartTSA:
SHORT 0 25
#incbin "Graphics\pressstart.tsa.bin"

ALIGN 4
slowTSA:
SHORT 0 25
#incbin "Graphics\slow.tsa.bin"

ALIGN 4
normalTSA:
SHORT 0 25
#incbin "Graphics\normal.tsa.bin"

ALIGN 4
fastTSA:
SHORT 0 25
#incbin "Graphics\fast.tsa.bin"

ALIGN 4
tasTSA:
SHORT 0 25
#incbin "Graphics\tas.tsa.bin"

ALIGN 4
backgroundgridTSA:
SHORT 0 320
Expand Down
Binary file modified rom.gba
Binary file not shown.

0 comments on commit 19d4f07

Please sign in to comment.