Skip to content

Commit 4782ebc

Browse files
committed
MegaZeux 2.80c release.
1 parent 75617b7 commit 4782ebc

36 files changed

Lines changed: 1218 additions & 414 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ OBJS = main.o graphics.o window.o hexchar.o event.o \
1010

1111
PREFIX = /usr
1212

13-
BIN = mzx280b.exe
13+
BIN = mzx280c.exe
1414

1515
CC = gcc
1616
CPP = g++

Makefile.linux

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ OBJS = main.o graphics.o window.o hexchar.o event.o \
66
idarray.o delay.o game2.o expr.o sprite.o runrobo2.o \
77
mzm.o decrypt.o audio.o edit.o edit_di.o block.o \
88
char_ed.o pal_ed.o param.o sfx_edit.o fill.o rasm.o \
9-
robo_ed.o configure.o
9+
robo_ed.o configure.o fsafeopen.o
1010

1111
PREFIX = /usr
1212

13-
BIN = mzx280b
13+
BIN = mzx280c
1414

1515
CC = gcc
1616
CPP = g++

audio.cpp

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "data.h"
3737
#include "configure.h"
3838
#include "gdm2s3m.h"
39+
#include "fsafeopen.h"
3940

4041
struct _ModPlugFile
4142
{
@@ -72,8 +73,8 @@ void audio_callback(void *userdata, Uint8 *stream, int len)
7273
// Reset position
7374
audio.current_mod->mSoundFile.SetCurrentPos(0);
7475
// Read anew remaining bytes
75-
ModPlug_Read(audio.current_mod, audio.mod_buffer + read_len,
76-
len - read_len);
76+
ModPlug_Read(audio.current_mod, audio.mod_buffer + read_len,
77+
len - read_len);
7778
}
7879
}
7980
else
@@ -232,10 +233,42 @@ void init_audio(config_info *conf)
232233
NULL
233234
};
234235

236+
if(conf->oversampling_on)
237+
{
238+
audio.mod_settings.mFlags = MODPLUG_ENABLE_OVERSAMPLING;
239+
}
240+
235241
audio.mod_settings.mFrequency = 44100;
236242
audio.mod_settings.mChannels = 2;
237243
audio.mod_settings.mBits = 16;
238-
audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_LINEAR;
244+
245+
switch(conf->resampling_mode)
246+
{
247+
case 0:
248+
{
249+
audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_NEAREST;
250+
break;
251+
}
252+
253+
case 1:
254+
{
255+
audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_LINEAR;
256+
break;
257+
}
258+
259+
case 2:
260+
{
261+
audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_SPLINE;
262+
break;
263+
}
264+
265+
case 3:
266+
{
267+
audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_FIR;
268+
break;
269+
}
270+
}
271+
239272
audio.mod_settings.mLoopCount = -1;
240273

241274
ModPlug_SetSettings(&audio.mod_settings);
@@ -252,20 +285,23 @@ void load_mod(char *filename)
252285
char *input_buffer;
253286
int file_size;
254287
int extension_pos = strlen(filename) - 4;
255-
char new_file[256];
288+
char new_file[MAX_PATH];
256289

