diff --git a/ASM/Snake/killSnake.elf b/ASM/Snake/killSnake.elf index dc9e51e..ff76b68 100644 Binary files a/ASM/Snake/killSnake.elf and b/ASM/Snake/killSnake.elf differ diff --git a/ASM/Snake/killSnake.s b/ASM/Snake/killSnake.s index 30fdf83..1bc6859 100644 --- a/ASM/Snake/killSnake.s +++ b/ASM/Snake/killSnake.s @@ -1,6 +1,218 @@ .thumb push {lr} +push {r4-r6} + +ldr r6,=drawTile + +@first, figure out which one of the four animations is going to be used, based on snek position +ldr r3,=#0x02000000 +ldrh r2,[r3] +lsl r2,#1 +add r2,#0x20 +sub r2,#2 +ldrb r4,[r3,r2] +add r2,#1 +ldrb r5,[r3,r2] + +@jump to a label based on the snake head position +cmp r4,#0xF +bhi rightSide +cmp r5,#0xC +bhi leftLower +b leftUpper +rightSide: +cmp r5,#0xC +bhi rightLowerTrampolin +b rightUpper + +rightLowerTrampolin: +b rightLower + +leftUpper: +add r5,#1 +mov r0,#1 +ldr r1,=#0x83B +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +add r4,#1 +mov r0,#1 +ldr r1,=#0x83C +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +add r4,#1 +mov r0,#1 +ldr r1,=#0x83D +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +sub r4,#2 +add r5,#1 +mov r0,#1 +ldr r1,=#0x837 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +add r4,#1 +mov r0,#1 +ldr r1,=#0x838 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +add r4,#1 +mov r0,#1 +ldr r1,=#0x839 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +b End + +leftLower: +sub r5,#1 +mov r0,#1 +mov r1,#0x3B +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +add r4,#1 +mov r0,#1 +mov r1,#0x3C +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +add r4,#1 +mov r0,#1 +mov r1,#0x3D +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +sub r4,#2 +sub r5,#1 +mov r0,#1 +mov r1,#0x37 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +add r4,#1 +mov r0,#1 +mov r1,#0x38 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +add r4,#1 +mov r0,#1 +mov r1,#0x39 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +b End + +rightUpper: +add r5,#1 +mov r0,#1 +ldr r1,=#0x846 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +sub r4,#1 +mov r0,#1 +ldr r1,=#0x845 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +sub r4,#1 +mov r0,#1 +ldr r1,=#0x844 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +add r4,#2 +add r5,#1 +mov r0,#1 +ldr r1,=#0x842 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +sub r4,#1 +mov r0,#1 +ldr r1,=#0x841 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +sub r4,#1 +mov r0,#1 +ldr r1,=#0x840 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +b End + +rightLower: +sub r5,#1 +mov r0,#1 +mov r1,#0x46 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +sub r4,#1 +mov r0,#1 +mov r1,#0x45 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +sub r4,#1 +mov r0,#1 +mov r1,#0x44 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +add r4,#2 +sub r5,#1 +mov r0,#1 +mov r1,#0x42 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +sub r4,#1 +mov r0,#1 +mov r1,#0x41 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +sub r4,#1 +mov r0,#1 +mov r1,#0x40 +mov r2,r4 +mov r3,r5 +mov lr,r6 +.short 0xF800 +b End End: +pop {r4-r6} pop {r0} bx r0 diff --git a/ASM/mainLoop.elf b/ASM/mainLoop.elf index 40b12bc..8cd1206 100644 Binary files a/ASM/mainLoop.elf and b/ASM/mainLoop.elf differ diff --git a/ASM/mainLoop.s b/ASM/mainLoop.s index 1f0b0ca..85c87ab 100644 --- a/ASM/mainLoop.s +++ b/ASM/mainLoop.s @@ -46,19 +46,23 @@ ldr r3,=loadData mov lr,r3 .short 0xF800 -@set background 0 and 1 to 16 colors mode -ldr r0,=#0x04000000 -mov r1,#1 -strb r1,[r0,#8] -strb r1,[r0,#10] - @enable all bgs +ldr r0,=#0x04000000 mov r1,#0xF strb r1,[r0,#1] -@lower bg 2 priority +@bg 0 priority +mov r1,#2 +strb r1,[r0,#0x8] +@bg 1 priority +mov r1,#0 +strb r1,[r0,#0xA] +@bg 2 priority mov r1,#3 strb r1,[r0,#0xC] +@bg 3 priority +mov r1,#1 +strb r1,[r0,#0xE] @lower bg 3 y coord a bit mov r1,#0x1E @@ -77,6 +81,30 @@ ldr r3,=loadData mov lr,r3 .short 0xF800 +ldr r0,=snekIMG +ldrh r0,[r0,#2] +lsl r0,#2 +ldr r1,=#0x06000000 +add r1,r0 +ldr r0,=heckIMG +ldr r3,=loadData +mov lr,r3 +.short 0xF800 + +ldr r0,=snekIMG +ldrh r0,[r0,#2] +lsl r0,#2 +ldr r1,=#0x06000000 +add r1,r0 +ldr r0,=heckIMG +ldrh r0,[r0,#2] +lsl r0,#2 +add r1,r0 +ldr r0,=heckmirrorIMG +ldr r3,=loadData +mov lr,r3 +.short 0xF800 + ldr r0,=#0x02000000 mov r1,#8 strb r1,[r0,#3] @speed @@ -164,7 +192,9 @@ ldrb r1,[r0] mov r0,#8 and r0,r1 cmp r0,#0 -beq pauseGame +bne dontpauseGame +b pauseGame +dontpauseGame: ldr r2,=#0x02000000 ldr r3,=#0x04000130 @@ -242,6 +272,12 @@ ldr r0,=moveSnake mov lr,r0 .short 0xF800 +@check for game over +ldr r0,=#0x02000000 +ldrb r3,[r0,#0xD] +cmp r3,#0xFF +beq gameover + ldr r0,=eatEgg mov lr,r0 .short 0xF800 @@ -280,10 +316,61 @@ swi #5 @wait for vblank b main gameover: +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 @death animation ldr r0,=killSnake mov lr,r0 .short 0xF800 +ldr r0,=#0x02000000 +add r0,#0x10 +mov r1,#1 +strb r1,[r0,#1] @set bg 1 to be updated +ldr r0,=copyBuffers +mov lr,r0 +.short 0xF800 +ldr r0,=#0x02000000 +add r0,#0x10 +mov r1,#0 +strb r1,[r0,#1] @set bg 1 to not be updated +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 +swi #5 @back to title screen ldr r0,=fadeOut mov lr,r0 diff --git a/ROM Buildfile.event b/ROM Buildfile.event index 525489c..89feaa6 100644 --- a/ROM Buildfile.event +++ b/ROM Buildfile.event @@ -164,6 +164,16 @@ snekPAL: SHORT 0 8 #incext png2dmp "Graphics\snek.png" --palette-only +ALIGN 4 +heckIMG: +SHORT 0 64 +#incext png2dmp "Graphics\heck.png" + +ALIGN 4 +heckmirrorIMG: +SHORT 0 64 +#incext png2dmp "Graphics\heckmirror.png" + ALIGN 4 titlescreenIMG: SHORT 0 9600 @@ -198,4 +208,3 @@ ALIGN 4 scoreTSA: SHORT 0 32 #incbin "Graphics\score.tsa.bin" - diff --git a/rom.gba b/rom.gba index c01afbc..6274b4d 100644 Binary files a/rom.gba and b/rom.gba differ