diff --git a/ASM/Snake/drawSnake.elf b/ASM/Snake/drawSnake.elf index e24a2a8..b9ff1d6 100644 Binary files a/ASM/Snake/drawSnake.elf and b/ASM/Snake/drawSnake.elf differ diff --git a/ASM/Snake/drawSnake.s b/ASM/Snake/drawSnake.s index 649c87d..1c24ea2 100644 --- a/ASM/Snake/drawSnake.s +++ b/ASM/Snake/drawSnake.s @@ -1,14 +1,48 @@ .thumb push {lr} -push {r4-r6} +push {r4-r7} ldr r4,=#0x02000000 +@erase old tongue if it exists +ldr r0,=bgTilemapsBuffer +ldr r0,[r0] +ldr r1,=#0x500 +add r1,r0 +tongueloop: +cmp r0,r1 +beq donetongue +ldrb r2,[r0] +cmp r2,#1 +beq erasetongue +cmp r2,#6 +beq erasetongue +add r0,#2 +b tongueloop +erasetongue: +mov r2,#0 +strh r2,[r0] +donetongue: +@erase old tail +ldrh r0,[r4,#0x1A] +cmp r0,#0 +beq erasedtail +ldr r3,=drawTile +mov lr,r3 +ldrb r2,[r4,#0x1A] @x +ldrb r3,[r4,#0x1B] @y +mov r1,#0 @attribute +mov r0,#0 @bg layer +.short 0xF800 +erasedtail: ldrh r5,[r4] @size cmp r5,#0 -beq End +bne dontEnd +b End dontEnd: sub r5,#1 lsl r5,#1 +mov r7,r5 +sub r7,#4 @get snake size sneakLoop: @@ -30,6 +64,11 @@ nextEntry: cmp r5,#0 beq End sub r5,#2 +cmp r5,r7 +beq skip +b sneakLoop +skip: +mov r7,r5 b sneakLoop drawTail: @@ -161,6 +200,6 @@ endtongue: b nextEntry End: -pop {r4-r6} +pop {r4-r7} pop {r0} bx r0 diff --git a/ASM/boot.elf b/ASM/boot.elf index cb9e4ff..b2af580 100644 Binary files a/ASM/boot.elf and b/ASM/boot.elf differ diff --git a/ASM/boot.s b/ASM/boot.s index 0856982..055ae68 100644 --- a/ASM/boot.s +++ b/ASM/boot.s @@ -34,9 +34,6 @@ mov r1,#0x10 add r2,#4 strb r1,[r0,r2] @start with a black screen -mov r1,#3 -strb r1,[r0,#1] @turn on bg layers 0 and 1 - @enable timer 0, 1 and 2 ldr r1,=#0x100 ldr r2,=#0xEEDB @@ -58,6 +55,8 @@ 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 +mov r1,#0x1D +strb r1,[r0,#13] @set the offset for the bg map 2 swi #5 diff --git a/ASM/mainLoop.elf b/ASM/mainLoop.elf index 4bb8008..c1c7d1d 100644 Binary files a/ASM/mainLoop.elf and b/ASM/mainLoop.elf differ diff --git a/ASM/mainLoop.s b/ASM/mainLoop.s index 62f56be..8e82b7a 100644 --- a/ASM/mainLoop.s +++ b/ASM/mainLoop.s @@ -16,6 +16,14 @@ ldr r1,[r1,#4] ldr r2,=#0x200 .short 0xF800 +@make the bg2 background +ldr r0,=backgroundgridTSA +ldr r1,=bgTilemaps +ldr r1,[r1,#8] +ldr r3,=loadData +mov lr,r3 +.short 0xF800 + @temporary black border ldr r0,=fillDest mov lr,r0 @@ -30,10 +38,14 @@ ldr r0,=#0x04000000 mov r1,#1 strb r1,[r0,#8] -@disable bg 1 for now -mov r1,#1 +@disable bg 1 for now, enable bg 2 +mov r1,#5 strb r1,[r0,#1] +@lower bg 2 priority +mov r1,#3 +strb r1,[r0,#0xC] + ldr r0,=snekIMG ldr r1,=#0x06000000 ldr r3,=loadData @@ -55,10 +67,12 @@ mov lr,r0 .short 0xF800 ldr r0,=#0x02000000 -add r0,#0x10 +mov r1,#0 +strb r1,[r0,#2] @reset facing direction +strb r1,[r0,#0xD] @reset game state mov r1,#1 -strb r1,[r0] @set bg 0 and 1 to be updated -strb r1,[r0,#1] +strb r1,[r0,#0x10] @set bg 0 and 1 to be updated +strb r1,[r0,#0x11] ldr r0,=drawSnake mov lr,r0 @@ -140,6 +154,11 @@ b skipSnake @skip game logic runSnake: strh r3,[r0,#0x18] @update counter +@check for game over +ldrb r3,[r0,#0xD] +cmp r3,#0xFF +beq gameover + ldr r0,=#0x02000000 add r0,#0x10 mov r1,#1 @@ -170,15 +189,6 @@ ldrb r0,[r0,#0xD] cmp r0,#0xF0 bhi nobg0draw -ldr r0,=fillDest -mov lr,r0 -mov r0,#0 -ldr r1,=bgTilemapsBuffer -ldr r1,[r1] -add r1,#0x80 -ldr r2,=#0x120 -.short 0xF800 - ldr r0,=drawSnake mov lr,r0 .short 0xF800 @@ -194,3 +204,12 @@ b main skipSnake: swi #5 @wait for vblank b main + +gameover: +@back to title screen +ldr r0,=fadeOut +mov lr,r0 +.short 0xF800 +ldr r0,=titlescreenLoop +mov lr,r0 +.short 0xF800 diff --git a/ASM/titlescreenLoop.elf b/ASM/titlescreenLoop.elf index 5e8b2b7..58632d3 100644 Binary files a/ASM/titlescreenLoop.elf and b/ASM/titlescreenLoop.elf differ diff --git a/ASM/titlescreenLoop.s b/ASM/titlescreenLoop.s index 7d5319b..e7034ce 100644 --- a/ASM/titlescreenLoop.s +++ b/ASM/titlescreenLoop.s @@ -1,7 +1,10 @@ .thumb -@set background 0 to 256 colors mode, and change priority ldr r0,=#0x04000000 +mov r1,#3 +strb r1,[r0,#1] @turn on bg layers 0 and 1 + +@set background 0 to 256 colors mode, and change priority mov r1,#0x81 strb r1,[r0,#8] diff --git a/Graphics/backgroundgrid.tsa.bin b/Graphics/backgroundgrid.tsa.bin new file mode 100644 index 0000000..4adf833 Binary files /dev/null and b/Graphics/backgroundgrid.tsa.bin differ diff --git a/Graphics/backgroundgrid.tsa.bin.bak b/Graphics/backgroundgrid.tsa.bin.bak new file mode 100644 index 0000000..b338a99 Binary files /dev/null and b/Graphics/backgroundgrid.tsa.bin.bak differ diff --git a/Graphics/snek.png b/Graphics/snek.png index 4893a9d..f18b75a 100644 Binary files a/Graphics/snek.png and b/Graphics/snek.png differ diff --git a/ROM Buildfile.event b/ROM Buildfile.event index 77cb257..6e53e8d 100644 --- a/ROM Buildfile.event +++ b/ROM Buildfile.event @@ -136,14 +136,14 @@ ALIGN 4 bgTilemapsBuffer: WORD $03000000 WORD $03000800 -WORD $0 +WORD $03001000 WORD $0 ALIGN 4 bgTilemaps: WORD $0600F800 WORD $0600F000 -WORD $0 +WORD $0600E800 WORD $0 ALIGN 4 @@ -181,3 +181,8 @@ presstartTSA: SHORT 0 25 #incbin "Graphics\pressstart.tsa.bin" +ALIGN 4 +backgroundgridTSA: +SHORT 0 320 +#incbin "Graphics\backgroundgrid.tsa.bin" + diff --git a/rom.gba b/rom.gba index 5acff3d..da8a04e 100644 Binary files a/rom.gba and b/rom.gba differ