Permalink
Browse files

MegaZeux 2.80c release.

  • Loading branch information...
ajs1984 committed Aug 11, 2008
1 parent 75617b7 commit 4782ebcc2c27390dd8e81645107362fa987690de
Showing with 1,218 additions and 414 deletions.
  1. +1 −1 Makefile
  2. +2 −2 Makefile.linux
  3. +60 −37 audio.cpp
  4. +3 −2 board.cpp
  5. +2 −2 board.h
  6. +6 −1 build.txt
  7. +52 −0 changelog.txt
  8. +2 −0 char_ed.cpp
  9. +13 −0 config.txt
  10. +35 −0 configure.cpp
  11. +2 −0 configure.h
  12. +99 −61 counter.cpp
  13. +10 −8 decrypt.cpp
  14. +83 −76 edit.cpp
  15. +2 −24 edit_di.cpp
  16. +4 −0 error.cpp
  17. +364 −0 fsafeopen.cpp
  18. +33 −0 fsafeopen.h
  19. +30 −10 game.cpp
  20. +7 −3 game2.cpp
  21. +26 −11 getpw.cpp
  22. +5 −5 graphics.cpp
  23. +67 −6 help.doc
  24. +10 −8 intake.cpp
  25. +8 −0 main.cpp
  26. +6 −0 port.txt
  27. +10 −5 rasm.cpp
  28. +6 −3 robo_ed.cpp
  29. +79 −49 robot.cpp
  30. +1 −0 robot.h
  31. +117 −83 runrobo2.cpp
  32. +0 −1 sfx.cpp
  33. +10 −3 sprite.cpp
  34. +4 −0 window.cpp
  35. +58 −12 world.cpp
  36. +1 −1 world.h
