mirror of
https://github.com/86Box/86Box.git
synced 2026-02-23 18:08:20 -07:00
Merge pull request #6672 from Domppari/hdd_audio_prototype
Support for HDD sound emulation
This commit is contained in:
@@ -71,23 +71,6 @@ typedef enum {
|
||||
MOTOR_STATE_STOPPING
|
||||
} motor_state_t;
|
||||
|
||||
/* WAV header structure */
|
||||
typedef struct {
|
||||
char riff[4];
|
||||
uint32_t size;
|
||||
char wave[4];
|
||||
char fmt[4];
|
||||
uint32_t fmt_size;
|
||||
uint16_t audio_format;
|
||||
uint16_t num_channels;
|
||||
uint32_t sample_rate;
|
||||
uint32_t byte_rate;
|
||||
uint16_t block_align;
|
||||
uint16_t bits_per_sample;
|
||||
char data[4];
|
||||
uint32_t data_size;
|
||||
} wav_header_t;
|
||||
|
||||
/* Audio sample structure */
|
||||
typedef struct {
|
||||
char filename[512];
|
||||
|
||||
@@ -172,6 +172,7 @@ typedef struct hard_disk_t {
|
||||
uint32_t hpc;
|
||||
uint32_t tracks;
|
||||
uint32_t speed_preset;
|
||||
uint32_t audio_profile;
|
||||
|
||||
uint32_t num_zones;
|
||||
uint32_t phy_cyl;
|
||||
@@ -233,6 +234,7 @@ extern double hdd_seek_get_time(hard_disk_t *hdd, uint32_t dst_addr, uint8_
|
||||
int hdd_preset_get_num(void);
|
||||
const char *hdd_preset_getname(int preset);
|
||||
extern const char *hdd_preset_get_internal_name(int preset);
|
||||
extern uint32_t hdd_preset_get_rpm(int preset);
|
||||
extern int hdd_preset_get_from_internal_name(char *s);
|
||||
extern void hdd_preset_apply(int hdd_id);
|
||||
|
||||
|
||||
83
src/include/86box/hdd_audio.h
Normal file
83
src/include/86box/hdd_audio.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Definitions for the hard disk audio emulation.
|
||||
*
|
||||
* Authors: Toni Riikonen, <riikonen.toni@gmail.com>
|
||||
*
|
||||
* Copyright 2026 Toni Riikonen.
|
||||
*/
|
||||
#ifndef EMU_HDD_AUDIO_H
|
||||
#define EMU_HDD_AUDIO_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <86box/hdd.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HDD_AUDIO_PROFILE_MAX 64
|
||||
|
||||
/* Spindle motor states */
|
||||
typedef enum {
|
||||
HDD_SPINDLE_STOPPED = 0,
|
||||
HDD_SPINDLE_STARTING,
|
||||
HDD_SPINDLE_RUNNING,
|
||||
HDD_SPINDLE_STOPPING
|
||||
} hdd_spindle_state_t;
|
||||
|
||||
/* Audio sample configuration structure */
|
||||
typedef struct {
|
||||
char filename[512];
|
||||
float volume;
|
||||
} hdd_audio_sample_config_t;
|
||||
|
||||
/* HDD audio profile configuration */
|
||||
typedef struct {
|
||||
int id;
|
||||
char name[128];
|
||||
char internal_name[64];
|
||||
uint32_t rpm;
|
||||
hdd_audio_sample_config_t spindlemotor_start;
|
||||
hdd_audio_sample_config_t spindlemotor_loop;
|
||||
hdd_audio_sample_config_t spindlemotor_stop;
|
||||
hdd_audio_sample_config_t seek_track;
|
||||
} hdd_audio_profile_config_t;
|
||||
|
||||
/* Functions for profile management */
|
||||
extern void hdd_audio_load_profiles(void);
|
||||
extern int hdd_audio_get_profile_count(void);
|
||||
extern const hdd_audio_profile_config_t *hdd_audio_get_profile(int id);
|
||||
extern const char *hdd_audio_get_profile_name(int id);
|
||||
extern const char *hdd_audio_get_profile_internal_name(int id);
|
||||
extern uint32_t hdd_audio_get_profile_rpm(int id);
|
||||
extern int hdd_audio_get_profile_by_internal_name(const char *internal_name);
|
||||
|
||||
/* HDD audio initialization and cleanup */
|
||||
extern void hdd_audio_init(void);
|
||||
extern void hdd_audio_reset(void);
|
||||
extern void hdd_audio_close(void);
|
||||
extern void hdd_audio_callback(int16_t *buffer, int length);
|
||||
extern void hdd_audio_seek(hard_disk_t *hdd, uint32_t new_cylinder);
|
||||
|
||||
/* Per-drive spindle control */
|
||||
extern void hdd_audio_spinup_drive(int hdd_index);
|
||||
extern void hdd_audio_spindown_drive(int hdd_index);
|
||||
extern hdd_spindle_state_t hdd_audio_get_drive_spindle_state(int hdd_index);
|
||||
|
||||
/* Legacy functions for backward compatibility - operate on all drives */
|
||||
extern void hdd_audio_spinup(void);
|
||||
extern void hdd_audio_spindown(void);
|
||||
extern hdd_spindle_state_t hdd_audio_get_spindle_state(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EMU_HDD_AUDIO_H */
|
||||
@@ -103,6 +103,9 @@ extern void sound_cd_thread_reset(void);
|
||||
extern void sound_fdd_thread_init(void);
|
||||
extern void sound_fdd_thread_end(void);
|
||||
|
||||
extern void sound_hdd_thread_init(void);
|
||||
extern void sound_hdd_thread_end(void);
|
||||
|
||||
extern void closeal(void);
|
||||
extern void inital(void);
|
||||
extern void givealbuffer(const void *buf);
|
||||
@@ -110,6 +113,7 @@ extern void givealbuffer_music(const void *buf);
|
||||
extern void givealbuffer_wt(const void *buf);
|
||||
extern void givealbuffer_cd(const void *buf);
|
||||
extern void givealbuffer_fdd(const void *buf, const uint32_t size);
|
||||
extern void givealbuffer_hdd(const void *buf, const uint32_t size);
|
||||
|
||||
#define sb_vibra16c_onboard_relocate_base sb_vibra16s_onboard_relocate_base
|
||||
#define sb_vibra16cl_onboard_relocate_base sb_vibra16s_onboard_relocate_base
|
||||
|
||||
28
src/include/86box/sound_util.h
Normal file
28
src/include/86box/sound_util.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef SOUND_UTIL_H
|
||||
#define SOUND_UTIL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* WAV file header structure */
|
||||
typedef struct wav_header_t {
|
||||
char riff[4];
|
||||
uint32_t file_size;
|
||||
char wave[4];
|
||||
char fmt[4];
|
||||
uint32_t fmt_size;
|
||||
uint16_t audio_format;
|
||||
uint16_t num_channels;
|
||||
uint32_t sample_rate;
|
||||
uint32_t byte_rate;
|
||||
uint16_t block_align;
|
||||
uint16_t bits_per_sample;
|
||||
char data[4];
|
||||
uint32_t data_size;
|
||||
} wav_header_t;
|
||||
|
||||
/* Load a WAV file and return stereo 16-bit samples
|
||||
* Returns allocated buffer (caller must free) or NULL on error
|
||||
* sample_count receives the number of stereo sample pairs */
|
||||
int16_t *sound_load_wav(const char *filename, int *sample_count);
|
||||
|
||||
#endif /* SOUND_UTIL_H */
|
||||
Reference in New Issue
Block a user