0  0 H@Î@Hï™HÿÎa²ðm;É]o66o;]ÉyÎöôôô¶ÆÖy•ª8@a4
P         ðÿÿÿÿÿÿÿÿ2Tv˜ºÜþïÍ«‰gE#2Tv˜ºÜþ2Tv˜ºÜþ    ÿÿÿÿ    ÿÿÿÿÿîÍ›F#  2d¹Üîÿ                                   î/â./ñÿïñþáïâïþÿïòîïþþ"ÌîÝËíÞÛÌÜí¼ÞËììÞÌÞÎÞíÝ¼ì¼ìÎÜËìÝ½>3#ÓÂ#>,3"33Ò3Ã#3Ó2=Ó32"3323"#<Òuvgweuvgwfgvv#bsr<s-33""2ã3#=""ãD´4L4DD4K4KDCCDCÄDLDDCD4ÃDCKDCL4íÝ¾ÝÍÍÝÞÞÞÞÝÝÝý½üÍ½ÝÝÝÝí½ÝßÍÞÞÝÞë=ÓÞÞÝíë¾¾ÞÞ=íÝ=ÓÝ=3í¾Þë½ÝÝíí3í¾$##C4##2##3B##"C32#B4"#3$#"3##2CVuFWfvwedgUuwffuVeWfWwuGegfUvUfV»¼ýÏüßÍÝÜÿ¿ÌûßÌÝÌÝÿßÝÿÿ½üÏÝ½¼Üÿß×|í7×î×>ÇÎíäÃçísrãÜg-ã>çLÞ>Ü=Ü~<ÒÌÜÜ<âí=#ÒÜÜÞ»2ã½"";ì#³ãÃ>;ÞÞíâ<¼ÍÌ»M»ÛÝ»ÌÌÍÛ½´»í»KÜÝÌÝÌË¼»ÍËKÌ½ÌšÌÜíèÎ«ÝÌ¼‰¼Ú­È­‰ÝÝÞˆîÍÍªÝÌÌœÜíïÞµÝÝîÜííÿwþîîgå}å^ËgÛÝîµýïÞÝVÝDDD4D4DDC33333344DDDDD4D34333334333#3#32"""""!##33313#3"#"""""#ÝÿîÛþïëÝíþ½ïÛýýïÝïßïþî½ý½ýßíÛýî¾ÝÿíñýîþÞñíñîñáñÿÞÞáþíÿß3D4333"3"D433333"""ñ3#"ñ""ñ"ÿÿÿÿ3#"ñ"""ñ"ñÿÿÿÿÌí»ËÌíÌÌÝíÌÝîîîî»ËÌíÌÌÌíÌÝÝíîîîîîþÜÝîñíîñîÿÿÿÿÜÝîþíîîñîîñÿÿÿÿÌí[ËfçÌlwçÌÝîîîî[ËÌíÌlfçÌ}wçîîîîîø}íwøî~ˆøîˆÿÿÿÿ}íîøî~wøîˆˆøÿÿÿÿÌÝîþìîÿÿíÿÿîíïïþïÿþïîÿþÿÿîþñ7s3#CDD#C3##C3$sCC$sC""s737s"wwwÃ<ÌÜ¼»»Ü¼ÌÜÜ¼ÌÛ<¼¼Ûì¼ÝÝìÃÌÃìÝÝî"»»ËÌKDDÄK»»LKKLLKËMLLKDLLÌÌKÌDDDˆ¹«™˜«Šš¹ª‰¨«ºœº«É©ºŠ˜ª›©¨º‰™º›ˆfµkwVWµvugUk[Æ[µ[elµ¶UvWg[uew¶[fÿþÿïîîîîîÿÿýïþþÿîîîîÞÿîþþÿîÿÿÿßîã""â""2!2!"."ò"2ÿ"""ò!"Vu6WfvwecgUuwffuVeWfWwu7egfUvUfVÌÝÝî"!!411CCÌ=Ì=í>=>433CCDD3»ËÌÌÌÌÌ-ÌÝÝ=î.>â Ð  Ð ÀÜÝÝ#ãîÍìÎÜÌÝÝÌÞÿÿíýÿÿïÝÌÌíËîíÞÜýßÞÞÿÿíÍìÎÜÌÝÝÌÞÿÿíýÿÿïÝÌÌíËîíÞÜ-ÔÞÞC;í      321#3ñÏü!Ä,A3#1#2ªªº»
° °
 °  °  ° °À À»ËÌÌ                      P ```        
  J
  ª  
p  ¤p`ªWPwv      D  @C  @    g eP v     "   B    `p   v` Vp Pp u                        PP pp                          p  `                           e                  P` `` `` pp                         pvg `                  `   ` V ee         P T P` P` `` `gwg            ` ```f``pvg `              `  p `vfV`e`eV @ @@ DD@T@PdUP`Vee egwg` ```f``gp `  P @@4343          pf pv  ` fpgV`e`eV `````'U "#        0# PPvPvPWPPWPpWPpvPvPPe   Vf`w `@t7C"##CC##CC##022’!22#"(‚!""*2¨#2!¢“3#9""£                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                "##2D$$B""##22³"#DD+"2#"´"$22;"#        ""##22³"#DD+"2#"´"$22;"#                #DD+"2#"´"$22;"#                        ´"$22;"#432CCBC2#A#1CDC$3C3#CBC"#A#1Ãí>4   C   Ü   í   $   #   "   1   4                0  0  @  0       @  °        0            @  °   "   1  3             @  °  "     3          Ð      Ð   À  <Ô  ¼Ó  LÛ  À  Ë¬ À  <²  <² °""*""±+"¡ÌÌÌ»         4 @+"´;"#"##22"##""        @3 ´" »2""##22"""!                                                                ª«™›¸™˜¹™©ªª›ˆˆ›©«º™™™ššˆ˜˜‰™›ªª        ™©ªª›ˆˆ›©«º™™™ššˆ˜˜‰™›ªª                ©«º™™™ššˆ˜˜‰™›ªª                        ˆ˜˜‰™›ªªÓ>34332$#324#4B4CDC3C4CC34"C3$#3   4   $   4   4   3   Ü   í   30  0  0$""@33$@30C0 30 3à î$"""@423   4   @   3   C  2 àî """B3#CC      3   4  0#   î 0   4D0   DC   04D0  0DC    @   4  D  @"""@"""0$2C@   @  »C °»C »4"Ì"Ì3C4  @#2"20"2"0"#" #"" 0"!  !  "   """!  !"   "        DD4343""4»ËÌ4ËÌÌ3Ëîî#Ìîî#Ìîî#Ìîî3""""33#ÜÝÝ#ÌÌÜ#îîÜ#îîÝ#îîÝ#îîí#ˆˆ¨ª¨ª™™¨»»»¨ËÌDªËÝÝšËÝÝšKÝÝšKÝÝª™™™™ªªšËÌÌšDDÄšÝÝÄšÝÝÌšÝÝÌšÝÝÜš """!233!333!233"""     """"333333333333""""     """33#33333#"""         °» ëºª«ª««ªª°ªº  «  °      °» ëºÌ«ªË«ÊÌ°ª¼  Ë  °      °» Ë¼ÌËÌËËÌÌ°Ì¼  Ë  °   «º  ª©
«™›ºš¹™ªª™™©«™™º šª
 «º      «º  š© ¹™°™™
°š©
 ªª        °    
	     š  © �   
  °  ð ûû°°°      û¿      ð¿¿ ðð ûû¿°°ðà  ðû¿  ðð¼ý¿Ïðý°þþ°þëßÀýðß°ýï°ðÀûïï°ßð#Íîî"Íîî"Íîî2Íîî2ÍÜÝ2ÝÝí233#"""2îîíîîì2îîìîîìÍÌìîîî""""!šLÝÝ™LÝÝ™LÝÝ©LÝÝ©LÄÌ©ÌÌÜ©ªªš™™™©ÝÝÜŠÝÝÛ©ÝÝÛ‰ÝÝÛ‰¼»Û‰ÝÝÝ™™™™‰ˆ˜ˆˆ îîîàÝÝÝÞÍÌÌÞÆÌÌÞÍÌÌàÝÝÝ îîî    îîîîÝÝÝÝÌÌÌÌÌÌÌÌÌÌÌÌÝÝÝÝîîîî    îîî ÝÝÝÌÌÜíÌÌÌíÌÌÜíÝÝÝîîî          ±"!"!!"""  !        î ±âÝ!"Þ!ÒÝ"í  Ñ        àî ÞíÝÞÝÞÞÝÝàÝí  Þ  à  �™‰ ÉLÝÉDÓÉ<Ý�<� �Ü�  Ø  €  ÐÝî ÍÌÝÍÌÝÍÜÝÐÜí ÐÜí  Þ  à  àîî ÞÝÝÞÝÝÞÝÝàÝí àÝí  Þ  à  ÃÌÌÌÌ¼ÃÌÌK4ÌÌ4;ÌÌ44Ì44ÌÌLÃÃÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÁÌÌÌÌÌÌÌÌÌÌÌÌÌ<ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ<¿      Â,   ¤¤  DD  DD wÍÜww×}w     ff  ÷÷  vw  vv  `e  df ffV     »»  ûû  »»  ÛÝ  °  » °»»  Pe  [U °ef PfQ Vfe VUU Vff pwwf  Uu  ff e fVv UUv ffv ww °  û¿  û¿»°»»»°»»»°»» ¿ð  ð              »» °ÿ¿ ¯¿ðÿÏ»°ÿ¼¼                            Ë»         $"B03#  £# 03#  3""                            »»                                                                                                                                                                                                 wwwwDwwDDwwDDˆˆD ˆˆ  ˆˆ  ˆˆ  ÿÿ F"ff U  U 'b  ebPPw  VW  f»°°» °° »» °°°°»  »  »         »  @»   »   »»  »  0           w  @w   ª   ÝÝ  Ý  0     2#  2#² "»"°+"²°+" ð  ð °»»» »»» °ËË °»¼  »»      ¼Ë» »»¼»»Ë»¼»»»»»        ""»  ""  »" °»" °+"      »"" """"²²»»+ 3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      3"0!!ñÿ" / ð#  !ÿ  !ò  23ò/!ð/ÿ  ð                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     2B  #$ @" "        @#$! B  1 0   3 4  s 2     0   !`#PG1$ 3 0  $           u# @  # 00  $         Ý  Ðí  í0Ðþ  ã  2  #  2   ÐÝî íÿ4   ò  2þ  þ B ý  à2     0 à- ÐÓþ  Ýþ #îþ@ÿ#            þ  þ # þ@ #         Ì  ÀÜ  Ü Àí Ò  *   !   ÀÌÝ Üî*  á  !í í 1 ì Ð!       Ð ÀÊí Ìí Ýí0î        Ð  ¬  !í í  í0          Ì  ÀL  L ÀÔ B  &   !   ÀÌD LÝ  Ñ  !Ô Ô 1 Ü @!       @ ÀÆÔ LÔ DÜ0Ý        Ð  d  !Ô Ô  Ü0            Üí ÀýïàÿÿþðßýÿïÿÿñïÿÿÿðÝ DD3A4#sA3#4#r$" 1r    Ë½ÍÑÛíÝÁÍìÌì.íî Ñ.    K»´±KLÄA»Ü´ÜÍÛM AÍ    °  «Š Àš‰ ©¬	«É«™‹¹«‰�¨š ™‰  `  [u ÀevPV\VÆ[fveUv`Wf fv             eP    e  `p P f ` `ff 3f 4"w@3" 03 #"  "       P   C P T       4Pd `  @@  D0 40DPCCP05DPE eF e     ËË@433#4Sw#3w6#033 #"  w   @3"@42 42  @  `# `7B  # @     4  $  2        e  p  r"  +" "" ""    "  ++°"+"""²" ""                 ;³ @;³4³3+433#333"0""     "b  Cv243#$CC!"""B   03  >>à3.33ãã3ò 3â  ?           Ü  ð  ôD @KD@DD@DD 44                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              #"  C#  @  ð         """"233# @     22 àð           0   0 ÀL#"Á<$"Ñ=  @ #2  11  1!  C#  í/  ?#  D2  #D                                                                                                      ""  !"!""""          Ì  Ì»ÌÌ»°»»»ÝÝ»Ý  Ý     °  K4 °D304;044044 CC  0 ÐÝÝëîîÞ¼îîíÌÜÝîÌÝíîÌÝíþÀÝí Üî ÐÝÝ«™šØ¼¨ˆíÌÜÝîÌÝíîÌÝíþÀÝí Üî ÐÝÝK34Ò¼B"íÌÜÝîÌÝíîÌÝíþÀÝí Üî                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ÐÝ ÐÝ ÝÝÝÝ        Ð  »î""Ìð  »              3  0°  $°  °  °  3°   °   3   3 @ $      3     2  03 @#° $ °  °  ° 3 °  3°  "3   í  Ðþ          °  ;  °      4  @3          °  ;  °      Ë  °Ü          °  ;  °     »  °¼  °Í  »Í  ÛÌ °û àÏ  þ                                                                                                                                                                                                                                       ÐÝÝ ÝÝÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ÝÐÝÝÝÝÝÝÝÝÝ ÝÝ  ÝÝ  ÝÝ  ÝÝ Ý  ÝÝÐÝÝÝÝÝ ÝÝ  ÝÝ                                                     Ð  î.""ð                       » "Â  »                                                                                                                                                                                                                                                                                                                                                                                 ÐÝÝ ÝÝÝÝÐÐÝ ÐÝ Ð                                                                                                                                                                                                                                                                                                                                                                        ~kZZ¥²¥ mUZžJJï£Í	¼Ì$$ÛºûÊ×O••Z(   €  @€  	) $   B  •A€                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    QRSRQRQRS                                                                                                                                                                                                                                    PPPPPP                                                                                                                                                                                                                                  PPPP                                                                                                                                                                                                                                 PP                                                                                                                                                                                   PP                                                                                                                                                                                                             PP                                                                                                                                                                                                                                            PP                                                                                                                                                                                                                                            PP                                                                                                                                                                                                                                            PP                                                                                                                                                                                                                                            PP                                                                                                                                                                                                                                            PP                                                                                                                                                                                                                                            PP                                                                                                                                                                                                                                            PP                                                                                                                                                                                                                                            PP                                                                                                                                                                                                                                            PP                                                                                                                                                                                                                                            PP                                                                                                                                                                                                            				                            PP                                                                                                                                                                                                           						                           PP                                                                                                                                                                                                           							                          PP                    000                                                                                                                                                                    			             							                          PP                   00000                                                                                                                                                                  					             					                          PP                   00000                                                                                                                                                                  					               		                          KPP   			            0000000                                                                                                                                                                							                                       JHPP   				           000000                                                                                                                                                                							            L                        HIPP  					 			        0000                                                                                                                                                                 						            L                       K PPI 				 			                                                                                                                                                                               		     L        LL HK                HHJ   PP  	  				 			                                                                                                                                                                                  L        LL /JHJ               SRQPPHH   							                                                                                                                                                                                  L        KHJ         SRQPPPPK     					                                                                                                                                                                           HK H HQRPQRPRQHJJIJ     !!/IH   				                                                                                                                                                                      KJ K H/PPPPPJ   !!!!   	                                                                                                                                                                        PPP!!!!!!!!!

/J                                                                                                                                                                          !!!!!!!


IH      	                                                                                                                                                                 !!!!!!

/IK   			                                                                                                                                                        !!!   


J 					  	                                                                                                                                                    














!     

  		  			                  �Œ                                                                                                                                 







     H     			                  ˆŠ�                                                                                                                                 

    

     

IIHI I                   ˜š›œ                                                                                                                                 

              




/                  �                                                                                                                                                    




/JIIHK            �                                                                                                                                                      


!!!     �                                                                                                                                     no                     


!!!!!!     �                                                                                                                                    ~                                



!!!!!!     �                                                                                                                                                                

