//
// FROGGER
//
// Jakub Wolsza | NET ID: jjw8728
//
// + This game is my version of the game frogger
// + 3 advanced features:
//	(1) Flying Objects (Logs)
//	(2) Acceleration   (Current dragging some logs faster than others)
//	(3) Animation      (Frog Drowning)
// + How to play:
//		-The goal of the game is to cross from one sand bar
//		 to the other. There are 3 levels, and you have 3 lives
//		 across all levels. Doing so sucessfully is winning the game.
//		-Touching water (blue) results in a loss of 1 life.
//		 Frogs position is subsequently reset to origin.
//		 After the loss of 3 lives, the game is over for good.
//		-Lilypads are safe, as are logs.But, all logs move with a
//		 nonzero velocity, and some also have an acceleration.
//		-Logs disappear at the edges of the screen. If the frog 
//		 is on the log at this time, it will fall into the water 
//		 and die.
// 		-Naviagation: Use push buttons to move frog. 
//		 Frog moves only when a rising edge is detected on a push button. 
//       Only 1 button can be pressed at a time.
//		 If more than one button is pressed, frog doesn't move.
//		-Press: 
//		 	'0' to move up
//		 	'1' to move down
//		 	'2' to move left
//		 	'3' to move right
//

.data
//
// Buffer Access
//
.EQU PIX_BUFFER, 0xc8000000
.EQU BACK_BUFFER,0x08000000
.EQU CHARBUF, 0xc9000000	
.EQU PIX_ADDR, 0xFF203020
.EQU BACK_PIX_ADDR, 0xFF203024
.EQU STATUS_ADDR, 0xFF20302C 
//
// Pixmap
//
.EQU PIXMAP_WIDTH, 0
.EQU PIXMAP_HEIGHT, 2
.EQU PIXMAP_TRANSPARENCY, 4
.EQU PIXMAP_PIXELDATA, 6
//
// Struct Specific Constants
//
.EQU LILY_PIX, 0
.EQU LILY_X, 4
.EQU LILY_Y, 6
.EQU FROG_PIX, 0
.EQU FROG_X, 4
.EQU FROG_Y, 6
.EQU FROG_LIVES, 8
.EQU FROG_JUMP, 9
.EQU ON_LOG, 10
.EQU ON_LILY, 11
.EQU DIR, 12
.EQU KEY_BUF,0xff200050
.EQU OLD_KEY,0
.EQU NEW_KEY,1
.EQU LOG_PIX, 0
.EQU LOG_X, 4
.EQU LOG_Y, 6
.EQU LOG_VEL, 8
.EQU LOG_ACCEL, 10
.EQU LOG_INIT_X, 12
.EQU LOG_INIT_VEL,14
.align 4
.text

