Topic: PETs Can't Keep Dying by AYCE

https://www.youtube.com/watch?v=WmEtDes5drY

Re: PETs Can't Keep Dying by AYCE

Pretty damn impressive. I think PET audio can be pushed further still, but this is quite an achievement.
Fun story, I was actually working on a multi-channel PET routine right when this got released. Grrrrr!

Re: PETs Can't Keep Dying by AYCE

I liked the achievement, but the bit pointed at Mr. Murray was kinda uncool. The 'wrong' person 'hired' implied there is me, I'm working on sound code for his project. Not to mention it questions my abilities, it also does not consider Mr. Murray has a vision on what he wants in his project. Sure I proposed multichannel stuff, sampled SFX, and other advanced things a while back for Planet X3, and once again for this one, but these ideas were all rejected in favor of the standard monophonic sound, not even going below the 245 Hz limit was considered at first. It also needs to be cross-platform (VIC-20, C64, with their native sound as well), and fit into mere 2.5K with code, SFX, and a music track.

website - 1bit music - other music - youtube - bandcamp - patreon - twitter (latest news there)

Re: PETs Can't Keep Dying by AYCE

Very impressive sound from the Pet. A friend of mine owns one that he found discarded in a skip a few years ago.

I've no idea what the text is talking about or who Mr Murray is but I enjoyed the music and great to hear beeper stuff on other platforms.

Re: PETs Can't Keep Dying by AYCE

@Shiru: Oh wow, that whole bit about Mr. Murray totally escaped my attention. Yeah, deffo uncool, but on the other hand it clearly says more about them than you guys.

Btw what's your approach for going below 245 Hz limit? Right now I'm toggling CB2 in direct mode via a Timer 1 interrupt, but I'm thinking there's got to be a better way. Also, the Raeto C West book mentions using the Timer 2 high-byte in conjunction with the Shift Register, but this doesn't appear to work. Am I missing something here?

@Tufty: Mr. Murray = The 8-bit Guy

Re: PETs Can't Keep Dying by AYCE

T2 high byte is not supposed to work in the free running mode. I hoped there is some hack to make it work, but considering not so precise emulation and lack of real hardware (not even sole 6522 chip) on my end, I can't do tests. Well, the main issue with pushing PET is that it isn't emulated well (not all timer modes covered, for one), and there is like 1.5 PET emulators around (.5 in MAME, difficult to setup).

To me it seem the only viable way at the moment is to use IRQ to toggle CB2, I did it as a software Shift Register imitation there. However, there is some issue on the real HW that is not figured out yet is that some tones disappear when you switching between IRQ and Shift Register (just on the transition point, maybe IRQs get skipped?), and this behavior is not emulated (works just fine in emulator).

Another issues are that default IRQ handler pushes all the registers before going IRQ trampoline, which wastes a ton of time; default system handler still need to be called once a frame (to make keyboard input work for the game), which introduces clicks; and unexpectedly annoying one, speaker in PET barely can reproduce low frequencies, they're getting very quiet.

website - 1bit music - other music - youtube - bandcamp - patreon - twitter (latest news there)

Re: PETs Can't Keep Dying by AYCE

is the transmission of a byte to the loudspeaker via serial interface in hardware? if in hardware, isn't it so that the serial transmission of a byte also sends the start and stop bit? (10 bits per 1 byte of data transmission)?

???

Re: PETs Can't Keep Dying by AYCE

6522 is not a real serial interface, it is merely a timer plus shift register, so it does not really know about start and stop bits, it is all up to software to implement actual communication protocols.

When 6522 used for CB2 sound, the free running mode driven by T2 counter is used, that is, a 8-bit counter divides 0.5 MHz and clocks a 8-bit output shift register that is looped. Naive approach for PET sound is to load %11110000, %11001100, or %10101010 into the shift register, then set up T2 counter to some desired frequency. This means you can't go below 500000/255 Hz (~245), but you can have wave shapes other than regular square wave.

There is another mode where you can also output an arbitrary bit stream, getting an IRQ every time when shift register gets empty, thus getting some buffered playback. This mode is not emulated, unfortunately.

