From ac4e457e177eae7ec54790c8faddedd3972285ba Mon Sep 17 00:00:00 2001 From: jordism Date: Mon, 29 Apr 2019 23:50:17 +0200 Subject: [PATCH 1/8] playing a bit with sounds --- font.asm | 7 ------- game.font | Bin 768 -> 0 bytes game_zx.c | 43 +++++++++++++++++++++++++++++++++++++++++++ game_zx.h | 1 + msnampac.c | 1 + zproject.lst | 1 - 6 files changed, 45 insertions(+), 8 deletions(-) delete mode 100644 font.asm delete mode 100644 game.font diff --git a/font.asm b/font.asm deleted file mode 100644 index d95696e..0000000 --- a/font.asm +++ /dev/null @@ -1,7 +0,0 @@ -SECTION FONT - -PUBLIC _game_font - -_game_font: - - BINARY "game.font" diff --git a/game.font b/game.font deleted file mode 100644 index 668eda5d2234d99e12dfa6fdd08c1eca3aceae53..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmXw1v1;5v5FHXBu2_u9EsQPj6<4aYOc4pqpvLc$Hwa!RuS}xS@_k=a0|M&o#x^^{qU*n0o zs!h~&)ULt$G1rBWt!F3U2Bt0aka>)Ymb4P61^*KO;VcemX{M!ygLeT6u5 z^h5Wx_?gNiQYXIh!y!H9gI1!qz`g9RvX$h^w(Pq_mSc|VJinQLW^59TN%AaO6;aNw E|7oA#Gynhq diff --git a/game_zx.c b/game_zx.c index a96b4b1..886d5b0 100644 --- a/game_zx.c +++ b/game_zx.c @@ -9,6 +9,47 @@ extern uint8_t strlen(char * chars); // temporary buffer to print points (e.g. 65535) char * chars = "0000000\0"; +void make_sound() { + __asm + .ayctrl EQU 65533 + .aydata EQU 49149 + + ld d,0 ; select the mixer register + ld e,10 ; enable channel A only + call outer ; send it to PSG + ld d,1 ; select the mixer register + ld e,10 ; enable channel A only + call outer ; send it to PSG + ld d,6 ; select the mixer register + ld e,29 ; enable channel A only + call outer ; send it to PSG + + ld d,7 ; select the mixer register + ld e,216 ; enable channel A only + call outer ; send it to PSG + + ld d,8 ; select the mixer register + ld e,31 ; enable channel A only + call outer ; send it to PSG + + ld d,11 ; select the mixer register + ld e,4 ; enable channel A only + call outer ; send it to PSG + + ld d,12 ; select the mixer register + ld e,4 ; enable channel A only + call outer ; send it to PSG + + ret + + .outer ld bc,ayctrl ; select control port + out (c),d ; send specified value + ld bc,aydata ; select data port + out (c),e ; send specified value + ret + + __endasm; +} // reversed order digit extract void print_points() { @@ -25,4 +66,6 @@ void print_points() { sp1_PrintAtInv(0, 26 + idx + col, INK_CYAN | PAPER_BLACK, chars[idx]); ++idx; } + make_sound(); + } \ No newline at end of file diff --git a/game_zx.h b/game_zx.h index cfc01ee..0a4895c 100644 --- a/game_zx.h +++ b/game_zx.h @@ -5,5 +5,6 @@ #include extern void print_points(); +extern void make_sound(); #endif diff --git a/msnampac.c b/msnampac.c index cce17c9..946ac05 100644 --- a/msnampac.c +++ b/msnampac.c @@ -140,6 +140,7 @@ int main() zx_border(INK_WHITE); while(1) { + if(lives == 0) { all_lives_lost(); } diff --git a/zproject.lst b/zproject.lst index 83dc8ad..b8cbd23 100644 --- a/zproject.lst +++ b/zproject.lst @@ -1,5 +1,4 @@ @build/binaries.lst -font game_zx.c logic.c sprites.c From cf319b086a507754dfe891a70864eb2a84e07de1 Mon Sep 17 00:00:00 2001 From: jordism Date: Wed, 1 May 2019 01:01:10 +0200 Subject: [PATCH 2/8] dead animation --- .DS_Store | Bin 8196 -> 8196 bytes Makefile | 3 +- afxplay.asm | 0 build/binaries.lst | 1 + build/prota_dead.asm | 296 +++++++++++++++++++++++++++++++++++++++++++ build/prota_dead.png | Bin 0 -> 2152 bytes game_zx.c | 44 +++---- globals.h | 5 + intro.scr | Bin 0 -> 6912 bytes logic.c | 20 ++- msnampac.c | 1 + sprites.c | 12 ++ sprites.h | 1 + zproject.lst | 1 + 14 files changed, 360 insertions(+), 24 deletions(-) create mode 100644 afxplay.asm create mode 100644 build/prota_dead.asm create mode 100644 build/prota_dead.png create mode 100644 intro.scr diff --git a/.DS_Store b/.DS_Store index 58a5c5769bde6e472e9699593be6b8ef2816d473..0f8784f3945f3adebc661df7ad6c470e3f2b24fc 100644 GIT binary patch delta 1106 zcmeH^$xjne0LI_PQr@!1GZ`vDI!H63I?=5B6~~}BL;$LozYBar$7rTQHznp z81-PrEvN|>V^mxcToW&vn3!nd5{QZ0$*X$PgBM>rxEwV81J2p?MdlPL#h}}nJ<(5 zObXGixHhVqpD5$yOp3FveodcybtSK&lEOAeLSZ!`4khh*@+w|KrFOPuL>-E2G2P5? z@H)!6x5uJURZqlCZJpderN^`{mD~}ECpHYIx(Lq`|Ip--<*g~bK~YqNQtAtaCrRq@ z1xwO1@tG4L%onVfTT|n$v(Q+R?@C&ci}|p@jRF*+2!2$e3e^ar6>aE1CpMx7z39U> zD2PJG00yxOV>p0=7{^hZ#3`J{Brf4Hrf?Pa@d(fG953(^Z}0&h@ySfhz+8IAj~fwU zNiFf!c$Z(`Iq~NXz3ZD>T)a(mIAL6Ku((yuN=z_o3k-#E%tIz zADa>N7M2!!y;6o~Hnk}a2q#lCWqMWB+$&{^QcSm|mUAgfv}U^XYlUkO^_Xts0^t(I z{>j&vb(UB^lW!ofz>0i>x_rqH!st)Ki(xlLu^0QWABS)lM+CrQ0^k`;;4IGJ0xqUO zUcpV=#vR#72Q|4d* delta 990 zcmd^+%}W$v9LJyU>aNeYV~y+jk~Iy>mYb%ymRe@zYN_Qac34pAOsOTyW=VP4|)#I%kTSxhu`Nj<{R@p zqWNp*y=_og&mlf!CXQr3o&TH?6irgUzlkniAKqT6seibh43 z=%IAK5=^MO;wsw}Gp`UUIUz^`x^_Y}E7g1rC+J+@m=-mA#9F?d3JTW~4$5jc(kGvq5jC37&034Nn+k7e`N8zhok2a(J*Y<6=MFYXn@be? z)AeRWQ58z5+jr=N@ySta4Mc+x)mU=u7^QHa6mG0X89eZ!2AfffW^}-hPV^xN846S! zg^mPL7{&8;@FVjA}t*e7_(z&>YS-!iQ4F>j0)NccQ6P?W?> PPRUZXBct ./build/topvertiright.asm png2udg ./build/ghostpill.png -a > ./build/ghostpill.asm png2sp1sprite ./build/prota_sprites.png -b -i sprite_protar -f 16 -s rodata_user > ./build/prota.asm + png2sp1sprite ./build/prota_dead.png -b -i sprite_protar_dead -f 16 -s rodata_user > ./build/prota_dead.asm png2sp1sprite ./build/red_ghost.png -b -i red_ghost -f 16 -s rodata_user > ./build/red_ghost.asm ls *.bin - zcc +zx -v -startup=31 -DWFRAMES=3 -clib=sdcc_iy -Cz--screen=screen.scr -SO3 --max-allocs-per-node10000 @zproject.lst -pragma-include:zpragma.inc -o msnampac -create-app + zcc +zx -v -startup=31 -DWFRAMES=3 -clib=sdcc_iy -Cz--screen=intro.scr -SO3 --max-allocs-per-node10000 @zproject.lst -pragma-include:zpragma.inc -o msnampac -create-app #zcc +zx -v -m -startup=31 -clib=sdcc_iy -SO3 --max-allocs-per-node10000 @zproject.lst -pragma-include:zpragma.inc -o alley #appmake +zx -b screen.scr --org 16384 --noloader --blockname screen -o screen.tap #appmake +zx -b alley_CODE.bin --org 24500 --noloader --blockname code -o code.tap diff --git a/afxplay.asm b/afxplay.asm new file mode 100644 index 0000000..e69de29 diff --git a/build/binaries.lst b/build/binaries.lst index fb65c95..861998b 100644 --- a/build/binaries.lst +++ b/build/binaries.lst @@ -1,4 +1,5 @@ prota +prota_dead horizontal vertical corner_left diff --git a/build/prota_dead.asm b/build/prota_dead.asm new file mode 100644 index 0000000..dd9ad26 --- /dev/null +++ b/build/prota_dead.asm @@ -0,0 +1,296 @@ +SECTION rodata_user + +; Original: 64, 24 (=8 x 3 chars) +; Blocks: 2 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +PUBLIC _sprite_protar_dead1 +._sprite_protar_dead1 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000110 + defb @00111111 + defb @01111111 + defb @01111111 + defb @11111111 + defb @11110000 + defb @11110000 + defb @11100000 + defb @11000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar_dead1_f2 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000001 + defb @00000001 + defb @00000001 + defb @00000001 + defb @00000011 + defb @00000011 + defb @00000011 + defb @00000011 + defb @00000011 + defb @00001111 + defb @00000010 + defb @00000010 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar_dead1_f3 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000001 + defb @00000001 + defb @00000001 + defb @00000001 + defb @00000001 + defb @00000001 + defb @00000001 + defb @00000001 + defb @00000001 + defb @00000001 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar_dead1_f4 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00001000 + defb @00000101 + defb @00000101 + defb @01100000 + defb @00010000 + defb @00000000 + defb @11100000 + defb @00000000 + defb @00010000 + defb @00100101 + defb @01000101 + defb @00001000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +PUBLIC _sprite_protar_dead2 +._sprite_protar_dead2 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @11000000 + defb @11100000 + defb @11100000 + defb @11110000 + defb @11110000 + defb @11110000 + defb @01110000 + defb @00111000 + defb @00001000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar_dead2_f2 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @11000000 + defb @11000000 + defb @11000000 + defb @11000000 + defb @11100000 + defb @11100000 + defb @11100000 + defb @11100000 + defb @11100000 + defb @11111000 + defb @00100000 + defb @00100000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar_dead2_f3 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @10000000 + defb @10000000 + defb @10000000 + defb @10000000 + defb @10000000 + defb @10000000 + defb @10000000 + defb @10000000 + defb @10000000 + defb @10000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + +._sprite_protar_dead2_f4 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @11000000 + defb @00010000 + defb @00010000 + defb @00100000 + defb @00000000 + defb @00011000 + defb @00000000 + defb @00100000 + defb @00010000 + defb @00000000 + defb @00000000 + defb @11000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + defb @00000000 + diff --git a/build/prota_dead.png b/build/prota_dead.png new file mode 100644 index 0000000000000000000000000000000000000000..5f1a52a77f138ad645f00522689b11f0500dad47 GIT binary patch literal 2152 zcmV-u2$%PXP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O1eucH}q={O2k52x0)kahUMl-e8Zv1&~rpZF|NO zTFnH42xPLr1_MGJK z$m8tSZJc|2#dCU1NZXQa&*vufZ6|L-`^9O{%gPQHdtBazyj#!hzBgshtKk;T{^RcS zHMRBX{XQgsF$ng&Gj4k84}1q%#lr(%e8oB7+j|{^bM=I0@+5zbow+XGz>CM{*d29` z@J}erH6y-Zw4Yo096Lqm!P&UIgC@mm@eDn#_ zAb~(u2n7A4kfEVUo`NBwNQp8Ps?o;~DaM$h)To+#3W-uoDdkjB%|3@rIp&meF1Z$0 zJW3dqSduBZlu|1etuS3NyJAGG%{AXbqZV6gxs_Hs} z_Z4$SsQVkt8KG`7_mQ_xSQ}M4idTXp3kB1|GYT69%v@cr(vyDsZ2r^$hl6t@c+?wD z3pyCkKr4f}d7j-)!fk7*w8m*NqjUfT3lt`g*k9wo_*+8777#09g&0>wTG+#46>bMTD30;J|+Tw_M_1#iZ{e!=(6l(`|-#u@N- z_>6e_t7dl8_n0+evqOepD#U_75$TLkry~{-&OkZ>c&|++40v0_<>QzzF_B`JIAmKR zI}@^j9_LgKbuDYO%{FcXHi0k}V~z(qAVQ<{A#Nq3E60{0da#TY64N5PX=~}jW7=FE zQUxkmu)RYoOLeoHd?5>{@7UguZNRnZXpW`IxnLMxO}RE4^GI1XaT?U^tifTO6ZYznG22>u1fNJZK=S!fG%u=Y5sak1b0g(;_i5|gP_*MJyoGHdc+Am>?vOfs> z%GMR)lC>^{Y{BdCpxbt(~)bs)!Rzc zLb2!tt3BAs+f(YzKQ19x?ez?z}{N7y|-?u zkXjX>g;!l@X{iHcL5jI#@DQVt-~`dnK{T_KwY8^olv-@pq^ReDDcE6-#$6%A&Jwv9 zMRFK{XnjL2RLSa|r5~KlN)_2G>e1P)B)L~J)?S6=)@CfN>UebGM`u6#i}}!C_{_DR zYv(QhSa6K+$U}%8@FtZnM1R9@Ec@!G?e@F9!>%imjD8jG^^+|fO z+B0(mKC9ujw>AhVZi}nu*30Ib1vQ`^!N$wNeg1Ryi|R9;M=<83`m=aIH6pU#+D@4F zO`e@s81*5uGPD;?ea?wrkPyuAd;9)-I-9Ta`N!$}Ufa!g zi#z|I_Q~0NCkFmT*){jN`$gFm#gDJ*P_1jrX8!C)*6aK?46*Ft&HtqC#K_|ub_W0e z00v@9M??Vp0Q>*|$XSe+00009a7bBm001r{001r{0eGc9b^rhX2XskIMF-;q9u+bs zJks^|0002bNkl)^^am4-bTA7B1?2sM4+la-*Y{-j^Y&`AxjN-kXf47E=S!5 zfYQ_18Q*_0NJPGrZ}~Jez;j%Q`jJl6TF!pQ8|a?};C2Keho`H5rGK{jE�nR!ml4 zgZF#9toPmqJvHqCD9ft5na$+oodZ%LIGempA`9FsP@|*zigSPmbY($vH25IG+aLiT e00e*l>}wxCKZhhRlHiH}00002)h9rHY|?Xf4BKU?~)c5J_o?RkHGJ$Cf+xvtvc3ftc} zr_&SlEnI85Px0^df3?1#R~PtS>%~wShw{W@30=pDio~&IC)!O@_-FBX7GZp$H~LYX zo<02oGp~y@QXF)jkI*uuL|-VSr>d8Sn$(Lvigj@@jY(YUj?eW6evG>3GwZWZ(K*~} zc3a}#>s$Qn0ITR)saO|txLf#>BociyJ4MH>^_lBzr43&r|8>jX(^%}14|5qSB>qBA zV^&Iii+|BWwxIj?g`fE|`GvNu=q0~dp9muC&=fZR(@5)Vq+9u?_af@~W`=%M{*4Cz zSAVwiU%x)$_=N&Nz{iHzx#ico%Fq2-TF${s{Cj@t3G(Op*`uOgpo^JyEj2tmzjI{| z;cm%)|7j%r`ZnjNo4gIa$F^`dsqIM}_}%`}?ospT?X8{{j>1 zQ5`?z8org|U%X$da}=#OzBl6dw3Z*+=bsOSKe@{9zc5SAf!6Y)qiDnNyZnDC@~;Y= znD|=wWid|CyOLk?ijrT0-{;ru|IC~(Hk>kld1O5c#@&+tATje1Kqlc zXf*Tsi5tH}*fPHyLgjesTbp5xi5|yxHtGyt@vSs|D1pv~<3JQ0D_=K1=C1JZT?l&-v4SMw|8C40tcHIHx93Nrz%HUt0tSJZqyUu@0)eX@ixczvC;7aKM#KJ_rPDr zw@8FP*B$&<-)>tU`K_rRyZ7?@-m(^cd|T=oyKnLN8FF(F?CQvW&+sP!zlz<781PTS z{JZ#|KRKHr|Cito*01DS@scVKe>6w5<@!=DeE6(2^7ELxW%};&8NbE~#i&+wz98fe z?zcEN-(3D1_&1v~E?_7Bu;G3?;U$IO=9r|DAAQ8QKIZ$M`ZIo;&vizLHHuMG`Cma# zlp3M?Z*edttaj-dA1KW2s&J?TNAXtGyWPTf*kb7?Eh40J%-g)ty4ELoE&i9pQ*UU! z%m0i@)EHMFxE&d|f@;#ipLg;1V$9aKKawu~&&DH+uiGE|Jl#bW@~7fgZ(-PFEdRQ- zS90~ZRqx_|_fq`L>+@bM|CunFU!V-{k&V%^cWwEQDDTLB2ft1qgtKkev&-?<#A$%<#vteZNicHQTfW zu1RBW+A=J%u<^?EXX92r+)w?sITOQQ$zRw%>EO40zqh5NeiTlC>wMaN(6#gD!)0~4 zt=6;l^R1g-jWFZ?&Of6;&fWQ@wi9e_0J($Nwa(h_w|rPP#``uuU-6C3+QDRSU~Do$ zIT;KFreeJZY{5mN&c?u0Ob@!nYjlhkKU`kNB$LVh{yyh-Zl}9)|K?3-lfn34OjkKR z&}IC14BZ6dBq=ey)A=^cCB{09V=#0u*&C0o!|E)oesmp4sp, &full_screen, (void*) ghosts[idx]->offset, ghosts[idx]->y, ghosts[idx]->x, 0, 0); + } + + // prota dead animation, first hide the sprite from the screen + sp1_MoveSprAbs(pacman.sp, &full_screen, (void*) pacman.offset, pacman.y, 32, 0, 0); + // 1, 33, 65, 97 + for(col = 1; col != 129; col += 32) { + sp1_MoveSprAbs(pacman.alt, &full_screen, (void*) col, pacman.y, pacman.x, 0, 0); + sp1_UpdateNow(); + for(idx = 0; idx != 5; ++idx) { + wait(); + } + } + + sp1_MoveSprAbs(pacman.alt, &full_screen, (void*) col, pacman.y, 32, 0, 0); + sp1_UpdateNow(); + pacman.y = 21; pacman.x = 14; pacman.dx = 0; @@ -82,7 +100,7 @@ uint8_t goto_xy(struct sprite * for_who, uint8_t x, uint8_t y) { struct sprite * has_collision() { for(idx = 0; idx != 4; ++idx) { - if(pacman.x == ghosts[idx]->x && pacman.y == ghosts[idx]->y) { + if(abs(pacman.x - ghosts[idx]->x) < 1 && abs(pacman.y - ghosts[idx]->y) < 1) { // eat return ghosts[idx]; } diff --git a/msnampac.c b/msnampac.c index 946ac05..79b9ee6 100644 --- a/msnampac.c +++ b/msnampac.c @@ -126,6 +126,7 @@ int main() sp1_TileEntry('n', topvertiright); pacman.sp = add_sprite(); + pacman.alt = add_dead_prota_sprite(); pacman.offset = 1; pacman.currentoffset = 1; diff --git a/sprites.c b/sprites.c index fa0c563..07dcb9d 100644 --- a/sprites.c +++ b/sprites.c @@ -67,6 +67,18 @@ struct sp1_ss * add_sprite() { return sp; } +struct sp1_ss * add_dead_prota_sprite() { + struct sp1_ss * sp; + sp = sp1_CreateSpr(SP1_DRAW_XOR1LB, SP1_TYPE_1BYTE, 3, (int)sprite_protar_dead1, 1); + sp1_AddColSpr(sp, SP1_DRAW_XOR1, SP1_TYPE_1BYTE, (int)sprite_protar_dead2, 1); + + sp1_AddColSpr(sp, SP1_DRAW_XOR1RB, SP1_TYPE_1BYTE, 0, 0); + + sp1_IterateSprChar(sp, initialiseColourYellow); + + return sp; +} + struct sp1_ss * add_ghost_sprite() { struct sp1_ss * sp; sp = sp1_CreateSpr(SP1_DRAW_LOAD1LB, SP1_TYPE_1BYTE, 3, (int)red_ghost1, 1); diff --git a/sprites.h b/sprites.h index 0563c9e..a136c87 100644 --- a/sprites.h +++ b/sprites.h @@ -9,6 +9,7 @@ extern struct sp1_ss * add_sprite(); +extern struct sp1_ss * add_dead_prota_sprite(); extern struct sp1_ss * add_ghost_sprite(); extern struct sp1_ss * add_ghost_red_sprite(); extern struct sp1_ss * add_ghost_cyan_sprite(); diff --git a/zproject.lst b/zproject.lst index b8cbd23..2a44fbd 100644 --- a/zproject.lst +++ b/zproject.lst @@ -1,4 +1,5 @@ @build/binaries.lst +afxplay game_zx.c logic.c sprites.c From dff359c988e0557411ec3abff49140b258602827 Mon Sep 17 00:00:00 2001 From: Jordi Sesmero Date: Wed, 1 May 2019 19:38:10 +0200 Subject: [PATCH 3/8] make sounds --- .DS_Store | Bin 8196 -> 10244 bytes ay/ay.lst | 2 + ay/ayfx.asm | 29 ++++++++ ay/ayfx.h | 18 +++++ ay/fx/click.afx | 1 + ay/fx/wowow.afx | Bin 0 -> 68 bytes ay/fx/wowow2.afx | Bin 0 -> 66 bytes ay/mfx.asm | 171 +++++++++++++++++++++++++++++++++++++++++++++++ game_zx.c | 43 ------------ int.c | 4 +- logic.c | 2 +- msnampac.c | 2 + zproject.lst | 1 + 13 files changed, 227 insertions(+), 46 deletions(-) create mode 100644 ay/ay.lst create mode 100644 ay/ayfx.asm create mode 100644 ay/ayfx.h create mode 100644 ay/fx/click.afx create mode 100644 ay/fx/wowow.afx create mode 100644 ay/fx/wowow2.afx create mode 100644 ay/mfx.asm diff --git a/.DS_Store b/.DS_Store index 0f8784f3945f3adebc661df7ad6c470e3f2b24fc..79fe1b9bc76e6c3f49f2a13802ae1f321ee42378 100644 GIT binary patch delta 1735 zcmb`HT}&KR6vxkhfpTY9%B+0sPYzXBMQ0 zTPsFQT9vHP#A>3(Xd)Uz8hkJ@^-W_;s*yzW!533~@S&QT7~_N9*;$lCjfQlRnRCxM z_ue`8{{Hu_bgc}_M1-D{8X&6SO~zl#O3u}}iq*sW%bnZ-_bD8Shk5&xa3Z3w&pltb zdb;>RA|Ff z=p8q;hs=e|Mp=Jw9+&EmZ!lIuEA zJi%8GGxY~_EjhZNtLE&4VoYl>RgcY#&Fh99j%Xt>C91h_SrD?LD%`R>o(k)8DcxL@ zY8l&<_LdZj9=S@8HrSM^nA)9j)tXVwW@L|ifTh`_l?Wy^{y`lEn-jCDz-7{c42H@OB#ASW(PaOW6TAgFwXZe$`@qV z;alY{CVkBAQ`7vncPNHAl+a@Q|JLezJhD7t71gb(n#vff?P|2QzqZS7Hw3P&N;*tk zG(c0NQGyofEIm!n(0O{D-lYw?NFULsbcsHr&*^LWmM+tG^gaDZKhahC8Gwi)I3Xjw z9|ur}dK^RxTG57fbfORa7{DNgFpddKVhSpvh+z&%EMWzY;|V;87w`(+!W!PjJ9rNl z?aCZn-`Qs{XLAN0^2WA!a>{m$g%j?-tH;|{*8e}%Q^D2qmD83?X<2zyZNnk|%|~y` zyi_*CxEw0?T`zhwSIcflTTXS2*DG1O&NeMqsPl?k7edx)tm8RHF5_$BnLMrlI~Qmc zy;1>(ZI5ef7ey(btHI75>*U!zoIBgBbjuZDw-^*GO-i(bTl&Ajy+&*FK8N-NZP7Oz z*bf}muksUzsXQ3SKJj$;^iV+5nP2PdImniJDFu>>b( zz)WKqX*`NEcnoK84$op089axV@rKRkPizA@UO9s|x3NXzy}fG6oF>}3Vm#Gc{#RW6 z$9Q6P$KBz!r_1u64<%!fcx;A;aKS14R=9rp1Gw_+9yLYW_E}fv`rI#hnG(-kWe)oy m%^m?RuIvfOBs}NRS#Z0dacy9vcTMBkz!=^&jem!+fjOe{;en4Z01WL|cXarp+u<gj`;|g!a6*i13 Vj2K@;GqJoVVC8zzz|Ma`0RV7u6rBJ7 literal 0 HcmV?d00001 diff --git a/ay/mfx.asm b/ay/mfx.asm new file mode 100644 index 0000000..d117dad --- /dev/null +++ b/ay/mfx.asm @@ -0,0 +1,171 @@ +; modified for z88dk/z80asm and Gandalf + +; mFX Player v0.1 +; by Intense in 2017 +; +; A sound effect player intended for simultaneous AY music+fx. +; Uses sound effects authored with Shiru's AyFxEdit. +; Uses a single redefinable AY channel for playback. +; If a new sound effect is added while another one is +; playing, the latter is interrupted and discarded. +; +; WARNING: This program expects the stack to contain +; AY register data. It should preferrably be used alongside +; the included mFX edition of the Vortex Tracker II player, +; or another AY music player that supports this mechanism. +; Do not call MFXPLAYM without a preceding call to the music +; player in case you want to play an effect on its own! +; Use the entry point MFXPLAYE for this instead. +; +; Init: +; call MFXINIT +; +; Adding a new effect: +; ld hl,EffectAddress ; MSB = 0 means no effect +; call MFXADD +; +; Once per frame (Vortex Tracker II example): +; ld hl,VT2PLAYER+10 ;setup byte in the VTII player (SETUP) +; set 1,(hl) ;enable stack output for AY reg data +; call VT2PLAYER+5 ;process VTII frame, SP=SP-14 at exit (PLAY) +; call MFXPLAYM ;process fx and OUTput to AY, SP=SP+14 + + + +; AY channel to use for playing back the sound effects +; Values are 0 for channel A, 1 for channel B, 2 for channel C +; Default: 1 + +defc mfxAyChannel = 2 + + + +; Initializes the player. +; Mutes the AY and sets up the variables. +; + +MFXINIT: + xor a + ld l,a + ld h,a + ld (mfxTone+1),hl ;zero tone and noise values + ld (mfxNoise+3),a + ld (mfxPtr+2),a ;set no sound effect + ld e,14 +mfxInit0: + dec e ;zero AY channels 0~13 + ld bc,0xFFFD + out (c),e + ld b,0xBF + out (c),a + jr nz,mfxInit0 + ret + + + +; Sets a new sound effect to play. +; If another effect was playing at the time, it is discarded. +; +; Input: HL = effect address MSB=0 for none + +MFXADD: + ld (mfxPtr+1),hl ;save it to mfxPtr and exit + ret + + + +; A secondary entry point used to play back the effects without the music. +; +; Input: None +MFXPLAYE: + pop de ;get the return address in DE + ld hl,0 ;PUSH 14 zero values into the stack + ld b,7 +mfxPlayE0: + push hl + djnz mfxPlayE0 + push de + + +; Main effect playback routine. Must be called each interrupt +; after a call to a mFX compatible music player. +; Expects AY register data (14 bytes) on the stack. At exit, +; SP will increment by 14 not counting the return address. +; +; Input: (SP) = return address followed by AY register data + +MFXPLAYM: + ld ix,2 ;IX = SP+2 + add ix,sp +mfxPtr: + ld hl,0 + ld a,h + or a ;if the effect pointer MSB is 0, that means no sound effect is set + jr z,MFXOUT ;in that case, just OUTput the music player AY frame and exit + + ld a,(hl) ;fetch the frame descriptor byte + and 0x0F ;leave only the volume nibble + ld (ix+8+mfxAyChannel),a;store the volume into the AY buffer + xor (hl) ;leave the mixer bits (upper) nibble + inc hl + bit 5,a ;is there a change to the tone pitch? + jr z,mfxPlayM0 ;if not, skip this part + ld de,mfxTone+1 + ldi ;store the new mFX tone pitch + ldi +mfxPlayM0: + bit 6,a ;is there a change to the noise pitch? + jr z,mfxPlayM1 ;if not, skip this part + ld de,mfxNoise+3 + bit 5,(hl) ;is the effect over yet? + ldi ;store the new mFX noise pitch + jr z,mfxPlayM1 + ld h,0 ;if end of effect, set effect ptr MSB to 0 (no playback) +mfxPlayM1: + ld (mfxPtr+1),hl ;save the effect pointer + ld e,a + or 0x6F-(1<<(mfxAyChannel^3)) +mfxPlayM2: + rrca ;rotate the mixer bits in the descriptor as needed + jr c,mfxPlayM2 ;based on the AY channel number + and (ix+7) ;combine it with the mixer value from the music player + ld (ix+7),a ;save the resulting final mixer value into the AY buffer + bit 7,e ;test whether the current mFX effect frame has noise enabled + jr nz,mfxPlayM3 +mfxNoise: + ld (ix+6),0 ;if it does, overwrite the noise pitch register data from the music player +mfxPlayM3: + bit 4,e ;test whether the current mFX effect frame has tone enabled + jr nz,mfxPlayM4 +mfxTone: + ld hl,0 ;if it does, overwrite the tone pitch register data from the music player + ld (ix+mfxAyChannel*2),l + ld (ix+mfxAyChannel*2+1),h +mfxPlayM4: + xor a + +MFXOUT: + pop ix ;IX = return address + ld bc,0xFFFD ;output the resulting AY register data for this frame and restore SP + ld de,0xFFBF + jr mfxOut0 +mfxOut1: + out (c),h + ld b,d + inc a +mfxOut0: + pop hl + out (c),a + ld b,e + out (c),l + ld b,d + inc a + out (c),a + ld b,e + cp 13 + jr nz,mfxOut1 + push ix + bit 7,h ;the envelope shape register (R13) should only be modified when it has changed + ret nz ;this should be indicated by BIT 7 reset in the music player AY data output + out (c),h + ret diff --git a/game_zx.c b/game_zx.c index 2f98ed9..8cab372 100644 --- a/game_zx.c +++ b/game_zx.c @@ -9,48 +9,6 @@ extern uint8_t strlen(char * chars); // temporary buffer to print points (e.g. 65535) char * chars = "0000000\0"; -void make_sound() { - __asm - .ayctrl EQU 65533 - .aydata EQU 49149 - - ld d,0 ; select the register - ld e,10 ; set value - call outer ; send it to PSG - ld d,1 ; - ld e,10 ; - call outer ; - ld d,6 ; - ld e,29 ; - call outer ; - - ld d,7 ; - ld e,216 ; - call outer ; - - ld d,8 ; - ld e,31 ; - call outer ; - - ld d,11 ; - ld e,4 ; - call outer ; - - ld d,12 ; - ld e,4 ; - call outer ; - - ret - - .outer ld bc,ayctrl ; select control port - out (c),d ; send specified value - ld bc,aydata ; select data port - out (c),e ; send specified value - ret - - __endasm; -} - // reversed order digit extract void print_points() { utoa(points, chars, 10); @@ -66,6 +24,5 @@ void print_points() { sp1_PrintAtInv(0, 26 + idx + col, INK_CYAN | PAPER_BLACK, chars[idx]); ++idx; } - make_sound(); } \ No newline at end of file diff --git a/int.c b/int.c index 757dd76..2f36f12 100644 --- a/int.c +++ b/int.c @@ -4,7 +4,7 @@ #include #include #include "int.h" - +#include "ay/ayfx.h" // timer unsigned char tick; @@ -14,7 +14,7 @@ IM2_DEFINE_ISR(isr) { // update the clock ++tick; - + mfx_playe(); } void diff --git a/logic.c b/logic.c index fb184ba..aa3a4e7 100644 --- a/logic.c +++ b/logic.c @@ -100,7 +100,7 @@ uint8_t goto_xy(struct sprite * for_who, uint8_t x, uint8_t y) { struct sprite * has_collision() { for(idx = 0; idx != 4; ++idx) { - if(abs(pacman.x - ghosts[idx]->x) < 1 && abs(pacman.y - ghosts[idx]->y) < 1) { + if(abs(pacman.x - ghosts[idx]->x) < 2 && abs(pacman.y - ghosts[idx]->y) < 2) { // eat return ghosts[idx]; } diff --git a/msnampac.c b/msnampac.c index 79b9ee6..54bfd8e 100644 --- a/msnampac.c +++ b/msnampac.c @@ -14,6 +14,7 @@ #include "int.h" #include "game_zx.h" +#include "ay/ayfx.h" @@ -104,6 +105,7 @@ void all_lives_lost() { int main() { + FXINIT(); setup_int(); // show paging capabilities. diff --git a/zproject.lst b/zproject.lst index 2a44fbd..752c01b 100644 --- a/zproject.lst +++ b/zproject.lst @@ -1,4 +1,5 @@ @build/binaries.lst +@ay/ay.lst afxplay game_zx.c logic.c From 95394a5add8caa2a0daa3d8158d57ca57fbd6444 Mon Sep 17 00:00:00 2001 From: jordism Date: Fri, 3 May 2019 23:59:17 +0200 Subject: [PATCH 4/8] switch to asm --- .DS_Store | Bin 10244 -> 10244 bytes ay/ay.lst | 1 - ay/ayfx.asm | 29 ------------- ay/ayfx.h | 18 -------- ay/mfx.asm | 2 +- int.asm | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++ int.c | 27 +----------- int.h | 1 + msnampac | Bin 0 -> 162 bytes msnampac.c | 5 +-- zproject.lst | 2 +- 11 files changed, 123 insertions(+), 79 deletions(-) delete mode 100644 ay/ayfx.asm delete mode 100644 ay/ayfx.h create mode 100644 int.asm create mode 100644 msnampac diff --git a/.DS_Store b/.DS_Store index 79fe1b9bc76e6c3f49f2a13802ae1f321ee42378..5b0de25b16f460b05f2fd691f405b145a4f1c179 100644 GIT binary patch delta 21 ZcmZn(XbITxS&Y$S^B1xI{9sCe5ddY42xR~O delta 21 ZcmZn(XbITxS&Y$i^B1xI{9sCe5ddYN2xkBQ diff --git a/ay/ay.lst b/ay/ay.lst index 6681372..aed72da 100644 --- a/ay/ay.lst +++ b/ay/ay.lst @@ -1,2 +1 @@ -ayfx mfx diff --git a/ay/ayfx.asm b/ay/ayfx.asm deleted file mode 100644 index dbcc7a3..0000000 --- a/ay/ayfx.asm +++ /dev/null @@ -1,29 +0,0 @@ -SECTION rodata_user - -PUBLIC mfx_add -PUBLIC _mfx_playe -PUBLIC mfx_mfxptr -PUBLIC _FXINIT - -defc mfx_init = _FXINIT -defc mfx_add = MFXADD -defc _mfx_playe = MFXPLAYE -defc mfx_mfxptr = mfxPtr - -INCLUDE "mfx.asm" - - -PUBLIC _ay_fx_click -PUBLIC _ay_fx_wowow - - -_ay_fx_click: - BINARY "fx/click.afx" -_ay_fx_wowow: - BINARY "fx/wowow.afx" - -_FXINIT: - call MFXINIT - ld hl, _ay_fx_wowow ; MSB = 0 means no effect - call MFXADD - ret diff --git a/ay/ayfx.h b/ay/ayfx.h deleted file mode 100644 index d8dd3c6..0000000 --- a/ay/ayfx.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef GAME_AY_H -#define GAME_AY_H - -// Bit Flags Returned from ay_is_playing() - -#define AY_PLAYING_NONE 0 -#define AY_PLAYING_SONG 1 -#define AY_PLAYING_FX 2 - -extern unsigned char ay_is_playing(void) __preserves_regs(d,e); - -// AY Effects Player - -extern void mfx_playe() __preserves_regs(a,b,c) __z88dk_callee; -extern void FXINIT() __preserves_regs(a,b,c) __z88dk_callee; - - -#endif diff --git a/ay/mfx.asm b/ay/mfx.asm index d117dad..ce55336 100644 --- a/ay/mfx.asm +++ b/ay/mfx.asm @@ -36,7 +36,7 @@ ; Values are 0 for channel A, 1 for channel B, 2 for channel C ; Default: 1 -defc mfxAyChannel = 2 +defc mfxAyChannel = 1 diff --git a/int.asm b/int.asm new file mode 100644 index 0000000..4c61cfb --- /dev/null +++ b/int.asm @@ -0,0 +1,117 @@ +INCLUDE "ay/mfx.asm" + +EXTERN _tick + +;;;;;;;;;;;;;;;;;;;;;; +; void setup_int(void) +;;;;;;;;;;;;;;;;;;;;;; + +SECTION code_user + +_ay_fx_wowow: + BINARY "ay/fx/wowow.afx" + +PUBLIC _enable_wowow + +_enable_wowow: + call MFXINIT ; this crashes + ld hl, _ay_fx_wowow + call MFXADD + ret + +PUBLIC _setup_int + +_setup_int: + + ; im2 table @ 0xd000 + + ld hl,0xd000 + ld de,0xd001 + ld bc,256 + + ld (hl),0xd1 + ldir + + ; jump to isr + + ld a,0xc3 + ld (0xd1d1),a + + ld hl,isr + ld (0xd1d2),hl + + ; I register + + ld a,0xd0 + ld i,a + + im 2 + ei + + ret + +;;;;;;;;;;;;;;;;;;; +; interrupt routine +;;;;;;;;;;;;;;;;;;; + +SECTION code_crt_common ;; place very low in memory, out of top 16k + +PUBLIC isr +PUBLIC isr_skip + + + +isr: + + push af + push bc + push de + push hl + exx + ex af,af' + push af + push bc + push de + push hl + push ix + push iy + + ; update clock + + ld a,(_tick) + inc a + ld (_tick),a + + + +isr_skip: + + ; music + + ld a,0x80 + ld i,a ; point I at uncontended bank + + ld a,h + or l + + call MFXPLAYE + + + ld a,0xd0 + ld i,a ; restore I + + pop iy + pop ix + pop hl + pop de + pop bc + pop af + ex af,af' + exx + pop hl + pop de + pop bc + pop af + + ei + reti diff --git a/int.c b/int.c index 2f36f12..bad0acc 100644 --- a/int.c +++ b/int.c @@ -1,22 +1,11 @@ -#include -#include -#include -#include #include #include "int.h" -#include "ay/ayfx.h" -// timer +#include +#include unsigned char tick; unsigned char timer; -IM2_DEFINE_ISR(isr) -{ - // update the clock - ++tick; - mfx_playe(); -} - void wait(void) { @@ -25,15 +14,3 @@ wait(void) timer = tick; } - -void -setup_int(void) -{ - im2_init((void *)0xd000); // CRT_ORG = 25124 - memset((void *)0xd000, 0xd1, 257); - - z80_bpoke(0xd1d1, 0xc3); - z80_wpoke(0xd1d2, (unsigned int)isr); - - intrinsic_ei(); -} diff --git a/int.h b/int.h index a2450d0..66b044c 100644 --- a/int.h +++ b/int.h @@ -23,5 +23,6 @@ extern unsigned char tick; extern void wait(void); extern void setup_int(void); +extern void enable_wowow(void); #endif diff --git a/msnampac b/msnampac new file mode 100644 index 0000000000000000000000000000000000000000..d822abb98b1def28376b53dc37b5cd36bb8f3ff6 GIT binary patch literal 162 zcmZ3VpRQEGV3fyTWXK@LC(HQv|Jz8m{ckH3zMNDtU^sbEk%57Y{i(p;t9KQd817mE zxi#B0-0Pn4-!11{r+hkJgI%zM;q8LA3r?47a0})!oX&f@K!Zt*0jN3tTQ+e1U+9$aGzXZ$ML?@evZ!4YOW;)pbseil* OZ|^=mU31`V;z Date: Sat, 4 May 2019 00:25:39 +0200 Subject: [PATCH 5/8] now sounds --- int.asm | 4 ++-- msnampac | Bin 162 -> 0 bytes msnampac.c | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) delete mode 100644 msnampac diff --git a/int.asm b/int.asm index 4c61cfb..7f827c1 100644 --- a/int.asm +++ b/int.asm @@ -1,5 +1,3 @@ -INCLUDE "ay/mfx.asm" - EXTERN _tick ;;;;;;;;;;;;;;;;;;;;;; @@ -8,6 +6,8 @@ EXTERN _tick SECTION code_user +INCLUDE "ay/mfx.asm" + _ay_fx_wowow: BINARY "ay/fx/wowow.afx" diff --git a/msnampac b/msnampac deleted file mode 100644 index d822abb98b1def28376b53dc37b5cd36bb8f3ff6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 162 zcmZ3VpRQEGV3fyTWXK@LC(HQv|Jz8m{ckH3zMNDtU^sbEk%57Y{i(p;t9KQd817mE zxi#B0-0Pn4-!11{r+hkJgI%zM;q8LA3r?47a0})!oX&f@K!Zt*0jN3tTQ+e1U+9$aGzXZ$ML?@evZ!4YOW;)pbseil* OZ|^=mU31`V;z Date: Sun, 5 May 2019 23:20:16 +0200 Subject: [PATCH 6/8] well some sound --- .DS_Store | Bin 10244 -> 10244 bytes ay/ay.lst | 2 +- int.asm | 39 ++++++++++++++++++++++++++------------- int.c | 3 +++ int.h | 2 +- logic.c | 3 ++- msnampac.c | 6 ++---- 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/.DS_Store b/.DS_Store index 5b0de25b16f460b05f2fd691f405b145a4f1c179..e3df39e9a73cc7194aa19c350d549133680c95d4 100644 GIT binary patch delta 767 zcma*lT}V@59LMqhuQbl_=z4tHnP-z3!_7=|Ybq*C$24*-Y}q6z)MlPwwC3p8z#By7d{j-EqgJU+ zU=eXgMm?Y<##82ypZw7l%xY=Mf39Giv69PN@)NK5%RmBElb1r&N5hn+Nt&Tqnxosa zNO$NFJ)^gjqhd2-Aj1X)cGSU#jqsxjy$BftPrN*La6ze8vy`eN{jAbsE0zfB064 zV$PCBEw8Aw$~Cq1jsCVkNdKS=a^4nuN7n6eN(^jK5SMIKihYB}>13+}!Pqo;d0Wlx z&DPu^IawiRHfwu_B(Va14`%J`;&lxdH*0q_uOy0sE4Y$&_OJX(*iY#Ved5r+=r;;E zav2A%fg25IMJIyjMh`ZjA5jcoJ7O5Z2;vwugj0s_Bo5;UrnvJ-oWg0G!C73uMO=dY iGOl2rb6+>O7jYN&a32rw7|(B=aO8^q`z06TU-BQ+ldE3< delta 745 zcmb8tPe{{Y9LMqRXO;YZ`8Xfb_Fv{0DwA}!jhvA+&D5!-=|(}3+uZLkTw6J_u>UlW zC{I5sDGy#Eas@%A1)Yj674&Zx6AHp>f1obWrKkPq)IoY~&-eZC9A130{n`F|5u?mX zES+6J1M5-UWjob5qu)Ek`LT>Lpd_PXiE*VpI;LdyCx+9h!Ni2ZA?Nf)o1?nU?Q3pn z%a`)94XlEx22&7BjhGtySgpk+^QaWci04}0#2RFtkwYViRJ<^;Y-V1G$K`M`8dH+m zXbba8yhq+Qu8d|9>6A7UKYug@bg^00VK$zXoq7{CD>#32kJj>Aad z2#(@7&fz>RAdAazUcpsd!z^xN4tH=DkMRtz@EULM7Ry+{XM9nY&3go?y`!_sz`FmE zdR8G_(*JQRuh?iXR#m&|Jx$wM)en}i5cOHN4j0$h8Gj(jd6U^x8RT{mqQ=wE|wNE!#yc62w|XsrVFy~#j$Pf`q-|;azw27Hif!&U=z+91 diff --git a/ay/ay.lst b/ay/ay.lst index aed72da..8b13789 100644 --- a/ay/ay.lst +++ b/ay/ay.lst @@ -1 +1 @@ -mfx + diff --git a/int.asm b/int.asm index 7f827c1..58b66eb 100644 --- a/int.asm +++ b/int.asm @@ -1,4 +1,5 @@ EXTERN _tick +EXTERN _pick ;;;;;;;;;;;;;;;;;;;;;; ; void setup_int(void) @@ -6,18 +7,6 @@ EXTERN _tick SECTION code_user -INCLUDE "ay/mfx.asm" - -_ay_fx_wowow: - BINARY "ay/fx/wowow.afx" - -PUBLIC _enable_wowow - -_enable_wowow: - call MFXINIT ; this crashes - ld hl, _ay_fx_wowow - call MFXADD - ret PUBLIC _setup_int @@ -94,9 +83,16 @@ isr_skip: ld a,h or l - call MFXPLAYE + ; FX + ld a,(_pick) + or a + JR Z, it_was_zero ; skip if it reaches zero + dec a ; else decrement + ld (_pick),a + call zap +it_was_zero: ld a,0xd0 ld i,a ; restore I @@ -115,3 +111,20 @@ isr_skip: ei reti + +zap: + ld d,16 ;speaker = bit 4 + ld e,0 ;distance between speaker move counter + ld b, 2 ;overall length counter +blp0: ld a,d + and 248 ;keep border colour the same + out (254),a ;move the speaker in or out depending on bit 4 + cpl ;toggle, so we alternative between speaker in and out to make sound + ld d,a ;store it + ld c,e ;now a pause +blp1: dec c + jr nz,blp1 + inc e ;change to inc e to reverse the sound, or remove to make it a note + djnz blp0 ;repeat B=255 times + ret + ; diff --git a/int.c b/int.c index bad0acc..177cff7 100644 --- a/int.c +++ b/int.c @@ -5,6 +5,9 @@ unsigned char tick; unsigned char timer; +unsigned char pick; + + void wait(void) diff --git a/int.h b/int.h index 66b044c..f518460 100644 --- a/int.h +++ b/int.h @@ -20,9 +20,9 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEAL #define clock(x) (tick) extern unsigned char tick; +extern unsigned char pick; extern void wait(void); extern void setup_int(void); -extern void enable_wowow(void); #endif diff --git a/logic.c b/logic.c index f3e4338..81ce399 100644 --- a/logic.c +++ b/logic.c @@ -1,5 +1,5 @@ #include "logic.h" - +#include "int.h" void check_keys() @@ -261,6 +261,7 @@ void check_fsm() { sp1_PrintAtInv(row, col, INK_BLACK, ' '); if(current == 9) { + pick += 1; points += 10; // ten points each } else if(current == 11) { points += 50; // energizers - are worth 50 points each diff --git a/msnampac.c b/msnampac.c index 5f1f0e7..e4f4774 100644 --- a/msnampac.c +++ b/msnampac.c @@ -97,6 +97,8 @@ void all_lives_lost() { } } srand(tick); + pick = 1; + } @@ -104,10 +106,6 @@ int main() { setup_int(); - intrinsic_di(); - enable_wowow(); - intrinsic_ei(); - // now sp1 sp1_Initialize( SP1_IFLAG_MAKE_ROTTBL | SP1_IFLAG_OVERWRITE_TILES | SP1_IFLAG_OVERWRITE_DFILE, INK_BLACK | PAPER_BLACK, From 9da49b392b565ec222686800ea5f06712ef43cdb Mon Sep 17 00:00:00 2001 From: jordism Date: Tue, 7 May 2019 23:18:54 +0200 Subject: [PATCH 7/8] use beepfx instead --- .DS_Store | Bin 10244 -> 8196 bytes afxplay.asm | 0 ay/ay.lst | 1 - ay/fx/click.afx | 1 - ay/fx/wowow.afx | Bin 68 -> 0 bytes ay/fx/wowow2.afx | Bin 66 -> 0 bytes ay/mfx.asm | 171 ---------------------------------------- fx/BeepFX.asm | 197 +++++++++++++++++++++++++++++++++++++++++++++++ fx/fx.lst | 1 + int.asm | 21 +---- zproject.lst | 2 +- 11 files changed, 202 insertions(+), 192 deletions(-) delete mode 100644 afxplay.asm delete mode 100644 ay/ay.lst delete mode 100644 ay/fx/click.afx delete mode 100644 ay/fx/wowow.afx delete mode 100644 ay/fx/wowow2.afx delete mode 100644 ay/mfx.asm create mode 100644 fx/BeepFX.asm create mode 100644 fx/fx.lst diff --git a/.DS_Store b/.DS_Store index e3df39e9a73cc7194aa19c350d549133680c95d4..4c33a03fb20063eccea3e1951e245e2aec11dae2 100644 GIT binary patch delta 118 zcmZn(XmOBWU|?W$DortDU;r^WfEYvza8E20o2aKK%mR`J@);OXlFEwRq`O5Tpm*0Uo7A1r8{rF~uGT6b$aMD{Q>m`?Gr> zMZBsQHEC6HMiYsNF-8;77}DT_iK%ZIV^WPxL?3)H)dwH^n;7GR&fXrC7>x<(B)h-) z{eCmEzuC`sX0>N^L?VQsFQWtr@$oL@k7Y&YTB>TT^>C$=JK#Qv#u8E9|2UeAX`87R zO4rVpUn-@=G;ED<5Sc7R7meiZQHB`^d;v#Maml_?N*QJ4?7ql+VliUMX2$4~(^Hl= zBAfHMQL+D6L{rqLoTgNu!i-q6yc}%r^84C?ffc`RIT#3r{JxI%(8`KHs~duM4BsDL zI=B4r$|Eo3u86gR>pMln=7N#gL_Ep;ot7^yW-Ns5;v8vf3s!O4JH-jCOd52ZWVw{P zGS}s5%}$u=LuN!fr=B$uX)~ONW#amTHk;6`*o-J<4E2l}lTB?w?Uzl}5Fu?@2ec2Q)Q3wx}uQ{G@Ems=A`-bK?t|p+#frs4mA<7p@6H zepXerBu!*9Q7x6x%q6jo(yQYBigMtG=&HlGs47u2+&C3HL5 z#ZFKc{K5qPwQ;^9!w%mm_2f1WxU<%F`#h2~X;smyD5^p!t?OyB3Dorj?2f?YRYO`y z4;doUL?ubGL@tnL$g^afyhh$3TjVnNkbFX}kWa~H|-59_ihA@oNn7|~aFbxH9=tv=rWvt=}Jc+09B3{9p*uYzO z8}H(>U73SRJl}>3wqWo9@9gNOAa2L_KlQ@}%gVe1?!oH<8r*|`zI58ExyfC5sIKv7 z;P&Hp<<{M&DOW_z!JC;k_p|$!tmV}Dyk3!tA8~0|u2An~Tp2>%X{zTrMX z0y`IMV_va@^S0-OIvEp-xghN9iEf_VC!XTjnrf+v^|G*F$xZ<*Q_ayvH$q zPPWO{9O3sI-|ys4l%N9DsDTGw96}>*#Zmatf)I|O3&#=8^E-(VoWUr@a4%*cW0o^i zIm0ApXu!;31z9|b$M85V;3A&G8gh6ZFXMHa*maOY1%d^GH+DeA6aD>4#+)T&`v>Fc zw#vWb%D={w^SdsTYJ0i7A{HWPJ(ketcnFuA;vc1(=ii5`$R6P<<95KhM>kWy73C^C r_qZMQ?V3LnTyFU@kxP0mX7k|oLgU83$nKfOje#+;XBz(vV+(%)3u%9@ diff --git a/afxplay.asm b/afxplay.asm deleted file mode 100644 index e69de29..0000000 diff --git a/ay/ay.lst b/ay/ay.lst deleted file mode 100644 index 8b13789..0000000 --- a/ay/ay.lst +++ /dev/null @@ -1 +0,0 @@ - diff --git a/ay/fx/click.afx b/ay/fx/click.afx deleted file mode 100644 index cb573c7..0000000 --- a/ay/fx/click.afx +++ /dev/null @@ -1 +0,0 @@ -eüHÐ \ No newline at end of file diff --git a/ay/fx/wowow.afx b/ay/fx/wowow.afx deleted file mode 100644 index e30064e19948fe414eece49fe1b546bd377b4238..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 68 zcmaE$!pyM1k!is^#s!ZU7Mx^g0DOe{;en4Z01WL|cXarp+u<gj`;|g!a6*i13 Vj2K@;GqJoVVC8zzz|Ma`0RV7u6rBJ7 diff --git a/ay/mfx.asm b/ay/mfx.asm deleted file mode 100644 index ce55336..0000000 --- a/ay/mfx.asm +++ /dev/null @@ -1,171 +0,0 @@ -; modified for z88dk/z80asm and Gandalf - -; mFX Player v0.1 -; by Intense in 2017 -; -; A sound effect player intended for simultaneous AY music+fx. -; Uses sound effects authored with Shiru's AyFxEdit. -; Uses a single redefinable AY channel for playback. -; If a new sound effect is added while another one is -; playing, the latter is interrupted and discarded. -; -; WARNING: This program expects the stack to contain -; AY register data. It should preferrably be used alongside -; the included mFX edition of the Vortex Tracker II player, -; or another AY music player that supports this mechanism. -; Do not call MFXPLAYM without a preceding call to the music -; player in case you want to play an effect on its own! -; Use the entry point MFXPLAYE for this instead. -; -; Init: -; call MFXINIT -; -; Adding a new effect: -; ld hl,EffectAddress ; MSB = 0 means no effect -; call MFXADD -; -; Once per frame (Vortex Tracker II example): -; ld hl,VT2PLAYER+10 ;setup byte in the VTII player (SETUP) -; set 1,(hl) ;enable stack output for AY reg data -; call VT2PLAYER+5 ;process VTII frame, SP=SP-14 at exit (PLAY) -; call MFXPLAYM ;process fx and OUTput to AY, SP=SP+14 - - - -; AY channel to use for playing back the sound effects -; Values are 0 for channel A, 1 for channel B, 2 for channel C -; Default: 1 - -defc mfxAyChannel = 1 - - - -; Initializes the player. -; Mutes the AY and sets up the variables. -; - -MFXINIT: - xor a - ld l,a - ld h,a - ld (mfxTone+1),hl ;zero tone and noise values - ld (mfxNoise+3),a - ld (mfxPtr+2),a ;set no sound effect - ld e,14 -mfxInit0: - dec e ;zero AY channels 0~13 - ld bc,0xFFFD - out (c),e - ld b,0xBF - out (c),a - jr nz,mfxInit0 - ret - - - -; Sets a new sound effect to play. -; If another effect was playing at the time, it is discarded. -; -; Input: HL = effect address MSB=0 for none - -MFXADD: - ld (mfxPtr+1),hl ;save it to mfxPtr and exit - ret - - - -; A secondary entry point used to play back the effects without the music. -; -; Input: None -MFXPLAYE: - pop de ;get the return address in DE - ld hl,0 ;PUSH 14 zero values into the stack - ld b,7 -mfxPlayE0: - push hl - djnz mfxPlayE0 - push de - - -; Main effect playback routine. Must be called each interrupt -; after a call to a mFX compatible music player. -; Expects AY register data (14 bytes) on the stack. At exit, -; SP will increment by 14 not counting the return address. -; -; Input: (SP) = return address followed by AY register data - -MFXPLAYM: - ld ix,2 ;IX = SP+2 - add ix,sp -mfxPtr: - ld hl,0 - ld a,h - or a ;if the effect pointer MSB is 0, that means no sound effect is set - jr z,MFXOUT ;in that case, just OUTput the music player AY frame and exit - - ld a,(hl) ;fetch the frame descriptor byte - and 0x0F ;leave only the volume nibble - ld (ix+8+mfxAyChannel),a;store the volume into the AY buffer - xor (hl) ;leave the mixer bits (upper) nibble - inc hl - bit 5,a ;is there a change to the tone pitch? - jr z,mfxPlayM0 ;if not, skip this part - ld de,mfxTone+1 - ldi ;store the new mFX tone pitch - ldi -mfxPlayM0: - bit 6,a ;is there a change to the noise pitch? - jr z,mfxPlayM1 ;if not, skip this part - ld de,mfxNoise+3 - bit 5,(hl) ;is the effect over yet? - ldi ;store the new mFX noise pitch - jr z,mfxPlayM1 - ld h,0 ;if end of effect, set effect ptr MSB to 0 (no playback) -mfxPlayM1: - ld (mfxPtr+1),hl ;save the effect pointer - ld e,a - or 0x6F-(1<<(mfxAyChannel^3)) -mfxPlayM2: - rrca ;rotate the mixer bits in the descriptor as needed - jr c,mfxPlayM2 ;based on the AY channel number - and (ix+7) ;combine it with the mixer value from the music player - ld (ix+7),a ;save the resulting final mixer value into the AY buffer - bit 7,e ;test whether the current mFX effect frame has noise enabled - jr nz,mfxPlayM3 -mfxNoise: - ld (ix+6),0 ;if it does, overwrite the noise pitch register data from the music player -mfxPlayM3: - bit 4,e ;test whether the current mFX effect frame has tone enabled - jr nz,mfxPlayM4 -mfxTone: - ld hl,0 ;if it does, overwrite the tone pitch register data from the music player - ld (ix+mfxAyChannel*2),l - ld (ix+mfxAyChannel*2+1),h -mfxPlayM4: - xor a - -MFXOUT: - pop ix ;IX = return address - ld bc,0xFFFD ;output the resulting AY register data for this frame and restore SP - ld de,0xFFBF - jr mfxOut0 -mfxOut1: - out (c),h - ld b,d - inc a -mfxOut0: - pop hl - out (c),a - ld b,e - out (c),l - ld b,d - inc a - out (c),a - ld b,e - cp 13 - jr nz,mfxOut1 - push ix - bit 7,h ;the envelope shape register (R13) should only be modified when it has changed - ret nz ;this should be indicated by BIT 7 reset in the music player AY data output - out (c),h - ret diff --git a/fx/BeepFX.asm b/fx/BeepFX.asm new file mode 100644 index 0000000..22e6fb5 --- /dev/null +++ b/fx/BeepFX.asm @@ -0,0 +1,197 @@ +;BeepFX player by Shiru +;You are free to do whatever you want with this code +SECTION code_user + +PUBLIC _playBasic + + +_playBasic: + ld a,0 +play: + ld hl,sfxData ;address of sound effects data + + di + push ix + push iy + + ld b,0 + ld c,a + add hl,bc + add hl,bc + ld e,(hl) + inc hl + ld d,(hl) + push de + pop ix ;put it into ix + + ld a,(23624) ;get border color from BASIC vars to keep it unchanged + rra + rra + rra + and 7 + ld (sfxRoutineToneBorder +1),a + ld (sfxRoutineNoiseBorder +1),a + ld (sfxRoutineSampleBorder+1),a + + +readData: + ld a,(ix+0) ;read block type + ld c,(ix+1) ;read duration 1 + ld b,(ix+2) + ld e,(ix+3) ;read duration 2 + ld d,(ix+4) + push de + pop iy + + dec a + jr z,sfxRoutineTone + dec a + jr z,sfxRoutineNoise + dec a + jr z,sfxRoutineSample + pop iy + pop ix + ei + ret + + + +;play sample + +sfxRoutineSample: + ex de,hl +sfxRS0: + ld e,8 + ld d,(hl) + inc hl +sfxRS1: + ld a,(ix+5) +sfxRS2: + dec a + jr nz,sfxRS2 + rl d + sbc a,a + and 16 +sfxRoutineSampleBorder: + or 0 + out (254),a + dec e + jr nz,sfxRS1 + dec bc + ld a,b + or c + jr nz,sfxRS0 + + ld c,6 + +nextData: + add ix,bc ;skip to the next block + jr readData + + + +;generate tone with many parameters + +sfxRoutineTone: + ld e,(ix+5) ;freq + ld d,(ix+6) + ld a,(ix+9) ;duty + ld (sfxRoutineToneDuty+1),a + ld hl,0 + +sfxRT0: + push bc + push iy + pop bc +sfxRT1: + add hl,de + ld a,h +sfxRoutineToneDuty: + cp 0 + sbc a,a + and 16 +sfxRoutineToneBorder: + or 0 + out (254),a + + dec bc + ld a,b + or c + jr nz,sfxRT1 + + ld a,(sfxRoutineToneDuty+1) ;duty change + add a,(ix+10) + ld (sfxRoutineToneDuty+1),a + + ld c,(ix+7) ;slide + ld b,(ix+8) + ex de,hl + add hl,bc + ex de,hl + + pop bc + dec bc + ld a,b + or c + jr nz,sfxRT0 + + ld c,11 + jr nextData + + + +;generate noise with two parameters + +sfxRoutineNoise: + ld e,(ix+5) ;pitch + + ld d,1 + ld h,d + ld l,d +sfxRN0: + push bc + push iy + pop bc +sfxRN1: + ld a,(hl) + and 16 +sfxRoutineNoiseBorder: + or 0 + and 248 ;keep border colour the same + out (254),a + dec d + jr nz,sfxRN2 + ld d,e + inc hl + ld a,h + and 31 + ld h,a +sfxRN2: + dec bc + ld a,b + or c + jr nz,sfxRN1 + + ld a,e + add a,(ix+6) ;slide + ld e,a + + pop bc + dec bc + ld a,b + or c + jr nz,sfxRN0 + + ld c,7 + jr nextData + + +sfxData: + +SoundEffectsData: + defw SoundEffect0Data + +SoundEffect0Data: + defb 2 ;noise + defw 2,1,512 + defb 0 diff --git a/fx/fx.lst b/fx/fx.lst new file mode 100644 index 0000000..59dd5b9 --- /dev/null +++ b/fx/fx.lst @@ -0,0 +1 @@ +BeepFX diff --git a/int.asm b/int.asm index 58b66eb..c4a3748 100644 --- a/int.asm +++ b/int.asm @@ -1,5 +1,6 @@ EXTERN _tick EXTERN _pick +EXTERN _playBasic ;;;;;;;;;;;;;;;;;;;;;; ; void setup_int(void) @@ -90,7 +91,8 @@ isr_skip: dec a ; else decrement ld (_pick),a - call zap + ;call zap + call _playBasic it_was_zero: ld a,0xd0 @@ -111,20 +113,3 @@ it_was_zero: ei reti - -zap: - ld d,16 ;speaker = bit 4 - ld e,0 ;distance between speaker move counter - ld b, 2 ;overall length counter -blp0: ld a,d - and 248 ;keep border colour the same - out (254),a ;move the speaker in or out depending on bit 4 - cpl ;toggle, so we alternative between speaker in and out to make sound - ld d,a ;store it - ld c,e ;now a pause -blp1: dec c - jr nz,blp1 - inc e ;change to inc e to reverse the sound, or remove to make it a note - djnz blp0 ;repeat B=255 times - ret - ; diff --git a/zproject.lst b/zproject.lst index 11ed06b..1fb3cd5 100644 --- a/zproject.lst +++ b/zproject.lst @@ -1,5 +1,5 @@ @build/binaries.lst -afxplay +@fx/fx.lst game_zx.c logic.c sprites.c From a639a5a617f640df798fbdf41178eb98ba851f2d Mon Sep 17 00:00:00 2001 From: jordism Date: Tue, 7 May 2019 23:21:05 +0200 Subject: [PATCH 8/8] use ms nampac sounds --- int.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/int.asm b/int.asm index c4a3748..935cc8c 100644 --- a/int.asm +++ b/int.asm @@ -91,7 +91,7 @@ isr_skip: dec a ; else decrement ld (_pick),a - ;call zap + ; https://www.sounds-resource.com/nes/mspacmannamco/sound/5206/ call _playBasic it_was_zero: