#uselib "WINMM.DLL" #func global waveOutOpen "waveOutOpen" sptr,sptr,sptr,sptr,sptr,sptr #func global waveOutPrepareHeader "waveOutPrepareHeader" sptr,sptr,sptr #func global waveOutWrite "waveOutWrite" sptr,sptr,sptr #const BUFSZ 1024 #const BUFSZH BUFSZ/2 #const BUFSZ2 BUFSZ*2 #const BUFSZ3 BUFSZ*3 #const BUFSZ4 BUFSZ*4 #module #deffunc synth_init ddim hz,512 : hz = 220.0 * 3.14159265359 / 44100.0 repeat 512, 1 : hz(cnt) = hz(cnt-1) * 1.0594630943593 : loop ddim sqt, 64 return #defcfunc sq int note, int ch, int vol if vol * note < 1 : sqt.ch=0.0 : return 0 sqt.ch += hz.note if sqt.ch>88200.0 : sqt.ch -= 88200.0 t = sin(sqt.ch) : if ch = 0 : t = t * t return int( t * vol ) #global randomize dialog "フルスクリーンで動作させますか?", 2, "anonymouseq" : fs = stat=6 onexit *q wfex = 0x00010001, 11025, 22050, 0x00100002 waveOutOpen varptr(phwo), -1, varptr(wfex), 0, 0, 0 if stat : end synth_init sdim buf, BUFSZ4 dim whdr, 8, 4 whdr = varptr(buf), BUFSZ whdr(0,1) = whdr+BUFSZ , BUFSZ whdr(0,2) = whdr+BUFSZ2, BUFSZ whdr(0,3) = whdr+BUFSZ3, BUFSZ addr = varptr(whdr) repeat 4 waveOutPrepareHeader phwo, addr+cnt*32, 32 loop dim revbuf, 8192 if fs : bgscr 1, ginfo_dispx, ginfo_dispy, 0 title "anonymouseq" boxf gmode 5,,,256 ctbl = 255, 0, 180, 0, 150, 255, 0, 180, 0, 180, 0, 150 ntbl = 1, 1, 3, 3, 3, 6, 6, 8, 8, 8, 10, 10 dim bn, 3 dim seq, 16 : dim seqx, 16 : dim seqy, 16 : dim svol, 16 bbase = 1600 repeat : gc = 31 : gr = sin(0.3 * gc) redraw 0 : color : boxf obt = bt : stick bt, 256 x = mousex : y = mousey if bt & 8 : bbase -= ( bbase > 500 ) * 50 if bt & 2 : bbase += ( bbase < 3000 ) * 50 if bt & 256 : hc++ :else: hc = 0 if bt & 128 : end if ( bv < 0 ) { if seq.sp*svol.sp>0 { note = seq.sp : vol = svol.sp : svol.sp -= 500 x = seqx.sp : y = seqy.sp : type = rnd(7) : gosub *ADD_PTCL } sp = (sp+1) & 15 repeat 3 t = rnd( 40 ) + 10 bn.cnt = (t / 12) * 12 + ntbl.(t\12) loop bv = bbase } if hc > 10 { if (cnt & 3) = 0 { type = 7 : gosub *ADD_PTCL } } if ( (bt & 256) ! 0 ) & ( (obt & 256) = 0 ) { mnote = x * 48 / ginfo_winx + 24 mnote = (mnote / 12) * 12 + ntbl.(mnote\12) seq.sp = mnote : seqx.sp = x : seqy.sp = y : svol.sp = 8000 } gosub *PTCL hsvcolor ,,255 : pos 0,0 : mes "delay="+bbase redraw 1 waveOutWrite phwo, addr+iReadBuf*32, 32 if stat : await 1 : else : iReadBuf = (iReadBuf+1)&3 if iWriteBuf != iReadBuf : gosub *FILL await 0 loop stop *FILL ofs = iWriteBuf * BUFSZ repeat BUFSZH wv = sq(note, 0, vol) + sq(bn.0, 1, bv) + sq(bn.1, 2, bv) + 0.3 * revbuf.rn + 0.1 * revbuf.((rn-3000)&4095) + 0.2 * revbuf.((rn-1700)&4095) wpoke buf, ofs, wv revbuf.rn = wv rn = (rn + 1) & 4095 ofs += 2 : vol-- : bv-- loop iWriteBuf = (iWriteBuf+1)&3 tick++ return *q wait 30 end *ERASE_PTCL nPtcl-- pt.pn = pt.nPtcl px.pn = px.nPtcl py.pn = py.nPtcl pr.pn = pr.nPtcl prv.pn = prv.nPtcl ps.pn = ps.nPtcl psv.pn = psv.nPtcl pl.pn = pl.nPtcl return *PTCL v = 1 + (nPtcl/4) repeat nPtcl : pn = cnt pr.pn += prv.pn : prv.pn *= 0.95 ps.pn += psv.pn : psv.pn *= 0.95 color , pl.pn * 8, pl.pn * 4 t = pt.pn x = int(px.pn) : y = int(py.pn) on t gosub *T0, *T0, *T0, *T0, *T1, *T2, *T3, *TL pl.pn -= v : if pl.pn < 0 : gosub *ERASE_PTCL loop return *GS gsquare pl.pn*-8-1, gx, gy return *SS si = ps.pn * 2.0 so = si + w repeat corner+1 : t = cnt * 2 : r = 6.283185 * cnt / corner + pr.pn sr = sin(r) : cr = cos(r) nxi = int(sr * si + x) nyi = int(cr * si + y) nxo = int(sr * so + x) nyo = int(cr * so + y) gx.3 = gx.2 : gx = gx.1, nxo, nxi gy.3 = gy.2 : gy = gy.1, nyo, nyi if cnt : gosub *GS loop return *T0 s = sin(pr.pn) c = cos(pr.pn) sx = s * 1500 cx = c * 1500 sy = c * 20 cy = s * -20 gx = x - sx - sy, x + sx - sy, x + sx + sy, x - sx + sy gy = y - cx - cy, y + cx - cy, y + cx + cy, y - cx + cy gosub *GS return *T1 corner = 64 : w = 36 : gosub *SS return *T2 corner = 4 : w = 50 : gosub *SS return *T3 corner = 3 : w = 80 : gosub *SS return *TL color 0, pl.pn * 4, pl.pn * 2 : h = pl.pn/4 gp = 0, y-h, ginfo_winx, y+h gx = gp.0, gp.2, gp.2, gp.0 gy = gp.1, gp.1, gp.3, gp.3 gosub *GS return *ADD_PTCL r = 0.001 * rnd(6280) rv = 0.001 * ( rnd(100) - 50 ) sv = 0.001 * rnd(1000) : sv = sqrt(sv) * 16 if type < 4 : rv = 0.0 if type = 5 : rv = 0.2 : sv = 16.0 pt.nPtcl = type px.nPtcl = double( x ) py.nPtcl = double( y ) ps.nPtcl = 0 psv.nPtcl = sv pr.nPtcl = r prv.nPtcl = rv pl.nPtcl = 31 nPtcl++ return