From c99c70d3010f3e9b817360f73c27a5f9c9105d54 Mon Sep 17 00:00:00 2001 From: Florian Schulze Date: Fri, 22 Feb 2002 15:08:11 +0000 Subject: [PATCH] Implemented -scaleup and -nosound options. Some fixes for first release. --- COPYING | 340 ++++++++++++++++++++++++++++++ ChangeLog | 7 + LINKS | 1 + TODO | 11 - config.h | 29 +++ dj.h | 29 +++ dos/gfx.c | 29 +++ dos/input.c | 29 +++ dos/interrpt.c | 29 +++ fireworks.c | 31 ++- globals.h | 79 ++++--- main.c | 56 ++++- menu.c | 33 ++- modify/pack.c | 29 +++ modify/unpack.c | 29 +++ readme-win32.txt | 7 + sdl/gfx.c | 525 ++++++++++++++++++++++++++++++----------------- sdl/input.c | 29 +++ sdl/interrpt.c | 29 +++ sdl/sound.c | 75 ++++++- 20 files changed, 1184 insertions(+), 242 deletions(-) create mode 100644 COPYING create mode 100644 readme-win32.txt diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + 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. + + + Copyright (C) + + 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. + + , 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. diff --git a/ChangeLog b/ChangeLog index b1e06e5..9d1a7a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +22 Feb 2002 - 1.0 + - working sound + - new scaling graphics mode + - cleaned up code + +=========================================================================== +This is the changelog of the linux version from which this port is derived. 25 Feb 2001 - 0.69 initial linux port, worked fine with freebsd too (chuck mason) diff --git a/LINKS b/LINKS index 8418c1e..b1b6be8 100644 --- a/LINKS +++ b/LINKS @@ -1,4 +1,5 @@ http://jumpbump.mine.nu/ +http://www.icculus.org/jumpnbump/ http://freshmeat.net/projects/jumpnbump http://winbe.linuxberg.com/x11html/preview/168332.html http://linuxapps.com/?page=application&database=current&id=3594 diff --git a/TODO b/TODO index 50d8fa3..e69de29 100644 --- a/TODO +++ b/TODO @@ -1,11 +0,0 @@ - -we need a -nosound parameter because: - -From: "Jo eL" -Date: Sun, 04 Mar 2001 15:28:33 -0000 -make a version which doesnt require sound -wont run for me - -the network code is working (testing) -/join #keen on irc.linux.com -March 11 2001 (done by LongIslandMan, http://jonatkins.org) diff --git a/config.h b/config.h index 14182b3..b3d477d 100644 --- a/config.h +++ b/config.h @@ -1,3 +1,32 @@ +/* + * config.h + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #ifndef __CONFIG_H #define __CONFIG_H diff --git a/dj.h b/dj.h index 07b2fc8..0898b02 100644 --- a/dj.h +++ b/dj.h @@ -1,3 +1,32 @@ +/* + * dj.h + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include #include #include diff --git a/dos/gfx.c b/dos/gfx.c index 134d7ba..0993f18 100644 --- a/dos/gfx.c +++ b/dos/gfx.c @@ -1,3 +1,32 @@ +/* + * gfx.h + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include "globals.h" diff --git a/dos/input.c b/dos/input.c index 0ab68b2..15aa1eb 100644 --- a/dos/input.c +++ b/dos/input.c @@ -1,3 +1,32 @@ +/* + * input.h + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include "globals.h" static int num_mouse_buttons; diff --git a/dos/interrpt.c b/dos/interrpt.c index 4c5f2c8..3bdf2e4 100644 --- a/dos/interrpt.c +++ b/dos/interrpt.c @@ -1,3 +1,32 @@ +/* + * interrpt.h + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include "globals.h" diff --git a/fireworks.c b/fireworks.c index 39cfba1..5f8db83 100644 --- a/fireworks.c +++ b/fireworks.c @@ -1,3 +1,32 @@ +/* + * fireworks.c + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include "globals.h" extern unsigned int ban_map[17][22]; @@ -19,7 +48,7 @@ void fireworks(void) int x, y; int old_x, old_y; int col; - pixel_t back[2]; + int back[2]; } stars[300]; register_background(NULL, NULL); diff --git a/globals.h b/globals.h index 8d57775..180d41c 100644 --- a/globals.h +++ b/globals.h @@ -1,3 +1,32 @@ +/* + * globals.h + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #ifndef __GLOBALS_H #define __GLOBALS_H @@ -22,6 +51,8 @@ #endif #ifdef _MSC_VER +# define WIN32_LEAN_AND_MEAN +# include # include # include # include @@ -36,24 +67,11 @@ #define JNB_WIDTH 400 #define JNB_HEIGHT 256 - -#ifndef SCALE_UP -#define SCALE_UP2 -#endif - -#if (defined(SCALE_UP) || defined(SCALE_UP2)) -#define JNB_BPP 16 -#define JNB_BYTESPP 2 -#define JNB_SURFACE_WIDTH (JNB_WIDTH*2) -#define JNB_SURFACE_HEIGHT (JNB_HEIGHT*2) -typedef unsigned short pixel_t; -#else -#define JNB_BPP 8 -#define JNB_BYTESPP 1 -#define JNB_SURFACE_WIDTH JNB_WIDTH -#define JNB_SURFACE_HEIGHT JNB_HEIGHT -typedef unsigned char pixel_t; -#endif +extern int screen_width; +extern int screen_height; +extern int screen_pitch; +extern int scale_up; +extern int bytes_per_pixel; #ifndef USE_SDL #define KEY_PL1_LEFT 0xcb @@ -132,8 +150,8 @@ typedef struct { int *height; int *hs_x; int *hs_y; - pixel_t **data; - unsigned char **orig_data; + void **data; + void **orig_data; } gob_t; struct { @@ -150,7 +168,7 @@ struct { int back_buf_ofs; } pobs[NUM_POBS]; } page_info[2]; - pixel_t pob_backbuf[2][JNB_SURFACE_WIDTH*JNB_SURFACE_HEIGHT]; + void *pob_backbuf[2]; } main_info; struct { @@ -253,6 +271,7 @@ void menu_deinit(void); /* gfx.c */ +void set_scaling(int scale); void open_screen(void); void wait_vrt(int mix); void draw_begin(void); @@ -260,30 +279,30 @@ void draw_end(void); void flippage(int page); void draw_begin(void); void draw_end(void); -void clear_lines(int page, int y, int count, pixel_t color); -pixel_t get_color(int color, char pal[768]); -pixel_t get_pixel(int page, int x, int y); -void set_pixel(int page, int x, int y, pixel_t color); +void clear_lines(int page, int y, int count, int color); +int get_color(int color, char pal[768]); +int get_pixel(int page, int x, int y); +void set_pixel(int page, int x, int y, int color); void setpalette(int index, int count, char *palette); void fillpalette(int red, int green, int blue); #ifdef DOS void get_block(char page, short x, short y, short width, short height, char *buffer); void put_block(char page, short x, short y, short width, short height, char *buffer); #else -void get_block(int page, int x, int y, int width, int height, pixel_t *buffer); -void put_block(int page, int x, int y, int width, int height, pixel_t *buffer); +void get_block(int page, int x, int y, int width, int height, void *buffer); +void put_block(int page, int x, int y, int width, int height, void *buffer); #endif void put_text(int page, int x, int y, char *text, int align); -void put_pob(int page, int x, int y, int image, gob_t *gob, int mask, unsigned char *mask_pic); +void put_pob(int page, int x, int y, int image, gob_t *gob, int mask, void *mask_pic); int pob_width(int image, gob_t *gob); int pob_height(int image, gob_t *gob); int pob_hs_x(int image, gob_t *gob); int pob_hs_y(int image, gob_t *gob); -int read_pcx(FILE * handle, char *buffer, int buf_len, char *pal); +int read_pcx(FILE * handle, void *buffer, int buf_len, char *pal); void register_background(char *pixels, char pal[768]); int register_gob(FILE *handle, gob_t *gob, int len); void recalculate_gob(gob_t *gob, char pal[768]); -void register_mask(char *pixels); +void register_mask(void *pixels); /* gfx.c */ diff --git a/main.c b/main.c index c404c1a..b6b424f 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,32 @@ +/* + * main.c + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include "globals.h" #ifndef M_PI @@ -155,7 +184,7 @@ struct { struct { int x, y; int old_x, old_y; - pixel_t back[2]; + int back[2]; int back_defined[2]; } flies[NUM_FLIES]; @@ -324,7 +353,8 @@ int main(int argc, char *argv[]) pal[454] = 8; pal[455] = 8; } - //register_background(background_pic, pal); + register_background(background_pic, pal); + recalculate_gob(&object_gobs, pal); last_keys[0] = 0; } @@ -1602,12 +1632,11 @@ void draw_pobs(int page) for (c1 = main_info.page_info[page].num_pobs - 1; c1 >= 0; c1--) { main_info.page_info[page].pobs[c1].back_buf_ofs = back_buf_ofs; - get_block(page, main_info.page_info[page].pobs[c1].x - pob_hs_x(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), main_info.page_info[page].pobs[c1].y - pob_hs_y(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), &main_info.pob_backbuf[page][back_buf_ofs]); -#ifdef SCALE_UP2 - back_buf_ofs += pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data) * pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data) * 4 * JNB_BYTESPP; -#else - back_buf_ofs += pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data) * pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data); -#endif + get_block(page, main_info.page_info[page].pobs[c1].x - pob_hs_x(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), main_info.page_info[page].pobs[c1].y - pob_hs_y(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), (unsigned char *)main_info.pob_backbuf[page] + back_buf_ofs); + if (scale_up) + back_buf_ofs += pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data) * pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data) * 4 * bytes_per_pixel; + else + back_buf_ofs += pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data) * pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data) * bytes_per_pixel; put_pob(page, main_info.page_info[page].pobs[c1].x, main_info.page_info[page].pobs[c1].y, main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data, 1, mask_pic); } @@ -1630,7 +1659,7 @@ void redraw_pob_backgrounds(int page) int c1; for (c1 = 0; c1 < main_info.page_info[page].num_pobs; c1++) - put_block(page, main_info.page_info[page].pobs[c1].x - pob_hs_x(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), main_info.page_info[page].pobs[c1].y - pob_hs_y(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), &main_info.pob_backbuf[page][main_info.page_info[page].pobs[c1].back_buf_ofs]); + put_block(page, main_info.page_info[page].pobs[c1].x - pob_hs_x(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), main_info.page_info[page].pobs[c1].y - pob_hs_y(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_width(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), pob_height(main_info.page_info[page].pobs[c1].image, main_info.page_info[page].pobs[c1].pob_data), (unsigned char *)main_info.pob_backbuf[page] + main_info.page_info[page].pobs[c1].back_buf_ofs); } @@ -1803,6 +1832,8 @@ int init_program(int argc, char *argv[], char *pal) else if (stricmp(argv[c1], "-fullscreen") == 0) fs_toggle(); #endif + else if (stricmp(argv[c1], "-scaleup") == 0) + set_scaling(1); else if (stricmp(argv[c1], "-dat") == 0) { if (c1 < (argc - 1)) { if ((handle = fopen(argv[c1 + 1], "rb")) != NULL) { @@ -1821,6 +1852,9 @@ int init_program(int argc, char *argv[], char *pal) } } + main_info.pob_backbuf[0] = malloc(screen_pitch*screen_height*bytes_per_pixel); + main_info.pob_backbuf[1] = malloc(screen_pitch*screen_height*bytes_per_pixel); + for (c1 = 0; c1 < 7; c1++) { player_anims[c1].num_frames = player_anim_data[c1 * 10]; player_anims[c1].restart_frame = player_anim_data[c1 * 10 + 1]; @@ -2077,7 +2111,6 @@ int init_program(int argc, char *argv[], char *pal) } - void deinit_program(void) { #ifdef DOS @@ -2106,6 +2139,9 @@ void deinit_program(void) if (main_info.error_str[0] != 0) { printf(main_info.error_str); +#ifdef _MSC_VER + MessageBox(0, main_info.error_str, "Jump'n'Bump", 0); +#endif exit(1); } else exit(0); diff --git a/menu.c b/menu.c index e021b4e..c0fd3b5 100644 --- a/menu.c +++ b/menu.c @@ -1,3 +1,32 @@ +/* + * menu.c + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include "globals.h" char *menu_background; @@ -6,13 +35,15 @@ char menu_pal[768]; char menu_cur_pal[768]; char *message[] = { - "Jump 'n Bump", + "Jump 'n Bump 1.0", "by Brainchild Design in 1998.", "Code by Mattias Brynervall.", "Graphics by Martin Magnusson", "and Andreas Brynervall.", "Music by Anders Nilsson.", "Linux port by Chuck Mason.", + "New SDL port by Florian Schulze.", + "http://www.icculus.org/jumpnbump/", "Visit our homepage at:", "http://www.algonet.se/~mattiasb", "Jump 'n Bump is e-mailware.", diff --git a/modify/pack.c b/modify/pack.c index 5149207..5debbea 100644 --- a/modify/pack.c +++ b/modify/pack.c @@ -1,3 +1,32 @@ +/* + * pack.c + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include #include #include diff --git a/modify/unpack.c b/modify/unpack.c index f20df08..09337a6 100644 --- a/modify/unpack.c +++ b/modify/unpack.c @@ -1,3 +1,32 @@ +/* + * unpack.c + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include #include #include diff --git a/readme-win32.txt b/readme-win32.txt new file mode 100644 index 0000000..2ccb179 --- /dev/null +++ b/readme-win32.txt @@ -0,0 +1,7 @@ +This port is done by Florian Schulze (crow@icculus.org). +Homepage: http://www.icculus.org/jumpnbump/ + +There is a new scaled up graphics mode. To use it add -scaleup to the command line. +The sound is now much better than in the old SDL versions. + +Florian Schulze \ No newline at end of file diff --git a/sdl/gfx.c b/sdl/gfx.c index 8aa7d43..29e8996 100644 --- a/sdl/gfx.c +++ b/sdl/gfx.c @@ -1,32 +1,84 @@ +/* + * gfx.c + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include "globals.h" +int screen_width=400; +int screen_height=256; +int screen_pitch=400; +int scale_up=0; +int bytes_per_pixel=1; +int dirty_block_shift=4; + static int current_pal[256]; static SDL_Surface *jnb_surface; static int fullscreen = 0; static int vinited = 0; -static pixel_t screen_buffer[2][JNB_SURFACE_WIDTH*JNB_SURFACE_HEIGHT]; +static void *screen_buffer[2]; static int drawing_enable = 0; -static pixel_t *background = NULL; +static void *background = NULL; static int background_drawn; -static pixel_t *mask = NULL; -static int dirty_blocks[2][25*16]; -#ifdef SCALE_UP2 -#define DIRTY_BLOCK_SHIFT 5 -#else -#define DIRTY_BLOCK_SHIFT 4 -#endif +static void *mask = NULL; +static int dirty_blocks[2][25*16*2]; -pixel_t *get_vgaptr(int page, int x, int y) +void *get_vgaptr(int page, int x, int y) { assert(drawing_enable==1); - return &screen_buffer[page][y*JNB_SURFACE_WIDTH+x]; + return (unsigned char *)screen_buffer[page] + (y*screen_pitch)+(x*bytes_per_pixel); } +void set_scaling(int scale) +{ + if (scale==1) { + screen_width=800; + screen_height=512; + scale_up=1; + bytes_per_pixel=2; + dirty_block_shift=5; + screen_pitch=screen_width*bytes_per_pixel; + } else { + screen_width=400; + screen_height=256; + scale_up=0; + bytes_per_pixel=1; + dirty_block_shift=4; + screen_pitch=screen_width*bytes_per_pixel; + } +} + void open_screen(void) { int lval = 0; + int bpp; + int flags; lval = SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_AUDIO); if (lval < 0) { @@ -34,10 +86,14 @@ void open_screen(void) exit(EXIT_FAILURE); } - if (fullscreen) - jnb_surface = SDL_SetVideoMode(JNB_SURFACE_WIDTH, JNB_SURFACE_HEIGHT, JNB_BPP, SDL_HWSURFACE | SDL_FULLSCREEN); + if (scale_up) + bpp = 16; else - jnb_surface = SDL_SetVideoMode(JNB_SURFACE_WIDTH, JNB_SURFACE_HEIGHT, JNB_BPP, SDL_HWSURFACE); + bpp = 8; + flags = SDL_SWSURFACE; + if (fullscreen) + flags |= SDL_FULLSCREEN; + jnb_surface = SDL_SetVideoMode(screen_width, screen_height, bpp, flags); if (!jnb_surface) { fprintf(stderr, "SDL ERROR: %s\n", SDL_GetError()); @@ -51,6 +107,14 @@ void open_screen(void) memset(current_pal, 0, sizeof(current_pal)); memset(dirty_blocks, 0, sizeof(dirty_blocks)); + screen_buffer[0]=malloc(screen_width*screen_height*bytes_per_pixel); + screen_buffer[1]=malloc(screen_width*screen_height*bytes_per_pixel); + +/* + dirty_blocks[0]=malloc(sizeof(int)*25*16+1000); + dirty_blocks[1]=malloc(sizeof(int)*25*16+1000); +*/ + return; } @@ -75,46 +139,79 @@ void wait_vrt(int mix) void clear_page(int page, int color) { int i,j; - pixel_t *buf = get_vgaptr(page, 0, 0); assert(drawing_enable==1); for (i=0; i<(25*16); i++) dirty_blocks[page][i] = 1; - for (i=0; i>DIRTY_BLOCK_SHIFT) - (y>>DIRTY_BLOCK_SHIFT) + 1; - y >>= DIRTY_BLOCK_SHIFT; + count = ((y+count)>>dirty_block_shift) - (y>>dirty_block_shift) + 1; + y >>= dirty_block_shift; for (i=0; i>DIRTY_BLOCK_SHIFT)*25+(x>>DIRTY_BLOCK_SHIFT)] = 1; + if (scale_up) { + x *= 2; + y *= 2; + } + + assert(x>dirty_block_shift)*25+(x>>dirty_block_shift)] = 1; - *get_vgaptr(page, x, y) = color; + if (bytes_per_pixel==1) + *(unsigned char *)get_vgaptr(page, x, y) = color; + else if (bytes_per_pixel==2) + *(unsigned short *)get_vgaptr(page, x, y) = color; + else + *(unsigned int *)get_vgaptr(page, x, y) = color; } @@ -460,8 +571,8 @@ void Super2xSaI (unsigned char *src, unsigned int src_pitch, int src_bytes_per_p void flippage(int page) { - int x,y,h,w; - pixel_t *src; + int x,y; + unsigned char *src; unsigned char *dest; assert(drawing_enable==0); @@ -483,39 +594,28 @@ void flippage(int page) #else dest=(unsigned char *)jnb_surface->pixels; src=screen_buffer[page]; - for (y=0; ypitch],0,JNB_SURFACE_WIDTH*JNB_BYTESPP); + for (y=0; ypitch],0,JNB_SURFACE_WIDTH*bytes_per_pixel); for (x=0; x<25; x++) { int count; int test_x; count=0; test_x=x; - while ( (test_x<25) && (dirty_blocks[page][(y>>DIRTY_BLOCK_SHIFT)*25+test_x]) ) { + while ( (test_x<25) && (dirty_blocks[page][(y>>dirty_block_shift)*25+test_x]) ) { count++; test_x++; } if (count) { - memcpy( &dest[y*jnb_surface->pitch+(x<>4)*JNB_BYTESPP*count); - //*((pixel_t *)(&dest[(y>>DIRTY_BLOCK_SHIFT)*jnb_surface->pitch+x*JNB_BYTESPP]))=0xe0e0; + memcpy( &dest[y*jnb_surface->pitch+(x<>4)*bytes_per_pixel*count); + //*((pixel_t *)(&dest[(y>>dirty_block_shift)*jnb_surface->pitch+x*bytes_per_pixel]))=0xe0e0; } x = test_x; } } memset(&dirty_blocks[page], 0, sizeof(int)*25*16); -/* - dest=(unsigned char *)jnb_surface->pixels; - src=screen_buffer[page]; - w=(jnb_surface->clip_rect.w>JNB_SURFACE_WIDTH)?(JNB_SURFACE_WIDTH):(jnb_surface->clip_rect.w); - h=(jnb_surface->clip_rect.h>JNB_SURFACE_HEIGHT)?(JNB_SURFACE_HEIGHT):(jnb_surface->clip_rect.h); - for (; h>0; h--) { - memcpy(dest,src,w*JNB_BYTESPP); - dest+=jnb_surface->pitch; - src+=JNB_SURFACE_WIDTH; - } -*/ #endif SDL_UnlockSurface(jnb_surface); SDL_Flip(jnb_surface); @@ -563,9 +663,8 @@ void setpalette(int index, int count, char *palette) colors[i+index].b = palette[i * 3 + 2] << 2; current_pal[i+index] = SDL_MapRGB(jnb_surface->format, colors[i+index].r, colors[i+index].g, colors[i+index].b); } -#ifndef SCALE_UP - SDL_SetColors(jnb_surface, &colors[index], index, count); -#endif + if (!scale_up) + SDL_SetColors(jnb_surface, &colors[index], index, count); } @@ -582,34 +681,33 @@ void fillpalette(int red, int green, int blue) colors[i].b = blue << 2; current_pal[i] = SDL_MapRGB(jnb_surface->format, colors[i].r, colors[i].g, colors[i].b); } -#ifndef SCALE_UP - SDL_SetColors(jnb_surface, colors, 0, 256); -#endif + if (!scale_up) + SDL_SetColors(jnb_surface, colors, 0, 256); } -void get_block(int page, int x, int y, int width, int height, pixel_t *buffer) +void get_block(int page, int x, int y, int width, int height, void *buffer) { + unsigned char *buffer_ptr, *vga_ptr; int h; - pixel_t *buffer_ptr, *vga_ptr; assert(drawing_enable==1); -#ifdef SCALE_UP2 - x *= 2; - y *= 2; - width *= 2; - height *= 2; -#endif + if (scale_up) { + x *= 2; + y *= 2; + width *= 2; + height *= 2; + } if (x < 0) x = 0; if (y < 0) y = 0; - if (y + height >= JNB_SURFACE_HEIGHT) - height = JNB_SURFACE_HEIGHT - y; - if (x + width >= JNB_SURFACE_WIDTH) - width = JNB_SURFACE_WIDTH - x; + if (y + height >= screen_height) + height = screen_height - y; + if (x + width >= screen_width) + width = screen_width - x; if (width<=0) return; if(height<=0) @@ -618,36 +716,36 @@ void get_block(int page, int x, int y, int width, int height, pixel_t *buffer) vga_ptr = get_vgaptr(page, x, y); buffer_ptr = buffer; for (h = 0; h < height; h++) { - memcpy(buffer_ptr, vga_ptr, width * JNB_BYTESPP); - vga_ptr += JNB_SURFACE_WIDTH; - buffer_ptr += width; + memcpy(buffer_ptr, vga_ptr, width * bytes_per_pixel); + vga_ptr += screen_pitch; + buffer_ptr += width * bytes_per_pixel; } } -void put_block(int page, int x, int y, int width, int height, pixel_t *buffer) +void put_block(int page, int x, int y, int width, int height, void *buffer) { int h; - pixel_t *vga_ptr, *buffer_ptr; + unsigned char *vga_ptr, *buffer_ptr; assert(drawing_enable==1); -#ifdef SCALE_UP2 - x *= 2; - y *= 2; - width *= 2; - height *= 2; -#endif + if (scale_up) { + x *= 2; + y *= 2; + width *= 2; + height *= 2; + } if (x < 0) x = 0; if (y < 0) y = 0; - if (y + height >= JNB_SURFACE_HEIGHT) - height = JNB_SURFACE_HEIGHT - y; - if (x + width >= JNB_SURFACE_WIDTH) - width = JNB_SURFACE_WIDTH - x; + if (y + height >= screen_height) + height = screen_height - y; + if (x + width >= screen_width) + width = screen_width - x; if (width<=0) return; if(height<=0) @@ -656,14 +754,14 @@ void put_block(int page, int x, int y, int width, int height, pixel_t *buffer) vga_ptr = get_vgaptr(page, x, y); buffer_ptr = buffer; for (h = 0; h < height; h++) { - memcpy(vga_ptr, buffer_ptr, width * JNB_BYTESPP); - vga_ptr += JNB_SURFACE_WIDTH; - buffer_ptr += width; + memcpy(vga_ptr, buffer_ptr, width * bytes_per_pixel); + vga_ptr += screen_pitch; + buffer_ptr += width * bytes_per_pixel; } - width = ((x+width)>>DIRTY_BLOCK_SHIFT) - (x>>DIRTY_BLOCK_SHIFT) + 1; - height = ((y+height)>>DIRTY_BLOCK_SHIFT) - (y>>DIRTY_BLOCK_SHIFT) + 1; - x >>= DIRTY_BLOCK_SHIFT; - y >>= DIRTY_BLOCK_SHIFT; + width = ((x+width)>>dirty_block_shift) - (x>>dirty_block_shift) + 1; + height = ((y+height)>>dirty_block_shift) - (y>>dirty_block_shift) + 1; + x >>= dirty_block_shift; + y >>= dirty_block_shift; while (width--) for (h=0; h=0); assert(imagenum_images); -#ifdef SCALE_UP2 - x *= 2; - y *= 2; -#endif + if (scale_up) { + x *= 2; + y *= 2; + width = draw_width = gob->width[image]*2; + height = draw_height = gob->height[image]*2; + x -= gob->hs_x[image]*2; + y -= gob->hs_y[image]*2; + } else { + width = draw_width = gob->width[image]; + height = draw_height = gob->height[image]; + x -= gob->hs_x[image]; + y -= gob->hs_y[image]; + } -#ifdef SCALE_UP2 - width = draw_width = gob->width[image]*2; - height = draw_height = gob->height[image]*2; - x -= gob->hs_x[image]*2; - y -= gob->hs_y[image]*2; -#else - width = draw_width = gob->width[image]; - height = draw_height = gob->height[image]; - x -= gob->hs_x[image]; - y -= gob->hs_y[image]; -#endif - if ((x + width) <= 0 || x >= JNB_SURFACE_WIDTH) + if ((x + width) <= 0 || x >= screen_width) return; - if ((y + height) <= 0 || y >= JNB_SURFACE_HEIGHT) + if ((y + height) <= 0 || y >= screen_height) return; - pob_offset = 0; + + pob_x = 0; + pob_y = 0; if (x < 0) { - pob_offset -= x; + pob_x -= x; draw_width += x; x = 0; } - if ((x + width) > JNB_SURFACE_WIDTH) - draw_width -= x + width - JNB_SURFACE_WIDTH; + if ((x + width) > screen_width) + draw_width -= x + width - screen_width; if (y < 0) { - pob_offset -= y * width; + pob_y -= y; draw_height += y; y = 0; } - if ((y + height) > JNB_SURFACE_HEIGHT) - draw_height -= y + height - JNB_SURFACE_HEIGHT; - - pob_ptr = &gob->data[image][pob_offset]; - vga_ptr = get_vgaptr(page, x, y); - mask_ptr = &mask[(y * JNB_SURFACE_WIDTH) + x]; - for (c1 = 0; c1 < draw_height; c1++) { - for (c2 = 0; c2 < draw_width; c2++) { - colour = *mask_ptr; - if (use_mask == 0 || (use_mask == 1 && colour == 0)) { - colour = *pob_ptr; - if (colour != 0) { - *vga_ptr = colour; + if ((y + height) > screen_height) + draw_height -= y + height - screen_height; + + + if (bytes_per_pixel==1) { + unsigned char *vga_ptr; + unsigned char *pob_ptr; + unsigned char *mask_ptr; + + vga_ptr = get_vgaptr(page, x, y); + pob_ptr = ((unsigned char *)gob->data[image]) + ((pob_y * width) + pob_x); + mask_ptr = ((unsigned char *)mask) + ((y * screen_pitch) + (x*bytes_per_pixel)); + for (c1 = 0; c1 < draw_height; c1++) { + for (c2 = 0; c2 < draw_width; c2++) { + colour = *mask_ptr; + if (use_mask == 0 || (use_mask == 1 && colour == 0)) { + colour = *pob_ptr; + if (colour != 0) { + *vga_ptr = colour; + } + } + vga_ptr++; + pob_ptr++; + mask_ptr++; + } + pob_ptr += width - c2; + vga_ptr += (screen_width - c2); + mask_ptr += (screen_width - c2); + } + } else if (bytes_per_pixel==2) { + unsigned short *vga_ptr; + unsigned short *pob_ptr; + unsigned short *mask_ptr; + + vga_ptr = get_vgaptr(page, x, y); + pob_ptr = (unsigned short *)(((unsigned char *)gob->data[image]) + ((pob_y * width) + pob_x)); + mask_ptr = (unsigned short *)(((unsigned char *)mask) + ((y * screen_pitch) + (x*bytes_per_pixel))); + for (c1 = 0; c1 < draw_height; c1++) { + for (c2 = 0; c2 < draw_width; c2++) { + colour = *mask_ptr; + if (use_mask == 0 || (use_mask == 1 && colour == 0)) { + colour = *pob_ptr; + if (colour != 0) { + *vga_ptr = colour; + } + } + vga_ptr++; + pob_ptr++; + mask_ptr++; + } + pob_ptr += width - c2; + vga_ptr += (screen_width - c2); + mask_ptr += (screen_width - c2); + } + } else { + unsigned int *vga_ptr; + unsigned int *pob_ptr; + unsigned int *mask_ptr; + + vga_ptr = get_vgaptr(page, x, y); + pob_ptr = (unsigned int *)(((unsigned char *)gob->data[image]) + ((pob_y * width) + pob_x)); + mask_ptr = (unsigned int *)(((unsigned char *)mask) + ((y * screen_pitch) + (x*bytes_per_pixel))); + for (c1 = 0; c1 < draw_height; c1++) { + for (c2 = 0; c2 < draw_width; c2++) { + colour = *mask_ptr; + if (use_mask == 0 || (use_mask == 1 && colour == 0)) { + colour = *pob_ptr; + if (colour != 0) { + *vga_ptr = colour; + } } + vga_ptr++; + pob_ptr++; + mask_ptr++; } - vga_ptr++; - pob_ptr++; - mask_ptr++; + pob_ptr += width - c2; + vga_ptr += (screen_width - c2); + mask_ptr += (screen_width - c2); } - pob_ptr += width - c2; - vga_ptr += (JNB_SURFACE_WIDTH - c2); - mask_ptr += (JNB_SURFACE_WIDTH - c2); } - draw_width = ((x+draw_width)>>DIRTY_BLOCK_SHIFT) - (x>>DIRTY_BLOCK_SHIFT) + 1; - draw_height = ((y+draw_height)>>DIRTY_BLOCK_SHIFT) - (y>>DIRTY_BLOCK_SHIFT) + 1; - x >>= DIRTY_BLOCK_SHIFT; - y >>= DIRTY_BLOCK_SHIFT; + draw_width = ((x+draw_width)>>dirty_block_shift) - (x>>dirty_block_shift) + 1; + draw_height = ((y+draw_height)>>dirty_block_shift) - (y>>dirty_block_shift) + 1; + x >>= dirty_block_shift; + y >>= dirty_block_shift; while (draw_width--) for (c1=0; c1format, (Uint8)(pal[i*3+0]<<2), (Uint8)(pal[i*3+1]<<2), (Uint8)(pal[i*3+2]<<2)); - background = malloc(JNB_SURFACE_WIDTH*JNB_SURFACE_HEIGHT*JNB_BYTESPP); + background = malloc(screen_pitch*screen_height); assert(background); - Super2xSaI(pixels, JNB_WIDTH, 1, (unsigned char *)background, JNB_SURFACE_WIDTH*JNB_BYTESPP, JNB_BYTESPP, JNB_WIDTH, JNB_HEIGHT, int_pal); + Super2xSaI(pixels, JNB_WIDTH, 1, (unsigned char *)background, screen_pitch, bytes_per_pixel, JNB_WIDTH, JNB_HEIGHT, int_pal); + } else { + background = malloc(JNB_WIDTH*JNB_HEIGHT); + assert(background); + memcpy(background, pixels, JNB_WIDTH*JNB_HEIGHT); } -#else - background = malloc(JNB_WIDTH*JNB_HEIGHT); - assert(background); - memcpy(background, pixels, JNB_WIDTH*JNB_HEIGHT); -#endif } int register_gob(FILE *handle, gob_t *gob, int len) @@ -990,8 +1140,8 @@ int register_gob(FILE *handle, gob_t *gob, int len) gob->height = malloc(gob->num_images*sizeof(int)); gob->hs_x = malloc(gob->num_images*sizeof(int)); gob->hs_y = malloc(gob->num_images*sizeof(int)); - gob->data = malloc(gob->num_images*sizeof(pixel_t *)); - gob->orig_data = malloc(gob->num_images*sizeof(unsigned char *)); + gob->data = malloc(gob->num_images*sizeof(void *)); + gob->orig_data = malloc(gob->num_images*sizeof(void *)); for (i=0; inum_images; i++) { int image_size; int offset; @@ -1006,12 +1156,12 @@ int register_gob(FILE *handle, gob_t *gob, int len) image_size = gob->width[i] * gob->height[i]; gob->orig_data[i] = malloc(image_size); memcpy(gob->orig_data[i], &gob_data[offset], image_size); -#ifdef SCALE_UP2 - image_size = gob->width[i] * gob->height[i] * 4 * JNB_BYTESPP; - gob->data[i] = malloc(image_size); -#else - gob->data[i] = gob->orig_data[i]; -#endif + if (scale_up) { + image_size = gob->width[i] * gob->height[i] * 4 * bytes_per_pixel; + gob->data[i] = malloc(image_size); + } else { + gob->data[i] = (unsigned short *)gob->orig_data[i]; + } } free(gob_data); return 0; @@ -1020,10 +1170,12 @@ int register_gob(FILE *handle, gob_t *gob, int len) void recalculate_gob(gob_t *gob, char pal[768]) { -#ifdef SCALE_UP2 int int_pal[256]; int i; + if (!scale_up) + return; + for (i=1; i<256; i++) { int_pal[i] = SDL_MapRGB(jnb_surface->format, (Uint8)(pal[i*3+0]<<2), (Uint8)(pal[i*3+1]<<2), (Uint8)(pal[i*3+2]<<2)); if (int_pal[i] == 0) @@ -1032,9 +1184,8 @@ void recalculate_gob(gob_t *gob, char pal[768]) int_pal[0] = 0; for (i=0; inum_images; i++) { - Super2xSaI(gob->orig_data[i], gob->width[i], 1, (unsigned char *)gob->data[i], gob->width[i]*2*JNB_BYTESPP, JNB_BYTESPP, gob->width[i], gob->height[i], int_pal); + Super2xSaI(gob->orig_data[i], gob->width[i], 1, (unsigned char *)gob->data[i], gob->width[i]*2*bytes_per_pixel, bytes_per_pixel, gob->width[i], gob->height[i], int_pal); } -#endif } void register_mask(char *pixels) @@ -1044,21 +1195,19 @@ void register_mask(char *pixels) mask = NULL; } assert(pixels); -#ifdef SCALE_UP2 - { + if (scale_up) { int int_pal[256]; int i; int_pal[0] = 0; for (i=1; i<256; i++) - int_pal[i] = 1; - mask = malloc(JNB_SURFACE_WIDTH*JNB_SURFACE_HEIGHT*JNB_BYTESPP); + int_pal[i] = 0xffffffff; + mask = malloc(screen_pitch*screen_height); + assert(mask); + Scale2x(pixels, JNB_WIDTH, 1, (unsigned char *)mask, screen_pitch, bytes_per_pixel, JNB_WIDTH, JNB_HEIGHT, int_pal); + } else { + mask = malloc(JNB_WIDTH*JNB_HEIGHT); assert(mask); - Scale2x(pixels, JNB_WIDTH, 1, (unsigned char *)mask, JNB_SURFACE_WIDTH*JNB_BYTESPP, JNB_BYTESPP, JNB_WIDTH, JNB_HEIGHT, int_pal); + memcpy(mask, pixels, JNB_WIDTH*JNB_HEIGHT); } -#else - mask = malloc(JNB_WIDTH*JNB_HEIGHT); - assert(mask); - memcpy(mask, pixels, JNB_WIDTH*JNB_HEIGHT); -#endif } diff --git a/sdl/input.c b/sdl/input.c index b205292..cdf00df 100644 --- a/sdl/input.c +++ b/sdl/input.c @@ -1,3 +1,32 @@ +/* + * input.c + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include "globals.h" int calib_joy(int type) diff --git a/sdl/interrpt.c b/sdl/interrpt.c index 5f8b956..aa77d3f 100644 --- a/sdl/interrpt.c +++ b/sdl/interrpt.c @@ -1,3 +1,32 @@ +/* + * interrpt.c + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include #include #include diff --git a/sdl/sound.c b/sdl/sound.c index 7da8b2b..46862a9 100644 --- a/sdl/sound.c +++ b/sdl/sound.c @@ -1,3 +1,32 @@ +/* + * sound.c + * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ + * + * Copyright (C) 2001 tarzeau@space.ch + * + * Copyright (C) 2002 Florian Schulze - crow@icculus.org + * + * Portions of this code are from the MPEG software simulation group + * idct implementation. This code will be replaced with a new + * implementation soon. + * + * This file is part of Jump'n'Bump. + * + * Jump'n'Bump 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. + * + * Jump'n'Bump 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 + */ + #include "globals.h" #include @@ -223,11 +252,15 @@ char dj_init(void) open_screen(); + if (main_info.no_sound) + return 0; + audio_buffers = SAMPLECOUNT*audio_rate/11025; if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) { fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); - return 0; + main_info.no_sound = 1; + return 1; } Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); @@ -245,6 +278,9 @@ char dj_init(void) void dj_deinit(void) { + if (main_info.no_sound) + return; + Mix_HaltMusic(); if (current_music) Mix_FreeMusic(current_music); @@ -305,6 +341,9 @@ char dj_set_num_sfx_channels(char num_channels) void dj_set_sfx_volume(char volume) { + if (main_info.no_sound) + return; + SDL_LockAudio(); global_sfx_volume = volume*2; SDL_UnlockAudio(); @@ -314,6 +353,9 @@ void dj_play_sfx(unsigned char sfx_num, unsigned short freq, char volume, char p { int slot; + if (main_info.no_sound) + return; + if (channel<0) { for (slot=0; slot