Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MegaZeux 2.80e release.

  • Loading branch information...
commit 837aa5de0d4c903af2fff99125c1cbdc9f47abae 1 parent 8ab51ab
@ajs1984 authored
Showing with 37,739 additions and 35,260 deletions.
  1. +0 −48 MZX270w_Bugs.txt
  2. +32 −31 Makefile
  3. +21 −0 Makefile.in
  4. +0 −43 Makefile.linux
  5. +15 −0 Makefile.platform
  6. +12 −0 arch/Makefile.linux
  7. +12 −0 arch/Makefile.macos
  8. +15 −0 arch/Makefile.win32
  9. +54 −0 config.sh
  10. +79 −3 config.txt
  11. +1 −1  contrib/gdm2s3m/src/Makefile
  12. +1 −1  contrib/libmodplug/src/Makefile
  13. +0 −46 cursor.h
  14. +8 −6 { → docs}/COPYING.DOC
  15. 0  { → docs}/betatest.txt
  16. +1 −1  { → docs}/build.txt
  17. +62 −0 { → docs}/changelog.txt
  18. 0  { → docs}/coms.txt
  19. 0  { → docs}/convmem.txt
  20. 0  { → docs}/counter_list.txt
  21. 0  { → docs}/develop.txt
  22. 0  { → docs}/filef200.txt
  23. 0  { → docs}/filef268.txt
  24. 0  { → docs}/fileform.txt
  25. 0  { → docs}/fix.doc
  26. 0  { → docs}/help.doc
  27. 0  { → docs}/info_mzx.txt
  28. 0  { → docs}/megazeux.doc
  29. 0  { → docs}/mzm.txt
  30. 0  { → docs}/port.txt
  31. 0  { → docs}/readme.txt
  32. 0  { → docs}/to_add.txt
  33. BIN  mzx_help.fil
  34. +0 −88 robo_ed.h
  35. +0 −36 scrdump.h
  36. +24 −0 src/Makefile
  37. +593 −589 { → src}/audio.cpp
  38. +78 −78 { → src}/audio.h
  39. +311 −311 { → src}/block.cpp
  40. +37 −37 { → src}/block.h
  41. +960 −958 { → src}/board.cpp
  42. +117 −117 { → src}/board.h
  43. +847 −847 { → src}/char_ed.cpp
  44. +30 −30 { → src}/char_ed.h
  45. +29 −29 { → src}/charset.h
  46. +7 −0 src/config.h
  47. +590 −509 { → src}/configure.cpp
  48. +80 −74 { → src}/configure.h
  49. +126 −126 { → src}/const.h
  50. +2,928 −2,929 { → src}/counter.cpp
  51. +131 −129 { → src}/counter.h
  52. 0  { → src}/counter_first_letter.h
  53. +319 −319 { → src}/data.cpp
  54. +71 −71 { → src}/data.h
  55. +201 −196 { → src}/decrypt.cpp
  56. +29 −29 { → src}/decrypt.h
  57. +35 −35 { → src}/delay.cpp
  58. +28 −28 { → src}/delay.h
  59. +3,108 −3,090 { → src}/edit.cpp
  60. +73 −73 { → src}/edit.h
  61. +1,510 −1,496 { → src}/edit_di.cpp
  62. +39 −37 { → src}/edit_di.h
  63. +184 −184 { → src}/error.cpp
  64. +35 −35 { → src}/error.h
  65. +864 −697 { → src}/event.cpp
  66. +100 −87 { → src}/event.h
  67. +519 −519 { → src}/expr.cpp
  68. +36 −36 { → src}/expr.h
  69. +395 −395 { → src}/fill.cpp
  70. +31 −31 { → src}/fill.h
  71. +226 −226 { → src}/fix.cpp
  72. +3 −3 { → src}/fsafeopen.cpp
  73. +33 −33 { → src}/fsafeopen.h
  74. +3,516 −3,514 { → src}/game.cpp
  75. +73 −73 { → src}/game.h
  76. +2,749 −2,748 { → src}/game2.cpp
  77. +49 −49 { → src}/game2.h
  78. +225 −225 { → src}/getpw.cpp
  79. +1,509 −1,484 { → src}/graphics.cpp
  80. +152 −150 { → src}/graphics.h
  81. +123 −123 { → src}/helpsys.cpp
  82. +34 −34 { → src}/helpsys.h
  83. +73 −73 { → src}/hexchar.cpp
  84. +31 −31 { → src}/hexchar.h
  85. +147 −147 { → src}/idarray.cpp
  86. +39 −39 { → src}/idarray.h
  87. +677 −677 { → src}/idput.cpp
  88. +39 −39 { → src}/idput.h
  89. +656 −651 { → src}/intake.cpp
  90. +40 −40 { → src}/intake.h
  91. +82 −82 { → src}/killgbl.cpp
  92. +130 −124 { → src}/main.cpp
  93. +30 −30 { → src}/main.h
  94. +1,751 −0 src/mmgr.cpp
  95. +167 −0 src/mmgr.h
  96. +589 −589 { → src}/mzm.cpp
  97. +32 −32 { → src}/mzm.h
  98. +60 −0 src/nommgr.h
  99. +306 −306 { → src}/pal_ed.cpp
  100. +29 −29 { → src}/pal_ed.h
  101. +1,315 −1,315 { → src}/param.cpp
  102. +65 −65 { → src}/param.h
  103. +138 −138 { → src}/password.cpp
  104. +41 −41 { → src}/password.h
  105. +2,461 −2,461 { → src}/rasm.cpp
  106. +199 −199 { → src}/rasm.h
  107. +1,961 −1,981 { → src}/robo_ed.cpp
  108. +104 −0 src/robo_ed.h
  109. +2,850 −2,827 { → src}/robot.cpp
  110. +257 −257 { → src}/robot.h
