Fork me on GitHub
-- title:   IK elbows
-- author:  congusbongus
-- desc:    Draw an arm with an elbow joint that bends realistically, given hand and shoulder positions
-- license: CC0
-- script:  moon
-- tags:    ik joint animation bone

distance=(x1,y1,x2,y2)->
	dx=x1-x2
	dy=y1-y2
	return math.sqrt(dx*dx+dy*dy)

thickline=(x1,y1,x2,y2,whalf,c)->
	dx,dy=x1-x2,y1-y2
	d=distance(x1,y1,x2,y2)
	dxn,dyn=dx/d,dy/d
	pxn,pyn=dyn,-dxn
	px,py=pxn*whalf,pyn*whalf
	xa,ya=x1+px,y1+py
	xb,yb=x2+px,y2+py
	xc,yc=x2-px,y2-py
	xd,yd=x1-px,y1-py
	tri(xa,ya,xb,yb,xc,yc,c)
	tri(xc,yc,xd,yd,xa,ya,c)

ARMLEN=40
ARMOUTC=0
ARMFILLC=7
arm=(x1,y1,x2,y2)->
	whalf=5
	d=distance(x1,y1,x2,y2)
	-- add elbows
	ed=0
	if d<ARMLEN
		ed=(ARMLEN-d)/2
	dx,dy=x1-x2,y1-y2
	dxn,dyn=dx/d,dy/d
	pxn,pyn=dyn,-dxn
	-- bend elbows perpendicular to arm, outwards
	if (x1>x2) != (y1<y2)
		pxn,pyn=-pxn,-pyn
	-- exception if arms too close - always bend downwards
	if d<20
		pxn,pyn=0,1
	ex=(x1+x2)/2+pxn*ed
	ey=(y1+y2)/2+pyn*ed
	-- arm and hand outlines
	thickline(x1,y1,ex,ey,whalf,ARMOUTC)
	circb(ex,ey,whalf,ARMOUTC)
	thickline(ex,ey,x2,y2,whalf,ARMOUTC)
	circb(x2,y2,8,ARMOUTC)
	-- arm and hand fills
	thickline(x1,y1,ex,ey,whalf-1,ARMFILLC)
	circ(ex,ey,whalf-1,ARMFILLC)
	thickline(ex,ey,x2,y2,whalf-1,ARMFILLC)
	circ(x2,y2,7,ARMFILLC)

CHAR_W=64
char_x=80
char_y=40
hand_l_x=80
hand_l_y=100
hand_r_x=150
hand_r_y=60
target="left hand"

move=(x,y)->
	if btn(0)
		y-=1
	elseif btn(1)
		y+=1
	if btn(2)
		x-=1
	elseif btn(3)
		x+=1
	return x,y

export TIC=->
	-- Move body part using arrow keys
	if target=="left hand"
		hand_l_x,hand_l_y=move(hand_l_x,hand_l_y)
	elseif target=="right hand"
		hand_r_x,hand_r_y=move(hand_r_x,hand_r_y)
	else
		char_x,char_y=move(char_x,char_y)
	-- Change target body part with A/B buttons
	if btnp(4) or btnp(5)
		if target=="left hand"
			target="right hand"
		elseif target=="right hand"
			target="body"
		else
			target="left hand"

	cls(8)
	-- Draw body
	spr(0,char_x,char_y,8,1,0,0,8,8)
	-- Left arm
	arm(char_x+CHAR_W/2-15,char_y+30,hand_l_x,hand_l_y)
	-- Right arm
	arm(char_x+CHAR_W/2+19,char_y+38,hand_r_x,hand_r_y)
	-- Draw cursor
	if target=="left hand"
		spr(256,hand_l_x-8,hand_l_y-8,0,1,0,0,2,2)
	elseif target=="right hand"
		spr(256,hand_r_x-8,hand_r_y-8,0,1,0,0,2,2)
	else
		spr(256,char_x+24,char_y+30,0,1,0,0,2,2)

	print("Moving: #{target}",84,12,12)

-- <TILES>
-- 000:8888888888888888888888888888888888888888888888888888888888888888
-- 001:8888888888888888888888888888888888888888888888888888888888888888
-- 002:8888888888888888888888888888888888888888888888888888888888888888
-- 003:8888888888888888888888888888888888888888888888888888888888888888
-- 004:8888880088880000888000008800000088000000800000008000000080000000
-- 005:0000000000000000000000000000000000000000000000000000000000777777
-- 006:0888888800000888000088880000008800000888000088880000008870000088
-- 007:8888888888888888888888888888888888888888888888888888888888888888
-- 016:8888888888888888888888888888888888888888888888888888888888888888
-- 017:8888888888888888888888888888888888888888888888888888888888888888
-- 018:8888888888888888888888888888888888888888888888888888888888888888
-- 019:8888888888888888888888888888888888888888888888888888888888888888
-- 020:8000000080000000800000008000000080000000880000778800007788000077
-- 021:07777777000777777770077707777070070cc77700cc07700777777777777777
-- 022:770008887708888800088888770888880c088888c00888887708888870888888
-- 023:8888888888888888888888888888888888888888888888888888888888888888
-- 032:8888888888888888888888888888888888888888888888888888888888888888
-- 033:8888888888888888888888888888888888888888888888888888888888888888
-- 034:8888888888888888888888888888888888888888888888888888888888888888
-- 035:8888888888888888888888888888888888888888888888888888888888888888
-- 036:8800000088000066880006678806667780666777806677778067777706777770
-- 037:77777777777777007777777777777ccc7777dddd77777ccc7777777707777770
-- 038:770888880008888870888888c0888888d0888888c08888887088888808888888
-- 039:8888888888888888888888888888888888888888888888888888888888888888
-- 048:8888888888888888888888888888888888888888888888888888888888888888
-- 049:8888888888888888888888808888880788888077888880778888807688888077
-- 050:8800000080777777077677777767777776777777677777777777777777777777
-- 051:0088888877000080777011007770111077011110770111107701111067011110
-- 052:0677777667677777676777777767777777767777777677777776777777767776
-- 053:6000000866608888666088887660888876088888670088886770000077701110
-- 054:8888888888888888888888888888888888888888888888888888888800008888
-- 055:8888888888888888888888888888888888888888888888888888888888888888
-- 064:8888888888888888888888888888888888888888888888888888888888888888
-- 065:8888807788888867888888678888888788888888888888888888888888888888
-- 066:7777777677777767777776777777677767666600880600118880111188801111
-- 067:7011111070111111011111110111111111111111111111111111111111111111
-- 068:7777777607777767077777771077777710007770111100011111111111111111
-- 069:7770111077701107770111070011110711111107111110771111107611111077
-- 070:7777008877777088777777087777770877777708777777787777777867777708
-- 071:8888888888888888888888888888888888888888888888888888888888888888
-- 080:8888888888888888888888888888888888888888888888888888888888888888
-- 081:8888888888888888888888888888888888888888888888888888888888888888
-- 082:8880111188801111888011118801111188011111880111118801111180011111
-- 083:1111111111111111111111111111111111111111111111111111111111111111
-- 084:1111111111111111111111111111111111111111111111111111111111111111
-- 085:1111107711110777111107771111000011110888111088881110888811108888
-- 086:6777770876777088767708880677088888008888888888888888888888888888
-- 087:8888888888888888888888888888888888888888888888888888888888888888
-- 096:8888888888888888888888888888888888888888888888888888888888888888
-- 097:8888888888888888888888888888888888888888888888888888888088888880
-- 098:8011111180111111011111110111111101111111011111111111111111111111
-- 099:1111111111111111111111111111111111111111111111111111111111111111
-- 100:1111111111111111111111111111111111111111111111111111111111111111
-- 101:1110888811108888111088881108888811088888110888881108888810888888
-- 102:8888888888888888888888888888888888888888888888888888888888888888
-- 103:8888888888888888888888888888888888888888888888888888888888888888
-- 112:8888888888888888888888888888888888888888888888888888888888888888
-- 113:8888880188888801888880118888881188888881888888888888888888888888
-- 114:1111111111111111111111111111111111111111111111118888111188888888
-- 115:1111111111111111111111111111111111111111111111111111111188888888
-- 116:1111111111111111111111111111111111111111111111111111111188888811
-- 117:1088888810888888108888881088888810888888108888880888888808888888
-- 118:8888888888888888888888888888888888888888888888888888888888888888
-- 119:8888888888888888888888888888888888888888888888888888888888888888
-- </TILES>

