Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
- Negative Charge
- Posts: 93
- Joined: Sat Jan 16, 2021 1:35 pm
- Contact:
Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
I’ve been experimenting with porting the 6502 SquatM 1-Bit Beeper Engine from the Atari 800/XL to the Electron.
In its early stages, and requires a Turbo Board (Slogger or equivalent) enabled for it to run at the required speed at the moment…. but it does work. Take a look here:
https://m.youtube.com/watch?v=5NdfpzJMO ... e=youtu.be
If you’re interested in the source, or have suggestions on how to reduce the cycle count (it’s very processor intensive!), take a look here: https://github.com/NegativeCharge/Acorn ... atM-Player
In its early stages, and requires a Turbo Board (Slogger or equivalent) enabled for it to run at the required speed at the moment…. but it does work. Take a look here:
https://m.youtube.com/watch?v=5NdfpzJMO ... e=youtu.be
If you’re interested in the source, or have suggestions on how to reduce the cycle count (it’s very processor intensive!), take a look here: https://github.com/NegativeCharge/Acorn ... atM-Player
Website: https://negativecharge.github.io/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
- Negative Charge
- Posts: 93
- Joined: Sat Jan 16, 2021 1:35 pm
- Contact:
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
If anyone’s interested, I’ve uploaded a version of the SquatM 1-Bit Beeper Engine for the BBC Micro here:
https://github.com/NegativeCharge/BBC-M ... atM-Player
Any help improving the performance of the CONSUL routine (named after the original Atari register) would be greatly appreciated. Alternating volumes really is the bottleneck in this engine.
https://github.com/NegativeCharge/BBC-M ... atM-Player
Any help improving the performance of the CONSUL routine (named after the original Atari register) would be greatly appreciated. Alternating volumes really is the bottleneck in this engine.
Website: https://negativecharge.github.io/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
- Negative Charge
- Posts: 93
- Joined: Sat Jan 16, 2021 1:35 pm
- Contact:
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
Here’s an example on the Acorn Electron with a Slogger Turbo Board enabled on the emulator.
It includes multi-channel tones, drums and sample playback using the ULA to create a toggle speaker.
Click on the image to watch:
It includes multi-channel tones, drums and sample playback using the ULA to create a toggle speaker.
Click on the image to watch:
Website: https://negativecharge.github.io/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
This is all fantastic work - I love how un-Beeb and un-Electron it all sounds.Negative Charge wrote: ↑Mon Nov 14, 2022 7:52 pm If anyone’s interested, I’ve uploaded a version of the SquatM 1-Bit Beeper Engine for the BBC Micro here:
https://github.com/NegativeCharge/BBC-M ... atM-Player
Any help improving the performance of the CONSUL routine (named after the original Atari register) would be greatly appreciated. Alternating volumes really is the bottleneck in this engine.
For optimising the Beeb CONSUL routine:
Code: Select all
.CONSOL
lsr a ;2
lsr a ;2
lsr a ;2
lsr a ;2 Only 4-bit volumes supported on tone channels 0, 1 and 2
ora #%10010000 ;2 bit-7 (latch/data), bits-6/5 (channel - 0), bit 4 (type - latch volume)
sta SYSVIA_ORAS ;4 Write reg/data to SN76489
lda #%00000000 ;2
sta SYSVIA_REGB ;4
; Sound write held low for 8us
; Seems to work at 6us, not 5us on an issue 3 beeb
nop ;2
nop ;2
nop ;2
nop ;2
lda #%00001000 ;2
sta SYSVIA_REGB ;4
rts ;6
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/
- Negative Charge
- Posts: 93
- Joined: Sat Jan 16, 2021 1:35 pm
- Contact:
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
Thanks Kieran. Very useful advice! I thought about in-lining the sound output code as this is clearly wasting 6 cycles for the JSR and another 6 for the RTS. This works in one location, but in the other I start running into the issue of branch distance being greater than 127 (I think by 5). I can certainly use a macro for the SN76489 write though as I duplicate that code.
I've managed to actually drop the 4 LSR A's, as they were only necessary as the outer loop was setting max volume to &FF for the Atari rather than &0F needed for the Beeb.
I've also managed to get some speed up simply by not outputting anything to screen and dropping a few PHA/PLA instances that were unnecessary. It's closer to the original playback speed now, but not quite.
Thanks!
I've managed to actually drop the 4 LSR A's, as they were only necessary as the outer loop was setting max volume to &FF for the Atari rather than &0F needed for the Beeb.
I've also managed to get some speed up simply by not outputting anything to screen and dropping a few PHA/PLA instances that were unnecessary. It's closer to the original playback speed now, but not quite.
Thanks!
Website: https://negativecharge.github.io/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
The Electron demos are out of this world, so impressed!
Please keep on doing what you're doing!
Please keep on doing what you're doing!
Please subscribe to the ABug YouTube channel!
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
That Elk demo is just every shade of awesome!
- Negative Charge
- Posts: 93
- Joined: Sat Jan 16, 2021 1:35 pm
- Contact:
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
Thanks I'm enjoying getting this working. I've always thought the Electron was capable of more in terms of audio, but it's only really the appearance of Shiru's 6502 port of a 1-Bit beeper engine to the Atari that made me look at this area again. I'd love to port more engines, but most are Z80-based, and my Z80 is even worse than my 6502
I'm hoping I can get the Electron version working at least to a level where the output is acceptable without requiring a turbo board, but instruction cycle optimisation isn't my strong point - I'm hoping the collective knowledge of the Stardot folk will be able to assist in that respect.
Website: https://negativecharge.github.io/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
- Negative Charge
- Posts: 93
- Joined: Sat Jan 16, 2021 1:35 pm
- Contact:
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
Thank you. I was pretty impressed the first time I got this working as you can imagine.
Website: https://negativecharge.github.io/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
You can use PHP, PLP for A7 cycle delay in two bytes saving a byte at the cost of a cycle or maybe two bytes depending on cycle stretching - I don't know the rules.
- Negative Charge
- Posts: 93
- Joined: Sat Jan 16, 2021 1:35 pm
- Contact:
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
Thanks Tricky! The general rule is I’m trying to save as many cycles as possible in the sound loop, while balancing the instruction cycle count between branches taken/not taken. I’m not too worried if I waste bytes through lookup tables etc.
The biggest reduction so far has been to inline subroutines via macros, as suggested by Kieran. JSR/RTS wastes 12 cycles and JSR/JMP 9, so it’s a pretty good reduction.
The only issue I’ve had is that the main sound loop is now over 127 bytes long and branching requires trampolines to jump back to the loop start. That wastes a minimum of 3 cycles (often 6), but is better than the 12 I was wasting through subroutines.
There may be a possibility to replace the SN76489 output code with something with a smaller cycle count, such as the code from Exile… going to investigate that next.
Website: https://negativecharge.github.io/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
You said that you needed 5 bytes to inline one of the uses and with the 4 you saved removing the nops, the extra byte daven would allow you to inline and save more than the extra cycle.
It may even be that swapping and removing an extra nop saves another cycle if it still works.
It may even be that swapping and removing an extra nop saves another cycle if it still works.
- Negative Charge
- Posts: 93
- Joined: Sat Jan 16, 2021 1:35 pm
- Contact:
Re: Experiments in 1-Bit Sound on the BBC Micro and Acorn Electron
Thanks Tricky. Yes, I see what you mean. Removing one of the nops still allows playback, so that’s only 6 cycles now and saves a byte. I’ll see if I can remove at least one of the two trampolines where I’ve inlined the sound_write_slow code.
Website: https://negativecharge.github.io/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/
Twitter: @Charge_Negative (https://mobile.twitter.com/charge_negative)
YouTube: https://youtube.com/channel/UCy7-RCobl0KsVJVTeO82roA
GitHub: https://github.com/NegativeCharge/