.global _start
_start:
	
	// Inital stack
	mov sp, #0x800000

	//Remember: forward and back point to the same spot
	//We change that here
	ldr r0,=BACK_PIX_ADDR
	ldr r2,=BACK_BUFFER
	str r2,[r0]
	
	//Initial position of frog loaded:
	ldr r1,=up_frog
	ldr r2,=frog
	str r1,[r2,#FROG_PIX]
	
	//Start Game
	bl level_1
	cmp r0,#1
	bne loser
	bl level_2
	cmp r0,#1
	bne loser
	bl level_3
	cmp r0,#1
	bne loser
	//Game has been won!
	b winner
	loser:
	bl GameLost
    b inf_loop
	winner:
	bl GameWon
	b inf_loop
	
	inf_loop:
	b inf_loop
    .LTORG 
	
	
.data
//
//Strings
//
level:
	.string "Level:"   
lives_str:
	.string "Lives:"   
win_str:
	.string "YOU SURVIVED"
lost_str:
	.string "RIP"
.align 2  
//
//Pixmaps
//
log:
	.hword 64,16,0xfffe  //width,height,clear
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0,0x59C0 ,0x59C0, 0x59C0, 0x59C0, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20
	.hword 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x59C0, 0x59C0
	.hword 0x59C0, 0x59C0, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20,0x8B20,0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20, 0x8B20

lily:
	.hword 16, 16, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0x6700, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x6700, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x6700, 0x6700, 0x6700, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x6700, 0x6700, 0x6700, 0xfffe, 0xfffe
	.hword 0xfffe, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0xfffe
	.hword 0xfffe, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0xfffe
	.hword 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0xfffe, 0xfffe, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700
	.hword 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700
	.hword 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700
	.hword 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700
	.hword 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700
	.hword 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700
	.hword 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700
	.hword 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700
	.hword 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700
	.hword 0xfffe, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0xfffe
	.hword 0xfffe, 0xfffe, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0x6700, 0xfffe, 0xfffe, 0xfffe, 0xfffe

up_frog:
	.hword 16, 16, 0xfffe  //width,height,clear
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xD979, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0xD979, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xD979, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0xD979, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe

up_frog_2:
	.hword 16, 16, 0xfffe  //width,height,clear
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xD979, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0xD979, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0x148A, 0xB73D, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xfffe, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0x148A, 0xB73D, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0x148A, 0xB73D, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xfffe, 0xfffe, 0x148A, 0xB73D, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe

up_frog_3:
	.hword 16, 16, 0xfffe  //width,height,clear
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe


left_frog:
	.hword 16, 16, 0xfffe  //width,height,clear
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xD979, 0xD979, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xF7EA, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe 
	.hword 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xF7EA, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xD979, 0xD979, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 

left_frog_2:
	.hword 16, 16, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xB73D, 0xD979, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xB73D, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xB73D, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xB73D, 0xD979, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 

left_frog_3:
	.hword 16, 16, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe

right_frog:
	.hword 16, 16, 0xfffe
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xD979, 0xD979, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xF7EA 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA 
	.hword 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A 
	.hword 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xF7EA 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xD979, 0xD979, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 

right_frog_2:
	.hword 16, 16, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xD979, 0xB73D, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xB73D, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xB73D, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xD979, 0xB73D, 0xfff 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe

right_frog_3:
	.hword 16, 16, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe
	
down_frog:
	.hword 16, 16, 0xfffe
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0x148A, 0x148A, 0x148A, 0x148A, 0xfffe, 0xD979, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0xD979, 0xfffe, 0x148A, 0x148A, 0x148A, 0x148A 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xD979, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0xD979, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xfffe, 0xfffe  

down_frog_2:
	.hword 16, 16, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xfffe, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xfffe, 0xfffe, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xfffe, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xfffe, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xfffe, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xfffe, 0x148A, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0x148A, 0xfffe, 0x148A, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xD979, 0x148A, 0xF7EA, 0xF7EA, 0x148A, 0xD979, 0xfffe, 0xB73D, 0xB73D, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe

down_frog_3:
	.hword 16, 16, 0xfffe
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0x148A, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xF7EA, 0xF7EA, 0x148A, 0xF7EA, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xF7EA, 0xF7EA, 0xF7EA, 0xF7EA, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xB73D, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	.hword 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe 
	
.align 4

//
//Structs
//

//	struct log
//	{
//		pixmap_ptr pixmap;
//		uint_8 x_pos;
//		uint_8 y_pos;
//		int_8 x_vel;
// 		int_8 x_accel;
//      int_8 init_x;
//		int_8 init_vel
//	}
//	
//	struct lily
//	{
//		pixmap_ptr pixmap;
//		uint_16 x_pos;
//		uint_16 y_pos;
//	}
//
//	struct frog
//	{
//		pixmap_ptr pixmap;  // This can change, depending on direction of travel
//		uint_16 x_pos;
//		uint_16 y_pos;
//		uint_4 lives;       // Single byte with lives left
//      uint_4 jump;        // Did frog just jump? 1 = yes, 0 = no. Used for log travel
//		uint_4 on_log;      // Captures if frog is on any log
//		uint_4 on_lily;     // Captures if frog is on any lily
//		uint_4 dir;         // Frog direction. 0 = up, 1=down, 2=left, 3 = right
//	}
//
//  struct direction  		//Stores which arrow keys have been pressed
//	{
//		uint_4 old_direction;
//		uint_4 new_direction;
//	}
//



//Values below are set only for INITAL level. 

//
// LILYPADS
//
lily1:
	.word 0
	.hword 100	//x-pos (col)
	.hword 214	//y-pos (row)
.align 4
lily2:
	.word 0
	.hword 202
	.hword 214
.align 4
lily3:
	.word 0
	.hword 168
	.hword 180
.align 4
lily4:
	.word 0
	.hword 270
	.hword 180
.align 4
lily5:
	.word 0
	.hword 83
	.hword 146
.align 4
lily6:
	.word 0
	.hword 185
	.hword 112
.align 4
lily7:
	.word 0
	.hword 202
	.hword 112
.align 4
lily8:
	.word 0
	.hword 134
	.hword 78
.align 4
lily9:
	.word 0
	.hword 219
	.hword 44
.align 4
//
// FROG
//
frog:
	.word 0
	.hword 151
	.hword 231
	.byte 3
	.byte 0
	.byte 0
	.byte 0
	.byte 0     //initial direction = up
.align 4
//
// LOGS
//
log1:
	.word 0     //pointer loaded in
	.hword 32   //x-pos (horiz)
	.hword 197  //y-pos (vert)
	.hword 3   //speed (Current speed)
	.hword 0    //accel
	.hword 32   //Initial x-pos
	.hword 3    //Initial speed
.align 4
log2:
	.word 0      //pointer loaded in
	.hword 288   //x-pos (horiz)
	.hword 163   //y-pos (vert)
	.hword -4    //speed
	.hword  0    //accel
	.hword 288   //Initial x-pos
	.hword -4    //Initial speed
.align 4
log3:
	.word 0      //pointer loaded in
	.hword 32    //x-pos (col)
	.hword 129   //y-pos (row)
	.hword  1    //speed
	.hword  1    //accel
	.hword 32    //Initial x-pos
	.hword  1    //Initial speed
.align 4
log4:
	.word 0      //pointer loaded in
	.hword 288   //x-pos (col)
	.hword 95    //y-pos (row)
	.hword -3    //speed
	.hword  0    //accel
	.hword 288   //Initial x-pos
	.hword -3    //Initial speed
.align 4
log5:
	.word 0      //pointer loaded in
	.hword 32    //x-pos (col)
	.hword 61    //y-pos (row)
	.hword 5     //speed
	.hword 0     //accel
	.hword 32    //Initial x-pos
	.hword 5     //Initial speed
.align 4
log6:
	.word 0       //pointer loaded in
	.hword 288    //x-pos (col)
	.hword 27     //y-pos (row)
	.hword  -7    //speed
	.hword  0     //accel
	.hword 288    //Initial x-pos
	.hword  -7    //Initial speed
	
log7:
	.word 0       //pointer loaded in
	.hword 288    //x-pos (col)
	.hword 27     //y-pos (row)
	.hword  -7    //speed
	.hword  0     //accel
	.hword 288    //Initial x-pos
	.hword  -7    //Initial speed
log8:
	.word 0       //pointer loaded in
	.hword 288    //x-pos (col)
	.hword 27     //y-pos (row)
	.hword  -7    //speed
	.hword  0     //accel
	.hword 288    //Initial x-pos
	.hword  -7    //Initial speed
log9:
	.word 0       //pointer loaded in
	.hword 288    //x-pos (col)
	.hword 27     //y-pos (row)
	.hword  -7    //speed
	.hword  0     //accel
	.hword 288    //Initial x-pos
	.hword  -7    //Initial speed
//
// DIRECTION
//
direction:
	.byte 0,0
//
// GAME VARIABLES
//
score:
	.byte 1
lives:
	.byte 3
water:
	.byte 0
.align 4
.text


//All functions used are below.
// Screen is 320 x 240 (0 to 319 and 0 to 239)



// Called from main.
// Inputs:NA
// Outputs: r0. r0 = 1 if level passed, r0 = 0 if failed
// -Draws level 1 scene, run level_1_loop till next level
level_1:
push {r4,lr}
	
	//Set initial frog position
	ldr r0,=frog
	mov r1,#151
	mov r2,#231
	strh r1,[r0,#FROG_X]
	strh r2,[r0,#FROG_Y]

	//Load Pixmaps into sprites
	ldr r1,=log
	ldr r2,=log1
	str r1,[r2,#LOG_PIX]
	ldr r2,=log2
	str r1,[r2,#LOG_PIX]
	ldr r2,=log3
	str r1,[r2,#LOG_PIX]
	ldr r2,=log4
	str r1,[r2,#LOG_PIX]
	ldr r2,=log5
	str r1,[r2,#LOG_PIX]
	ldr r2,=log6
	str r1,[r2,#LOG_PIX]
	ldr r2,=log7
	str r1,[r2,#LOG_PIX]
	ldr r2,=log8
	str r1,[r2,#LOG_PIX]
	ldr r2,=log9
	str r1,[r2,#LOG_PIX]

	ldr r1,=lily
	ldr r2,=lily1
	str r1,[r2,#LILY_PIX]
	ldr r2,=lily2
	str r1,[r2,#LILY_PIX]
	ldr r2,=lily3
	str r1,[r2,#LILY_PIX]
	ldr r2,=lily4
	str r1,[r2,#LILY_PIX]
	ldr r2,=lily5
	str r1,[r2,#LILY_PIX]
	ldr r2,=lily6
	str r1,[r2,#LILY_PIX]
	ldr r2,=lily7
	str r1,[r2,#LILY_PIX]
	ldr r2,=lily8
	str r1,[r2,#LILY_PIX]
	ldr r2,=lily9
	str r1,[r2,#LILY_PIX]
	
	bl DrawText
	mov r1,#0               //Frog initially not submerged
	ldr r2,=water
	ldrb r1,[r2]
	mov r0,#0              //Frog is initially not done with level
	
	// Go into loop.
	// Swap pixel addresses, and draw to unused
 	redo_level_1_loop:
	bl level_1_loop
	mov r3,r0               //r0->r3:frog done? 1=yes,0=no
	//Swap pixel_addr
		ldr r0,=PIX_ADDR		
		mov r1,#1				
		str r1,[r0]
	//End of swap
	//Wait for status to indicate finish
		ldr r0,=STATUS_ADDR
		wait_loop:
		ldr r2,[r0]
		mov r1,#1
		and r2,r2,r1    //keep only smallest bit
		cmp r2,#1
		beq wait_loop
	//End of wait
	//Check if lives = 0
	ldr r4,=lives
	ldrb r4,[r4]
	cmp r4,#0
	bne Not_dead
	mov r0,#0               //game failed, return 0
	b exit_lvl_1
	Not_dead:
	cmp r3,#1         		//Check if level is complete
	bne redo_level_1_loop
	mov r0,#1               //level sucessfully complete,return 1
	exit_lvl_1:
pop {r4,pc}
.LTORG


// Called from level_1. 
// Input:  NA
// Output: r0=1 if level complete, r0=0 if level incomplete
// -Updates moving sprites
// -Checks for completion of level. Exits once complete.
// -Changes which buff to use.
level_1_loop:
push {r4,r5,r6,lr}
	
	//r4: which buffer to draw to
	ldr r4,=BACK_PIX_ADDR
	ldr r4,[r4]
	
	// Draw Water
	ldr r0,=0x0A53
	mov r1,r4
	bl ClearVGA
	
	// Draw land
	ldr r0,=#0
	ldr r1,=#18
	mov r2,r4
	bl DrawLand
	ldr r0,=#223
	ldr r1,=#239
	mov r2,r4
	bl DrawLand
	
	// Draw Lilypads
	ldr  r0,=lily1       
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]  // r0 has address, NOT value stored
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily2
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily3
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily4
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily5
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily6
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily7
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily8
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily9
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit

	// Check if frog is on top of map
	ldr r0,=frog
	ldrh r1,[r0,#FROG_Y]
	cmp r1,#18				
	blt finished_level_1    
		//LEVEL NOT FINISHED.UPDATE EVERYTHING
		///////////////////////////////
		//Check if frog is submerged...
		ldr r1,=water
		ldrb r1,[r1]
		cmp r1,#1
		blt skip_overwrite_1
		ldr r1,=direction
		mov r0,#0
		strb r0,[r1,#NEW_KEY]
		ldr r1,=frog
		strb r0,[r1,#FROG_JUMP] 
		b do_other_updates_1
		///////////////////////////////
		skip_overwrite_1:
		bl CheckInput
		do_other_updates_1:
		//FROG UPDATE
		mov r0,r4
		bl UpdateFrog 
		// LOG UPDATE
		ldr r0,=log1
		mov r1,r4
		bl UpdateLog
		ldr r0,=log2
		mov r1,r4
		bl UpdateLog
		ldr r0,=log3
		mov r1,r4
		bl UpdateLog
		ldr r0,=log4
		mov r1,r4
		bl UpdateLog
		ldr r0,=log5
		mov r1,r4
		bl UpdateLog
		ldr r0,=log6
		mov r1,r4
		bl UpdateLog
		//CHECK ALL LILYs
		ldr r0,=lily1
		bl CheckLily
		ldr r0,=lily2
		bl CheckLily 
		ldr r0,=lily3
		bl CheckLily
		ldr r0,=lily4
		bl CheckLily
		ldr r0,=lily5
		bl CheckLily
		ldr r0,=lily6
		bl CheckLily
		ldr r0,=lily7
		bl CheckLily
		ldr r0,=lily8
		bl CheckLily
		ldr r0,=lily9
		bl CheckLily
		///////////////////////////////
		//Check if frog is submerged...
		ldr r1,=water
		ldrb r1,[r1]
		cmp r1,#1
		bge is_submerging_1
		///////////////////////////////
		//Print Frog
		ldr r0,=frog
		ldrh r1,[r0,#FROG_X]
		ldrh r2,[r0,#FROG_Y]
		mov  r3,r4              //which buffer
		ldr r0,[r0,#FROG_PIX]
		bl BitBlit
		//Check if in water
		bl CheckWater        //r0 = 1 if in water
		ldr r1,=water
		strb r0,[r1]         //Store fact if frog is in water
		mov r0,#0            //Level not complete
		b exit_level_1_update
	finished_level_1:
	bl IncrementScore       
	bl DrawText             
	mov r0,#1				//Level complete
	mov r1,#0               //Frog not submerging; store that
	ldr r2,=water
    strb r1,[r2]
	exit_level_1_update:
	//Clear on_log & on_lily
	ldr r2,=frog
	mov r3,#0
	strb r3,[r2,#ON_LOG]
	strb r3,[r2,#ON_LILY]
	b exit_level_1_loop
	
	is_submerging_1:
	bl DrawText          //Update display, display lost life.
	ldr r1,=water
	ldrb r0,[r1]         //r0 = water var.
	//See if r0 = 3. This means animation has run its course
	//Time to set frog back to origin, set water var = 0.
	cmp r0,#3
	blt keep_submerged_1
	//Set frog to origin
		ldr r0,=frog
		mov r1,#151
		mov r2,#231
		strh r1,[r0,#FROG_X]
		strh r2,[r0,#FROG_Y]
	//Load original pixmap into frog
		ldr r1,=up_frog
		str r1,[r0,#FROG_PIX]
	//Set water var = 0
		ldr r1,=water
		mov r0,#0
		strb r0,[r1]
	b exit_level_1_loop
	keep_submerged_1:
	bl SubmergeFrog
	add r0,r0,#1
	ldr r1,=water
	strb r0,[r1]        //increment water var & store
	//Draw frog
	ldr r0,=frog
	ldrh r1,[r0,#FROG_X]
	ldrh r2,[r0,#FROG_Y]
	ldr r3,=BACK_PIX_ADDR
	ldr r3,[r3]             //which buffer
	ldr r0,[r0,#FROG_PIX]
	bl BitBlit
	mov r0,#0                 //Level not complete yet
	exit_level_1_loop:
pop {r4,r5,r6,pc}
.LTORG

//
// LEVEL 2
//
// Called from main.
// Inputs:NA
// Outputs: r0. r0 = 1 if level passed, r0 = 0 if failed
// -Draws level 2 scene, run level_2_loop till next level
level_2:
push {r4,lr}
	
	//Set initial frog position
	ldr r0,=frog
	mov r1,#151
	mov r2,#231
	strh r1,[r0,#FROG_X]
	strh r2,[r0,#FROG_Y]
	//
	//
	//Load in NEW log values
	//
	// LOG 1
	//
	ldr r0,=log1
	ldr r1,=#32               //New Col (32 (L) or 288(R))
	ldr r2,=#214              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#6                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 2
	//
	ldr r0,=log2
	ldr r1,=#288               //New Col (32 (L) or 288(R))
	ldr r2,=#180              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#-3                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 3
	//
	ldr r0,=log3
	ldr r1,=#288               //New Col (32 (L) or 288(R))
	ldr r2,=#163              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#-8                 //New Velocity
	ldr r2,=#0                  //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 4
	//
	ldr r0,=log4
	ldr r1,=#32               //New Col (32 (L) or 288(R))
	ldr r2,=#129              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#1                 //New Velocity
	ldr r2,=#1                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 5
	//
	ldr r0,=log5
	ldr r1,=#288               //New Col (32 (L) or 288(R))
	ldr r2,=#95              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#-6                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 6
	//
	ldr r0,=log6
	ldr r1,=#100               //New Col (32 (L) or 288(R))
	ldr r2,=#95              //New Row
	strh r1,[r0,#LOG_X]
	ldr r1,=#288
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#-6                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 7
	//
	ldr r0,=log7
	ldr r1,=#32               //New Col (32 (L) or 288(R))
	ldr r2,=#61               //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#6                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 8
	//
	ldr r0,=log8
	ldr r1,=#150               //New Col (32 (L) or 288(R))
	ldr r2,=#61              //New Row
	strh r1,[r0,#LOG_X]
	ldr r1,=#32
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#6                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 9
	//
	ldr r0,=log9
	ldr r1,=#32               //New Col (32 (L) or 288(R))
	ldr r2,=#27              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#6                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	//Load in NEW lily values
	//
	// LILY1
	//
	ldr r0,=lily1
	ldr r1,=#219             //New Col
	ldr r2,=#197			  //New Row
	strh r1,[r0,#LILY_X]
	strh r2,[r0,#LILY_Y]
	//
	// LILY2
	//
	ldr r0,=lily2
	ldr r1,=#49             //New Col
	ldr r2,=#146			  //New Row
	strh r1,[r0,#LILY_X]
	strh r2,[r0,#LILY_Y]
	//
	// LILY3
	//
	ldr r0,=lily3
	ldr r1,=#117            //New Col
	ldr r2,=#112			  //New Row
	strh r1,[r0,#LILY_X]
	strh r2,[r0,#LILY_Y]
	//
	// LILY4
	//
	ldr r0,=lily4
	ldr r1,=#100             //New Col
	ldr r2,=#78			  //New Row
	strh r1,[r0,#LILY_X]
	strh r2,[r0,#LILY_Y]
	//
	// LILY5
	//
	ldr r0,=lily5
	ldr r1,=#219             //New Col
	ldr r2,=#44			  //New Row
	strh r1,[r0,#LILY_X]
	strh r2,[r0,#LILY_Y]
	
	bl DrawText
	mov r1,#0               //Frog initially not submerged
	ldr r2,=water
	ldrb r1,[r2]
	mov r0,#0              //Frog is initially not done with level
	
	// Go into loop.
	// Swap pixel addresses, and draw to unused
 	redo_level_2_loop:
	bl level_2_loop
	mov r3,r0               //r0->r3:frog done? 1=yes,0=no
	//Swap pixel_addr
		ldr r0,=PIX_ADDR		
		mov r1,#1				
		str r1,[r0]
	//End of swap
	//Wait for status to indicate finish
		ldr r0,=STATUS_ADDR
		wait_2_loop:
		ldr r2,[r0]
		mov r1,#1
		and r2,r2,r1    //keep only smallest bit
		cmp r2,#1
		beq wait_2_loop
	//End of wait
	//Check if lives = 0
	ldr r4,=lives
	ldrb r4,[r4]
	cmp r4,#0
	bne Not_dead_2
	mov r0,#0               //game failed, return 0
	b exit_lvl_2
	Not_dead_2:
	cmp r3,#1         		//Check if level is complete
	bne redo_level_2_loop
	mov r0,#1               //level sucessfully complete,return 1
	exit_lvl_2:
pop {r4,pc}
.LTORG


// Called from level_2. 
// Input:  NA
// Output: r0=1 if level complete, r0=0 if level incomplete
// -Updates moving sprites
// -Checks for completion of level. Exits once complete.
// -Changes which buff to use.
level_2_loop:
push {r4,r5,r6,lr}
	
	//r4: which buffer to draw to
	ldr r4,=BACK_PIX_ADDR
	ldr r4,[r4]
	
	// Draw Water
	ldr r0,=0x0A53
	mov r1,r4
	bl ClearVGA
	
	// Draw land
	ldr r0,=#0
	ldr r1,=#18
	mov r2,r4
	bl DrawLand
	ldr r0,=#223
	ldr r1,=#239
	mov r2,r4
	bl DrawLand
	
	// Draw Lilypads
	ldr  r0,=lily1       
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]  // r0 has address, NOT value stored
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily2
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily3
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily4
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily5
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit

	// Check if frog is on top of map
	ldr r0,=frog
	ldrh r1,[r0,#FROG_Y]
	cmp r1,#18				
	blt finished_level_2    
		//LEVEL NOT FINISHED.UPDATE EVERYTHING
		///////////////////////////////
		//Check if frog is submerged...
		ldr r1,=water
		ldrb r1,[r1]
		cmp r1,#1
		blt skip_overwrite_2
		ldr r1,=direction
		mov r0,#0
		strb r0,[r1,#NEW_KEY]
		ldr r1,=frog
		strb r0,[r1,#FROG_JUMP] 
		b do_other_updates_2
		///////////////////////////////
		skip_overwrite_2:
		bl CheckInput
		do_other_updates_2:
		//FROG UPDATE
		mov r0,r4
		bl UpdateFrog 
		// LOG UPDATE
		ldr r0,=log1
		mov r1,r4
		bl UpdateLog
		ldr r0,=log2
		mov r1,r4
		bl UpdateLog
		ldr r0,=log3
		mov r1,r4
		bl UpdateLog
		ldr r0,=log4
		mov r1,r4
		bl UpdateLog
		ldr r0,=log5
		mov r1,r4
		bl UpdateLog
		ldr r0,=log6
		mov r1,r4
		bl UpdateLog
		ldr r0,=log7
		mov r1,r4
		bl UpdateLog
		ldr r0,=log8
		mov r1,r4
		bl UpdateLog
		ldr r0,=log9
		mov r1,r4
		bl UpdateLog
		//CHECK ALL LILYs
		ldr r0,=lily1
		bl CheckLily
		ldr r0,=lily2
		bl CheckLily 
		ldr r0,=lily3
		bl CheckLily
		ldr r0,=lily4
		bl CheckLily
		ldr r0,=lily5
		bl CheckLily
		///////////////////////////////
		//Check if frog is submerged...
		ldr r1,=water
		ldrb r1,[r1]
		cmp r1,#1
		bge is_submerging_2
		///////////////////////////////
		//Print Frog
		ldr r0,=frog
		ldrh r1,[r0,#FROG_X]
		ldrh r2,[r0,#FROG_Y]
		mov  r3,r4              //which buffer
		ldr r0,[r0,#FROG_PIX]
		bl BitBlit
		//Check if in water
		bl CheckWater        //r0 = 1 if in water
		ldr r1,=water
		strb r0,[r1]         //Store fact if frog is in water
		mov r0,#0            //Level not complete
		b exit_level_2_update
	finished_level_2:
	bl IncrementScore       
	bl DrawText             
	mov r0,#1				//Level complete
	mov r1,#0               //Frog not submerging; store that
	ldr r2,=water
    strb r1,[r2]
	exit_level_2_update:
	//Clear on_log & on_lily
	ldr r2,=frog
	mov r3,#0
	strb r3,[r2,#ON_LOG]
	strb r3,[r2,#ON_LILY]
	b exit_level_2_loop
	
	is_submerging_2:
	bl DrawText          //Update display, display lost life.
	ldr r1,=water
	ldrb r0,[r1]         //r0 = water var.
	//See if r0 = 3. This means animation has run its course
	//Time to set frog back to origin, set water var = 0.
	cmp r0,#3
	blt keep_submerged_2
	//Set frog to origin
		ldr r0,=frog
		mov r1,#151
		mov r2,#231
		strh r1,[r0,#FROG_X]
		strh r2,[r0,#FROG_Y]
	//Load original pixmap into frog
		ldr r1,=up_frog
		str r1,[r0,#FROG_PIX]
	//Set water var = 0
		ldr r1,=water
		mov r0,#0
		strb r0,[r1]
	b exit_level_2_loop
	keep_submerged_2:
	bl SubmergeFrog
	add r0,r0,#1
	ldr r1,=water
	strb r0,[r1]        //increment water var & store
	//Draw frog
	ldr r0,=frog
	ldrh r1,[r0,#FROG_X]
	ldrh r2,[r0,#FROG_Y]
	ldr r3,=BACK_PIX_ADDR
	ldr r3,[r3]             //which buffer
	ldr r0,[r0,#FROG_PIX]
	bl BitBlit
	mov r0,#0                 //Level not complete yet
	exit_level_2_loop:
pop {r4,r5,r6,pc}
.LTORG


//
// LEVEL 3
//
// Called from main.
// Inputs:NA
// Outputs: r0. r0 = 1 if level passed, r0 = 0 if failed
// -Draws level 2 scene, run level_2_loop till next level
level_3:
push {r4,lr}
	
	//Set initial frog position
	ldr r0,=frog
	mov r1,#151
	mov r2,#231
	strh r1,[r0,#FROG_X]
	strh r2,[r0,#FROG_Y]
	
	
	//Load in NEW log values
	//
	// LOG 1
	//
	ldr r0,=log1
	ldr r1,=#32               //New Col (32 (L) or 288(R))
	ldr r2,=#214              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#8                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 2
	//
	ldr r0,=log2
	ldr r1,=#288               //New Col (32 (L) or 288(R))
	ldr r2,=#197              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#-2                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 3
	//
	ldr r0,=log3
	ldr r1,=#32               //New Col (32 (L) or 288(R))
	ldr r2,=#180              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#5                 //New Velocity
	ldr r2,=#0                  //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 4 
	//
	ldr r0,=log4
	ldr r1,=#288               //New Col (32 (L) or 288(R))
	ldr r2,=#146              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#-1                 //New Velocity
	ldr r2,=#-1                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 5
	//
	ldr r0,=log5
	ldr r1,=#32               //New Col (32 (L) or 288(R))
	ldr r2,=#129              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#5                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 6   
	//
	ldr r0,=log6
	ldr r1,=#288               //New Col (32 (L) or 288(R))
	ldr r2,=#95              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#-8                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 7    
	//
	ldr r0,=log7
	ldr r1,=#32               //New Col (32 (L) or 288(R))
	ldr r2,=#61               //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#8                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 8
	//
	ldr r0,=log8
	ldr r1,=#32               //New Col (32 (L) or 288(R))
	ldr r2,=#61              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#8                 //New Velocity
	ldr r2,=#0                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	//
	// LOG 9
	//
	ldr r0,=log9
	ldr r1,=#288               //New Col (32 (L) or 288(R))
	ldr r2,=#44              //New Row
	strh r1,[r0,#LOG_X]
	strh r1,[r0,#LOG_INIT_X]
	strh r2,[r0,#LOG_Y]
	ldr r1,=#-1                 //New Velocity
	ldr r2,=#-1                 //New Accel
	strh r1,[r0,#LOG_VEL]
	strh r1,[r0,#LOG_INIT_VEL]
	strh r2,[r0,#LOG_ACCEL]
	
	
	
	//
	//Load in NEW lily values
	//
	// LILY1
	//
	ldr r0,=lily1
	ldr r1,=#253             //New Col
	ldr r2,=#163			  //New Row
	strh r1,[r0,#LILY_X]
	strh r2,[r0,#LILY_Y]
	//
	// LILY2  
	//
	ldr r0,=lily2
	ldr r1,=#253             //New Col
	ldr r2,=#112			  //New Row
	strh r1,[r0,#LILY_X]
	strh r2,[r0,#LILY_Y]
	//
	// LILY3   
	//
	ldr r0,=lily3
	ldr r1,=#100            //New Col
	ldr r2,=#78			  //New Row
	strh r1,[r0,#LILY_X]
	strh r2,[r0,#LILY_Y]
	//
	// LILY4  
	//
	ldr r0,=lily4
	ldr r1,=#202          //New Col
	ldr r2,=#27			  //New Row
	strh r1,[r0,#LILY_X]
	strh r2,[r0,#LILY_Y]
	
	bl DrawText
	mov r1,#0               //Frog initially not submerged
	ldr r2,=water
	ldrb r1,[r2]
	mov r0,#0              //Frog is initially not done with level
	
	// Go into loop.
	// Swap pixel addresses, and draw to unused
 	redo_level_3_loop:
	bl level_3_loop
	mov r3,r0               //r0->r3:frog done? 1=yes,0=no
	//Swap pixel_addr
		ldr r0,=PIX_ADDR		
		mov r1,#1				
		str r1,[r0]
	//End of swap
	//Wait for status to indicate finish
		ldr r0,=STATUS_ADDR
		wait_3_loop:
		ldr r2,[r0]
		mov r1,#1
		and r2,r2,r1    //keep only smallest bit
		cmp r2,#1
		beq wait_3_loop
	//End of wait
	//Check if lives = 0
	ldr r4,=lives
	ldrb r4,[r4]
	cmp r4,#0
	bne Not_dead_3
	mov r0,#0               //game failed, return 0
	b exit_lvl_3
	Not_dead_3:
	cmp r3,#1         		//Check if level is complete
	bne redo_level_3_loop
	mov r0,#1               //level sucessfully complete,return 1
	exit_lvl_3:
pop {r4,pc}
.LTORG

// Called from level_3. 
// Input:  NA
// Output: r0=1 if level complete, r0=0 if level incomplete
// -Updates moving sprites
// -Checks for completion of level. Exits once complete.
// -Changes which buff to use.
level_3_loop:
push {r4,r5,r6,lr}
	
	//r4: which buffer to draw to
	ldr r4,=BACK_PIX_ADDR
	ldr r4,[r4]
	
	// Draw Water
	ldr r0,=0x0A53
	mov r1,r4
	bl ClearVGA
	
	// Draw land
	ldr r0,=#0
	ldr r1,=#18
	mov r2,r4
	bl DrawLand
	ldr r0,=#223
	ldr r1,=#239
	mov r2,r4
	bl DrawLand
	
	// Draw Lilypads
	ldr  r0,=lily1       
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]  // r0 has address, NOT value stored
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily2
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily3
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit
	ldr  r0,=lily4
	ldrh r1,[r0,#LILY_X]
	ldrh r2,[r0,#LILY_Y]
	ldr  r0,[r0,#LILY_PIX]
	mov r3,r4
	bl BitBlit

	// Check if frog is on top of map
	ldr r0,=frog
	ldrh r1,[r0,#FROG_Y]
	cmp r1,#18				
	blt finished_level_3    
		//LEVEL NOT FINISHED.UPDATE EVERYTHING
		///////////////////////////////
		//Check if frog is submerged...
		ldr r1,=water
		ldrb r1,[r1]
		cmp r1,#1
		blt skip_overwrite_3
		ldr r1,=direction
		mov r0,#0
		strb r0,[r1,#NEW_KEY]
		ldr r1,=frog
		strb r0,[r1,#FROG_JUMP] 
		b do_other_updates_3
		///////////////////////////////
		skip_overwrite_3:
		bl CheckInput
		do_other_updates_3:
		//FROG UPDATE
		mov r0,r4
		bl UpdateFrog 
		// LOG UPDATE
		ldr r0,=log1
		mov r1,r4
		bl UpdateLog
		ldr r0,=log2
		mov r1,r4
		bl UpdateLog
		ldr r0,=log3
		mov r1,r4
		bl UpdateLog
		ldr r0,=log4
		mov r1,r4
		bl UpdateLog
		ldr r0,=log5
		mov r1,r4
		bl UpdateLog
		ldr r0,=log6
		mov r1,r4
		bl UpdateLog
		ldr r0,=log7
		mov r1,r4
		bl UpdateLog
		ldr r0,=log8
		mov r1,r4
		bl UpdateLog
		ldr r0,=log9
		mov r1,r4
		bl UpdateLog
		//CHECK ALL LILYs
		ldr r0,=lily1
		bl CheckLily
		ldr r0,=lily2
		bl CheckLily 
		ldr r0,=lily3
		bl CheckLily
		ldr r0,=lily4
		bl CheckLily
		///////////////////////////////
		//Check if frog is submerged...
		ldr r1,=water
		ldrb r1,[r1]
		cmp r1,#1
		bge is_submerging_3
		///////////////////////////////
		//Print Frog
		ldr r0,=frog
		ldrh r1,[r0,#FROG_X]
		ldrh r2,[r0,#FROG_Y]
		mov  r3,r4              //which buffer
		ldr r0,[r0,#FROG_PIX]
		bl BitBlit
		//Check if in water
		bl CheckWater        //r0 = 1 if in water
		ldr r1,=water
		strb r0,[r1]         //Store fact if frog is in water
		mov r0,#0            //Level not complete
		b exit_level_3_update
	finished_level_3:
	bl IncrementScore       
	bl DrawText             
	mov r0,#1				//Level complete
	mov r1,#0               //Frog not submerging; store that
	ldr r2,=water
    strb r1,[r2]
	exit_level_3_update:
	//Clear on_log & on_lily
	ldr r2,=frog
	mov r3,#0
	strb r3,[r2,#ON_LOG]
	strb r3,[r2,#ON_LILY]
	b exit_level_3_loop
	
	is_submerging_3:
	bl DrawText          //Update display, display lost life.
	ldr r1,=water
	ldrb r0,[r1]         //r0 = water var.
	//See if r0 = 3. This means animation has run its course
	//Time to set frog back to origin, set water var = 0.
	cmp r0,#3
	blt keep_submerged_3
	//Set frog to origin
		ldr r0,=frog
		mov r1,#151
		mov r2,#231
		strh r1,[r0,#FROG_X]
		strh r2,[r0,#FROG_Y]
	//Load original pixmap into frog
		ldr r1,=up_frog
		str r1,[r0,#FROG_PIX]
	//Set water var = 0
		ldr r1,=water
		mov r0,#0
		strb r0,[r1]
	b exit_level_3_loop
	keep_submerged_3:
	bl SubmergeFrog
	add r0,r0,#1
	ldr r1,=water
	strb r0,[r1]        //increment water var & store
	//Draw frog
	ldr r0,=frog
	ldrh r1,[r0,#FROG_X]
	ldrh r2,[r0,#FROG_Y]
	ldr r3,=BACK_PIX_ADDR
	ldr r3,[r3]             //which buffer
	ldr r0,[r0,#FROG_PIX]
	bl BitBlit
	mov r0,#0                 //Level not complete yet
	exit_level_3_loop:
pop {r4,r5,r6,pc}
.LTORG


// Called from level loop
// Function increments score when called.
// Inputs:  NA
// Outputs: NA
IncrementScore:
push {r4,r5,lr}
	ldr r4,=score
	ldrb r5,[r4]
	add r5,r5,#1
	strb r5,[r4]
pop {r4,r5,pc}


// Called in various places
// Called to draw text at bottom (including level and lives)
// Inputs:  NA 
// Outputs: NA
// -Note: r0,r1,r2 are all overriden inside.
DrawText:
push {lr}
	bl ClearTextBuffer
	//Write Level
	mov r0,#2
	mov r1,#58
	ldr r2,=level
    bl DrawStr
	mov r0,#8
	mov r1,#58
	ldr r2,=score
	ldrb r2,[r2]
	bl DrawNum
	//Write Lives
	mov r0,#15
	mov r1,#58
	ldr r2,=lives_str
    bl DrawStr
	mov r0,#22
	mov r1,#58
	ldr r2,=lives
	ldrb r2,[r2]
	bl DrawNum
pop {pc}


// Called from level_loop.
// Inputs:  NA 
// Outputs: NA
// -Checks button buffer to see which button has been pressed
// -Updates direction struct based on old state and new press
// -Updates frog struct to document if frog had jumped
CheckInput:
	//r4: Key buffer
	//r5: Direction Struct PTR
	//r6: Intermediate
	//r7: Old state
	//r8: Key pressed
push {r4,r5,r6,r7,r8,lr}
	ldr  r4,=KEY_BUF
	ldrb r8,[r4]
	ldr  r5,=direction
	ldrb r7,[r5,#OLD_KEY]
	and  r6,r7,r8        //AND the old direction with new
	                    //If non-zero: means direction was already pressed
						//Don't add anything to KEY_NEW, simply exit
	cmp r6,#0
	beq update_key
	//If key press isn't new, nothing changes.
	mov r6,#0
	strb r6,[r5,#NEW_KEY]
	//Update frog struct to reflect fact that frog HASN'T jumped
	ldr r7,=frog
	strb r6,[r7,#FROG_JUMP] 
	b exit_update
	update_key:
	strb r8,[r5,#NEW_KEY]    //else (if not repeat): store new keypress
	strb r8,[r5,#OLD_KEY]
	//Update frog struct to reflect fact that frog HAS jumped
	mov r6,#1
	ldr r7,=frog
	strb r6,[r7,#FROG_JUMP] 
	exit_update:
pop {r4,r5,r6,r7,r8,pc}


// Called from level loop.
// Inputs:  r0, Buffer
// Outputs: NA
// -Checks which key has been pressed & if move can happen.
// -If so, it updates position in frog struct & changes pixmap
UpdateFrog:
	push {r4,lr}
	//r4:buffer
	mov r4,r0
	
	ldr r0,=direction
	ldrb r1,[r0,#NEW_KEY]
	cmp r1,#1
	bne down_case
	ldr r0,=frog
	ldrh r1,[r0,#FROG_Y]
	//Check if in bounds...
	cmp r1,#10
	ble exit_updatefrog
	sub r1,r1,#17
	strh r1,[r0,#FROG_Y]
	//Change frog pix_image
	ldr r2,=up_frog
	ldr r3,=frog
	str r2,[r3,#FROG_PIX]
	//Store direction
	mov r1,#0
	strb r1,[r3,#DIR]   
	b exit_updatefrog
	down_case:
	cmp r1,#2
	bne left_case
	ldr r0,=frog
	ldrh r1,[r0,#FROG_Y]
	//Check if in bounds...
	cmp r1,#231
	bge exit_updatefrog
	add r1,r1,#17
	strh r1,[r0,#FROG_Y]
	//Change frog pix_image
	ldr r2,=down_frog
	ldr r3,=frog
	str r2,[r3,#FROG_PIX]
	//Store direction
	mov r1,#1
	strb r1,[r3,#DIR] 
	b exit_updatefrog
	left_case:
	cmp r1,#4
	bne right_case
	ldr r0,=frog
	ldrh r1,[r0,#FROG_X]
	//Check if in bounds...
	cmp r1,#15
	ble exit_updatefrog
	sub r1,r1,#17
	strh r1,[r0,#FROG_X]
	//Change frog pix_image
	ldr r2,=left_frog
	ldr r3,=frog
	str r2,[r3,#FROG_PIX]
	//Store direction
	mov r1,#2
	strb r1,[r3,#DIR] 
	b exit_updatefrog
	right_case:
	cmp r1,#8
	bne exit_updatefrog
	ldr r0,=frog
	ldrh r1,[r0,#FROG_X]
	//Check if in bounds...
	cmp r1,#304
	bge exit_updatefrog
	add r1,r1,#17
	strh r1,[r0,#FROG_X]
	//Change frog pix_image
	ldr r2,=right_frog
	ldr r3,=frog
	str r2,[r3,#FROG_PIX]
	//Store direction
	mov r1,#3
	strb r1,[r3,#DIR] 
	exit_updatefrog:
	//Don't draw frog here: overdraw by other sprites.
pop {r4,pc}



// Called from level loop.
// Input:  r0, lily label. 
// Output: NA
// -Checks if frog is within lily box
//  if so, frog center is alligned
// -Updates on_lily struct element
CheckLily:
push {r4,r5,r6,r7,r8,r9,lr}
	//r4: lily label
	//r5: lily x
	//r6: lily y
	//r7: frog label
	//r8: frog x
	//r9: frog y
	mov  r4,r0
	ldrh r5,[r4,#LILY_X]
	ldrh r6,[r4,#LILY_Y]
	ldr r7,=frog
	ldrh r8,[r7,#FROG_X]
	ldrh r9,[r7,#FROG_Y]
	
	//(1)Check if col quailifies
	add r5,r5,#6
	cmp r8,r5
	bgt Not_On_Lily
	sub r5,r5,#16
	cmp r8,r5
	blt Not_On_Lily
	
	//(2)Check if row qualifies
	add r6,r6,#8
	cmp r9,r6
	bgt Not_On_Lily
	sub r6,r6,#16
	cmp r9,r6
	blt Not_On_Lily
	
	//Passing these tests = frog is on log
	//load coords lof lily into frog struct
	//First,reload unmodified coords
	ldrh r5,[r4,#LILY_X]
	ldrh r6,[r4,#LILY_Y]
	strh r5,[r7,#FROG_X]
	strh r6,[r7,#FROG_Y]
	//
	//If frog is on ANY lily, ON_LILY = 1
	mov r4,#1
	strb r4,[r7,#ON_LILY]  
	Not_On_Lily:
pop {r4,r5,r6,r7,r8,r9,pc}




// Called in level loop.
// Inputs: NA
// Outputs: r0 = 1 if in water
//			r0 = 0 if not in water
// -Call this function after ALL lilypads and logs are updated
// -Check if frog is on any log or lilypad or sandbar
// -If on neither: life is lost, output reflects this
// -Note: Can use output to trigger animation loop
CheckWater:
push {r4,r5,r6,r7,r8,r9,r10,lr}
	//r4:frog label
	//r5:frog x
	//r6:frog y
	//r7:ON_LOG
	//r8:ON_LILY
	//r9:Lives struct
	//r10:Lives var
	ldr r4,=frog
	ldrh r5,[r4,#FROG_X]
	ldrh r6,[r4,#FROG_Y]
	ldrb r7,[r4,#ON_LOG]
	ldrb r8,[r4,#ON_LILY]
	ldr r9,=lives
	ldrb r10,[r9]
	// Check if on bottom sandbar
	cmp r6,#223       //223 = start of bottom row				
	bgt not_in_water
	// Check if on top sandbar
	cmp r6,#18        //18 = start of top row
	blt not_in_water
	cmp r7,#1
	beq not_in_water
	cmp r8,#1
	beq not_in_water
	// Failing tests:frog is in water
	mov r0,#1
	// Subtract life, save
	sub r10,r10,#1
	strb r10,[r9]
	mov r0,#1
	b exit_checkwater
	not_in_water:
	mov r0,#0
	b exit_checkwater
	exit_checkwater:
pop {r4,r5,r6,r7,r8,r9,r10,pc}



// Called in level loop
// Inputs: r0, frame number
// Output: NA
// -Changes frog pixmap ptr when called to next frame.
// -Grabs next frog pixmap ptr, loads it into frog
// -Don't modify r1
SubmergeFrog:
push {r4,r5,r6,r7,r8,r9,lr}
	//r4:frame number
	//r5:frog label
	//r6:frog pixmap ptr
	//r7:frog direction
	//r8:new pixmap ptr
	mov r4,r0
	ldr r5,=frog
	ldr r6,[r5,#FROG_PIX]
	ldrb r7,[r5,#DIR]
	
	// (0) Frog is facing up
	cmp r7,#0
	bne face_down
	cmp r4,#1
	bne u_2
		ldr r8,=up_frog_2
		str r8,[r5,#FROG_PIX]
		b exit_submerge
	u_2:
	cmp r4,#2
	bne exit_submerge
		ldr r8,=up_frog_3
		str r8,[r5,#FROG_PIX]
		b exit_submerge
		
	// (1) Frog is facing down
	face_down:
	cmp r7,#1
	bne face_left
	cmp r4,#1
	bne d_2
		ldr r8,=down_frog_2
		str r8,[r5,#FROG_PIX]
		b exit_submerge
	d_2:
	cmp r4,#2
	bne exit_submerge
		ldr r8,=down_frog_3
		str r8,[r5,#FROG_PIX]
		b exit_submerge
	
	// (2) Frog is facing left
	face_left:
	cmp r7,#2
	bne face_right
	cmp r4,#1
	bne l_2
		ldr r8,=left_frog_2
		str r8,[r5,#FROG_PIX]
		b exit_submerge
	l_2:
	cmp r4,#2
	bne exit_submerge
		ldr r8,=left_frog_3
		str r8,[r5,#FROG_PIX]
		b exit_submerge
	
	// (3) Frog is facing right
	face_right:
	cmp r7,#3
	bne exit_submerge
	cmp r4,#1
	bne r_2
		ldr r8,=right_frog_2
		str r8,[r5,#FROG_PIX]
		b exit_submerge
	r_2:
	cmp r4,#2
	bne exit_submerge
		ldr r8,=right_frog_3
		str r8,[r5,#FROG_PIX]
		b exit_submerge
	exit_submerge:
pop {r4,r5,r6,r7,r8,r9,pc}
	
	
// Called from main program.
// Inputs: NA
// Outputs:NA
// -Clears screen with message after death
GameLost:
push {lr}
	//Fill front buffers with black color
	ldr r0,=0x0000
	ldr r1,=PIX_ADDR
	ldr r1,[r1]
	bl ClearVGA	
	bl ClearTextBuffer
	mov r0,#39
	mov r1,#30
	ldr r2,=lost_str
    bl DrawStr	
pop {pc}



// Called from main program
// Inputs: NA
// Outputs:NA
// -Clears screen with message after survival
GameWon:
push {lr}
	//Fill front buffer with green
	ldr r0,=0x05C4
	ldr r1,=PIX_ADDR
	ldr r1,[r1]
	bl ClearVGA
	bl ClearTextBuffer
	mov r0,#34
	mov r1,#30
	ldr r2,=win_str
    bl DrawStr
pop {pc}


// Called from level loop for every log.
// Inputs:  
// 			r0, pointer to log
//			r1,	buffer
// Outputs: NA
// -Updates log position, checks is frog is on log, draws log
UpdateLog:
	push {r4,r5,r6,r7,r8,r9,r10,r11,lr}
	//r4:buffer
	//r5:log pointer
	//r6:Log X
	//r7:Log Y
	//r8:Log Vel
	//r9:Log Accel
	//r10:Log initial x
	//r11:Log initial vel
	mov   r4,r1
	mov   r5,r0
	ldrh  r6,[r5,#LOG_X]
	ldrh  r7,[r5,#LOG_Y]
	ldrsh r8,[r5,#LOG_VEL]
	ldrsh r9,[r5,#LOG_ACCEL]
	ldrh  r10,[r5,#LOG_INIT_X]
	ldrsh  r11,[r5,#LOG_INIT_VEL]
	
	//Change x_pos and x_vel
	add r6,r6,r8
	add r8,r8,r9
	
	//Bounds checked
	cmp r6,#32
	ble delete_log
	ldr r3,=#288
	cmp r6,r3
	bge delete_log
	
	//Save new x_pos and x_vel
	strh r6,[r5,#LOG_X]
	strh r8,[r5,#LOG_VEL]
	ldr r0,[r5,#LOG_PIX]
	mov r1,r6
	mov r2,r7
	mov r3,r4              //Change r3 to buff
	bl BitBlit
	b check_froggie 
	
	delete_log:
	strh r10,[r5,#LOG_X]    //reset x to init_x
	strh r11,[r5,#LOG_VEL]  //reset vel to init_vel
	//Set inputs for BitBlit
	ldr  r0,[r0,#LOG_PIX]  //
	mov  r1,r6
	mov  r2,r7
	mov  r3,r4              //Change r3 to buff
	bl BitBlit
	b exit_updatelogs
	
	check_froggie:
	mov r0,r5          //r0 = label of log
	bl  didFrogLand
	cmp r0,#1
	bne exit_updatelogs
	
	// Update on_log. Cleared after level loop.
	ldr r2,=frog
	strb r0,[r2,#ON_LOG]
	// Edit frog position
	add  r1,r1,r8        //r1 = relative offset + velocity
	add  r1,r1,r6        //r1 = r1 + log_x
	sub  r1,r1,r9        //r1 = r1 - accel
	strh r1,[r2,#FROG_X] 
	strh r7,[r2,#FROG_Y] 
	//Frog is drawn in UpdateFrog, not here
	exit_updatelogs:
	pop {r4,r5,r6,r7,r8,r9,r10,r11,pc}


// Helper to UpdateLog function
// Input: r0, pointer to log
// Output:
// 		  r0 = 0 if no landing; r0 = 1 if frog lands on log
// 		  r1 = amount of pixels between center of frog and log (x)
//       (Only changes if frog lands: r0 =1)
// -Tells if frog overlaps with input log
didFrogLand:
	//r0: Pointer (address) of log of interest
	push {r4,r5,r6,r7,lr}
	ldrh r1,[r0,#LOG_X]
	ldrh r2,[r0,#LOG_Y]
	ldr  r4,=frog
	ldrh r5,[r4,#FROG_X]
	ldrh r6,[r4,#FROG_Y]
	//Frog center must lie in bounding box of log.
	//Log has 64 pixel length (roughly 31 on each side of center)
	// and 16 pixel width (roughly 8 on each side of center
	
	//(1)Check if col quailifies
	add r1,r1,#31
	cmp r5,r1
	bgt water_landing
	sub r1,r1,#62
	cmp r5,r1
	blt water_landing
	
	//(2)Check if row qualifies
	add r2,r2,#8
	cmp r6,r2
	bgt water_landing
	sub r2,r2,#8
	cmp r6,r2
	blt water_landing
	
	//Passing these tests = frog is on log
	ldrh r1,[r0,#LOG_X]   //make r1 log center again
	mov r0,#1
	sub r1,r5,r1          
			//Frog_x - Log_x => r1
			// If frog to left of log center : r1 is (-)
		    // If frog to right of log center : r1 is (+)
	b exit_didFrogLand
	water_landing:
	mov r0,#0
	exit_didFrogLand:
pop {r4,r5,r6,r7,pc}



// Called from level function
// Input: 
//		r0 = Top row bound
//		r1 = Bottom row bound
//		r2 = Buffer
// Output: None
// -Draws land (end of level) to both buffers
DrawLand:
push {r4,r5,r6,r7,r8,r9,lr}
	//r4: Top row
	//r5: Bottom Row
	//r6: Color
	//r7: Pixel Buff
	//r8: Intermediate
	//r9: Current col
	mov r4,r0
	mov r5,r1
	ldr r6,=#0x9C81 //sand color
		
	b land_row_cond
	land_row:
		//inner loop start
		mov r9,#0
		b land_col_cond
		land_col:
			//MEAT
			mov r7,r2             //Load in address of pix_buf
			orr r7,r7,r9,lsl #1
			orr r7,r7,r4,lsl #10  //Combine x and y in pix_buf
			strh r6,[r7]         
			add r9,r9,#1
	 	land_col_cond:
		    ldr r8,=#319
			cmp r9,r8
			ble land_col
		//inner loop end
		add r4,r4,#1
	land_row_cond:
		ldr r8,=#239
		cmp r4,r8
		bgt exit_drawland
		cmp r4,r5
		ble land_row	
	exit_drawland:	
	pop {r4,r5,r6,r7,r8,r9,pc}





//
// OLD FUNCTIONS: DON"T MODIFY ANYTHING BELOW
//

ClearTextBuffer:
	push {r4,r5,lr}
	 //r4 (x,col) goes from 0 to 79
	 //r5 (y,row) goes from 0 to 59
	mov r4,#0
	mov r5,#0
	
	b clear_row_cond
	clear_row:
		//inner loop start
		mov r4,#0
		b clear_col_cond
		clear_col:
			mov r0,r4
			mov r1,r5
			mov r2,#0x20
			bl WriteASCII
			add r4,r4,#1
	 	clear_col_cond:
			cmp r4,#79
			ble clear_col
		//inner loop end
		add r5,r5,#1
	clear_row_cond:
		cmp r5,#59
		ble clear_row	
	exit_clear_text:
	pop {r4,r5,pc}



//r0:color
//r1:buffer
ClearVGA:
	push {r4,r5,r6,r7,r8,lr}
	//r1: Buffer
	//r4: Color
	//r5: Pixel Col  (x)
	//r6: Pixel Row  (y)
	//r7: Pixel Buff
	//r8: Intermediate
	mov r4,r0
	mov r5,#0
	mov r6,#0
	
	b color_row_cond
	color_row:
		//inner loop start
		mov r5,#0
		b color_col_cond
		color_col:
			//MEAT
			mov r7,r1            //CHANGE:Load in address of buffer
			orr r7,r7,r5,lsl #1
			orr r7,r7,r6,lsl #10  //Combine x and y in buffer
			strh r4,[r7]         
			add r5,r5,#1
	 	color_col_cond:
		    ldr r8,=#319
			cmp r5,r8
			ble color_col
		//inner loop end
		add r6,r6,#1
	color_row_cond:
		ldr r8,=#239
		cmp r6,r8
		ble color_row	
	pop {r4,r5,r6,r7,r8,pc}




//Pixmap Data 
//{
//	width : halfword
//	height : halfword
//	transparency : halfword
//	pixeldata : halfword list (length = width * height)
//}

//Inputs: r0,r1,r2,r3 (which buffer to use)
BitBlit:
	push {r4,r5,r6,r7,r8,r9,r10,r11,lr}
	//r3: buffer
	//r4: pixel map pointer (pointer to image we must draw)
	//r5:  x coordinate of current x pixel coord
	//r6:  y coordinate of current y pixel coord
	//r7:  Width of map, later used as loop var limit (col,x)
	//r8:  Height of map,later used as loop var limit (row,y)
	//r9:  Loop index
	//r10: Pix buf, also used as temp var in several spots
	//r11: Color for pixel

	
	mov r4,r0
	ldrh r7,[r4,#PIXMAP_WIDTH]
	ldrh r8,[r4,#PIXMAP_HEIGHT]
	
	//Compute where to start on Pixel buffer for VGA first
	lsr r5,r7,#1    //lsr for unsigned is division by 2 (approx)
	lsr r6,r8,#1
	sub r5,r1,r5
	sub r6,r2,r6
	// r5(x) and r6(y) now contain top-left corner of image
	// will be used as pixel loop var
	
	mov r9,#0
	b draw_row_cond
	draw_row:
		//inner loop start
		ldrh r7,[r4,#PIXMAP_WIDTH]  //load in width for new row
		b draw_col_cond
		draw_col:
			
			add r10,r4,#PIXMAP_PIXELDATA //r10 = address of start of data (temp var)
			ldrh r11,[r10,r9]            //Got next halfword
			mov r10,r3                   //CHANGE (1) : ...=PIX_BUFFER 
			orr r10,r10,r5,lsl #1
			orr r10,r10,r6,lsl #10       //Combine x and y in pix_buf
			
			//Check if transparent.
		    ldrh r1,[r4,#PIXMAP_TRANSPARENCY]
			cmp r1,r11
			beq  transparent
			strh r11,[r10]
			transparent:
			add r9,r9,#2           //Next halfword color, increment by 2 (2 bytes later)
			add r5,r5,#1
			sub r7,r7,#1
			//		
		draw_col_cond:
		    cmp r7,#0
			ble next_line
		    ldr r10,=#319
			cmp r5,r10
			bgt right_col_cutoff
			ble draw_col
		//inner loop end
		
		
		//below is pain
		right_col_cutoff:
		ldrh r10,[r4,#PIXMAP_WIDTH]
		sub r10,r10,r7         //r10 = #cols printed  (8-cut off cols)
		sub r5,r5,r10          //x-coord brought back to start (works)
		add r6,r6,#1           //move down y-coord pixel
		sub r8,r8,#1           //Next row...
		//Move forward in index (r9) by cutoff amount
		add r9,r9,r7,lsl #1
		b draw_row_cond
			
		next_line:
			//Move cursor x(r5) and y(r6)
			ldrh r7,[r4,#PIXMAP_WIDTH]   //load in width
			sub r5,r5,r7                 //Move cursor left by width pixels
			add r6,r6,#1                 //Move cursor down by one pixel(next row)     
			sub r8,r8,#1                  //subtract height
	draw_row_cond:
		ldr r10,=#239
		cmp r6,r10
		bgt exit_bb
		cmp r8,#0        //r8 = # rows
		bgt draw_row
		
	exit_bb:	
	pop {r4,r5,r6,r7,r8,r9,r10,r11,pc}




//
//Helpers to ClearTextBuffer
//

DrawStr:
	push {r4,r5,r6,r7,r8,lr}
	//r4 : x-pos of string start
	//r5 : y-pos of string start
	//r6 : Address of char (initially first char)
	//r7 : Ascii value of char

	mov r4,r0
	mov r5,r1
	mov r6,r2

	b drawstr_cond
	drawstr_loop:
	    mov r0,r4             //Load in args
		mov r1,r5
		mov r2,r7             
		bl WriteASCII
	    add r4,r4,#1          // Increment x-position
		//add r5,r5,#1     <-- No need to increment: want horizontally displayed string
		add r6,r6,#1          // Increment char address to get next char
	drawstr_cond:
	    ldrb r7,[r6]         // Load in next char in string
		mov r0,r4             //Check if in bounds
	    mov r1,r5
		bl CheckBounds
		cmp r0,#0
		beq exit_drawstr
		cmp r7,#0            // Check if null character
		beq exit_drawstr
		b drawstr_loop
		
	exit_drawstr:
	pop {r4,r5,r6,r7,r8,pc}


//
// Helper to DrawStr
//
CheckBounds:
    push {lr}
	cmp r0,#80           // Check if x-coordinate in bounds
	bge out_of_bounds
	cmp r0,#0
	blt out_of_bounds
	
	cmp r1,#60           // Check if y-coordinate in bounds
	bge out_of_bounds
	cmp r0,#0
	blt out_of_bounds
	
	//Else
	b in_bounds
	
	out_of_bounds:
	mov r0,#0
	b exit_CheckBounds
	in_bounds:
	mov r0,#1
	exit_CheckBounds:
	pop {pc}


//DrawNum(x,y,n)
//Prints R->L, therefore checks leftword bounds.
DrawNum:
	push {r4,r5,r6,r7,r8,r9,lr}
	//r4: X-coord
	//r5: Y-coord
	//r6: Number to Draw (Dividend)
	//r7: Digit to draw (Remainder)
	//r8: Intermediate results
	//r9: Signed? (1=Yes,0=No)
	
	mov r4,r0
	mov r5,r1
	mov r6,r2  
	mov r7,#0
	mov r8,#0
	mov r9,#0
	
	//Initial check to see if inputs may be valid
	bl CheckBounds
	cmp r0,#0
	beq done_with_drawnum
	
	//Check if signed
	cmp r6,#0
	bge drawnum_loop
	mov r9,#1
	//Take absolute value of dividend (r6)
	asr r8,r6,#31       //Shift to right by 31
    add r6, r6, r8          
    eor r6, r6, r8 
	mov r8,#0
	
	
	//No branch to condition: Want loop to run at least once
	//If we want zero to be printed
	drawnum_loop:
	mov r0,r6             //Update dividend input
	bl  div10             //After this: r0 = quotient
	lsl r8,r0,#3          
	add r8,r8,r0,lsl #1   //Now: r8 = 10*quotient
	sub r7,r6,r8          //Remainder (r7) = k-10*quotient
	mov r6,r0             //move quotient to replace dividend
	
	//Now, print r7: remainder
	add r7,r7,#48         //Turn number into ASCII
	mov r0,r4             //Load args
	mov r1,r5
	mov r2,r7
	bl WriteASCII
	sub r4,r4,#1          // Decrement X-Coord (printing R->L)
	num_cond:
	    mov r0,r4             //Check if in bounds
	    mov r1,r5
		bl CheckBounds
		cmp r0,#0
		beq done_with_drawnum
		cmp r6,#0              //Check if end has been arrived at
		bne drawnum_loop
	
	//Draw sign
	cmp r9,#1
	bne done_with_drawnum
	mov r0,r4             //Load position args
	mov r1,r5
	mov r2,#45             //Load ASCII "-"
	bl WriteASCII
	
	done_with_drawnum:
pop {r4,r5,r6,r7,r8,r9,pc}

//Return quotient of divison r0/#10
div10:
	push {r4,r5,lr}
	//r0 : divdend
	//r4 : remainder
	//r5 : quotient
	mov r4,r0
	mov r5,#0
	b d_cond
	d_loop:
		sub r4,r4,#10
		add r5,r5,#1
	d_cond:
		cmp r4,#10
		bge d_loop
	mov r0,r5
pop {r4,r5,pc}



//WriteASCII(x,y,ASCII)
WriteASCII:
	push {r4,r5,r6,r7,r8,lr}
	//r4: x-coord
	//r5: y-coord
	//r6: Ascii value to draw
	//r7: Charbuf
	//r8: Address to draw to
	mov r4,r0
	mov r5,r1
	mov r6,r2
	ldr r7,=CHARBUF
	mov r8,#0
	add r8,r7,r5,lsl #7   // Move y-coord into proper spot (7 bits into charbuff)
    add r8,r8,r4          // Move x-coord into charbuff
    strb r6,[r8]          // Store character in charbuff address
pop {r4,r5,r6,r7,r8,pc}


