From d22fb95c5cfc3a40a15e90de93dac3e7739f27a8 Mon Sep 17 00:00:00 2001 From: LeonarthCG Date: Mon, 13 Aug 2018 03:12:14 +0200 Subject: [PATCH] Added eggs Added egg generation, drawing and eating, improved snake turning --- .gitignore | 1 + ASM/Egg/Assemble ARM ELF.bat | 9 ++++ ASM/Egg/drawEgg.elf | Bin 0 -> 1592 bytes ASM/Egg/drawEgg.s | 20 +++++++++ ASM/Egg/eatEgg.elf | Bin 0 -> 1476 bytes ASM/Egg/eatEgg.s | 19 ++++++++ ASM/Egg/makeEgg.elf | Bin 0 -> 1916 bytes ASM/Egg/makeEgg.s | 75 +++++++++++++++++++++++++++++++ ASM/Snake/bonkSnake.elf | Bin 0 -> 1540 bytes ASM/Snake/bonkSnake.s | 31 +++++++++++++ ASM/Snake/moveSnake.elf | Bin 2280 -> 2752 bytes ASM/Snake/moveSnake.s | 53 +++++++++++++++++++--- ASM/Snake/turnSnake.elf | Bin 1736 -> 2228 bytes ASM/Snake/turnSnake.s | 83 ++++++++++++++++++++++++++++++++++- ASM/mainLoop.elf | Bin 2176 -> 2488 bytes ASM/mainLoop.s | 23 ++++++++++ RAM map.txt | 6 ++- ROM Buildfile.event | 13 ++++++ rom.gba | Bin 3156 -> 3664 bytes 19 files changed, 325 insertions(+), 8 deletions(-) create mode 100644 ASM/Egg/Assemble ARM ELF.bat create mode 100644 ASM/Egg/drawEgg.elf create mode 100644 ASM/Egg/drawEgg.s create mode 100644 ASM/Egg/eatEgg.elf create mode 100644 ASM/Egg/eatEgg.s create mode 100644 ASM/Egg/makeEgg.elf create mode 100644 ASM/Egg/makeEgg.s create mode 100644 ASM/Snake/bonkSnake.elf create mode 100644 ASM/Snake/bonkSnake.s diff --git a/.gitignore b/.gitignore index 3896f80..56d2b6c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.db Event Assembler/ +*.sav diff --git a/ASM/Egg/Assemble ARM ELF.bat b/ASM/Egg/Assemble ARM ELF.bat new file mode 100644 index 0000000..0df75b4 --- /dev/null +++ b/ASM/Egg/Assemble ARM ELF.bat @@ -0,0 +1,9 @@ +@echo off + +SET startDir=C:\devkitPro\devkitARM\bin\ + +@rem Assemble into an elf +SET as="%startDir%arm-none-eabi-as" +%as% -g -mcpu=arm7tdmi -mthumb-interwork %1 -o "%~n1.elf" + +pause \ No newline at end of file diff --git a/ASM/Egg/drawEgg.elf b/ASM/Egg/drawEgg.elf new file mode 100644 index 0000000000000000000000000000000000000000..2362451a1f4e9822e1d29f677c27e53507634ed8 GIT binary patch literal 1592 zcmbVMK~EDw6n?WyX;HwUm>4ly3?xL84HAusCmITsK#dW4+h}&}S{h-I-L29C5pNtl z8e=?r^kU+{AHh}qBPL$_zHMhaHYONeGdth+zBli^*_rL@<@FV%lxR~jCw(UJ)lQY% z?R1)xqKt`r$*+A}$*=u5k{h|>_nn^|DcP$d2l7jOld8@nRtM0MI-lzI_?Vy$Q)8&5 zdu}}rqS##zc0(^pww9`HW%p@&CkT_+t+tZ;ZQqT<;Ca*c-10`vU2Zl-8j<%3z=^vp z<}B8lygr@T!nD2T%v%;py<=JGGL-FS4(v3Q-G1TIESKtoda1loT5uNbIJZO{stG9$ zPpI?CE=(0>3m0-}pXuWYp1rm+C)?Imz6Rt4p5GF65inPNRJ*%bsjbSeRZt^JoVc@- zcs}MN>dsplMZva{1pA3N4KMM;@#9z=IvauCZa&#=g@MUi;j>+YrkdybQSj1Ky~qoj z0TQ4A$4io^<+l^?6U_eWc8S>dnP$t-K!k!v3IqyT)$;5^?!{i>lezGUzW0@#vI z^NnWCGZ`YVWn_RGhn4Ds@uPCqSWzUNNn|-}$V?->!JDn^AnnJ3=tH)!fnm;Qf_+%{ z#JGj$;CjZ9&-S=JH5c48 z#?o$LF#e=C_M_JT3iBNh^h|5>;AVe^Mt?jJ-CqS*uVISs7#|3FrnNfgc5S_J?kV0D;D5oND)gW>}7K9?Cs)vR)BuEK|en_aYiq^!W5s6dT8&o6^ zg;O|k;=mu^Z=hVbBJl(GA6$52dmYnDQJ*xKH}hs^CTshBz4cfKK^lT8G>wS*W~Ag- zBUhozG)otn-^a#yo2;s__HqC7quftgnVd{MiTjfeM~$e^IEFK5mw&~d`8mQ2ZVMBe zYtCNi1)^Ro9hHZKv(jyImqrDtJ4Lx62zm zW^p--74yh83{3jMQ(326`d7+`&NJ9a=bq;@HJQ!S0C8-NSufgEfh-PiZF{y z#aqRz`Dji2T!$q)>lE?M8nv5X(vxnF#5K@-ZM*$&cdPw`3Pw@P2(rUB10`K}6~z8f zGvysCvO7{qvfVHwJMj8;$8$&B=l!1VW#gXza){DMldc0K;vmRM2xr z3h@~*|9PW`%;cZyVFs_R~QKDy@%z!nVjm zOrHUzU$C!C5@>B5akk$&`dP?vKfVLquLZ8pfYJ~F-?fI;4v^5CwJ`#VNdn%Du@B46 zbugEo70>0oo;v`CbOaaS+o^tfRtYNVQv87ME{&!;aee%)$6^z~Z_xR~crNe3J7oJ+ L5a2aSq38YuD-M|} literal 0 HcmV?d00001 diff --git a/ASM/Egg/eatEgg.s b/ASM/Egg/eatEgg.s new file mode 100644 index 0000000..8ee46e4 --- /dev/null +++ b/ASM/Egg/eatEgg.s @@ -0,0 +1,19 @@ +.thumb + +ldr r0,=#0x02000000 +ldrh r1,[r0,#0x6] @egg coords +ldrh r2,[r0] @size +lsl r2,#1 +add r2,#0x20 +sub r2,#2 +ldrh r2,[r0,r2] @head coords +cmp r1,r2 +bne End +mov r3,#0 +strh r3,[r0,#0x6] @destroy egg +ldrh r3,[r0,#0xE] +add r3,#1 @add size +strh r3,[r0,#0xE] + +End: +bx lr diff --git a/ASM/Egg/makeEgg.elf b/ASM/Egg/makeEgg.elf new file mode 100644 index 0000000000000000000000000000000000000000..08646684ca1e5222a7bbf5f93b4301a38dfd42ea GIT binary patch literal 1916 zcmbVN&rcIU6n?V{W&HsHqERr~Es)e;)b3d%^HEv-5rLy?OKY&9q$`nK&ne zAPGTP+E7G)8e&i5v3SZ-D>W0n=*qvoPuZg%I`j9=(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 +bne End @if egg already exists, do nothing + +@generate egg color and save it +ldr r0,=rng +mov lr,r0 +.short 0xF800 +mov r1,#1 +and r0,r1 +ldr r1,=#0x02000000 +add r0,#20 +str r0,[r1,#0x14] + +@make a list of all tiles that are available +mov r0,#0 +mov r1,#2 +mov r2,#0 @ammount of tiles in the list*2 +b loopnoadd +loop: +add r0,#1 +loopnoadd: +cmp r0,#0x1E +bne dontincreasey +mov r0,#0 +add r1,#1 +dontincreasey: +cmp r1,#0x14 +beq endloop +@check if the coords conflict with the body, if they do, do not add them to the list +push {r0-r2} +ldr r2,=bonkSnake +mov lr,r2 +.short 0xF800 +mov r3,r0 +pop {r0-r2} +cmp r3,#1 +beq loop +ldr r3,=#0x02005000 +strb r0,[r3,r2] +add r2,#1 +strb r1,[r3,r2] +add r2,#1 +b loop +endloop: + +ldr r0,=#0x02000000 +strh r2,[r0,#0x16] @save length + +@choose a tile from the list +ldr r0,=rng +mov lr,r0 +.short 0xF800 + +ldr r3,=#0x02000000 +ldrh r1,[r3,#0x16] +lsr r1,#1 +add r1,#1 +swi #6 @divide random number by length/2 +1 +lsl r1,#1 +ldr r3,=#0x02005000 +ldrh r0,[r3,r1] + +@store coords +ldr r3,=#0x02000000 +strh r0,[r3,#6] + +End: +pop {r0} +bx r0 diff --git a/ASM/Snake/bonkSnake.elf b/ASM/Snake/bonkSnake.elf new file mode 100644 index 0000000000000000000000000000000000000000..18f3f17a4ac868cc1b7dfcd4c5debe086e90f60b GIT binary patch literal 1540 zcmbVMO>5Lp6umF$j8koE$Es8+n0|;|NYFtM#6_ncj!NsoTBsV7#7WzsZBmkqC@5BO z(VrkHE?oNq{25)kbmw0X+<4BLd6Vd-(gW|kbMC#l_vX&ayk1zmsgx1}CDW2Ck*~J) zl&)Q6wO>D#BR|C1X&~I%ev)m>HN5%wX?r`2veav|vRm!IOQUdeJ@CEy@{+e4`J16g z5J#Jux@o7)l7)M|a?)-&mW7I+S)C!$*L$sLsKYhj73&`^g*5K2IQ3V&c@W0mujk&^EAEcR~ST61IH2K94be&`1+QKvvl^?OU#?$0mX zmaQ#dhWgIJ2a4ZWxw@&ognGe&&lCq^Y<`xaBs(puPTNs}+Ss-HO&?gleB3 z1WEX;==BpnS`U!`#a%zkl2*{ppbvok*9{Y~yKib9vtjA|SlXzh59g2xfVUsqDd=Hv z&a49^oXLcdh(7~9RnR>OVoO>32YN?~J~< zvJf?8swry-weW&vo+!$?)}RRAf%cO{|IyqI^M7FsQJf$16a03IcZahi#<3XJ`NTy$ z8VjJ0xPZk8929p6G3FUio$nn<7shuHniHPs+A}0(evCj*mih2%`>3#7J{=jFuuny7*5}N2#2H#_C`F!D%Smky8I1Umv&Qk z8yv1392(#L$!BU+;YC~z-{E-GQ+ZE}w+i-E3K;o)us-YZWDmuBs}T7&lIQyaZa}6( literal 0 HcmV?d00001 diff --git a/ASM/Snake/bonkSnake.s b/ASM/Snake/bonkSnake.s new file mode 100644 index 0000000..22c0f22 --- /dev/null +++ b/ASM/Snake/bonkSnake.s @@ -0,0 +1,31 @@ +.thumb + +@r0 = x, r1 = y + +lsl r1,#8 +add r0,r1 @xy + +ldr r2,=#0x02000000 +ldrh r3,[r2] +add r2,#0x20 +lsl r3,#1 +add r3,r2 + +loop: +cmp r2,r3 +beq nobonk +ldrh r1,[r2] +cmp r1,r0 +beq bonk +add r2,#2 +b loop + +bonk: +mov r0,#1 +b End + +nobonk: +mov r0,#0 + +End: +bx lr diff --git a/ASM/Snake/moveSnake.elf b/ASM/Snake/moveSnake.elf index b7b675312ed8b7ad2c996f8b2ae696d5bca29f96..7427eda258a51cbf1cb7983f17d6cf18fe80ce9e 100644 GIT binary patch literal 2752 zcmbVOOKcle6uoaI9~aW*3rZ9NcH&e{B3VvSAPpcTshfl}DTTN|kwrTbPZE>ZW9-SN zDx&GmAdnCXgg~k)R#g$Zf)L6E)IGzlV&z=~3xw1~`AC#=XZ*&GAXL7Az3;p` zcV?b_`Q*Zk5Q3x$ic_5tO@_Qk<1ufFQyU#7`Z9U*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ff --git a/ASM/Snake/moveSnake.s b/ASM/Snake/moveSnake.s index 93b8399..d10db70 100644 --- a/ASM/Snake/moveSnake.s +++ b/ASM/Snake/moveSnake.s @@ -1,15 +1,28 @@ .thumb +push {lr} push {r4,r5} ldr r4,=#0x02000000 +ldrb r0,[r4,#0xD] +cmp r0,#0xF0 +bhi EndTrampolin mov r5,r4 ldrh r0,[r5] cmp r0,#0 -beq gameOver +beq gameOverTrampolin ldr r3,=#540 cmp r0,r3 -beq gameOver +beq gameOverWinTrampolin + +b skipTrampolin +EndTrampolin: +b End +gameOverTrampolin: +b gameOver +gameOverWinTrampolin: +b gameOverWin +skipTrampolin: mov r3,r5 add r3,#0x20 @@ -110,6 +123,15 @@ b End domove: @check if the snake is going to hit herself +push {r0-r3} +mov r0,r1 +mov r1,r2 +ldr r3,=bonkSnake +mov lr,r3 +.short 0xF800 +cmp r0,#1 +beq gameOverBonk +pop {r0-r3} strb r1,[r4] strb r2,[r4,#1] b End @@ -163,6 +185,15 @@ ldrh r3,[r4] add r3,#1 strh r3,[r4] @check if the snake is going to hit herself +push {r0-r3} +mov r0,r1 +mov r1,r2 +ldr r3,=bonkSnake +mov lr,r3 +.short 0xF800 +cmp r0,#1 +beq gameOverBonk +pop {r0-r3} strb r1,[r4,r0] add r0,#1 strb r2,[r4,r0] @@ -170,8 +201,20 @@ b End End: pop {r4,r5} -bx lr +pop {r0} +bx r0 + +gameOverBonk: +pop {r0-r3} gameOver: -pop {r4,r5} -bx lr +ldr r0,=#0x02000000 +mov r1,#0xFF +strb r1,[r0,#0xD] +b End + +gameOverWin: +ldr r0,=#0x02000000 +mov r1,#0xFE +strb r1,[r0,#0xD] +b End diff --git a/ASM/Snake/turnSnake.elf b/ASM/Snake/turnSnake.elf index 82b0bb1078a8883e0ea5ff8602b2132dab4f016b..5f63da860d9c82970099cc6abc9dd07777d7d410 100644 GIT binary patch literal 2228 zcmbVN&u<$=6n?YoI1VKBnzSM!KpoqGO(QK%DWU;{Z0zPoX%Hmz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2aMj;p+XtN&qIqaE4decC$h(EpF!LQ29d}()^K&?JBR@zo=SKg-k0m(8shm* LK%T%RMdtel!y(0b diff --git a/ASM/Snake/turnSnake.s b/ASM/Snake/turnSnake.s index 138e280..f918374 100644 --- a/ASM/Snake/turnSnake.s +++ b/ASM/Snake/turnSnake.s @@ -1,7 +1,13 @@ .thumb +push {lr} ldr r1,=#0x02000000 +@check game over +ldrb r0,[r1,#0xD] +cmp r0,#0xF0 +bhi End + @get button presses ldrb r0,[r1,#5] lsl r0,#4 @@ -42,7 +48,7 @@ b End store: @one final check, check if the snake is going to be turning towards the screen ldr r2,=#0x02000000 -ldrb r1,[r2] +ldrh r1,[r2] lsl r1,#1 add r1,#0x20 sub r1,#2 @@ -53,21 +59,89 @@ cmp r0,#0x10 bne notright cmp r1,#0x1D beq End +@check if bonk +push {r0-r3} +ldr r3,=bonkSnake +mov lr,r3 +ldr r2,=#0x02000000 +ldrh r3,[r2] +lsl r3,#1 +add r3,#0x20 +sub r3,#2 +add r2,r3 +ldrb r0,[r2] +ldrb r1,[r2,#1] +add r0,#1 +.short 0xF800 +cmp r0,#1 +beq turnBonk +pop {r0-r3} notright: cmp r0,#0x20 bne notleft cmp r1,#0 beq End +@check if bonk +push {r0-r3} +ldr r3,=bonkSnake +mov lr,r3 +ldr r2,=#0x02000000 +ldrh r3,[r2] +lsl r3,#1 +add r3,#0x20 +sub r3,#2 +add r2,r3 +ldrb r0,[r2] +ldrb r1,[r2,#1] +sub r0,#1 +.short 0xF800 +cmp r0,#1 +beq turnBonk +pop {r0-r3} notleft: cmp r0,#0x40 bne notup cmp r2,#2 beq End +@check if bonk +push {r0-r3} +ldr r3,=bonkSnake +mov lr,r3 +ldr r2,=#0x02000000 +ldrh r3,[r2] +lsl r3,#1 +add r3,#0x20 +sub r3,#2 +add r2,r3 +ldrb r0,[r2] +ldrb r1,[r2,#1] +sub r1,#1 +.short 0xF800 +cmp r0,#1 +beq turnBonk +pop {r0-r3} notup: cmp r0,#0x80 bne notdown cmp r2,#0x13 beq End +@check if bonk +push {r0-r3} +ldr r3,=bonkSnake +mov lr,r3 +ldr r2,=#0x02000000 +ldrh r3,[r2] +lsl r3,#1 +add r3,#0x20 +sub r3,#2 +add r2,r3 +ldrb r0,[r2] +ldrb r1,[r2,#1] +add r1,#1 +.short 0xF800 +cmp r0,#1 +beq turnBonk +pop {r0-r3} notdown: ldr r1,=#0x02000000 strb r3,[r1,#2] @@ -76,4 +150,9 @@ End: ldr r0,=#0x02000000 @clear button presses mov r1,#0 @this is to stop the infinite zig-zag the snake does if you hold up/down and left/right and release strb r1,[r0,#5] @zig-zag can still be performed by holding down both keys, if you really really want to do that -bx lr +pop {r0} +bx r0 + +turnBonk: +pop {r0-r3} +b End diff --git a/ASM/mainLoop.elf b/ASM/mainLoop.elf index ece911148fd0dd09008f95a9cd77aaea9c2ce72a..35699754097469fe79bf7e69d320915872708a89 100644 GIT binary patch delta 871 zcmZWmOK1~e5T1WG`-mhYT4M+Xo6R;aA88V!cqxi6wo1WTJc`D;A@SyR3Y zJJqli%+c9u$l6$t8beXBU#=}3H9mkT*Mj8HUDX{Cr0^0)mr;1P~{W{lnc+JM#p;I76kvObL8J;Rez16}6_ba_Bm26SUU-@=eG>aEOO zD(5cOOV{z35^v6yX6zH?GR$ACSEec?V0P}B?Phjqo~`LCcIl7D$6SvyHsKi!kwyU4 zm=gf&%t?UP%qf5la~fciIRo&Pncn}Nc@G&~PWA$PWZnmGftmiD${YjmF&p?<343?B ze@hZ5)D$LES~iZUrm{x8XV6wn$tQ40O)|YulZub7*~Cv&2Mr}HDY}@^Qj)IWSrRrj uw3KM!6Dp-Od`G3n_>)QXsB3hXXc@+c_t{V{{5_LvYGy>ns zg#?Wp0)v7U1uX;#H*IZYtAuFLDmQIfwX9v|K0#s*-1EENIrp4<&;6K-iT=IuC&RQJN2Y5d9E?YURjblublPG_3>M|T`e zh3RWj+en7Tn`$fDOA}UecPjH0MXTvZPI@&i$0w8FPFmUs#COL2+uoNd9deRhc1>7^ z+kWlF_*k`OU8-1x$~b=}j}G`J?Q^7Zba3=S%@aN0zt(el$_2ex_2VhdU0N{Ormwf@ z+x$)sWMwKUkhyT)@)G#zMT~y~LGAz%!{)9?&xE1@;a5fLDh7 zz#GE>;H{w#yf+MhhlYgs+f_HvY4ladzn{l*|L5~uv8QF?b-Sor8o0@??V>sZf3iyk zzwDAelY%48J4JP(`Ib{6<~gUVPBrg}80HU7nI`$WgnnyQZi(tV;+84m8Mi#yVFA7Z bQqn|*L5D2!5?7X_E^J6He|(_;86dWQ`nY9l diff --git a/ASM/mainLoop.s b/ASM/mainLoop.s index f7b932e..24da79e 100644 --- a/ASM/mainLoop.s +++ b/ASM/mainLoop.s @@ -63,6 +63,10 @@ add r0,#0x10 mov r1,#1 strb r1,[r0] @set bg 0 to be updated +ldr r0,=makeEgg +mov lr,r0 +.short 0xF800 + ldr r0,=turnSnake mov lr,r0 .short 0xF800 @@ -71,6 +75,19 @@ ldr r0,=moveSnake mov lr,r0 .short 0xF800 +ldr r0,=eatEgg +mov lr,r0 +.short 0xF800 + +ldr r0,=makeEgg +mov lr,r0 +.short 0xF800 + +ldr r0,=#0x02000000 +ldrb r0,[r0,#0xD] +cmp r0,#0xF0 +bhi nobg0draw + ldr r0,=cleanSnake mov lr,r0 .short 0xF800 @@ -79,6 +96,12 @@ ldr r0,=drawSnake mov lr,r0 .short 0xF800 +ldr r0,=drawEgg +mov lr,r0 +.short 0xF800 + +nobg0draw: + skipSnake: b main diff --git a/RAM map.txt b/RAM map.txt index 88f7e02..c7f2387 100644 --- a/RAM map.txt +++ b/RAM map.txt @@ -12,5 +12,9 @@ $02000010 BYTE Update background map 0 flag $02000011 BYTE Update background map 1 flag $02000012 BYTE Update background map 2 flag $02000013 BYTE Update background map 3 flag +$02000014 BYTE Tile to use for egg +.. +$02000016 SHORT Length of list at $02005000 ... -$02000020 LIST Snake body piece coordinates \ No newline at end of file +$02000020 LIST Snake body piece coordinates +$02005000 LIST Buffer with available tiles for eggs diff --git a/ROM Buildfile.event b/ROM Buildfile.event index 8c13c70..45428c1 100644 --- a/ROM Buildfile.event +++ b/ROM Buildfile.event @@ -54,10 +54,14 @@ turnSnake: //button presses are saved each frame, even if the game logic isn't run each frame, and are cleared at the end of this routine //this allows the player to input a direction for the snake to turn to without having to hold the button down waiting for the game logic //the snake also can't turn towards the border of the screen if adjacent to it +//in addition, the snake can't turn if doing so is going to make her face her own body immediately moveSnake: #inctext lyn "ASM\Snake\moveSnake.elf" //check if the snake has grown and move all pieces of the body as needed +bonkSnake: +#inctext lyn "ASM\Snake\bonkSnake.elf" //check if the given coords are already occupied by snake, return 1 if it is + cleanSnake: #inctext lyn "ASM\Snake\cleanSnake.elf" //wipe the background layer to avoid leftover snake bits @@ -69,6 +73,15 @@ drawSnakeBody: //the checks got long enough for it to justify a routine //snake body shapes are the -, the |, the luigi, the waluigi, the mirror luigi and the mirror waluigi, of course +makeEgg: +#inctext lyn "ASM\Egg\makeEgg.elf" //spawn egg and write the coords and tile to ram for the drawEgg routine + +eatEgg: +#inctext lyn "ASM\Egg\eatEgg.elf" //check if head and egg are in the same coords, and if so remove egg and add size to snake + +drawEgg: +#inctext lyn "ASM\Egg\drawEgg.elf" //draw egg according to the coords and tile in ram + /* facing directions of the snake: 1 diff --git a/rom.gba b/rom.gba index e42d2afb9b6f501bbfa71745e84b079fd2dcbf4f..d8062dd872a18dc906393a2a3d53edf9cefb6879 100644 GIT binary patch delta 1105 zcmZ9LL2MgU5Qb;ouI*=NVjDZDlWgg(tyF6pDQo)@7myscYTw$lYNCKbdI>#ow5bFe z6=Wv|v<)DEELEXMaNvRj2c#x93lSnD4jf*fhqN5BMM4%mMQSB1gc@eo98$D;GxPR+ zZ#47o?A^4~zUA2diUS9L@F4^K!e|hObOe4zaAT(l2DYXJ8u(V$x1Fru8P>^&tc@#K z@%{xEX!T5E!ih#>Igs^N*SsbN`ZZPbikA*;0FbVj+F<38CQ zj0G2lHWkG2z=lQj#-Yjghr6MT1t&lDsb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