website - 1bit music - other music - youtube - bandcamp - patreon - twitter (latest news there)

Re: PETs Can't Keep Dying by AYCE

Shiru wrote:

There is another mode where you can also output an arbitrary bit stream, getting an IRQ every time when shift register gets empty, thus getting some buffered playback. This mode is not emulated, unfortunately.

Damnit! So that's why that didn't work when I tried it. I guess MAME doesn't emulate that either, does it?
Also, do you have any more in-depth documentation about the PET? I'm mostly working with petmem.txt, pet-io-2.txt, The PET User Port Cookbook, and the Raeto West book. Somehow I don't find any of them particularly satisfying.

pet-io-2.txt mentions

Also (on my machine), when generating sound one must first set the shift
register in "free running" mode, and then load it with a value to shift.
The other way around does not seem to work.

Is that true? I have one player prototype that sets the Shift register to $ff and just toggles bit 4 in ACR, and that seems to work fine on my friend's 8032.

Fun story, I once owned a half-working 8096... for a couple of hours. It was given to me at a demoparty. Since I had no means of transporting it, I had to give it away. It's now in the computer museum in Katowice.

Re: PETs Can't Keep Dying by AYCE

I'm working with VICE, as I wasn't able to set up MAME properly. Judging by MAME source code, it does emulate IRQ on shifting, or trying to do so, at least. Latest updates to 6522 emulation there were doing in August, so it is kinda alive.

Emulation quality in VICE, on the other hand, is kinda questionable. It is incomplete, and the way the sound emulated is really weird. Like, direct CB2 control sounds unfiltered, while SR-driven sound is clearly filtered with very weird curve, it gets quieter as the pitch rises, up to the point of being really faint, then gets back to normal volume. So it sounds like a mess in a normal music. Also pitch and frame rate seem to be a bit off.

I didn't find any in-depth docs other than that you're mentioned, and I missed pet-io-2.txt altogether (thanks!). I also used 6522 datasheets, there is three of them, and they're actually different. Synertek SY6522 from 1982 (not 1978!) seem to be more detailed in the timers section. I also looked up VICE and MAME source code.

As I don't have access to the real thing, and active back-and-forth is kinda difficult to do (David is busy man), I can't say for sure. However, Synertek datasheet mentions it explicitly - first enable shifting, then load value to the register to start shifting. As for bit 5 of ACR and loading $ff, I did it other way, by toggling bit 5 of PCR - it does work on the HW regardless of the shift register contents. However, there is the missing notes issue, may be related to either of these things. Will try your approach (looks more elegant), thank for hints.

website - 1bit music - other music - youtube - bandcamp - patreon - twitter (latest news there)

Re: PETs Can't Keep Dying by AYCE

Thanks to utz's input I got PET running in MAME. Turned out that MAME emulates 6522 quirks better, like, VICE would allow incorrect code to work just fine. However, MAME's SR produced pitch is twice higher than it should be.

website - 1bit music - other music - youtube - bandcamp - patreon - twitter (latest news there)

12

Re: PETs Can't Keep Dying by AYCE

Shiru wrote:

However, MAME's SR produced pitch is twice higher than it should be.

Ugh. Do you want me to file an issue against MAME? Occasionally folks there are pretty quick with fixing stuff. I'd need some sort of "proof" though.

Re: PETs Can't Keep Dying by AYCE

Sure, would be nice if it get fixed.

Here is the proof. Run this PRG in VICE, and you'll hear ~245 Hz sound, as expected. Run it in MAME, and you'll hear it twice higher.

The code is:

    lda #$10        ;shift out free running at T2 rate
    sta VIA_CR
    lda #255        ;lowest possible frequency, 1000000/16/255=245hz
    sta VIA_T2CL
    lda #%00001111
    sta VIA_SR
Post's attachments

test_pet.prg 82 b, 1 downloads since 2020-12-13 

You don't have the permssions to download the attachments of this post.
website - 1bit music - other music - youtube - bandcamp - patreon - twitter (latest news there)

14

Re: PETs Can't Keep Dying by AYCE

Done: https://github.com/mamedev/mame/issues/7559
Can't upload the .prg there, cause github managed to break file uploads from ff on linux again.