Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
port sound and music
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 4, 2023
1 parent 69fdf33 commit 1fff7c1
Show file tree
Hide file tree
Showing 25 changed files with 1,450 additions and 255 deletions.
168 changes: 84 additions & 84 deletions docs/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 63 additions & 63 deletions docs/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,34 @@ typedef struct DISPLAY_MODE_LIST {
} DISPLAY_MODE_LIST;

typedef struct STRING_FLAGGED {
LPTSTR lpString;
bool isPresented;
char *content;
bool is_valid;
} STRING_FLAGGED;

typedef struct DISPLAY_ADAPTER {
LPGUID lpAdapterGuid;
GUID adapterGuid;
STRING_FLAGGED driverDescription;
STRING_FLAGGED driverName;
DDCAPS driverCaps;
DDCAPS helCaps;
GUID deviceGuid;
D3DDEVICEDESC D3DHWDeviceDesc;
DISPLAY_MODE_LIST hwDispModeList;
DISPLAY_MODE_LIST swDispModeList;
DISPLAY_MODE vgaMode1;
DISPLAY_MODE vgaMode2;
DWORD screenWidth;
bool hwRenderSupported;
bool swWindowedSupported;
bool hwWindowedSupported;
bool isVgaMode1Presented;
bool isVgaMode2Presented;
bool perspectiveCorrectSupported;
bool ditherSupported;
bool zBufferSupported;
bool linearFilterSupported;
bool shadeRestricted;
LPGUID adapter_guid_ptr;
GUID adapter_guid;
STRING_FLAGGED driver_description;
STRING_FLAGGED driver_name;
DDCAPS driver_caps;
DDCAPS hel_caps;
GUID device_guid;
D3DDEVICEDESC device_desc;
DISPLAY_MODE_LIST hw_display_mode_list;
DISPLAY_MODE_LIST sw_display_mode_list;
DISPLAY_MODE vga_mode1;
DISPLAY_MODE vga_mode2;
DWORD screen_width;
bool hw_render_supported;
bool sw_windowed_supported;
bool hw_windowed_supported;
bool is_vga_mode1_presented;
bool is_vga_mode2_presented;
bool perspective_correct_supported;
bool dither_supported;
bool zbuffer_supported;
bool linear_filter_supported;
bool shade_sestricted;
} DISPLAY_ADAPTER;

typedef struct DISPLAY_ADAPTER_NODE {
Expand Down Expand Up @@ -1800,10 +1800,10 @@ typedef struct CINE_FRAME {
00445A50 000003B1 -R HRESULT __stdcall EnumDisplayModesCallback(LPDDSDESC lpDDSurfaceDesc, LPVOID lpContext);
00445E10 00000040 -R bool __cdecl WinVidInit(void);
00445E50 000000AF -R bool __cdecl WinVidGetDisplayAdapters(void);
00445F00 00000013 -R void __thiscall FlaggedStringDelete(struct STRING_FLAGGED *item);
00445F00 00000013 +R void __thiscall FlaggedString_Delete(struct STRING_FLAGGED *item);
00445F20 0000001A -R bool __cdecl EnumerateDisplayAdapters(struct DISPLAY_ADAPTER_LIST *displayAdapterList);
00445F40 000001BE -R BOOL __stdcall EnumDisplayAdaptersCallback(GUID *lpGUID, LPTSTR lpDriverDescription, LPTSTR lpDriverName, LPVOID lpContext);
00446100 00000035 -R void __thiscall FlaggedStringsCreate(struct DISPLAY_ADAPTER *adapter);
00446100 00000035 +R void __thiscall FlaggedString_CreateArray(struct DISPLAY_ADAPTER *adapter);
00446140 0000006A -R bool __cdecl WinVidRegisterGameWindowClass(void);
004461B0 0000049F -R LRESULT __stdcall WinVidGameWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
004467C0 000001C0 -R void __cdecl WinVidResizeGameWindow(HWND hWnd, int32_t edge, LPRECT rect);
Expand Down Expand Up @@ -1833,7 +1833,7 @@ typedef struct CINE_FRAME {
004473B0 0000007F -R bool __cdecl WinInputInit(void);
00447430 00000024 -R bool __cdecl DInputEnumDevices(JOYSTICK_LIST *joystickList);
00447460 000000E8 -R BOOL __stdcall DInputEnumDevicesCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
00447550 0000001F -R void __thiscall FlaggedStringCreate(struct STRING_FLAGGED *item, DWORD dwSize);
00447550 0000001F +R void __thiscall FlaggedStringCreate(struct STRING_FLAGGED *item, DWORD dwSize);
00447570 0000004E -R JOYSTICK_NODE *__cdecl GetJoystick(GUID *lpGuid);
004475C0 000000C9 -R void __cdecl DInputKeyboardCreate(void);
00447690 00000029 -R void __cdecl DInputKeyboardRelease(void);
Expand All @@ -1854,24 +1854,24 @@ typedef struct CINE_FRAME {
00447B30 00000018 x sub_447B30
00447B40 00000039 x sub_447B40
00447B90 0000002F x sub_447B90
00447BC0 00000048 - struct SOUND_ADAPTER_NODE *__cdecl S_Audio_Sample_GetAdapter(GUID *guid);
00447C10 0000002E - void __cdecl S_Audio_Sample_CloseAllTracks(void);
00447C40 0000010E - bool __cdecl S_Audio_Sample_Load(int32_t sample_id, LPWAVEFORMATEX format, const void *data, int32_t data_size);
00447D50 00000045 - bool __cdecl S_Audio_Sample_IsTrackPlaying(int32_t track_id);
00447DA0 000000E7 - int32_t __cdecl S_Audio_Sample_Play(int32_t sample_id, int32_t volume, int32_t pitch, int32_t pan, int32_t flags);
00447E90 00000039 - int32_t __cdecl S_Audio_Sample_GetFreeTrackIndex(void);
00447ED0 0000002C - void __cdecl S_Audio_Sample_AdjustTrackVolumeAndPan(int32_t track_id, int32_t volume, int32_t pan);
00447F00 00000031 - void __cdecl S_Audio_Sample_AdjustTrackPitch(int32_t track_id, int32_t pitch);
00447F40 0000002F - void __cdecl S_Audio_Sample_CloseTrack(int32_t track_id);
00447FA0 00000005 -R sub_447FA0
00447FB0 0000009C - bool __cdecl S_Audio_Sample_Init(void);
00448050 0000001A - bool __cdecl S_Audio_Sample_DSoundEnumerate(struct SOUND_ADAPTER_LIST *adapter_list);
00448070 000000E2 - BOOL __stdcall S_Audio_Sample_DSoundEnumCallback(LPGUID guid, LPCTSTR description, LPCTSTR module, LPVOID context);
00448160 0000017C - void __cdecl S_Audio_Sample_Init2(HWND hwnd);
004482E0 0000001C - bool __cdecl S_Audio_Sample_DSoundCreate(GUID *guid);
00448300 000000C4 - bool __cdecl S_Audio_Sample_DSoundBufferTest(void);
004483D0 0000002A - void __cdecl S_Audio_Sample_Shutdown(void);
00448400 00000006 - bool __cdecl S_Audio_Sample_IsEnabled(void);
00447BC0 00000048 + struct SOUND_ADAPTER_NODE *__cdecl S_Audio_Sample_GetAdapter(GUID *guid);
00447C10 0000002E + void __cdecl S_Audio_Sample_CloseAllTracks(void);
00447C40 0000010E + bool __cdecl S_Audio_Sample_Load(int32_t sample_id, LPWAVEFORMATEX format, const void *data, int32_t data_size);
00447D50 00000045 + bool __cdecl S_Audio_Sample_IsTrackPlaying(int32_t track_id);
00447DA0 000000E7 + int32_t __cdecl S_Audio_Sample_Play(int32_t sample_id, int32_t volume, int32_t pitch, int32_t pan, int32_t flags);
00447E90 00000039 + int32_t __cdecl S_Audio_Sample_GetFreeTrackIndex(void);
00447ED0 0000002C + void __cdecl S_Audio_Sample_AdjustTrackVolumeAndPan(int32_t track_id, int32_t volume, int32_t pan);
00447F00 00000031 + void __cdecl S_Audio_Sample_AdjustTrackPitch(int32_t track_id, int32_t pitch);
00447F40 0000002F + void __cdecl S_Audio_Sample_CloseTrack(int32_t track_id);
00447FA0 00000005 +R sub_447FA0
00447FB0 0000009C + bool __cdecl S_Audio_Sample_Init(void);
00448050 0000001A + bool __cdecl S_Audio_Sample_DSoundEnumerate(struct SOUND_ADAPTER_LIST *adapter_list);
00448070 000000E2 + BOOL __stdcall S_Audio_Sample_DSoundEnumCallback(LPGUID guid, LPCTSTR description, LPCTSTR module, LPVOID context);
00448160 0000017C + void __cdecl S_Audio_Sample_Init2(HWND hwnd);
004482E0 0000001C + bool __cdecl S_Audio_Sample_DSoundCreate(GUID *guid);
00448300 000000C4 + bool __cdecl S_Audio_Sample_DSoundBufferTest(void);
004483D0 0000002A + void __cdecl S_Audio_Sample_Shutdown(void);
00448400 00000006 + bool __cdecl S_Audio_Sample_IsEnabled(void);
00448410 00000005 -R sub_448410
00448420 00000001 -R sub_448420
00448430 0000013B -R void __cdecl CreateScreenBuffers(void);
Expand Down Expand Up @@ -2071,23 +2071,23 @@ typedef struct CINE_FRAME {
00454D60 0000032D -R void __cdecl CheckCheatMode(void);
004550C0 0000007D -R void __cdecl S_SaveSettings(void);
00455140 000000DB -R void __cdecl S_LoadSettings(void);
00455220 00000046 - int32_t __cdecl S_Audio_Sample_OutPlay(int32_t sample_id, uint16_t volume, int32_t pitch, int32_t pan);
00455270 0000002A - int32_t __cdecl S_Audio_Sample_CalculateSampleVolume(int32_t volume);
004552A0 00000026 - int32_t __cdecl S_Audio_Sample_CalculateSamplePan(int16_t pan);
004552D0 00000046 - int32_t __cdecl S_Audio_Sample_OutPlayLooped(int32_t track_id, uint16_t volume, int32_t pitch, int32_t pan);
00455320 00000039 - void __cdecl S_Audio_Sample_OutSetPanAndVolume(int32_t track_id, int32_t pan, uint16_t volume);
00455360 0000001C - void __cdecl S_Audio_Sample_OutSetPitch(int32_t track_id, int32_t pitch);
00455380 0000000A - void __cdecl Sound_SetMasterVolume(int32_t volume);
00455390 00000017 - void __cdecl S_Audio_Sample_OutCloseTrack(int32_t track_id);
004553B0 0000003C - void __cdecl S_Audio_Sample_OutCloseAllTracks(void);
004553C0 0000001F - BOOL __cdecl S_Audio_Sample_OutIsTrackPlaying(int32_t track_id);
004553E0 00000077 - bool __cdecl Music_Init(void);
00455460 00000051 - void __cdecl Music_Shutdown(void);
00455500 0000006F - void __cdecl Music_Play(int16_t track_id, bool is_looped);
00455570 00000039 - void __cdecl Music_Stop(void);
004555B0 00000084 - bool __cdecl Music_PlaySynced(int32_t trackID);
00455640 00000061 - int32_t __cdecl Music_GetFrames(void);
004556B0 00000092 * void __cdecl Music_SetVolume(int32_t volume);
00455220 00000046 + int32_t __cdecl S_Audio_Sample_OutPlay(int32_t sample_id, uint16_t volume, int32_t pitch, int32_t pan);
00455270 0000002A + int32_t __cdecl S_Audio_Sample_CalculateSampleVolume(int32_t volume);
004552A0 00000026 + int32_t __cdecl S_Audio_Sample_CalculateSamplePan(int16_t pan);
004552D0 00000046 + int32_t __cdecl S_Audio_Sample_OutPlayLooped(int32_t track_id, uint16_t volume, int32_t pitch, int32_t pan);
00455320 00000039 + void __cdecl S_Audio_Sample_OutSetPanAndVolume(int32_t track_id, int32_t pan, uint16_t volume);
00455360 0000001C + void __cdecl S_Audio_Sample_OutSetPitch(int32_t track_id, int32_t pitch);
00455380 0000000A + void __cdecl Sound_SetMasterVolume(int32_t volume);
00455390 00000017 + void __cdecl S_Audio_Sample_OutCloseTrack(int32_t track_id);
004553B0 0000003C + void __cdecl S_Audio_Sample_OutCloseAllTracks(void);
004553C0 0000001F + BOOL __cdecl S_Audio_Sample_OutIsTrackPlaying(int32_t track_id);
004553E0 00000077 + bool __cdecl Music_Init(void);
00455460 00000051 + void __cdecl Music_Shutdown(void);
00455500 0000006F + void __cdecl Music_Play(int16_t track_id, bool is_looped);
00455570 00000039 + void __cdecl Music_Stop(void);
004555B0 00000084 + bool __cdecl Music_PlaySynced(int32_t trackID);
00455640 00000061 + int32_t __cdecl Music_GetFrames(void);
004556B0 00000092 + void __cdecl Music_SetVolume(int32_t volume);
004557A0 00000137 -R void __cdecl CopyBitmapPalette(RGB888 *srcPal, BYTE *srcBitmap, int32_t bitmapSize, RGB888 *destPal);
004558E0 000000C8 -R BYTE __cdecl FindNearestPaletteEntry(RGB888 *palette, int32_t red, int32_t green, int32_t blue, bool ignoreSysPalette);
004559B0 000000AE -R void __cdecl SyncSurfacePalettes(void *srcData, int32_t width, int32_t height, int32_t srcPitch, RGB888 *srcPalette, void *dstData, int32_t dstPitch, RGB888 *dstPalette, bool preserveSysPalette);
Expand Down
7 changes: 7 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,20 @@ dll_sources = [
'src/game/camera.c',
'src/game/math.c',
'src/game/matrix.c',
'src/game/music.c',
'src/game/shell.c',
'src/game/sound.c',
'src/inject_exec.c',
'src/inject_util.c',
'src/lib/winmm.c',
'src/log.c',
'src/main_dll.c',
'src/memory.c',
'src/specific/s_audio_sample.c',
'src/specific/s_filesystem.c',
'src/specific/s_music.c',
'src/specific/s_pauld.c',
'src/specific/s_flagged_string.c',
]

executable(
Expand Down
11 changes: 6 additions & 5 deletions src/game/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "game/math.h"
#include "game/matrix.h"
#include "game/music.h"
#include "global/const.h"
#include "global/funcs.h"
#include "global/vars.h"
Expand Down Expand Up @@ -795,12 +796,12 @@ void __cdecl Camera_Update(void)

void __cdecl Camera_LoadCutsceneFrame(void)
{
g_CineFrame++;
if (g_CineFrame >= g_NumCineFrames) {
g_CineFrame = g_NumCineFrames - 1;
g_CineFrameIdx++;
if (g_CineFrameIdx >= g_NumCineFrames) {
g_CineFrameIdx = g_NumCineFrames - 1;
}

const struct CINE_FRAME *frame = &g_CineData[g_CineFrame];
const struct CINE_FRAME *frame = &g_CineData[g_CineFrameIdx];
int32_t tx = frame->tx;
int32_t ty = frame->ty;
int32_t tz = frame->tz;
Expand Down Expand Up @@ -847,7 +848,7 @@ void __cdecl Camera_LoadCutsceneFrame(void)

void __cdecl Camera_UpdateCutscene(void)
{
const struct CINE_FRAME *frame = &g_CineData[g_CineFrame];
const struct CINE_FRAME *frame = &g_CineData[g_CineFrameIdx];
int32_t tx = frame->tx;
int32_t ty = frame->ty;
int32_t tz = frame->tz;
Expand Down
37 changes: 37 additions & 0 deletions src/game/music.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "global/types.h"
#include "specific/s_music.h"

bool __cdecl Music_Init(void)
{
return S_Music_Init();
}

void __cdecl Music_Shutdown(void)
{
S_Music_Shutdown();
}

void __cdecl Music_Play(int16_t track_id, bool is_looped)
{
S_Music_Play(track_id, is_looped);
}

void __cdecl Music_Stop(void)
{
S_Music_Stop();
}

bool __cdecl Music_PlaySynced(int32_t track_id)
{
return S_Music_PlaySynced(track_id);
}

uint32_t __cdecl Music_GetFrames(void)
{
return S_Music_GetFrames();
}

void __cdecl Music_SetVolume(int32_t volume)
{
S_Music_SetVolume(volume);
}
11 changes: 11 additions & 0 deletions src/game/music.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include "global/types.h"

bool __cdecl Music_Init(void);
void __cdecl Music_Shutdown(void);
void __cdecl Music_Play(int16_t track_id, bool is_looped);
void __cdecl Music_Stop(void);
bool __cdecl Music_PlaySynced(int32_t track_id);
uint32_t __cdecl Music_GetFrames(void);
void __cdecl Music_SetVolume(int32_t volume);
8 changes: 8 additions & 0 deletions src/game/sound.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "game/sound.h"

#include "global/vars.h"

void __cdecl Sound_SetMasterVolume(int32_t volume)
{
g_MasterVolume = volume;
}
5 changes: 5 additions & 0 deletions src/game/sound.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "global/types.h"

void __cdecl Sound_SetMasterVolume(int32_t volume);
3 changes: 3 additions & 0 deletions src/global/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
#define MIN_HEAD_ROTATION (-MAX_HEAD_ROTATION) // = -9100
#define MAX_HEAD_TILT_CAM (85 * PHD_DEGREE) // = 15470
#define MIN_HEAD_TILT_CAM (-MAX_HEAD_TILT_CAM) // = -15470

#define MAX_AUDIO_SAMPLE_BUFFERS 256
#define MAX_AUDIO_SAMPLE_TRACKS 32
Loading

0 comments on commit 1fff7c1

Please sign in to comment.