save speaker volume to XPRAM

This commit is contained in:
kanjitalk755 2024-12-08 09:57:37 +09:00
parent d3aa80f703
commit 4cc1333939
2 changed files with 6 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "user_strings.h"
#include "audio.h"
#include "audio_defs.h"
#include "xpram.h"
#include <SDL_mutex.h>
#include <SDL_audio.h>
@ -369,6 +370,7 @@ void audio_set_speaker_volume(uint32 vol)
speaker_volume = ((vol >> 16) + (vol & 0xffff)) / 2;
if (speaker_volume > MAC_MAX_VOLUME)
speaker_volume = MAC_MAX_VOLUME;
XPRAM[8] = (XPRAM[8] & 0xf8) | (speaker_volume * 7 / 256 & 7);
}
static int get_audio_volume() {

View File

@ -38,6 +38,7 @@
#include "user_strings.h"
#include "prefs.h"
#include "main.h"
#include "audio.h"
#define DEBUG 0
#include "debug.h"
@ -168,6 +169,9 @@ bool InitAll(const char *vmdir)
// Init audio
AudioInit();
int vol = (XPRAM[8] & 7) * 256 / 7;
vol += vol < 256;
audio_set_speaker_volume(vol | vol << 16);
// Init video
if (!VideoInit(ROMVersion == ROM_VERSION_64K || ROMVersion == ROM_VERSION_PLUS || ROMVersion == ROM_VERSION_CLASSIC))