Skip to content
Browse files

MegaZeux 2.80 release.

  • Loading branch information...
1 parent 058a44d commit f9d511465cb7a5be6e299f87388756d33c16ee03 @ajs1984 committed
Sorry, we could not display the entire diff because it was too big.
View
342 COPYING.DOC
@@ -0,0 +1,342 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 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.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ 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
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+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) <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
+ 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., 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) 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.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+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
BIN GUS.MSE
Binary file not shown.
View
48 MZX270w_Bugs.txt
@@ -0,0 +1,48 @@
+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
BIN MZXBLANK.FIL
Binary file not shown.
View
BIN MZX_CMOD.FIL
Binary file not shown.
View
131 Makefile
@@ -1,95 +1,36 @@
-#
-# You need TASM 3.0 and Borland C++ 3.0 to use this Makefile.
-#
-# Please note that in these old versions of MegaZeux, the source
-# for the robot editor was lost. Therefore this file just hacks
-# in robo_ed.obj when required.
-#
-
-.AUTODEPEND
-
-INCPATH=C:\BORLANDC\INCLUDE;.
-LIBPATH=C:\BORLANDC\LIB;.
-
-CC = bcc +megazeux.cfg -I$(INCPATH) -L$(LIBPATH)
-TASM = tasm
-TLIB = tlib
-TLINK = tlink
-
-.c.obj:
- @$(CC) -c {$< }
-
-.cpp.obj:
- @$(CC) -c {$< }
-
-.asm.obj:
- @$(TASM) /jWARN /MX /M5 /ZI /O /T $<,$@
-
-obj = arrowkey.obj beep.obj blink.obj block.obj boardmem.obj \
-ceh.obj charset.obj char_ed.obj comp_chk.obj counter.obj cursor.obj \
-data.obj data2.obj detect.obj dt_data.obj edit.obj edit_di.obj egacode.obj \
-ems.obj error.obj ezboard.obj expr.obj fill.obj game.obj game2.obj getkey.obj \
-graphics.obj helpsys.obj hexchar.obj idarray.obj idput.obj intake.obj \
-main.obj meminter.obj meter.obj mouse.obj mstring.obj mzm.obj new_mod.obj \
-palette.obj pal_ed.obj param.obj password.obj random.obj retrace.obj \
-roballoc.obj runrobot.obj runrobo2.obj saveload.obj scrdisp.obj scrdump.obj \
-sfx.obj sfx_edit.obj sprite.obj string.obj timer.obj window.obj vlayer.obj
-
-#
-# I'd rather this wasn't necessary, but I can't think of a way either in
-# Make or DOS to convert the space separated list above into a + separated
-# list. So it's just copy/pasted. This tr command helps:
-# tr ' ' '+' << "EOF"
-#
-lobj = arrowkey.obj+beep.obj+blink.obj+block.obj+boardmem.obj+\
-ceh.obj+charset.obj+char_ed.obj+comp_chk.obj+counter.obj+cursor.obj+\
-data.obj+data2.obj+detect.obj+dt_data.obj+edit.obj+edit_di.obj+egacode.obj+\
-ems.obj+error.obj+ezboard.obj+expr.obj+fill.obj+game.obj+game2.obj+getkey.obj+\
-graphics.obj+helpsys.obj+hexchar.obj+idarray.obj+idput.obj+intake.obj+\
-main.obj+meminter.obj+meter.obj+mouse.obj+mstring.obj+mzm.obj+new_mod.obj+\
-palette.obj+pal_ed.obj+param.obj+password.obj+random.obj+retrace.obj+\
-roballoc.obj+runrobot.obj+runrobo2.obj+saveload.obj+scrdisp.obj+scrdump.obj+\
-sfx.obj+sfx_edit.obj+sprite.obj+string.obj+timer.obj+window.obj+vlayer.obj
-
-all: megazeux.exe fix.exe getpw.exe killgbl.exe txt2hlp.exe ver1to2.exe
-
-megazeux.exe: $(obj)
- @$(TLINK) /m/c/d/P-/L$(LIBPATH) @&&|
-c0l.obj+$(lobj)+robo_ed.obj,megazeux,megazeux,mse_cl.lib+cl.lib
-|
-
-#
-# Other external binaries that might be useful
-#
-
-fix.exe: fix.obj
- @$(TLINK) /m/c/d/P-/L$(LIBPATH) @&&|
-c0l.obj+fix.obj,fix,fix,cl.lib
-|
-
-getpw.exe: getpw.obj
- @$(TLINK) /m/c/d/P-/L$(LIBPATH) @&&|
-c0l.obj+getpw.obj,getpw,getpw,cl.lib
-|
-
-killgbl.exe: killgbl.obj
- @$(TLINK) /m/c/d/P-/L$(LIBPATH) @&&|
-c0l.obj+killgbl.obj,killgbl,killgbl,cl.lib
-|
-
-txt2hlp.exe: txt2hlp.obj
- @$(TLINK) /m/c/d/P-/L$(LIBPATH) @&&|
-c0l.obj+txt2hlp.obj,txt2hlp,txt2hlp,cl.lib
-|
-
-ver1to2.exe: ver1to2.obj
- @$(TLINK) /m/c/d/P-/L$(LIBPATH) @&&|
-c0l.obj+ver1to2.obj,ver1to2,ver1to2,cl.lib
-|
-
-clean:
- @ren robo_ed.obj robo_ed.bak
- @del *.obj
- @ren robo_ed.bak robo_ed.obj
- @del *.exe
- @del *.map
+# 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
+
+PREFIX = /usr
+
+BIN = mzx280.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}
+
+clean:
+ rm -f *.o ${BIN}
+
View
43 Makefile.linux
@@ -0,0 +1,43 @@
+# 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
+
+PREFIX = /usr
+
+BIN = mzx280
+
+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
BIN PAS.MSE
Binary file not shown.
View
0 README.TXT
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
BIN ROBO_ED.OBJ
Binary file not shown.
View
BIN SB16.MSE
Binary file not shown.
View
BIN SB1X.MSE
Binary file not shown.
View
BIN SB2X.MSE
Binary file not shown.
View
BIN SBPRO.MSE
Binary file not shown.
View
475 arrowkey.asm
@@ -1,475 +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.
-
-;
-; ARROWKEY.ASM- Code to intercept int 9 to handle the keyboard and keep
-; track of the status of arrow keys, space, and delete.
-;
-
-Ideal
-
-include "arrowkey.inc"
-
-p186
-JUMPS
-include "model.inc"
-
-Codeseg
-
-keyb_mode db 0
-key_code db 0
-up_pressed db 0
-dn_pressed db 0
-lf_pressed db 0
-rt_pressed db 0
-sp_pressed db 0
-del_pressed db 0
-old_vector_09 dd 0
-kb_installed db 0
-curr_table db 1
-
-; 256 byte table for keyboard codes-
-; 0 means pass on to normal handler
-; 1 means discard
-; 2 means dump and loop for another keypress
-; 3 means special (arrow, space, or delete)
-
-action_table db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;000h - 00Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 ;010h - 01Fh
- db 0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0 ;020h - 02Fh
- db 0,0,0,0,0,0,1,1,1,3,0,0,0,0,0,0 ;030h - 03Fh
- db 0,0,0,0,0,1,1,0,3,0,0,3,0,3,0,0 ;040h - 04Fh
- db 3,0,0,3,1,0,0,0,0,0,0,0,0,0,0,0 ;050h - 05Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 ;060h - 06Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;070h - 07Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;080h - 08Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 ;090h - 09Fh
- db 0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0 ;0A0h - 0AFh
- db 0,0,0,0,0,0,1,1,1,3,0,0,0,0,0,0 ;0B0h - 0BFh
- db 0,0,0,0,0,1,1,0,3,0,0,3,0,3,0,0 ;0C0h - 0CFh
- db 3,0,0,3,1,0,0,0,0,0,0,0,0,0,0,0 ;0D0h - 0DFh
- db 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 ;0E0h - 0EFh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;0F0h - 0FFh
-
-; Table #2 is a more normal table- It lets arrows, space, delete, alt,
-; and shift through normally.
-
-action_tbl2 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;000h - 00Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 ;010h - 01Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;020h - 02Fh
- db 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 ;030h - 03Fh
- db 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 ;040h - 04Fh
- db 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0 ;050h - 05Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 ;060h - 06Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;070h - 07Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;080h - 08Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 ;090h - 09Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;0A0h - 0AFh
- db 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 ;0B0h - 0BFh
- db 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 ;0C0h - 0CFh
- db 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0 ;0D0h - 0DFh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 ;0E0h - 0EFh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;0F0h - 0FFh
-
-state_table db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;000h - 00Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;010h - 01Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;020h - 02Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;030h - 03Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;040h - 04Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;050h - 05Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;060h - 06Fh
- db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;070h - 07Fh
-
-
-;
-; Function- intercept_09
-;
-; New keyboard handler. (game orientated) Above variables will now contain
-; current status (1=pressed, 0=not pressed) of the arrow keys, (both numpad
-; and regular) delete, and space. Pause, scroll-lock, num-lock, print screen,
-; sysrq, ctrl-c, and ctrl-s are all surpressed. Alt, Ctrl, and Shift are all
-; ignored from now on. All other keypressed are interpreted as normal and
-; eventually sent to the keyboard buffer to be read as normal. The above
-; variables are set to 1 and held there if a key is held, but if you change
-; one to another number other than 0 it will stay there instead of flipping
-; back to 0. IE if you set rt_pressed to 2 and right is held, it will NOT
-; change rt_pressed to 1. Release will still set it to 0 however.
-;
-
-proc intercept_09 far
- pusha
-
-@@key_loop:
- ; Get scan code
- sti
- in al,60h
- ; This is special code that will set the key array too.
- ; The msb determines if the key was set or released..
- mov cl, al
- ; Not it; 0 for released, 1 for pressed.
- not cl
- ; Put it at the lsb...
- shr cl, 7
- ; Make another copy for the index...
- mov bx, ax
- ; Only interested in the 7 least significant bits.
- and bx, 07Fh
- add bx, OFFSET cs:state_table
- ; Voila!
- mov [cs:bx], cl
- mov [key_code],al
-
- ; Set dl to 0, which means no loop
-; xor dl,dl
-
- ; AL: (according to table above)
- ; 48h UP C8h UP RELEASED
- ; 50h DOWN D0h DOWN RELEASED
- ; 4Bh LEFT CBh LEFT RELEASED
- ; 4Dh RIGHT CDh RIGHT RELEASED
- ; 39h SPACE B9h SPACE RELEASED
- ; 53h DELETE D3h DELETE RELEASED
- ;
- ; E0h or E1h : Dump and loop
- ;
- ; Discard:
- ; 1Dh, 2Ah, 36h, 37h, 38h, 45h, 46h, 54h, 6Fh,
- ; 9Dh, AAh, B6h, B7h, B8h, C5h, C6h, D4h, EFh
-
- ; Save al in cl, get correct table in CS:BX
- mov cl,al
- mov bx,OFFSET cs:action_table
- cmp [curr_table],0
- je @@table_correct
- add bx,256 ; Table 2.
-@@table_correct:
-
- ; xlat to get code
- xlat [cs:bx]
-
- ; Check code- 0 to pass on, 1 to dump, 2 to dump and continue
- cmp al,0
- je @@normal_handler
- cmp al,1
- je @@discard_key
-; cmp al,2
-; jne @@special_key
-
- ; Dump and continue- set dl to 1 to note a loop, then go to dump
-; inc dl
-; jmp @@discard_key
-
-@@special_key:
- ; Key press-
- cmp cl,53h
- je @@del
- cmp cl,48h
- je @@up
- cmp cl,50h
- je @@dn
- cmp cl,4Bh
- je @@lf
- cmp cl,4Dh
- je @@rt
- cmp cl,39h
- je @@space
-
- ; Key release-
- cmp cl,0D3h
- je @@del_off
- cmp cl,0C8h
- je @@up_off
- cmp cl,0D0h
- je @@dn_off
- cmp cl,0CBh
- je @@lf_off
- cmp cl,0CDh
- je @@rt_off
-
- ; Must be 0B9h, or @@space_off
-
-@@space_off:
- mov [cs:sp_pressed],0
- jmp @@discard_key
-@@del:
- ; Only set if not already set somehow
- cmp [cs:del_pressed],0
- jne @@discard_key
- mov [cs:del_pressed],1
- jmp @@discard_key
-@@del_off:
- mov [cs:del_pressed],0
- jmp @@discard_key
-@@up:
- cmp [cs:up_pressed],0
- jne @@discard_key
- mov [cs:up_pressed],1
- jmp @@discard_key
-@@dn:
- cmp [cs:dn_pressed],0
- jne @@discard_key
- mov [cs:dn_pressed],1
- jmp @@discard_key
-@@lf:
- cmp [cs:lf_pressed],0
- jne @@discard_key
- mov [cs:lf_pressed],1
- jmp @@discard_key
-@@rt:
- cmp [cs:rt_pressed],0
- jne @@discard_key
- mov [cs:rt_pressed],1
- jmp @@discard_key
-@@space:
- cmp [cs:sp_pressed],0
- jne @@discard_key
- mov [cs:sp_pressed],1
- jmp @@discard_key
-@@up_off:
- mov [cs:up_pressed],0
- jmp @@discard_key
-@@dn_off:
- mov [cs:dn_pressed],0
- jmp @@discard_key
-@@lf_off:
- mov [cs:lf_pressed],0
- jmp @@discard_key
-@@rt_off:
- mov [cs:rt_pressed],0
-
-@@discard_key:
-
- ; Two modes of discarding keys. (second chosen via command line)
- cmp [cs:keyb_mode],1
- je @@discard_key2
- in al,061h
- or al,80h
- out 061h,al
- and al,07Fh
- out 061h,al
-
- ; Loop?
-; cmp dl,1
-; je @@key_loop
-
- ; Reset interrupt
- cli
- mov al,020h
- out 020h,al
- sti
- popa
- iret
-
-@@discard_key2:
- in al,061h
- mov ah,al
- or al,80h
- out 061h,al
- mov al,ah
- out 061h,al
-
- ; Loop?
-; cmp dl,1
-; je @@key_loop
-
- ; Reset interrupt
- cli
- mov al,020h
- out 020h,al
- sti
- popa
- iret
-
-@@normal_handler:
-
- ; Reset ALT+Number work area
-
- mov bx,ds
- mov ax,0040h
- mov ds,ax
- mov [BYTE PTR ds:0019h],0
- mov ds,bx
-
- ; Not a key important to us- cycle through normal handler.
- popa
- jmp [DWORD PTR cs:old_vector_09]
-endp intercept_09
-
-;
-; Function- install_i09
-;
-; Installs new keyboard handler. Necessary before up_pressed, dn_pressed,
-; etc. have any meaning.
-;
-
-proc install_i09 far
- push ds es
- pusha
- ; All keys are released
- xor al,al
- mov [cs:dn_pressed],al
- mov [cs:up_pressed],al
- mov [cs:lf_pressed],al
- mov [cs:rt_pressed],al
- mov [cs:sp_pressed],al
- mov [cs:del_pressed],al
- ; Turn off all BIOS shift flags and "Last was E0, E1" flags
- mov ax,0040h
- mov ds,ax
- mov si,0017h
- and [BYTE PTR ds:si],0F0h
- inc si
- and [BYTE PTR ds:si],0E0h
- mov si,0096h
- and [BYTE PTR ds:si],0F0h
- ; Intercept int 9
- cli
- mov ah,35h
- mov al,09h
- int 21h
- mov si,OFFSET cs:old_vector_09
- mov [cs:si],bx
- mov [cs:si+2],es
- mov ah,25h
- mov al,09h
- push cs
- pop ds
- mov dx,OFFSET cs:intercept_09
- int 21h
- sti
- mov [cs:kb_installed],1
- popa
- pop es ds
- ret
-endp install_i09
-
-;
-; Function- uninstall_i09
-;
-; Uninstalls new keyboard handler. Must be called before exiting program!
-;
-
-proc uninstall_i09 far
- push ds es
- pusha
- ; Turn off all BIOS shift flags and "Last was E0, E1" flags
- mov ax,0040h
- mov ds,ax
- mov si,0017h
- and [BYTE PTR ds:si],0F0h
- inc si
- and [BYTE PTR ds:si],0E0h
- mov si,0096h
- and [BYTE PTR ds:si],0F0h
- ; Restore int 9
- cli
- mov ah,25h
- mov al,09h
- lds dx,[cs:old_vector_09]
- int 21h
- sti
- mov [cs:kb_installed],0
- popa
- pop es ds
- ret
-endp uninstall_i09
-
-;
-; Function- switch_keyb_table
-;
-; Changes to table 0 or 1. Table 1 is less strict, letting arrow keys,
-; space, delete, alt, and shift through.
-;
-
-proc switch_keyb_table far
-arg table_num:byte
- pusha
- push ds es
- ; All keys are released
- xor al,al
- mov [cs:dn_pressed],al
- mov [cs:up_pressed],al
- mov [cs:lf_pressed],al
- mov [cs:rt_pressed],al
- mov [cs:sp_pressed],al
- mov [cs:del_pressed],al
- ; Turn off all BIOS shift flags and "Last was E0, E1" flags
- mov ax,0040h
- mov ds,ax
- mov si,0017h
- and [BYTE PTR ds:si],0F0h
- inc si
- and [BYTE PTR ds:si],0E0h
- mov si,0096h
- and [BYTE PTR ds:si],0F0h
- ; Change table number
- mov al,[table_num]
- and al,1
- mov [curr_table],al
- ; Done!
- pop es ds
- popa
- ret
-endp switch_keyb_table
-
-;
-; Replacements for kbhit and getch
-;
-
-proc kbhit far
- mov ah,11h
- int 16h
- jz @@nokey
- mov ax,1
- ret
-@@nokey:
- xor ax,ax
- ret
-endp kbhit
-
-next_press db 0
-proc getch far
- cmp [cs:next_press],0
- je @@norm_press
- mov al,[cs:next_press]
- mov [cs:next_press],0
- xor ah,ah
- ret
-@@norm_press:
- mov ah,10h
- int 16h
- or al,al
- jz @@ext
- cmp al,224
- jne @@ok
-@@ext:
- mov [cs:next_press],ah
- xor al,al
-@@ok:
- xor ah,ah
- ret
-endp getch
-
-public kbhit
-public getch
-
-ends
-
-end
View
54 arrowkey.h
@@ -1,54 +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.
- */
-
-/* ARROWKEY.H- Declarations for ARROWKEY.ASM */
-
-#ifndef __ARROWKEY_H
-#define __ARROWKEY_H
-
-extern char far kb_installed;/* Whether the keyboard routines are installed */
-extern char far up_pressed;
-extern char far dn_pressed;
-extern char far lf_pressed;
-extern char far rt_pressed;
-extern char far sp_pressed;
-extern char far del_pressed;
-extern char far key_code; /* Latest key code */
-extern char far keyb_mode; /* Set to 1 for different key discard code */
-extern char far curr_table; /* The current keyboard table (0/1) */
-extern char far state_table[128];
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void far install_i09(void); /* Run to install keyboard code */
-void far uninstall_i09(void);/* Run to uninstall keyboard code */
-
-/* Run with param of 0 to switch to game mode keyboard, or param of 1 to
- switch to somewhat normal mode keyboard */
-void far switch_keyb_table(char table);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
View
18 arrowkey.inc
@@ -1,18 +0,0 @@
-
-; Include file- ARROWKEY.INC
-; Declarations for ARROWKEY.ASM
-
-global C install_i09:far
-global C uninstall_i09:far
-global C key_code:byte
-global C up_pressed:byte
-global C dn_pressed:byte
-global C lf_pressed:byte
-global C rt_pressed:byte
-global C sp_pressed:byte
-global C del_pressed:byte
-global C kb_installed:byte
-global C keyb_mode:byte ; Set to 1 for alternate code
-global C switch_keyb_table:far
-global C curr_table:byte
-global C state_table:far
View
550 audio.cpp
@@ -0,0 +1,550 @@
+/* $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 <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"
+
+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, i3, offset = 0;
+ Sint16 *mix_src_ptr;
+ Sint32 *mix_dest_ptr;
+ Sint32 *buffer_src_ptr;
+ Sint16 *buffer_dest_ptr;
+ Sint16 cur_sample16;
+ 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);
+ // Zero out remainder bytes
+ memset(audio.mod_buffer + read_len, 0, 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_S16,
+ 2,
+ 0,
+ buffer_size,
+ 0,
+ 0,
+ audio_callback,
+ NULL
+ };
+
+ audio.mod_settings.mFrequency = 44100;
+ audio.mod_settings.mChannels = 2;
+ audio.mod_settings.mBits = 16;
+ audio.mod_settings.mResamplingMode = MODPLUG_RESAMPLE_LINEAR;
+ 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[256];
+
+ if(extension_pos && !strcasecmp(filename + extension_pos, ".gdm"))
+ {
+ struct stat file_info;
+
+ // GDM -> S3M
+ strcpy(new_file, filename);
+ memcpy(new_file + extension_pos, ".s3m", 4);
+
+ if(stat(new_file, &file_info))
+ {
+ // If it doesn't exist, create it by converting.
+ convert_gdm_s3m(filename, new_file);
+ }
+
+ filename = new_file;
+ }
+
+ if(audio.mod_playing)
+ end_mod();
+
+ input_file = fopen(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)
+{
+ struct stat file_info;
+ 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)
+ {
+ // Out of samples, so destroy a random existing one.
+ int r = rand() % 16;
+ end_individual_sample(r);
+ }
+
+ if((extension_pos >= 0) && !strcasecmp(filename + extension_pos, ".sam"))
+ {
+ // SAM -> WAV
+ strcpy(new_file, filename);
+ memcpy(new_file + extension_pos, ".wav", 4);
+
+ if(stat(new_file, &file_info))
+ {
+ // Create it
+ convert_sam_to_wav(filename, new_file);
+ }
+ filename = new_file;
+ }
+
+ input_file = fopen(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++;
+ }
+
+ free(input_buffer);
+ }
+}
+
+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);
+}
+
+void mod_exit(void)
+{
+
+}
+
+void mod_init(void)
+{
+
+}
+
+void spot_sample(int freq, int sample)
+{
+
+}
+
+// This function will remove samples from the cache one at a time,
+// starting with least-played and ending with currently-playing.
+// Call it removes ONE sample unless CLEAR_ALL is set. Returns 1
+// if nothing was found to deallocate (IE no further fixes possible)
+int free_sam_cache(char clear_all)
+{
+
+}
+
+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, period;
+ 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
77 audio.h
@@ -0,0 +1,77 @@
+/* $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 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
35 beep.cpp
@@ -1,35 +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.
- */
-
-// Function to make a short *BEEP* sound.
-
-#include <dos.h>
-#include "timer.h"
-#include "beep.h"
-#include "data.h"
-#include "sfx.h"
-
-void beep(void) {
- //Don't beep if sfx not on speaker.
- if(!sfx_on) return;
- if(is_playing()) return;//No interrupty
- submit_sound(1600,7);
-}
View
0 beep.h
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
41 blink.cpp
@@ -1,41 +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.
- */
-
-// Simple functions to turn blink on and off. (disabling and enabling
-// light background colors)
-
-#include "blink.h"
-
-void blink_on(void) {
- asm {//Turn blink on
- mov ax,1003h
- mov bl,1
- int 10h
- }
-}
-
-void blink_off(void) {
- asm {//Turn blink off
- mov ax,1003h
- mov bl,0
- int 10h
- }
-}
View
0 blink.h
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
851 block.cpp
@@ -21,17 +21,16 @@
/* Block functions and dialogs */
+#include <stdio.h>
+
#include "helpsys.h"
#include "idput.h"
-#include <stdio.h>
#include "error.h"
#include "block.h"
#include "window.h"
#include "data.h"
-#include <_null.h>
-#include <dos.h>
#include "idarray.h"
-#include "roballoc.h"
+#include "world.h"
//--------------------------
//
@@ -43,633 +42,271 @@
// ( ) Paint block
// ( ) Copy to/from overlay
// ( ) Save as ANSi
-// ( ) Save as MZM - I added this one. - Exo
+// ( ) 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 far *bdi_strs[3]={ "Copy block\nMove block\nClear block\nFlip block\n\
-Mirror block\nPaint block\nCopy to/from overlay\nSave as ANSi\nSave as MZM",
-"OK","Cancel" };
-int bdi_p1s[3]={ 9,0,-1 };
-int bdi_p2s[1]={ 20 };
-int block_op=0;
-void far *bdi_storage[1]={ &block_op };
-
-dialog bdi={
- 26,3,53,17,"Choose block command",3,
- bdi_types,
- bdi_xs,
- bdi_ys,
- bdi_strs,
- bdi_p1s,
- bdi_p2s,
- bdi_storage,0 };
-
-int block_cmd(void) {
- int t1;
- set_context(73);
- t1=run_dialog(&bdi,current_pg_seg);
- pop_context();
- if(t1) return -1;
- return block_op;
-}
+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 adi_types[3]={ DE_RADIO,DE_BUTTON,DE_BUTTON };
-char adi_xs[3]={ 6,5,15 };
-char adi_ys[3]={ 4,11,11 };
-char far *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 far *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(void) {
- set_context(74);
- if(run_dialog(&adi,current_pg_seg)) {
- pop_context();
- return -1;
- }
- pop_context();
- return obj_type;
-}
+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 };
-char csdi_types[3]={ DE_RADIO,DE_BUTTON,DE_BUTTON };
-char csdi_xs[3]={ 6,5,15 };
-char csdi_ys[3]={ 4,11,11 };
-char far *csdi_strs[3]={ "MegaZeux default\nBlank set",
-"OK","Cancel" };
-int csdi_p1s[3]={ 2,0,-1 };
-int csdi_p2s[1]={ 16 };
-int cs_type=0;
-void far *csdi_storage[1]={ &cs_type };
-
-dialog csdi={
- 26,4,53,17,"Character set",3,
- csdi_types,
- csdi_xs,
- csdi_ys,
- csdi_strs,
- csdi_p1s,
- csdi_p2s,
- csdi_storage,0 };
-
-int choose_char_set(void) {
- set_context(75);
- if(run_dialog(&csdi,current_pg_seg)) {
- pop_context();
- return -1;
- }
- pop_context();
- return cs_type;
+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 ed_types[3]={ DE_INPUT,DE_BUTTON,DE_BUTTON };
-char ed_xs[3]={ 5,15,37 };
-char ed_ys[3]={ 2,4,4 };
-char far *ed_strs[3]={ NULL,"OK","Cancel" };
-int ed_p1s[3]={ 16,0,1 };
-int ed_p2s=193;
-void far *fe_ptr=NULL;
-dialog e_di={ 10,8,69,14,NULL,3,ed_types,ed_xs,ed_ys,ed_strs,ed_p1s,
- &ed_p2s,&fe_ptr,0 };
-
-char save_file_dialog(char far *title,char far *prompt,char far *dest) {
- fe_ptr=(void far *)dest;
- ed_strs[0]=prompt;
- e_di.title=title;
- char t1=run_dialog(&e_di,current_pg_seg);
- return t1;
+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;
}
-//The ansi prefix code
-char ansi_pre[3]="[";
-//EGA colors to ANSi colors
-char col2ansi[8]={ 0,4,2,6,1,5,3,7 };
-//Mini func to output meta codes to transform color from one to another.
-//Curr color is the current color and dest color is the color we want.
-char issue_meta(unsigned char curr,unsigned char dest,FILE *fp) {
- int size=2;
- char reset=0;
- if(curr==dest) return 0;
- fwrite(ansi_pre,1,2,fp);
- if((curr&128)&&(!(dest&128))) reset=1;
- if((curr&8)&&(!(dest&8))) reset=1;
- if(reset) {
- fputc('0',fp);
- size++;
- curr=7;
- }
- if(dest&128) {
- if(size>2) {
- fputc(';',fp);
- size++;
- }
- fputc('5',fp);
- size++;
- }
- if(dest&8) {
- if(size>2) {
- fputc(';',fp);
- size++;
- }
- fputc('1',fp);
- size++;
- }
- //Bold/Blink set. Set fg
- if((curr&7)!=(dest&7)) {
- if(size>2) {
- fputc(';',fp);
- size++;
- }
- fputc('3',fp);
- fputc('0'+col2ansi[dest&7],fp);
- size+=2;
- }
- //Set bk
- if((curr&112)!=(dest&112)) {
- if(size>2) {
- fputc(';',fp);
- size++;
- }
- fputc('4',fp);
- fputc('0'+col2ansi[(dest&112)>>4],fp);
- size+=2;
- }
- //Send 'm'
- fputc('m',fp);
- return(size+1);
+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 =
+{
+ 26, 4, 53, 17, "Character set", 3, csdi_types, csdi_xs, csdi_ys,
+ csdi_strs, csdi_p1s, csdi_p2s, csdi_storage, 0
+};
+
+int choose_char_set(World *mzx_world)
+{
+ set_context(75);
+ if(run_dialog(mzx_world, &csdi))
+ {
+ pop_context();
+ return -1;
+ }
+ pop_context();
+ return cs_type;
}
-//Export ansi according to current view.
-//Only exports the actual chars if text_only is set.
-void export_ansi(char far *file,int x1,int y1,int x2,int y2,char text_only) {
- FILE *fp;
- int x,y,line_size;
- int curr_color;
- int col,chr;
- unsigned char far *vid=(unsigned char far *)MK_FP(current_pg_seg,0);
- fp=fopen(file,"wb");
- if(fp==NULL) {
- if(text_only) error("Error exporting text",1,24,current_pg_seg,0x1401);
- else error("Error exporting ANSi",1,24,current_pg_seg,0x0F01);
- return;
- }
- //Fix xsiz/ysiz
- if((x2-x1)>78) x2=x1+78;
- if((y2-y1)>23) y2=y1+23;
- //File open- Init x/y pos and color
- x=x1; y=y1;
- curr_color=7;
- line_size=8;
- if(!text_only) {
- fwrite(ansi_pre,1,2,fp);
- fwrite("0m",1,2,fp);
- fwrite(ansi_pre,1,2,fp);
- fwrite("2J",1,2,fp);
- }
- //Ready to fly! Longest meta code issuable is , or
- //12 characters.
- do {
- id_put(0,0,x,y,0,0,current_pg_seg);
- chr=vid[0]; col=vid[1];
- //Issue meta code
- if(!text_only) line_size+=issue_meta(curr_color,col,fp);
- curr_color=col;
- //Plot character- NOT if an ESC, 10, 13, 9, 8, 0, or 7. (Then use
- //alternates)
- if(chr==27) chr='-';//Alternate (ESC)
- else if(chr==10) chr=219;//Alternate (LF)
- else if(chr==13) chr=14;//Alternate (CR)
- else if(chr==9) chr='o';//Alternate (TAB)
- else if(chr==8) chr=219;//Alternate (BKSP)
- else if(chr==7) chr=249;//Alternate (BELL)
- else if(chr==0) chr=32;//Alternate (NUL)
- fputc(chr,fp); line_size++;
- //Increase x/y
- if((++x)>x2) {
- x=x1;
- //Issue CR/LF
- fputc(13,fp);
- fputc(10,fp);
- line_size=0;
- if((++y)>y2) break;
- }
- else {
- //Line too long? (Can't happen in text mode)
- if(line_size>230) {
- //Issue save/restore
- fwrite(ansi_pre,1,2,fp);
- fputc('s',fp);
- fputc(13,fp);
- fputc(10,fp);
- fwrite(ansi_pre,1,2,fp);
- fputc('u',fp);
- line_size=3;
- }
- }
- //Loop!
- } while(1);
- //Done- close
- issue_meta(curr_color,7,fp);
- fclose(fp);
+char ed_types[3] = { DE_INPUT, DE_BUTTON, DE_BUTTON };
+char ed_xs[3] = { 5, 15, 37 };
+char ed_ys[3] = { 2, 4, 4 };
+char *ed_strs[3] = { NULL, "OK", "Cancel" };
+int ed_p1s[3] = { 32, 0, 1 };
+int ed_p2s = 192;
+void *fe_ptr = NULL;
+
+dialog e_di =
+{
+ 10, 8, 69, 14, NULL, 3, ed_types, ed_xs, ed_ys, ed_strs, ed_p1s,
+ &ed_p2s, &fe_ptr, 0
+};
+
+char edc_types[5] = { DE_INPUT, DE_NUMBER, DE_NUMBER, DE_BUTTON, DE_BUTTON };
+char edc_xs[5] = { 5, 5, 28, 15, 37 };
+char edc_ys[5] = { 2, 3, 3, 5, 5 };
+char *edc_strs[5] = { "Save as: ", "Offset: ", "Size: ", "OK", "Cancel" };
+int edc_p1s[5] = { 32, 0, 1, 0, 1 };
+int edc_p2s[5] = { 192, 255, 256, 0, 0 };
+void *edc_storage[5] = { NULL };
+
+dialog ec_di =
+{
+ 10, 8, 69, 15, "Export", 5, edc_types, edc_xs, edc_ys, edc_strs, edc_p1s,
+ edc_p2s, edc_storage, 0
+};
+
+int save_file_dialog(World *mzx_world, char *title, char *prompt, char *dest)
+{
+ fe_ptr = (void *)dest;
+ ed_strs[0] = prompt;
+ e_di.title = title;
+ return run_dialog(mzx_world, &e_di);
}
-char exdi_types[3]={ DE_RADIO,DE_BUTTON,DE_BUTTON };
-char exdi_xs[3]={ 2,5,15 };
-char exdi_ys[3]={ 3,11,11 };
-char far *exdi_strs[3]={ "Board file (MZB)\nCharacter set (CHR)\n\
-Ansi display (ANS)\nText file (TXT)\nPalette (PAL)\nSound effects (SFX)",
-"OK","Cancel" };
-int exdi_p1s[3]={ 6,0,-1 };
-int exdi_p2s[1]={ 19 };
-void far *exdi_storage[1]={ NULL };
-
-dialog exdi={
- 26,4,53,17,"Export as:",3,
- exdi_types,
- exdi_xs,
- exdi_ys,
- exdi_strs,
- exdi_p1s,
- exdi_p2s,
- exdi_storage,0 };
-
-int export_type(void) {
- int t1=0;
- set_context(77);
- exdi_storage[0]=&t1;
- if(run_dialog(&exdi,current_pg_seg)) {
- pop_context();
- return -1;
- }
- pop_context();
- return t1;
+int save_char_dialog(World *mzx_world, char *dest, int *char_offset,
+ int *char_size)
+{
+ edc_storage[0] = dest;
+ edc_storage[1] = char_offset;
+ edc_storage[2] = char_size;
+ return run_dialog(mzx_world, &ec_di);
}
+// The ansi prefix code
+char ansi_pre[3] = "[";
+// EGA colors to ANSi colors
+char col2ansi[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
+// Mini func to output meta codes to transform color from one to another.
+// Curr color is the current color and dest color is the color we want.
-char imdi_types[3]={ DE_RADIO,DE_BUTTON,DE_BUTTON };
-char imdi_xs[3]={ 2,5,15 };
-char imdi_ys[3]={ 3,12,12 };
-char far *imdi_strs[3]={ "Board file (MZB)\nCharacter set (CHR)\n\
-Ansi display (ANS)\nWorld file (MZX)\nPalette (PAL)\nSound effects (SFX)\n\
-Ansi (choose pos.)\nMZM (choose pos.)",
-"OK","Cancel" };
-int imdi_p1s[3]={ 8,0,-1 };
-int imdi_p2s[1]={ 19 };
-void far *imdi_storage[1]={ NULL };
-
-dialog imdi={
- 26,3,53,17,"Import:",3,
- imdi_types,
- imdi_xs,
- imdi_ys,
- imdi_strs,
- imdi_p1s,
- imdi_p2s,
- imdi_storage,0 };
-
-int import_type(void) {
- int t1=0;
- set_context(78);
- imdi_storage[0]=&t1;
- if(run_dialog(&imdi,current_pg_seg)) {
- pop_context();
- return -1;
- }
- pop_context();
- return t1;
-}
+char exdi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
+char exdi_xs[3] = { 2, 5, 15 };
+char exdi_ys[3] = { 3, 9, 9 };
-//Imports an ANSi into board as fake/block or into overlay. Starts at
-//UL corner. obj_type is the thing id for normal import (Text, etc.) OR
-//0 for overlay import. (verify overlay is on before calling this function)
-void import_ansi(char far *filename,char obj_type,int &curr_thing,
- int &curr_param,int start_x,int start_y) {
- int x=start_x,y=start_y,ux,color=7;
- int save_x=start_x,save_y=start_y,t1,t2,sym;
- FILE * fp;
- fp=fopen(filename,"rb");
- if(fp==NULL) {
- error("Error importing ANSi",1,24,current_pg_seg,0x1901);
- return;
- }
- do {
- sym=fgetc(fp);
- if(feof(fp)) break;
- //Tabs & BCKSPACE are interpreted as ANSi chars...
- if(sym==0x1B) {//ESC for ANSi code...
- sym=fgetc(fp);
- if(sym=='[') {//Yep.
- t2=-1;
- sym=fgetc(fp);
- //Save/Restore position
- if(sym=='s') {
- save_x=x;
- save_y=y;
- continue;
- }
- if(sym=='u') {
- x=save_x;
- y=save_y;
- continue;
- }
- //Clear line
- if(sym=='K') {
- continue;
- }
- //Move X chars in a direction
- if(sym=='A') {
- y--;