Remove SRB2 Music Player

This thing is ancient history and also depends on FMOD.
This commit is contained in:
Eidolon 2022-07-17 19:37:46 -05:00
parent 955259d5c1
commit 2ff3035746
12 changed files with 0 additions and 1404 deletions

View file

@ -1,44 +0,0 @@
# Makfile of SRB2MP
CFLAGS +=-Wall -mms-bitfields -fno-exceptions
LDFLAGS +=-mwindows -lfmod
WINDRESFLAGS=
SRC=lump.c SRB2MP.c
ifdef DEBUGMODE
CFLAGS +=-g -D_DEBUG
LDFLAGS +=-g
else
CFLAGS :=-Os -s $(CFLAGS)
LDFLAGS :=-s $(LDFLAGS)
endif
OBJ=$(SRC:.c=.o) # replaces the .c from SRC with .o
EXTRAOBJ=Script1.res
EXE=SRB2MP.exe
ifdef PREFIX
CC=$(PREFIX)-gcc
WINDRES ?=$(PREFIX)-windres
endif
WINDRES ?=windres
RM=rm
%.o: %.c StdAfx.h lump.h resource.h
$(CC) $(CFLAGS) -o $@ -c $<
%.res: %.rc resource.h
$(WINDRES) -i $< -O rc $(WINDRESFLAGS) -o $@ -O coff
.PHONY : all # .PHONY ignores files named all
all: $(EXE) # all is dependent on $(EXE) to be complete
$(EXE): $(OBJ) $(EXTRAOBJ) # $(EXE) is dependent on all of the files in $(OBJ) to exist
$(CC) $(OBJ) $(EXTRAOBJ) $(LDFLAGS) -o $@
.PHONY : clean # .PHONY ignores files named clean
clean:
-$(RM) $(OBJ) $(EXTRAOBJ)

View file