Sorry, we could not display the entire diff because it was too big.
View
48 MZX270w_Bugs.txt
@@ -1,48 +0,0 @@
-In general:
- * These crashes are doing weird things to my monitor. It's now
- continually making minute resizes on the horizontal aspect, even
- though the program is crashed and closed. There, it just did it
- again!
-
-In Caverns:
- * Fish in the fountain seem to be abnormally "intelligent" in their
- following patterns. They get in the way a lot more than I remember
- them doing.
- * The rainbow bridge does not appear when all the gems are collected.
- There is a character change to reflect the gem placement, and a
- flash of light, but no bridge.
-
-In Demon Earth:
- * Game will often crash on start. I suspect this may have something
- to do with the way Nytar forced all four game files to load up the
- starting world when played, since it seems to work when you play
- from the world DE_START. However, this is only conjecture.
- * Fade in after room transition doesn't look right, there is a bright
- flash of the room before it goes back to dark and fades up.
- * Name selection still doesn't work, and hasn't since 2.69c. The
- player is always called "Player". This may be the fault of bad
- coding taking improper advantage of a 2.69b bug.
- * When arriving on Earth, I'm not sure the character set changed
- correctly; when I went over to the boulders blocking the east passage
- they looked like a type of game enemy, not boulders.
- * Upon touching the boulders, the game crashed to desktop.
- * There is clearly a problem with the status bar that is hard to
- diagnose. It appears that it somehow gets uncoupled from tracking
- energy and health, perhaps on getting a power up. All I could tell
- was that the numbers were stuck at full (I initially thought
- something was broken so that I had infinite ammo), but when I kept
- firing shots I eventually drained both my energy and my health and
- died.
- * Loading an old version's save game (just to check) crashed the
- program with a "Windowing Code Bug". I know this isn't supported
- functionality, and didn't expect it to be, but it would be nice if
- it failed gracefully with a "Save game is from a previous version"
- error, instead of a fatal crash.
-
-In Rayne's Jellybean:
- * The game is entirely unplayable, the characters on the game screen
- are a bunch of garbage, and while the basic shape is apparent by the
- colors, the only legible things are the four answers.
- * I can't tell for sure, but if I remember what the keys are for
- selecting answers are, then they aren't working, and cause no
- response.
View
63 Makefile
@@ -1,36 +1,37 @@
-# MZX makefile
+#
+# Slave MegaZeux makefile
+#
+include Makefile.platform
+include Makefile.in
-OBJS = main.o graphics.o window.o hexchar.o event.o \
- error.o helpsys.o world.o board.o robot.o idput.o \
- intake.o sfx.o scrdisp.o data.o game.o counter.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
+SUBDIRS = contrib/gdm2s3m/src contrib/libmodplug/src src
-PREFIX = /usr
+all: subdir
-BIN = mzx280d.exe
-
-CC = gcc
-CPP = g++
-STRIP = strip
-CFLAGS = -mconsole -O2 -funsigned-char -ffast-math
-INCLUDES = -I$(PREFIX)/include -I$(PREFIX)/include/SDL
-
-LIBS = -L$(PREFIX)/lib -lmingw32 -lSDLmain -lSDL -lmodplug -lgdm2s3m
-
-.SUFFIXES: .cpp
-
-%.o: %.cpp
- ${CPP} ${CFLAGS} ${INCLUDES} -c $<
-
-all: mzx
-
-mzx: ${OBJS}
- ${CPP} ${OBJS} ${LIBS} -o ${BIN}
- ${STRIP} --strip-all ${BIN}
+subdir:
+ list='$(SUBDIRS)'; \
+ for subdir in $$list; do \
+ pwd=`pwd`; \
+ cd $$subdir && make && cd $$pwd; \
+ done;
clean:
- rm -f *.o ${BIN}
-
+ list='$(SUBDIRS)'; \
+ for subdir in $$list; do \
+ pwd=`pwd`; \
+ cd $$subdir && make clean && cd $$pwd; \
+ done;
+
+install:
+ mkdir -p ${PREFIX}/share/megazeux && \
+ chown root:root ${PREFIX}/share/megazeux && \
+ chmod 0755 ${PREFIX}/share/megazeux && \
+ install -o root -m 0644 mzx_default.chr ${PREFIX}/share/megazeux && \
+ install -o root -m 0644 mzx_blank.chr ${PREFIX}/share/megazeux && \
+ install -o root -m 0644 mzx_smzx.chr ${PREFIX}/share/megazeux && \
+ install -o root -m 0644 mzx_ascii.chr ${PREFIX}/share/megazeux && \
+ install -o root -m 0644 default.spl ${PREFIX}/share/megazeux && \
+ install -o root -m 0644 mzx_help.fil ${PREFIX}/share/megazeux && \
+ install -o root -m 0644 config.txt /etc/megazeux-config && \
+ install -o root -m 0755 ${TARGET} ${PREFIX}/bin && \
+ ln -sf ${TARGET} ${PREFIX}/bin/megazeux
View
21 Makefile.in
@@ -0,0 +1,21 @@
+#
+# used by all makefiles
+#
+CC = gcc
+CPP = g++
+
+# default target name
+TARGET = mzx280e
+VERSION = 2.80e
+
+# default optimisations
+CXXFLAGS = -O2 -funsigned-char -ffast-math -Wall -DMZX_VERSION=\"${VERSION}\"
+CXXFLAGS += -I../contrib/libmodplug/src -I../contrib/libmodplug/src/include
+CXXFLAGS += -I../contrib/gdm2s3m/src
+LIBS += ../contrib/libmodplug/src/libmodplug.a
+LIBS += ../contrib/gdm2s3m/src/libgdm2s3m.a
+
+.SUFFIXES: .cpp
+
+%.o: %.cpp
+ ${CXX} ${CXXFLAGS} ${INCLUDES} -c $<
View
43 Makefile.linux
@@ -1,43 +0,0 @@
-# MZX makefile
-
-OBJS = main.o graphics.o window.o hexchar.o event.o \
- error.o helpsys.o world.o board.o robot.o idput.o \
- intake.o sfx.o scrdisp.o data.o game.o counter.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 fsafeopen.o
-
-PREFIX = /usr
-
-BIN = mzx280d
-
-CC = gcc
-CPP = g++
-STRIP = strip
-CFLAGS = -O2 -funsigned-char -ffast-math
-INCLUDES = -I$(PREFIX)/include/SDL
-INCLUDES += -Icontrib/libmodplug/src -Icontrib/libmodplug/src/include
-INCLUDES += -Icontrib/gdm2s3m/src
-
-LIBS = -lSDL -lpthread
-LIBS += contrib/gdm2s3m/src/libgdm2s3m.a
-LIBS += contrib/libmodplug/src/libmodplug.a
-
-.SUFFIXES: .cpp
-
-%.o: %.cpp
- ${CPP} ${CFLAGS} ${INCLUDES} -c $<
-
-all: mzx
-
-mzx: ${OBJS}
- ${MAKE} -fcontrib/gdm2s3m/src/Makefile
- ${MAKE} -fcontrib/libmodplug/src/Makefile
- ${CPP} ${OBJS} ${LIBS} -o ${BIN}
- ${STRIP} --strip-all ${BIN}
-
-clean:
- ${MAKE} -fcontrib/gdm2s3m/src/Makefile clean
- ${MAKE} -fcontrib/libmodplug/src/Makefile clean
- rm -f *.o ${BIN}
View
15 Makefile.platform
@@ -0,0 +1,15 @@
+#
+# linux makefile generics
+#
+
+# location of strip (must be defined)
+STRIP = strip --strip-unneeded
+
+# standard linker includes
+INCLUDES = -I${PREFIX}/include -I${PREFIX}/include/SDL
+
+# standard libraries
+LIBS = -L$(PREFIX)/lib -lSDL -lpthread
+
+# install prefix
+PREFIX=/usr
View
12 arch/Makefile.linux
@@ -0,0 +1,12 @@
+#
+# linux makefile generics
+#
+
+# location of strip (must be defined)
+STRIP = strip --strip-unneeded
+
+# standard linker includes
+INCLUDES = -I${PREFIX}/include -I${PREFIX}/include/SDL
+
+# standard libraries
+LIBS = -L$(PREFIX)/lib -lSDL -lpthread
View
12 arch/Makefile.macos
@@ -0,0 +1,12 @@
+#
+# macos makefile generics
+#
+
+# location of strip (must be defined)
+STRIP = true
+
+# standard linker includes
+INCLUDES = -I${PREFIX}/include -I${PREFIX}/include/SDL
+
+# standard libraries
+LIBS = -L$(PREFIX)/lib -lSDL -lpthread
View
15 arch/Makefile.win32
@@ -0,0 +1,15 @@
+#
+# win32 makefile generics
+#
+
+# windows requires a binary extension
+BINEXT = .exe
+
+# location of strip (must be defined)
+STRIP = strip --strip-unneeded
+
+# standard linker includes
+INCLUDES = -I${PREFIX}/include -I${PREFIX}/include/SDL
+
+# standard libraries
+LIBS = -L$(PREFIX)/lib -lmingw32 -mwindows -lSDLmain -lSDL
View
54 config.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+if [ "$1" = "" ]; then
+ if [ "`uname -o`" = "GNU/Linux" ]; then
+ echo "Assuming Linux operating system.."
+ cp -f arch/Makefile.linux Makefile.platform
+ ARCH=linux
+ else
+ echo "Assuming Windows operating system.."
+ cp -f arch/Makefile.win32 Makefile.platform
+ ARCH=win32
+ fi
+else
+ cp -f arch/Makefile.$1 Makefile.platform
+ ARCH=$1
+fi
+
+if [ ! -f Makefile.platform ]; then
+ echo "Invalid platform selection (see arch/)"
+ exit 1
+fi
+
+if [ "$2" = "" ]; then
+ echo "Assuming /usr prefix.."
+ PREFIX=/usr
+else
+ PREFIX=$2
+fi
+
+echo >> Makefile.platform
+echo "# install prefix" >> Makefile.platform
+echo "PREFIX=$PREFIX" >> Makefile.platform
+
+if [ "$ARCH" = "win32" ]; then
+ echo "#define MZX_DEFAULT_CHR \"mzx_default.chr\"" > src/config.h
+ echo "#define MZX_BLANK_CHR \"mzx_blank.chr\"" >> src/config.h
+ echo "#define MZX_SMZX_CHR \"mzx_smzx.chr\"" >> src/config.h
+ echo "#define MZX_ASCII_CHR \"mzx_ascii.chr\"" >> src/config.h
+ echo "#define DEFAULT_SPL \"default.spl\"" >> src/config.h
+ echo "#define MZX_HELP_FIL \"mzx_help.fil\"" >> src/config.h
+ echo "#define CONFIG_TXT \"config.txt\"" >> src/config.h
+fi
+
+if [ "$ARCH" = "linux" -o "$ARCH" = "macos" ]; then
+ echo "#define MZX_DEFAULT_CHR \"$PREFIX/share/megazeux/mzx_default.chr\"" > src/config.h
+ echo "#define MZX_BLANK_CHR \"$PREFIX/share/megazeux/mzx_blank.chr\"" >> src/config.h
+ echo "#define MZX_SMZX_CHR \"$PREFIX/share/megazeux/mzx_smzx.chr\"" >> src/config.h
+ echo "#define MZX_ASCII_CHR \"$PREFIX/share/megazeux/mzx_ascii.chr\"" >> src/config.h
+ echo "#define DEFAULT_SPL \"$PREFIX/share/megazeux/default.spl\"" >> src/config.h
+ echo "#define MZX_HELP_FIL \"$PREFIX/share/megazeux/mzx_help.fil\"" >> src/config.h
+ echo "#define CONFIG_TXT \"/etc/megazeux-config\"" >> src/config.h
+fi
+
+echo "All done!"
View
82 config.txt
@@ -1,5 +1,5 @@
# Configuration file for MegaZeux
-# August 6, 2004
+# December 16, 2004
# Comments begin with #. Whitespace is ignored. Empty lines are
# ignored as well.
@@ -8,6 +8,8 @@
# If value is not given, then it is assumed to be 1.
# You can include spaces in values by escaping them with \s.
# (see the default macros for examples)
+# For directories, use forward slashes (/) instead of back-slashes,
+# as they work more reliably.
# Note that even if the option is given to change the values
# in MZX, this text file will NOT be modified, and hence the
# values will revert to what they are here when you restart MZX.
@@ -38,6 +40,7 @@
#force_height_multiplier = 1
# Whether MZX should start up in fullscreen or not.
+# Press ctrl-alt-enterWh to toggle fullscreen as MZX runs.
#fullscreen = 0
@@ -56,7 +59,7 @@
# Allow music to be sampled at higher precision. Increases CPU
# usage but increases audio quality as well.
-enable_oversampling = 1
+#enable_oversampling = 1
# Set resampling mode. Choices are:
# none (fastest, poor quality)
@@ -64,7 +67,7 @@ enable_oversampling = 1
# cubic (slow, great quality)
# fir (very slow, excellent quality)
-resampling_mode = fir
+#resampling_mode = linear
# Whether music/samples should be played or not.
# Does not include PC speaker effects.
@@ -81,6 +84,7 @@ resampling_mode = fir
# Volume samples play at
#sample_volume = 8
+
### Game options ###
# Name of world file that should be loaded when MZX starts.
@@ -144,3 +148,75 @@ resampling_mode = fir
#macro_three = goto\s
#macro_four = send\s
#macro_five = :\splayershot^
+
+# Whether or not the palette should be reverted to default
+# when the robot editor is load. If set, SMZX mode 0 will
+# also be enforced.
+
+#robot_editor_default_palette = 0
+
+
+# Backup options
+
+# Backups are save files made in the editor. They will only be made
+# while in the main editor, not while in a sub-editor or a dialogue
+# box of sorts. Note that this can cause slight pauses while editing,
+# as the game saves.
+# If you have multiple backups you should check the modified date in
+# a console or file properties to determine which was most recently
+# modified. The number will not indicate most recently saved.
+
+# How many backups to be made. Set to zero to disable backups.
+
+#backup_count = 0
+
+# How often (in seconds) backups should be made
+
+#backup_interval = 60
+
+# The name of the backup file. If you choose "backup" with 3 backups
+# the backups will be named backup1.mzx, backup2.mzx, and backup3.mzx.
+
+#backup_name = backup
+
+
+# Joystick options
+
+# It is possible to emulate key presses using a joystick. If this file
+# is config.txt these options will apply as a default to all games -
+# you can put them in game.cnf to apply specifically to game.mzx.
+
+# A joystick is first specified as joyN where N is the number from
+# 1 onwards identifying the joystick in your system. You may have
+# to experiment to find which joystick is which number, if you have
+# multiple ones, otherwise just use 1. Up to 16 joysticks are
+# recognized.
+# You can currently map two things, axes and buttons.
+# Axes/buttons are mapped to keys given by number. You can find out
+# a key's number by printing key_pressed in a loop (NOT key_code).
+# Axis mapping looks as follows:
+
+#joyXaxisY = A, B
+
+# Where X is the number of the joystick, Y is the number of the axis
+# (1 is typically left/right, 2 is typically up/down), A is the key
+# for one extreme (such as left) and B is the key for the other
+# (such as right).
+
+# Button mapping looks as follows:
+
+#joyXbuttonY = A
+
+# Where X is the number of the joystick, Y is the number of the button
+# (you may have to experiment to find out which button is which number),
+# and A is the key whose press is emulated when this button is pressed.
+
+
+# Misc Options
+
+# Set to 1 if you want MZX to pause when key focus is lost. Useful for
+# when another app (such as someone IM'ing you) steals the screen. This
+# might cause MZX to lock up sometimes on some machines - if you have
+# problems with it don't enable it.
+
+#pause_on_unfocus = 0
View
2  contrib/gdm2s3m/src/Makefile
@@ -9,7 +9,7 @@
CFLAGS := -Wall -std=c99
o := o
-gdm2s3m_base = contrib/gdm2s3m/src
+gdm2s3m_base = .
gdm2s3m_cflags := -W -Wmissing-format-attribute -Wpointer-arith -Wcast-align
gdm2s3m_cflags += -Wwrite-strings -pedantic -I${gdm2s3m_base}
gdm2s3m = ${gdm2s3m_base}/libgdm2s3m.a
View
2  contrib/libmodplug/src/Makefile
@@ -9,7 +9,7 @@
CXXFLAGS := -Wall
o := o
-libmodplug_base = contrib/libmodplug/src
+libmodplug_base = .
libmodplug_cflags = -DHAVE_INTTYPES_H -I${libmodplug_base} \
-I${libmodplug_base}/libmodplug
View
46 cursor.h
@@ -1,46 +0,0 @@
-/* $Id$
- * MegaZeux
- *
- * Copyright (C) 1996 Greg Janson
- * Copyright (C) 1998 Matthew D. Williams - dbwilli@scsn.net
- *
- * 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.
- */
-
-/* CURSOR.H- Declarations for CURSOR.ASM */
-
-#ifndef __CURSOR_H
-#define __CURSOR_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void cursor_underline(void);
-void cursor_solid(void);
-void cursor_off(void);
-void move_cursor(int x_pos,int y_pos);
-
-extern unsigned char cursor_mode;
-
-#define CURSOR_INVIS 2
-#define CURSOR_BLOCK 1
-#define CURSOR_UNDERLINE 0
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
View
14 COPYING.DOC → docs/COPYING.DOC
@@ -2,8 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -280,7 +279,7 @@ POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
- Appendix: How to Apply These Terms to Your New Programs
+ How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@@ -292,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
+ Copyright (C) <year> <name of author>
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
@@ -306,14 +305,15 @@ the "copyright" line and a pointer to where the full notice is found.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
- Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
@@ -338,3 +338,5 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
+
+
View
0  betatest.txt → docs/betatest.txt
File renamed without changes
View
2  build.txt → docs/build.txt
@@ -12,7 +12,7 @@ SDL: http://www.libsdl.org/
libmodplug: http://prdownloads.sourceforge.net/modplug-xmms/
-gdm2s3m: http://mzx.bitpack.net/gdm2s3m-1.1.tar.gz
+gdm2s3m: http://mzx.bitpack.net/gdm2s3m-1.5-lite.tar.gz
(should also show up on other sites soon)
NOTE: As of this writing, libmodplug (version 0.7) has a bug that
View
62 changelog.txt → docs/changelog.txt
@@ -1,3 +1,65 @@
++ Fixed a bug causing problems with static overlay if a non-overlaid sprite
+ is displayed so it's clipped off the edge of the screen.
++ Fixed a bug in the display of c?x color boxes in the F2 menu in the robot
+ editor
++ Fixed a bug that caused incorrect thisx/thisy for one cycle after copyblock
++ Fixed a bug preventing calls to nonexistant subroutines from passing that
+ point in the robot
++ Fixed crash on sam 0 "file"
++ Fixed a bug where loading new SFX may not correctly overwrite previous ones
++ Fixed a bug where you could only load/unload so many mods before MZX couldn't
+ load anymore.. same bug as the SAMs but went unnoticed!
++ Fixed a bug that caused you to be infinitely stuck in the global settings
+ dialog box when you press previous on the next page.
++ Fixed a bug where going to next then exiting would not save the changes
+ from the previous page.
++ Fixed a bug that could cause crashes while ending modules.
++ Fixed a bug that could do the same kind of thing with sams.
++ Fixed an allocation bug when loading MZX worlds that could lead to crashes.
++ Fixed a bug that caused MZX to crash if you interpolated an expression with
+ a value equal to or greater than 1 billion.
++ Fixed a bug where mixing ccheck1/2 with sprites from board and vlayer could
+ cause problems (that's the short version of the explanation, I'll spare you
+ the long one)
++ Fixed a bug that could cause certain old MZX games to crash after the title
+ screen
++ Somewhere broke missiles between 2.80c and 2.80d. Fixed.
++ Fixed error in lit bomb anim sequence setup in char ID editor.
++ Reworked a lot of robot editor code; adding/deleting lines while marked areas
+ are active should work more naturally now and it's hopefully no longer possible
+ to crash it in the same ways it was previously.
++ Fixed crash when setting mesg row to less than 0.
++ Fixed mouse presses not working in the robot editor.
++ Made MZX ignore alt + tab so you can safely switch in your WM without it
+ triggering...
++ Added numerical key entry for number boxes. Use 0-9 to add to the most
+ significant digit and backspace to take it away.
+- Fixed maximum board size to about 16.7 million tiles (128MB), for now.
++ Added config.txt option to make MZX pause when key focus is lost
+ (when clicking on another window, perhaps) or when it's minimized. Music will
+ still continue.
++ Added save/load position to the editor. Works for loads inbetween boards as
+ well. Press ctrl + num to save to slots 0 through 9 and alt + num to load from
+ that slot. Please press shift + 8 or the numpad * key instead of alt + 8 to
+ set mod wildcard.
++ MZX now ignores the mouse scroll wheel instead of interpreting it as a click.
++ Fixed a further bug that could cause playing samples to crash.
++ Added config file option to revert the robot editor to the default palette
+ when loaded.
++ Fixed bug in shoot command.
++ Fixed error when making save name in editor but cancelling.
++ Auto-backup - see config.txt for details.
++ Joystick key mapping - see config.txt for details.
++ You can now load game-specific config files by creating game.cnf for the
+ corresponding game.cnf (for instance, caverns.cnf). This is mainly useful
+ for joystick key mapping. Note that these settings will NOT go away if
+ another game is loaded that doesn't have a .cnf.
++ Alt-enter finally works as block action in the robot editor.
++ Loading a .mzx/.sav from another directory indirectly (via command-line or
+ robotic) will now actually change the current working directory.
+
+October 9, 2004 - MZX 2.80d
+
+ Fixed cursor going invisible when escaping from import in the editor
+ Fixed robot editor entry when pressing OK on global info
+ Fixed lack of name for MZB import/export (any MZB's exported in prior
View
0  coms.txt → docs/coms.txt
File renamed without changes
View
0  convmem.txt → docs/convmem.txt
File renamed without changes
View
0  counter_list.txt → docs/counter_list.txt
File renamed without changes
View
0  develop.txt → docs/develop.txt
File renamed without changes
View
0  filef200.txt → docs/filef200.txt
File renamed without changes
View
0  filef268.txt → docs/filef268.txt 100644 → 100755
File renamed without changes
View
0  fileform.txt → docs/fileform.txt
File renamed without changes
View
0  fix.doc → docs/fix.doc
File renamed without changes
View
0  help.doc → docs/help.doc
File renamed without changes
View
0  info_mzx.txt → docs/info_mzx.txt
File renamed without changes
View
0  megazeux.doc → docs/megazeux.doc
File renamed without changes
View
0  mzm.txt → docs/mzm.txt 100644 → 100755
File renamed without changes
View
0  port.txt → docs/port.txt
File renamed without changes
View
0  readme.txt → docs/readme.txt
File renamed without changes
View
0  to_add.txt → docs/to_add.txt
File renamed without changes
View
BIN  mzx_help.fil
Binary file not shown
View
88 robo_ed.h
@@ -1,88 +0,0 @@
-/* $Id$
- * MegaZeux
- *
- * Copyright (C) 2004 Gilead Kutnick - exophase@adelphia.net
- *
- * 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.
- */
-
-#ifndef __ROBO_ED_H
-#define __ROBO_ED_H
-
-#include "rasm.h"
-#include "world.h"
-
-typedef struct _robot_line robot_line;
-
-typedef enum
-{
- valid,
- invalid_uncertain,
- invalid_discard,
- invalid_comment
-} validity_types;
-
-struct _robot_line
-{
- int line_text_length;
- int line_bytecode_length;
- char *line_text;
- char *line_bytecode;
- char arg_types[20];
- int num_args;
- validity_types validity_status;
-
- struct _robot_line *next;
- struct _robot_line *previous;
-};
-
-extern char macros[5][64];
-
-void robot_editor(World *mzx_world, Robot *cur_robot);
-robot_line *move_line_up(robot_line *current_rline, int count,
- int *current_line);
-robot_line *move_line_down(robot_line *current_rline, int count,
- int *current_line);
-void strip_ccodes(char *dest, char *src);
-int change_line(robot_line *current_rline, char *command_buffer,
- int include_ignores, int base, validity_types invalid_status,
- int *size);
-int add_blank_line(robot_line *next_rline, robot_line *previous_rline,
- int *size);
-void display_robot_line(robot_line *current_rline, int y,
- int color_code, char *color_codes);
-int remove_line(robot_line *current_rline);
-int validate_lines(World *mzx_world, robot_line *current_rline,
- int show_none, int *size);
-void insert_string(char *dest, char *string, int *position);
-int block_menu(World *mzx_world);
-int add_line(robot_line *next_rline, robot_line *previous_rline,
- int *size, char *command_buffer, int include_ignores, int base,
- validity_types invalid_status);
-void paste_buffer(robot_line *current_rline, int *total_lines,
- int *current_line, int *size, int include_ignores, int base,
- validity_types invalid_status);
-void copy_block_to_buffer(robot_line *start_rline, int num_lines);
-robot_line *clear_block(int first_line, robot_line *first_rline,
- int num_lines, int *current_line, int *total_lines, int *size,
- robot_line *cursor_rline);
-void export_block(World *mzx_world, robot_line *base,
- robot_line *block_start, robot_line *block_end, int region_default);
-void import_block(World *mzx_world, robot_line *current_rline,
- int *total_lines, int *current_line, int *size, int include_ignores,
- int base, validity_types invalid_status);
-void edit_settings(World *mzx_world);
-
-#endif
View
0  scrdisp.cpp
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0  scrdisp.h
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
36 scrdump.h
@@ -1,36 +0,0 @@
-/* MegaZeux
- *
- * Copyright (C) 1996 Greg Janson
- * Copyright (C) 1998 Matthew D. Williams - dbwilli@scsn.net
- * Copyright (C) 1998 MenTaLguY - mentalg@geocities.com
- *
- * 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.
- */
-
-#ifndef __SCRDUMP_H
-#define __SCRDUMP_H
-
-//#ifdef __cplusplus
-//extern "C" {
-//#endif
-
-void smzx_dump_screen();
-void dump_screen();
-
-//#ifdef __cplusplus
-//}
-//#endif
-
-#endif
View
0  sfx.cpp
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0  sfx.h
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0  sfx_edit.cpp
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0  sfx_edit.h
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0  sprite.cpp
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0  sprite.h
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
24 src/Makefile
@@ -0,0 +1,24 @@
+#
+# core MegaZeux makefile
+#
+include ../Makefile.platform
+include ../Makefile.in
+
+OBJS = main.o graphics.o window.o hexchar.o event.o \
+ error.o helpsys.o world.o board.o robot.o idput.o \
+ intake.o sfx.o scrdisp.o data.o game.o counter.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 fsafeopen.o
+
+MZX = ../${TARGET}
+
+all: mzx
+
+mzx: ${OBJS}
+ ${CPP} ${OBJS} ${LIBS} -o ${MZX}${BINEXT}
+ ${STRIP} ${MZX}${BINEXT}
+
+clean:
+ rm -f *.o *~ ${MZX}${BINEXT}
View
1,182 audio.cpp → src/audio.cpp
@@ -1,589 +1,593 @@
-/* $Id$
- * MegaZeux
- *
- * Copyright (C) 2004 Gilead Kutnick
- * Copyright (C) 2004 madbrain
- *
- * 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.
- */
-
-// Code to handle module playing, sample playing, and PC speaker
-// sfx emulation.
-
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-
-#include "audio.h"
-#include "modplug.h"
-#include "libmodplug/stdafx.h"
-#include "libmodplug/sndfile.h"
-#include "SDL.h"
-#include "sfx.h"
-#include "data.h"
-#include "configure.h"
-#include "gdm2s3m.h"
-#include "fsafeopen.h"
-#include "delay.h"
-
-struct _ModPlugFile
-{
- CSoundFile mSoundFile;
-};
-
-audio_struct audio;
-
-int error_mode;
-
-// An update should happen every 2ms, so this many samples
-const double pc_speaker_interval = 44100 / 500;
-const int freq_conversion = 3579364;
-
-void audio_callback(void *userdata, Uint8 *stream, int len)
-{
- int i, i2, offset = 0;
- Sint16 *mix_src_ptr;
- Sint32 *mix_dest_ptr;
- Sint32 *buffer_src_ptr;
- Sint16 *buffer_dest_ptr;
- Sint32 cur_sample;
- int sample_duration, end_duration;
- int increment_value, increment_buffer;
-
- if(audio.mod_playing && music_on)
- {
- int read_len =
- ModPlug_Read(audio.current_mod, audio.mod_buffer, len);
-
- if(read_len < 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);
- }
- }
- else
- {
- memset(audio.mod_buffer, 0, len);
- }
-
- mix_dest_ptr = audio.mix_buffer;
- mix_src_ptr = audio.mod_buffer;
-
- for(i = 0; i < len / 2; i++)
- {
- *mix_dest_ptr = *mix_src_ptr;
- mix_dest_ptr++;
- mix_src_ptr++;
- }
-
- // Mix PC speaker effect. First get whatever ran over from last time.
-
- mix_dest_ptr = audio.mix_buffer;
-
- sample_duration = audio.pc_speaker_last_duration;
-
- if(sample_duration >= len / 4)
- {
- end_duration = len / 4;
- audio.pc_speaker_last_duration = sample_duration - end_duration;
- sample_duration = end_duration;
- }
-
- if(audio.pc_speaker_last_playing)
- {
- increment_value =
- (int)((double)audio.pc_speaker_last_frequency / 44100.0 * 4294967296.0);
- increment_buffer = audio.pc_speaker_last_increment_buffer;
-
- for(i = 0; i < sample_duration; i++)
- {
- cur_sample = (Uint32)((increment_buffer & 0x80000000) >> 18) - 4096;
- *mix_dest_ptr += cur_sample;
- *(mix_dest_ptr + 1) += cur_sample;
- increment_buffer += increment_value;
- mix_dest_ptr += 2;
- }
- audio.pc_speaker_last_increment_buffer = increment_buffer;
- }
- else
- {
- mix_dest_ptr += (sample_duration * 2);
- }
-
- offset += sample_duration;
-
- if(offset < len / 4)
- audio.pc_speaker_last_playing = 0;
-
- while(offset < len / 4)
- {
- sound_system();
- sample_duration = (int)(pc_speaker_interval * audio.pc_speaker_note_duration);
-
- if(offset + sample_duration >= len / 4)
- {
- end_duration = (len / 4) - offset;
- audio.pc_speaker_last_duration = sample_duration - end_duration;
- audio.pc_speaker_last_playing = audio.pc_speaker_playing;
- audio.pc_speaker_last_frequency = audio.pc_speaker_frequency;
-
- sample_duration = end_duration;
- }
-
- offset += sample_duration;
-
- if(audio.pc_speaker_playing)
- {
- increment_value =
- (int)((double)audio.pc_speaker_frequency / 44100.0 * 4294967296.0);
- increment_buffer = 0;
-
- for(i = 0; i < sample_duration; i++)
- {
- cur_sample = (Uint32)((increment_buffer & 0x80000000) >> 18) - 4096;
- *mix_dest_ptr += cur_sample;
- *(mix_dest_ptr + 1) += cur_sample;
- increment_buffer += increment_value;
- mix_dest_ptr += 2;
- }
- audio.pc_speaker_last_increment_buffer = increment_buffer;
- }
- else
- {
- mix_dest_ptr += (sample_duration * 2);
- }
- }
-
- // Mix samples, if any are playing
-
- if(audio.num_samples_playing && music_on)
- {
- for(i = 0; i < 16; i++)
- {
- if(audio.samples_playing[i])
- {
- int read_len =
- ModPlug_Read(audio.samples_playing[i], audio.sample_buffers[i], len);
-
- mix_src_ptr = audio.sample_buffers[i];
- mix_dest_ptr = audio.mix_buffer;
-
- for(i2 = 0; i2 < read_len / 2; i2++)
- {
- *mix_dest_ptr += *mix_src_ptr;
- mix_src_ptr++;
- mix_dest_ptr++;
- }
-
- // If a full read wasn't done the sample's play is up, so destroy it
- if(read_len < len)
- end_individual_sample(i);
- }
- }
- }
-
- buffer_src_ptr = audio.mix_buffer;
- buffer_dest_ptr = (Sint16 *)stream;
-
- for(i = 0; i < len / 2; i++)
- {
- cur_sample = *buffer_src_ptr;
- if(cur_sample > 32767)
- cur_sample = 32767;
-
- if(cur_sample < -32768)
- cur_sample = -32768;
-
- *buffer_dest_ptr = cur_sample;
- buffer_src_ptr++;
- buffer_dest_ptr++;
- }
-}
-
-void init_audio(config_info *conf)
-{
- int buffer_size = conf->buffer_size;
-
- SDL_AudioSpec desired_spec =
- {
- 44100,
- AUDIO_S16SYS,
- 2,
- 0,
- buffer_size,
- 0,
- 0,
- audio_callback,
- 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;
-
- 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);
-
- SDL_OpenAudio(&desired_spec, &audio.audio_settings);
- audio.mod_buffer = (Sint16 *)malloc(audio.audio_settings.size);
- audio.mix_buffer = (Sint32 *)malloc(audio.audio_settings.size * 2);
- SDL_PauseAudio(0);
-}
-
-void load_mod(char *filename)
-{
- FILE *input_file;
- char *input_buffer;
- int file_size;
- int extension_pos = strlen(filename) - 4;
- char new_file[MAX_PATH];
-
- if(extension_pos && !strcasecmp(filename + extension_pos, ".gdm"))
- {
- 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);
-
- 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(translated_filename_src, new_file);
- }
-
- filename = new_file;
- }
-
- if(audio.mod_playing)
- end_mod();
-
- input_file = fsafeopen(filename, "rb");
-
- if(input_file)
- {
- file_size = filelength(input_file);
-
- input_buffer = (char *)malloc(file_size);
- fread(input_buffer, file_size, 1, input_file);
- audio.current_mod = ModPlug_Load(input_buffer, file_size);
-
- if(audio.current_mod)
- {
- audio.mod_playing = 1;
- }
-
- free(input_buffer);
- }
-}
-
-void end_mod(void)
-{
- if(audio.mod_playing)
- {
- ModPlug_Unload(audio.current_mod);
- audio.mod_playing = 0;
- }
-}
-
-void play_sample(int freq, char *filename)
-{
- FILE *input_file;
- char *input_buffer;
- int file_size;
- int extension_pos = strlen(filename) - 4;
- char new_file[256];
-
- // FIXME - destroy least recently used?
- if(audio.num_samples_playing >= MAX_SAMS)
- {
- unsigned int smallest = audio.sam_timestamps[0];
- int smallest_i = 0;
- int i;
- for(i = 1; i < MAX_SAMS; i++)
- {
- if(audio.sam_timestamps[i] < smallest)
- {
- smallest = audio.sam_timestamps[i];
- smallest_i = i;
- }
- }
-
- end_individual_sample(smallest_i);
- }
-
- if(extension_pos && !strcasecmp(filename + extension_pos, ".sam"))
- {
- 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);
-
- fsafetranslate(filename, translated_filename_src);
-
- if(fsafetranslate(new_file, translated_filename_dest) < 0)
- {
- // If it doesn't exist, create it by converting.
- convert_sam_to_wav(translated_filename_src, new_file);
- }
-
- filename = new_file;
- }
-
- input_file = fsafeopen(filename, "rb");
-
- if(input_file)
- {
- int i;
- ModPlugFile *sample_loaded;
-
- file_size = filelength(input_file);
-
- input_buffer = (char *)malloc(file_size);
- fread(input_buffer, file_size, 1, input_file);
- sample_loaded = ModPlug_Load(input_buffer, file_size);
-
- if(sample_loaded)
- {
- // 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;
-
- // Find a free position to put it
- for(i = 0; i < 16; i++)
- {
- if(audio.samples_playing[i] == NULL)
- break;
- }
-
- audio.samples_playing[i] = sample_loaded;
- audio.sample_buffers[i] =
- (Sint16 *)malloc(audio.audio_settings.size);
- audio.num_samples_playing++;
- audio.sam_timestamps[i] = get_ticks();
- }
-
- free(input_buffer);
- fclose(input_file);
- }
-}
-
-void end_individual_sample(int sam_num)
-{
- ModPlug_Unload(audio.samples_playing[sam_num]);
- free(audio.sample_buffers[sam_num]);
- audio.num_samples_playing--;
- audio.samples_playing[sam_num] = NULL;
-}
-
-void end_sample(void)
-{
- int i;
- for(i = 0; i < 16; i++)
- {
- if(audio.samples_playing[i])
- end_individual_sample(i);
- }
-}
-
-void jump_mod(int order)
-{
- if(audio.mod_playing)
- audio.current_mod->mSoundFile.SetCurrentOrder(order);
-}
-
-int get_order()
-{
- if(audio.mod_playing)
- return audio.current_mod->mSoundFile.GetCurrentOrder();
- else
- return 0;
-}
-
-
-// FIXME - This may have to be adjusted slightly. It SEEMS that
-// playing the module at a volume of 1-128 is suitable.
-
-void volume_mod(int vol)
-{
- if(audio.mod_playing)
- audio.current_mod->mSoundFile.SetMasterVolume((vol * music_gvol / 16) + 1);
-}
-
-// FIXME - Implement? The best route right now would be to load a module
-// then mangle it so it only plays the given sample at the given frequency.
-
-void spot_sample(int freq, int sample)
-{
-
-}
-
-void sound(int frequency, int duration)
-{
- audio.pc_speaker_playing = 1;
- audio.pc_speaker_frequency = frequency;
- audio.pc_speaker_note_duration = duration;
-}
-
-void nosound(int duration)
-{
- audio.pc_speaker_playing = 0;
- audio.pc_speaker_note_duration = duration;
-}
-
-
-int filelength(FILE *fp)
-{
- int length;
-
- fseek(fp, 0, SEEK_END);
- length = ftell(fp);
- fseek(fp, 0, SEEK_SET);
-
- return length;
-}
-
-const int default_period = 428;
-
-// Based off of original source by madbrain
-
-void convert_sam_to_wav(char *source_name, char *dest_name)
-{
- FILE *source, *dest;
- int frequency;
- int source_length, dest_length;
-
- char *data;
- int i;
-
- source = fopen(source_name, "rb");
-
- if(source == NULL)
- return;
-
- dest = fopen(dest_name, "wb");
-
- source_length = filelength(source);
-
- frequency = freq_conversion / default_period;
- data = (char *)malloc(source_length + 44);
- dest_length = source_length - 8;
-
- data[0] = 'R';
- data[1] = 'I';
- data[2] = 'F';
- data[3] = 'F';
- data[4] = dest_length & 0xFF;
- data[5] = (dest_length >> 8) & 0xFF;
- data[6] = (dest_length >> 16) & 0xFF;
- data[7] = (dest_length >> 24) & 0xFF;
- data[8] = 'W';
- data[9] = 'A';
- data[10] = 'V';
- data[11] = 'E';
-
- data[12] = 'f';
- data[13] = 'm';
- data[14] = 't';
- data[15] = ' ';
- data[16] = 16;
- data[17] = 0;
- data[18] = 0;
- data[19] = 0;
- data[20] = 1; // pcm
- data[21] = 0;
- data[22] = 2; // mono
- data[23] = 0;
-
- // frequency, bytes/second
- data[24] = frequency & 0xFF;
- data[25] = (frequency >> 8) & 0xFF;
- data[26] = (frequency >> 16) & 0xFF;
- data[27] = (frequency >> 24) & 0xFF;
- data[28] = frequency & 0xFF;
- data[29] = (frequency >> 8) & 0xFF;
- data[30] = (frequency >> 16) & 0xFF;
- data[31] = (frequency >> 24) & 0xFF;
-
- data[32] = 1; // total bytes/sample
- data[33] = 0;
- data[34] = 8; // bit depth
- data[35] = 0;
- data[36] = 'd';
- data[37] = 'a';
- data[38] = 't';
- data[39] = 'a';
-
- // Sample length
- data[40] = source_length & 0xFF;
- data[41] = (source_length >> 8) & 0xFF;
- data[42] = (source_length >> 16) & 0xFF;
- data[43] = (source_length >> 24) & 0xFF;
-
- fread(data + 44, source_length, 1, source);
-
- for(i = 44; i <dest_length; i++)
- data[i] += 128;
-
- fwrite(data, dest_length, 1, dest);
-
- free(data);
- fclose(source);
- fclose(dest);
-}
+/* $Id$
+ * MegaZeux
+ *
+ * Copyright (C) 2004 Gilead Kutnick
+ * Copyright (C) 2004 madbrain
+ *
+ * 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.
+ */
+
+// Code to handle module playing, sample playing, and PC speaker
+// sfx emulation.
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include "audio.h"
+#include "modplug.h"
+#include "libmodplug/stdafx.h"
+#include "libmodplug/sndfile.h"
+#include "SDL.h"
+#include "sfx.h"
+#include "data.h"
+#include "configure.h"
+#include "gdm2s3m.h"
+#include "fsafeopen.h"
+#include "delay.h"
+
+struct _ModPlugFile
+{
+ CSoundFile mSoundFile;
+};
+
+audio_struct audio;
+
+int error_mode;
+
+// An update should happen every 2ms, so this many samples
+const double pc_speaker_interval = 44100 / 500;
+const int freq_conversion = 3579364;
+
+void audio_callback(void *userdata, Uint8 *stream, int len)
+{
+ int i, i2, offset = 0;
+ Sint16 *mix_src_ptr;
+ Sint32 *mix_dest_ptr;
+ Sint32 *buffer_src_ptr;
+ Sint16 *buffer_dest_ptr;
+ Sint32 cur_sample;
+ int sample_duration, end_duration;
+ int increment_value, increment_buffer;
+
+ if(audio.mod_playing && music_on)
+ {
+ int read_len =
+ ModPlug_Read(audio.current_mod, audio.mod_buffer, len);
+
+ if(read_len < 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);
+ }
+ }
+ else
+ {
+ memset(audio.mod_buffer, 0, len);
+ }
+
+ mix_dest_ptr = audio.mix_buffer;
+ mix_src_ptr = audio.mod_buffer;
+
+ for(i = 0; i < len / 2; i++)
+ {
+ *mix_dest_ptr = *mix_src_ptr;
+ mix_dest_ptr++;
+ mix_src_ptr++;
+ }
+
+ // Mix PC speaker effect. First get whatever ran over from last time.
+
+ mix_dest_ptr = audio.mix_buffer;
+
+ sample_duration = audio.pc_speaker_last_duration;
+
+ if(sample_duration >= len / 4)
+ {
+ end_duration = len / 4;
+ audio.pc_speaker_last_duration = sample_duration - end_duration;
+ sample_duration = end_duration;
+ }
+
+ if(audio.pc_speaker_last_playing)
+ {
+ increment_value =
+ (int)((double)audio.pc_speaker_last_frequency / 44100.0 * 4294967296.0);
+ increment_buffer = audio.pc_speaker_last_increment_buffer;
+
+ for(i = 0; i < sample_duration; i++)
+ {
+ cur_sample = (Uint32)((increment_buffer & 0x80000000) >> 18) - 4096;
+ *mix_dest_ptr += cur_sample;
+ *(mix_dest_ptr + 1) += cur_sample;
+ increment_buffer += increment_value;
+ mix_dest_ptr += 2;
+ }
+ audio.pc_speaker_last_increment_buffer = increment_buffer;
+ }
+ else
+ {
+ mix_dest_ptr += (sample_duration * 2);
+ }
+
+ offset += sample_duration;
+
+ if(offset < len / 4)
+ audio.pc_speaker_last_playing = 0;
+
+ while(offset < len / 4)
+ {
+ sound_system();
+ sample_duration = (int)(pc_speaker_interval * audio.pc_speaker_note_duration);
+
+ if(offset + sample_duration >= len / 4)
+ {
+ end_duration = (len / 4) - offset;
+ audio.pc_speaker_last_duration = sample_duration - end_duration;
+ audio.pc_speaker_last_playing = audio.pc_speaker_playing;
+ audio.pc_speaker_last_frequency = audio.pc_speaker_frequency;
+
+ sample_duration = end_duration;
+ }
+
+ offset += sample_duration;
+
+ if(audio.pc_speaker_playing)
+ {
+ increment_value =
+ (int)((double)audio.pc_speaker_frequency / 44100.0 * 4294967296.0);
+ increment_buffer = 0;
+
+ for(i = 0; i < sample_duration; i++)
+ {
+ cur_sample = (Uint32)((increment_buffer & 0x80000000) >> 18) - 4096;
+ *mix_dest_ptr += cur_sample;
+ *(mix_dest_ptr + 1) += cur_sample;
+ increment_buffer += increment_value;
+ mix_dest_ptr += 2;
+ }
+ audio.pc_speaker_last_increment_buffer = increment_buffer;
+ }
+ else
+ {
+ mix_dest_ptr += (sample_duration * 2);
+ }
+ }
+
+ // Mix samples, if any are playing
+
+ if(audio.num_samples_playing && music_on)
+ {
+ for(i = 0; i < 16; i++)
+ {
+ if(audio.samples_playing[i])
+ {
+ int read_len =
+ ModPlug_Read(audio.samples_playing[i], audio.sample_buffers[i], len);
+
+ mix_src_ptr = audio.sample_buffers[i];
+ mix_dest_ptr = audio.mix_buffer;
+
+ for(i2 = 0; i2 < read_len / 2; i2++)
+ {
+ *mix_dest_ptr += *mix_src_ptr;
+ mix_src_ptr++;
+ mix_dest_ptr++;
+ }
+
+ // If a full read wasn't done the sample's play is up, so destroy it
+ if(read_len < len)
+ end_individual_sample(i);
+ }
+ }
+ }
+
+ buffer_src_ptr = audio.mix_buffer;
+ buffer_dest_ptr = (Sint16 *)stream;
+
+ for(i = 0; i < len / 2; i++)
+ {
+ cur_sample = *buffer_src_ptr;
+ if(cur_sample > 32767)
+ cur_sample = 32767;
+
+ if(cur_sample < -32768)
+ cur_sample = -32768;
+
+ *buffer_dest_ptr = cur_sample;
+ buffer_src_ptr++;
+ buffer_dest_ptr++;
+ }
+}
+
+void init_audio(config_info *conf)
+{
+ int buffer_size = conf->buffer_size;
+
+ SDL_AudioSpec desired_spec =
+ {
+ 44100,
+ AUDIO_S16SYS,
+ 2,
+ 0,
+ buffer_size,
+ 0,
+ 0,
+ audio_callback,
+ 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;
+
+ 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);
+
+ SDL_OpenAudio(&desired_spec, &audio.audio_settings);
+ audio.mod_buffer = (Sint16 *)malloc(audio.audio_settings.size);
+ audio.mix_buffer = (Sint32 *)malloc(audio.audio_settings.size * 2);
+ SDL_PauseAudio(0);
+}
+
+void load_mod(char *filename)
+{
+ FILE *input_file;
+ char *input_buffer;
+ int file_size;
+ int extension_pos = strlen(filename) - 4;
+ char new_file[MAX_PATH];
+
+ if(extension_pos && !strcasecmp(filename + extension_pos, ".gdm"))
+ {
+ 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);
+
+ 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(translated_filename_src, new_file);
+ }
+
+ filename = new_file;
+ }
+
+ if(audio.mod_playing)
+ end_mod();
+
+ input_file = fsafeopen(filename, "rb");
+
+ if(input_file)
+ {
+ file_size = filelength(input_file);
+
+ input_buffer = (char *)malloc(file_size);
+ fread(input_buffer, file_size, 1, input_file);
+ audio.current_mod = ModPlug_Load(input_buffer, file_size);
+
+ if(audio.current_mod)
+ {
+ audio.mod_playing = 1;
+ }
+
+ free(input_buffer);
+
+ fclose(input_file);
+ }
+}
+
+void end_mod(void)
+{
+ if(audio.mod_playing)
+ {
+ audio.mod_playing = 0;
+ ModPlug_Unload(audio.current_mod);
+ }
+}
+
+void play_sample(int freq, char *filename)
+{
+ FILE *input_file;
+ char *input_buffer;
+ int file_size;
+ int extension_pos = strlen(filename) - 4;
+ char new_file[256];
+
+ // FIXME - destroy least recently used?
+ if(audio.num_samples_playing >= MAX_SAMS)
+ {
+ unsigned int smallest = audio.sam_timestamps[0];
+ int smallest_i = 0;
+ int i;
+
+ for(i = 1; i < MAX_SAMS; i++)
+ {
+ if(audio.sam_timestamps[i] < smallest)
+ {
+ smallest = audio.sam_timestamps[i];
+ smallest_i = i;
+ }
+ }
+
+ end_individual_sample(smallest_i);
+ }
+
+ if(extension_pos && !strcasecmp(filename + extension_pos, ".sam"))
+ {
+ 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);
+
+ fsafetranslate(filename, translated_filename_src);
+
+ if(fsafetranslate(new_file, translated_filename_dest) < 0)
+ {
+ // If it doesn't exist, create it by converting.
+ convert_sam_to_wav(translated_filename_src, new_file);
+ }
+
+ filename = new_file;
+ }
+
+ input_file = fsafeopen(filename, "rb");
+
+ if(input_file)
+ {
+ int i;
+ ModPlugFile *sample_loaded;
+
+ file_size = filelength(input_file);
+
+ input_buffer = (char *)malloc(file_size);
+ fread(input_buffer, file_size, 1, input_file);
+ sample_loaded = ModPlug_Load(input_buffer, file_size);
+
+ if(sample_loaded)
+ {
+ // 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;
+
+ // Find a free position to put it
+ for(i = 0; i < 16; i++)
+ {
+ if(audio.samples_playing[i] == NULL)
+ break;
+ }
+
+ audio.sample_buffers[i] =
+ (Sint16 *)malloc(audio.audio_settings.size);
+ audio.sam_timestamps[i] = get_ticks();
+ audio.num_samples_playing++;
+ audio.samples_playing[i] = sample_loaded;
+ }
+
+ free(input_buffer);
+ fclose(input_file);
+ }
+}
+
+void end_individual_sample(int sam_num)
+{
+ ModPlugFile *current_sam = audio.samples_playing[sam_num];
+ audio.samples_playing[sam_num] = NULL;
+ audio.num_samples_playing--;
+ ModPlug_Unload(current_sam);
+ free(audio.sample_buffers[sam_num]);
+}
+
+void end_sample(void)
+{
+ int i;
+ for(i = 0; i < 16; i++)
+ {
+ if(audio.samples_playing[i])
+ end_individual_sample(i);
+ }
+}
+
+void jump_mod(int order)
+{
+ if(audio.mod_playing)
+ audio.current_mod->mSoundFile.SetCurrentOrder(order);
+}
+
+int get_order()
+{
+ if(audio.mod_playing)
+ return audio.current_mod->mSoundFile.GetCurrentOrder();
+ else
+ return 0;
+}
+
+
+// FIXME - This may have to be adjusted slightly. It SEEMS that
+// playing the module at a volume of 1-128 is suitable.
+
+void volume_mod(int vol)
+{
+ if(audio.mod_playing)
+ audio.current_mod->mSoundFile.SetMasterVolume((vol * music_gvol / 16) + 1);
+}
+
+// FIXME - Implement? The best route right now would be to load a module
+// then mangle it so it only plays the given sample at the given frequency.
+
+void spot_sample(int freq, int sample)
+{
+
+}
+
+void sound(int frequency, int duration)
+{
+ audio.pc_speaker_playing = 1;
+ audio.pc_speaker_frequency = frequency;
+ audio.pc_speaker_note_duration = duration;
+}
+
+void nosound(int duration)
+{
+ audio.pc_speaker_playing = 0;
+ audio.pc_speaker_note_duration = duration;
+}
+
+
+int filelength(FILE *fp)
+{
+ int length;
+
+ fseek(fp, 0, SEEK_END);
+ length = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+
+ return length;
+}
+
+const int default_period = 428;
+
+// Based off of original source by madbrain
+
+void convert_sam_to_wav(char *source_name, char *dest_name)
+{
+ FILE *source, *dest;
+ int frequency;
+ int source_length, dest_length;
+
+ char *data;
+ int i;
+
+ source = fopen(source_name, "rb");
+
+ if(source == NULL)
+ return;
+
+ dest = fopen(dest_name, "wb");
+
+ source_length = filelength(source);
+
+ frequency = freq_conversion / default_period;
+ data = (char *)malloc(source_length + 44);
+ dest_length = source_length - 8;
+
+ data[0] = 'R';
+ data[1] = 'I';
+ data[2] = 'F';
+ data[3] = 'F';
+ data[4] = dest_length & 0xFF;
+ data[5] = (dest_length >> 8) & 0xFF;
+ data[6] = (dest_length >> 16) & 0xFF;
+ data[7] = (dest_length >> 24) & 0xFF;
+ data[8] = 'W';
+ data[9] = 'A';
+ data[10] = 'V';
+ data[11] = 'E';
+
+ data[12] = 'f';
+ data[13] = 'm';
+ data[14] = 't';
+ data[15] = ' ';
+ data[16] = 16;
+ data[17] = 0;
+ data[18] = 0;
+ data[19] = 0;
+ data[20] = 1; // pcm
+ data[21] = 0;
+ data[22] = 2; // mono
+ data[23] = 0;
+
+ // frequency, bytes/second
+ data[24] = frequency & 0xFF;
+ data[25] = (frequency >> 8) & 0xFF;
+ data[26] = (frequency >> 16) & 0xFF;
+ data[27] = (frequency >> 24) & 0xFF;
+ data[28] = frequency & 0xFF;
+ data[29] = (frequency >> 8) & 0xFF;
+ data[30] = (frequency >> 16) & 0xFF;
+ data[31] = (frequency >> 24) & 0xFF;
+
+ data[32] = 1; // total bytes/sample
+ data[33] = 0;
+ data[34] = 8; // bit depth
+ data[35] = 0;
+ data[36] = 'd';
+ data[37] = 'a';
+ data[38] = 't';
+ data[39] = 'a';
+
+ // Sample length
+ data[40] = source_length & 0xFF;
+ data[41] = (source_length >> 8) & 0xFF;
+ data[42] = (source_length >> 16) & 0xFF;
+ data[43] = (source_length >> 24) & 0xFF;
+
+ fread(data + 44, source_length, 1, source);
+
+ for(i = 44; i <dest_length; i++)
+ data[i] += 128;
+
+ fwrite(data, dest_length, 1, dest);
+
+ free(data);
+ fclose(source);
+ fclose(dest);
+}
View
156 audio.h → src/audio.h
@@ -1,78 +1,78 @@
-/* $Id$
- * MegaZeux
- *
- * Copyright (C) 2004 Gilead Kutnick
- *
- * 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.
- */
-
-// Definitions for audio.cpp
-
-#ifndef AUDIO_H
-#define AUDIO_H
-
-#include "SDL.h"
-#include "modplug.h"
-#include "configure.h"
-
-#define MAX_SAMS 16
-
-typedef struct
-{
- SDL_AudioSpec audio_settings;
- ModPlugFile *current_mod;
- ModPlug_Settings mod_settings;
- int mod_playing;
- int num_samples_playing;
- ModPlugFile *samples_playing[MAX_SAMS];
- Sint32 *mix_buffer;
- Sint16 *mod_buffer;
- Sint16 *sample_buffers[MAX_SAMS];
- Uint32 sam_timestamps[MAX_SAMS];
- Uint32 repeat_timeout;
- Uint32 repeat_timestamp;
- Uint32 pc_speaker_on;
- Uint32 pc_speaker_playing;
- Uint32 pc_speaker_frequency;
- Sint32 pc_speaker_last_frequency;
- Uint32 pc_speaker_note_duration;
- Uint32 pc_speaker_last_duration;
- Uint32 pc_speaker_last_playing;
- Uint32 pc_speaker_sample_cutoff;
- Uint32 pc_speaker_last_increment_buffer;
-} audio_struct;
-
-void init_audio(config_info *conf);
-void load_mod(char *filename);
-void end_mod(void);
-void play_sample(int freq, char *filename);
-void end_individual_sample(int sam_num);
-void end_sample(void);
-void jump_mod(int order);
-int get_order();
-void volume_mod(int vol);
-void mod_exit(void);
-void mod_init(void);
-void spot_sample(int freq, int sample);
-int free_sam_cache(char clear_all);
-void fix_global_volumes(void);
-void sound(int frequency, int duration);
-void nosound(int duration);
-int filelength(FILE *fp);
-void convert_sam_to_wav(char *source_name, char *dest_name);
-
-extern int error_mode;
-
-#endif
+/* $Id$
+ * MegaZeux
+ *
+ * Copyright (C) 2004 Gilead Kutnick
+ *
+ * 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.
+ */
+
+// Definitions for audio.cpp
+
+#ifndef AUDIO_H
+#define AUDIO_H
+
+#include "SDL.h"
+#include "modplug.h"
+#include "configure.h"
+
+#define MAX_SAMS 16
+
+typedef struct
+{
+ SDL_AudioSpec audio_settings;
+ ModPlugFile *current_mod;
+ ModPlug_Settings mod_settings;
+ int mod_playing;
+ int num_samples_playing;
+ ModPlugFile *samples_playing[MAX_SAMS];
+ Sint32 *mix_buffer;
+ Sint16 *mod_buffer;
+ Sint16 *sample_buffers[MAX_SAMS];
+ Uint32 sam_timestamps[MAX_SAMS];
+ Uint32 repeat_timeout;
+ Uint32 repeat_timestamp;
+ Uint32 pc_speaker_on;
+ Uint32 pc_speaker_playing;
+ Uint32 pc_speaker_frequency;
+ Sint32 pc_speaker_last_frequency;
+ Uint32 pc_speaker_note_duration;
+ Uint32 pc_speaker_last_duration;
+ Uint32 pc_speaker_last_playing;
+ Uint32 pc_speaker_sample_cutoff;
+ Uint32 pc_speaker_last_increment_buffer;
+} audio_struct;
+
+void init_audio(config_info *conf);
+void load_mod(char *filename);
+void end_mod(void);
+void play_sample(int freq, char *filename);
+void end_individual_sample(int sam_num);
+void end_sample(void);
+void jump_mod(int order);
+int get_order();
+void volume_mod(int vol);
+void mod_exit(void);
+void mod_init(void);
+void spot_sample(int freq, int sample);
+int free_sam_cache(char clear_all);
+void fix_global_volumes(void);
+void sound(int frequency, int duration);
+void nosound(int duration);
+int filelength(FILE *fp);
+void convert_sam_to_wav(char *source_name, char *dest_name);
+
+extern int error_mode;
+
+#endif
View
622 block.cpp → src/block.cpp
@@ -1,311 +1,311 @@
-/* $Id$
- * MegaZeux
- *
- * Copyright (C) 1996 Greg Janson
- * Copyright (C) 1998 Matthew D. Williams - dbwilli@scsn.net
- *
- * 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.
- */
-
-/* Block functions and dialogs */
-
-#include <stdio.h>
-
-#include "helpsys.h"
-#include "idput.h"
-#include "error.h"
-#include "block.h"
-#include "window.h"
-#include "data.h"
-#include "idarray.h"
-#include "world.h"
-
-//--------------------------
-//
-// ( ) Copy block
-// ( ) Move block
-// ( ) Clear block
-// ( ) Flip block
-// ( ) Mirror block
-// ( ) Paint block
-// ( ) Copy to/from overlay
-// ( ) Save as ANSi
-// ( ) Save as MZM
-//
-// _OK_ _Cancel_
-//
-//--------------------------
-
-char bdi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
-char bdi_xs[3] = { 2, 5, 15 };
-char bdi_ys[3] = { 2, 12, 12 };
-
-char *bdi_strs[3] =
-{
- "Copy block\n"
- "Copy block (repeated)\n"
- "Move block\n"
- "Clear block\n"
- "Flip block\n"
- "Mirror block\n"
- "Paint block\n"
- "Copy to/from overlay\n"
- "Save as MZM",
- "OK", "Cancel"
-};
-
-int bdi_p1s[3] = { 9, 0, -1};
-int bdi_p2s[1] = { 21 };
-int block_op = 0;
-void *bdi_storage[1] = { &block_op };
-
-dialog bdi =
-{
- 26, 3, 54, 17, "Choose block command", 3, bdi_types, bdi_xs,
- bdi_ys, bdi_strs, bdi_p1s, bdi_p2s, bdi_storage, 0
-};
-
-int block_cmd(World *mzx_world)
-{
- int dialog_ret;
- set_context(73);
- dialog_ret = run_dialog(mzx_world, &bdi);
- pop_context();
- if(dialog_ret)
- return -1;
-
- return block_op;
-}
-
-char adi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
-char adi_xs[3] = { 6, 5, 15 };
-char adi_ys[3] = { 4, 11, 11 };
-char *adi_strs[3] = { "Custom Block\nCustom Floor\nText", "OK", "Cancel" };
-int adi_p1s[3] = { 3, 0, -1 };
-int adi_p2s[1] = { 12 };
-int obj_type = 0;
-void *adi_storage[1] = { &obj_type };
-
-dialog adi =
-{
- 26, 4, 53, 17, "Object type", 3, adi_types, adi_xs, adi_ys, adi_strs,
- adi_p1s, adi_p2s, adi_storage, 0
-};
-
-int rtoo_obj_type(World *mzx_world)
-{
- set_context(74);
-
- if(run_dialog(mzx_world, &adi))
- {
- pop_context();
- return -1;
- }
-
- pop_context();
- return obj_type;
-}
-
-char csdi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
-char csdi_xs[3] = { 4, 5, 15 };
-char csdi_ys[3] = { 4, 11, 11 };
-char *csdi_strs[3] =
-{
- "MegaZeux default\n"
- "ASCII set\n"
- "SMZX set\n"
- "Blank set", "OK", "Cancel"
-};
-
-int csdi_p1s[3] = { 4, 0, -1};
-int csdi_p2s[1] = { 16 };
-int cs_type = 0;
-void *csdi_storage[1] = { &cs_type };
-
-dialog csdi =
-{