257290
if(extension_pos && !strcasecmp(filename + extension_pos, ".gdm"))
258291
{
259-
struct stat file_info;
292+
char translated_filename_src[MAX_PATH];
293+
char translated_filename_dest[MAX_PATH];
260294

261295
// GDM -> S3M
262296
strcpy(new_file, filename);
263297
memcpy(new_file + extension_pos, ".s3m", 4);
264298

265-
if(stat(new_file, &file_info))
299+
fsafetranslate(filename, translated_filename_src);
300+
301+
if(fsafetranslate(new_file, translated_filename_dest) < 0)
266302
{
267303
// If it doesn't exist, create it by converting.
268-
convert_gdm_s3m(filename, new_file);
304+
convert_gdm_s3m(translated_filename_src, new_file);
269305
}
270306

271307
filename = new_file;
@@ -274,7 +310,7 @@ void load_mod(char *filename)
274310
if(audio.mod_playing)
275311
end_mod();
276312

277-
input_file = fopen(filename, "rb");
313+
input_file = fsafeopen(filename, "rb");
278314

279315
if(input_file)
280316
{
@@ -304,7 +340,6 @@ void end_mod(void)
304340

305341
void play_sample(int freq, char *filename)
306342
{
307-
struct stat file_info;
308343
FILE *input_file;
309344
char *input_buffer;
310345
int file_size;
@@ -313,23 +348,29 @@ void play_sample(int freq, char *filename)
313348

314349
// FIXME - destroy least recently used?
315350
if(audio.num_samples_playing >= MAX_SAMS)
316-
return;
351+
return;
317352

318-
if((extension_pos >= 0) && !strcasecmp(filename + extension_pos, ".sam"))
353+
if(extension_pos && !strcasecmp(filename + extension_pos, ".sam"))
319354
{
320-
// SAM -> WAV
355+
char translated_filename_src[MAX_PATH];
356+
char translated_filename_dest[MAX_PATH];
357+
358+
// GDM -> S3M
321359
strcpy(new_file, filename);
322360
memcpy(new_file + extension_pos, ".wav", 4);
323361

324-
if(stat(new_file, &file_info))
362+
fsafetranslate(filename, translated_filename_src);
363+
364+
if(fsafetranslate(new_file, translated_filename_dest) < 0)
325365
{
326-
// Create it
327-
convert_sam_to_wav(filename, new_file);
366+
// If it doesn't exist, create it by converting.
367+
convert_sam_to_wav(translated_filename_src, new_file);
328368
}
369+
329370
filename = new_file;
330371
}
331372

332-
input_file = fopen(filename, "rb");
373+
input_file = fsafeopen(filename, "rb");
333374

334375
if(input_file)
335376
{
@@ -344,31 +385,14 @@ void play_sample(int freq, char *filename)
344385

345386
if(sample_loaded)
346387
{
347-
int sample_length = sample_loaded->mSoundFile.Ins[1].nLength;
348-
349388
// A little hack to modify the pitch
350389
sample_loaded->mSoundFile.Ins[1].nC4Speed = (freq_conversion / freq) / 2;
351390
sample_loaded->mSoundFile.Ins[2].nC4Speed = (freq_conversion / freq) / 2;
352391
sample_loaded->mSoundFile.Ins[1].nVolume = (256 * sound_gvol) / 8;
353392
sample_loaded->mSoundFile.Ins[2].nVolume = (256 * sound_gvol) / 8;
354393

355-
// This number is pretty much obtained via experimentation. It can probably
356-
// stand to be a little higher.
357-
sample_length /= 110;
358-
359-
if(sample_length < 256)
360-
{
361-
sample_loaded->mSoundFile.Patterns[0][0].param = sample_length;
362-
sample_loaded->mSoundFile.Patterns[0][2].command = CMD_PATTERNBREAK;
363-
}
364-
else
365-
{
366-
int row_duration = sample_length / 255;
367-
sample_loaded->mSoundFile.Patterns[0][0].param = 255;
368-
if(row_duration < 62)
369-
sample_loaded->mSoundFile.Patterns[0][2 + row_duration].command =
370-
CMD_PATTERNBREAK;
371-
}
394+
// This number is pretty much obtained via experimentation. It can probably
395+
// stand to be a little higher.
372396

373397
// Find a free position to put it
374398
for(i = 0; i < 16; i++)
@@ -384,7 +408,7 @@ void play_sample(int freq, char *filename)
384408
}
385409

386410
free(input_buffer);
387-
fclose(input_file);
411+
fclose(input_file);
388412
}
389413
}
390414

@@ -567,4 +591,3 @@ void convert_sam_to_wav(char *source_name, char *dest_name)
567591
fclose(source);
568592
fclose(dest);
569593
}
570-

board.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ void load_board_direct(Board *cur_board, FILE *fp, int savegame)
201201
{
202202
cur_board->board_dir[i] = fgetc(fp);
203203
}
204+
204205
cur_board->restart_if_zapped = fgetc(fp);
205206
cur_board->time_limit = fgetw(fp);
206207
cur_board->last_key = fgetc(fp);
@@ -598,8 +599,8 @@ void save_RLE2_plane(char *plane, FILE *fp, int size)
598599
current_char = plane[i];
599600
runsize = 1;
600601

601-
while((plane[i + 1] == current_char) && (runsize < 127) &&
602-
(i < (size - 1)))
602+
while((i < (size - 1)) && (plane[i + 1] == current_char) &&
603+
(runsize < 127))
603604
{
604605
i++;
605606
runsize++;

board.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct _Board
3232
{
3333
int size;
3434

35-
char board_name[BOARD_NAME_SIZE];
35+
char board_name[32];
3636

3737
int board_width;
3838
int board_height;
@@ -47,7 +47,7 @@ struct _Board
4747
char *overlay;
4848
char *overlay_color;
4949

50-
char mod_playing[FILENAME_SIZE];
50+
char mod_playing[256];
5151
int viewport_x;
5252
int viewport_y;
5353
int viewport_width;

build.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ Next, you need the correct libraries installed, which are the
1010

1111
SDL: http://www.libsdl.org/
1212

13-
libmodplug: http://sourceforge.net/projects/libmodplug/
13+
libmodplug: http://prdownloads.sourceforge.net/modplug-xmms/
1414

1515
gdm2s3m: http://mzx.bitpack.net/gdm2s3m-1.1.tar.gz
1616
(should also show up on other sites soon)
1717

18+
NOTE: As of this writing, libmodplug (version 0.7) has a bug that
19+
doesn't allow it to correctly load 2-channel FT2 saved mods. There
20+
is a patch included to rectify this; you should patch libmodplug
21+
before building if you have this version.
22+
1823
Now, you need GCC installed and GNU make to actually build. Currently,
1924
GCC on Windows and Linux are supported. Use Makefile.linux to build on
2025
Linux, and the vanilla Makefile to build on Windows. As of this writing,

changelog.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
1+
+ Fixed issues with the commands counter not being reset
2+
+ Color intensity now gets reset when you enter the editor
3+
+ SAMs got cutoff sometimes now.. fixed
4+
+ Fixed bug where loading a world with empty boards could change the starting,
5+
endgame, and death boards
6+
+ Fixed bug where you could text enter off the bottom of the board, causing
7+
problems
8+
+ Fixed bug involving cutting/clearing the entire robot in the robot editor
9+
while not at the first line
10+
+ Fixed robot name entry for global robot not disappearing on small boards
11+
+ Fixed bug where you could duplicate the player by holding down a direction
12+
as a saved game loads
13+
+ Fixed bug where you could go to line 0 in the robot editor
14+
+ Saving an MZM now auto-adds the .mzm extension...
15+
+ Fixed black screen on quicksave
16+
+ Fixed bug where opening a file didn't close the old one if one was open
17+
(so it'd eventually crash MZX)
18+
+ Changed alt+backspace behavior in intake so it doesn't exit
19+
+ Added clipping for refx/refy/width/height for sprites (less than 0 at
20+
initialization, greater than board width/height at draw)
21+
+ Fixed direction parsing for move all
22+
+ Fixed bug where creating things on top of the player would use a slot
23+
for robots/scrolls/signs/sensors instead of just copy to the buffer
24+
+ Added ability to use chars as immediates in Robotic commands
25+
(ie, set "$str.0" 'a')
26+
+ Added options to enable oversampling and specify resampling mode in
27+
the config file (higher quality audio)
28+
+ Building with patched modplug that fixes loading 2-channel mods
29+
outputted by FT2. If you're building yourself, see build.txt.
30+
+ Fixed inability to mouse click in alt + h mode
31+
+ Fixed ability to mouse click outside of board range
32+
+ Should work better for Linux users; case insensitivity for file opens
33+
has been added.
34+
+ Fixed close bug that was affecting Linux builds (may affect more)
35+
+ Keypad enter works where normal enter works now
36+
+ Fixed disappearing cursor when cancelling out of abandon changes box
37+
when loading a new world in the editor
38+
+ Fixed problems when loading/saving robots outside of ID range (do not
39+
hardcode ID's people)
40+
+ Fixed problem with NO BOARD exits being set to something else when
41+
empty boards were being stripped or when worlds were being imported
42+
+ Fixed bug where auto-decrypting worlds didn't work if the XOR value
43+
was negative
44+
+ Fixed problem with rid not working the first cycle
45+
+ Fixed inability to interpolate (with &&'s) counter names larger than
46+
14
47+
+ Added new robot mem counter in debug box (only kb precise, rounds up)
48+
+ Fixed ability to clone the player on non-title board after testing
49+
+ Lengthened size of mod name buffers
50+
+ Fixed bug where send x y doesn't work from the global robot
51+
+ Fixed a few bugs that could cause MZX to crash
52+
153
August 11, 2004 - MZX 2.80b
254

355
+ Made it possible for robots to move through teleporters

char_ed.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ int char_editor(World *mzx_world)
297297
break;
298298
}
299299

300+
case SDLK_KP_ENTER:
300301
case SDLK_RETURN:
301302
{
302303
int new_char = char_selection(current_char);
@@ -705,6 +706,7 @@ int smzx_char_editor(World *mzx_world)
705706
break;
706707
}
707708

709+
case SDLK_KP_ENTER:
708710
case SDLK_RETURN:
709711
{
710712
int new_char = char_selection(current_char);

config.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@
5353

5454
#audio_buffer = 2048
5555

56+
# Allow music to be sampled at higher precision. Increases CPU
57+
# usage but increases audio quality as well.
58+
59+
#enable_oversampling = 0
60+
61+
# Set resampling mode. Choices are:
62+
# none (fastest, poor quality)
63+
# linear (fast, good quality)
64+
# cubic (slow, great quality)
65+
# fir (very slow, excellent quality)
66+
67+
#resampling_mode = linear
68+
5669
# Whether music/samples should be played or not.
5770
# Does not include PC speaker effects.
5871

0 commit comments

Comments
 (0)