@ -1,464 +0,0 @@
// SRB2MP.cpp : Defines the entry point for the application.
//
#include "StdAfx.h"
#include "lump.h"
#define APPTITLE "SRB2 Music Player"
#define APPVERSION "v0.1"
#define APPAUTHOR "SSNTails"
#define APPCOMPANY "Sonic Team Junior"
static FSOUND_STREAM *fmus = NULL;
static int fsoundchannel = -1;
static FMUSIC_MODULE *mod = NULL;
static struct wadfile* wfptr = NULL;
static inline VOID M_SetVolume(int volume)
{
if (mod && FMUSIC_GetType(mod) != FMUSIC_TYPE_NONE)
FMUSIC_SetMasterVolume(mod, volume);
if (fsoundchannel != -1)
FSOUND_SetVolume(fsoundchannel, volume);
}
static inline BOOL M_InitMusic(VOID)
{
if (FSOUND_GetVersion() < FMOD_VERSION)
{
printf("Error : You are using the wrong DLL version!\nYou should be using FMOD %.02f\n", FMOD_VERSION);
return FALSE;
}
#ifdef _DEBUG
FSOUND_SetOutput(FSOUND_OUTPUT_WINMM);
#endif
if (!FSOUND_Init(44100, 1, FSOUND_INIT_GLOBALFOCUS))
{
printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
return FALSE;
}
return TRUE;
}
static inline VOID M_FreeMusic(VOID)
{
if (mod)
{
FMUSIC_StopSong(mod);
FMUSIC_FreeSong(mod);
mod = NULL;
}
if (fmus)
{
FSOUND_Stream_Stop(fmus);
FSOUND_Stream_Close(fmus);
fmus = NULL;
fsoundchannel = -1;
}
}
static inline VOID M_ShutdownMusic(VOID)
{
M_FreeMusic();
FSOUND_Close();
//remove(musicfile); // Delete the temp file
}
static inline VOID M_PauseMusic(VOID)
{
if (mod && !FMUSIC_GetPaused(mod))
FMUSIC_SetPaused(mod, TRUE);
if (fsoundchannel != -1 && FSOUND_IsPlaying(fsoundchannel))
FSOUND_SetPaused(fsoundchannel, TRUE);
}
static inline VOID M_ResumeMusic(VOID)
{
if (mod && FMUSIC_GetPaused(mod))
FMUSIC_SetPaused(mod, FALSE);
if (fsoundchannel != -1 && FSOUND_GetPaused(fsoundchannel))
FSOUND_SetPaused(fsoundchannel, FALSE);
}
static inline VOID M_StopMusic(VOID)
{
if (mod)
FMUSIC_StopSong(mod);
if (fsoundchannel != -1 && fmus && FSOUND_IsPlaying(fsoundchannel))
FSOUND_Stream_Stop(fmus);
}
static inline VOID M_StartFMODSong(LPVOID data, int len, int looping, HWND hDlg)
{
const int loops = FSOUND_LOOP_NORMAL|FSOUND_LOADMEMORY;
const int nloop = FSOUND_LOADMEMORY;
M_FreeMusic();
if (looping)
mod = FMUSIC_LoadSongEx(data, 0, len, loops, NULL, 0);
else
mod = FMUSIC_LoadSongEx(data, 0, len, nloop, NULL, 0);
if (mod)
{
FMUSIC_SetLooping(mod, (signed char)looping);
FMUSIC_SetPanSeperation(mod, 0.0f);
}
else
{
if (looping)
fmus = FSOUND_Stream_Open(data, loops, 0, len);
else
fmus = FSOUND_Stream_Open(data, nloop, 0, len);
}
if (!fmus && !mod)
{
MessageBoxA(hDlg, FMOD_ErrorString(FSOUND_GetError()), "Error", MB_OK|MB_APPLMODAL);
return;
}
// Scan the OGG for the COMMENT= field for a custom loop point
if (looping && fmus)
{
const BYTE *origpos, *dataum = data;
size_t scan, size = len;
CHAR buffer[512];
BOOL titlefound = FALSE, artistfound = FALSE;
unsigned int loopstart = 0;
origpos = dataum;
for(scan = 0; scan < size; scan++)
{
if (!titlefound)
{
if (*dataum++ == 'T')
if (*dataum++ == 'I')
if (*dataum++ == 'T')
if (*dataum++ == 'L')
if (*dataum++ == 'E')
if (*dataum++ == '=')
{
size_t titlecount = 0;
CHAR title[256];
BYTE length = *(dataum-10) - 6;
while(titlecount < length)
title[titlecount++] = *dataum++;
title[titlecount] = '\0';
sprintf(buffer, "Title: %s", title);
SendMessage(GetDlgItem(hDlg, IDC_TITLE), WM_SETTEXT, 0, (LPARAM)(LPCSTR)buffer);
titlefound = TRUE;
}
}
}
dataum = origpos;
for(scan = 0; scan < size; scan++)
{
if (!artistfound)
{
if (*dataum++ == 'A')
if (*dataum++ == 'R')
if (*dataum++ == 'T')
if (*dataum++ == 'I')
if (*dataum++ == 'S')
if (*dataum++ == 'T')
if (*dataum++ == '=')
{
size_t artistcount = 0;
CHAR artist[256];
BYTE length = *(dataum-11) - 7;
while(artistcount < length)
artist[artistcount++] = *dataum++;
artist[artistcount] = '\0';
sprintf(buffer, "By: %s", artist);
SendMessage(GetDlgItem(hDlg, IDC_ARTIST), WM_SETTEXT, 0, (LPARAM)(LPCSTR)buffer);
artistfound = TRUE;
}
}
}
dataum = origpos;
for(scan = 0; scan < size; scan++)
{
if (*dataum++ == 'C'){
if (*dataum++ == 'O'){
if (*dataum++ == 'M'){
if (*dataum++ == 'M'){
if (*dataum++ == 'E'){
if (*dataum++ == 'N'){
if (*dataum++ == 'T'){
if (*dataum++ == '='){
if (*dataum++ == 'L'){
if (*dataum++ == 'O'){
if (*dataum++ == 'O'){
if (*dataum++ == 'P'){
if (*dataum++ == 'P'){
if (*dataum++ == 'O'){
if (*dataum++ == 'I'){
if (*dataum++ == 'N'){
if (*dataum++ == 'T'){
if (*dataum++ == '=')
{
size_t newcount = 0;
CHAR looplength[64];
while (*dataum != 1 && newcount < 63)
{
looplength[newcount++] = *dataum++;
}
looplength[newcount] = '\n';
loopstart = atoi(looplength);
}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
else
dataum--;}
}
if (loopstart > 0)
{
const int length = FSOUND_Stream_GetLengthMs(fmus);
const int freq = 44100;
const unsigned int loopend = (unsigned int)((freq/1000.0f)*length-(freq/1000.0f));
if (!FSOUND_Stream_SetLoopPoints(fmus, loopstart, loopend))
{
printf("FMOD(Start,FSOUND_Stream_SetLoopPoints): %s\n",
FMOD_ErrorString(FSOUND_GetError()));
}
}
}
if (mod)
FMUSIC_PlaySong(mod);
if (fmus)
fsoundchannel = FSOUND_Stream_PlayEx(FSOUND_FREE, fmus, NULL, FALSE);
M_SetVolume(128);
}
static inline VOID FreeWADLumps(VOID)
{
M_FreeMusic();
if (wfptr) free_wadfile(wfptr);
wfptr = NULL;
}
static inline VOID ReadWADLumps(LPCSTR WADfilename, HWND hDlg)
{
HWND listbox = GetDlgItem(hDlg, IDC_PLAYLIST);
FILE* f;
struct lumplist *curlump;
SendMessage(listbox, LB_RESETCONTENT, 0, 0);
FreeWADLumps();
f = fopen(WADfilename, "rb");
wfptr = read_wadfile(f);
fclose(f);
/* start of C_LIST */
/* Loop through the lump list, printing lump info */
for(curlump = wfptr->head->next; curlump; curlump = curlump->next)
{
LPCSTR lumpname = get_lump_name(curlump->cl);
if (!strncmp(lumpname, "O_", 2) || !strncmp(lumpname, "D_", 2))
SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)(LPCSTR)get_lump_name(curlump->cl));
}
/* end of C_LIST */
}
//
// OpenWadfile
//
// Provides a common dialog box
// for selecting the desired wad file.
//
static inline VOID OpenWadfile(HWND hDlg)
{
OPENFILENAMEA ofn;
CHAR FileBuffer[256] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.hwndOwner = hDlg;
ofn.lpstrFilter = "WAD Files\0*.wad\0All Files\0*.*\0\0";
ofn.lpstrInitialDir = NULL;
ofn.lpstrFile = FileBuffer;
ofn.lStructSize = sizeof(ofn);
ofn.nMaxFile = sizeof(FileBuffer);
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if (GetOpenFileNameA(&ofn))
ReadWADLumps(FileBuffer, hDlg);
}
static inline VOID PlayLump(HWND hDlg)
{
HWND listbox = GetDlgItem(hDlg, IDC_PLAYLIST);
LRESULT cursel = SendMessage(listbox, LB_GETCURSEL, 0, 0);
/* Start of C_EXTRACT */
CHAR argv[9];
SendMessage(listbox, LB_GETTEXT, cursel, (LPARAM)(LPCSTR)argv);
/* Extract LUMPNAME FILENAME pairs */
if (wfptr)
{
struct lumplist *extracted;
printf("Extracting lump %s...\n", argv);
/* Find the lump to extract */
extracted = find_previous_lump(wfptr->head, NULL, argv);
if (extracted == NULL || (extracted = extracted->next) == NULL)
return;
/* Extract lump */
M_StartFMODSong(extracted->cl->data, extracted->cl->len, FALSE, hDlg);
/* end of extracting LUMPNAME FILENAME pairs */
} /* end of C_EXTRACT */
return;
}
static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hWnd, message, wParam, lParam);
}
static INT_PTR CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
M_InitMusic();
break;
case WM_CLOSE:
EndDialog(hDlg, message);
break;
case WM_DESTROY:
FreeWADLumps();
M_ShutdownMusic();
break;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case 2:
EndDialog(hDlg, message);
return TRUE;
case IDC_ABOUT: // The About button.
{
char TempString[256];
sprintf(TempString, "%s %s by %s - %s", APPTITLE, APPVERSION, APPAUTHOR, APPCOMPANY);
MessageBoxA(hDlg, TempString, "About", MB_OK|MB_APPLMODAL);
}
return TRUE;
case IDC_OPEN:
OpenWadfile(hDlg);
return TRUE;
case IDC_PLAY:
PlayLump(hDlg);
return TRUE;
default:
break;
}
break;
}
}
return FALSE;
}
static inline VOID RegisterDialogClass(LPCSTR name, WNDPROC callback, HINSTANCE hInst)
{
WNDCLASSA wnd;
wnd.style = CS_HREDRAW | CS_VREDRAW;
wnd.cbWndExtra = DLGWINDOWEXTRA;
wnd.cbClsExtra = 0;
wnd.hCursor = LoadCursorA(NULL,(LPCSTR)MAKEINTRESOURCE(IDC_ARROW));
wnd.hIcon = LoadIcon(NULL,MAKEINTRESOURCE(IDI_ICON1));
wnd.hInstance = hInst;
wnd.lpfnWndProc = callback;
wnd.lpszClassName = name;
wnd.lpszMenuName = NULL;
wnd.hbrBackground = (HBRUSH)(COLOR_WINDOW);
if (!RegisterClassA(&wnd))
{
return;
}
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// Prevent multiples instances of this app.
CreateMutexA(NULL, TRUE, APPTITLE);
if (GetLastError() == ERROR_ALREADY_EXISTS)
return 0;
RegisterDialogClass("SRB2MP", MainWndproc, hInstance);
DialogBoxA(hInstance, (LPCSTR)IDD_MAIN, NULL, DialogProc);
return 0;
}

View file

@ -1,148 +0,0 @@
# Microsoft Developer Studio Project File - Name="SRB2MP" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=SRB2MP - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "SRB2MP.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "SRB2MP.mak" CFG="SRB2MP - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "SRB2MP - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "SRB2MP - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "SRB2MP - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fmodvc.lib /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "SRB2MP - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib fmodvc.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "SRB2MP - Win32 Release"
# Name "SRB2MP - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\lump.c
# End Source File
# Begin Source File
SOURCE=.\SRB2MP.c
# End Source File
# Begin Source File
SOURCE=.\StdAfx.c
# ADD CPP /Yc"stdafx.h"
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\lump.h
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\icon1.ico
# End Source File
# Begin Source File
SOURCE=.\icon2.ico
# End Source File
# Begin Source File
SOURCE=.\icon3.ico
# End Source File
# Begin Source File
SOURCE=.\Script1.rc
# End Source File
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project

View file

@ -1,29 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "SRB2MP"=.\SRB2MP.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

Binary file not shown.

View file

@ -1,118 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOG DISCARDABLE 0, 0, 262, 170
STYLE DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "SRB2 Music Player"
FONT 8, "MS Sans Serif"
BEGIN
PUSHBUTTON "E&xit",IDCANCEL,205,145,50,19
PUSHBUTTON "&About",IDC_ABOUT,230,15,23,10
LISTBOX IDC_WADLIST,5,30,112,110,LBS_SORT | LBS_NOINTEGRALHEIGHT |
WS_VSCROLL | WS_TABSTOP
LISTBOX IDC_PLAYLIST,140,30,114,110,LBS_SORT |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "&Play",IDC_PLAY,140,145,60,20
PUSHBUTTON "->",IDC_ADD,120,35,15,15
PUSHBUTTON "<-",IDC_REMOVE,120,55,15,15
PUSHBUTTON "&Open WAD...",IDC_OPEN,5,10,50,15
ICON IDI_ICON1,IDC_STATIC,205,5,20,20
LTEXT "Title:",IDC_TITLE,5,140,125,10
LTEXT "By:",IDC_ARTIST,5,150,125,15
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 255
TOPMARGIN, 7
BOTTOMMARGIN, 163
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON DISCARDABLE "icon1.ico"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -1,8 +0,0 @@
// stdafx.cpp : source file that includes just the standard includes
// SRB2MP.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "StdAfx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

View file

@ -1,35 +0,0 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
//#define UNICODE
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <commdlg.h>
// TODO: reference additional headers your program requires here
#ifdef __MINGW32__
#include <FMOD/fmod.h>
#include <FMOD/fmod_errors.h>
#else
#include <fmod.h>
#include <fmod_errors.h>
#endif
#include "resource.h"
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -1,471 +0,0 @@
/*
LumpMod v0.21, a command-line utility for working with lumps in wad files.
Copyright (C) 2003 Thunder Palace Entertainment.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
lump.c: Provides functions for dealing with lumps
*/
#include "StdAfx.h"
#include <string.h>
#include <ctype.h>
#include "lump.h"
/* Read contents of a wad file and store them in memory.
* fpoint is the file to read, opened with "rb" mode.
* A pointer to a new wadfile struct will be returned, or NULL on error.
*/
struct wadfile *read_wadfile(FILE *fpoint) {
struct wadfile *wfptr;
struct lumplist *curlump;
unsigned long diroffset, filelen;
unsigned long count;
/* Allocate memory for wadfile struct */
wfptr = (struct wadfile*)malloc(sizeof(struct wadfile));
if(wfptr == NULL) return NULL;
/* Read first four characters (PWAD or IWAD) */
if(fread(wfptr->id, 4, 1, fpoint) < 1) {
free(wfptr);
return NULL;
}
/* Read number of lumps */
if(fread(&(wfptr->numlumps), 4, 1, fpoint) < 1) {
free(wfptr);
return NULL;
}
/* If number of lumps is zero, nothing more needs to be done */
if(wfptr->numlumps == 0) {
wfptr->head = NULL;
return wfptr;
}
/* Read offset of directory */
if(fread(&diroffset, 4, 1, fpoint) < 1) {
free(wfptr);
return NULL;
}
/* Verify that the directory as long as it needs to be */
fseek(fpoint, 0, SEEK_END);
filelen = ftell(fpoint);
if((filelen - diroffset) / DIRENTRYLEN < wfptr->numlumps) {
free(wfptr);
return NULL;
}
/* Allocate memory for head lumplist item and set head pointer */
curlump = (struct lumplist*)malloc(sizeof(struct lumplist));
if(curlump == NULL) {
free(wfptr);
return NULL;
}
wfptr->head = curlump;
curlump->cl = NULL;
/* Read directory entries and lumps */
for(count = 0; count < wfptr->numlumps; count++) {
long lumpdataoffset;
/* Advance to a new list item */
curlump->next = (struct lumplist*)malloc(sizeof(struct lumplist));
if(curlump->next == NULL) {
free_wadfile(wfptr);
return NULL;
}
curlump = curlump->next;
curlump->next = NULL;
/* Allocate memory for the lump info */
curlump->cl = (struct lump*)malloc(sizeof(struct lump));
if(curlump->cl == NULL) {
free_wadfile(wfptr);
return NULL;
}
/* Seek to the proper position in the file */
if(fseek(fpoint, diroffset + (count * DIRENTRYLEN), SEEK_SET) != 0) {
free_wadfile(wfptr);
return NULL;
}
/* Read offset of lump data */
if(fread(&lumpdataoffset, 4, 1, fpoint) < 1) {
free_wadfile(wfptr);
return NULL;
}
/* Read size of lump in bytes */
if(fread(&(curlump->cl->len), 4, 1, fpoint) < 1) {
free_wadfile(wfptr);
return NULL;
}
/* Read lump name */
if(fread(curlump->cl->name, 8, 1, fpoint) < 1) {
free_wadfile(wfptr);
return NULL;
}
/* Read actual lump data, unless lump size is 0 */
if(curlump->cl->len > 0) {
if(fseek(fpoint, lumpdataoffset, SEEK_SET) != 0) {
free_wadfile(wfptr);
return NULL;
}
/* Allocate memory for data */
curlump->cl->data = (unsigned char*)malloc(curlump->cl->len);
if(curlump->cl->data == NULL) {
free_wadfile(wfptr);
return NULL;
}
/* Fill the data buffer */
if(fread(curlump->cl->data, curlump->cl->len, 1, fpoint) < 1) {
free_wadfile(wfptr);
return NULL;
}
} else curlump->cl->data = NULL;
} /* End of directory reading loop */
return wfptr;
}
/* Free a wadfile from memory as well as all related structures.
*/
void free_wadfile(struct wadfile *wfptr) {
struct lumplist *curlump, *nextlump;
if(wfptr == NULL) return;
curlump = wfptr->head;
/* Free items in the lump list */
while(curlump != NULL) {
/* Free the actual lump and its data, if necessary */
if(curlump->cl != NULL) {
if(curlump->cl->data != NULL) free(curlump->cl->data);
free(curlump->cl);
}
/* Advance to next lump and free this one */
nextlump = curlump->next;
free(curlump);
curlump = nextlump;
}
free(wfptr);
}
/* Write complete wadfile to a file stream, opened with "wb" mode.
* fpoint is the stream to write to.
* wfptr is a pointer to the wadfile structure to use.
* Return zero on success, nonzero on failure.
*/
int write_wadfile(FILE *fpoint, struct wadfile *wfptr) {
struct lumplist *curlump;
long lumpdataoffset, diroffset;
if(wfptr == NULL) return 1;
/* Write four-character ID ("PWAD" or "IWAD") */
if(fwrite(wfptr->id, 4, 1, fpoint) < 1) return 2;
/* Write number of lumps */
if(fwrite(&(wfptr->numlumps), 4, 1, fpoint) < 1) return 3;
/* Offset of directory is not known yet. For now, write number of lumps
* again, just to fill the space.
*/
if(fwrite(&(wfptr->numlumps), 4, 1, fpoint) < 1) return 4;
/* Loop through lump list, writing lump data */
for(curlump = wfptr->head; curlump != NULL; curlump = curlump->next) {
/* Don't write anything for the head of the lump list or for lumps of
zero length */
if(curlump->cl == NULL || curlump->cl->data == NULL) continue;
/* Write the data */
if(fwrite(curlump->cl->data, curlump->cl->len, 1, fpoint) < 1)
return 5;
}
/* Current position is where directory will start */
diroffset = ftell(fpoint);
/* Offset for the first lump's data is always 12 */
lumpdataoffset = 12;
/* Loop through lump list again, this time writing directory entries */
for(curlump = wfptr->head; curlump != NULL; curlump = curlump->next) {
/* Don't write anything for the head of the lump list */
if(curlump->cl == NULL) continue;
/* Write offset for lump data */
if(fwrite(&lumpdataoffset, 4, 1, fpoint) < 1) return 6;
/* Write size of lump data */
if(fwrite(&(curlump->cl->len), 4, 1, fpoint) < 1) return 7;
/* Write lump name */
if(fwrite(curlump->cl->name, 8, 1, fpoint) < 1) return 8;
/* Increment lumpdataoffset variable as appropriate */
lumpdataoffset += curlump->cl->len;
}
/* Go back to header and write the proper directory offset */
fseek(fpoint, 8, SEEK_SET);
if(fwrite(&diroffset, 4, 1, fpoint) < 1) return 9;
return 0;
}
/* Get the name of a lump, as a null-terminated string.
* item is a pointer to the lump (not lumplist) whose name will be obtained.
* Return NULL on error.
*/
char *get_lump_name(struct lump *item) {
char convname[9], *retname;
if(item == NULL) return NULL;
memcpy(convname, item->name, 8);
convname[8] = '\0';
retname = (char*)malloc(strlen(convname) + 1);
if(retname != NULL) strcpy(retname, convname);
return retname;
}
/* Find the lump after start and before end having a certain name.
* Return a pointer to the list item for that lump, or return NULL if no lump
* by that name is found or lumpname is too long.
* lumpname is a null-terminated string.
* If end parameter is NULL, search to the end of the entire list.
*/
struct lumplist *find_previous_lump(struct lumplist *start, struct lumplist
*end, char *lumpname) {
struct lumplist *curlump, *lastlump;
char *curname;
int found = 0;
/* Verify that parameters are valid */
if(start==NULL || start==end || lumpname==NULL || strlen(lumpname) > 8)
return NULL;
/* Loop through the list from start parameter */
lastlump = start;
for(curlump = start->next; curlump != end && curlump != NULL;
curlump = curlump->next) {
/* Skip header lump */
if(curlump->cl == NULL) continue;
/* Find name of this lump */
curname = get_lump_name(curlump->cl);
if(curname == NULL) continue;
/* Compare names to see if this is the lump we want */
if(strcmp(curname, lumpname) == 0) {
found = 1;
break;
}
/* Free memory allocated to curname */
free(curname);
lastlump = curlump;
}
if(found) return lastlump;
return NULL;
}
/* Remove a lump from the list, free it, and free its data.
* before is the lump immediately preceding the lump to be removed.
* wfptr is a pointer to the wadfile structure to which the removed lump
* belongs, so that numlumps can be decreased.
*/
void remove_next_lump(struct wadfile *wfptr, struct lumplist *before) {
struct lumplist *removed;
/* Verify that parameters are valid */
if(before == NULL || before->next == NULL || wfptr == NULL) return;
/* Update linked list to omit removed lump */
removed = before->next;
before->next = removed->next;
/* Free lump info and data if necessary */
if(removed->cl != NULL) {
if(removed->cl->data != NULL) free(removed->cl->data);
free(removed->cl);
}
free(removed);
/* Decrement numlumps */
wfptr->numlumps--;
}
/* Add a lump.
* The lump will follow prev in the list and be named name, with a data size
* of len.
* A copy will be made of the data.
* Return zero on success or nonzero on failure.
*/
int add_lump(struct wadfile *wfptr, struct lumplist *prev, char *name, long
len, unsigned char *data) {
struct lump *newlump;
struct lumplist *newlumplist;
unsigned char *copydata;
/* Verify that parameters are valid */
if(wfptr == NULL || prev == NULL || name == NULL || strlen(name) > 8)
return 1;
/* Allocate space for newlump and newlumplist */
newlump = (struct lump*)malloc(sizeof(struct lump));
newlumplist = (struct lumplist*)malloc(sizeof(struct lumplist));
if(newlump == NULL || newlumplist == NULL) return 2;
/* Copy lump data and set up newlump */
if(len == 0 || data == NULL) {
newlump->len = 0;
newlump->data = NULL;
} else {
newlump->len = len;
copydata = (unsigned char*)malloc(len);
if(copydata == NULL) return 3;
memcpy(copydata, data, len);
newlump->data = copydata;
}
/* Set name of newlump */
memset(newlump->name, '\0', 8);
if(strlen(name) == 8) memcpy(newlump->name, name, 8);
else strcpy(newlump->name, name);
/* Set up newlumplist and alter prev appropriately */
newlumplist->cl = newlump;
newlumplist->next = prev->next;
prev->next = newlumplist;
/* Increment numlumps */
wfptr->numlumps++;
return 0;
}
/* Rename a lump.
* renamed is a pointer to the lump (not lumplist) that needs renaming.
* newname is a null-terminated string with the new name.
* Return zero on success or nonzero on failure.
*/
int rename_lump(struct lump *renamed, char *newname) {
/* Verify that parameters are valid. */
if(newname == NULL || renamed == NULL || strlen(newname) > 8) return 1;
/* Do the renaming. */
memset(renamed->name, '\0', 8);
if(strlen(newname) == 8) memcpy(renamed->name, newname, 8);
else strcpy(renamed->name, newname);
return 0;
}
/* Find the last lump in a wadfile structure.
* Return this lump or NULL on failure.
*/
struct lumplist *find_last_lump(struct wadfile *wfptr) {
struct lumplist *curlump;
if(wfptr == NULL || wfptr->head == NULL) return NULL;
curlump = wfptr->head;
while(curlump->next != NULL) curlump = curlump->next;
return curlump;
}
/* Find the last lump between start and end.
* Return this lump or NULL on failure.
*/
struct lumplist *find_last_lump_between(struct lumplist *start, struct
lumplist *end) {
struct lumplist *curlump;
if(start == NULL) return NULL;
curlump = start;
while(curlump->next != end) {
curlump = curlump->next;
if(curlump == NULL) break;
}
return curlump;
}
/* Find the next section lump. A section lump is MAPxx (0 <= x <= 9), ExMy
* (0 <= x <= 9, 0 <= y <= 9), or any lump whose name ends in _START or _END.
* Return NULL if there are no section lumps after start.
*/
struct lumplist *find_next_section_lump(struct lumplist *start) {
struct lumplist *curlump, *found = NULL;
char *curname;
/* Verify that parameter is valid */
if(start == NULL || start->next == NULL) return NULL;
/* Loop through the list from start parameter */
for(curlump = start->next; curlump != NULL && found == NULL;
curlump = curlump->next) {
/* Skip header lump */
if(curlump->cl == NULL) continue;
/* Find name of this lump */
curname = get_lump_name(curlump->cl);
if(curname == NULL) continue;
/* Check to see if this is a section lump */
if(strlen(curname) == 5 && strncmp("MAP", curname, 3) == 0 &&
isdigit(curname[3]) && isdigit(curname[4]))
found = curlump;
else if(strlen(curname) == 4 && curname[0] == 'E' && curname[2] ==
'M' && isdigit(curname[1]) && isdigit(curname[3]))
found = curlump;
else if(strlen(curname) == 7 && strcmp("_START", &curname[1]) == 0)
found = curlump;
else if(strlen(curname) == 8 && strcmp("_START", &curname[2]) == 0)
found = curlump;
else if(strlen(curname) == 5 && strcmp("_END", &curname[1]) == 0)
found = curlump;
else if(strlen(curname) == 6 && strcmp("_END", &curname[2]) == 0)
found = curlump;
/* Free memory allocated to curname */
free(curname);
}
return found;
}

View file

@ -1,61 +0,0 @@
/*
LumpMod v0.21, a command-line utility for working with lumps in wad files.
Copyright (C) 2003 Thunder Palace Entertainment.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
lump.h: Defines constants, structures, and functions used in lump.c
*/
#ifndef __LUMP_H
#define __LUMP_H
/* Entries in the wadfile directory are 16 bytes */
#define DIRENTRYLEN 16
/* Lumps and associated info */
struct lump {
long len;
unsigned char *data;
char name[8];
};
/* Linked list of lumps */
struct lumplist {
struct lump *cl; /* actual content of the lump */
struct lumplist *next;
};
/* Structure to contain all wadfile data */
struct wadfile {
char id[4]; /* IWAD or PWAD */
unsigned long numlumps; /* 32-bit integer */
struct lumplist *head; /* points to first entry */
};
/* Function declarations */
struct wadfile *read_wadfile(FILE *);
void free_wadfile(struct wadfile *);
int write_wadfile(FILE *, struct wadfile *);
char *get_lump_name(struct lump *);
struct lumplist *find_previous_lump(struct lumplist *, struct lumplist *, char *);
void remove_next_lump(struct wadfile *, struct lumplist *);
int add_lump(struct wadfile *, struct lumplist *, char *, long, unsigned char *);
int rename_lump(struct lump *, char *);
struct lumplist *find_last_lump(struct wadfile *);
struct lumplist *find_last_lump_between(struct lumplist *, struct lumplist *);
struct lumplist *find_next_section_lump(struct lumplist *);
#endif

View file

@ -1,26 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Script1.rc
//
#define IDD_MAIN 101
#define IDI_ICON1 102
#define IDC_ABOUT 1000
#define IDC_WADLIST 1001
#define IDC_PLAYLIST 1002
#define IDC_PLAY 1003
#define IDC_ADD 1004
#define IDC_REMOVE 1005
#define IDC_OPEN 1006
#define IDC_TITLE 1007
#define IDC_ARTIST 1008
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1009
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif