eruonna [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=10210 Pool <p> <table><tr><td> <a href="/bbs/?pid=13351#p"> <img src="/bbs/thumbs/pico13375.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=13351#p"> Pool 0.9</a><br><br> by <a href="/bbs/?uid=10210"> eruonna</a> <br><br><br> <a href="/bbs/?pid=13351#p"> [Click to Play]</a> </td></tr></table> </p> <p>Working on a pool game. Also includes <a href="http://www.bbc.com/news/magazine-34015430">Loop</a>.</p> <p>Added zoomed out mode to pool. Press button 2 to toggle zoom. Also added a check so that any ball that makes it outside the bounds of the table is considered to have gone in a pocket (because I think the most likely way to achieve that is by bouncing through a pocket in some strange way).</p> <p> <table><tr><td> <a href="/bbs/?pid=13351#p"> <img src="/bbs/thumbs/pico13350.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=13351#p"> Pool 0.8</a><br><br> by <a href="/bbs/?uid=10210"> eruonna</a> <br><br><br> <a href="/bbs/?pid=13351#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=2374 https://www.lexaloffle.com/bbs/?tid=2374 Sun, 30 Aug 2015 19:59:19 UTC Data structures for sfx and music <p>I didn't see this documented anywhere, and I had to work it out for my drumbeat cart, so I thought I'd save everyone else the trouble and publish what I know.</p> <p><strong>SFX:</strong></p> <p>A sound effect is stored in 68 bytes. Sfx 0 starts at address 0x3200, sfx 1 at address 0x3244, and so on.</p> <p>The first 64 bytes (offset 0..63) store the 32 notes of the sound effect as described below.</p> <p>Offset 64 is a byte that determines the editor mode: 0 for graph mode, nonzero for tracker mode. This has no effect on playback, just on the mode opened in the editor by default.</p> <p>Offset 65 stores the playback speed. (Higher values correspond to slower playback, so &quot;speed&quot; isn't exactly the right name, but that is what is used in the editor.)</p> <p>Offsets 66 and 67 store the loop begin and loop end times. A sound effect contains only 32 notes, but these times may be set to any byte value. All times past 32 simply play silence.</p> <p><strong>Note format:</strong></p> <p>A note is stored in 16 bits, two bytes little-endian.</p> <p>Bits 0..5 store the pitch, ranging from 0 (C in octave 0) to 63 (D# in octave 5). The tracker mode editor can only enter pitches up to 60 (C 5), but it can display and play higher pitches.</p> <p>Bits 6..8 store the instrument; the values are the same as in the tracker mode editor.</p> <p>Bits 9..11 store the volume. Volume 0 corresponds to silence.</p> <p>Bits 12..14 store the effect; the values are the same as in the tracker mode editor.</p> <p>Bit 15 appears to be unused.</p> <p><strong>Example code:</strong></p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre> -- This code is public domain, feel free to copy, use, and modify however you'd like function make_note(pitch, instr, vol, effect) return { pitch + 64*(inst%4) , 16*effect + 2*vol + flr(instr/4) } -- flr may be redundant when this is poke'd into memory end function get_note(sfx, time) local addr = 0x3200 + 68*sfx + 2*time return { peek(addr) , peek(addr + 1) } end function set_note(sfx, time, note) local addr = 0x3200 + 68*sfx + 2*time poke(addr, note[1]) poke(addr+1, note[2]) end function get_speed(sfx) return peek(0x3200 + 68*sfx + 65) end function set_speed(sfx, speed) poke(0x3200 + 68*sfx + 65, speed) end function get_loop_start(sfx) return peek(0x3200 + 68*sfx + 66) end function get_loop_end(sfx) return peek(0x3200 + 68*sfx + 67) end function set_loop(sfx, start, end) local addr = 0x3200 + 68*sfx poke(addr + 66, start) poke(addr + 67, end) end </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p><strong>Music format:</strong></p> <p>A music pattern consists of four channels, each of which may have a sound effect played on it, plus some playback control flags.</p> <p>The patterns are stored in four bytes, with pattern 0 at address 0x3100. Each byte describes one channel.</p> <p>Bits 0..5 are the sfx to be played on the channel.</p> <p>Bit 6 is mute. If it is 0, the channel is played; if it is 1, the channel is silenced.</p> <p>Bit 7 contains the playback control flags:<br /> Byte 0 bit 7 is the loop start flag<br /> Byte 1 bit 7 is the loop end flag<br /> Byte 2 bit 7 is the stop flag<br /> Byte 3 bit 7 is unused</p> <p>Playback control is as follows (I haven't tested all possibilities here):<br /> When a pattern reaches the end, if the stop flag is set on this pattern, playback stops.<br /> Otherwise, if the loop end flag is set on this pattern, move back until a pattern with the loop start flag set is found, and continue playback from there.<br /> Otherwise, continue playback with the next pattern.</p> https://www.lexaloffle.com/bbs/?tid=2341 https://www.lexaloffle.com/bbs/?tid=2341 Wed, 26 Aug 2015 18:29:10 UTC Random drumbeats <p> <table><tr><td> <a href="/bbs/?pid=12873#p"> <img src="/bbs/thumbs/pico12907.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=12873#p"> Random drumbeats 0.2</a><br><br> by <a href="/bbs/?uid=10210"> eruonna</a> <br><br><br> <a href="/bbs/?pid=12873#p"> [Click to Play]</a> </td></tr></table> </p> <p>Generate some random drum beats. Press Z for a new one. They are saved as sfx 0 on the cart, in case you get one you want to use somewhere else. Based on ideas from <a href="http://boodler.org/package/com.eblong.zarf.algomusic.snazz/">this</a>.</p> <p>I hope to add more complex and longer beats.</p> <p>Added a menu with some different generation algorithms. Mutating creates a beat that changes a little at regular intervals. Sometimes it uses some non-percussive sounds, which is a bug, but I have not been able to track down the cause.</p> <p> <table><tr><td> <a href="/bbs/?pid=12873#p"> <img src="/bbs/thumbs/pico12872.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=12873#p"> Random drumbeats 0.1</a><br><br> by <a href="/bbs/?uid=10210"> eruonna</a> <br><br><br> <a href="/bbs/?pid=12873#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=2295 https://www.lexaloffle.com/bbs/?tid=2295 Fri, 21 Aug 2015 21:08:10 UTC