View
@@ -10,7 +10,7 @@ OBJS = main.o graphics.o window.o hexchar.o event.o \
PREFIX = /usr
-BIN = mzx280b.exe
+BIN = mzx280c.exe
CC = gcc
CPP = g++
View
@@ -6,11 +6,11 @@ OBJS = main.o graphics.o window.o hexchar.o event.o \
idarray.o delay.o game2.o expr.o sprite.o runrobo2.o \
mzm.o decrypt.o audio.o edit.o edit_di.o block.o \
char_ed.o pal_ed.o param.o sfx_edit.o fill.o rasm.o \
- robo_ed.o configure.o
+ robo_ed.o configure.o fsafeopen.o
PREFIX = /usr
-BIN = mzx280b
+BIN = mzx280c
CC = gcc
CPP = g++
View
@@ -36,6 +36,7 @@
#include "data.h"
#include "configure.h"
#include "gdm2s3m.h"
+#include "fsafeopen.h"
struct _ModPlugFile
{
@@ -72,8 +73,8 @@ void audio_callback(void *userdata, Uint8 *stream, int len)
// Reset position
audio.current_mod->mSoundFile.SetCurrentPos(0);
// Read anew remaining bytes
- ModPlug_Read(audio.current_mod, audio.mod_buffer + read_len,
- len - read_len);
+ ModPlug_Read(audio.current_mod, audio.mod_buffer + read_len,
+ len - read_len);
}
}
else
@@ -232,10 +233,42 @@ void init_audio(config_info *conf)
NULL
};
+ if(conf->oversampling_on)
+ {
+ audio.mod_settings.mFlags = MODPLUG_ENABLE_OVERSAMPLING;
+ }
+
audio.mod_settings.mFrequency = 44100;
audio.mod_settings.mChannels = 2;
audio.mod_settings.mBits = 16;
- audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_LINEAR;
+
+ switch(conf->resampling_mode)
+ {
+ case 0:
+ {
+ audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_NEAREST;
+ break;
+ }
+
+ case 1:
+ {
+ audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_LINEAR;
+ break;
+ }
+
+ case 2:
+ {
+ audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_SPLINE;
+ break;
+ }
+
+ case 3:
+ {
+ audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_FIR;
+ break;
+ }
+ }
+
audio.mod_settings.mLoopCount = -1;
ModPlug_SetSettings(&audio.mod_settings);
@@ -252,20 +285,23 @@ void load_mod(char *filename)
char *input_buffer;
int file_size;
int extension_pos = strlen(filename) - 4;
- char new_file[256];
+ char new_file[MAX_PATH];
if(extension_pos && !strcasecmp(filename + extension_pos, ".gdm"))
{
- struct stat file_info;
+ char translated_filename_src[MAX_PATH];
+ char translated_filename_dest[MAX_PATH];
// GDM -> S3M
strcpy(new_file, filename);
memcpy(new_file + extension_pos, ".s3m", 4);
- if(stat(new_file, &file_info))
+ fsafetranslate(filename, translated_filename_src);
+
+ if(fsafetranslate(new_file, translated_filename_dest) < 0)
{
// If it doesn't exist, create it by converting.
- convert_gdm_s3m(filename, new_file);
+ convert_gdm_s3m(translated_filename_src, new_file);
}
filename = new_file;
@@ -274,7 +310,7 @@ void load_mod(char *filename)
if(audio.mod_playing)
end_mod();
- input_file = fopen(filename, "rb");
+ input_file = fsafeopen(filename, "rb");
if(input_file)
{
@@ -304,7 +340,6 @@ void end_mod(void)
void play_sample(int freq, char *filename)
{
- struct stat file_info;
FILE *input_file;
char *input_buffer;
int file_size;
@@ -313,23 +348,29 @@ void play_sample(int freq, char *filename)
// FIXME - destroy least recently used?
if(audio.num_samples_playing >= MAX_SAMS)
- return;
+ return;
- if((extension_pos >= 0) && !strcasecmp(filename + extension_pos, ".sam"))
+ if(extension_pos && !strcasecmp(filename + extension_pos, ".sam"))
{
- // SAM -> WAV
+ char translated_filename_src[MAX_PATH];
+ char translated_filename_dest[MAX_PATH];
+
+ // GDM -> S3M
strcpy(new_file, filename);
memcpy(new_file + extension_pos, ".wav", 4);
- if(stat(new_file, &file_info))
+ fsafetranslate(filename, translated_filename_src);
+
+ if(fsafetranslate(new_file, translated_filename_dest) < 0)
{
- // Create it
- convert_sam_to_wav(filename, new_file);
+ // If it doesn't exist, create it by converting.
+ convert_sam_to_wav(translated_filename_src, new_file);
}
+
filename = new_file;
}
- input_file = fopen(filename, "rb");
+ input_file = fsafeopen(filename, "rb");
if(input_file)
{
@@ -344,31 +385,14 @@ void play_sample(int freq, char *filename)
if(sample_loaded)
{
- int sample_length = sample_loaded->mSoundFile.Ins[1].nLength;
-
// A little hack to modify the pitch
sample_loaded->mSoundFile.Ins[1].nC4Speed = (freq_conversion / freq) / 2;
sample_loaded->mSoundFile.Ins[2].nC4Speed = (freq_conversion / freq) / 2;
sample_loaded->mSoundFile.Ins[1].nVolume = (256 * sound_gvol) / 8;
sample_loaded->mSoundFile.Ins[2].nVolume = (256 * sound_gvol) / 8;
- // This number is pretty much obtained via experimentation. It can probably
- // stand to be a little higher.
- sample_length /= 110;
-
- if(sample_length < 256)
- {
- sample_loaded->mSoundFile.Patterns[0][0].param = sample_length;
- sample_loaded->mSoundFile.Patterns[0][2].command = CMD_PATTERNBREAK;
- }
- else
- {
- int row_duration = sample_length / 255;
- sample_loaded->mSoundFile.Patterns[0][0].param = 255;
- if(row_duration < 62)
- sample_loaded->mSoundFile.Patterns[0][2 + row_duration].command =
- CMD_PATTERNBREAK;
- }
+ // This number is pretty much obtained via experimentation. It can probably
+ // stand to be a little higher.
// Find a free position to put it
for(i = 0; i < 16; i++)
@@ -384,7 +408,7 @@ void play_sample(int freq, char *filename)
}
free(input_buffer);
- fclose(input_file);
+ fclose(input_file);
}
}
@@ -567,4 +591,3 @@ void convert_sam_to_wav(char *source_name, char *dest_name)
fclose(source);
fclose(dest);
}
-
View
@@ -201,6 +201,7 @@ void load_board_direct(Board *cur_board, FILE *fp, int savegame)
{
cur_board->board_dir[i] = fgetc(fp);
}
+
cur_board->restart_if_zapped = fgetc(fp);
cur_board->time_limit = fgetw(fp);
cur_board->last_key = fgetc(fp);
@@ -598,8 +599,8 @@ void save_RLE2_plane(char *plane, FILE *fp, int size)
current_char = plane[i];
runsize = 1;
- while((plane[i + 1] == current_char) && (runsize < 127) &&
- (i < (size - 1)))
+ while((i < (size - 1)) && (plane[i + 1] == current_char) &&
+ (runsize < 127))
{
i++;
runsize++;
View
@@ -32,7 +32,7 @@ struct _Board
{
int size;
- char board_name[BOARD_NAME_SIZE];
+ char board_name[32];
int board_width;
int board_height;
@@ -47,7 +47,7 @@ struct _Board
char *overlay;
char *overlay_color;
- char mod_playing[FILENAME_SIZE];
+ char mod_playing[256];
int viewport_x;
int viewport_y;
int viewport_width;
View
@@ -10,11 +10,16 @@ Next, you need the correct libraries installed, which are the
SDL: http://www.libsdl.org/
-libmodplug: http://sourceforge.net/projects/libmodplug/
+libmodplug: http://prdownloads.sourceforge.net/modplug-xmms/
gdm2s3m: http://mzx.bitpack.net/gdm2s3m-1.1.tar.gz
(should also show up on other sites soon)
+NOTE: As of this writing, libmodplug (version 0.7) has a bug that
+doesn't allow it to correctly load 2-channel FT2 saved mods. There
+is a patch included to rectify this; you should patch libmodplug
+before building if you have this version.
+
Now, you need GCC installed and GNU make to actually build. Currently,
GCC on Windows and Linux are supported. Use Makefile.linux to build on
Linux, and the vanilla Makefile to build on Windows. As of this writing,
View
@@ -1,3 +1,55 @@
++ Fixed issues with the commands counter not being reset
++ Color intensity now gets reset when you enter the editor
++ SAMs got cutoff sometimes now.. fixed
++ Fixed bug where loading a world with empty boards could change the starting,
+ endgame, and death boards
++ Fixed bug where you could text enter off the bottom of the board, causing
+ problems
++ Fixed bug involving cutting/clearing the entire robot in the robot editor
+ while not at the first line
++ Fixed robot name entry for global robot not disappearing on small boards
++ Fixed bug where you could duplicate the player by holding down a direction
+ as a saved game loads
++ Fixed bug where you could go to line 0 in the robot editor
++ Saving an MZM now auto-adds the .mzm extension...
++ Fixed black screen on quicksave
++ Fixed bug where opening a file didn't close the old one if one was open
+ (so it'd eventually crash MZX)
++ Changed alt+backspace behavior in intake so it doesn't exit
++ Added clipping for refx/refy/width/height for sprites (less than 0 at
+ initialization, greater than board width/height at draw)
++ Fixed direction parsing for move all
++ Fixed bug where creating things on top of the player would use a slot
+ for robots/scrolls/signs/sensors instead of just copy to the buffer
++ Added ability to use chars as immediates in Robotic commands
+ (ie, set "$str.0" 'a')
++ Added options to enable oversampling and specify resampling mode in
+ the config file (higher quality audio)
++ Building with patched modplug that fixes loading 2-channel mods
+ outputted by FT2. If you're building yourself, see build.txt.
++ Fixed inability to mouse click in alt + h mode
++ Fixed ability to mouse click outside of board range
++ Should work better for Linux users; case insensitivity for file opens
+ has been added.
++ Fixed close bug that was affecting Linux builds (may affect more)
++ Keypad enter works where normal enter works now
++ Fixed disappearing cursor when cancelling out of abandon changes box
+ when loading a new world in the editor
++ Fixed problems when loading/saving robots outside of ID range (do not
+ hardcode ID's people)
++ Fixed problem with NO BOARD exits being set to something else when
+ empty boards were being stripped or when worlds were being imported
++ Fixed bug where auto-decrypting worlds didn't work if the XOR value
+ was negative
++ Fixed problem with rid not working the first cycle
++ Fixed inability to interpolate (with &&'s) counter names larger than
+ 14
++ Added new robot mem counter in debug box (only kb precise, rounds up)
++ Fixed ability to clone the player on non-title board after testing
++ Lengthened size of mod name buffers
++ Fixed bug where send x y doesn't work from the global robot
++ Fixed a few bugs that could cause MZX to crash
+
August 11, 2004 - MZX 2.80b
+ Made it possible for robots to move through teleporters
View
@@ -297,6 +297,7 @@ int char_editor(World *mzx_world)
break;
}
+ case SDLK_KP_ENTER:
case SDLK_RETURN:
{
int new_char = char_selection(current_char);
@@ -705,6 +706,7 @@ int smzx_char_editor(World *mzx_world)
break;
}
+ case SDLK_KP_ENTER:
case SDLK_RETURN:
{
int new_char = char_selection(current_char);
View
@@ -53,6 +53,19 @@
#audio_buffer = 2048
+# Allow music to be sampled at higher precision. Increases CPU
+# usage but increases audio quality as well.
+
+#enable_oversampling = 0
+
+# Set resampling mode. Choices are:
+# none (fastest, poor quality)
+# linear (fast, good quality)
+# cubic (slow, great quality)
+# fir (very slow, excellent quality)
+
+#resampling_mode = linear
+
# Whether music/samples should be played or not.
# Does not include PC speaker effects.
Oops, something went wrong.

0 comments on commit 4782ebc

Please sign in to comment.