Skip to content

Emulate PSG in SN76489 mode for pre-SMS consoles - #150

Open
maxim-zhao wants to merge 3 commits into
ocornut:masterfrom
maxim-zhao:sg1000-psg
Open

Emulate PSG in SN76489 mode for pre-SMS consoles#150
maxim-zhao wants to merge 3 commits into
ocornut:masterfrom
maxim-zhao:sg1000-psg

Conversation

@maxim-zhao

Copy link
Copy Markdown
Collaborator

Somehow Meka was always emulating in SMS mode. The difference is barely noticeable for white noise, but very noticeable for periodic - but then SG games hardly ever use that.

@maxim-zhao

Copy link
Copy Markdown
Collaborator Author

Internally it was trying to say SN76489AN = SMS/GG, SN79489 = SG/SC (Sound Type in drivers.h) so I felt I had to rename this. I also introduced a different enum for this in the PSG emulator.

Overall I also want to throw away this PSG emulator because it's kind of inaccurate compared to modern ones. But that's for another time.

Comment thread meka/srcs/sound/psg.cpp
#define NoiseWhiteFeedback_SMSGG 0x0009 // Bits 0 and 3
#define NoiseWhiteFeedback_SGSC 0x0006 // Bits 1 and 2

#define NoiseWhiteFeedback NoiseWhiteFeedback_SMSGG

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these were used

Comment thread meka/srcs/sound/psg.cpp Outdated
for (int i = 0; i < 4; i++) // FIXME: to be done in sound.c ?
PSG.Channels[i].Active = TRUE;
SN76489_Reset (Z80_DEFAULT_CPU_CLOCK, Sound.SampleRate);
SN76489_Reset (Z80_DEFAULT_CPU_CLOCK, Sound.SampleRate, NOISE_MODE_SEGA);

@maxim-zhao maxim-zhao May 12, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gets reset later anyway so the noise mode doesn't matter

Comment thread meka/srcs/app_techinfo.h

#define TECHINFO_LINES (14)
#define TECHINFO_COLUMNS (90)
#define TECHINFO_COLUMNS (100)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need more space...

Comment thread meka/srcs/machine.cpp Outdated
// resume_fm();
FM_Reset();
SN76489_Reset (g_machine.TV->CPU_clock, Sound.SampleRate);
SN76489_Reset (g_machine.TV->CPU_clock, Sound.SampleRate, g_driver->snd == SND_SN76489 ? NOISE_MODE_SEGA : NOISE_MODE_SN76489);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's where we actually set the chip type into the PSG emulator

@maxim-zhao
maxim-zhao requested a review from ocornut May 12, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant