Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .gitignore

This file was deleted.

23 changes: 23 additions & 0 deletions MSWindows/exe_header.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
1 VERSIONINFO
FILEVERSION 0,1,0,0
PRODUCTVERSION 0,1,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904E4"
BEGIN
VALUE "CompanyName", "jc_reborn"
VALUE "FileDescription", "JC Reborn Windows Screen Saver"
VALUE "FileVersion", "0.1"
VALUE "InternalName", "jc_reborn"
VALUE "LegalCopyright", ""
VALUE "OriginalFilename", "jc_reborn.exe"
VALUE "ProductName", "JC Reborn"
VALUE "ProductVersion", "0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x809, 1252
END
END
1 change: 1 addition & 0 deletions MSWindows/icon.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jc_reborn_icon ICON "jc_reborn.ico"
81 changes: 81 additions & 0 deletions MSWindows/jc_reboen.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Language="1033"
Manufacturer="Jérémie Guillaume"
Name="JC Reborn"
UpgradeCode="36c19eaf-0929-46a4-b239-7bc8185605f2"
Version="1.0.0.0"
Codepage="UTF-8" >

<Package InstallScope="perMachine" Compressed="yes" />

<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />

<MediaTemplate EmbedCab="yes" />

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="WindowsFolder" />
<Directory Id="SIERRASCRANTIC" FileSource="will_be_overwritten_by_setdirectory">
<Component Id="ResourceFiles" Guid="c069467b-289e-4a86-bb01-74ed3e62b0ec">
<File Id="resource_001" Source="RESOURCE.001" />
<File Id="resource_map" Source="RESOURCE.map" />
<File Id="sound0_wav" Source="sound0.wav" />
<File Id="sound1_wav" Source="sound1.wav" />
<File Id="sound2_wav" Source="sound2.wav" />
<File Id="sound3_wav" Source="sound3.wav" />
<File Id="sound4_wav" Source="sound4.wav" />
<File Id="sound5_wav" Source="sound5.wav" />
<File Id="sound6_wav" Source="sound6.wav" />
<File Id="sound7_wav" Source="sound7.wav" />
<File Id="sound8_wav" Source="sound8.wav" />
<File Id="sound9_wav" Source="sound9.wav" />
<File Id="sound10_wav" Source="sound10.wav" />
<File Id="sound12_wav" Source="sound12.wav" />
<File Id="sound14_wav" Source="sound14.wav" />
<File Id="sound15_wav" Source="sound15.wav" />
<File Id="sound16_wav" Source="sound16.wav" />
<File Id="sound17_wav" Source="sound17.wav" />
<File Id="sound18_wav" Source="sound18.wav" />
<File Id="sound19_wav" Source="sound19.wav" />
<File Id="sound20_wav" Source="sound20.wav" />
<File Id="sound21_wav" Source="sound21.wav" />
<File Id="sound22_wav" Source="sound22.wav" />
<File Id="sound23_wav" Source="sound23.wav" />
<File Id="sound24_wav" Source="sound24.wav" />
<CreateFolder />
</Component>
</Directory>
</Directory>

<SetDirectory Id="SIERRASCRANTIC" Value="[WindowsVolume]\SIERRA\SCRANTIC" />

<Feature Id="JCInstaller">
<ComponentRef Id="scr" />
<ComponentRef Id="sdl2" />
<ComponentRef Id="ResourceFiles" />
</Feature>

<Icon Id="icon_ico" SourceFile="MSWindows\jc_reborn.ico"/>

<Property Id="ARPPRODUCTICON" Value="icon_ico" />

<CustomAction Id="ShowScreenSaverSettings" Directory="WindowsFolder" Execute="commit" Impersonate="yes" ExeCommand="cmd.exe /c &quot;control desk.cpl,,@screensaver&quot;" Return="asyncNoWait" />

<InstallExecuteSequence>
<Custom Action="ShowScreenSaverSettings" After="InstallInitialize" />
</InstallExecuteSequence>

</Product>

<Fragment>
<ComponentGroup Id="ProductComponents" Directory="WindowsFolder">
<Component Id="scr" Guid="C0F4841E-092E-4952-962C-891BBB93F410">
<File Id="jc_reborn.scr" Source="jc_reborn.scr" KeyPath="yes" />
</Component>
<Component Id="sdl2" Guid="9D26DA33-34AD-491A-B2F4-C2DB829EE605">
<File Id="SDL2.dll" Source="SDL2.dll" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Binary file added MSWindows/jc_reborn.ico
Binary file not shown.
12 changes: 9 additions & 3 deletions Makefile.MinGW
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
$(shell windres MSWindows\icon.rc -O coff -o icon.res)
$(shell windres MSWindows\exe_header.rc -O coff -o exe_header.res)

CFLAGS=-I/include/ -Wall --std=c99
Copy link
Owner

Choose a reason for hiding this comment

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

Normally MinGW maps windows paths to unix-like ones. Using native Windows paths shouldn't be necessary ...

CC = "C:\MinGW\bin\gcc.exe"

LDFLAGS=-L/lib/ -mwindows
CFLAGS=-IC:\MinGW\include\ -Wall --std=c99 -g3

LDFLAGS=-LC:\MinGW\include\lib\ -mwindows

LDLIBS=-lmingw32 -lSDL2main -lSDL2

Expand All @@ -22,7 +26,9 @@ OBJ = jc_reborn.o \
graphics.o \
sound.o \
events.o \
config.o
config.o \
icon.res \
exe_header.res
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe a minor indentation issue here ? (spaces vs tabs)



all: $(EXE)
Expand Down
77 changes: 77 additions & 0 deletions WindowsInstallerBuild.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
@ECHO OFF
ECHO Checking prerequisites
IF "%WIX%"=="" GOTO NOWIX
echo %path% | FINDSTR /c:"MinGW" >nul
IF ERRORLEVEL 1 GOTO NOMINGW
IF NOT EXIST "Makefile" GOTO NOMAKEFILE
for %%x in (
SDL2.dll
RESOURCE.001
RESOURCE.MAP
sound0.wav
sound1.wav
sound3.wav
sound4.wav
sound5.wav
sound6.wav
sound7.wav
sound8.wav
sound9.wav
sound10.wav
sound12.wav
sound14.wav
sound15.wav
sound16.wav
sound17.wav
sound18.wav
sound19.wav
sound2.wav
sound20.wav
sound21.wav
sound22.wav
sound23.wav
sound24.wav
) do (
SET filename=%%x
IF NOT EXIST %%x GOTO FILEMISSING
)

ECHO building
REM Run ordinary make
make
IF ERRORLEVEL 1 GOTO MAKEERROR
IF EXIST "jc_reborn.scr" DEL jc_reborn.scr
RENAME jc_reborn.exe jc_reborn.scr

ECHO Creating MSI
"%WIX%\bin\candle" MSWindows\*.wxs -o MSWindows\obj\
IF ERRORLEVEL 1 GOTO CANDLEERROR
"%WIX%\bin\light" MSWindows\obj\*.wixobj -o jc_reborn.msi
IF ERRORLEVEL 1 GOTO LIGHTERROR
echo Done, you can now install from jc_reborn.msi
GOTO :EOF

:NOWIX
ECHO ERROR: Could not find WiX Toolset
GOTO :EOF

:NOMINGW
ECHO ERROR: Could not find MinGW, mare sure it's in the PATH
GOTO :EOF

:NOMAKEFILE
ECHO ERROR: Please rename Makefile.MinGW to MakeFile
GOTO :EOF

:MAKEERROR
ECHO ERROR: Build failed
GOTO :EOF

:FILEMISSING
ECHO ERROR: %filename% not found

:CANDLEERROR
ECHO ERROR: compiling WiX installer WXS file

:LIGHTERROR
ECHO ERROR: assembling MSI
35 changes: 27 additions & 8 deletions jc_reborn.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@
#include "story.h"


static int argDump = 0;
static int argBench = 0;
static int argTtm = 0;
static int argAds = 0;
static int argPlayAll = 0;
static int argIsland = 0;
static int argDump = 0;
static int argBench = 0;
static int argTtm = 0;
static int argAds = 0;
static int argPlayAll = 0;
static int argIsland = 0;
static int argRun = 1;


static char *args[3];
static int numArgs = 0;


static void usage()
{
printf("\n");
Expand Down Expand Up @@ -135,6 +136,20 @@ static void parseArgs(int argc, char **argv)
else if (!strcmp(argv[i], "hotkeys")) {
evHotKeysEnabled = 1;
}
#ifdef _WIN32
else if (argc == 0) {
argRun = 0; // Settings window not supported
}
else if (!strcmp(argv[i], "/c")) {
argRun = 0; // Modal settings window not supported
}
else if (!strcmp(argv[i], "/p")) {
argRun = 0; // Preview window not supported
}
else if (!strcmp(argv[i], "/s")) {
argRun = 1; // Run screen saver
}
#endif
}
}

Expand All @@ -148,11 +163,15 @@ static void parseArgs(int argc, char **argv)
argPlayAll = 1;
}


int main(int argc, char **argv)
{
parseArgs(argc, argv);

if (!argRun) // Windows screen saver mode, do not run screen saver
{
return;
}

if (argDump)
debugMode = 1;

Expand Down
19 changes: 12 additions & 7 deletions resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ int numTtmResources = 0;

static struct TMapFile mapFile;


static struct TAdsResource *parseAdsResource(FILE *f)
{
struct TAdsResource *adsResource;
uint8 *buffer;


adsResource = safe_malloc(sizeof(struct TAdsResource));

buffer = readUint8Block(f,4);
Expand Down Expand Up @@ -343,10 +341,14 @@ static void parseMapFile(char *fileName)
{
FILE *f_map; // , *f_res; // TODO

f_map = fopen(fileName,"rb");
char *mapFilePath = concat(resourceDirectory, fileName);

f_map = fopen(mapFilePath,"rb");

if (f_map == NULL)
fatalError("Resources map file not found: %s\n", fileName);
fatalError("Resources map file not found: %s\n", mapFilePath);

free(mapFilePath);

mapFile.unknown1 = readUint8(f_map); // first 5 uint8s unknown
mapFile.unknown2 = readUint8(f_map);
Expand All @@ -369,15 +371,18 @@ static void parseMapFile(char *fileName)
fclose(f_map);
}


static void parseResourceFile(char * filename)
{
FILE *f;

f = fopen(mapFile.resFileName,"rb");
char* resourceFilePath = concat(resourceDirectory, mapFile.resFileName);

f = fopen(resourceFilePath, "rb");

if (f == NULL)
fatalError("Main resources file not found: %s\n", mapFile.resFileName);
fatalError("Main resources file not found: %s\n", resourceFilePath);

free(resourceFilePath);

if (debugMode) {
printf("Loading resources ");
Expand Down
8 changes: 8 additions & 0 deletions resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,11 @@ struct TBmpResource *findBmpResource(char *searchString);
struct TScrResource *findScrResource(char *searchString);
struct TTtmResource *findTtmResource(char *searchString);

//----------------------------
// Constants
//----------------------------
#ifdef _WIN32
static char *resourceDirectory = "C:\\SIERRA\\SCRANTIC\\";
#else
static char *resourceDirectory = "";
#endif
8 changes: 5 additions & 3 deletions sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "mytypes.h"
#include "utils.h"
#include "sound.h"

#include "resource.h"

#define NUM_OF_SOUNDS 25

Expand Down Expand Up @@ -80,14 +80,16 @@ void soundInit()
for (int i=0; i < NUM_OF_SOUNDS; i++) {

char filename[20];

sprintf(filename, "sound%d.wav", i);

if (SDL_LoadWAV(filename, &audioSpec, &sounds[i].data, &sounds[i].length) == NULL) {
char *resourceFile = concat(resourceDirectory, filename);

if (SDL_LoadWAV(resourceFile, &audioSpec, &sounds[i].data, &sounds[i].length) == NULL) {
sounds[i].data = NULL;
sounds[i].length = 0;
debugMsg("SDL_LoadWAV() warning: %s", SDL_GetError());
}
free(resourceFile);
}

audioSpec.callback = soundCallback;
Expand Down
8 changes: 8 additions & 0 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,11 @@ char *getMonthAndDay()
return result;
}

char* concat(char *str1, char *str2)
{
int length = strlen(str1) + strlen(str2) + 1;
char* str = safe_malloc(length);
strcpy(str,str1);
strcat(str,str2);
return str;
}
1 change: 1 addition & 0 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ void hexdump(uint8 *data, uint32 len);
int getDayOfYear();
int getHour();
char *getMonthAndDay();
char* concat(char *str1, char *str2);
Copy link
Owner

Choose a reason for hiding this comment

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

indentation issue here, too