!!!!!!                                                                                                                                   

                               !!!!!!                                                                                                                              

                             





                                                                                                                              
                        



                                                                                                                              
            



                                                                                                                                
                                                                                                                                                              

                                                                                                                                                                    


                                                                                                                                                                                                                                                                                                                                               TTTTTTTTTTTT                                                                                                                                                       TTTTTTTTT                                                                                                                                                       TTT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ÁÁÁÁÂÂÂÂÂÂÁÁÁ                                                                                                                                                                                                                                  ÁÁÁÂÂÃÃÃÃÃÃÂÂÁÁ                                                                                                                                                                                                                                ÁÁÁÂÃÃÃÄÄÄÄÃÃÃÂÁÁ                                                                                                                                                                                                                              ÁÁÁÂÃÃÄÄÅÅÅÅÄÄÃÃÂÁ                                                                                                                                                                                                                              ÁÁÁÂÃÄÅÅÆÆÆÆÅÅÄÃÂÁÁ                                                                                                                                                                                                                             ÁÁÂÃÃÄÅÆÊÊÊÊÆÅÄÃÃÂÁÁ                                                                                                                                                                                                                            ÁÁÂÃÄÅÆÊÊÊÊÊÊÆÅÄÃÂÁÁ                                                                                                                                                                                                                            ÁÁÂÃÄÅÆÊÊÊÊÊÊÆÅÄÃÂÁÁ                                                                                                                                                                                                                            ÁÁÂÃÄÅÆ ÊÊÊÊÊÆÅÄÃÂÁÁ                                                                                                                                                                                                                            ÁÁÂÃÄÅÆ  ÊÊ  ÆÅÄÃÂÁÁ                                                                                                                                                                                                                            ÁÁÂÃÃÄÅÆ    ÆÅÄÃÃÂÁÁ                                                                                                                                                                                                                            ÁÁÁÂÃÄÅÅÆÆÆÆÅÅÄÃÂÁÁ                                                                                                                                                                                                                              ÁÁÂÃÃÄÄÅÅÅÅÄÄÃÃÂÁ                                                                                                                                                                                                                                ÁÁÂÃÃÃÄÄÄÄÃÃÃÂÁÁ                                                                                                                                                                                                                                  ÁÂÂÃÃÃÃÃÃÂÂÁÁ                                                                                                                                                                                                                                   ÁÁÁÂÂÂÂÂÂÁÁÁ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¢                                                                                                                                                                                                                  °¦¦¦¦¦¦¦¦¦¦§················Ç²                                                                                                                                                                                                                  °¦¦¦¦¦¦¦¦¦¦ÈÈÈÈÈÈÈÈÈÈÈÈÈÈ¸¸¸¸²                                                                                                                                                                                                                  °àáàáàáàáàáàáàáàáàáàá±±±±±±±±²                                                                                                                                                                                                                  °ðñðñðñðñðñðñðñðñðñðñ±±±±±±±±²                                                                                                                                                                                                                  °±±±±±±±±±±±±±±±±±±±±±±±±±±±±²                                                                                                                                                                                                                  °àáàáàáàáàáàáàáàáàáàáÉÊË£¤¤¤¥²                                                                                                                                                                                                                  °ðñðñðñðñðñðñðñðñðñðñ£¤¥³´´´µ²                                                                                                                                                                                                                  °àáàáàáàáàáàáàáàáàáàá³´µ³´´´µ²                                                                                                                                                                                                                  °ðñðñðñðñðñðñðñðñðñðñÃÄÅ³´´´µ²                                                                                                                                                                                                                  °àáàáàáàáàáàáàáàáàáàá£¤¥³´´´µ²                                                                                                                                                                                                                  °ðñðñðñðñðñðñðñðñðñðñ³´µ³´´´µ²                                                                                                                                                                                                                  °àáàáàáàáàáàáàáàáàáàáÃÄÅ³´´´µ²                                                                                                                                                                                                                  °ðñðñðñðñðñðñðñðñðñðñ£¤¥³´´´µ²                                                                                                                                                                                                                  °àáàáàáàáàáàáàáàáàáàá³´µ³´´´µ²                                                                                                                                                                                                                 °ðñðñðñðñðñðñðñðñðñðñÃÄÅÃÄÄÄÅ²                                                                                                                                                                                                                ÀÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÂ	| ^\ñ_U[YÔ_bX U@_p\0X@_à[@T _ ZPVÐ_0ZàTP_€[€W`_€Y€T _ Z€U _€í ?pÐ À Ò äò$68F	Xfdbd    PPcPcQbCVEE³D³C£D”V„XƒZƒ\ƒ]‚\ƒ\ƒ[„Z„]„]„]…\†Z‡\‡_‡_ˆ_ˆ_Š_‹     NJöFäAÓ@ãEöHÇL–N•N•OàO N KJIòIáL°L²NãNNOOO O O O O O |    PáQöS	X,YüZ\î\\\O\?]/^/___ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ‰     PáUöZ	],_ü__î___O_?_/_/___ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ž     ‚ ° Ðð @p                       =                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     @PA`CwFwHJA0B@CWFWI_K_BB E7G7I?J?K KÐL'LçL/LïLMMÿM MM k6   @       @	 @    @          @    @   	 @ @   `3                                                 ¦/þØ  ����� €������ �€   €€€                                                                                                                                                                       À? ªêªªªªªªªªªWffwªªªªªªªªªªªªªªªªªªªªªªªªªªªÚî®ªªªªªªªªªªwfvVªªªªWffwªªªªªªªªªªªªWffwwfvVVeWfwfvVWffwfuVgVeWfªªªªªªªªªªªªªªêªªªªªªªªªWUvFªªªªªªªªªªªªªªªªªªªªªªªªªªªêîÞªªªªªªªªªªeguWªªªªWUvFªªªªªªªªªªªªWUv1#"3#12323#3#1!3#12323#3#113¡ªªíªªªªªªªªªVwgfªªªªªªªªªªªªªªªªªªªªªªªªªªªíîîªªªªªªªªªªevUvªªªªVwgfªªªªªªªªªªªªVwg!ÿò/ò/!ÿ!ÿò/ò/!ÿ!"2ªÚîªªªªªªªªªudWeªªªªªªªªªªªªªªªªªªªªªÚªªªªîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîudÿ/òvÿ!_ö/!oõòeÿòVÿ!oö/!¯úòªÿ"ÿÿ¡áª¡ª¡VAª¡ª¡ª¡ª¡ª¡ª¡ªêÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ^u6ñªúò¯ªªÿªªúÿªªú¯ªªÿ¯ªªÿªªúÿªªú¯ªªÿ¯ª/¡±"¡±"¡±"a±"¡±"¡±"¡±"¡±"¡±"¡±"¡Þ]UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUÕív7ñªª¯ªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªª£!"!¡!"!¡!"!a!"!¡!"!¡!"!¡!"!¡!"!¡!"!¡!"!¡Þffffffffffffffffffffffffffffffffffffffíg5òªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªªª£!""¡!""¡!""q!""¡!""¡!""¡!""¡!""¡!""Ñ!""¡ÞmffffffffffffffffffffffffffffffffffffÖífò¯ªªªªªªªªªªªªªªªªªªªªªªªªªªªª¦ªªªªú¢"ª"ª"V"ª"ª"ª"ª"ª"í"­é}wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww×^e"¯ªªªªªªªªªªªªªªªªªªªªªªªªªj¦ª¦ªªªª/¢î!¡©ª!¡©ª!¡Ww!A©ª!¡©ª!á©ª!¡©ª!¡©ª!Ñîî!áÞíîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîWw!¯ªªªªªªªªªªªªªªªªªªªªªªªªªªfªfªªªªú¢î®ª©©ª©©egUª©©ª©î­©©ª©©ª©íîîîîîîîîîîîî­ª©ªÙí®ª©ª©ª©ª©ª©ª©ª©ª©ª©ª©ª©ª©eg6ñªªªªªªªªªªªªªªªªªªªªj¦ªªªªjfffªªªªú£îîÞ©ª©ª©ª©ªvUfV©ª©ª©ªîî®ª©ª©ª©ª©ª©îîîîîîîîîîîîîîÞ­ªÙíî®©ª©ª©ª©ª©ª©ª©ª©ª©ª©ª©ª©ªvUòªªªªªªªªªªªªªªªªªªªªjfªªªªffjf¦ªjªª/£îîîª©ª©efUgVuFWVuFWªÙîî®©ª©ª©ª©ª©ÚîîîîîîîîîîîîîîîÞ­ewFUª©ª©VgGfª©ª©ª©ª©ª©ª©ª©ª©ef%¯ªªªªªªªªªªªªªªªªªªªªffªªªªffff¦ªjfªù£îîî©ª©ªUfvVfvwefvwe©íîîÞª©ª©ª©ª©ÚíîîîîîîîîîîîîîîîîÞWUve©ª©ªgUgV©ª©ª©ª©ª©ª©ª©ª©ªUf6¯ªªªªªªªªªªªªªªªªªªªªff¦ªªªffff¦ªjfªú¢îDD433"""GDD33#""RDD433"""IDD33#""âDD433"""NDD33#""rˆˆ¨ªª™™™GDD33#""¢DD433"""ª©tW7òªªªªªªªªªªªªªªªªªªªªff¦ªªªfcff¦ªff¦/¡î43"""33#F3#""233b43"""33#J3#""233â43"""33#N3#""233r¨ª™™™ªªšG3#""233¢43"""33#©ªfu6!¯ªªªªªªªªªª¦ªªªªªªªªff¦ªªªjcff¦ªff¦£î4»ËÌÜÝÝ#F³»ÌÌÝÝ=R4»ËÌÜÝÝ#I³»ÌÌÝÝ=â4»ËÌÜÝÝ#N³»ÌÌÝÝ=r¨»»»ËÌÌšE³»ÌÌÝÝ=’4»ËÌÜÝÝ#ª™Wf!¯ªªªªªªªªªª¦ªªªªjjªjfffªªªª£fc¦ªffö¢î4Ë    Ü#F³     =r4    Ð#J³     =â4Ë  ÀÜ#N³ÌÌÌÌÌ=b¨ËÌ   ÀšG³ÌÌÌÌÌ=¢4ËÌÌÌÌÜ#™ªWU6ñªªªªªªªªªªª¦ªªªªªªªjfffªªªª£j£ªªfcö“î3ËÐÝîÐ#7³@DKÃ=b3DDD4Ð#9³à332=â3ËwàÜ#>³ìîîîÎ=bªËÝ`#Àš7³ì   Î=’3ËîîîîÜ#ª™Vwòªªªªªªªªªªjfªªªª¦¦ªjfc¦ªªªz¢ª£ªªj£ª/£î#Ì íÿ4Ð#7Â@CDD=b#D4DDÐ#:Â <âÃ=â#Ì  Ý#>ÂìîîîÞ=bšËÝ`7BÀš4ÂìpPÞ=¢#ÌîîîîÝ#™ªud'¯ªªªªªªªªªªff¦ªªª¦ªªªª£ªªªª7sª£ªªª£ªú“î#Ì  òÐ#6Â°D³D=R#C333Ð#9Â0#23=â#Ð#>ÂìîîîÞ=RšKÝ #Àš<Âì g Þ=’#ÌîîîîÝ#ª™îî>¯ªªªªªªªªjfff¦ªªªªªªªª£ªªªz33§£ªªª£ªù¢î#Ìî 2þà#6Â04D4>r#3334à#:Â =3<>â#à#>ÂìîîîÞ>bšKÝ@ Üš<Â 'Ð>¢#Ìîîîîí#™Úîî>òªªªªªªªªjfff¦ªJDªªªªª£ªªª7#3srzwwbª/‘î#Í þà5Ò@LÄD>q#4DDDà9Ò03-Ó>á#@3"à>ÒìîîîÞ>qšL ÝÜŠ9Ò²"Ð>‘#Íîîîîíªíîî>!¯ªªªªªªªjffffª$"¤ªªªª£¦zw3#233"33s'£î"Í B ýà2'Ò@ôÿÿÿÿS"DD4ÿÿ?*Ò0=#óÿ/ã"Í@42ÿÿ?.ÒìîîîÎ.c™ 4 ýÿ¯*Ò""òÿÿ£"Íîîîîì2Ýîîî!¯ªªªªªªªffff¦J,"LªªJw¢w733,Â33"333ó’î"  àà&Ò0ü»ÿ»ûa"343¿»)Ò03#ó»ÿá"Í 42¿».ÒìîîîÎ.a™$Ðÿ»�)Ò""ò»û‘"Íîîîîìîîîî>ñªw§ªªªªªjcfc¦ª,"¢ "w3s3"3ÃÌÌ<3"233ó£î22 î à%Ó@ôÿûûÿq2333¿¿*Ó 2Âóÿûá2Í@¿ÿ.ÓìîîîÎ.a©2 Ý¿ÿ�*Ó !ñûû¡2Íîîîîìîîîîòw3#*ªªªªjcª£ªª,"¢ w333#"3ÌÌÌÌÌ"""""/“î2 ÐÍÌì%Ó ð¿ÿ»ÿa2   ¿»-Ó    ¿ÿá2ÍÜ  ¿û.ÓÌÝÝÌÌ.Q© À¼¿»�)ÓÌ  ð»û‘2ÍÜÝÍÌìîîîî.?33#rªªªªªCª£ªªÎîq73333#"ÂÌÌÌÌÌ"""""ù£î2ffffff/&ÓÝýûÿÿûR2ÝÝíî¿¿/.ÓÝÝîþÿûâ2ÝÝíîÿ¿/.ÓÝÝîîî.R©ÌÌÜÝ¿¿Ÿ)ÓÝÝîþûû¢2ÝÝíîîî"îîîî>/23#"wwªªªr¤£¤J7w3333Ì<,"ÌÌÌÌÌÌ,"""Âù’g233#"""&33ó»û»ÿA233#"¿».333"ò»ÿá233#"¿û.333""""á©ªªš™¿»�)333"ò»û‘233#"""îîîî>ò"ÌÌ3#"ªzw3'swz3"233ÌÌÌÌ"ÌÌìÎÌÌÌÌì.Â/¡U"""2!&""òÿÿÿa"""2ÿÿ."""ñÿá"""2ÿÿ."""á™™™©ˆÿÿ�)"""ñÿÿ¡"""2!îîîî>!/ÌÌ<3#"""3s2373""ÂÌÌÌÌÌÌÌÌìîÎÌÌÌÌîÎ“WvVuWvVteufdgUuuWvVteufîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîî�©™©™©™©™©™©™©™îîîîîîîîîî!ÿÌÌÌ33"2333333Ã"""ÌÌÌÌÌÌÌüïîÎÌÌÌÌìþ¢gfwegfwveWfwffuegfwveWfîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîî®™©™©™©™©™©™©™©îîîîîîîîîî>ñÌÌÌÌ,ÿ333,2333ÌÌ"""ÎÌÌÌÌÌÌÌîÌÌîÌÌÌü“uVgfuVgwfvVVeWffuVgwfvVîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîž©™©™©™©™©™©™©ÙîîîîîîîîîîòÌÌÌÌ,òÌÌÌ,2óÿÃÌÌìîîþÌÌÌÌÌÌÌÌÌìîÌÌÌÌ/£WVGfWVGeguWWwuGfWVGeguWîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîî®™©™©™©™©™©™©™éîîîîîîîîîî.ÿÌÌÌÌ,ÿÌÌÌ,ÂÌüÌÌÌìîîþÌÌÌÌÌÌÌÌÌÌîÌüÌÌù“gUuVgUuevUvegfUVgUuevUvîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîÞ™™™™™™™™™™™™™éîîîîîîîîîî>ÿÌÌÌÌÌÌÌÌÌìÂÌÌÌÌÌÌîÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÏù’dwVUdwVftvevUfVUdwVftveîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîîî™™™™™™™™™™™™™éîîîîîîîîîî>òÌÌÌÎÌÌÌüÌìÎÌÌÌîîÌÌÌÌÌìÎÌÌÌüÌÌÌÌÌîüÿ/‘gGfefUgefUgefUgewFUVuFWîîîîîîîîîîîîîîîîDDD4DDD4DDD4îîîîîî™™™™™™™™™™™™™íîîîîîîîîîî>!ÏÌìÎÌÌÌÌÌÌÎÌÌÌîîÌÌÌÌÌìÎÌÌÌÌÌÌÌÌÌîÎÌ“UgVUfvVUfvVUfvVWUvefvweîîîîîîîîîîîîîîîîD4DDD4DDD4DDîîîîîî™™™™™™™™™™™™™îîîîîîîîîîî.ÏüïÎÌÌÌÌÌÌÌÌÌÌîîÌÌÌüÏìþÿÏÌÌÌÌÌÌüîÌü‘WvVtWwutWwutWwuteufdgUuîîîîîîîîîîîîîîîîC333C333C333îîîîîî�™™™™™™™™™™™™îîîîîîîîîîî.!òüÏÎÌÌÌîÎÌÌÌÌîîîÎÌÌüÏüÿÿÌÌÌÌÌÌÌÌÌÌü"‘gfwfuVefuVefuVeveWfwffuîîîîîîîîîîîîîîîî333433343334îîîîîîž™™™™™™™™™™™™îîîîîîîîîîî.!ÏüÌÌÌÌîîîÌÌÌÌîîîîîÌÌüÏÌÌÌÌÌÌÌÌÌÌÌÌü/‘uVgWffwWffwWffwwfvVVeWfîîîîîîîîîîîîîîîî4DDD4DDD4DDDîîîîîîž™™™™™™™™™™™Ùîîîîîîîîîîî>ñÌÌÌÌÌÌîîîÌÌÌÌîîîîîîÌüÏÌÌÌÌÌÌÌÏÌÌÌÌÌ/“WVGWUvFWUvFWUvFeguWWwuGîîîîîîîîîîîîîîîîDD4DDD4DDD4Dîîîîîîž™™™™™™™™™™™éîîîîîîîîîîî>ñÌÌÌÌÌÌÌÌÌÌÌÌÌîîîÌÌÌÌüïÌÌÌÎÌÌÌÏÌÌüÌÌ“gUuVwgfVwgfVwgfevUvegfUîîîîîîîîîîîîîîîî343334333433îîîîîîÞ˜™˜™˜™˜™˜™˜éîîîîîîîîîîîòìþÿÌÌÿÏÿÌÿÏÿÿÿîÎüÿÌÌüïîÌÿïÌÿÿÏÌü/ïî“dwVudWeudWeudWeftvevUfVîîîîîîîîîîîîîîîî333433343334îîîîîîî™˜™˜™˜™˜™˜™èîîîîîîîîîîîÿÿ"ÿÌ/òÿüòÏü"ÿÎ/!ÿÌ/òïüòÏü"ÿÌ/!òÿ!‘fUgefUgVuFWewFUVgGfewFUefUgîîîîîîîîDDD4333#333#333#DDD4îîî�™˜™˜™˜™˜™˜íîîîîîîîîîîîî#"!ÿò/ò/!ÿ!ÿò/ò/!ÿ!1ufvVUfvVfvweWUvegUgVWUveUfvVîîîîîîîîD4DD3#33#33#3D4DDîîîž˜™˜™˜™˜™˜™îîîîîîîîîîîîî3231!3#1!323231!3#1!323"2aeWwutWwudgUuteufuWvVteuftWwuîîîîîîîîC3332"""2"""2"""C333îîîÞ™˜™˜™˜™˜™˜îîîîîîîîîîîîîîîîJêîîîî##3Bîîîîîž™˜™˜™˜™˜™˜wfgvwfgvwuVefuVewffuveWfegfwveWffuVeîîîîîîîî3334""!#""!#""!#3334îîîî˜™˜™˜™˜™˜™îîîîîîîîîîîîîîîîªîîîîî##"Cîîîîîž˜™˜™˜™˜™˜™v#bsv#bsvffwWffwVeWfwfvVfuVgwfvVWffwîîîîîîîî4DDD#333#333#3334DDDîîîî�˜™˜™˜™˜™˜îîîîîîîîîîîîîî®ê~îîîîî32#BîîîîîÞ™˜™˜™˜™˜™˜r<s-r<s-rUvFWUvFWwuGeguWfWVGeguWWUvFîîîîîîîîDD4D13#313#313#3DD4Dîîîîž™˜™˜™˜™˜Ùîîîîîîîîîîîîîî®¤~nîîîî4"#3îîîîîî•Y˜™˜™˜™˜™33""33""3wgfVwgfegfUevUvVgUuevUvVwgfîîîîîîîî3433"#"""#"""#""3433îîîîÞ˜™˜™˜™˜™èîîîîîîîîîîîîîîæªWåîîîî$#"3îîîîåî–•™˜™˜™˜™˜2ã3#2ã3#2dWeudWevUfVftveUdwVftveudWeîîîîîîîî3334"""#"""#"""#3334îîîîî™˜™˜™˜™˜éîîîîîîîîîîîîîî^æwvîîîî##2Cîîîînnm™˜™˜™˜™˜™=""ã=""ã=wFUefUgVgGfVuFWewFUVuFWîîîîîîîîDDD4Ìí»Ë333#333#333#Ìí»ËDDD4î�™˜™˜™˜™èîîîîîîîîîîîîîîuvgwuvgw’!îîîîuvgwuvgwuvgw>3#Ó-Ã2">UveUfvVgUgVfvweWUvefvweîîîîîîîîD4DDÌíÌÌ3#33#33#3ÌíÌÌD4DDîÞ˜™˜™˜™˜íîîîîîîîî®êîîDîeuvgeuvg22#îîîîeuvgeuvgeuvgÂ#>,3#33ÂeuftWwuuWvVdgUuteufdgUuîîîîîîîîC333ÝíÌÝ2"""2"""2"""ÝíÌÝC333îî�˜™˜™˜™îîîîîîîîîJêîNCîwfgvwfgv"(îîîîwfgvwfgvwfgv3"33"#3=3eWffuVeegfwwffuveWfwffuîîîîîîîî3334îîîî""!#""!#""!#îîîî3334îîž™˜™˜™˜îîîîîîîîîªîîNäîv#bsv#bs‚!"îîîîv#bsv#bsv#bsÒ3Ã#Ó#=3ÒfvVWffwfuVgVeWfwfvVVeWfîîîîîîîî4DDD»ËÌí#333#333#333»ËÌí4DDDîîž˜™˜™˜Ùîîîîîîî®ê~îîîçær<s-r<s-"*2¨îîîîr<s-r<s-r<s-3Ó2=2<3-3guWWUvFfWVGWwuGeguWWwuGîîîîîîîîDD4DÌÌÌí13#313#313#3ÌÌÌíDD4Dîîž™˜™˜™èîîîîîîî®¤~nîægî33""33""#2!îîîî33""33""33""Ó32"33"3ÓvUvVwgfVgUuegfUevUvegfUîîîîîîîî3433ÌÝÝí"#"""#"""#""ÌÝÝí3433îîÞ˜™˜™˜íîîîîîîîæªWåæeçå2ã3#2ã3#¢“3#îîîî2ã3#2ã3#2ã3#3323Âã2,3tveudWeUdwVvUfVftvevUfVîîîîîîîî3334îîîî"""#"""#"""#îîîî3334îîî™ˆ™ˆ™îîîîîîîî^æwv^îçv=""ã=""ã9""£îîîî=""ã=""ã=""ã"#<Ò=23ã"wFUVgGfefUg$##CefUgefUgîîîîîîîîîîîîÌí»Ë333#333#333#333#îîîîîîîˆ™ˆ™ˆîîîîîîîîuvgwuvgw>3#Ó-##Ó-Ã2"uvgw-Ã2"232â"á"á>3#Ó>UvegUgVUfvV4##2UfvVUfvVîîîîîîîîîîîîÌíÌÌ3#33#33#33#3îîîîÂ,î�ˆ™ˆÙî"îîî"îîeuvgeuvgÂ#>,Ã3-#3#33euvg3#332==</""/""Â#>,ÂeufuWvVtWwu##3BtWwutWwuîîîîîîîîîîîîÝíÌÝ2"""2"""2"""2"""îîîîáŽ™ˆ™èîBâîîBâîwfgvwfgv3"332Ã33"#3=wfgv"#3=33#3"ÿ#""ÿ#"3"333eWfegfwfuVe##"CfuVefuVeîîîîîîîîîîîîîîîî""!#""!#""!#""!#îîîî¤¤îÞˆ™ˆéî.âîî.âîv#bsv#bsÒ3Ã#ã3"ÂÓ#=3v#bsÓ#=32Ó#2/"â/"âÒ3Ã#ÒfvVfuVgWffw32#BWffwWffwîîîîîîîîîîîî»ËÌí#333#333#333#333îîîîDDîî™ˆ™ín~îîn~îîr<s-r<s-3Ó2=#2=#2<3-r<s-2<3-,"3>"!#"!#3Ó2=3guWfWVGWUvF4"#3WUvFWUvFîîîîîîîîîîîîÌÌÌí13#313#313#313#3îîîîDDîîˆ™ˆîîvnîîvnî33""33""Ó32"323333"333""33"333<##"#"Ó32"ÓvUvVgUuVwgf$#"3VwgfVwgfîîîîîîîîîîînÌÝÝí"#"""#"""#"""#""îîîwÍÜwî�ˆ™îV~æîV~æî2ã3#2ã3#3323ÃÓÓ#Âã2,2ã3#Âã2,2Ò3<!!"!!"33233tveUdwVudWe##2CudWeudWeîîîîîîîîîînvîîîî"""#"""#"""#"""#îîîw×}wîŽ™Øî^~îu^~îu=""ã=""ã"#<Ò.#3#=23ã=""ã=23ã=22Ò."">."">"#<Ò"gGfîîîîîîîî$##CîîîîîîîîîîîîîîîîînvwÌí»Ë333#333#333#333#îîîwwwwîžˆéîuvgwuvgw>3#Ó-Ã2"-##Ó>3#Ó232â232â-Ã2"â2â2ã""â>3#Ó-UgVîîîîîîîî4##2îîîîîîîîîîîîîîîîîvwwÌíÌÌ3#33#33#33#3îîîDwwDîÞ"èîeuvgeuvgÂ#>,3#33Ã3-#Â#>,2==<2==<3#33"â"â"Â#>,ÃWvVîîîîîîîî##3BîîîîîîîîîîîîîîîîfwwwÝíÌÝ2"""2"""2"""2"""îîîDwwDîîBâîwfgvwfgv3"33"#3=2Ã333"3333#333#3"#3=!""!"""2!3"332gfwîîîîîîîî##"Cîîîîîîîîîîîîîîînwwwwîîîî""!#""!#""!#""!#îîîDˆˆDîî-âîv#bsv#bsÒ3Ã#Ó#=3ã3"ÂÒ3Ã#2Ó#22Ó#2Ó#=3!!!!!!2!"Ò3Ã#ãuVgîîîîîîîî32#Bîîîîîîîîîîîîîîîvwwww»ËÌí#333#333#333#333îîîîˆˆîîn~îîr<s-r<s-3Ó2=2<3-#2=#3Ó2=,"3>,"3>2<3-./!"./!"."ò3Ó2=#WVGîîîîîîîî4"#3îîîîîîîîîîîîîînwwwwwÌÌÌí13#313#313#313#3îîîîˆˆnîîvnî33""33""Ó32"33"33233Ó32"33<#33<#33"3!/2!!/2!"2ÿ"Ó32"3gUuîîîîîîîî$#"3îîîîîîîîîîîîîîvwwwwwÌÝÝí"#"""#"""#"""#""îîîîˆˆæîV~æî2ã3#2ã3#3323Âã2,ÃÓÓ#33232Ò3<2Ò3<Âã2,""!""!""ò3323ÃdwVîîîîîîîî##2Cîîîîîîîîîîîîînwwwwwwîîîî"""#"""#"""#"""#îîîîÿÿîu^~îu=""ã=""ã"#<Ò=23ã.#3#"#<Ò=22Ò=22Ò=23ãòò"áòò"á!""#<Ò.îîîîîîîîîîî$##Cîîîîîîîîîîîîî~wwwwwwÝîþ¾ÛÝÎ¼ëîß½ÝÿîÛî/â.uvgwuvgw>3#Ó232â-##Ó-##Ó-Ã2"232â232â-Ã2">3#Ó-##Ó"//"á"áâ2ÌîDîîîîîîîîî4##2îîîîîîîîîîîîîvwwwwwwÛÿßíÍìÎËÞýßÛþïëÝ/ñeuvgeuvgÂ#>,2==<Ã3-#Ã3-#3#332==<2==<3#33Â#>,Ã3-#!""/""/"""âËNCîîîîîîîîî##3Bîîîîîîîîîîîîîwwwwwwwîû½íÎËÝÞßÛîïíþ½ïÿïñwfgvwfgv3"3333#32Ã332Ã33"#3=33#333#3"#3=3"332Ã33#ò"ÿ#""ÿ#"!""ÝNäîîîîîîîîî##"Cîîîîîîîîîîîîîwwwwwww¾ÝßïíìíÌþýþÝÛýýïþáv#bsv#bsÒ3Ã#2Ó#2ã3"Âã3"ÂÓ#=32Ó#22Ó#2Ó#=3Ò3Ã#ã3"Â"òâ/"â/"â!!!½îçæîîîîîîîî32#BîîîîîîîîîîîînwwwwwwwïÿîÿíÎÎ¼þßß½Ýïßïïâïþrì3#rì3#3Ó2=,"3>#2=##2=#2<3-,"3>,"3>2<3-3Ó2=#2=#1"!#"!#./!"Þfgfæîîîîîîî4"#3îîîîîîîîîîîî~wwwwwwwÿÞïÝíËÞÍþÛïÞþî½ýÿï332#332#Ó32"33<#3233323333"333<#33<#33"3Ó32"3233""!#"#"!/2!îewugfæîîîîî$#"3îîîîîîîîîîîîvwwwwwwwýÞýÛÌ½íÞÝ¾þï½ýßíòîïþ23#-23#-33232Ò3<ÃÓÓ#ÃÓÓ#Âã2,2Ò3<2Ò3<Âã2,3323ÃÓÓ#.1"!!!"!!"""!ìwwvwwgfæîîî##2Cîîîîîîîîîîîîwwwwwwwwí½í½¼ÝîÌ½îÿÝÛýî¾þ"=2#ã=2#ã"#<Ò=22Ò.#3#.#3#=23ã=22Ò=22Ò=23ã"#<Ò.#3##!.."">."">òò"áÜvgwwwwwgfæî$##Cîîîîîîîîîîîîwwwwwwwwuvgw-##Óuvgwuvgw-##Ó>3#Ó>3#Ó232â-##Ó232â232â>3#ÓËÍËÍËÍËÍÌÝí½232âÌÝí½"á"//"//ÌîÝËËuvgwwDwwwçî4##2îî®êîîDîîîînwwwwwwDweuvgÃ3-#euvgeuvgÃ3-#Â#>,Â#>,2==<Ã3-#2==<2==<Â#>,¼ÎÜÎ¼ÎÜÎËîÎÜ2==<ËîÎÜ/""!""!""íÞÛÌ¼fgvwGCwwwgî##3BîîJêîNCîîîî~wwwwwGCwwfgv2Ã33wfgvwfgv2Ã333"333"3333#32Ã3333#333#33"33ÌíÜîÌíÜîÝë¼Ü33#3Ýë¼Ü"ÿ#"#ò#òÜí¼ÞÌ#bswGtwwwwæ##"CîîªîîNäîîîî~wwwwwGtwv#bsã3"Âv#bsv#bsã3"ÂÒ3Ã#Ò3Ã#2Ó#2ã3"Â2Ó#22Ó#2Ò3Ã#îÝîíîÝîí½ÌÎÞ2Ó#2½ÌÎÞ/"â"òâ"òâËììÞî<s-wwwvwwwç32#B®ê~îîîçæîîîvwwwwwwwvr<s-#2=#r<s-r<s-#2=#3Ó2=3Ó2=,"3>#2=#,"3>,"3>3Ó2=íìÌÛíìÌÛÞîÝî,"3>ÞîÝî"!#11ÌÞÎÞí3""wvgwwwwg4"#3®¤~nîægîîîîwwwwwwvgw33""323333""33""3233Ó32"Ó32"33<#323333<#33<#Ó32"ÍË¾ÝÍË¾ÝîÍÞÌ33<#îÍÞÌ#"""!""!íÝ¼ìÍã3#vewuwwww$#"3æªWåæeçåîîîwwwwwvewu2ã3#ÃÓÓ#2ã3#2ã3#ÃÓÓ#332333232Ò3<ÃÓÓ#2Ò3<2Ò3<3323Íìî¼Íìî¼ìÍìË2Ò3<ìÍìË!!".1"!.1"!¼ìÎÜÍ""ãWwwvwwww##2C^æwv^îçvîînwwwwwWwwv=""ã.#3#=""ã=""ã.#3#"#<Ò"#<Ò=22Ò.#3#=22Ò=22Ò"#<ÒÛÞÝÌÛÞÝÌÜ¼Ü¼=22ÒÜ¼Ü¼."">#!.#!.ËìÝ½Û##Óuvgwwwww$##Cuvgwuvgwuvgwwwwwuvgw>3#Ó232âã""â"á"//-##Ó-##Ó-Ã2">3#Ó>3#ÓËÍËÍËÍËÍÌîÝËÌîÝËÌîÝËÌÝí½ËÍËÍÌÝí½"//"áËÍËÍÌ3-#euvgw"ww4##2euvgeuvgeuvgww§zeuvgÂ#>,2==<"/""!""Ã3-#Ã3-#3#33Â#>,Â#>,¼ÎÜÎ¼ÎÜÎíÞÛÌíÞÛÌíÞÛÌËîÎÜ¼ÎÜÎËîÎÜ!""/""¼ÎÜÎËÃ33wfgvwBrw##3BwfgvwfgvwfgvwwJzwfgv3"3333#3"2!"ÿ#"#ò2Ã332Ã33"#3=3"333"33ÌíÜîÌíÜîÜí¼ÞÜí¼ÞÜí¼ÞÝë¼ÜÌíÜîÝë¼Ü#ò"ÿ#"ÌíÜîÝ3"Âv#bsw'rw##"Cv#bsv#bsv#bswwªwv#bsÒ3Ã#2Ó#22!"/"â"òâã3"Âã3"ÂÓ#=3Ò3Ã#Ò3Ã#îÝîíîÝîíËììÞËììÞËììÞ½ÌÎÞîÝîí½ÌÎÞ"òâ/"âîÝîí½2=#r<s-gwww32#Br<s-r<s-r<s-§zwwr<s-3Ó2=,"3>."ò"!#1#2=##2=#2<3-3Ó2=3Ó2=íìÌÛíìÌÛÌÞÎÞÌÞÎÞÌÞÎÞÞîÝîíìÌÛÞîÝî1"!#íìÌÛÞ23333""wvgw4"#333""33""33""§¤wg33""Ó32"33<#"2ÿ"#"""!3233323333"3Ó32"Ó32"ÍË¾ÝÍË¾ÝíÝ¼ìíÝ¼ìíÝ¼ìîÍÞÌÍË¾ÝîÍÞÌ""!#"ÍË¾ÝîÓÓ#2ã3#Vwvw$#"32ã3#2ã3#2ã3#vªWu2ã3#33232Ò3<""ò!!".1"!ÃÓÓ#ÃÓÓ#Âã2,33233323Íìî¼Íìî¼¼ìÎÜ¼ìÎÜ¼ìÎÜìÍìËÍìî¼ìÍìË.1"!!!"Íìî¼ì#3#=""ãWwwu##2C=""ã=""ã=""ãWvwv=""ã"#<Ò=22Ò!"."">#!..#3#.#3#=23ã"#<Ò"#<ÒÛÞÝÌÛÞÝÌËìÝ½ËìÝ½ËìÝ½Ü¼Ü¼ÛÞÝÌÜ¼Ü¼#!.."">ÛÞÝÌÜÃ2"-Ã2"uvgw’!232â-Ã2"232âuvgw-##Ó-Ã2"-Ã2"â2â2"á"áâ2ÌÝí½ÌîÝËËÍËÍÌîÝËÛÝÎ¼ÌÝí½ÌîÝËËÍËÍÌîÝËÌîÝËÌÝí½ËÍËÍÌîÝËÛÝÎ¼Ì#333#33euvg22#2==<3#332==<euvgÃ3-#3#333#33"â"â/""/"""âËîÎÜíÞÛÌ¼ÎÜÎíÞÛÌÍìÎËËîÎÜíÞÛÌ¼ÎÜÎíÞÛÌíÞÛÌËîÎÜ¼ÎÜÎíÞÛÌÍìÎËí#3="#3=wfgv"(33#3"#3=33#3wfgv2Ã33"#3="#3=!""!"""ÿ#""ÿ#"!""Ýë¼ÜÜí¼ÞÌíÜîÜí¼ÞÎËÝÞÝë¼ÜÜí¼ÞÌíÜîÜí¼ÞÜí¼ÞÝë¼ÜÌíÜîÜí¼ÞÎËÝÞÜ#=3Ó#=3v#bs‚!"2Ó#2Ó#=32Ó#2v#bsã3"ÂÓ#=3Ó#=3!!!!!!/"â/"â!!!½ÌÎÞËììÞîÝîíËììÞíìíÌ½ÌÎÞËììÞîÝîíËììÞËììÞ½ÌÎÞîÝîíËììÞíìíÌË<3-2<3-r<s-"*2¨,"3>2<3-,"3>r<s-#2=#2<3-2<3-./!"./!""!#"!#./!"ÞîÝîÌÞÎÞíìÌÛÌÞÎÞíÎÎ¼ÞîÝîÌÞÎÞíìÌÛÌÞÎÞÌÞÎÞÞîÝîíìÌÛÌÞÎÞíÎÎ¼Ì3"333"333""#2!33<#33"333<#33""323333"333"3!/2!!/2!#"#"!/2!îÍÞÌíÝ¼ìÍË¾ÝíÝ¼ìíËÞÍîÍÞÌíÝ¼ìÍË¾ÝíÝ¼ìíÝ¼ìîÍÞÌÍË¾ÝíÝ¼ìíËÞÍíã2,Âã2,2ã3#¢“3#2Ò3<Âã2,2Ò3<2ã3#ÃÓÓ#Âã2,Âã2,""!""!!!"!!"""!ìÍìË¼ìÎÜÍìî¼¼ìÎÜÌ½íÞìÍìË¼ìÎÜÍìî¼¼ìÎÜ¼ìÎÜìÍìËÍìî¼¼ìÎÜÌ½íÞ¼23ã=23ã=""ã9""£=22Ò=23ã=22Ò=""ã.#3#=23ã=23ãòò"áòò"á."">."">òò"áÜ¼Ü¼ËìÝ½ÛÞÝÌËìÝ½¼ÝîÌÜ¼Ü¼ËìÝ½ÛÞÝÌËìÝ½ËìÝ½Ü¼Ü¼ÛÞÝÌËìÝ½¼ÝîÌË32â>3#Ó232â-##Ó>3#Ó>3#Ó-##Ó-Ã2"-Ã2"232âÌîÝËâ2"áã""ââ2â2â2ÛÝÎ¼ÌîÝËÛÝÎ¼ÛÝÎ¼ÛÝÎ¼ÌÝí½ÛÝÎ¼ÌîÝËÌÝí½ÌÝí½ÌîÝËÛÝÎ¼ÌÝí½Ë==<Â#>,2==<Ã3-#Â#>,Â#>,Ã3-#3#333#332==<íÞÛÌ"â/""""â"â"âÍìÎËíÞÛÌÍìÎËÍìÎËÍìÎËËîÎÜÍìÎËíÞÛÌËîÎÜËîÎÜíÞÛÌÍìÎËËîÎÜ¼3#33"3333#32Ã333"333"332Ã33"#3="#3=33#3Üí¼Þ!"""ÿ#""2!!""!""!""ÎËÝÞÜí¼ÞÎËÝÞÎËÝÞÎËÝÞÝë¼ÜÎËÝÞÜí¼ÞÝë¼ÜÝë¼ÜÜí¼ÞÎËÝÞÝë¼ÜÌÓ#2Ò3Ã#2Ó#2ã3"ÂÒ3Ã#Ò3Ã#ã3"ÂÓ#=3Ó#=32Ó#2ËììÞ!!!/"â2!"!!!!!!!!!íìíÌËììÞíìíÌíìíÌíìíÌ½ÌÎÞíìíÌËììÞ½ÌÎÞ½ÌÎÞËììÞíìíÌ½ÌÎÞî"3>3Ó2=,"3>#2=#3Ó2=3Ó2=#2=#2<3-2<3-,"3>ÌÞÎÞ./!""!#."ò./!"./!"./!"íÎÎ¼ÌÞÎÞíÎÎ¼íÎÎ¼íÎÎ¼ÞîÝîíÎÎ¼ÌÞÎÞÞîÝîÞîÝîÌÞÎÞíÎÎ¼ÞîÝîí3<#Ó32"33<#3233Ó32"Ó32"323333"333"333<#íÝ¼ì!/2!#""2ÿ"!/2!!/2!!/2!íËÞÍíÝ¼ìíËÞÍíËÞÍíËÞÍîÍÞÌíËÞÍíÝ¼ìîÍÞÌîÍÞÌíÝ¼ìíËÞÍîÍÞÌÍÒ3<33232Ò3<ÃÓÓ#33233323ÃÓÓ#Âã2,Âã2,2Ò3<¼ìÎÜ""!!!"""ò""!""!""!Ì½íÞ¼ìÎÜÌ½íÞÌ½íÞÌ½íÞìÍìËÌ½íÞ¼ìÎÜìÍìËìÍìË¼ìÎÜÌ½íÞìÍìËÍ22Ò"#<Ò=22Ò.#3#"#<Ò"#<Ò.#3#=23ã=23ã=22ÒËìÝ½òò"á."">!"òò"áòò"áòò"á¼ÝîÌËìÝ½¼ÝîÌ¼ÝîÌ¼ÝîÌÜ¼Ü¼¼ÝîÌËìÝ½Ü¼Ü¼Ü¼Ü¼ËìÝ½¼ÝîÌÜ¼Ü¼Ûáã""â232â232â-Ã2"232â-##Ó232â-##ÓÛÝÎ¼ÛÝÎ¼ÌÝí½ÛÝÎ¼"á"á"//"á"//"//îÿþïÌîÝËÌîÝËËÍËÍÌîÝËÛÝÎ¼ÌîÝËÛÝÎ¼ÌîÝËÌîÝËËÍËÍÌ"""2==<2==<3#332==<Ã3-#2==<Ã3-#ÍìÎËÍìÎËËîÎÜÍìÎË/""/""!""/""!""!""ïýîïíÞÛÌíÞÛÌ¼ÎÜÎíÞÛÌÍìÎËíÞÛÌÍìÎËíÞÛÌíÞÛÌ¼ÎÜÎËÿ#""2!33#333#3"#3=33#32Ã3333#32Ã33ÎËÝÞÎËÝÞÝë¼ÜÎËÝÞ"ÿ#""ÿ#"#ò"ÿ#"#ò#òïÿîÞÜí¼ÞÜí¼ÞÌíÜîÜí¼ÞÎËÝÞÜí¼ÞÎËÝÞÜí¼ÞÜí¼ÞÌíÜîÝ"â2!"2Ó#22Ó#2Ó#=32Ó#2ã3"Â2Ó#2ã3"ÂíìíÌíìíÌ½ÌÎÞíìíÌ>ã3ã/"â"òâ/"â"òâ"òâïïîþËììÞËììÞîÝîíËììÞíìíÌËììÞíìíÌËììÞËììÞîÝîí½!#."ò,"3>,"3>2<3-,"3>#2=#,"3>#2=#íÎÎ¼íÎÎ¼ÞîÝîíÎÎ¼#32#"!#1"!#11ïÿþÿÌÞÎÞÌÞÎÞíìÌÛÌÞÎÞíÎÎ¼ÌÞÎÞíÎÎ¼ÌÞÎÞÌÞÎÞíìÌÛÞ#""2ÿ"33<#33<#33"333<#323333<#3233íËÞÍíËÞÍîÍÞÌíËÞÍ32##"""!#"""!""!îïþÿíÝ¼ìíÝ¼ìÍË¾ÝíÝ¼ìíËÞÍíÝ¼ìíËÞÍíÝ¼ìíÝ¼ìÍË¾Ýî!!"""ò2Ò3<2Ò3<Âã2,2Ò3<ÃÓÓ#2Ò3<ÃÓÓ#Ì½íÞÌ½íÞìÍìËÌ½íÞ32##!!".1"!!!".1"!.1"!ïîÞÿ¼ìÎÜ¼ìÎÜÍìî¼¼ìÎÜÌ½íÞ¼ìÎÜÌ½íÞ¼ìÎÜ¼ìÎÜÍìî¼ì"">!"=22Ò=22Ò=23ã=22Ò.#3#=22Ò.#3#¼ÝîÌ¼ÝîÌÜ¼Ü¼¼ÝîÌ."">."">#!.."">#!.#!.ïþîþËìÝ½ËìÝ½ÛÞÝÌËìÝ½¼ÝîÌËìÝ½¼ÝîÌËìÝ½ËìÝ½ÛÞÝÌÜâ2"á-##Ó-##ÓÌÍË¼ÜÜ½Û»¼ýÏ-##ÓÛÝÎ¼ÛÝÎ¼ÛÝÎ¼ÌîÝËÌîÝËËÍËÍïîïþÿþÿïïîïþÿþÿïîÿþïïîïþ»¼ýÏÌÝí½ÌîÝËËÍËÍÛÝÎ¼ÛÝÎ¼ÌÝí½ÛÝÎ¼ÌîÝËÛÝÎ¼Ì"â/""Ã3-#Ã3-#ûÍß¿ßÜßýüßÍÝÃ3-#ÍìÎËÍìÎËÍìÎËíÞÛÌíÞÛÌ¼ÎÜÎÿíîþîîîîÿíîþîîîîïýîïÿíîþüßÍÝËîÎÜíÞÛÌ¼ÎÜÎÍìÎËÍìÎËËîÎÜÍìÎËíÞÛÌÍìÎËí"""ÿ#"2Ã332Ã33üßÿÏÏËÿýÜÿ¿Ì2Ã33ÎËÝÞÎËÝÞÎËÝÞÜí¼ÞÜí¼ÞÌíÜîÿïþîîÿÿýÿïþîîÿÿýïÿîÞÿïþîÜÿ¿ÌÝë¼ÜÜí¼ÞÌíÜîÎËÝÞÎËÝÞÝë¼ÜÎËÝÞÜí¼ÞÎËÝÞÜ!!/"âã3"Âã3"ÂÍßý½ÝÏÿýûßÌÝã3"ÂíìíÌíìíÌíìíÌËììÞËììÞîÝîíÿïÿþïþþÿÿïÿþïþþÿïïîþÿïÿþûßÌÝ½ÌÎÞËììÞîÝîííìíÌíìíÌ½ÌÎÞíìíÌËììÞíìíÌË/!""!##2=##2=#ßÿüÝÛßýÜÌÝÿß#2=#íÎÎ¼íÎÎ¼íÎÎ¼ÌÞÎÞÌÞÎÞíìÌÛïîþþîîîîïîþþîîîîïÿþÿïîþþÌÝÿßÞîÝîÌÞÎÞíìÌÛíÎÎ¼íÎÎ¼ÞîÝîíÎÎ¼ÌÞÎÞíÎÎ¼Ì/2!#"32333233ßÿ¼üüÿýÏÝÿÿ½3233íËÞÍíËÞÍíËÞÍíÝ¼ìíÝ¼ìÍË¾ÝíîÿþÞÿîþíîÿþÞÿîþîïþÿíîÿþÝÿÿ½îÍÞÌíÝ¼ìÍË¾ÝíËÞÍíËÞÍîÍÞÌíËÞÍíÝ¼ìíËÞÍí"!!!"ÃÓÓ#ÃÓÓ#ßýÍýûýÜ¿üÏÝ½ÃÓÓ#Ì½íÞÌ½íÞÌ½íÞ¼ìÎÜ¼ìÎÜÍìî¼þîßþþÿîÿþîßþþÿîÿïîÞÿþîßþüÏÝ½ìÍìË¼ìÎÜÍìî¼Ì½íÞÌ½íÞìÍìËÌ½íÞ¼ìÎÜÌ½íÞ¼ò"á."">.#3#.#3#½ÛÍÍË¼ÜÌ¼Üÿß.#3#¼ÝîÌ¼ÝîÌ¼ÝîÌËìÝ½ËìÝ½ÛÞÝÌþïÿîÿÿßîþïÿîÿÿßîïþîþþïÿî¼ÜÿßÜ¼Ü¼ËìÝ½ÛÞÝÌ¼ÝîÌ¼ÝîÌÜ¼Ü¼¼ÝîÌËìÝ½¼ÝîÌË"//"áÌÝí½ËÍËÍÛÝÎ¼ÛÝÎ¼ÜÜ½ÛÛÝÎ¼ÌÝí½ËÍËÍËÍËÍÌÝí½ÌÝí½ÛÝÎ¼îÿþïÿþÿïîýÿÿÿþÿïïîïþÿþÿïÌÍË¼ÌîÝËÌîÝËÛÝÎ¼ËÍËÍÌÝí½ÌîÝËÛÝÎ¼ÌÝí½ÌîÝËÛ!""/""ËîÎÜ¼ÎÜÎÍìÎËÍìÎËßÜßýÍìÎËËîÎÜ¼ÎÜÎ¼ÎÜÎËîÎÜËîÎÜÍìÎËïýîïîîîîÿîÿïîîîîÿíîþîîîîûÍß¿íÞÛÌíÞÛÌÍìÎË¼ÎÜÎËîÎÜíÞÛÌÍìÎËËîÎÜíÞÛÌÍ#ò"ÿ#"Ýë¼ÜÌíÜîÎËÝÞÎËÝÞÏËÿýÎËÝÞÝë¼ÜÌíÜîÌíÜîÝë¼ÜÝë¼ÜÎËÝÞïÿîÞîÿÿýïîÿíîÿÿýÿïþîîÿÿýüßÿÏÜí¼ÞÜí¼ÞÎËÝÞÌíÜîÝë¼ÜÜí¼ÞÎËÝÞÝë¼ÜÜí¼ÞÎòâ/"â½ÌÎÞîÝîííìíÌíìíÌÝÏÿýíìíÌ½ÌÎÞîÝîíîÝîí½ÌÎÞ½ÌÎÞíìíÌïïîþïþþÿîîîîïþþÿÿïÿþïþþÿÍßý½ËììÞËììÞíìíÌîÝîí½ÌÎÞËììÞíìíÌ½ÌÎÞËììÞí6² -- 0.0.08
-- title:  BitMiner
-- author: JKBYKM
-- desc:   A wip sandbox
-- script: lua

-- DEBUG
 DEBUG=false
 fpsNow=60
 fpsTick=0
 fpsFrms=0
 function updFps()
  fpsFrms=fpsFrms+1
  local t=time()
  if t-fpsTick>=1000 then
   fpsNow=fpsFrms
   fpsFrms=0
   fpsTick=t
  end
 end
 function dbgCtx(ctx,x,y)
  print("t"..ctx.tile.." w"..ctx.wall,x,y,12,true,1,true)
  print("tu"..ctx.tileAdj.up.." td"..ctx.tileAdj.down,x,y+8,12,true,1,true)
  print("tl"..ctx.tileAdj.left.." tr"..ctx.tileAdj.right,x,y+16,12,true,1,true)
  print("wu"..ctx.wallAdj.up.." wd"..ctx.wallAdj.down,x,y+24,12,true,1,true)
  print("wl"..ctx.wallAdj.left.." wr"..ctx.wallAdj.right,x,y+32,12,true,1,true)
 end
 function mouseTileCtx()
  local mt = cam:mouseTarget()
  return mt.tx,mt.ty,mt.ctx
 end
 function drawDbg()
  local stk = plr.invt[plr.selectedSlot]
  local mineProg = 0
  if not stk:isEmpty() then
    mineProg = stk.itm.progress
  end
  local tx,ty,ctx = mouseTileCtx()
  print("tx:"..tx.." ty:"..ty,140,80,12,true,1,true)
  dbgCtx(ctx,140,88)
  print("mine progress:"..mineProg,2,80,12,true,1,true)
  print("x:"..plr.x.." y:"..plr.y,2,88,12,true,1,true)
  print("vx:"..fmt(plr.vx).." vy:"..fmt(plr.vy),2,96,12,true,1,true)
  print("g:"..tostring(plr.on_ground).." j:"..tostring(plr.jumping),2,104,12,true,1,true)
  print("m:"..plr.medium.." ff:"..tostring(plr.feet_fluid).." ef:"..tostring(plr.eyes_fluid),2,112,12,true,1,true)
  print("hp:"..plr.hp.." st:"..flr(plr.stamina).." o2:"..plr.o2,2,120,12,true,1,true)
  print("fps:"..fpsNow,2,128,11,true,1,true)
 end
--

-- Math
 max=math.max
 min=math.min
 rnd=math.random
 flr=math.floor
 function round(n)return flr(n+.5)end
 function snap(a,b,c)if math.abs(a-b)<c then return b else return a end end
 function fmt(n)return string.format("%8.4f",n)end
 function clamp(v,a,b) return min(max(v,a),b) end
 function lerp(a,b,t)return a+(b-a)*t end
 function wrap(v,m)local r=v%m if r<0 then r=r+m end return r end
--

-- BACKGROUND
 farBase=45
 farAmp=85
 farSmth=7
 nearBase=88
 nearAmp=53
 nearSmth=13
 cldCnt=6
 mtnW=512
 cldW=480
 farPar=.18
 nearPar=.45
 farMtn={}
 nearMtn={}
 clouds={}
 function drawSky()
  for y=0,scrH-1 do
   local t=y/(scrH-1)
   local a,b,k
   if t<.25 then
    a,b,k=10,9,t/.25
   elseif t<.65 then
    a,b,k=9,8,(t-.25)/.40
   else
    a,b,k=8,15,(t-.65)/.35
   end
   line(0,y,scrW-1,y,a)
   local off=(y%2)*2
   if k>.15 then
    for x=off,scrW-1,4 do pix(x,y,b) end
   end
   if k>.45 then
    for x=off+1,scrW-1,4 do pix(x,y,b) end
   end
   if k>.75 then
    for x=off+2,scrW-1,4 do pix(x,y,b) end
   end
  end
 end
 function mkMtn(base,amp,smth)
  local arr={}
  local y=base
  local targ=base
  for x=0,mtnW-1 do
   if x%smth==0 then targ=base+rnd(-amp,amp) end
   y=lerp(y,targ,.06)
   arr[x]=y
  end
  for x=0,mtnW-1 do
   arr[x]=arr[x]+math.sin(x*.015)*10+math.sin(x*.037+1.7)*6
  end
  local blend=64
  local startY=arr[0]
  for i=0,blend-1 do
   local x=mtnW-blend+i
   local t=i/(blend-1)
   local s=t*t*(3-2*t)
   arr[x]=lerp(arr[x],startY,s)
  end
  for x=1,mtnW-2 do
   local a,b,c=arr[x-1],arr[x],arr[x+1]
   if b<a and b<c then arr[x]=b-2 end
  end
  for x=0,mtnW-1 do arr[x]=flr(arr[x]) end
  return arr
 end
 function initCld()
  clouds={}
  for i=1,cldCnt do
   local dep=rnd()
   clouds[i]={
    x=rnd()*cldW,
    y=flr(6+(1-dep)*18+rnd(0,16)),
    s=(10+rnd()*12)*(.72+dep*.58),
    spd=.03+dep*.18,
    dep=dep,
    wob=rnd()*6.28318
   }
  end
 end
 function initBg()
  farMtn=mkMtn(farBase,farAmp,farSmth)
  nearMtn=mkMtn(nearBase,nearAmp,nearSmth)
  initCld()
 end
 function drawMtn(arr,edgeCol,fillCol,camX,par)
  for x=0,scrW-1 do
   local sx=wrap(x+flr(camX*par),mtnW)
   local y=arr[sx]
   pix(x,y,edgeCol)
   line(x,y+1,x,scrH-1,fillCol)
  end
 end
 function drawCld(cld,drawX,t)
  local y=cld.y
  local s=cld.s
  local puffCol,shadeCol=11,12
  if cld.dep<.33 then puffCol,shadeCol=12,11 end
  circ(drawX-s*.28,y,s*.20,puffCol)
  circ(drawX,y-1,s*.28,puffCol)
  circ(drawX+s*.30,y,s*.18,puffCol)
  elli(drawX,y+s*.10,s*.72,s*.14,shadeCol)
 end
 function drawClds(camX,t,minDep,maxDep)
  for i=1,#clouds do
   local cld=clouds[i]
   if cld.dep>=minDep and cld.dep<maxDep then
    local par=.10+cld.dep*.35
    local x=wrap(cld.x-camX*par+t*cld.spd,cldW)-40
    drawCld(cld,x,t)
    drawCld(cld,x-cldW,t)
    drawCld(cld,x+cldW,t)
   end
  end
 end
 function drawBg(camX)
  local t=time()/16
  drawSky()
  drawClds(camX,t,0,.20)
  drawMtn(farMtn,13,14,camX,farPar)
  drawClds(camX,t,.20,.70)
  drawMtn(nearMtn,6,7,camX,nearPar)
  drawClds(camX,t,.70,1.01)
 end
--

-- NOISE
 Noise={}
 function Noise.lerp(a,b,t)return a+(b-a)*t end
 function Noise.smooth(t)return t*t*(3-2*t)end
 function Noise.newBuff(w,h,fill)
  local b={}
  fill=fill or 0
  for x=0,w do
   b[x]={}
   for y=0,h do
    b[x][y]=fill
   end
  end
  return{w=w,h=h,b=b}
 end
 function Noise.newRandBuff(w,h,amp)
  local b={}
  amp=amp or 1
  for x=0,w do
   b[x]={}
   for y=0,h do
    b[x][y]=rnd()*amp
   end
  end
  return{w=w,h=h,b=b}
 end
 function Noise.get(n,x,y)
  if x<0 then x=0 elseif x>n.w then x=n.w end
  if y<0 then y=0 elseif y>n.h then y=n.h end
  return n.b[x][y]
 end
 function Noise.sampleLayer(n,x,y,outW,outH)
  local fx=x*n.w/outW
  local fy=y*n.h/outH
  local x0=flr(fx)
  local y0=flr(fy)
  local x1=x0+1
  local y1=y0+1
  local tx=Noise.smooth(fx-x0)
  local ty=Noise.smooth(fy-y0)
  local v00=Noise.get(n,x0,y0)
  local v10=Noise.get(n,x1,y0)
  local v01=Noise.get(n,x0,y1)
  local v11=Noise.get(n,x1,y1)
  local a=Noise.lerp(v00,v10,tx)
  local b=Noise.lerp(v01,v11,tx)
  return Noise.lerp(a,b,ty)
 end
 function Noise.new(w,h,scale,octaves,persistence,lacunarity)
  local n={}
  n.w=w
  n.h=h
  n.scale=scale or 8
  n.octaves=octaves or 4
  n.persistence=persistence or .5
  n.lacunarity=lacunarity or 2
  n.layers={}
  n.maxVal=0
  local amp=1
  local freq=1
  local m=max(w,h)
  local nw=w/m
  local nh=h/m
  for i=1,n.octaves do
   local lw=max(2,flr(nw*n.scale*freq))
   local lh=max(2,flr(nh*n.scale*freq))
   n.layers[i]=Noise.newRandBuff(lw,lh,amp)
   n.maxVal=n.maxVal+amp
   amp=amp*n.persistence
   freq=freq*n.lacunarity
  end
  function n:sample(x,y)
   local v=0
   for i=1,#self.layers do
    v=v+Noise.sampleLayer(self.layers[i],x,y,self.w,self.h)
   end
   return v/self.maxVal
  end
  return n
 end
--

-- WORLD GEN
 function fillWorldWalls(surface)
  for x=0,WORLD_W do for y=0,WORLD_H do
    if y>=surface[x] + 7 then
     setLyrId(wallLyr,x,y,32)
    elseif y>=surface[x] + 1 then
     setLyrId(wallLyr,x,y,33)
    else
     setLyrId(wallLyr,x,y,0)
    end
  end end
 end
 function clearWorldTiles()
  for x=0,WORLD_W do for y=0,WORLD_H do
    setLyrId(tileLyr,x,y,0)
  end end
 end
 function genSurface(heightNoise)
  local surf={}
  for x=0,WORLD_W do
   local n=heightNoise:sample(x,0)
   surf[x]=flr(38+n*22)
  end
  return surf
 end
 function genTerrain(surface)
  for x=0,WORLD_W do
   local sy=surface[x]
   for y=0,WORLD_H do
    if y<sy then
     setLyrId(tileLyr,x,y,0)
    elseif y==sy then
     setLyrId(tileLyr,x,y,4)   -- grass
    elseif y<sy+4 then
     setLyrId(tileLyr,x,y,3)   -- dirt
    else
     setLyrId(tileLyr,x,y,2)   -- stone
    end
   end
  end
 end
 function genCaves(caveNoise,surface)
  for x=0,WORLD_W do
   for y=0,WORLD_H do
    local n=caveNoise:sample(x,y)
    local thresh = .7-.2*(y-surface[x])/(WORLD_H - surface[x])
    if n>thresh then
     setLyrId(tileLyr,x,y,0)
    end
   end
  end
 end
 function genOre(oreNoise,tileId,replaceId,threshold,minDepth)
  for x=0,WORLD_W do
   for y=minDepth,WORLD_H do
    if getLyrId(tileLyr,x,y)==replaceId then
     if oreNoise:sample(x,y)>threshold then
      setLyrId(tileLyr,x,y,tileId)
     end
    end
   end
  end
 end
 function blobFunc(x, y) return (y+2-2*math.sqrt(y*y+1))*(math.sqrt((y-1)*(y-1)+1)-y/2)-x*x end
 function leafBlob(cx, cy, k)
  local radius = math.ceil(3*k)
  for dx = -radius, radius do
   for dy = -radius, radius do
    local sx = flr(dx+0.5)/k
    local sy = flr(dy+0.5)/k
    if blobFunc(sx, -sy)+.1*rnd() > 0 then
     local tx = cx+dx
     local ty = cy+dy
     if getLyrId(tileLyr,tx,ty) == 0 then
      setLyrId(tileLyr,tx,ty,9)
     end
    end
   end
  end
 end
 function genTree(tx, ty)
  local height = rnd(3, 5)
  local topY = ty - height
  setLyrId(tileLyr,tx,ty,60)
  -- trunk
  for i = 1, height do
   setLyrId(tileLyr,tx,ty-i,8)
  end
  leafBlob(tx,topY+1,height+1)
  return true
 end
 function genTallGrass(tx, ty)
  for x=-5,5 do for y=-2,2 do 
   if getLyrId(tileLyr,tx+x,ty+y)==0 and getLyrId(tileLyr,tx+x,ty+y+1)==4 and rnd()<.7 then setLyrId(tileLyr,tx+x,ty+y,40 + rnd(4)) end
  end end
 end
 function genSurfObj(surface, obj, tile,  space, p)
  for x=4,WORLD_W-4 do
   local y=surface[x]
   if getLyrId(tileLyr,x,y)==tile and rnd()<p and x%space == 0 then
    if getLyrId(tileLyr,x,y-1)==0 then
     obj(x,y)
    end
   end
  end
 end
 function findSpawn(surface)
  local x=WORLD_W//2
  local y=surface[x]
  for _=1,20 do
   if getLyrId(tileLyr, x, y) == 4 then
    return x*8,y*8-16
   end
   x=x+rnd(-10,10)
   y=surface[x]
  end
 end
 function genWorld()
  clearWorldTiles()
  local heightNoise=Noise.new(WORLD_W,WORLD_H,12,4,.5,2)
  local caveNoise  =Noise.new(WORLD_W,WORLD_H,70,2,.3,1.3)
  local coalNoise  =Noise.new(WORLD_W,WORLD_H,100,1,.5,2)
  local ironNoise=Noise.new(WORLD_W,WORLD_H,100,3,.9,2)
  local gemNoise   =Noise.new(WORLD_W,WORLD_H,10,2,.5,2)
  local surface=genSurface(heightNoise)
  genTerrain(surface)
  genCaves(caveNoise,surface)
  fillWorldWalls(surface)
  genOre(coalNoise,10,2,.8,50)   -- coal in stone
  genOre(ironNoise,12,2,.75,70) -- iron
  genOre(gemNoise,14,2,.9,60)    -- sapphire-ish
  genSurfObj(surface,genTree,4,4,.3)
  genSurfObj(surface,genTallGrass,4,15,1)
  local sx,sy=findSpawn(surface)
  plr.x=sx
  plr.y=sy
 end
--

-- WORLD
 WORLD_H=135
 WORLD_W=239

 mineCrkTx=nil
 mineCrkTy=nil
 mineCrkLvl=0

 function newWorldLyr(defaultId, boundsId)
  return {
   defaultId=defaultId or 0,
   boundsId=boundsId or 1,
   ids={},
   data={},
   states={}
  }
 end

 function initWorldLyr(lyr)
  for x=0,WORLD_W do
   lyr.ids[x]={}
   lyr.data[x]={}
   lyr.states[x]={}
   for y=0,WORLD_H do
    local id=lyr.defaultId
    lyr.ids[x][y]=id
    lyr.data[x][y]={rot=rnd(0,3)}
    lyr.states[x][y]=nil
   end
  end
 end

 function lyrInBounds(tx,ty)
  return tx>=0 and ty>=0 and tx<=WORLD_W and ty<=WORLD_H
 end

 function getLyrId(lyr,tx,ty)
  if not lyrInBounds(tx,ty) then return lyr.boundsId end
  if not lyr.ids[tx] then return lyr.defaultId end
  return lyr.ids[tx][ty] or lyr.defaultId
 end

 function setLyrId(lyr,tx,ty,id)
  if not lyrInBounds(tx,ty) then return end
  if not lyr.ids[tx] then
   lyr.ids[tx]={}
   lyr.data[tx]={}
   lyr.states[tx]={}
  end
  lyr.ids[tx][ty]=id or lyr.defaultId
  lyr.data[tx][ty]={rot=rnd(0,3)}
  lyr.states[tx][ty]=nil
  if lyr.writeFn then lyr.writeFn(tx,ty,lyr.ids[tx][ty]) end
 end

 function getLyrData(lyr,tx,ty)
  if not lyrInBounds(tx,ty) then return nil end
  if not lyr.data[tx] then return nil end
  return lyr.data[tx][ty]
 end

 function setLyrData(lyr,tx,ty,data)
  if not lyrInBounds(tx,ty) then return end
  if not lyr.data[tx] then lyr.data[tx]={} end
  lyr.data[tx][ty]=data
 end

 function getLyrState(lyr,tx,ty)
  if not lyrInBounds(tx,ty) then return nil end
  if not lyr.states[tx] then return nil end
  return lyr.states[tx][ty]
 end

 function setLyrState(lyr,tx,ty,state)
  if not lyrInBounds(tx,ty) then return end
  if not lyr.states[tx] then lyr.states[tx]={} end
  lyr.states[tx][ty]=state
 end
 
 function getLyrAdj(lyr, tx, ty)
   return {
     up    = getLyrId(lyr, tx, ty-1),
     down  = getLyrId(lyr, tx, ty+1),
     left  = getLyrId(lyr, tx-1, ty),
     right = getLyrId(lyr, tx+1, ty)
   }
 end

 function getTileCtx(tx, ty)
   return {
     tile = getLyrId(tileLyr, tx, ty),
     wall = getLyrId(wallLyr, tx, ty),
     tileAdj = getLyrAdj(tileLyr, tx, ty),
     wallAdj = getLyrAdj(wallLyr, tx, ty)
   }
 end

 function hasAnySide(adj)
   return adj.up ~= 0 or adj.down ~= 0 or adj.left ~= 0 or adj.right ~= 0
 end

 wallLyr=nil
 tileLyr=nil

 function initWalls()
  wallLyr=newWorldLyr(0,1)
  initWorldLyr(wallLyr)
 end

 function initTiles()
  tileLyr=newWorldLyr(0,1)
  initWorldLyr(tileLyr)
 end

 function tileAt(px,py)
  return getLyrId(tileLyr,px//8,py//8)
 end
--

-- CAMERA
 Cam={}
 Cam.__index=Cam
 cam=nil
 function Cam:new()
  local c=setmetatable({},self)
  c.x=0
  c.y=0
  return c
 end
 function Cam:update()
  self.x=flr(plr.x-(scrW//2-plr.w//2))
  self.y=flr(plr.y-(scrH//2-plr.h//2))
 end
 function Cam:screenToWorld(sx,sy)
  return sx+self.x,sy+self.y
 end
 function Cam:worldToScreen(wx,wy)
  return wx-self.x,wy-self.y
 end
 function Cam:tileAtScreen(sx,sy)
  local wx,wy=self:screenToWorld(sx,sy)
  return wx//8,wy//8
 end
 function Cam:mouseTarget()
  local mx,my=mouse()
  local wx,wy=self:screenToWorld(mx,my)
  local tx=wx//8
  local ty=wy//8
  local ctx=getTileCtx(tx,ty)
  local id=ctx.tile
  local isWall=false
  if id==0 and ctx.wall~=0 then
   id=ctx.wall
   isWall=true
  end
  return {
   mx=mx,my=my,
   worldx=wx,worldy=wy,
   tx=tx,ty=ty,
   ctx=ctx,
   tile=ctx.tile,
   wall=ctx.wall,
   id=id,
   isWall=isWall
  }
 end
 function Cam:drawMineCrack()
  if mineCrkTx==nil or mineCrkLvl<=0 then return end
  local sx=mineCrkTx*8-self.x
  local sy=mineCrkTy*8-self.y
  spr(236+mineCrkLvl,sx,sy,0)
 end
 function Cam:drawLyr(lyr)
  local tileX=self.x//8
  local tileY=self.y//8
  local offX=-(self.x%8)
  local offY=-(self.y%8)
  for sx=0,30 do
   for sy=0,17 do
    local tx=tileX+sx
    local ty=tileY+sy
    local id=getLyrId(lyr,tx,ty)
    local data=getLyrData(lyr,tx,ty)
    if id~=0 then
     local rot = fget(id,7) and data.rot or 0
     spr(id,offX+sx*8,offY+sy*8,0,1,0,rot)
    end
   end
  end
 end
 function Cam:drawPlayer()
  if plr.vx<0 then
   plr.flip=1
  elseif plr.vx>0 then
   plr.flip=0
  end
  if plr.ifrms%2==0 then
   spr(plr.sprite,scrW//2-4,scrH//2-8,0,1,plr.flip,0,1,2)
  end
 end
 function Cam:drawDrops()
  for i=1,#drops do
   drops[i]:draw(self.x, self.y)
  end
 end
 function Cam:draw()
  drawBg(self.x)
  self:drawLyr(wallLyr)
  self:drawLyr(tileLyr)
  self:drawMineCrack()
  self:drawPlayer()
  self:drawDrops()
  if DEBUG then drawDbg() end
 end
--

-- UI
 scrW=240
 scrH=136
 invt_open=false
 invtScrlRow=0
 inv_cursor_stk=nil
 miniMapBig = false
 miniMapCache={}
 function drawSprBox(sprId,x1,y1,x2,y2)
  spr(sprId,x1,y1,0,1,0,0)
  spr(sprId,x2,y1,0,1,0,1)
  spr(sprId,x2,y2,0,1,0,2)
  spr(sprId,x1,y2,0,1,0,3)
  local left,right,xspan = x1+8,x2-8,x2-x1-16
  if xspan >= 0 then
   local nx = max(1, math.ceil(xspan/8) + 1)
   for i=0,nx-1 do
    local t = (nx==1) and 0 or i/(nx-1)
    local x = flr(left + t*xspan + 0.5)
    spr(sprId+1,x,y1,0,1,0,0)
    spr(sprId+1,x,y2,0,1,0,2)
   end
  end

  -- left / right
  local top,bot,yspan = y1+8,y2-8,y2-y1-16
  if yspan >= 0 then
   local ny = max(1, math.ceil(yspan/8) + 1)
   for i=0,ny-1 do
    local t = (ny==1) and 0 or i/(ny-1)
    local y = flr(top + t*yspan + 0.5)
    spr(sprId+1,x1,y,0,1,0,3)
    spr(sprId+1,x2,y,0,1,0,1)
   end
  end
 end
 function initMiniMap()
  miniMapCache={}
  vbank(1)
  cls(0)
  for tile=0,255 do
   cls(0)
   spr(tile,0,0,0)
   local cnts={}
   local bestColor=10
   local bestCnt=-1
   for px=0,7 do
    for py=0,7 do
     local c=pix(px,py)
     if c~=0 and (tile == 2 or c~=13)then
      cnts[c]=(cnts[c] or 0)+1
      if cnts[c]>bestCnt then
       bestCnt=cnts[c]
       bestColor=c
      end
     end
    end
   end
   miniMapCache[tile]=bestColor
  end
  cls()
  vbank(0)
 end
 function drawMiniMap()
  local DX,DY,color=35,20,0
  if miniMapBig then 
   DX,DY,color=scrW//2-4,scrH//2-4,0
  end
  for x=-DX,DX do
   for y=-DY,DY do
    local tile=tileAt(plr.x+x*8,plr.y+y*8)
    if tile== 0 then tile = getLyrId(wallLyr,(plr.x+x*8)//8,(plr.y+y*8)//8) end
    if x==0 and (y==0 or y==1) then color=0 else color=miniMapCache[tile] end
    pix(scrW+x-DX-5,y+DY+4,color)
   end
  end
  drawSprBox(304,scrW-2*DX-7,1,scrW-9,2*DY-2)
 end
 function drawHart(i,health,sprShift)
  local x=8*(i-1)
  local flash=(time()//100)%2
  if health<1 then
   spr(249+sprShift,x,3,0)
  elseif health==1 then
   spr(248+flash+sprShift,x,3,0)
  elseif health==2 then
   spr(248+sprShift,x,3,0)
  elseif health==3 then
   spr(247+flash+sprShift,x,3,0)
  else
   spr(247+sprShift,x,3,0)
  end
 end
 function drawOxy()
  local oxy=plr.o2//15
  for i=-2,2 do
   local x=116+9*i
   local sprId=234
   if oxy<=0 then sprId=236
   elseif oxy<=8 and oxy%2==1 then sprId=235 end
   spr(sprId,x,50,0)
   oxy=oxy-7
  end
 end
 function outlineSpr(id,x,y)
  vbank(1)
  cls()
  spr(id,0,0,0)
  local mask={}
  for px=0,7 do
   mask[px]={}
   for py=0,7 do
    mask[px][py]=pix(px,py)
   end
  end
  cls()
  vbank(0)
  for i=-1,1 do for j=-1,1 do
   for px=0,7 do for py=0,7 do
    if mask[px][py] ~= 0 then
     pix(x+px+i,y+py+j,0)
    end end
   end
  end end
 end
 function outlinePrint(txt, x, y)
  txt = tostring(txt)
  for i=-1,1 do for j=-1,1 do
    print(txt, x+i, y+j, 15, true, 1, true)
  end end
  print(txt, x, y, 11, true, 1, true)
 end
 function drawStkIcon(stk,x,y)
  if stk:isEmpty() then return end
  local itm = stk.itm
  local cnt = stk.cnt or 0
  outlineSpr(itm.id, x+4, y+4)
  spr(itm.id, x+4, y+4, 0)
  if itm.dur and itm.maxDur then
   if itm.dur < itm.maxDur then
    local durBar = (12 * itm.dur) // itm.maxDur
    line(x+2, y+13, x+14, y+13, 15)
    line(x+2, y+13, x+2+durBar, y+13, 6)
   end
  elseif cnt > 1 then
   local t_X = x + 15 - 4*#tostring(cnt)
   local t_Y = y + 10
   outlinePrint(cnt, t_X, t_Y)
  end
 end
 function drawSlotFrm(x,y,selected)
  local sprShift = selected and 2 or 0
  spr(224+sprShift, x, y, -1, 1, 0, 0, 2, 2)
 end
 function drawInvtSlot(slotIdx,x,y)
  drawSlotFrm(x,y,slotIdx == plr.selectedSlot)
  drawStkIcon(plr.invt[slotIdx],x,y)
 end

 function invtLayout()
  local cols = 9
  local rows = 5
  local slotSize = 17
  local x = (scrW - cols*slotSize + 1)//2
  local y = 28
  return x,y,cols,rows,slotSize
 end

 function visibleInvtRows()
  local _,_,_,rows = invtLayout()
  return rows
 end

 function maxInvtScrl()
  local cols,rows = 9,visibleInvtRows()
  local totalRows = max(1, math.ceil(#plr.invt / cols))
  return max(0, totalRows - rows)
 end

 function clampInvtScrl()
  invtScrlRow = clamp(invtScrlRow, 0, maxInvtScrl())
 end

 function invtSlotAt(mx,my)
  local startX,startY,cols,rows,slotSize = invtLayout()
  if mx < startX or my < startY then return nil end

  local col = (mx - startX) // slotSize
  local row = (my - startY) // slotSize
  if col < 0 or col >= cols or row < 0 or row >= rows then return nil end

  local slot = invtScrlRow*cols + row*cols + col + 1
  if slot > #plr.invt then return nil end
  return slot
 end

 function swapInvtSlot(slot)
  if inv_cursor_stk == nil then
   inv_cursor_stk = emptyStk()
  end

  local held = inv_cursor_stk
  inv_cursor_stk = plr.invt[slot]
  plr.invt[slot] = held

  if slot <= 9 then
   plr.selectedSlot = slot
  end
 end

 function drawInvtCursor(mx,my)
  if inv_cursor_stk == nil or inv_cursor_stk:isEmpty() then return end
  drawStkIcon(inv_cursor_stk,mx-8,my-8)
 end

 function drawInvtScreen()
  local x,y,cols,rows,slotSize = invtLayout()
  local boxPad = 10
  local boxX1 = x - boxPad
  local boxY1 = y - 16
  local boxX2 = x + cols*slotSize - 1 + boxPad - 1
  local boxY2 = y + rows*slotSize - 1 + 18

  rect(0,0,scrW,scrH,0)
  rect(0,0,scrW,scrH,1)
  drawSprBox(304,boxX1,boxY1,boxX2,boxY2)
  outlinePrint("Invt",x + 46,boxY1 + 4)
  print("[B] close  click to swap",x+8,boxY2-10,12,true,1,true)

  local topSlot = invtScrlRow*cols + 1
  for row=0,rows-1 do
   for col=0,cols-1 do
    local slot = topSlot + row*cols + col
    if slot <= #plr.invt then
     drawInvtSlot(slot, x + col*slotSize, y + row*slotSize)
    end
   end
  end

  local maxScrl = maxInvtScrl()
  if maxScrl > 0 then
   outlinePrint((invtScrlRow+1).."/"..(maxScrl+1), boxX2-24, boxY1+4)
  end

  local mx,my = mouse()
  drawInvtCursor(mx,my)
 end

 function drawHotbar()
  for i=1,9 do
   drawInvtSlot(i, 2 + (i-1)*17, 14)
  end
 end

 function drawUi()
  if invt_open then
   drawInvtScreen()
   return
  end

  local hpShift=((plr.ifrms//5)%2==1) and -16 or 0
  local hp=plr.hp
  for i=1,10 do
   drawHart(i,hp,hpShift)
   hp=hp-4
  end

  local sprShift=plr.winded and -16 or 0
  spr(244+sprShift,80,3,0)
  for i=1,8 do spr(245+sprShift,80+8*i,3,0) end
  spr(246+sprShift,152,3,0)

  local fill=plr.stamina/1000
  if fill>0 then
   local x2=83+fill*73
   line(83,5,x2,5,5)
   line(82,6,x2+1,6,6)
   line(83,7,x2,7,6)
   line(83,8,x2,8,7)
  end

  if plr.o2<plr.max_o2 then drawOxy() end

  drawHotbar()
  drawMiniMap()
 end

 function death_screen()
  death_frm = death_frm or frm
  cam:update()
  cam:draw()
  plr.ifrms=plr.ifrms-1

  if death_frm==frm-1 then sfx(63) end
  if frm-death_frm>40 then
   cls(2)
   if (frm//30)%2==1 then
    print("Press [B] to respawn",65,70,14,false,1)
   end
   if btnp(5) then
    plr=makePlr(WORLD_W*4,165)
    death_frm=nil
   end
  end
  print("You Died!",32,35,12,false,4)
 end
--

-- TILES
 Tile={}
 Tile.__index=Tile
 function Tile:new(id, props)
  props=props or {}
  local t=setmetatable({}, self)
  t.id=id
  t.hardness=props.hardness or 5
  t.tool=props.tool
  t.drop=props.drop
  t.upd=props.upd
  return t
 end
 function Tile:brake(tx,ty)
  if self.drop then
   drops[#drops+1]=Drop:new(self.drop(),tx*8+2,ty*8+2)
  else
   drops[#drops+1]=Drop:new(ItmStk:new(makeItm(self.id),1),tx*8+2,ty*8+2)
  end
 end
 tiles={}
 function defTile(id, props)
  tiles[id]=Tile:new(id, props)
  return tiles[id]
 end
 function getTile(id) return tiles[id] or tiles[0] end
 function isSolid(tile) return fget(tile,0) end
 function isReplaceable(tile) return fget(tile,1) end
 --loot tables
 function ltTbl(list)
  return function()
   if #list==0 then return emptyStk() end
   local totalWeight=0
   for i=1,#list do
    totalWeight=totalWeight+(list[i][4] or 1)
   end
   local r=rnd()*totalWeight
   local acc=0
   for i=1,#list do
    local e=list[i]
    acc=acc+(e[4] or 1)
    if r<=acc then
     local id=e[1]
     local minCnt=e[2] or 1
     local maxCnt=e[3] or minCnt
     local cnt=max(0,rnd(minCnt,maxCnt))
     return ItmStk:new(makeItm(id),cnt)
    end
   end
   return emptyStk()
  end
 end
 -- tile updates
 function Tile:fallingBlock()
  return function(self,tx,ty,ctx)
   if not isSolid(ctx.tileAdj.down) then
    queueTileSet(tx,ty,0)
    queueTileSet(tx,ty+1,self.id)
    if isReplaceable(ctx.tileAdj.down,1) then tiles[ctx.tileAdj.down]:brake(tx,ty) end
    sfx(5)
   end
  end
 end
 function Tile:supportDown(list)
  if list then 
   return function(self,tx,ty,ctx)
    local supported = false
    for _,id in pairs(list) do supported = supported or ctx.tileAdj.down == id end
    if not supported then 
     queueTileSet(tx,ty,0)
     self:brake(tx,ty)
    end
   end
  else
   return function(self,tx,ty,ctx)
    if not isSolid(ctx.tileAdj.down) then
     queueTileSet(tx,ty,0)
     self:brake(tx,ty)
    end
   end
  end
 end
 function Tile:grow(speed, list)
  return function(self,tx,ty,ctx)
   if rnd() < (1/speed) then
    queueTileSet(tx,ty,self.id + 3)
   end
   self:supportDown(list)(self,tx,ty,ctx)
  end
 end
 function Tile:growTree(speed,list)
  return function(self,tx,ty,ctx)
   if rnd() < (1/speed) then
    genTree(tx,ty+1)
   end
   self:supportDown(list)(self,tx,ty,ctx)
  end
 end
 function Tile:leafDecay(maxDist)
  local dist = function(x,y) return getLyrData(tileLyr,x,y).logDist end
  return function(self,tx,ty,ctx)
   local minDist=nil
   for x=-1,1 do for y=-1,1 do 
    if dist(tx+x,ty+y) then
     minDist=min(dist(tx+x,ty+y),minDist or dist(tx+x,ty+y))
    end
    if getLyrId(tileLyr,tx+x,ty+y) == 8 then minDist=0 end
   end end
  
   getLyrData(tileLyr,tx,ty).logDist = (minDist or maxDist) + 1
   if getLyrData(tileLyr,tx,ty).logDist > maxDist and rnd()<.001 then 
    queueTileSet(tx,ty,0)
    tiles[self.id]:brake(tx,ty)
   end
  end
 end


 -- air and void
  for id=0,1 do defTile(id,{hardness=-id,drop=ltTbl({{1,0,0}})}) end 
 -- mined with pick
  defTile(2,{hardness=100,tool=1,drop= ltTbl({{18}}),tier=0})
  for id=10,15 do defTile(id,{hardness=150+30*(id-10),tool=1,tier=clamp(id-11,0,3)})end
  for id=18,32 do defTile(id,{hardness=100,tool=1,tier=0})end
  tiles[18].drop = ltTbl({{368,2,3}})
 -- mined with axe
  defTile(8,{hardness=100,tool=2,drop=ltTbl({{16}})})
  defTile(9,{hardness=100,tool=2,drop=ltTbl({{381,0,1},{379},{380},{381}}),upd=Tile:leafDecay(10)})
  for id=16,17 do defTile(id,{hardness=50,tool=2})end
 -- mined with shovle
  for id=3,7 do defTile(id,{hardness=100,tool=3})end
  defTile(33,{hardness=100,tool=3})
  defTile(60,{hardness=100,tool=3})
  tiles[4].drop = ltTbl({{3}})
  tiles[60].drop = ltTbl({{3}})
 --plants
  for id=41,44 do defTile(id,{drop=ltTbl({{374,0,2},{375,0,1},{376,0,1}}),upd=Tile:supportDown({3,4,60})})end
  for id=45,53 do defTile(id,{drop=ltTbl({{374+id%3}}),upd=Tile:grow(100,{3,4,60})})end
  cropDrops= {{{377,1,3},{374,2,3}},{{375,2,5}},{{376,1,3}}}
  for id=54,56 do defTile(id,{drop=ltTbl(cropDrops[id%3]),upd=Tile:supportDown({3,4,60})})end
  defTile(58,{upd=Tile:supportDown({3,4,5,6,7,60})})
  defTile(57,{upd=Tile:growTree(100,{3,4})})
 -- def updates
  for id=5,6 do tiles[id].upd=Tile:fallingBlock()end
--

--TILE UPDATES
 BG_PHASES = 60
 bgPhase = 0
 pendingTileChanges={}
 function getMiniMapTileBounds()
  local DX,DY = 35,20
  if miniMapBig then
   DX,DY = scrW//2-4, scrH//2-4
  end
  local cx = plr.x // 8
  local cy = plr.y // 8
  local x1 = max(0, cx - DX)
  local y1 = max(0, cy - DY)
  local x2 = min(WORLD_W, cx + DX)
  local y2 = min(WORLD_H, cy + DY)
  return x1,y1,x2,y2
 end
 function updTilesRegion(x1,y1,x2,y2)
  for y=y1,y2 do for x=x1,x2 do
   local id = getLyrId(tileLyr,x,y)
   local tile = getTile(id)
   if tile.upd then
    local ctx = getTileCtx(x,y)
    tile.upd(tile,x,y,ctx)
   end 
  end end
 end
 function updTilesBgStag()
  local mx1,my1,mx2,my2 = getMiniMapTileBounds()
  for y=0,WORLD_H do for x=0,WORLD_W do
   local inMini = x>=mx1 and x<=mx2 and y>=my1 and y<=my2
   if not inMini and ((x + y) % BG_PHASES) == bgPhase then
    local id = getLyrId(tileLyr,x,y)
    local tile = getTile(id)
    if tile.upd then
     local ctx = getTileCtx(x,y)
     tile.upd(tile,x,y,ctx)
    end
   end
  end end
  bgPhase = (bgPhase + 1) % BG_PHASES
 end
 function queueTileSet(tx,ty,id) pendingTileChanges[#pendingTileChanges+1]={tx=tx,ty=ty,id=id}end
 function applyTileChanges()
  for i=1,#pendingTileChanges do
   local c=pendingTileChanges[i]
   setLyrId(tileLyr,c.tx,c.ty,c.id)
  end
  pendingTileChanges={}
 end
 function updTilesCmbd()
  pendingTileChanges = {}
  if frm % 5 == 0 then
   local x1,y1,x2,y2 = getMiniMapTileBounds()
   updTilesRegion(x1,y1,x2,y2)
  end
  updTilesBgStag()
  applyTileChanges()
 end
--

-- ITEMS
 ItmStk={}
 ItmStk.__index=ItmStk
 Itm={}
 Itm.__index=Itm
 itmDefs={}
 function ItmStk:new(itm,cnt)
  local s=setmetatable({}, self)
  if itm==nil then
   s.itm=nil
   s.cnt=0
  else
   s.itm=itm
   s.cnt=cnt or 1
  end
  return s
 end
 function ItmStk:clear()
  self.itm=nil
  self.cnt=0
 end
 function ItmStk:isEmpty() return self.itm==nil or self.cnt<=0 end
 function ItmStk:addStk(other)
  if not itmsStkable(self.itm,other.itm) then return other end
  if self.cnt+other.cnt<=self.itm.maxStk then
   self.cnt=self.cnt+other.cnt
   other:clear()
  else
   other.cnt=(self.cnt+other.cnt)-self.itm.maxStk
   self.cnt=self.itm.maxStk
  end
 end
 function emptyStk() return ItmStk:new(nil,0) end
 function Itm:new(id,props)
  props=props or {}

  local itm=setmetatable({}, self)
  itm.id=id
  itm.name=props.name or ("itm_"..id)
  itm.type=props.type or "material"
  itm.useTime=props.useTime or 20
  itm.useType=props.useType
  itm.maxStk=props.maxStk or 99
  itm.maxDur=props.maxDur
  itm.dur=props.maxDur
  itm.progress=0
  itm.targetTx=nil
  itm.targetTy=nil
  itm.cooldown=0

  return itm
 end
 function Itm:clone()
  local c=Itm:new(self.id,{
   name=self.name,
   type=self.type,
   useTime=self.useTime,
   useType=self.useType,
   maxStk=self.maxStk,
   maxDur=self.maxDur
  })
  return c
 end
 function Itm:use(mt)
  if self.useType==nil then return false end
  return self.useType(self,mt)
 end
 function Itm:placeBlock(tID)
  return function(itm,mt)
   local tx,ty,ctx = mt.tx,mt.ty,mt.ctx
   if not fget(ctx.tile,1) then return false end --replaceable spr flag
   local nearBlock = hasAnySide(ctx.tileAdj)
   local anchoredByWall = ctx.wall~=0
   if nearBlock or anchoredByWall then
    setLyrId(tileLyr,tx,ty,tID)
    return true
   end 
   return false
  end
 end
 function Itm:placeWall(tID)
  return function(itm,mt)
   local tx,ty,ctx = mt.tx,mt.ty,mt.ctx
   if ctx.wall~=0 then return false end
   local nearWall = hasAnySide(ctx.wallAdj)
   local anchoredByBlock = ctx.tile~=0 or hasAnySide(ctx.tileAdj)
   if nearWall or anchoredByBlock then
    setLyrId(wallLyr,tx,ty,tID)
    return true
   end
   return false
  end
 end
 
 function Itm:plant(tID,plantOn)
  return function(itm,mt)
   local tx,ty,ctx = mt.tx,mt.ty,mt.ctx
   if ctx.tile~=0 then return false end
   if ctx.tileAdj.down == plantOn then
    setLyrId(tileLyr,tx,ty,tID)
    return true
   end
   return false
  end
 end

 function Itm:fert()
  return function(itm,mt)
   local tx,ty,ctx = mt.tx,mt.ty,mt.ctx
   if ctx.tile == 0 and ctx.tileAdj.down == 4 then 
    genTallGrass(tx, ty)
    return true 
   end
   return false
  end
 end

 function Itm:mine(power,toolType)
  return function(itm,mt)
   local tx,ty = mt.tx,mt.ty
   local targetId = mt.id
   local miningWall = mt.isWall
   local tile = getTile(targetId)
   if tile.hardness<=0 then
    resetMine(itm)
    return false
   end
   if itm.targetTx~=tx or itm.targetTy~=ty then
    itm.progress=0
    itm.targetTx=tx
    itm.targetTy=ty
   end
   local minePower=power
   if tile.tool~=nil and toolType~=tile.tool then
    minePower=1
   end
   itm.progress=itm.progress+minePower
   local crkLvl=(4*itm.progress)//tile.hardness
   crkLvl=clamp(crkLvl,0,3)
   mineCrkTx=tx
   mineCrkTy=ty
   mineCrkLvl=crkLvl
   if itm.progress>=tile.hardness then
    if miningWall then
     setLyrId(wallLyr,tx,ty,0)
    else
     setLyrId(tileLyr,tx,ty,0)
    end
    resetMine(itm)
    tile:brake(tx,ty)
    return true
   end
   return false
  end
 end
 function Itm:eat(hp) return function(itm,mt) return healPlr(hp) end end
 function defItm(id,props)
  local def=Itm:new(id,props)
  itmDefs[id]=def
  return def
 end
 function makeItm(id)
  local def=itmDefs[id]
  if not def then error("missing itm def: "..tostring(id)) end
  return def:clone()
 end
 function itmsStkable(a,b)
  if a==nil or b==nil then return false end
  if a.id~=b.id then return false end
  if a.maxDur~=nil or b.maxDur~=nil then return false end
  return true
 end

 -- wals and blocks
 wallItmIds={17,19,21,23,25,32,33}
 for id=1,55 do defItm(id,{useTime=30,useType=Itm:placeBlock(id)})end
 for _,id in pairs(wallItmIds)do defItm(id,{useTime=10,useType=Itm:placeWall(id)}) end
 -- tools
 for t=0,3 do for k=1,3 do defItm(352+4*t+k,{useType=Itm:mine(t,k),maxDur=flr(100*(2.5)^t),maxStk=1}) end end
 -- gems & ingots
 for id=368,373 do defItm(id,{useType=Itm:placeBlock(id-342)})end
 -- crop seeds
 for id=374,376 do defItm(id,{useType=Itm:plant(id-329,60)})end
 defItm(377,{})
 -- fertalizer
 defItm(378,{useType=Itm:fert()})
 -- acorn
 defItm(379,{useType=Itm:plant(57,4)})
 -- stick
 defItm(380,{})
 -- food
 for id=381,386 do defItm(id,{useType=Itm:eat(3*(id-380))}) end
 -- hand
 defItm(999,{useType=Itm:mine(1,nil),maxStk=1})
--

--INVENTORY
 function makeInv()
  local inv={}

  inv[1]=ItmStk:new(makeItm(357),1)
  inv[2]=ItmStk:new(makeItm(5),25)

  for i=3,45 do
   inv[i]=emptyStk()
  end

  return inv
 end

 function makeDbgInv()
  local inv={}
  local ids={}

  for id,_ in pairs(itmDefs) do
   if id ~= 999 then
    ids[#ids+1]=id
   end
  end

  table.sort(ids)

  for i=1,#ids do
   local itm = makeItm(ids[i])
   local cnt = itm.maxDur and 1 or itm.maxStk
   inv[i]=ItmStk:new(itm,cnt)
  end

  local totalSlots = max(45,#ids)
  for i=#ids+1,totalSlots do
   inv[i]=emptyStk()
  end

  return inv
 end

 function setDbgMode(enabled)
  DEBUG = enabled
  if plr == nil then return end

  invt_open = false
  inv_cursor_stk = emptyStk()

  if enabled then
   if plr.saved_invt == nil then
    plr.saved_invt = plr.invt
   end
   plr.invt = makeDbgInv()
   plr.selectedSlot = 1
   invtScrlRow = 0
  else
   if plr.saved_invt ~= nil then
    plr.invt = plr.saved_invt
    plr.saved_invt = nil
   end
  end

  clampInvtScrl()
 end

 function updItmCooldowns()
  for i=1,#plr.invt do
   local stk=plr.invt[i]
   if not stk:isEmpty() and stk.itm.cooldown and stk.itm.cooldown>0 then
    stk.itm.cooldown=stk.itm.cooldown-1
   end
  end
 
  if plr.hand_itm and plr.hand_itm.cooldown>0 then
   plr.hand_itm.cooldown=plr.hand_itm.cooldown-1
  end
 end
--

-- DROPS
 Drop = {}
 Drop.__index = Drop

 function Drop:new(stk,x,y)
  local d = setmetatable({}, self)

  d.stk = stk

  d.x = x or 0
  d.y = y or 0
  d.vx = rnd(-10,10) / 10
  d.vy = -1.2

  d.w = 4
  d.h = 4

  d.fricx = 0.85
  d.gravity = 0.12
  d.max_fall = 2.5

  d.age = 0
  d.pickup_delay = 20
  d.dead = false
  return d
 end

 function Drop:upd()
  if self.stk.cnt <=0 then 
   self.dead = true
   return
  end

  self.age = self.age + 1
  self.h = 4+math.sin(self.age / 20)
 
  self.vy = math.min(self.vy + self.gravity, self.max_fall)
 
  -- move x
  local newX = self.x + self.vx
  if self.vx > 0 then
   if isSolid(tileAt(newX + self.w, self.y))
   or isSolid(tileAt(newX + self.w, self.y + self.h - 1)) then
    self.vx = 0
   else
    self.x = newX
   end
  elseif self.vx < 0 then
   if isSolid(tileAt(newX, self.y))
   or isSolid(tileAt(newX, self.y + self.h - 1)) then
    self.vx = 0
   else
    self.x = newX
   end
  end
 
  -- move y
  local newY = self.y + self.vy
  if self.vy > 0 then
   if isSolid(tileAt(self.x, newY + self.h))
   or isSolid(tileAt(self.x + self.w - 1, newY + self.h)) then
    self.vy = 0
    self.y = flr((newY + self.h)//8)*8 - self.h
   else
    self.y = newY
   end
  elseif self.vy < 0 then
   if isSolid(tileAt(self.x, newY))
   or isSolid(tileAt(self.x + self.w - 1, newY)) then
    self.vy = 0
   else
    self.y = newY
   end
  end
 
  self.vx = self.vx * self.fricx
  if math.abs(self.vx) < 0.02 then self.vx = 0 end
 end

 function Drop:draw(camX, camY)
  local sx = flr(self.x - camX)
  local sy = flr(self.y - camY)

  smlSpr(self.stk.itm.id, sx, sy)
 end
 
 function giveStk(stk)
  if stk:isEmpty() then return true end

  for i=1,#plr.invt do
   local slot = plr.invt[i]
   if not slot:isEmpty() then
    slot:addStk(stk)
    if stk:isEmpty() then return true end
   end
  end

  for i=1,#plr.invt do
   if plr.invt[i]:isEmpty() then
    plr.invt[i] = stk
    return true
   end
  end

  return false
 end

 function Drop:tryPickup()
  if self.age < self.pickup_delay then return end
 
  local px1 = plr.x - 4
  local py1 = plr.y
  local px2 = plr.x + plr.w+4
  local py2 = plr.y + plr.h
 
  local dx1 = self.x
  local dy1 = self.y
  local dx2 = self.x + self.w
  local dy2 = self.y + self.h
 
  local overlap = dx1 < px2 and dx2 > px1 and dy1 < py2 and dy2 > py1
  if overlap then
   if giveStk(self.stk) then
    self.dead = true
    sfx(6)
   end
  end
 end

 drops = {}
 function updDrops()
  for i = #drops, 1, -1 do
   local drop = drops[i]
   drop:upd()
   drop:tryPickup()

   if drop.dead then
    drops[i] = drops[#drops]
    drops[#drops] = nil
   end
  end
 end
 
 function smlSpr(id, x, y)
  vbank(1)
  cls()
  spr(id,0,0,0)
 
  local stamp={}
  for px=0,3 do
   stamp[px]={}
   for py=0,3 do
    stamp[px][py]=pix(px*2,py*2)
   end
  end
  cls()
  vbank(0)
  
  for px=0,3 do for py=0,3 do
   if stamp[px][py] ~= 0 then
    pix(x+px,y+py,stamp[px][py])
  end end end
 end
--

-- PLAYER
 function makePlr(x,y)
  return{
   x=x,y=y,vx=0,vy=0,ax=0,ay=0.5,
   fricx=.7,fricy=.95,
   w=4,h=15,sprite=256,flip=0,
   on_ground=false,jumping=false,
   hp=40,max_hp=40,stamina=1000,max_stam=1000,o2=600,max_o2=600,
   invt=makeInv(),selectedSlot=1,hand_itm=makeItm(999),usingHand = false,
   saved_invt=nil,
   regen_timer=0,regen_speed=120,
   winded=false,working=false,
   ifrms=60,maxv=0,last_dx=1,
   medium="air",last_medium="air",
   feet_fluid=false,eyes_fluid=false,
   sound_timer=0
  }
 end
 function inpPlr()
  plr.ax=0
  plr.working=false
  if btnp(5) then
   if invt_open then
    if inv_cursor_stk ~= nil and not inv_cursor_stk:isEmpty() then
     if giveStk(inv_cursor_stk) then
      inv_cursor_stk = emptyStk()
     else
      clampInvtScrl()
      return
     end
    end
    invt_open = false
   else
    invt_open = true
    invtScrlRow = 0
   end
   clampInvtScrl()
  end
  if invt_open then return end
  if btn(2) then plr.ax=plr.ax-.5 end
  if btn(3) then plr.ax=plr.ax+.5 end
  if plr.medium=="air" then
   plr.fricx=.7
   plr.fricy=.95
   if btnp(4) and plr.on_ground then
    local pct=plr.stamina/plr.max_stam
    local vol=1+flr(14*pct)
    if not plr.winded then
     sfx(1,"D-4",20,0,vol)
     plr.vy=-5
     plr.stamina=plr.stamina-100
    else
     sfx(1,"D-3",20,0,vol)
     plr.vy=-2
     plr.stamina=plr.stamina-50
    end
    plr.on_ground=false
    plr.jumping=true
    plr.maxv=0
   end
   if btn(4) and plr.jumping then
    if plr.vy<0 then plr.ay=.05 else plr.ay=.167 end
   else
    plr.ay=.5
   end
  elseif plr.medium=="submerged" then
   plr.jumping=false
   plr.ay=.1
   plr.fricx=.5
   plr.fricy=.8
   plr.working=true
   if btnp(4) and plr.on_ground then
    sfx(1,"D-3",20,0,5)
    plr.vy=-3
    if plr.winded then plr.stamina=max(0,plr.stamina-20) end
    plr.on_ground=false
   end
   if btn(4) and not plr.winded then
    plr.fricy=.9
    plr.vy=plr.vy-.7
    plr.vy=max(plr.vy,-2.5)
    plr.stamina=plr.stamina-2
    if frm-plr.sound_timer>60 then
     sfx(3,"E-5",-1,0,5)
     plr.sound_timer=frm
    end
   end
   if plr.last_medium=="air" then
    local note=55+rnd(3)
    sfx(2,note,20,0,5)
   end
  elseif plr.medium=="wading" then
   plr.ay=.15
   plr.fricx=.5
   plr.fricy=.9
   if plr.last_medium=="air" then
    local note=55+rnd(3)
    sfx(2,note,20,0,5)
    plr.vy=1
    plr.jumping=false
   end
   if btnp(4) and plr.on_ground then
    sfx(1,"D-3",20,0,5)
    if not plr.winded then
     plr.vy=-3
     plr.stamina=plr.stamina-100
    else
     plr.vy=-1
     plr.stamina=plr.stamina-50
    end
    plr.on_ground=false
    plr.jumping=true
    plr.maxv=0
   end
   if btn(4) and not (plr.on_ground or plr.winded) then
    if frm-plr.sound_timer>60 then
     sfx(3,"E-5",-1,0,5)
     plr.sound_timer=frm
    end
    plr.ay=0
    plr.working=true
    plr.jumping=true
    local amp=(math.abs(3*plr.vx)+1)/10
    plr.y=plr.y+amp*math.sin(6.283*time()/1000)
    plr.stamina=plr.stamina-amp
   end
  end
 end
 function moveX()
  local oldVx=plr.vx
  local newX=plr.x+plr.vx
  if plr.vx>0 then
   plr.last_dx=1
   local right=newX+plr.w
   if isSolid(tileAt(right,plr.y))
   or isSolid(tileAt(right,plr.y+plr.h//2))
   or isSolid(tileAt(right,plr.y+plr.h-1)) then
    plr.x=(right//8)*8-plr.w
    plr.vx=0
   else
    plr.x=newX
   end
  elseif plr.vx<0 then
   plr.last_dx=-1
   local left=newX
   if isSolid(tileAt(left,plr.y))
   or isSolid(tileAt(left,plr.y+plr.h//2))
   or isSolid(tileAt(left,plr.y+plr.h-1)) then
    plr.x=(left//8+1)*8
    plr.vx=0
   else
    plr.x=newX
   end
  end
  if math.abs(plr.vx)<1/60 then plr.vx=0 end
  if plr.vx==0 then
   if oldVx>0 then
    plr.x=math.ceil(plr.x)
   elseif oldVx<0 then
    plr.x=flr(plr.x)
   end
  end
 end
 function moveY()
  local newY=plr.y+plr.vy
  if plr.vy>0 then
   local botProbe=newY+plr.h+1/2
   local left=plr.x
   local mid=plr.x+plr.w//2
   local right=plr.x+plr.w-1
   if isSolid(tileAt(left,botProbe))
   or isSolid(tileAt(mid,botProbe))
   or isSolid(tileAt(right,botProbe)) then
    plr.y=(botProbe//8)*8-plr.h
    if plr.vy>6.25 then hurtPlr((plr.vy-6)*4) end
    plr.vy=0
    plr.on_ground=true
    plr.jumping=false
   else
    plr.y=newY
    plr.on_ground=false
    if plr.medium=="air" then plr.jumping=false end
   end
  elseif plr.vy<0 then
   local top=newY
   local left=plr.x
   local mid=plr.x+plr.w//2
   local right=plr.x+plr.w-1
   if isSolid(tileAt(left,top))
   or isSolid(tileAt(mid,top))
   or isSolid(tileAt(right,top)) then
    plr.y=(top//8+1)*8
    plr.vy=0
   else
    plr.y=newY
   end
  end
 end
 function hurtPlr(dmg,kbx,kby,numFrms)
  kbx=kbx or 0
  kby=kby or -3
  numFrms=numFrms or 10
  dmg=max(0,flr(dmg))
  if plr.ifrms==0 then
   plr.ifrms=numFrms
   plr.vx=plr.vx+kbx
   plr.vy=plr.vy+kby
   plr.hp=plr.hp-dmg
   sfx(4)
  end
  if plr.hp<=0 then
   death_frm=frm
   plr.dead=true
  end
  plr.regen_timer=plr.regen_speed
 end
 function healPlr(hp)
  if plr.hp<40 then
   if hp then plr.hp=plr.hp+hp end
   if plr.regen_timer<0 then
    plr.hp=plr.hp+1
    plr.regen_timer=plr.regen_speed
   end
   return true
  end
  plr.regen_timer=plr.regen_timer-1
  return false
 end
 function recStam()
  if plr.stamina<=0 then plr.winded=true end
  if plr.working then return end

  local regen=2
  if plr.winded then regen=3 end

  if plr.stamina<plr.max_stam then
   plr.stamina=plr.stamina+regen
  end

  if plr.stamina>=plr.max_stam then
   plr.stamina=plr.max_stam
   plr.winded=false
  end
 end
 function breathe()
  if plr.eyes_fluid then
   plr.o2=max(0,plr.o2-1)
  else
   plr.o2=math.min(plr.max_o2,plr.o2+1)
  end
  if plr.o2<=0 then hurtPlr(2,0,-1,30) end
 end
 function updPlr()
  inpPlr()
  updItmCooldowns()
  plrMouse()
  plr.vx=plr.vx*plr.fricx+plr.ax
  plr.vy=plr.vy*plr.fricy+plr.ay
  moveX()
  moveY()
  healPlr()
  recStam()
  breathe()
  plr.ifrms=max(plr.ifrms-1,0)
 end
--

-- MOUSE
 MB_LEFT  = 1
 MB_MID   = 2
 MB_RIGHT = 4
 prevMouseBits = 0

 function mouseBits()
  local _,_,lmb,mmb,rmb = mouse()
  local bits=0
  if lmb then bits=bits|MB_LEFT end
  if mmb then bits=bits|MB_MID end
  if rmb then bits=bits|MB_RIGHT end
  return bits
 end

 function isDown(bits, button)
  return (bits & button)~=0
 end

 function mouseTarget()
  return cam:mouseTarget()
 end

 function resetMine(itm)
  if itm==nil then return end
  itm.progress=0
  itm.targetTx=nil
  itm.targetTy=nil
  mineCrkTx=nil
  mineCrkTy=nil
  mineCrkLvl=0
 end

 function mouseInvt(mx,my,mb,pressed,scrl)
  if not invt_open then return false end

  if scrl ~= 0 then
   invtScrlRow = invtScrlRow - scrl
   clampInvtScrl()
  end

  if isDown(pressed, MB_LEFT) then
   local slot = invtSlotAt(mx,my)
   if slot ~= nil then
    swapInvtSlot(slot)
   end
  end

  return true
 end

 function mouseHotbar(mx,my,pressed,scrl)
  if scrl ~= 0 then
   plr.selectedSlot = (plr.selectedSlot - 1 - scrl) % 9 + 1
  end

  if isDown(pressed, MB_LEFT) then
   if my <= 32 and my > 13 then
    local slot = (mx-2)//17 + 1
    if slot >= 1 and slot <= 9 then
     plr.selectedSlot = slot
    end
   end
  end

  return plr.invt[plr.selectedSlot]
 end

 function mouseActiveItm(stk,pressed)
  local itm=nil

  if isDown(pressed, MB_LEFT) then
   if stk:isEmpty() then
    plr.usingHand=true
    itm=plr.hand_itm
   else
    plr.usingHand=false
    itm=stk.itm
   end
  else
   if plr.usingHand then
    itm=plr.hand_itm
   elseif not stk:isEmpty() then
    itm=stk.itm
   end
  end

  return itm
 end

 function mouseResetMine(itm,stk,mb,mt)
  if not isDown(mb, MB_LEFT) then
   resetMine(plr.hand_itm)
   if not stk:isEmpty() then resetMine(stk.itm) end
  end

  if itm and itm.targetTx ~= nil then
   if itm.targetTx ~= mt.tx or itm.targetTy ~= mt.ty then
    resetMine(itm)
   end
  end
 end

 function mouseUseItm(itm,stk,mt,mb)
  if not isDown(mb, MB_LEFT) then return end
  if itm==nil then return end
  if mt.my <= 32 then return end
  if itm.use == nil then return end
  if itm.cooldown > 0 then return end

  if itm:use(mt) then
   itm.cooldown = itm.useTime

   if not plr.usingHand then
    if itm.maxDur ~= nil then
     itm.dur = itm.dur - 1
     if itm.dur <= 0 then
      plr.invt[plr.selectedSlot] = emptyStk()
     end
    else
     stk.cnt = stk.cnt - 1
     if stk.cnt <= 0 then
      plr.invt[plr.selectedSlot] = emptyStk()
     end
    end
   end
  end
 end

 function plrMouse()
  local mt = mouseTarget()
  local mx,my = mt.mx,mt.my
  local _,_,_,_,_,_,scrl = mouse()
  scrl = scrl or 0
  local mb = mouseBits()
  local pressed = mb & (~prevMouseBits)
  if mouseInvt(mx,my,mb,pressed,scrl) then
   prevMouseBits = mb
   return
  end
  local stk = mouseHotbar(mx,my,pressed,scrl)
  local itm = mouseActiveItm(stk,pressed)
  mouseResetMine(itm,stk,mb,mt)
  mouseUseItm(itm,stk,mt,mb)
  prevMouseBits = mb
 end
--
function BOOT()
 initBg()
 initTiles()
 initWalls()
 initMiniMap()

 plr = makePlr(WORLD_W*4,WORLD_H*4)
 lastx,lasty = plr.x,plr.y
 cam=Cam:new()
 cam:update()

 inv_cursor_stk = emptyStk()
 invt_open=false
 invtScrlRow=0
 if DEBUG then setDbgMode(true) end
 npcs={}
 frm=0

 genWorld()
end
function TIC()
 frm=frm+1
 updFps()

 if not plr.dead then
  if miniMapBig then
   drawUi()
   if keyp(13) then
    miniMapBig = not miniMapBig
    if DEBUG then plr.x,plr.y = lastx,lasty end
   end
  else
   if keyp(13) then 
    miniMapBig = not miniMapBig 
    if DEBUG then 
     lastx,lasty = plr.x,plr.y
     plr.x,plr.y = WORLD_W*4,WORLD_H*4
    end
   end
   if keyp(11) then setDbgMode(not DEBUG) end
   if keyp(12) then hurtPlr(20) end
   updTilesCmbd()
   updPlr()
   updDrops()
   if keyp(2) then genTallGrass(plr.x//8, 2 + plr.y//8) end
   cam:update()
   cam:draw()
   drawUi()
  end
 else
  death_screen()
 end
end

