From c1cd053a08476f45d923806ea6772c33f00a7c15 Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Sun, 24 Oct 2021 16:47:51 +0100 Subject: [PATCH 01/15] Start final tile draw routine in seperate file --- makefile | 2 +- src/batman.asm | 2 ++ src/tiles.asm | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/tiles.asm diff --git a/makefile b/makefile index ea6adbb..003f02e 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,7 @@ ARCULATOR = ../../sarah-walker-pcem/arculator/hostfs all: build/batman -build/batman: src/batman.asm build/level-1.bin build/main_title.bin build/intro_screen.bin build/intro_font.bin build/status_bar.bin build/palette_fade.bin build/level_1_map.asm +build/batman: src/batman.asm src/tiles.asm build/level-1.bin build/main_title.bin build/intro_screen.bin build/intro_font.bin build/status_bar.bin build/palette_fade.bin build/level_1_map.asm vasmarm_std src/batman.asm -a2 -m2 -opt-ldrpc -opt-adr -L build/batman.lst -Fbin -o build/batman build/level-1.bin: build/level-1.asm diff --git a/src/batman.asm b/src/batman.asm index ab2c672..374af7a 100644 --- a/src/batman.asm +++ b/src/batman.asm @@ -33,6 +33,8 @@ stack: .include "vdu.asm" .include "macros.asm" +.include "tiles.asm" + ; **************************************************************** ; set_display_start diff --git a/src/tiles.asm b/src/tiles.asm new file mode 100644 index 0000000..54b20b3 --- /dev/null +++ b/src/tiles.asm @@ -0,0 +1,77 @@ +; **************************************************************** +; tiles.asm +; ---------------------------------------------------------------- +; Copyright (c) 2021 Scott Moore, all rights reserved. +; **************************************************************** + +; **************************************************************** +; Constants +; ---------------------------------------------------------------- +; Define constants used in this file and calling functions. +; **************************************************************** + +.set CLIP_TOP, 0 +.set CLIP_BOTTOM, 256 +.set CLIP_LEFT, 0 +.set CLIP_RIGHT, 320 + +; **************************************************************** +; draw_16x16_tile +; ---------------------------------------------------------------- +; Copy a 16x16 tile to the screen or display buffer, source +; address must be word aligned. +; ---------------------------------------------------------------- +; Parameters +; ---------------------------------------------------------------- +; R0 : number of the 16x16 tile in the tileset +; R1 : address of the tileset +; R2 : x coordinate to copy the tile to +; R3 : y coordinate to copy the tile to +; R4 : address of the screen or display buffer +; R5 : N/A +; R6 : N/A +; R7 : N/A +; R8 : N/A +; R9 : N/A +; R10 : N/A +; R11 : N/A +; R11 : N/A +; ---------------------------------------------------------------- +; Returns +; ---------------------------------------------------------------- +; R0 : Unchanged +; R1 : Unchanged +; R2 : Unchanged +; R3 : Unchanged +; R4 : Unchanged +; R5 : Unchanged +; R6 : Unchanged +; R7 : Unchanged +; R8 : Unchanged +; R9 : Unchanged +; R10 : Unchanged +; R11 : Unchanged +; R11 : Unchanged +; **************************************************************** +draw_16x16_tile: + + STMFD SP!, {R0-R12} ; store all the registers on the stack + + CMP R3,#CLIP_TOP + 16 + BLT draw_16x16_tile_clipped_top + CMP R3,#CLIP_BOTTOM - 16 + BGT draw_16x16_tile_clipped_bottom + CMP R2,#CLIP_LEFT + 16 + BLT draw_16x16_tile_clipped_left + CMP R2,#CLIP_TOP - 16 + BGT draw_16x16_tile_clipped_right + +draw_16x16_tile_clipped_top: +draw_16x16_tile_clipped_bottom: +draw_16x16_tile_clipped_left: +draw_16x16_tile_clipped_right: +draw_16x16_tile_exit: ; exit function code + + LDMFD SP!, {R0-R12} ; restore all the registers from the stack + MOV PC,R14 ; return from function + From bc75dc807af28d86636a6802231a19b59a88d00c Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Sun, 24 Oct 2021 19:54:27 +0100 Subject: [PATCH 02/15] Check for all clipping possibilities --- src/tiles.asm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/tiles.asm b/src/tiles.asm index 54b20b3..2cd0d07 100644 --- a/src/tiles.asm +++ b/src/tiles.asm @@ -67,9 +67,38 @@ draw_16x16_tile: BGT draw_16x16_tile_clipped_right draw_16x16_tile_clipped_top: + CMP R3,#CLIP_TOP - 16 + BLE draw_16x16_tile_exit + CMP R2,#CLIP_LEFT + 16 + BLT draw_16x16_tile_clipped_top_left + CMP R2,#CLIP_TOP - 16 + BGT draw_16x16_tile_clipped_top_right + + +draw_16x16_tile_clipped_top_left: + +draw_16x16_tile_clipped_top_right: + draw_16x16_tile_clipped_bottom: + CMP R3,#CLIP_BOTTOM + 16 + BGE draw_16x16_tile_exit + CMP R2,#CLIP_LEFT + 16 + BLT draw_16x16_tile_clipped_bottom_left + CMP R2,#CLIP_TOP - 16 + BGT draw_16x16_tile_clipped_bottom_right + +draw_16x16_tile_clipped_bottom_left: + +draw_16x16_tile_clipped_bottom_right: + draw_16x16_tile_clipped_left: + CMP R2,#CLIP_LEFT - 16 + BLE draw_16x16_tile_clipped_right + draw_16x16_tile_clipped_right: + CMP R2,#CLIP_RIGHT + 16 + BGE draw_16x16_tile_clipped_right + draw_16x16_tile_exit: ; exit function code LDMFD SP!, {R0-R12} ; restore all the registers from the stack From 8af5bdcf483f9e672fe7cf45b6be666b7bee1cd1 Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Sun, 24 Oct 2021 20:17:43 +0100 Subject: [PATCH 03/15] Add code to draw pixel aligned unclipped tile --- src/batman.asm | 28 +-- src/tiles.asm | 559 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 568 insertions(+), 19 deletions(-) diff --git a/src/batman.asm b/src/batman.asm index 374af7a..3267991 100644 --- a/src/batman.asm +++ b/src/batman.asm @@ -440,7 +440,7 @@ copy_16x16_tile_to_screen: STMFD SP!, {R0-R12} ; store all the registers on the stack - AND R8,R2,#0b11 ; get 4 pixel x coordinate offset and set status flags + AND R8,R2,#0b11 ; get 4 pixel x coordinate offset MOV R7,#16*16*4 ; put the size of a single tile in bytes into R7 MLA R12,R0,R7,R1 ; calculate the address of the start of the tile [source = (tile number * (16 * 16)) + address of tileset] ADD R12,R12,R8,LSL #8 ; add 4 pixel x coordinate offset * (16*16) to get pre-shifted tile @@ -2058,39 +2058,39 @@ main_draw_tile_map_loop: MOV R0,#70 ADRL R1,level_1_tiles LDR R4,[R12] - MOV R5,#0 - MOV R6,#0 - MOV R7,#0 - MOV R8,#0 + ; MOV R5,#0 + ; MOV R6,#0 + ; MOV R7,#0 + ; MOV R8,#0 VDU 19,0,24,0,240,0,-1,-1,-1,-1 - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R0,R0,#1 ADD R2,R2,#16 - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R0,R0,#1 ADD R2,R2,#16 - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R0,R0,#16-2 SUB R2,R2,#32 ADD R3,R3,#16 - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R0,R0,#1 ADD R2,R2,#16 - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R0,R0,#1 ADD R2,R2,#16 - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R0,R0,#16-2 SUB R2,R2,#32 ADD R3,R3,#16 - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R0,R0,#1 ADD R2,R2,#16 - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R0,R0,#1 ADD R2,R2,#16 - BL copy_16x16_tile_to_screen + BL draw_16x16_tile VDU 19,0,24,0,0,0,-1,-1,-1,-1 LDMFD SP!, {R0-R8} diff --git a/src/tiles.asm b/src/tiles.asm index 2cd0d07..d027a89 100644 --- a/src/tiles.asm +++ b/src/tiles.asm @@ -54,18 +54,558 @@ ; R11 : Unchanged ; **************************************************************** draw_16x16_tile: - STMFD SP!, {R0-R12} ; store all the registers on the stack - CMP R3,#CLIP_TOP + 16 + CMP R3,#CLIP_TOP BLT draw_16x16_tile_clipped_top CMP R3,#CLIP_BOTTOM - 16 BGT draw_16x16_tile_clipped_bottom - CMP R2,#CLIP_LEFT + 16 + CMP R2,#CLIP_LEFT BLT draw_16x16_tile_clipped_left - CMP R2,#CLIP_TOP - 16 + CMP R2,#CLIP_RIGHT - 16 BGT draw_16x16_tile_clipped_right +draw_16x16_tile_unclipped: + AND R8,R2,#0b11 ; get 4 pixel x coordinate offset + MOV R7,#16*16*4 ; put the size of a single tile in bytes into R7 + MLA R12,R0,R7,R1 ; calculate the address of the start of the tile [source = (tile number * (16 * 16)) + address of tileset] + ADD R12,R12,R8,LSL #8 ; add 4 pixel x coordinate offset * (16*16) to get pre-shifted tile + MOV R7,#320 ; put the width of a scanline into R7 + MLA R11,R3,R7,R4 ; calculate the address of the destination [destination = (y * 320) + address of screen or buffer] + ADD R11,R11,R2 ; add x to the destination address + + CMP R8,#0b00 + BEQ draw_16x16_tile_unclipped_00 + CMP R8,#0b01 + BEQ draw_16x16_tile_unclipped_01 + CMP R8,#0b10 + BEQ draw_16x16_tile_unclipped_10 + CMP R8,#0b11 + BEQ draw_16x16_tile_unclipped_11 + +draw_16x16_tile_unclipped_00: + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it + + B draw_16x16_tile_exit + +draw_16x16_tile_unclipped_01: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address + + B draw_16x16_tile_exit + +draw_16x16_tile_unclipped_10: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + B draw_16x16_tile_exit + +draw_16x16_tile_unclipped_11: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + B draw_16x16_tile_exit + draw_16x16_tile_clipped_top: CMP R3,#CLIP_TOP - 16 BLE draw_16x16_tile_exit @@ -74,10 +614,13 @@ draw_16x16_tile_clipped_top: CMP R2,#CLIP_TOP - 16 BGT draw_16x16_tile_clipped_top_right + B draw_16x16_tile_exit draw_16x16_tile_clipped_top_left: + B draw_16x16_tile_exit draw_16x16_tile_clipped_top_right: + B draw_16x16_tile_exit draw_16x16_tile_clipped_bottom: CMP R3,#CLIP_BOTTOM + 16 @@ -87,17 +630,23 @@ draw_16x16_tile_clipped_bottom: CMP R2,#CLIP_TOP - 16 BGT draw_16x16_tile_clipped_bottom_right + B draw_16x16_tile_exit + draw_16x16_tile_clipped_bottom_left: + B draw_16x16_tile_exit draw_16x16_tile_clipped_bottom_right: + B draw_16x16_tile_exit draw_16x16_tile_clipped_left: CMP R2,#CLIP_LEFT - 16 BLE draw_16x16_tile_clipped_right + B draw_16x16_tile_exit + draw_16x16_tile_clipped_right: CMP R2,#CLIP_RIGHT + 16 - BGE draw_16x16_tile_clipped_right + BGE draw_16x16_tile_exit draw_16x16_tile_exit: ; exit function code From 3e55c4133b943e1f1368eea70cd20cb76cfb798f Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Sun, 24 Oct 2021 23:19:16 +0100 Subject: [PATCH 04/15] Change clipping values to prevent drawing over status display --- src/batman.asm | 10 ++++------ src/tiles.asm | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/batman.asm b/src/batman.asm index 3267991..609d0d3 100644 --- a/src/batman.asm +++ b/src/batman.asm @@ -1804,7 +1804,7 @@ draw_tile_map_loop: MOV R2,R7 ADD R3,R3,#16 ADD R10,R10,#128 - CMP R3,#160 + CMP R3,#192 BLE draw_tile_map_loop LDMFD SP!, {R6} @@ -2024,7 +2024,7 @@ main_draw_tile_map: ADRL R0,status_bar LDR R1,[R12] - MOV R2,#176 + MOV R2,#208 MOV R3,#320 MLA R1,R2,R3,R1 MOV R2,#48 @@ -2053,15 +2053,13 @@ main_draw_tile_map_loop: SWI OS_Mouse MOV R2,R0,LSR #2 + SUB R2,R2,#24 MOV R3,R1,LSR #2 EOR R3,R3,#0b11111111 + SUB R3,R3,#24 MOV R0,#70 ADRL R1,level_1_tiles LDR R4,[R12] - ; MOV R5,#0 - ; MOV R6,#0 - ; MOV R7,#0 - ; MOV R8,#0 VDU 19,0,24,0,240,0,-1,-1,-1,-1 BL draw_16x16_tile diff --git a/src/tiles.asm b/src/tiles.asm index d027a89..b544134 100644 --- a/src/tiles.asm +++ b/src/tiles.asm @@ -11,7 +11,7 @@ ; **************************************************************** .set CLIP_TOP, 0 -.set CLIP_BOTTOM, 256 +.set CLIP_BOTTOM, 208 .set CLIP_LEFT, 0 .set CLIP_RIGHT, 320 From b7616d2b678e130a2308f29aa0dbae90533a0559 Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Sun, 24 Oct 2021 23:23:30 +0100 Subject: [PATCH 05/15] Change tile map drawing to use new draw_16x16_tile function --- src/batman.asm | 126 ++++++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/batman.asm b/src/batman.asm index 609d0d3..01c6a71 100644 --- a/src/batman.asm +++ b/src/batman.asm @@ -1677,64 +1677,64 @@ draw_tile_map: draw_tile_map_cropped_top_row: LDRB R0,[R10] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#1] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#2] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#3] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#4] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#5] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#6] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#7] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#8] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#9] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#10] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#11] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#12] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#13] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#14] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#15] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#16] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#17] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#18] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#19] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile MOV R2,R7 ADD R3,R3,#16 SUB R3,R3,R5 @@ -1743,64 +1743,64 @@ draw_tile_map_cropped_top_row: draw_tile_map_loop: LDRB R0,[R10] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#1] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#2] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#3] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#4] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#5] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#6] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#7] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#8] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#9] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#10] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#11] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#12] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#13] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#14] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#15] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#16] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#17] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#18] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#19] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile MOV R2,R7 ADD R3,R3,#16 ADD R10,R10,#128 @@ -1813,64 +1813,64 @@ draw_tile_map_loop: draw_tile_map_cropped_bottom_row: LDRB R0,[R10] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#1] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#2] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#3] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#4] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#5] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#6] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#7] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#8] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#9] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#10] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#11] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#12] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#13] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#14] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#15] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#16] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#17] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#18] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile ADD R2,R2,#16 LDRB R0,[R10,#19] - BL copy_16x16_tile_to_screen + BL draw_16x16_tile draw_tile_map_exit: ; exit loop @@ -2041,9 +2041,9 @@ main_draw_tile_map_loop: VDU 19,0,24,0,0,0,-1,-1,-1,-1 - ; ADD R4,R4,#1 - ; CMP R4,#29*16 - ; MOVEQ R4,#0 + ADD R4,R4,#1 + CMP R4,#29*16 + MOVEQ R4,#0 ADD R3,R3,#1 CMP R3,#102*16 SUBEQ R3,R3,#102*16 From 8ca711bb70e31ff0cc97e3482a79208dedb0e97f Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Mon, 25 Oct 2021 16:34:25 +0100 Subject: [PATCH 06/15] Comment all of tile.asm --- src/batman.asm | 163 ++++--------------------------------------- src/tiles.asm | 186 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 155 insertions(+), 194 deletions(-) diff --git a/src/batman.asm b/src/batman.asm index 01c6a71..439e003 100644 --- a/src/batman.asm +++ b/src/batman.asm @@ -1658,88 +1658,18 @@ draw_tile_map: STMFD SP!, {R0-R12,R14} ; store all registers onto the stack - AND R7,R3,#0b1111 ; get pixel in tile to start from - AND R5,R4,#0b1111 ; get scanline in tile to start from + AND R5,R3,#0b1111 ; get pixel in tile to start from + AND R6,R4,#0b1111 ; get scanline in tile to start from MOV R3,R3,LSR #4 ; divide tilemap x coordinate by 16 MOV R4,R4,LSR #4 ; divide tilemap y coordinate by 16 - MOV R9,#128 ; move width of tilemap into R5 - MLA R10,R4,R9,R0 ; calculate top left of tilemap to draw from (source = (y * 128) + tilemap_address) - ADD R10,R10,R3 ; add x tile to start from to tilemap source address + MOV R7,#128 ; move width of tilemap into R5 + MLA R10,R4,R7,R0 ; calculate top left of tilemap to draw from (source = (y * 128) + tilemap_address) + ADD R10,R10,R3 ; add x tile to start from to tilemap source address MOV R4,R2 - EOR R7,R7,#0b1111 - MOV R2,R7 - MOV R3,#0 - MOV R6,#0 - STMFD SP!, {R5} - CMP R5,#0 - BEQ draw_tile_map_loop - -draw_tile_map_cropped_top_row: - LDRB R0,[R10] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#1] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#2] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#3] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#4] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#5] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#6] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#7] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#8] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#9] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#10] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#11] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#12] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#13] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#14] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#15] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#16] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#17] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#18] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#19] - BL draw_16x16_tile - MOV R2,R7 - ADD R3,R3,#16 - SUB R3,R3,R5 - ADD R10,R10,#128 - MOV R5,#0 + MOV R7,#0 + SUB R2,R7,R5 + SUB R3,R7,R6 draw_tile_map_loop: LDRB R0,[R10] @@ -1801,77 +1731,12 @@ draw_tile_map_loop: ADD R2,R2,#16 LDRB R0,[R10,#19] BL draw_16x16_tile - MOV R2,R7 + SUB R2,R2,#320-16 ADD R3,R3,#16 ADD R10,R10,#128 - CMP R3,#192 + CMP R3,#208 BLE draw_tile_map_loop - LDMFD SP!, {R6} - CMP R6,#0 - BEQ draw_tile_map_exit -draw_tile_map_cropped_bottom_row: - - LDRB R0,[R10] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#1] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#2] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#3] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#4] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#5] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#6] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#7] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#8] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#9] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#10] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#11] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#12] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#13] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#14] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#15] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#16] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#17] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#18] - BL draw_16x16_tile - ADD R2,R2,#16 - LDRB R0,[R10,#19] - BL draw_16x16_tile - draw_tile_map_exit: ; exit loop LDMFD SP!, {R0-R12,R14} ; restore all registers from the stack, including R14 Link registger @@ -2039,7 +1904,7 @@ main_draw_tile_map_loop: BL draw_tile_map - VDU 19,0,24,0,0,0,-1,-1,-1,-1 + ; VDU 19,0,24,0,0,0,-1,-1,-1,-1 ADD R4,R4,#1 CMP R4,#29*16 @@ -2061,7 +1926,7 @@ main_draw_tile_map_loop: ADRL R1,level_1_tiles LDR R4,[R12] - VDU 19,0,24,0,240,0,-1,-1,-1,-1 + ; VDU 19,0,24,0,240,0,-1,-1,-1,-1 BL draw_16x16_tile ADD R0,R0,#1 ADD R2,R2,#16 @@ -2089,14 +1954,14 @@ main_draw_tile_map_loop: ADD R0,R0,#1 ADD R2,R2,#16 BL draw_16x16_tile - VDU 19,0,24,0,0,0,-1,-1,-1,-1 + ; VDU 19,0,24,0,0,0,-1,-1,-1,-1 LDMFD SP!, {R0-R8} MOV R0,#19 SWI OS_Byte BL swap_display_buffers - VDU 19,0,24,0,0,240,-1,-1,-1,-1 + ; VDU 19,0,24,0,0,240,-1,-1,-1,-1 B main_draw_tile_map_loop exit: diff --git a/src/tiles.asm b/src/tiles.asm index b544134..50fc118 100644 --- a/src/tiles.asm +++ b/src/tiles.asm @@ -56,14 +56,14 @@ draw_16x16_tile: STMFD SP!, {R0-R12} ; store all the registers on the stack - CMP R3,#CLIP_TOP - BLT draw_16x16_tile_clipped_top - CMP R3,#CLIP_BOTTOM - 16 - BGT draw_16x16_tile_clipped_bottom - CMP R2,#CLIP_LEFT - BLT draw_16x16_tile_clipped_left - CMP R2,#CLIP_RIGHT - 16 - BGT draw_16x16_tile_clipped_right + CMP R3,#CLIP_TOP ; check to see if y coordinate is + BLT draw_16x16_tile_clipped_top ; less than the top clip line + CMP R3,#CLIP_BOTTOM - 16 ; check to see if y coordinate is + BGT draw_16x16_tile_clipped_bottom ; greater than the bottom clip line + CMP R2,#CLIP_LEFT ; check to see if x coordinate is + BLT draw_16x16_tile_clipped_left ; less than the left clip pixel + CMP R2,#CLIP_RIGHT - 16 ; check to see if x coordinate is + BGT draw_16x16_tile_clipped_right ; greater than the right clip pixel draw_16x16_tile_unclipped: AND R8,R2,#0b11 ; get 4 pixel x coordinate offset @@ -74,14 +74,14 @@ draw_16x16_tile_unclipped: MLA R11,R3,R7,R4 ; calculate the address of the destination [destination = (y * 320) + address of screen or buffer] ADD R11,R11,R2 ; add x to the destination address - CMP R8,#0b00 - BEQ draw_16x16_tile_unclipped_00 - CMP R8,#0b01 - BEQ draw_16x16_tile_unclipped_01 - CMP R8,#0b10 - BEQ draw_16x16_tile_unclipped_10 - CMP R8,#0b11 - BEQ draw_16x16_tile_unclipped_11 + CMP R8,#0b00 ; check if x coordinate is word aligned + BEQ draw_16x16_tile_unclipped_00 ; if so, call word aligned draw function + CMP R8,#0b01 ; check if x coordinate is aligned with byte 1 + BEQ draw_16x16_tile_unclipped_01 ; if so, call byte 1 aligned draw function + CMP R8,#0b10 ; check if x coordinate is aligned with byte 2 + BEQ draw_16x16_tile_unclipped_10 ; if so, call byte 2 aligned draw function + CMP R8,#0b11 ; check if x coordinate is aligned with byte 3 + BEQ draw_16x16_tile_unclipped_11 ; if so, call byte 3 aligned draw function draw_16x16_tile_unclipped_00: LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 @@ -132,7 +132,7 @@ draw_16x16_tile_unclipped_00: LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 STMIA R11,{R0-R3} ; store 16 bytes from R0-R3 to the destination address with incrementing it - B draw_16x16_tile_exit + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_unclipped_01: LDMIA R11,{R0} ; load the destination word so we can keep some of it @@ -278,7 +278,7 @@ draw_16x16_tile_unclipped_01: ORR R5,R5,R0 ; put back the destination pixels we need to keep STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address - B draw_16x16_tile_exit + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_unclipped_10: LDMIA R11,{R0} ; load the destination word so we can keep some of it @@ -457,7 +457,7 @@ draw_16x16_tile_unclipped_10: STMIA R11,{R5-R9} ; store 20 bytes from R5-R9 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline - B draw_16x16_tile_exit + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_unclipped_11: LDMIA R11,{R0} ; load the destination word so we can keep some of it @@ -604,49 +604,145 @@ draw_16x16_tile_unclipped_11: STMIA R11,{R5-R9} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline - B draw_16x16_tile_exit + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_clipped_top: - CMP R3,#CLIP_TOP - 16 - BLE draw_16x16_tile_exit - CMP R2,#CLIP_LEFT + 16 - BLT draw_16x16_tile_clipped_top_left - CMP R2,#CLIP_TOP - 16 - BGT draw_16x16_tile_clipped_top_right - - B draw_16x16_tile_exit + CMP R3,#CLIP_TOP - 16 ; check to see if y coordinate is completely off the screen + BLE draw_16x16_tile_exit ; if so, branch to exit function + CMP R2,#CLIP_LEFT + 16 ; check to see if x coordinate is less than left clip pixel + BLT draw_16x16_tile_clipped_top_left ; if so, branch to clipped top & left function + CMP R2,#CLIP_RIGHT - 16 ; check to see if x coordinate is greater than right clip pixel + BGT draw_16x16_tile_clipped_top_right ; if so, branch to clipped top & right function + +draw_16x16_tile_clipped_top_unclipped_left_right: + AND R8,R2,#0b11 ; get 4 pixel x coordinate offset + MOV R7,#16*16*4 ; put the size of a single tile in bytes into R7 + MLA R12,R0,R7,R1 ; calculate the address of the start of the tile [source = (tile number * (16 * 16)) + address of tileset] + ADD R12,R12,R8,LSL #8 ; add 4 pixel x coordinate offset * (16*16) to get pre-shifted tile + MOV R7,#320 ; put the width of a scanline into R7 + MOV R11,R4 ; move destination address into R11 + ADD R11,R11,R2 ; add x to the destination address + MOV R7,#CLIP_TOP ; move 0 into R7 + SUB R7,R7,R3 ; subtract y coordinate (-15...-1) from 0 to calculate how many tile lines to clip + + CMP R8,#0b00 ; check if x coordinate is word aligned + BEQ draw_16x16_tile_clipped_top_unclipped_left_right_00 ; if so, call word aligned draw function + CMP R8,#0b01 ; check if x coordinate is aligned with byte 1 + BEQ draw_16x16_tile_clipped_top_unclipped_left_right_01 ; if so, call byte 1 aligned draw function + CMP R8,#0b10 ; check if x coordinate is aligned with byte 2 + BEQ draw_16x16_tile_clipped_top_unclipped_left_right_10 ; if so, call byte 2 aligned draw function + CMP R8,#0b11 ; check if x coordinate is aligned with byte 3 + BEQ draw_16x16_tile_clipped_top_unclipped_left_right_11 ; if so, call byte 3 aligned draw function + +draw_16x16_tile_clipped_top_unclipped_left_right_00: + ADRL R0,draw_16x16_tile_unclipped_00 ; get address of word aligned draw function into R0 + MOV R1,#16 ; move 16 into R1 + MLA R12,R1,R7,R12 ; calculate start address of clipped tile : (16 * clip_y) + tile_start_address + MOV R1,#3 * 4 ; put length of instructions needed per scanline + MLA R0,R1,R7,R0 ; calculate code start address : (12 * clip_y) + code_start_address + MOV PC,R0 ; move calculated code start address into program counter + +draw_16x16_tile_clipped_top_unclipped_left_right_01: + ADRL R0,draw_16x16_tile_unclipped_01 ; get address of byte 1 aligned draw function into R0 + MOV R1,#16 ; move 16 into R1 + MLA R12,R1,R7,R12 ; calculate start address of clipped tile : (16 * clip_y) + tile_start_address + MOV R1,#8 * 4 ; put length of instructions needed per scanline + MLA R0,R1,R7,R0 ; calculate code start address : (32 * clip_y) + code_start_address + MOV PC,R0 ; move calculated code start address into program counter +draw_16x16_tile_clipped_top_unclipped_left_right_10: + ADRL R0,draw_16x16_tile_unclipped_10 ; get address of byte 2 aligned draw function into R0 + MOV R1,#16 ; move 16 into R1 + MLA R12,R1,R7,R12 ; calculate start address of clipped tile : (16 * clip_y) + tile_start_address + MOV R1,#10 * 4 ; put length of instructions needed per scanline + MLA R0,R1,R7,R0 ; calculate code start address : (40 * clip_y) + code_start_address + MOV PC,R0 ; move calculated code start address into program counter +draw_16x16_tile_clipped_top_unclipped_left_right_11: + ADRL R0,draw_16x16_tile_unclipped_11 ; get address of byte 3 aligned draw function into R0 + MOV R1,#16 ; move 16 into R1 + MLA R12,R1,R7,R12 ; calculate start address of clipped tile : (16 * clip_y) + tile_start_address + MOV R1,#8 * 4 ; put length of instructions needed per scanline + MLA R0,R1,R7,R0 ; calculate code start address : (32 * clip_y) + code_start_address + MOV PC,R0 ; move calculated code start address into program counter draw_16x16_tile_clipped_top_left: - B draw_16x16_tile_exit + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_clipped_top_right: - B draw_16x16_tile_exit + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_clipped_bottom: - CMP R3,#CLIP_BOTTOM + 16 - BGE draw_16x16_tile_exit - CMP R2,#CLIP_LEFT + 16 - BLT draw_16x16_tile_clipped_bottom_left - CMP R2,#CLIP_TOP - 16 - BGT draw_16x16_tile_clipped_bottom_right - - B draw_16x16_tile_exit + CMP R3,#CLIP_BOTTOM ; check to see if y coordinate is completely off the screen + BGE draw_16x16_tile_exit ; if so, branch to exit function + CMP R2,#CLIP_LEFT + 16 ; check to see if x coordinate is less than left clip pixel + BLT draw_16x16_tile_clipped_bottom_left ; if so, branch to clipped bottom & left function + CMP R2,#CLIP_RIGHT - 16 ; check to see if x coordinate is greater than right clip pixel + BGT draw_16x16_tile_clipped_bottom_right ; if so, branch to clipped bottom & right function + +draw_16x16_tile_clipped_bottom_unclipped_left_right: + AND R8,R2,#0b11 ; get 4 pixel x coordinate offset + MOV R7,#16*16*4 ; put the size of a single tile in bytes into R7 + MLA R12,R0,R7,R1 ; calculate the address of the start of the tile [source = (tile number * (16 * 16)) + address of tileset] + ADD R12,R12,R8,LSL #8 ; add 4 pixel x coordinate offset * (16*16) to get pre-shifted tile + MOV R7,#320 ; put the width of a scanline into R7 + MLA R11,R3,R7,R4 ; calculate the address of the destination [destination = (y * 320) + address of screen or buffer] + ADD R11,R11,R2 ; add x to the destination address + MOV R7,#CLIP_BOTTOM ; move clip bottom scanline into R7 + SUB R7,R7,R3 ; subtract y coordinate from clip bottom scanline to calculate how many tile lines to draw + + CMP R8,#0b00 ; check if x coordinate is word aligned + BEQ draw_16x16_tile_clipped_bottom_unclipped_left_right_00 ; if so, call word aligned draw function + CMP R8,#0b01 ; check if x coordinate is aligned with byte 1 + BEQ draw_16x16_tile_clipped_bottom_unclipped_left_right_01 ; if so, call byte 1 aligned draw function + CMP R8,#0b10 ; check if x coordinate is aligned with byte 2 + BEQ draw_16x16_tile_clipped_bottom_unclipped_left_right_10 ; if so, call byte 2 aligned draw function + CMP R8,#0b11 ; check if x coordinate is aligned with byte 3 + BEQ draw_16x16_tile_clipped_bottom_unclipped_left_right_11 ; if so, call byte 3 aligned draw function + +draw_16x16_tile_clipped_bottom_unclipped_left_right_00: + ADRL R0,draw_16x16_tile_unclipped_00 ; get address of word aligned draw function into R0 + MOV R1,#16 ; move 16 into R1 + SUB R7,R1,R7 ; calculate number of tile rows to clip : 16 - draw_y + MOV R1,#3 * 4 ; put length of instructions needed per scanline + MLA R0,R1,R7,R0 ; calculate code start address : (12 * clip_y) + code_start_address + MOV PC,R0 ; move calculated code start address into program counter + +draw_16x16_tile_clipped_bottom_unclipped_left_right_01: + ADRL R0,draw_16x16_tile_unclipped_01 ; get address of byte 1 aligned draw function into R0 + MOV R1,#16 ; move 16 into R1 + SUB R7,R1,R7 ; calculate number of tile rows to clip : 16 - draw_y + MOV R1,#8 * 4 ; put length of instructions needed per scanline + MLA R0,R1,R7,R0 ; calculate code start address : (32 * clip_y) + code_start_address + MOV PC,R0 ; move calculated code start address into program counter +draw_16x16_tile_clipped_bottom_unclipped_left_right_10: + ADRL R0,draw_16x16_tile_unclipped_10 ; get address of byte 2 aligned draw function into R0 + MOV R1,#16 ; move 16 into R1 + SUB R7,R1,R7 ; calculate number of tile rows to clip : 16 - draw_y + MOV R1,#10 * 4 ; put length of instructions needed per scanline + MLA R0,R1,R7,R0 ; calculate code start address : (40 * clip_y) + code_start_address + MOV PC,R0 ; move calculated code start address into program counter +draw_16x16_tile_clipped_bottom_unclipped_left_right_11: + ADRL R0,draw_16x16_tile_unclipped_11 ; get address of byte 3 aligned draw function into R0 + MOV R1,#16 ; move 16 into R1 + SUB R7,R1,R7 ; calculate number of tile rows to clip : 16 - draw_y + MOV R1,#8 * 4 ; put length of instructions needed per scanline + MLA R0,R1,R7,R0 ; calculate code start address : (32 * clip_y) + code_start_address + MOV PC,R0 ; move calculated code start address into program counter draw_16x16_tile_clipped_bottom_left: - B draw_16x16_tile_exit + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_clipped_bottom_right: - B draw_16x16_tile_exit + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_clipped_left: - CMP R2,#CLIP_LEFT - 16 - BLE draw_16x16_tile_clipped_right + CMP R2,#CLIP_LEFT - 16 ; check to see if x coordinate is completely off the screen + BLE draw_16x16_tile_exit ; if so, branch to exit function - B draw_16x16_tile_exit + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_clipped_right: - CMP R2,#CLIP_RIGHT + 16 - BGE draw_16x16_tile_exit + CMP R2,#CLIP_RIGHT + 16 ; check to see if x coordinate is completely off the screen + BGE draw_16x16_tile_exit ; if so, branch to exit function draw_16x16_tile_exit: ; exit function code From bf2acbdbc721cd9170317f7e7fa711cde6f17515 Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Tue, 26 Oct 2021 15:02:17 +0100 Subject: [PATCH 07/15] Now clipping against left clip value --- src/tiles.asm | 334 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 334 insertions(+) diff --git a/src/tiles.asm b/src/tiles.asm index 50fc118..4ab50a4 100644 --- a/src/tiles.asm +++ b/src/tiles.asm @@ -738,8 +738,342 @@ draw_16x16_tile_clipped_left: CMP R2,#CLIP_LEFT - 16 ; check to see if x coordinate is completely off the screen BLE draw_16x16_tile_exit ; if so, branch to exit function + ADD R2,R2,#CLIP_LEFT + 16 + AND R8,R2,#0b11 ; get 4 pixel x coordinate offset + AND R9,R2,#0b1100 ; get 4 word x coordinate offset + MOV R7,#16*16*4 ; put the size of a single tile in bytes into R7 + MLA R12,R0,R7,R1 ; calculate the address of the start of the tile [source = (tile number * (16 * 16)) + address of tileset] + ADD R12,R12,R8,LSL #8 ; add 4 pixel x coordinate offset * (16*16) to get pre-shifted tile + MOV R7,#320 ; put the width of a scanline into R7 + MLA R11,R3,R7,R4 ; calculate the address of the destination [destination = (y * 320) + address of screen or buffer] + + ; CMP R8,#0b00 ; check if x coordinate is word aligned + ; BEQ draw_16x16_tile_clipped_left_00 ; if so, call word aligned draw function + ; CMP R8,#0b01 ; check if x coordinate is aligned with byte 1 + ; BEQ draw_16x16_tile_clipped_left_01 ; if so, call byte 1 aligned draw function + ; CMP R8,#0b10 ; check if x coordinate is aligned with byte 2 + ; BEQ draw_16x16_tile_clipped_left_10 ; if so, call byte 2 aligned draw function + ; CMP R8,#0b11 ; check if x coordinate is aligned with byte 3 + ; BEQ draw_16x16_tile_clipped_left_11 ; if so, call byte 3 aligned draw function + +draw_16x16_tile_clipped_left_00: + TEQ R9,#0b1100 + BEQ draw_16x16_tile_clipped_left_00_11 + TEQ R9,#0b1000 + BEQ draw_16x16_tile_clipped_left_00_10 + TEQ R9,#0b0100 + BEQ draw_16x16_tile_clipped_left_00_01 + +draw_16x16_tile_clipped_left_00_00: + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_left_00_01: + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} + STR R0,[R11,#4] ; store 12 bytes from R1-R3 to the destination address without incrementing it + B draw_16x16_tile_exit ; branch to exit function +draw_16x16_tile_clipped_left_00_10: + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R2-R3} + STR R0,[R11,#8] ; store 12 bytes from R1-R3 to the destination address without incrementing it + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_left_00_11: + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R1-R3} ; store 12 bytes from R1-R3 to the destination address without incrementing it + STR R0,[R11,#12] ; store pre-shifted end of tile + + B draw_16x16_tile_exit ; branch to exit function + + +draw_16x16_tile_clipped_left_01: + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_left_10: + B draw_16x16_tile_exit ; branch to exit function +draw_16x16_tile_clipped_left_11: + B draw_16x16_tile_exit ; branch to exit function + + draw_16x16_tile_clipped_right: CMP R2,#CLIP_RIGHT + 16 ; check to see if x coordinate is completely off the screen BGE draw_16x16_tile_exit ; if so, branch to exit function From 30b1b4a2647af3f52f4c1198404739722268b5bb Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Tue, 26 Oct 2021 21:20:21 +0100 Subject: [PATCH 08/15] Now clipping against right clip value --- src/tiles.asm | 2154 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 2116 insertions(+), 38 deletions(-) diff --git a/src/tiles.asm b/src/tiles.asm index 4ab50a4..62c5bd0 100644 --- a/src/tiles.asm +++ b/src/tiles.asm @@ -609,10 +609,10 @@ draw_16x16_tile_unclipped_11: draw_16x16_tile_clipped_top: CMP R3,#CLIP_TOP - 16 ; check to see if y coordinate is completely off the screen BLE draw_16x16_tile_exit ; if so, branch to exit function - CMP R2,#CLIP_LEFT + 16 ; check to see if x coordinate is less than left clip pixel + CMP R2,#CLIP_LEFT ; check to see if x coordinate is less than left clip pixel BLT draw_16x16_tile_clipped_top_left ; if so, branch to clipped top & left function - CMP R2,#CLIP_RIGHT - 16 ; check to see if x coordinate is greater than right clip pixel - BGT draw_16x16_tile_clipped_top_right ; if so, branch to clipped top & right function + CMP R2,#CLIP_RIGHT - 16 ; check to see if x coordinate is greater than right clip pixel + BGT draw_16x16_tile_clipped_top_right ; if so, branch to clipped top & right function draw_16x16_tile_clipped_top_unclipped_left_right: AND R8,R2,#0b11 ; get 4 pixel x coordinate offset @@ -738,6 +738,7 @@ draw_16x16_tile_clipped_left: CMP R2,#CLIP_LEFT - 16 ; check to see if x coordinate is completely off the screen BLE draw_16x16_tile_exit ; if so, branch to exit function +draw_16x16_tile_clipped_left_00: ADD R2,R2,#CLIP_LEFT + 16 AND R8,R2,#0b11 ; get 4 pixel x coordinate offset AND R9,R2,#0b1100 ; get 4 word x coordinate offset @@ -747,16 +748,6 @@ draw_16x16_tile_clipped_left: MOV R7,#320 ; put the width of a scanline into R7 MLA R11,R3,R7,R4 ; calculate the address of the destination [destination = (y * 320) + address of screen or buffer] - ; CMP R8,#0b00 ; check if x coordinate is word aligned - ; BEQ draw_16x16_tile_clipped_left_00 ; if so, call word aligned draw function - ; CMP R8,#0b01 ; check if x coordinate is aligned with byte 1 - ; BEQ draw_16x16_tile_clipped_left_01 ; if so, call byte 1 aligned draw function - ; CMP R8,#0b10 ; check if x coordinate is aligned with byte 2 - ; BEQ draw_16x16_tile_clipped_left_10 ; if so, call byte 2 aligned draw function - ; CMP R8,#0b11 ; check if x coordinate is aligned with byte 3 - ; BEQ draw_16x16_tile_clipped_left_11 ; if so, call byte 3 aligned draw function - -draw_16x16_tile_clipped_left_00: TEQ R9,#0b1100 BEQ draw_16x16_tile_clipped_left_00_11 TEQ R9,#0b1000 @@ -1016,67 +1007,2154 @@ draw_16x16_tile_clipped_left_00_11: B draw_16x16_tile_exit ; branch to exit function +draw_16x16_tile_clipped_right: + CMP R2,#CLIP_RIGHT ; check to see if x coordinate is completely off the screen + BGE draw_16x16_tile_exit ; if so, branch to exit function + + AND R8,R2,#0b11 ; get 4 pixel x coordinate offset + AND R9,R2,#0b1100 ; get 4 word x coordinate offset + MOV R7,#16*16*4 ; put the size of a single tile in bytes into R7 + MLA R12,R0,R7,R1 ; calculate the address of the start of the tile [source = (tile number * (16 * 16)) + address of tileset] + ADD R12,R12,R8,LSL #8 ; add 4 pixel x coordinate offset * (16*16) to get pre-shifted tile + MOV R7,#320 ; put the width of a scanline into R7 + MLA R11,R3,R7,R4 ; calculate the address of the destination [destination = (y * 320) + address of screen or buffer] + ADD R11,R11,R2 ; add x to the destination address + + TEQ R9,#0b1100 + BEQ draw_16x16_tile_clipped_right_11 + TEQ R9,#0b1000 + BEQ draw_16x16_tile_clipped_right_10 + TEQ R9,#0b0100 + BEQ draw_16x16_tile_clipped_right_01 + +draw_16x16_tile_clipped_right_00: + CMP R8,#0b00 ; check if x coordinate is word aligned + BEQ draw_16x16_tile_clipped_right_00_00 ; if so, call word aligned draw function + CMP R8,#0b01 ; check if x coordinate is aligned with byte 1 + BEQ draw_16x16_tile_clipped_right_00_01 ; if so, call byte 1 aligned draw function + CMP R8,#0b10 ; check if x coordinate is aligned with byte 2 + BEQ draw_16x16_tile_clipped_right_00_10 ; if so, call byte 2 aligned draw function + CMP R8,#0b11 ; check if x coordinate is aligned with byte 3 + BEQ draw_16x16_tile_clipped_right_00_11 ; if so, call byte 3 aligned draw function -draw_16x16_tile_clipped_left_01: +draw_16x16_tile_clipped_right_00_00: LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it ADD R11,R11,#320 ; move destination address to the next scanline LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 - STMIA R11,{R3} ; store 4 bytes from R3 to the destination address without incrementing it + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it - B draw_16x16_tile_exit ; branch to exit function + B draw_16x16_tile_exit ; branch to exit function -draw_16x16_tile_clipped_left_10: - B draw_16x16_tile_exit ; branch to exit function -draw_16x16_tile_clipped_left_11: - B draw_16x16_tile_exit ; branch to exit function +draw_16x16_tile_clipped_right_00_01: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline -draw_16x16_tile_clipped_right: - CMP R2,#CLIP_RIGHT + 16 ; check to see if x coordinate is completely off the screen - BGE draw_16x16_tile_exit ; if so, branch to exit function + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_00_10: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R8} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_00_11: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R8} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_11: + CMP R8,#0b00 ; check if x coordinate is word aligned + BEQ draw_16x16_tile_clipped_right_11_00 ; if so, call word aligned draw function + CMP R8,#0b01 ; check if x coordinate is aligned with byte 1 + BEQ draw_16x16_tile_clipped_right_11_01 ; if so, call byte 1 aligned draw function + CMP R8,#0b10 ; check if x coordinate is aligned with byte 2 + BEQ draw_16x16_tile_clipped_right_11_10 ; if so, call byte 2 aligned draw function + CMP R8,#0b11 ; check if x coordinate is aligned with byte 3 + BEQ draw_16x16_tile_clipped_right_11_11 ; if so, call byte 3 aligned draw function + +draw_16x16_tile_clipped_right_11_00: + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0} ; store 16 bytes from R0-R3 to the destination address with incrementing it + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_11_01: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_11_10: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_11_11: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_10: + CMP R8,#0b00 ; check if x coordinate is word aligned + BEQ draw_16x16_tile_clipped_right_10_00 ; if so, call word aligned draw function + CMP R8,#0b01 ; check if x coordinate is aligned with byte 1 + BEQ draw_16x16_tile_clipped_right_10_01 ; if so, call byte 1 aligned draw function + CMP R8,#0b10 ; check if x coordinate is aligned with byte 2 + BEQ draw_16x16_tile_clipped_right_10_10 ; if so, call byte 2 aligned draw function + CMP R8,#0b11 ; check if x coordinate is aligned with byte 3 + BEQ draw_16x16_tile_clipped_right_10_11 ; if so, call byte 3 aligned draw function + +draw_16x16_tile_clipped_right_10_00: + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R1} ; store 16 bytes from R0-R3 to the destination address with incrementing it + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_10_01: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_10_10: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R6} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_10_11: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R6} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + B draw_16x16_tile_exit ; branch to exit function +draw_16x16_tile_clipped_right_01: + CMP R8,#0b00 ; check if x coordinate is word aligned + BEQ draw_16x16_tile_clipped_right_01_00 ; if so, call word aligned draw function + CMP R8,#0b01 ; check if x coordinate is aligned with byte 1 + BEQ draw_16x16_tile_clipped_right_01_01 ; if so, call byte 1 aligned draw function + CMP R8,#0b10 ; check if x coordinate is aligned with byte 2 + BEQ draw_16x16_tile_clipped_right_01_10 ; if so, call byte 2 aligned draw function + CMP R8,#0b11 ; check if x coordinate is aligned with byte 3 + BEQ draw_16x16_tile_clipped_right_01_11 ; if so, call byte 3 aligned draw function + +draw_16x16_tile_clipped_right_01_00: + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + LDMIA R12!,{R0-R3} ; load 16 bytes from the soure address into R0-R3 + STMIA R11,{R0-R2} ; store 16 bytes from R0-R3 to the destination address with incrementing it + + B draw_16x16_tile_exit ; branch to exit function +draw_16x16_tile_clipped_right_01_01: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R0,R0,#0x000000ff ; mask out the destination we want to keep + AND R9,R5,#0x000000ff ; get the shifted end of the tile into R9 + AND R5,R5,#0xffffff00 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address + + B draw_16x16_tile_exit ; branch to exit function + +draw_16x16_tile_clipped_right_01_10: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + MOV R0,R0,LSL #16 ; mask out the destination we want to keep by shifting + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + MOV R9,R5,LSL #16 ; get the shifted end of the tile into R9 + MOV R9,R9,LSR #16 ; shift back to the right bit position + MOV R5,R5,LSR #16 ; mask out the shifted end of the tile + MOV R5,R5,LSL #16 ; shift back to the right bit position + ORR R5,R5,R0,LSR #16 ; put back the destination pixels we need to keep and shift them into the correct position + STMIA R11,{R5-R7} ; store 20 bytes from R5-R9 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + B draw_16x16_tile_exit ; branch to exit function +draw_16x16_tile_clipped_right_01_11: + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + LDMIA R11,{R0} ; load the destination word so we can keep some of it + AND R0,R0,#0x00ffffff ; mask out the destination we want to keep + LDMIA R12!,{R5-R8} ; load 16 bytes from the soure address into R5-R8 + AND R9,R5,#0x00ffffff ; get the shifted end of the tile into R9 + AND R5,R5,#0xff000000 ; mask out the shifted end of the tile + ORR R5,R5,R0 ; put back the destination pixels we need to keep + STMIA R11,{R5-R7} ; store 16 bytes from R0-R3 to the destination address with incrementing it + ADD R11,R11,#320 ; move destination address to the next scanline + + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_exit: ; exit function code From d9a03a4b03fcac72095c1e12b26bfb3408077cbe Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Tue, 26 Oct 2021 21:20:39 +0100 Subject: [PATCH 09/15] Draw 1 extra tile per row now we are clipping --- src/batman.asm | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/batman.asm b/src/batman.asm index 439e003..201ec23 100644 --- a/src/batman.asm +++ b/src/batman.asm @@ -80,6 +80,14 @@ set_display_start: MOV PC,R14 ; return from function +set_border_colour: + MOV R0,#0b01000000 << 24 + MOV R1,R1,LSL #20 + ORR R0,R0,R1,LSR #20 + MOV R1,#0x3400000 + STR R0,[R1] + MOV PC,R14 + swap_display_buffers: STMFD SP!, {R0-R2,R14} @@ -1731,7 +1739,10 @@ draw_tile_map_loop: ADD R2,R2,#16 LDRB R0,[R10,#19] BL draw_16x16_tile - SUB R2,R2,#320-16 + ADD R2,R2,#16 + LDRB R0,[R10,#20] + BL draw_16x16_tile + SUB R2,R2,#320 ADD R3,R3,#16 ADD R10,R10,#128 CMP R3,#208 @@ -1838,9 +1849,7 @@ intro_screen_loop: LDMFD SP!, {R0-R2} LDR R1,[R12] ADD R1,R1,R5 - ;VDU 19,0,24,0,0,240,-1,-1,-1,-1 BL copy_buffer_to_screen - ;VDU 19,0,24,0,0,0,-1,-1,-1,-1 SUB R5,R5,#320 ADD R2,R2,#1 CMP R2,#200 @@ -1884,6 +1893,7 @@ intro_screen_skip_1: BL fade_screen_to_black main_draw_tile_map: + MOV R3,#0 MOV R4,#0 @@ -1898,14 +1908,18 @@ main_draw_tile_map: BL copy_buffer_to_screen main_draw_tile_map_loop: + + STMFD SP!, {R1-R3} + MOV R1,#15 << 8 + BL set_border_colour + LDMFD SP!, {R1-R3} + ADRL R0,level_1_map_tilemap ADRL R1,level_1_tiles LDR R2,[R12] BL draw_tile_map - ; VDU 19,0,24,0,0,0,-1,-1,-1,-1 - ADD R4,R4,#1 CMP R4,#29*16 MOVEQ R4,#0 @@ -1926,7 +1940,6 @@ main_draw_tile_map_loop: ADRL R1,level_1_tiles LDR R4,[R12] - ; VDU 19,0,24,0,240,0,-1,-1,-1,-1 BL draw_16x16_tile ADD R0,R0,#1 ADD R2,R2,#16 @@ -1954,14 +1967,17 @@ main_draw_tile_map_loop: ADD R0,R0,#1 ADD R2,R2,#16 BL draw_16x16_tile - ; VDU 19,0,24,0,0,0,-1,-1,-1,-1 LDMFD SP!, {R0-R8} + STMFD SP!, {R1-R3} + MOV R1,#15 << 4 + BL set_border_colour + LDMFD SP!, {R1-R3} + MOV R0,#19 SWI OS_Byte BL swap_display_buffers - ; VDU 19,0,24,0,0,240,-1,-1,-1,-1 B main_draw_tile_map_loop exit: From 2f9a58caebf243041dca5d86ef59283a7e9c949f Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Tue, 26 Oct 2021 21:40:40 +0100 Subject: [PATCH 10/15] Add test sprite --- assets/sprites/test_40x48.aseprite | 3 +++ assets/sprites/test_40x48.png | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 assets/sprites/test_40x48.aseprite create mode 100644 assets/sprites/test_40x48.png diff --git a/assets/sprites/test_40x48.aseprite b/assets/sprites/test_40x48.aseprite new file mode 100644 index 0000000..82d2aa3 --- /dev/null +++ b/assets/sprites/test_40x48.aseprite @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4dadbbc6e61a8e134f61fea2134e61838c96c241ec76c72e0a67b8e388af4276 +size 1324 diff --git a/assets/sprites/test_40x48.png b/assets/sprites/test_40x48.png new file mode 100644 index 0000000..cbc6343 --- /dev/null +++ b/assets/sprites/test_40x48.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c3a838df2f5f862f75363bc2d785b48ec513789fb309f0f830bdf36419cc9e9 +size 1205 From eed223100a559a9cec0fb8fe3a98f6d0bc4d49fc Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Tue, 26 Oct 2021 22:03:41 +0100 Subject: [PATCH 11/15] Start compiled sprite script --- src/tiles.asm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tiles.asm b/src/tiles.asm index 62c5bd0..c09da46 100644 --- a/src/tiles.asm +++ b/src/tiles.asm @@ -665,9 +665,11 @@ draw_16x16_tile_clipped_top_unclipped_left_right_11: MOV PC,R0 ; move calculated code start address into program counter draw_16x16_tile_clipped_top_left: + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_clipped_top_right: + B draw_16x16_tile_exit ; branch to exit function draw_16x16_tile_clipped_bottom: From 6c11530a1cb53ccff05b016d896a5f3c921e8d0a Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Wed, 27 Oct 2021 20:10:48 +0100 Subject: [PATCH 12/15] Move memc and vidc functions into there own include files --- src/batman.asm | 135 +++++++++++++++++++++++++------------------------ src/memc.asm | 58 +++++++++++++++++++++ src/vidc.asm | 60 ++++++++++++++++++++++ 3 files changed, 188 insertions(+), 65 deletions(-) create mode 100644 src/memc.asm create mode 100644 src/vidc.asm diff --git a/src/batman.asm b/src/batman.asm index 201ec23..394bbe5 100644 --- a/src/batman.asm +++ b/src/batman.asm @@ -33,61 +33,11 @@ stack: .include "vdu.asm" .include "macros.asm" +.include "memc.asm" +.include "vidc.asm" .include "tiles.asm" -; **************************************************************** -; set_display_start -; ---------------------------------------------------------------- -; Copy 4 bytes from a register to the screen or display -; buffer, function assumes a 320 byte wide scanline width. -; ---------------------------------------------------------------- -; Parameters -; ---------------------------------------------------------------- -; R0 : physical address of screen display buffer >> 2 -; R1 : N/A -; R2 : N/A -; R3 : N/A -; R4 : N/A -; R5 : N/A -; R6 : N/A -; R7 : N/A -; R8 : N/A -; R9 : N/A -; R10 : N/A -; R11 : N/A -; R11 : N/A -; ---------------------------------------------------------------- -; Returns -; ---------------------------------------------------------------- -; R0 : Corrupted -; R1 : Corrupted -; R2 : Unchanged -; R3 : Unchanged -; R4 : Unchanged -; R5 : Unchanged -; R6 : Unchanged -; R7 : Unchanged -; R8 : Unchanged -; R9 : Unchanged -; R10 : Unchanged -; R11 : Unchanged -; R11 : Unchanged -; **************************************************************** -set_display_start: - ADD R0,R0,#0x3600000 ; Add pre-shifted screen start address to VIDC address - STR R0,[R0] ; Put VIDC address and screen start address onto address bus - - MOV PC,R14 ; return from function - -set_border_colour: - MOV R0,#0b01000000 << 24 - MOV R1,R1,LSL #20 - ORR R0,R0,R1,LSR #20 - MOV R1,#0x3400000 - STR R0,[R1] - MOV PC,R14 - swap_display_buffers: STMFD SP!, {R0-R2,R14} @@ -96,14 +46,14 @@ swap_display_buffers: LDR R1,[R2,#4] STR R1,[R2,#0] STR R0,[R2,#4] - ADRL R2,vidc_address_screen_start + ADRL R2,memc_address_screen_start LDR R0,[R2,#0] LDR R1,[R2,#4] STR R1,[R2,#0] STR R0,[R2,#4] MOV R0,R1 - BL set_display_start + BL memc_set_display_start LDMFD SP!, {R0-R2,R14} MOV PC,R14 @@ -1763,28 +1713,28 @@ fade_screen_to_black: LDR R2,[R12,#4] BL fade_buffer_with_lookup MOV R0,#80*256 - BL set_display_start + BL memc_set_display_start ADRL R0,palette_fade LDR R1,[R12,#4] LDR R2,[R12,#0] BL fade_buffer_with_lookup MOV R0,#0 - BL set_display_start + BL memc_set_display_start ADRL R0,palette_fade LDR R1,[R12,#0] LDR R2,[R12,#4] BL fade_buffer_with_lookup MOV R0,#80*256 - BL set_display_start + BL memc_set_display_start ADRL R0,palette_fade LDR R1,[R12,#4] LDR R2,[R12,#0] BL fade_buffer_with_lookup MOV R0,#0 - BL set_display_start + BL memc_set_display_start EOR R0,R0,R0 LDR R1,[R12] @@ -1911,7 +1861,7 @@ main_draw_tile_map_loop: STMFD SP!, {R1-R3} MOV R1,#15 << 8 - BL set_border_colour + BL vidc_set_border_colour LDMFD SP!, {R1-R3} ADRL R0,level_1_map_tilemap @@ -1920,12 +1870,62 @@ main_draw_tile_map_loop: BL draw_tile_map + STMFD SP!,{R0-R2} + MOV R0,#129 + MOV R1,#-98 + MOV R2,#255 + SWI OS_Byte + CMP R2,#255 + BNE No_Z_Key + SUB R3,R3,#1 + CMP R3,#0 + ADDLT R3,R3,#128*16 +No_Z_Key: + MOV R0,#129 + MOV R1,#-67 + MOV R2,#255 + SWI OS_Byte + CMP R2,#255 + BNE No_X_Key + ADD R3,R3,#1 + CMP R3,#128*16 + MOVEQ R3,#0 +No_X_Key: + MOV R0,#129 + MOV R1,#-87 + MOV R2,#255 + SWI OS_Byte + CMP R2,#255 + BNE No_L_Key ADD R4,R4,#1 - CMP R4,#29*16 + CMP R4,#64*16 MOVEQ R4,#0 - ADD R3,R3,#1 - CMP R3,#102*16 - SUBEQ R3,R3,#102*16 +No_L_Key: + MOV R0,#129 + MOV R1,#-56 + MOV R2,#255 + SWI OS_Byte + CMP R2,#255 + BNE No_P_Key + SUB R4,R4,#1 + CMP R4,#0 + ADDLT R4,R4,#64*16 +No_P_Key: + MOV R0,#129 + MOV R1,#-113 + MOV R2,#255 + SWI OS_Byte + CMP R2,#255 + BEQ exit + + LDMFD SP!,{R0-R2} + + ; ADD R4,R4,#1 + ; CMP R4,#29*16 + ; MOVEQ R4,#0 + ; ADD R3,R3,#1 + ; CMP R3,#102*16 + ; SUBEQ R3,R3,#102*16 STMFD SP!, {R0-R8} @@ -1940,6 +1940,11 @@ main_draw_tile_map_loop: ADRL R1,level_1_tiles LDR R4,[R12] + STMFD SP!,{R0-R1} + MOV R1,#0b000000001111 + BL vidc_set_border_colour + LDMFD SP!,{R0-R1} + BL draw_16x16_tile ADD R0,R0,#1 ADD R2,R2,#16 @@ -1972,7 +1977,7 @@ main_draw_tile_map_loop: STMFD SP!, {R1-R3} MOV R1,#15 << 4 - BL set_border_colour + BL vidc_set_border_colour LDMFD SP!, {R1-R3} MOV R0,#19 @@ -2104,7 +2109,7 @@ vdu_variables_screen_start_buffer: .4byte 0x00000000 .4byte 0x00000000 -vidc_address_screen_start: +memc_address_screen_start: .4byte 0x00005000 .4byte 0x00000000 diff --git a/src/memc.asm b/src/memc.asm new file mode 100644 index 0000000..0e70421 --- /dev/null +++ b/src/memc.asm @@ -0,0 +1,58 @@ +; **************************************************************** +; memc.asm +; ---------------------------------------------------------------- +; Copyright (c) 2021 Scott Moore, all rights reserved. +; **************************************************************** + +; **************************************************************** +; Constants +; ---------------------------------------------------------------- +; Define constants used in this file and calling functions. +; **************************************************************** + +.set MEMC, 0x3600000 + +; **************************************************************** +; memc_set_display_start +; ---------------------------------------------------------------- +; Copy 4 bytes from a register to the screen or display +; buffer, function assumes a 320 byte wide scanline width. +; ---------------------------------------------------------------- +; Parameters +; ---------------------------------------------------------------- +; R0 : physical address of screen display buffer >> 2 +; R1 : N/A +; R2 : N/A +; R3 : N/A +; R4 : N/A +; R5 : N/A +; R6 : N/A +; R7 : N/A +; R8 : N/A +; R9 : N/A +; R10 : N/A +; R11 : N/A +; R11 : N/A +; ---------------------------------------------------------------- +; Returns +; ---------------------------------------------------------------- +; R0 : Corrupted +; R1 : Unchanged +; R2 : Unchanged +; R3 : Unchanged +; R4 : Unchanged +; R5 : Unchanged +; R6 : Unchanged +; R7 : Unchanged +; R8 : Unchanged +; R9 : Unchanged +; R10 : Unchanged +; R11 : Unchanged +; R11 : Unchanged +; **************************************************************** +memc_set_display_start: + ADD R0,R0,#MEMC ; Add pre-shifted screen start address to VIDC address + STR R0,[R0] ; Put VIDC address and screen start address onto address bus + + MOV PC,R14 ; return from function + diff --git a/src/vidc.asm b/src/vidc.asm new file mode 100644 index 0000000..f68b598 --- /dev/null +++ b/src/vidc.asm @@ -0,0 +1,60 @@ +; **************************************************************** +; vidc.asm +; ---------------------------------------------------------------- +; Copyright (c) 2021 Scott Moore, all rights reserved. +; **************************************************************** + +; **************************************************************** +; Constants +; ---------------------------------------------------------------- +; Define constants used in this file and calling functions. +; **************************************************************** + +.set VIDC, 0x3400000 + +; **************************************************************** +; vidc_set_border_colour +; ---------------------------------------------------------------- +; Set VIDC register for border colour, +; ---------------------------------------------------------------- +; Parameters +; ---------------------------------------------------------------- +; R0 : N/A +; R1 : red (0-3), green (4-7), blue (8-11) values for border +; R2 : N/A +; R3 : N/A +; R4 : N/A +; R5 : N/A +; R6 : N/A +; R7 : N/A +; R8 : N/A +; R9 : N/A +; R10 : N/A +; R11 : N/A +; R11 : N/A +; ---------------------------------------------------------------- +; Returns +; ---------------------------------------------------------------- +; R0 : Corrupted +; R1 : Corrupted +; R2 : Unchanged +; R3 : Unchanged +; R4 : Unchanged +; R5 : Unchanged +; R6 : Unchanged +; R7 : Unchanged +; R8 : Unchanged +; R9 : Unchanged +; R10 : Unchanged +; R11 : Unchanged +; R11 : Unchanged +; **************************************************************** + +vidc_set_border_colour: + MOV R0,#0b01000000 << 24 + MOV R1,R1,LSL #20 + ORR R0,R0,R1,LSR #20 + MOV R1,#VIDC + STR R0,[R1] + MOV PC,R14 + From 466500dece6807ee3c6b77853aee4c0afce4eeb1 Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Wed, 27 Oct 2021 20:11:11 +0100 Subject: [PATCH 13/15] Add tiles to fill full 128x64 map --- assets/maps/level-1.tmx | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/assets/maps/level-1.tmx b/assets/maps/level-1.tmx index 07d5d89..c8a6177 100644 --- a/assets/maps/level-1.tmx +++ b/assets/maps/level-1.tmx @@ -44,29 +44,29 @@ 19,4,97,4,20,103,104,105,103,77,105,39,20,60,38,59,40,17,117,35,118,19,86,4,65,66,20,23,20,60,41,41,4,117,51,116,19,4,79,80,20,20,59,20,20,20,41,41,42,43,44,47,47,42,43,41,41,4,20,37,69,69,69,69,42,43,44,46,45,17,51,116,18,19,44,46,45,42,43,44,46,45,42,43,44,46,45,103,67,105,44,48,87,89,120,30,120,121,122,123,124,125,122,38,120,121,41,41,41,52,53,53,53,17,51,2,19,4,79,80,4,4,4,4,4,4,4,4, 19,56,56,56,56,56,56,56,56,56,56,55,56,56,56,56,56,118,117,51,116,19,56,56,56,56,56,55,56,56,56,56,56,17,102,2,19,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,118,102,2,18,19,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,118,102,2,19,56,56,56,4,4,4,4,4,4,4,4, 18,102,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,118,102,2,18,102,2,2,2,2,2,2,2,2,2,2,118,18,18,18,117,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,118,18,18,19,102,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,18,18,18,102,2,2,2,2,2,2,2,2,2,2, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18, +18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18 From ea11527582bf0348bdc73fa767d66b919b206752 Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Wed, 27 Oct 2021 20:12:07 +0100 Subject: [PATCH 14/15] Remove incorrect +16 for left clip check --- src/tiles.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tiles.asm b/src/tiles.asm index c09da46..2d51874 100644 --- a/src/tiles.asm +++ b/src/tiles.asm @@ -675,7 +675,7 @@ draw_16x16_tile_clipped_top_right: draw_16x16_tile_clipped_bottom: CMP R3,#CLIP_BOTTOM ; check to see if y coordinate is completely off the screen BGE draw_16x16_tile_exit ; if so, branch to exit function - CMP R2,#CLIP_LEFT + 16 ; check to see if x coordinate is less than left clip pixel + CMP R2,#CLIP_LEFT ; check to see if x coordinate is less than left clip pixel BLT draw_16x16_tile_clipped_bottom_left ; if so, branch to clipped bottom & left function CMP R2,#CLIP_RIGHT - 16 ; check to see if x coordinate is greater than right clip pixel BGT draw_16x16_tile_clipped_bottom_right ; if so, branch to clipped bottom & right function From 8eabe54fac698937e51d17b9f7c60c0b7324029d Mon Sep 17 00:00:00 2001 From: "Scott Moore (Arch)" Date: Wed, 27 Oct 2021 20:12:33 +0100 Subject: [PATCH 15/15] Start compiled sprite script --- scripts/compilesprite.py | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 scripts/compilesprite.py diff --git a/scripts/compilesprite.py b/scripts/compilesprite.py new file mode 100755 index 0000000..f1355f6 --- /dev/null +++ b/scripts/compilesprite.py @@ -0,0 +1,82 @@ +#!/usr/bin/python3 + +import sys +import argparse +import ntpath +import itertools + +from pathlib import Path +from PIL import Image + +parser = argparse.ArgumentParser(description='Compile indexed color PNG sprite to Acorn ARM assembler.') +parser.add_argument('-i', '--infile', nargs='+', type=argparse.FileType('rb'),default=sys.stdin) +parser.add_argument('-o', '--outfile', nargs='+', type=argparse.FileType('wt'),default=sys.stdout) +parser.add_argument('-sw', '--spritewidth', type=int,default=8) +parser.add_argument('-sh', '--spriteheight', type=int,default=8) + +args = parser.parse_args() + +filenames = [args.infile, args.outfile] + +for infile, outfile in zip(args.infile, args.outfile): + filename = Path(ntpath.basename(infile.name)).stem + + image = Image.open(infile) + image_name = filename + image_width,image_height = image.size + + sprite_width = args.spritewidth + sprite_height = args.spriteheight + + palette_name = filename + "_palette" + palette_type,palette_data = image.palette.getdata() + + f_out = outfile + + image_pixels = image.load() + + print("\ncompilesprite: '"+infile.name+"' => '"+outfile.name+"'") + print("\tImage size : "+f'{image_width}'+"x"+f'{image_height}') + print("\tSprite size : "+f'{sprite_width}'+"x"+f'{sprite_height}') + + label_name = image_name.replace("-","_") + f_out.write(label_name+':\n') + + iy = 0 + tile = 0 + + while iy < image_height: + ix = 0 + while ix < image_width: + f_out.write(label_name+f'_sprite_{tile}'+':\n') + y = 0 + while y < sprite_height: + x = 0 + while x < sprite_width: + # b0 = image_pixels[ix + x + 0,iy + y] + # b1 = image_pixels[ix + x + 1,iy + y] + # b2 = image_pixels[ix + x + 2,iy + y] + # b3 = image_pixels[ix + x + 3,iy + y] + # b4 = image_pixels[ix + x + 4,iy + y] + # b5 = image_pixels[ix + x + 5,iy + y] + # b6 = image_pixels[ix + x + 6,iy + y] + # b7 = image_pixels[ix + x + 7,iy + y] + # f_out.write(f'0x{b0:02x},'+f'0x{b1:02x},'+f'0x{b2:02x},'+f'0x{b3:02x},'+f'0x{b4:02x},'+f'0x{b5:02x},'+f'0x{b6:02x},'+f'0x{b7:02x}') + x += 8 + # if x >= sprite_width: + # f_out.write('\n') + # else: + # f_out.write(',') + y += 1 + + tile = tile + 1 + + ix += sprite_width + if ix < image_width: + if iy <= (image_height - sprite_height): + f_out.write('\n') + + iy += sprite_height + + f_out.write(label_name+'_end:\n\n') + f_out.close() \ No newline at end of file