-- <SPRITES>
-- 000:0000000400000044000004440000000400000004004000000440000044444000
-- 001:0000000040000000440000000000000000000000000040000000440000444440
-- 016:0440000000400000000000040000000400000444000000440000000400000000
-- 017:0000440000004000000000000000000044000000400000000000000000000000
-- </SPRITES>

-- <SCREEN>
-- 000:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 001:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 002:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 003:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 004:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 005:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 006:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 007:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 008:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 009:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 010:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 011:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 012:888888888888888888888888888888888888888888888888888888888888888888888888888888888888cc8cc8888888888888cc8888888888888cc88888cc8888888888888cc888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 013:888888888888888888888888888888888888888888888888888888888888888888888888888888888888ccccc88ccc88cc88c8888cccc888ccc88cc88888cccc888ccc888cccc8c88cc888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 014:888888888888888888888888888888888888888888888888888888888888888888888888888888888888ccccc8cc88c8cc88c8cc8cc88c8c88cc88888888cc88c8cc88c8c88cc8c88cc888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 015:888888888888888888888888888888888888888888888888888888888888888888888888888888888888c8c8c8cc88c88ccc88cc8cc88c8ccccc8cc88888cc88c8cc88c8c88cc88cccc888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 016:888888888888888888888888888888888888888888888888888888888888888888888888888888888888c888c88ccc8888c888cc8cc88c8888cc8cc88888cccc888ccc888cccc8888cc888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 017:8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888ccc8888888888888888888888888888ccc8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 018:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 019:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 020:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 021:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 022:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 023:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 024:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 025:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 026:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 027:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 028:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 029:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 030:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 031:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 032:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 033:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 034:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 035:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 036:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888880000000000088888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 037:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888000000000000000008888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 038:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888880000000000000000088888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 039:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888800000000000000000000888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 040:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888800000000000000000008888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 041:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888000000000000000000088888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 042:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888000000000000000000000888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 043:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888000000000777777700000888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 044:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888000000007777777770008888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 045:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888000000000077777770888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 046:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888000000077700777000888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 047:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888000000007777070770888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 048:8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888880000000070cc7770c0888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 049:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888800007700cc0770c00888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 050:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888800007707777777770888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 051:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888800007777777777708888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 052:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888800000077777777770888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 053:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888800006677777700000888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 054:888888888888888888888888888888888888888888888888888888888888888888888888888888888888880000088888888888888888888888888800066777777777708888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 055:888888888888888888888888888888888888888888888888888888888888888888888888888888888888808777008888888888888888888888888806667777777cccc08888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 056:88888888888888888888888888888888888888888888888888888888888888888888888888888888888808777770088888888888888888888888806667777777ddddd08888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 057:888888888888888888888888888888888888888888888888888888888888888888888888888888888880877777777008888888888888888888888066777777777cccc08888888888888888888800000888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 058:888888888888888888888888888888888888888888888888888888888888888888888888888888888880777777777770088888888888888888888067777777777777708888888888888888880077777008888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 059:888888888888888888888888888888888888888888888888888888888888888888888888888888888880777777777777700888888888888888880677777007777770088888888888888888807777777770888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 060:888888888888888888888888888888888888888888888888888888888888888888888888888888888807777777777777777008000000008888880677777660000008888888888888888888077777777777088888888888888888888888888888888888888888888888888888888888888888888888888888
-- 061:888888888888888888888888888888888888888888888888888888888888888888888888888888888007777777777777777770077777770000806767777766608888888888888888888880777777777777708888888888888888888888888888888888888888888888888888888888888888888888888888
-- 062:888888888888888888888888888888888888888888888888888888888888888888888888888888888077777777777777777777767777777011006767777766608888888888888888888880777777777777708888888888888888888888888888888888888888888888888888888888888888888888888888
-- 063:888888888888888888888888888888888888888888888888888888888888888888888888888888880777777777777777777777677777777011107767777776608888888888888888888807777777777777770888888888888888888888888888888888888888888888888888888888888888888888888888
-- 064:888888888888888888888888888888888888888888888888888888888888888888888888888888800777777777777777777777777777770111107776777776088888888888888888888807777777777777770888888888888888888888888888888888888888888888888888888888888888888888888888
-- 065:888888888888888888888888888888888888888888888888888888888888888888888888888880077777777777077777777777777777770111107776777767008888888888888888888807777777777777770888888888888888888888888888888888888888888888888888888888888888888888888888
-- 066:888888888888888888888888888888888888888888888888888888888888888888888888888807777777777770800777777777777777770111147776777767700000888888888888888807777777777777770888888888888888888888888888888888888888888888888888888888888888888888888888
-- 067:888888888888888888888888888888888888888888888888888888888888888888888888888077777777777700888007777777777777670111444776777677701110000088888888888807777777777777770888888888888888888888888888888888888888888888888888888888888888888888888888
-- 068:888888888888888888888888888888888888888888888888888888888888888888888888880777777777777708888880077777777776701114444477777677701110777700888888888807777777777777708888888888888888888888888888888888888888888888888888888888888888888888888888
-- 069:888888888888888888888888888888888888888888888888888888888888888888888888880777777777777708888888800777777767701111140777776777701107777700888888888807777777777777708888888888888888888888888888888888888888888888888888888888888888888888888888
-- 070:888888888888888888888888888888888888888888888888888888888888888888888888807777777777777770888888886777777677011111140777777777011107777777000088888077777777777777088888888888888888888888888888888888888888888888888888888888888888888888888888
-- 071:888888888888888888888888888888888888888888888888888888888888888888888888807777777777777770888888888777776777014111111077477700111107777777777700000077777777777770888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 072:888888888888888888888888888888888888888888888888888888888888888888888888807777777777777770888888888867666600144111111000447011111107777777777777770777777777777008888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 073:888888888888888888888888888888888888888888888888888888888888888888888888807777777777777770888888888888060011444441111144444111111077777777777777777777777777000888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 074:888888888888888888888888888888888888888888888888888888888888888888888888807777777777777770888888888888801111144111111111441111111076777777777777777777777770888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 075:888888888888888888888888888888888888888888888888888888888888888888888888880777777777777708888888888888801111114111111111411111111077677777777777777777777770888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 076:888888888888888888888888888888888888888888888888888888888888888888888888880777777777777708888888888888801111111111141111111111111077677777777777777777777708888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 077:888888888888888888888888888888888888888888888888888888888888888888888888888077777777777088888888888888801111111111141111111111110777767777777777777777777008888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 078:888888888888888888888888888888888888888888888888888888888888888888888888888807777777770888888888888888801111111114444411111111110777760007777777777777777088888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 079:888888888888888888888888888888888888888888888888888888888888888888888888888880077777008888888888888888011111111111444111111111110000067700000777777777778088888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 080:888888888888888888888888888888888888888888888888888888888888888888888888888888800000888888888888888888011111111111141111111111110888880088888000077777780888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 081:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888011111111111111111111111108888888888888888800777808888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 082:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888011111111111111111111111108888888888888888880000088888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 083:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888880011111111111111111111111108888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 084:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888880111111111111111111111111108888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 085:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888880111111111111111111111111108888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 086:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888801111111111111111111111111108888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 087:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888801111111111111111111111111088888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 088:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888801111111111111111111111111088888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 089:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888801111111111111111111111111088888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 090:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888011111111111111111111111111088888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 091:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888011111111111111111111111110888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 092:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888880111111111111111111111111110888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 093:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888880111111111111111111111111110888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 094:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888801111111111111111111111111110888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 095:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888881111111111111111111111111110888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 096:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888111111111111111111111111110888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 097:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888811111111111111111111111110888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 098:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888881111111111111111111108888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 099:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888881108888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 100:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 101:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 102:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 103:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 104:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 105:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 106:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 107:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 108:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 109:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 110:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 111:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 112:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 113:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 114:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 115:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 116:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 117:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 118:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 119:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 120:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 121:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 122:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 123:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 124:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 125:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 126:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 127:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 128:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 129:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 130:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 131:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 132:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 133:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 134:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- 135:888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
-- </SCREEN>

-- <PALETTE>
-- 000:000000d63600e47200f2b500ffff00a0470ce7964ef7b88e3072a43b5dcb41a6f673eff7f4f4f4a3a3a3525252bc1616
-- </PALETTE>