From 7aad83db1af932b17a70ffc07475a7900082d8b2 Mon Sep 17 00:00:00 2001 From: Seb/The Removers Date: Tue, 18 Dec 2007 19:09:00 +0000 Subject: [PATCH] Jaguar sources: initial import. git-svn-id: svn://obiwan/Jaguar@1 1d14b586-ad98-11dc-b037-dddde97c3f5c --- LICENSE | 504 +++++++ Makefile | 100 ++ blit/Makefile | 43 + blit/blit.h | 45 + blit/blitmove.s | 566 ++++++++ blit/blitset.s | 151 +++ blit/jaguar.inc | 1 + build.sh | 34 + collision/Makefile | 44 + collision/collision.h | 90 ++ collision/collision.s | 399 ++++++ collision/display_def.s | 1 + collision/jaguar.inc | 1 + console/.depend | 2 + console/Makefile | 42 + console/console.h | 49 + console/open_console.c | 11 + console/open_custom_console.c | 432 ++++++ display/Makefile | 45 + display/display.h | 138 ++ display/display.ps | Bin 0 -> 50910 bytes display/display.s | 732 ++++++++++ display/display.s.ORIG | 715 ++++++++++ display/display_cfg.s | 134 ++ display/display_def.s | 105 ++ display/jaguar.inc | 1 + doc/Doxyfile | 233 ++++ doc/Makefile | 19 + doc/html/annotated.html | 35 + doc/html/blit_8h.html | 122 ++ doc/html/collision_8h.html | 247 ++++ doc/html/console_8h.html | 163 +++ doc/html/display_8h.html | 171 +++ doc/html/doxygen.css | 358 +++++ doc/html/doxygen.png | Bin 0 -> 1281 bytes doc/html/fb2d_8h.html | 481 +++++++ doc/html/files.html | 39 + doc/html/functions.html | 191 +++ doc/html/functions_vars.html | 191 +++ doc/html/globals.html | 352 +++++ doc/html/globals_defs.html | 128 ++ doc/html/globals_enum.html | 44 + doc/html/globals_eval.html | 86 ++ doc/html/globals_func.html | 213 +++ doc/html/globals_type.html | 44 + doc/html/globals_vars.html | 50 + doc/html/index.html | 67 + doc/html/interrupt_8h.html | 198 +++ doc/html/joypad_8h.html | 503 +++++++ doc/html/memalign_8h.html | 74 + doc/html/op_8h.html | 72 + doc/html/screen_8h.html | 390 ++++++ doc/html/sound_8h.html | 508 +++++++ doc/html/sprite_8h.html | 618 +++++++++ doc/html/structaffine__transform.html | 175 +++ doc/html/structanimation__chunk.html | 67 + doc/html/structdisplay.html | 67 + doc/html/structjoypad__state.html | 169 +++ doc/html/structlinear__transform.html | 101 ++ doc/html/structmblock.html | 50 + doc/html/structscreen.html | 84 ++ doc/html/structsprite.html | 531 ++++++++ doc/html/tab_b.gif | Bin 0 -> 35 bytes doc/html/tab_l.gif | Bin 0 -> 706 bytes doc/html/tab_r.gif | Bin 0 -> 2585 bytes doc/html/tabs.css | 102 ++ doc/latex/FreeSans.ttf | Bin 0 -> 22932 bytes doc/latex/Makefile | 19 + doc/latex/annotated.tex | 11 + doc/latex/blit_8h.tex | 52 + doc/latex/collision_8h.tex | 132 ++ doc/latex/console_8h.tex | 58 + doc/latex/display_8h.tex | 100 ++ doc/latex/doxygen.sty | 78 ++ doc/latex/fb2d_8h.tex | 273 ++++ doc/latex/files.tex | 15 + doc/latex/index.tex | 54 + doc/latex/interrupt_8h.tex | 108 ++ doc/latex/joypad_8h.tex | 277 ++++ doc/latex/memalign_8h.tex | 45 + doc/latex/op_8h.tex | 65 + doc/latex/refman.tex | 78 ++ doc/latex/screen_8h.tex | 160 +++ doc/latex/sound_8h.tex | 239 ++++ doc/latex/sprite_8h.tex | 261 ++++ doc/latex/structaffine__transform.tex | 85 ++ doc/latex/structanimation__chunk.tex | 34 + doc/latex/structdisplay.tex | 34 + doc/latex/structjoypad__state.tex | 88 ++ doc/latex/structlinear__transform.tex | 52 + doc/latex/structmblock.tex | 25 + doc/latex/structscreen.tex | 43 + doc/latex/structsprite.tex | 269 ++++ fb2d/Makefile | 43 + fb2d/fb2d.h | 202 +++ fb2d/fb2d.s | 800 +++++++++++ fb2d/fb2d_def.s | 36 + fb2d/fixp_def.s | 81 ++ fb2d/jaguar.inc | 1 + fb2d/screen_def.s | 1 + interrupt/Makefile | 45 + interrupt/interrupt.h | 50 + interrupt/interrupt.s | 370 +++++ interrupt/jaguar.inc | 1 + jaguar.inc | 736 ++++++++++ joypad/Makefile | 45 + joypad/jaguar.inc | 1 + joypad/joypad.h | 110 ++ joypad/joypad.s | 297 ++++ log | 205 +++ main.h | 226 ++++ memalign/.depend | 1 + memalign/Makefile | 42 + memalign/memalign.c | 30 + memalign/memalign.h | 51 + rmvlib-1.0.tar.gz | Bin 0 -> 71809 bytes rmvlib-1.1.1.tar.gz | Bin 0 -> 73196 bytes rmvlib-1.1.2.tar.gz | Bin 0 -> 73257 bytes rmvlib-1.1.3.tar.gz | Bin 0 -> 74770 bytes rmvlib-1.1.tar.gz | Bin 0 -> 73068 bytes screen/.depend | 6 + screen/Makefile | 43 + screen/a_1_buf.c | 40 + screen/a_2_buf.c | 53 + screen/a_z_buf.c | 52 + screen/cl_screen.s | 59 + screen/jaguar.inc | 1 + screen/n_screen.c | 25 + screen/s_1_buf.c | 38 + screen/scr2spr.c | 76 ++ screen/screen.h | 133 ++ screen/screen_def.s | 37 + screen/screen_inline.c | 51 + sound/Makefile | 47 + sound/amiga.txt | 255 ++++ sound/jaguar.inc | 1 + sound/pt-play.s | 1796 +++++++++++++++++++++++++ sound/sound.h | 110 ++ sound/sound.s | 614 +++++++++ sound/sound.s.LONG | 639 +++++++++ sound/sound.s.ORIG | 613 +++++++++ sprite/.depend | 12 + sprite/Makefile | 47 + sprite/a_sprite.c | 30 + sprite/c_layer.c | 25 + sprite/d_sprite.c | 29 + sprite/h_layer.c | 25 + sprite/iter_all.c | 26 + sprite/iter_one.c | 28 + sprite/m_layer.c | 26 + sprite/n_display.c | 104 ++ sprite/n_sprite.c | 91 ++ sprite/op.h | 132 ++ sprite/s_layer.c | 25 + sprite/s_sprite.c | 85 ++ sprite/so_layer.c | 89 ++ sprite/sprite.h | 295 ++++ 157 files changed, 23115 insertions(+) create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 blit/Makefile create mode 100644 blit/blit.h create mode 100644 blit/blitmove.s create mode 100644 blit/blitset.s create mode 120000 blit/jaguar.inc create mode 100755 build.sh create mode 100644 collision/Makefile create mode 100644 collision/collision.h create mode 100644 collision/collision.s create mode 120000 collision/display_def.s create mode 120000 collision/jaguar.inc create mode 100644 console/.depend create mode 100644 console/Makefile create mode 100644 console/console.h create mode 100644 console/open_console.c create mode 100644 console/open_custom_console.c create mode 100644 display/Makefile create mode 100644 display/display.h create mode 100644 display/display.ps create mode 100644 display/display.s create mode 100644 display/display.s.ORIG create mode 100644 display/display_cfg.s create mode 100644 display/display_def.s create mode 120000 display/jaguar.inc create mode 100644 doc/Doxyfile create mode 100644 doc/Makefile create mode 100644 doc/html/annotated.html create mode 100644 doc/html/blit_8h.html create mode 100644 doc/html/collision_8h.html create mode 100644 doc/html/console_8h.html create mode 100644 doc/html/display_8h.html create mode 100644 doc/html/doxygen.css create mode 100644 doc/html/doxygen.png create mode 100644 doc/html/fb2d_8h.html create mode 100644 doc/html/files.html create mode 100644 doc/html/functions.html create mode 100644 doc/html/functions_vars.html create mode 100644 doc/html/globals.html create mode 100644 doc/html/globals_defs.html create mode 100644 doc/html/globals_enum.html create mode 100644 doc/html/globals_eval.html create mode 100644 doc/html/globals_func.html create mode 100644 doc/html/globals_type.html create mode 100644 doc/html/globals_vars.html create mode 100644 doc/html/index.html create mode 100644 doc/html/interrupt_8h.html create mode 100644 doc/html/joypad_8h.html create mode 100644 doc/html/memalign_8h.html create mode 100644 doc/html/op_8h.html create mode 100644 doc/html/screen_8h.html create mode 100644 doc/html/sound_8h.html create mode 100644 doc/html/sprite_8h.html create mode 100644 doc/html/structaffine__transform.html create mode 100644 doc/html/structanimation__chunk.html create mode 100644 doc/html/structdisplay.html create mode 100644 doc/html/structjoypad__state.html create mode 100644 doc/html/structlinear__transform.html create mode 100644 doc/html/structmblock.html create mode 100644 doc/html/structscreen.html create mode 100644 doc/html/structsprite.html create mode 100644 doc/html/tab_b.gif create mode 100644 doc/html/tab_l.gif create mode 100644 doc/html/tab_r.gif create mode 100644 doc/html/tabs.css create mode 100644 doc/latex/FreeSans.ttf create mode 100644 doc/latex/Makefile create mode 100644 doc/latex/annotated.tex create mode 100644 doc/latex/blit_8h.tex create mode 100644 doc/latex/collision_8h.tex create mode 100644 doc/latex/console_8h.tex create mode 100644 doc/latex/display_8h.tex create mode 100644 doc/latex/doxygen.sty create mode 100644 doc/latex/fb2d_8h.tex create mode 100644 doc/latex/files.tex create mode 100644 doc/latex/index.tex create mode 100644 doc/latex/interrupt_8h.tex create mode 100644 doc/latex/joypad_8h.tex create mode 100644 doc/latex/memalign_8h.tex create mode 100644 doc/latex/op_8h.tex create mode 100644 doc/latex/refman.tex create mode 100644 doc/latex/screen_8h.tex create mode 100644 doc/latex/sound_8h.tex create mode 100644 doc/latex/sprite_8h.tex create mode 100644 doc/latex/structaffine__transform.tex create mode 100644 doc/latex/structanimation__chunk.tex create mode 100644 doc/latex/structdisplay.tex create mode 100644 doc/latex/structjoypad__state.tex create mode 100644 doc/latex/structlinear__transform.tex create mode 100644 doc/latex/structmblock.tex create mode 100644 doc/latex/structscreen.tex create mode 100644 doc/latex/structsprite.tex create mode 100644 fb2d/Makefile create mode 100644 fb2d/fb2d.h create mode 100644 fb2d/fb2d.s create mode 100644 fb2d/fb2d_def.s create mode 100644 fb2d/fixp_def.s create mode 120000 fb2d/jaguar.inc create mode 120000 fb2d/screen_def.s create mode 100644 interrupt/Makefile create mode 100644 interrupt/interrupt.h create mode 100644 interrupt/interrupt.s create mode 120000 interrupt/jaguar.inc create mode 100644 jaguar.inc create mode 100644 joypad/Makefile create mode 120000 joypad/jaguar.inc create mode 100644 joypad/joypad.h create mode 100644 joypad/joypad.s create mode 100644 log create mode 100644 main.h create mode 100644 memalign/.depend create mode 100644 memalign/Makefile create mode 100644 memalign/memalign.c create mode 100644 memalign/memalign.h create mode 100644 rmvlib-1.0.tar.gz create mode 100644 rmvlib-1.1.1.tar.gz create mode 100644 rmvlib-1.1.2.tar.gz create mode 100644 rmvlib-1.1.3.tar.gz create mode 100644 rmvlib-1.1.tar.gz create mode 100644 screen/.depend create mode 100644 screen/Makefile create mode 100644 screen/a_1_buf.c create mode 100644 screen/a_2_buf.c create mode 100644 screen/a_z_buf.c create mode 100644 screen/cl_screen.s create mode 120000 screen/jaguar.inc create mode 100644 screen/n_screen.c create mode 100644 screen/s_1_buf.c create mode 100644 screen/scr2spr.c create mode 100644 screen/screen.h create mode 100644 screen/screen_def.s create mode 100644 screen/screen_inline.c create mode 100644 sound/Makefile create mode 100644 sound/amiga.txt create mode 120000 sound/jaguar.inc create mode 100644 sound/pt-play.s create mode 100644 sound/sound.h create mode 100644 sound/sound.s create mode 100644 sound/sound.s.LONG create mode 100644 sound/sound.s.ORIG create mode 100644 sprite/.depend create mode 100644 sprite/Makefile create mode 100644 sprite/a_sprite.c create mode 100644 sprite/c_layer.c create mode 100644 sprite/d_sprite.c create mode 100644 sprite/h_layer.c create mode 100644 sprite/iter_all.c create mode 100644 sprite/iter_one.c create mode 100644 sprite/m_layer.c create mode 100644 sprite/n_display.c create mode 100644 sprite/n_sprite.c create mode 100644 sprite/op.h create mode 100644 sprite/s_layer.c create mode 100644 sprite/s_sprite.c create mode 100644 sprite/so_layer.c create mode 100644 sprite/sprite.h diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5ab7695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +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 and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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 with +this License. + + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. 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 library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f27aeb2 --- /dev/null +++ b/Makefile @@ -0,0 +1,100 @@ +JAGPATH=$(HOME)/Jaguar +CROSSPATH=/usr/local/m68k-aout/m68k-aout +MADMAC=$(JAGPATH)/bin/mac +CC=$(CROSSPATH)/bin/gcc +AR=$(CROSSPATH)/bin/ar + +MACFLAGS=-fb -v +CFLAGS=-mc68000 -Wall -fomit-frame-pointer -O2 -msoft-float +SRCS= +SRCC= +SRCH= +OBJS=$(SRCC:.c=.o) $(SRCS:.s=.o) +NASUBDIRS=interrupt display collision fb2d sound +ASUBDIRS=sprite screen joypad blit memalign console +OSUBDIRS=doc +SUBDIRS=$(NASUBDIRS) $(ASUBDIRS) $(OSUBDIRS) + +PROJECT=rmvlib +# also change in Doxyfile!!! +PROJECT_NUMBER=1.1.3 + +TARFILE=$(PROJECT)-$(PROJECT_NUMBER).tar + +DISTFILES=Makefile main.h jaguar.inc LICENSE build.sh + +INSTALLH= +INSTALLLIB=$(PROJECT).a + +TARGET=$(HOME)/tmp/rmvlib + +all: subdirs $(OBJS) $(PROJECT).a + +$(PROJECT).a: Makefile subdirs $(OBJS) + for dir in $(ASUBDIRS); do $(AR) rvs $(PROJECT).a $$dir/*.o; done + +.PHONY: subdirs $(SUBDIRS) + +subdirs: $(SUBDIRS) + +$(SUBDIRS): + $(MAKE) -C $@ + +%.o: %.s + $(MADMAC) $(MACFLAGS) $< + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +clean: + for dir in $(SUBDIRS); do $(MAKE) clean -C $$dir; done + rm -f *~ $(OBJS) $(PROJECT).a + +dist: + tar cfv $(TARFILE) $(DISTFILES); \ + for dir in $(SUBDIRS); do \ + for file in `$(MAKE) -s dist-files -C $$dir`; do \ + tar rfv $(TARFILE) "$$dir/$$file"; \ + done; \ + done; + gzip $(TARFILE) + +list-headers: + for file in $(INSTALLH); do \ + echo "$$file"; \ + done; \ + for dir in $(SUBDIRS); do \ + for file in `$(MAKE) -s install-h -C $$dir`; do \ + echo "$$dir/$$file"; \ + done; \ + done + +list-objects: + for file in $(INSTALLLIB); do \ + echo "$$file"; \ + done; \ + for dir in $(SUBDIRS); do \ + for file in `$(MAKE) -s install-lib -C $$dir`; do \ + echo "$$dir/$$file"; \ + done; \ + done + +install: + mkdir -p "$(TARGET)/include"; \ + mkdir -p "$(TARGET)/lib"; \ + for file in $(INSTALLH); do \ + install -m "u+rw,go+r" "$$file" "$(TARGET)/include"; \ + done; \ + for dir in $(SUBDIRS); do \ + for file in `$(MAKE) -s install-h -C $$dir`; do \ + install -m "u+rw,go+r" "$$dir/$$file" "$(TARGET)/include"; \ + done; \ + done; \ + for file in $(INSTALLLIB); do \ + install -m "u+rw,go+r" "$$file" "$(TARGET)/lib"; \ + done; \ + for dir in $(SUBDIRS); do \ + for file in `$(MAKE) -s install-lib -C $$dir`; do \ + install -m "u+rw,go+r" "$$dir/$$file" "$(TARGET)/lib"; \ + done; \ + done diff --git a/blit/Makefile b/blit/Makefile new file mode 100644 index 0000000..338660d --- /dev/null +++ b/blit/Makefile @@ -0,0 +1,43 @@ +JAGPATH=$(HOME)/Jaguar +CROSSPATH=/usr/local/m68k-aout/m68k-aout +MADMAC=$(JAGPATH)/bin/mac +CC=$(CROSSPATH)/bin/gcc +AR=$(CROSSPATH)/bin/ar + +MACFLAGS=-fb -v +CFLAGS=-mc68000 -Wall -fomit-frame-pointer -O2 -msoft-float + +SRCC= +SRCS=blitset.s blitmove.s +SRCH=blit.h +OBJS=$(SRCC:.c=.o) $(SRCS:.s=.o) + +DISTFILES=Makefile $(SRCC) $(SRCH) $(SRCS) jaguar.inc +INSTALLH=blit.h +INSTALLLIB= + +# all: .depend $(OBJS) +all: $(OBJS) + +%.o: %.s + $(MADMAC) $(MACFLAGS) $< + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +clean: + rm -f *~ $(OBJS) .depend + +dist-files: + @echo $(DISTFILES) + +install-h: + @echo $(INSTALLH) + +install-lib: + @echo $(INSTALLLIB) + +# .depend: $(SRCC) +# $(CC) -MM $(SRCC) > .depend + +# -include .depend diff --git a/blit/blit.h b/blit/blit.h new file mode 100644 index 0000000..af614bc --- /dev/null +++ b/blit/blit.h @@ -0,0 +1,45 @@ +/* The Removers'Library */ +/* Copyright (C) 2006 Seb/The Removers */ +/* http://removers.atari.org/ */ + +/* This library is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU Lesser General Public */ +/* License as published by the Free Software Foundation; either */ +/* version 2.1 of the License, or (at your option) any later version. */ + +/* This library 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 */ +/* Lesser General Public License for more details. */ + +/* You should have received a copy of the GNU Lesser General Public */ +/* License along with this library; if not, write to the Free Software */ +/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** \file blit.h + * \brief Functions that uses the blitter to set or move buffers. + */ +#ifndef _BLIT_H +#define _BLIT_H + +#include + +/** Set the n bytes of the buffer starting at dst with character c. */ +void *blitset(/** Buffer address */ + void *dst, + /** Byte to be used to fill the buffer */ + int c, + /** Number of bytes to set */ + size_t n); + +/** Move a number of bytes from src buffer to dst buffer. + * The two buffers may overlap in memory. + */ +void *blitmove(/** Address of the source buffer */ + void *src, + /** Address of the target buffer */ + void *dst, + /** Number of bytes to move */ + size_t n); + +#endif diff --git a/blit/blitmove.s b/blit/blitmove.s new file mode 100644 index 0000000..b7f6dcd --- /dev/null +++ b/blit/blitmove.s @@ -0,0 +1,566 @@ +; The Removers'Library +; Copyright (C) 2006 Seb/The Removers +; http://removers.atari.org/ + +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. + +; This library 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 +; Lesser General Public License for more details. + +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + include "jaguar.inc" + +.macro wait_blitter +.wait_\~: + move.l B_CMD,\1 + btst #0,\1 + beq.s .wait_\~ +.endm + + .globl _blitmove + + .text + .68000 + +;;; void *blitmove(void *src, void *dst, size_t n) +_blitmove: + movem.l d2/a2,-(sp) + move.l 12+8(sp),d0 + beq .move_end + move.l #0,A1_CLIP ; **work around** + movem.l 12+0(sp),a0-a1 ; a0=src, a1=dst + cmp.l a0,a1 + beq .move_end + blo .fwd_move +.dst_hi_src: + lea (a0,d0.l),a2 ; end src + cmp.l a2,a1 + bhi .fwd_move ; forward PHRASE mode +.bwd_move: + lea (a1,d0.l),a1 ; end dest + move.l a2,a0 ; end src + ;; backward copy: slow since it uses PIXEL mode + move.w a0,d1 + lsr.w #1,d1 + bcc .bwd_src_even +.bwd_src_odd: + move.w a1,d1 + lsr.w #1,d1 + bcs .bwd_same_parity +.bwd_opposite_parity: + move.w a1,d1 + and.w #%111,d1 + beq.s .bwd_opp_dst_padded + subq.w #1,d1 +.bwd_opp_pad_dst: + move.b -(a0),-(a1) + subq.l #1,d0 + dbeq d1,.bwd_opp_pad_dst + beq .move_end +.bwd_opp_dst_padded: +;;; a0 is end of source address and is odd +;;; a1 is end of dest address and is aligned on a phrase boundary +;;; d0 is size to be moved + move.l #PIXEL8|XADDPIX|PITCH1|XSIGNSUB,A2_FLAGS + move.l #PIXEL8|XADDPIX|PITCH1|XSIGNSUB,A1_FLAGS + moveq #0,d1 + move.w a0,d1 + and.w #%111,d1 ; we know it is odd + sub.w d1,a0 +;;; first 16k blocks + lsl.l #2,d0 + swap d0 + tst.w d0 + beq.s .bwd_opp_less_16k + subq.w #1,d0 +.bwd_opp_x_16k: +.bwd_opp_fill_loop: + move.l #$4000,d2 + sub.l d2,a0 + sub.l d2,a1 + move.l a0,A2_BASE + move.l a1,A1_BASE + subq.w #1,d2 + move.l d2,A1_PIXEL + add.w d1,d2 + move.l d2,A2_PIXEL + move.l #$14000,B_COUNT + move.l #LFU_REPLACE|SRCEN,B_CMD + wait_blitter d2 + dbf d0,.bwd_opp_fill_loop +.bwd_opp_less_16k: + move.w #1,d0 + swap d0 + lsr.w #2,d0 + beq .move_end + moveq #0,d2 + move.w d0,d2 + addq.l #7,d2 + and.w #~%111,d2 ; d2 <= $4000 + sub.l d2,a0 + sub.l d2,a1 + subq.w #1,d2 + move.l a1,A1_BASE + move.l d2,A1_PIXEL + add.w d1,d2 ; here, we know that 0 <= d2 < 32767 !! + move.l d2,A2_PIXEL + move.l a0,A2_BASE + move.l d0,B_COUNT + move.l #LFU_REPLACE|SRCEN,B_CMD + wait_blitter d2 + bra .move_end +.bwd_src_even: + move.w a1,d1 + lsr.w #1,d1 + bcs .bwd_opposite_parity +.bwd_same_parity: +;;; we first pad dest to a phrase boundary + moveq #0,d1 ; because long op with d0 + move.w a1,d1 + and.w #%111,d1 + beq.s .bwd_same_dst_padded + sub.l d1,d0 + blo.s .bwd_same_slow_padding +.bwd_same_fast_padding: + subq.w #1,d1 + lsl.w #2,d1 + move.l .bwd_same_padrout(pc,d1.w),a2 + jmp (a2) +.bwd_same_padrout: + dc.l .bwd_same_pad1 + dc.l .bwd_same_pad2 + dc.l .bwd_same_pad3 + dc.l .bwd_same_pad4 + dc.l .bwd_same_pad5 + dc.l .bwd_same_pad6 + dc.l .bwd_same_pad7 +.bwd_same_pad7: + move.b -(a0),-(a1) +.bwd_same_pad6: + move.w -(a0),-(a1) +.bwd_same_pad4: + move.l -(a0),-(a1) + bra.s .bwd_same_dst_padded +.bwd_same_pad5: + move.b -(a0),-(a1) + move.l -(a0),-(a1) + bra.s .bwd_same_dst_padded +.bwd_same_pad3: + move.b -(a0),-(a1) +.bwd_same_pad2: + move.w -(a0),-(a1) + bra.s .bwd_same_dst_padded +.bwd_same_pad1: + move.b -(a0),-(a1) + bra.s .bwd_same_dst_padded +.bwd_same_slow_padding: + add.l d1,d0 + subq.w #1,d1 +.bwd_same_pad_dst: + move.b -(a0),-(a1) + subq.l #1,d0 + dbeq d1,.bwd_same_pad_dst + beq .move_end +.bwd_same_dst_padded: +;;; a0 is end of source address and is even +;;; a1 is end of dest address and is aligned on a phrase boundary +;;; d0 is size to be moved + moveq #0,d1 + move.w a0,d1 + and.w #%111,d1 + sub.w d1,a0 + lsr.w #2,d1 + bcc .bwd_same_long +.bwd_same_word: + roxl.w #1,d1 ; offset +;;; here we work in 16 bits + lsl.l #1,d0 + swap d0 + tst.w d0 + beq.s .bwd_same_word_lt_32k +.bwd_same_word_move_x_32k: + subq.w #1,d0 + move.l #PIXEL16|XADDPIX|PITCH1|XSIGNSUB,A2_FLAGS + move.l #PIXEL16|XADDPIX|PITCH1|XSIGNSUB,A1_FLAGS +.bwd_same_word_fill_loop: + move.l #$8000,d2 + sub.l d2,a0 + sub.l d2,a1 + move.l a0,A2_BASE + move.l a1,A1_BASE + lsr.l #1,d2 ; $4000 + subq.w #1,d2 + move.l d2,A1_PIXEL + add.w d1,d2 + move.l d2,A2_PIXEL + move.l #$14000,B_COUNT ; $4000 * 2 = $8000 + move.l #LFU_REPLACE|SRCEN,B_CMD + wait_blitter d2 + dbf d0,.bwd_same_word_fill_loop +.bwd_same_word_lt_32k: + move.w #1,d0 + swap d0 + lsl.w #1,d0 + bcc.s .bwd_same_word_lt_16k + move.l #PIXEL16|XADDPIX|PITCH1|XSIGNSUB,A2_FLAGS + move.l #PIXEL16|XADDPIX|PITCH1|XSIGNSUB,A1_FLAGS + move.l #$4000,d2 + sub.l d2,a0 + sub.l d2,a1 + move.l a0,A2_BASE + move.l a1,A1_BASE + lsr.l #1,d2 ; $2000 + subq.w #1,d2 + move.l d2,A1_PIXEL + add.w d1,d2 + move.l d2,A2_PIXEL + move.l #$12000,B_COUNT ; $2000 * 2 = $4000 + move.l #LFU_REPLACE|SRCEN,B_CMD + wait_blitter d2 +.bwd_same_word_lt_16k: + lsr.w #2,d0 + beq .move_end + add.w d1,d1 ; offset *= 2 + move.l #PIXEL8|XADDPIX|PITCH1|XSIGNSUB,A2_FLAGS + move.l #PIXEL8|XADDPIX|PITCH1|XSIGNSUB,A1_FLAGS + moveq #0,d2 + move.w d0,d2 + addq.l #7,d2 + and.w #~%111,d2 ; d2 <= $4000 + sub.l d2,a0 + sub.l d2,a1 + subq.w #1,d2 + move.l a1,A1_BASE + move.l d2,A1_PIXEL + add.w d1,d2 ; here, we know that 0 <= d2 < 32767 !! + move.l d2,A2_PIXEL + move.l a0,A2_BASE + move.l d0,B_COUNT + move.l #LFU_REPLACE|SRCEN,B_CMD + wait_blitter d2 + bra .move_end +.bwd_same_long: +;;; here we work in 32 bits + swap d0 + tst.w d0 + beq.s .bwd_same_long_move_lt_64k +.bwd_same_long_move_x_64k: + subq.w #1,d0 + move.l #PIXEL32|XADDPIX|PITCH1|XSIGNSUB,A2_FLAGS + move.l #PIXEL32|XADDPIX|PITCH1|XSIGNSUB,A1_FLAGS +.bwd_same_long_fill_loop: + move.l #$10000,d2 + sub.l d2,a0 + sub.l d2,a1 + move.l a0,A2_BASE + move.l a1,A1_BASE + lsr.l #2,d2 ; $4000 + subq.w #1,d2 + move.l d2,A1_PIXEL + add.w d1,d2 + move.l d2,A2_PIXEL + move.l #$14000,B_COUNT ; $4000 * 4 = $10000 + move.l #LFU_REPLACE|SRCEN,B_CMD + wait_blitter d2 + dbf d0,.bwd_same_long_fill_loop +.bwd_same_long_move_lt_64k: +;;; because offset might be > 0, +;;; the last block should be < 16k +;;; here, we make a 16k, 32k or 48k block + move.w #1,d0 + swap d0 + moveq #0,d2 + move.w d0,d2 + rol.w #2,d2 + and.w #%11,d2 + beq.s .bwd_same_long_move_lt_16k + move.l #PIXEL32|XADDPIX|PITCH1|XSIGNSUB,A2_FLAGS + move.l #PIXEL32|XADDPIX|PITCH1|XSIGNSUB,A1_FLAGS + swap d2 + lsr.l #2,d2 + sub.l d2,a0 + sub.l d2,a1 + move.l a0,A2_BASE + move.l a1,A1_BASE + lsr.l #2,d2 + swap d2 + move.w #1,d2 + swap d2 + move.l d2,B_COUNT + swap d2 + clr.w d2 + swap d2 + subq.w #1,d2 + move.l d2,A1_PIXEL + add.w d1,d2 + move.l d2,A2_PIXEL + move.l #LFU_REPLACE|SRCEN,B_CMD + wait_blitter d2 +.bwd_same_long_move_lt_16k: + lsl.w #2,d0 + lsr.w #2,d0 + beq .move_end + lsl.w #2,d1 ; offset *= 4 + move.l #PIXEL8|XADDPIX|PITCH1|XSIGNSUB,A2_FLAGS + move.l #PIXEL8|XADDPIX|PITCH1|XSIGNSUB,A1_FLAGS + moveq #0,d2 + move.w d0,d2 + addq.l #7,d2 + and.w #~%111,d2 ; d2 <= $4000 + sub.l d2,a0 + sub.l d2,a1 + subq.w #1,d2 + move.l a1,A1_BASE + move.l d2,A1_PIXEL + add.w d1,d2 ; here, we know that 0 <= d2 < 32767 !! + move.l d2,A2_PIXEL + move.l a0,A2_BASE + move.l d0,B_COUNT + move.l #LFU_REPLACE|SRCEN,B_CMD + wait_blitter d2 + bra .move_end +.fwd_move: + ;; forward copy: fast since it uses PHRASE mode + ;; a0 = source address + ;; a1 = dest address + ;; d0 = size + move.w a0,d1 + lsr.w #1,d1 + bcc .fwd_src_even +.fwd_src_odd: + move.w a1,d1 + lsr.w #1,d1 + bcs .fwd_same_parity +.fwd_opposite_parity: +;;; here, the best we can do is moving 1 byte at a time + moveq #8,d1 + sub.w a1,d1 + and.w #%111,d1 + beq.s .fwd_opp_dst_padded + subq.w #1,d1 +.fwd_opp_pad_dst: + move.b (a0)+,(a1)+ + subq.l #1,d0 + dbeq d1,.fwd_opp_pad_dst + beq .move_end +.fwd_opp_dst_padded: + move.l #LFU_REPLACE|SRCEN|SRCENX,a2 ; we have to realign source data (since it is odd) + move.l #PIXEL8|XADDPHR|PITCH1,A2_FLAGS + move.l #PIXEL8|XADDPHR|PITCH1,A1_FLAGS + moveq #0,d1 + move.w a0,d1 + and.w #%111,d1 ; we know it is not null + sub.w d1,a0 +;;; first 16k blocks + lsl.l #2,d0 + swap d0 + tst.w d0 + beq.s .fwd_opp_less_16k + subq.w #1,d0 +.fwd_opp_x_16k: +.fwd_opp_fill_loop: + move.l a0,A2_BASE + move.l d1,A2_PIXEL + move.l a1,A1_BASE + move.l #0,A1_PIXEL + move.l #$14000,B_COUNT ; $4000 * 1 = $4000 + move.l a2,B_CMD + moveq #1,d2 + swap d2 + lsr.l #2,d2 + add.l d2,a0 + add.l d2,a1 + wait_blitter d2 + dbf d0,.fwd_opp_fill_loop +.fwd_opp_less_16k: + move.w #1,d0 + swap d0 + lsr.w #2,d0 + beq .move_end + move.l a0,A2_BASE + move.l d1,A2_PIXEL + move.l a1,A1_BASE + move.l #0,A1_PIXEL + move.l d0,B_COUNT + move.l a2,B_CMD + wait_blitter d2 + bra .move_end +.fwd_src_even: + move.w a1,d1 + lsr.w #1,d1 + bcs .fwd_opposite_parity +.fwd_same_parity: +;;; here, we can at least move 2 bytes at a time after dst padding + moveq #8,d1 + sub.w a1,d1 + and.w #%111,d1 + beq.s .fwd_same_dst_padded + sub.l d1,d0 + blo.s .fwd_same_slow_padding +.fwd_same_fast_padding: + subq.w #1,d1 + lsl.w #2,d1 + move.l .fwd_same_padrout(pc,d1.w),a2 + jmp (a2) +.fwd_same_padrout: + dc.l .fwd_same_pad1 + dc.l .fwd_same_pad2 + dc.l .fwd_same_pad3 + dc.l .fwd_same_pad4 + dc.l .fwd_same_pad5 + dc.l .fwd_same_pad6 + dc.l .fwd_same_pad7 +.fwd_same_pad7: + move.b (a0)+,(a1)+ +.fwd_same_pad6: + move.w (a0)+,(a1)+ +.fwd_same_pad4: + move.l (a0)+,(a1)+ + bra.s .fwd_same_dst_padded +.fwd_same_pad5: + move.b (a0)+,(a1)+ + move.l (a0)+,(a1)+ + bra.s .fwd_same_dst_padded +.fwd_same_pad3: + move.b (a0)+,(a1)+ +.fwd_same_pad2: + move.w (a0)+,(a1)+ + bra.s .fwd_same_dst_padded +.fwd_same_pad1: + move.b (a0)+,(a1)+ + bra.s .fwd_same_dst_padded +.fwd_same_slow_padding: + add.l d1,d0 + subq.w #1,d1 +.fwd_same_pad_dst: + move.b (a0)+,(a1)+ + subq.l #1,d0 + dbeq d1,.fwd_same_pad_dst + beq .move_end +.fwd_same_dst_padded: +;;; the dest address is aligned on a phrase boundary +;;; and we know that the source address is even +;;; depending on src is long aligned or not, we transfer longs or words + move.l #LFU_REPLACE|SRCEN|SRCENX,a2 ; we realign source data unless it is phrase aligned (see below) + moveq #0,d1 + move.w a0,d1 + and.w #%111,d1 + sub.w d1,a0 + lsr.w #2,d1 + bcc .fwd_same_long +.fwd_same_word: + roxl.w #1,d1 ; offset +;;; here we transfer words until it remains less than 32k of data +;;; then we transfer bytes +;;; first 32k blocks + lsl.l #1,d0 + swap d0 + tst.w d0 + beq.s .fwd_same_word_move_lt_32k +.fwd_same_word_move_x_32k: + subq.w #1,d0 + move.l #PIXEL16|XADDPHR|PITCH1,A2_FLAGS + move.l #PIXEL16|XADDPHR|PITCH1,A1_FLAGS +.fwd_same_word_fill_loop: + move.l a0,A2_BASE + move.l d1,A2_PIXEL + move.l a1,A1_BASE + move.l #0,A1_PIXEL + move.l #$14000,B_COUNT ; $4000 * 2 = $8000 + move.l a2,B_CMD + moveq #1,d2 + swap d2 + lsr.l #1,d2 + add.l d2,a0 + add.l d2,a1 + wait_blitter d2 + dbf d0,.fwd_same_word_fill_loop +.fwd_same_word_move_lt_32k: + move.w #1,d0 + swap d0 + lsr.w #1,d0 + beq .move_end + add.w d1,d1 ; offset *= 2 + move.l #PIXEL8|XADDPHR|PITCH1,A2_FLAGS + move.l #PIXEL8|XADDPHR|PITCH1,A1_FLAGS + move.l a0,A2_BASE + move.l d1,A2_PIXEL + move.l a1,A1_BASE + move.l #0,A1_PIXEL + move.l d0,B_COUNT + move.l a2,B_CMD + wait_blitter d2 + bra .move_end +.fwd_same_long: +;;; here we transfer long words until it remains less than 32k of data +;;; then we transfer bytes + bne.s .fwd_same_long_go + move.l #LFU_REPLACE|SRCEN,a2 ; no need to realign source +.fwd_same_long_go: +;;; we first transfer 64k blocks + swap d0 + tst.w d0 + beq.s .fwd_same_long_move_lt_64k +.fwd_same_long_move_x_64k: + subq.w #1,d0 + move.l #PIXEL32|XADDPHR|PITCH1,A2_FLAGS + move.l #PIXEL32|XADDPHR|PITCH1,A1_FLAGS +.fwd_same_long_fill_loop: + move.l a0,A2_BASE + move.l d1,A2_PIXEL + move.l a1,A1_BASE + move.l #0,A1_PIXEL + move.l #$14000,B_COUNT ; $4000 * 4 = $10000 + move.l a2,B_CMD + moveq #1,d2 + swap d2 + add.l d2,a0 + add.l d2,a1 + wait_blitter d2 + dbf d0,.fwd_same_long_fill_loop +.fwd_same_long_move_lt_64k: +;;; then possibly one 32k block + move.w #1,d0 + swap d0 + lsl.w #1,d0 + bcc.s .fwd_same_long_move_lt_32k +.fwd_same_long_move_32k: + move.l #PIXEL32|XADDPHR|PITCH1,A2_FLAGS + move.l #PIXEL32|XADDPHR|PITCH1,A1_FLAGS + move.l a0,A2_BASE + move.l d1,A2_PIXEL + move.l a1,A1_BASE + move.l #0,A1_PIXEL + move.l #$12000,B_COUNT ; $2000 * 4 = $8000 + move.l a2,B_CMD + moveq #1,d2 + swap d2 + lsr.l #1,d2 + add.l d2,a0 + add.l d2,a1 + wait_blitter d2 +.fwd_same_long_move_lt_32k: + lsr.w #1,d0 + beq.s .move_end + lsl.w #2,d1 ; offset *= 4 + move.l #PIXEL8|XADDPHR|PITCH1,A2_FLAGS + move.l #PIXEL8|XADDPHR|PITCH1,A1_FLAGS + move.l a0,A2_BASE + move.l d1,A2_PIXEL + move.l a1,A1_BASE + move.l #0,A1_PIXEL + move.l d0,B_COUNT + move.l a2,B_CMD + wait_blitter d2 +.move_end: + movem.l (sp)+,d2/a2 + move.l 8(sp),d0 ; return address + rts diff --git a/blit/blitset.s b/blit/blitset.s new file mode 100644 index 0000000..2b13f96 --- /dev/null +++ b/blit/blitset.s @@ -0,0 +1,151 @@ +; The Removers'Library +; Copyright (C) 2006 Seb/The Removers +; http://removers.atari.org/ + +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. + +; This library 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 +; Lesser General Public License for more details. + +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + include "jaguar.inc" + +.macro wait_blitter +.wait_\~: + move.l B_CMD,\1 + btst #0,\1 + beq.s .wait_\~ +.endm + + .globl _blitset + + .text + .68000 + +;;; void *blitset(void *dst, int c, size_t n); +_blitset: + move.l d2,-(sp) + move.l 8+8(sp),d1 ; size + beq .end_fill ; if size is null then do nothing + move.l 8+4(sp),d0 ; fill pattern + move.w d0,d2 + lsl.w #8,d0 + move.b d2,d0 + move.w d0,d2 + swap d2 + move.w d0,d2 ; 4 times the same byte + move.l 8+0(sp),a0 + moveq #8,d0 + sub.w a0,d0 + and.w #%111,d0 + beq.s .dst_padded +;;; we first align dst address on a phrase boundary +;;; note that if dst is long aligned and size is a multiple of 4 +;;; then all memory access are in long words (or phrases) + sub.l d0,d1 + blo.s .slow_padding +.fast_padding: + subq.w #1,d0 + lsl.w #2,d0 + move.l .padrout(pc,d0.w),a1 + jmp (a1) +.padrout: + dc.l .pad1 + dc.l .pad2 + dc.l .pad3 + dc.l .pad4 + dc.l .pad5 + dc.l .pad6 + dc.l .pad7 +.pad7: + move.b d2,(a0)+ +.pad6: + move.w d2,(a0)+ +.pad4: + move.l d2,(a0)+ + bra.s .dst_padded +.pad5: + move.b d2,(a0)+ + move.l d2,(a0)+ + bra.s .dst_padded +.pad3: + move.b d2,(a0)+ +.pad2: + move.w d2,(a0)+ + bra.s .dst_padded +.pad1: + move.b d2,(a0)+ + bra.s .dst_padded +.slow_padding: + add.l d0,d1 + subq.w #1,d0 +.pad_dst: + move.b d2,(a0)+ + subq.l #1,d1 + dbeq d0,.pad_dst + beq .end_fill +.dst_padded: + ;; here, dest address is on a phrase boundary + ;; a0 = dst + ;; d1 = size + ;; d2 = fill pattern + move.l d2,B_PATD + move.l d2,B_PATD+4 + move.l #0,A1_CLIP ; **work around** + swap d1 + tst.w d1 + beq.s .fill_lt_64k +.fill_x_64k: + ;; here we fill 64k by 64k + subq.w #1,d1 + move.l #PIXEL32|XADDPHR|PITCH1,A1_FLAGS +.fill_loop: + move.l a0,A1_BASE + move.l #0,A1_PIXEL + move.l #$14000,B_COUNT ; $4000 * 4 = $10000 = 64 ko + move.l #PATDSEL,B_CMD + moveq #1,d2 + swap d2 + add.l d2,a0 + wait_blitter d2 + dbf d1,.fill_loop +.fill_lt_64k: + move.w #1,d1 + swap d1 + ;; here d1 < 64k + lsl.w #1,d1 + bcc.s .fill_lt_32k +.fill_32k: + ;; here we fill 32k + move.l #PIXEL32|XADDPHR|PITCH1,A1_FLAGS + move.l a0,A1_BASE + move.l #0,A1_PIXEL + move.l #$12000,B_COUNT ; $2000 * 4 = $8000 = 32 ko + move.l #PATDSEL,B_CMD + moveq #1,d2 + swap d2 + lsr.l #1,d2 + add.l d2,a0 + wait_blitter d2 +.fill_lt_32k: + ;; here d1 < 32k + lsr.w #1,d1 + beq.s .end_fill + move.l #PIXEL8|XADDPHR|PITCH1,A1_FLAGS + move.l a0,A1_BASE + move.l #0,A1_PIXEL + move.l d1,B_COUNT + move.l #PATDSEL,B_CMD + wait_blitter d2 +.end_fill: + move.l (sp)+,d2 + move.l 4(sp),d0 ; return address + rts diff --git a/blit/jaguar.inc b/blit/jaguar.inc new file mode 120000 index 0000000..7b95f03 --- /dev/null +++ b/blit/jaguar.inc @@ -0,0 +1 @@ +../jaguar.inc \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..af914eb --- /dev/null +++ b/build.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +cpath=`pwd` +tpath=/usr/local/m68k-aout +ipath=$tpath/m68k-aout/include +lpath=$tpath/m68k-aout/lib/m68000 + +for file in `make -s list-headers` +do + name=`basename $file` + echo "Symbolic linking $cpath/$file to $ipath/$name" + if [ -e "$ipath/$name" ] + then + echo "Skipping" + else + ln -s "$cpath/$file" "$ipath/$name" + fi +done + +make > log 2>&1 + +for file in `make -s list-objects` +do + name=`basename $file` + echo "Symbolic linking $cpath/$file to $lpath/$name" + if [ -e "$lpath/$name" ] + then + echo "Skipping" + else + ln -s "$cpath/$file" "$lpath/$name" + fi +done + + diff --git a/collision/Makefile b/collision/Makefile new file mode 100644 index 0000000..6333ab1 --- /dev/null +++ b/collision/Makefile @@ -0,0 +1,44 @@ +JAGPATH=$(HOME)/Jaguar +CROSSPATH=/usr/local/m68k-aout/m68k-aout +MADMAC=$(JAGPATH)/bin/mac +CC=$(CROSSPATH)/bin/gcc +AR=$(CROSSPATH)/bin/ar + +MACFLAGS=-fb -v +CFLAGS=-mc68000 -Wall -fomit-frame-pointer -O2 -msoft-float + +SRCC= +SRCS=collision.s +SRCH=collision.h +OBJS=$(SRCC:.c=.o) $(SRCS:.s=.o) + +DISTFILES=Makefile $(SRCC) $(SRCH) $(SRCS) display_def.s jaguar.inc +INSTALLH=collision.h +INSTALLLIB=collision.o + +# all: .depend $(OBJS) +all: $(OBJS) + +%.o: %.s + $(MADMAC) $(MACFLAGS) $< + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +clean: + rm -f *~ $(OBJS) .depend + +dist-files: + @echo $(DISTFILES) + +install-h: + @echo $(INSTALLH) + +install-lib: + @echo $(INSTALLLIB) + +# .depend: $(SRCC) +# $(CC) -MM $(SRCC) > .depend + +# -include .depend + diff --git a/collision/collision.h b/collision/collision.h new file mode 100644 index 0000000..ca6e64a --- /dev/null +++ b/collision/collision.h @@ -0,0 +1,90 @@ +/* The Removers'Library */ +/* Copyright (C) 2006 Seb/The Removers */ +/* http://removers.atari.org/ */ + +/* This library is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU Lesser General Public */ +/* License as published by the Free Software Foundation; either */ +/* version 2.1 of the License, or (at your option) any later version. */ + +/* This library 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 */ +/* Lesser General Public License for more details. */ + +/* You should have received a copy of the GNU Lesser General Public */ +/* License along with this library; if not, write to the Free Software */ +/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** \file collision.h + * \brief Pixel precise collision routine. + */ +#ifndef _COLLISION_H +#define _COLLISION_H + +#include + +#define COLLISION_DONE 0x80000000 +/** The two sprites collide. + */ +#define COLLISION_COLLIDE 0x8000 +/** The bounding boxes of the two sprites intersect. + */ +#define COLLISION_INTERSECT 0x80 +/** The first ::sprite is above the second one. */ +#define COLLISION_Y1_LE_Y2 0x1 +/** The first ::sprite is on the left of the second one. */ +#define COLLISION_X1_LE_X2 0x2 + +/** Initialise the GPU collision routine. + * + * The given address must be an address in GPU ram where to load the + * GPU routine. + * + * It returns the address of the end of the collision routine in GPU + * ram (which is long aligned). + */ +void *init_collision_routine(/** Address where to load the GPU + * routine. It should be long aligned. */ + void *addr); + +/** Run the collision test between the two given sprites. + * + * The collision routine works only with 16 bit sprites that are not + * scaled and not reflected. + * + * The result of the test can be read with ::get_collision_result. + */ +void launch_collision_test(/** Address of the first sprite. It should + * be long aligned. */ + sprite *s1, + /** Address of the second sprite sprite. It + * should be long aligned. */ + sprite *s2); + +/** Checks whether the collision test launched with + * ::launch_collision_test has finished. + */ +long is_collision_done(); + +/** Returns the result of the collision test. + * + * If COLLISION_INTERSECT then the two bounding boxes intersect. In + * this case, it returns the coordinates of the intersection box. + * + * If COLLISION_Y1_LE_Y2 then y is relative to first sprite, otherwise + * relative to the second sprite. + * + * If COLLISION_X1_LE_X2 then xis relative to first sprite, otherwise + * relative to the second sprite. + */ +long get_collision_result(/** Y coordinate of the intersection box */ + short int *y, + /** Height of the intersection box */ + short int *h, + /** X coordinate of the intersection box */ + short int *x, + /** Width of the intersection box */ + short int *w); + +#endif diff --git a/collision/collision.s b/collision/collision.s new file mode 100644 index 0000000..fabfdd1 --- /dev/null +++ b/collision/collision.s @@ -0,0 +1,399 @@ +; The Removers'Library +; Copyright (C) 2006 Seb/The Removers +; http://removers.atari.org/ + +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. + +; This library 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 +; Lesser General Public License for more details. + +; You should have received a copy of the GNU Lesser General Public +; License along with this library; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + include "display_def.s" + + .extern GPU_SUBROUT_ADDR + +.macro jsr_gpu + ;; \1: address of the subroutine + move.l \1,GPU_SUBROUT_ADDR +.endm + + .text + .68000 + +;;; GPU collision sub-routine +;;; this sub-routine works only on non-scaled +;;; 16 bpp transparent sprites (animation is taken into account) +;;; the field FIRSTPIX, REFLECT are ignored +;;; this sub-routine is self-relocatable +;;; it computes the intersection box and the collision flag +COLLISION_COLLIDE equ 15 +COLLISION_Y1_LE_Y2 equ 0 +COLLISION_X1_LE_X2 equ 1 +COLLISION_INTERSECT equ 7 + + .phrase +display_collision_routine: + .gpu + .org 0 + +.gpu_collision_begin: + move PC,r16 ; to relocate the sub routine + movei #.gpu_collision_params+8-.gpu_collision_begin,r0 + moveq #1,r1 + add r16,r0 ; relocate + shlq #31,r1 + store r1,(r0) ; not yet tested (most significant bit is a mutex) + subq #8,r0 + load (r0),r14 ; SPRITE1 + addq #4,r0 + load (r0),r15 ; SPRITE2 + addq #4,r0 + ;; r14 is SPRITE1 address + ;; r15 is SPRITE2 address + ;; r0 is subrout result address + load (r14+SPRITE_SND_PHRASE/4),r1 + load (r15+SPRITE_SND_PHRASE/4),r21 + btst #SPRITE_ANIM_ON_OFF,r1 + jr eq,.no_sprite1_anim + load (r14+(SPRITE_SND_PHRASE+4)/4),r2 +.sprite1_anim: + load (r14+SPRITE_ANIM_DATA/4),r3 + load (r14+SPRITE_ANIM_ARRAY/4),r11 + shlq #17,r3 ; get INDEX + .if DISPLAY_USE_LEGACY_ANIMATION + shrq #15,r3 ; INDEX<<2 + .else + shrq #14,r3 ; INDEX<<3 + .endif + add r3,r11 + load (r11),r3 ; get DATA + jr .ok_sprite1_data +.no_sprite1_anim: + load (r14+SPRITE_Y/4),r4 ; !! get Y|X !! **instead of nop** + load (r14+SPRITE_DATA/4),r3 ; get DATA +.ok_sprite1_data: + btst #SPRITE_ANIM_ON_OFF,r21 + jr eq,.no_sprite2_anim + load (r15+(SPRITE_SND_PHRASE+4)/4),r22 +.sprite2_anim: + load (r15+SPRITE_ANIM_DATA/4),r23 + load (r15+SPRITE_ANIM_ARRAY/4),r11 + shlq #17,r23 ; get INDEX + .if DISPLAY_USE_LEGACY_ANIMATION + shrq #15,r23 ; INDEX<<2 + .else + shrq #14,r23 ; INDEX<<3 + .endif + add r23,r11 + load (r11),r23 ; get DATA + jr .ok_sprite2_data +.no_sprite2_anim: + load (r15+SPRITE_Y/4),r24 ; !! get Y|X !! **instead of nop** + load (r15+SPRITE_DATA/4),r23 ; get DATA +.ok_sprite2_data: + move r4,r5 + shlq #16,r4 + sharq #16,r5 ; Y1 + sharq #16,r4 ; X1 + move r24,r25 + shlq #16,r24 + sharq #16,r25 ; Y2 + sharq #16,r24 ; X2 + ;; here we have to adjust coordinates wrt hotpot + ;; remember that we treat NEITHER scaled sprites NOR reflected ones !! + ;; (this explains why this part is simplified) + btst #SPRITE_USE_HOTSPOT,r1 + jr eq,.ok_sprite1_coords + nop + load (r14+SPRITE_HY/4),r6 ; load HY|HX + move r6,r7 + sharq #16,r6 ; HY + shlq #16,r7 ; to get HX + sub r6,r5 ; Y -= HY + sharq #16,r7 ; HX + sub r7,r4 ; X -= HX +.ok_sprite1_coords: + btst #SPRITE_USE_HOTSPOT,r21 + jr eq,.ok_sprite2_coords + nop + load (r15+SPRITE_HY/4),r26 ; load HY|HX + move r26,r27 + sharq #16,r26 ; HY + shlq #16,r27 ; to get HX + sub r26,r25 ; Y -= HY + sharq #16,r27 ; HX + sub r27,r24 ; X -= HX +.ok_sprite2_coords: + ;; r1, r2 is snd phrase of SPRITE1 + ;; r3 is DATA1 + ;; r4,r5 is X1,Y1 + ;; r21, r22 is snd phrase of SPRITE2 + ;; r23 is DATA2 + ;; r24,r25 is X2,Y2 + shlq #26,r1 + shlq #26,r21 + move r2,r6 + move r22,r26 + shrq #18,r2 + shrq #18,r22 + shlq #22,r6 + shlq #22,r26 + shrq #22,r1 + shrq #22,r21 + shrq #22,r6 ; HEIGHT1 + shrq #22,r26 ; HEIGHT2 + move r2,r11 + move r22,r12 + shrq #10,r2 + shrq #10,r22 + shlq #22,r11 ; DWIDTH1 << 22 + shlq #22,r12 ; DWIDTH2 << 22 + shrq #22,r11 ; DWIDTH1 + shrq #22,r12 ; DWIDTH2 + or r2,r1 ; IWIDTH1 + or r22,r21 ; IWIDTH2 + shlq #2,r1 ; IWIDTH1 in words = pixels + shlq #2,r21 ; IWIDTH2 in words = pixels + ;; r1 is IWIDTH1 (16 bit pixels) hence is W1 + ;; r21 is IWIDTH2 (16 bit pixels) hence is W2 + ;; r11 is DWIDTH1 + ;; r12 is DWIDTH2 + ;; r6 is HEIGHT1 + ;; r26 is HEIGHT2 + movei #.gpu_collision_return-.gpu_collision_begin,r19 + moveq #0,r20 ; no collision + add r16,r19 ; relocate + move r6,r7 ; save H1 + move r26,r27 ; save H2 + add r5,r7 ; Y1+H1 + add r25,r27 ; Y2+H2 + sub r5,r27 ; if Y2+H2 - Y1 < 0 then no collision + jump mi,(r19) + sub r25,r7 ; if Y1+H1 - Y2 < 0 then no collision + jump mi,(r19) + sub r5,r25 ; Y2-Y1 + jr pl,.y1_le_y2 + move r1,r8 ; save W1 +.y1_gt_y2: + ;; Y2 - Y1 < 0 + abs r25 + move r25,r17 + mult r12,r25 ; |Y2-Y1| * DWIDTH2 + shlq #16,r17 + shlq #3,r25 ; offset Y + cmp r6,r27 ; get min(h1,y2+h2-y1) + jr mi,.min_h1_done + add r25,r23 ; add offset Y to DATA2 + move r6,r27 ; height of intersection +.min_h1_done: + subq #1,r27 + jump mi,(r19) ; if HEIGHT = 0 then no collision + or r27,r17 + jr .y_done + move r21,r28 ; save W2 +.y1_le_y2: + ;; Y2 - Y1 >= 0 + bset #COLLISION_Y1_LE_Y2,r20 + move r25,r17 + mult r2,r25 ; |Y2-Y1| * DWIDTH1 + shlq #16,r17 + shlq #3,r25 ; offset Y + cmp r26,r7 ; get min(h2,y1+h1-y2) + jr mi,.min_h2_done + add r25,r3 ; add offset Y to DATA1 + move r26,r7 +.min_h2_done: + subq #1,r7 + jump mi,(r19) ; if HEIGHT = 0 then no collision + or r7,r17 + move r21,r28 +.y_done: + ;; + add r4,r8 ; X1+W1 + add r24,r28 ; X2+W2 + sub r4,r28 + jump mi,(r19) ; if X2+W2 - X1 < 0 then no collision + sub r24,r8 + jump mi,(r19) ; if X1+W1 - X2 < 0 then no collision + sub r4,r24 ; X2-X1 + jr pl,.x1_le_x2 + nop +.x1_gt_x2: + ;; X2 - X1 < 0 + abs r24 + move r24,r18 + shlq #1,r24 ; offset X + shlq #16,r18 + cmp r1,r28 ; get min(w1,x2+w2-x1) + jr mi,.min_w1_done + add r24,r23 ; add offset X to DATA2 + move r1,r28 ; width of the intersection +.min_w1_done: + subq #1,r28 + jump mi,(r19) ; if WIDTH = 0 then no collision + or r28,r18 + jr .x_done + nop +.x1_le_x2: + ;; X2 - X1 >= 0 + bset #COLLISION_X1_LE_X2,r20 + move r24,r18 + shlq #1,r24 ; offset X + shlq #16,r18 + cmp r21,r8 ; get min(w2,x1+w1-x2) + jr mi,.min_w2_done + add r24,r3 ; add offset X to DATA1 + move r21,r8 +.min_w2_done: + subq #1,r8 + jump mi,(r19) ; if WIDTH = 0 then no collision + or r8,r18 +.x_done: + ;; write Y coords + subq #8,r0 ; to write Y|H coords + bset #COLLISION_INTERSECT,r20 + store r17,(r0) + addq #4,r0 ; to write X|W coords + ;; write X coords + store r18,(r0) + addq #4,r0 + ;; + ;; lower word of r17 contains height-1 + ;; lower word of r18 contains width-1 + ;; r3 is DATA1 address (fixed) + ;; r23 is DATA2 address (fixed) + shlq #16,r18 + shlq #16,r17 + shrq #16,r18 + shrq #16,r17 + addq #1,r18 + shlq #3,r11 ; DWIDTH1 in bytes + shlq #1,r18 ; bytes per line + shlq #3,r12 ; DWIDTH2 in bytes + sub r18,r11 ; offset1 (to reach next line) + sub r18,r12 ; offset2 (to reach next line) +.gpu_collision_test: + move r18,r19 ; width (in bytes) +.gpu_collision_test_line: + loadw (r3),r10 + cmpq #0,r10 ; is it transparent? + jr eq,.gpu_collision_test_skip + addq #2,r3 ; instead of a nop + loadw (r23),r10 + cmpq #0,r10 + jr ne,.gpu_collision_collide +.gpu_collision_test_skip: + addq #2,r23 ; instead of nop + subq #2,r19 + jr ne,.gpu_collision_test_line + nop + add r11,r3 + add r12,r23 + subq #1,r17 + jr pl,.gpu_collision_test + nop + jr .gpu_collision_return + nop +.gpu_collision_collide: + bset #COLLISION_COLLIDE,r20 +.gpu_collision_return: + store r20,(r0) + ;; return from sub routine + load (r31),r0 + jump (r0) + addq #4,r31 + .long +.gpu_collision_params: + dc.l 0 + dc.l 0 + dc.l 0 + .long +.gpu_collision_end: + +COLLISION_ROUTINE_SIZE equ .gpu_collision_end-.gpu_collision_begin +COLLISION_PARAMS equ .gpu_collision_params-.gpu_collision_begin + +; GPU_COLLISION_SPRITE1 equ .gpu_collision_params-.gpu_collision_begin +; GPU_COLLISION_SPRITE2 equ .gpu_collision_params+4-.gpu_collision_begin +; GPU_COLLISION_RESULT equ .gpu_collision_params+8-.gpu_collision_begin +; GPU_COLLISION_COORDS equ .gpu_collision_params-.gpu_collision_begin + + .print "Collision routine code size: ",COLLISION_ROUTINE_SIZE + + .68000 + .text + + .globl _launch_collision_test +;;; void launch_collision_test(sprite *s1, sprite *s2); +_launch_collision_test: + move.l collision_address,a0 + lea COLLISION_PARAMS(a0),a1 + move.l 4(sp),(a1)+ + move.l 8(sp),(a1)+ + move.l #$80000000,(a1)+ + jsr_gpu a0 + rts + + .globl _is_collision_done +;;; long is_collision_done(); +_is_collision_done: + move.l collision_address,a0 + move.l COLLISION_PARAMS+8(a0),d0 + rts + + .globl _get_collision_result +;;; long get_collision_result(short int *y, short int *h, short int *x, short int *w) +_get_collision_result: + move.l a2,-(sp) + move.l collision_address,a0 + movem.l 4+4(sp),a1-a2 + lea COLLISION_PARAMS+8(a0),a0 +.wait: + move.l (a0),d0 + bmi.s .wait + subq.w #8,a0 + move.l (a0)+,d1 + move.w d1,(a2) ; H + swap d1 + move.w d1,(a1) ; Y + move.l (a0),d1 + movem.l 4+12(sp),a1-a2 + move.w d1,(a2) ; W + swap d1 + move.w d1,(a1) ; X + move.l (sp)+,a2 + rts + + .extern _bcopy + .globl _init_collision_routine +;;; void *init_collision_routine(void *addr) +_init_collision_routine: + pea COLLISION_ROUTINE_SIZE + move.l 4+4(sp),-(sp) + pea display_collision_routine + jsr _bcopy + lea 12(sp),sp + move.l 4(sp),d0 + move.l d0,collision_address + add.l #COLLISION_ROUTINE_SIZE,d0 + rts + + .data + .even + dc.b "Collision Routine by Seb/The Removers" + .even + + .bss + .long +collision_address: + ds.l 1 + + diff --git a/collision/display_def.s b/collision/display_def.s new file mode 120000 index 0000000..321af43 --- /dev/null +++ b/collision/display_def.s @@ -0,0 +1 @@ +../display/display_def.s \ No newline at end of file diff --git a/collision/jaguar.inc b/collision/jaguar.inc new file mode 120000 index 0000000..7b95f03 --- /dev/null +++ b/collision/jaguar.inc @@ -0,0 +1 @@ +../jaguar.inc \ No newline at end of file diff --git a/console/.depend b/console/.depend new file mode 100644 index 0000000..88df384 --- /dev/null +++ b/console/.depend @@ -0,0 +1,2 @@ +open_console.o: open_console.c +open_custom_console.o: open_custom_console.c diff --git a/console/Makefile b/console/Makefile new file mode 100644 index 0000000..7df4b2f --- /dev/null +++ b/console/Makefile @@ -0,0 +1,42 @@ +JAGPATH=$(HOME)/Jaguar +CROSSPATH=/usr/local/m68k-aout/m68k-aout +MADMAC=$(JAGPATH)/bin/mac +CC=$(CROSSPATH)/bin/gcc +AR=$(CROSSPATH)/bin/ar + +MACFLAGS=-fb -v +CFLAGS=-mc68000 -Wall -fomit-frame-pointer -O2 -msoft-float + +SRCC=open_console.c open_custom_console.c +SRCS= +SRCH=console.h +OBJS=$(SRCC:.c=.o) $(SRCS:.s=.o) + +DISTFILES=Makefile $(SRCC) $(SRCS) $(SRCH) +INSTALLH=console.h +INSTALLLIB= + +all: .depend $(OBJS) + +%.o: %.s + $(MADMAC) $(MACFLAGS) $< + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +clean: + rm -f *~ $(OBJS) .depend + +dist-files: + @echo $(DISTFILES) + +install-h: + @echo $(INSTALLH) + +install-lib: + @echo $(INSTALLLIB) + +.depend: $(SRCC) + $(CC) -MM $(SRCC) > .depend + +-include .depend diff --git a/console/console.h b/console/console.h new file mode 100644 index 0000000..040e90a --- /dev/null +++ b/console/console.h @@ -0,0 +1,49 @@ +/* The Removers'Library */ +/* Copyright (C) 2006 Seb/The Removers */ +/* http://removers.atari.org/ */ + +/* This library is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU Lesser General Public */ +/* License as published by the Free Software Foundation; either */ +/* version 2.1 of the License, or (at your option) any later version. */ + +/* This library 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 */ +/* Lesser General Public License for more details. */ + +/* You should have received a copy of the GNU Lesser General Public */ +/* License along with this library; if not, write to the Free Software */ +/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** \file console.h + * \brief an on-screen console + */ + +#ifndef _CONSOLE_H +#define _CONSOLE_H + +#include +#include + +/** Open a new console attached to the given display, at given + coordinates. It is implemented as a 1 bpp screen buffer: you can + specify the index in the CLUT. + */ +FILE *open_console(/** display */ display *d, + /** X coordinate */ int x, + /** Y coordinate */ int y, + /** index in CLUT */ int idx); + +/** Open a new console attached to the given display, at given + coordinates. + */ +FILE *open_custom_console(/** display */ display *d, + /** X coordinate */ int x, + /** Y coordinate */ int y, + /** index in CLUT */ int idx, + /** number of columns */ int width, + /** number of lines */ int height, + /** layer */ int layer); + +#endif diff --git a/console/open_console.c b/console/open_console.c new file mode 100644 index 0000000..b926ecc --- /dev/null +++ b/console/open_console.c @@ -0,0 +1,11 @@ +#include +#include + +// CONSOLE_WIDTH should be a multiple of 8 +#define DFLT_CONSOLE_WIDTH 40 +#define DFLT_CONSOLE_HEIGHT 25 +#define DFLT_CONSOLE_LAYER 0 + +FILE *open_console(display *d, int x, int y, int idx) { + return open_custom_console(d,x,y,idx,DFLT_CONSOLE_WIDTH,DFLT_CONSOLE_HEIGHT,DFLT_CONSOLE_LAYER); +} diff --git a/console/open_custom_console.c b/console/open_custom_console.c new file mode 100644 index 0000000..c8b9f71 --- /dev/null +++ b/console/open_custom_console.c @@ -0,0 +1,432 @@ +#include +#include + +#define USE_BLITTER 0 + +#if USE_BLITTER +// scrolling is made with the Blitter +#include +#else +// scrolling is made with the 68k +#include +#endif + +typedef struct { + short int x; + short int y; + short int width; + short int height; + sprite *s; +} console; + +static char ascii_fnt[256*8] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x24, 0x42, 0x81, 0xE7, 0x24, 0x24, 0x3C, + 0x3C, 0x24, 0x24, 0xE7, 0x81, 0x42, 0x24, 0x18, + 0x18, 0x14, 0xF2, 0x81, 0x81, 0xF2, 0x14, 0x18, + 0x18, 0x28, 0x4F, 0x81, 0x81, 0x4F, 0x28, 0x18, + 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF, + 0xF8, 0x88, 0x8F, 0x89, 0xF9, 0x41, 0x41, 0x7F, + 0xFF, 0x89, 0x89, 0x89, 0xF9, 0x81, 0x81, 0xFF, + 0x01, 0x03, 0x06, 0x8C, 0xD8, 0x70, 0x20, 0x00, + 0x7E, 0xC3, 0xD3, 0xD3, 0xDB, 0xC3, 0xC3, 0x7E, + 0x18, 0x3C, 0x2C, 0x2C, 0x7E, 0x18, 0x18, 0x00, + 0x10, 0x1C, 0x12, 0x10, 0x10, 0x70, 0xF0, 0x60, + 0xF0, 0xC0, 0xFE, 0xD8, 0xDE, 0x18, 0x18, 0x00, + 0x70, 0xC8, 0xDE, 0xDB, 0xDB, 0x7E, 0x1B, 0x1B, + 0x03, 0x00, 0x0F, 0x03, 0x03, 0x03, 0x03, 0x0F, + 0x90, 0x20, 0xD0, 0xA0, 0xD0, 0xA8, 0xD0, 0xE0, + 0x7C, 0xC6, 0xC6, 0x00, 0xC6, 0xC6, 0x7C, 0x00, + 0x06, 0x06, 0x06, 0x00, 0x06, 0x06, 0x06, 0x00, + 0x7C, 0x06, 0x06, 0x7C, 0xC0, 0xC0, 0x7C, 0x00, + 0x7C, 0x06, 0x06, 0x7C, 0x06, 0x06, 0x7C, 0x00, + 0xC6, 0xC6, 0xC6, 0x7C, 0x06, 0x06, 0x06, 0x00, + 0x7C, 0xC0, 0xC0, 0x7C, 0x06, 0x06, 0x7C, 0x00, + 0x7C, 0xC0, 0xC0, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, + 0x7C, 0x06, 0x06, 0x00, 0x06, 0x06, 0x06, 0x00, + 0x7C, 0xC6, 0xC6, 0x7C, 0xC6, 0xC6, 0x7C, 0x00, + 0x7C, 0xC6, 0xC6, 0x7C, 0x06, 0x06, 0x7C, 0x00, + 0x00, 0x3C, 0x46, 0x06, 0x7E, 0x66, 0x3C, 0x00, + 0x78, 0x66, 0x7D, 0x64, 0x7E, 0x03, 0x0B, 0x06, + 0x07, 0x0F, 0x1F, 0x18, 0x18, 0x10, 0x1E, 0x17, + 0xF0, 0xF8, 0xEC, 0x04, 0x04, 0x04, 0x3C, 0x54, + 0x11, 0x0B, 0x0D, 0x06, 0x07, 0x2E, 0x39, 0x38, + 0xFC, 0xFC, 0xFF, 0xE1, 0xE1, 0x21, 0x3F, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00, + 0x66, 0x66, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00, + 0x14, 0x3E, 0x55, 0x3C, 0x1E, 0x55, 0x3E, 0x14, + 0x62, 0x66, 0x0C, 0x18, 0x30, 0x66, 0x46, 0x00, + 0x78, 0xCC, 0x61, 0xCE, 0xCC, 0xCC, 0x78, 0x00, + 0x18, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x08, 0x18, 0x18, 0x18, 0x18, 0x08, 0x04, + 0x20, 0x10, 0x18, 0x18, 0x18, 0x18, 0x10, 0x20, + 0x00, 0x54, 0x38, 0xFE, 0x38, 0x54, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x20, + 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x00, + 0x3C, 0x66, 0x6E, 0x76, 0x66, 0x66, 0x3C, 0x00, + 0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x3C, 0x66, 0x0E, 0x1C, 0x38, 0x70, 0x7E, 0x00, + 0x7E, 0x0C, 0x18, 0x3C, 0x06, 0x46, 0x3C, 0x00, + 0x0C, 0x1C, 0x2C, 0x4C, 0x7E, 0x0C, 0x0C, 0x00, + 0x7E, 0x60, 0x7C, 0x06, 0x06, 0x46, 0x3C, 0x00, + 0x1C, 0x20, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00, + 0x7E, 0x06, 0x0E, 0x1C, 0x18, 0x18, 0x18, 0x00, + 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00, + 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x0C, 0x38, 0x00, + 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x10, 0x00, + 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00, + 0x00, 0x00, 0x3C, 0x00, 0x00, 0x3C, 0x00, 0x00, + 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00, + 0x3C, 0x46, 0x06, 0x0C, 0x18, 0x18, 0x00, 0x18, + 0x3C, 0x66, 0x6E, 0x6A, 0x6E, 0x60, 0x3C, 0x00, + 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, + 0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x00, + 0x3C, 0x62, 0x60, 0x60, 0x60, 0x62, 0x3C, 0x00, + 0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00, + 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x7E, 0x00, + 0x7E, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x60, 0x00, + 0x3C, 0x62, 0x60, 0x6E, 0x66, 0x66, 0x3E, 0x00, + 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x46, 0x3C, 0x00, + 0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66, 0x00, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7C, 0x00, + 0xFC, 0xD6, 0xD6, 0xD6, 0xD6, 0xC6, 0xC6, 0x00, + 0x62, 0x72, 0x7A, 0x5E, 0x4E, 0x46, 0x42, 0x00, + 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, + 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x00, + 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x06, + 0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x00, + 0x3C, 0x62, 0x70, 0x3C, 0x0E, 0x46, 0x3C, 0x00, + 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x64, 0x78, 0x00, + 0xC6, 0xC6, 0xC6, 0xD6, 0xD6, 0xD6, 0xFC, 0x00, + 0x66, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x66, 0x00, + 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x00, + 0x7E, 0x0E, 0x1C, 0x38, 0x70, 0x60, 0x7E, 0x00, + 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00, + 0x40, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, + 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, + 0x10, 0x38, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, + 0x00, 0xC0, 0xC0, 0x60, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x00, + 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00, + 0x00, 0x3C, 0x62, 0x60, 0x60, 0x62, 0x3C, 0x00, + 0x06, 0x3E, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, + 0x00, 0x3C, 0x66, 0x7E, 0x60, 0x62, 0x3C, 0x00, + 0x1E, 0x30, 0x7C, 0x30, 0x30, 0x30, 0x30, 0x00, + 0x00, 0x3E, 0x66, 0x66, 0x66, 0x3E, 0x46, 0x3C, + 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, + 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x00, 0x08, 0x18, 0x18, 0x18, 0x18, 0x58, 0x30, + 0x60, 0x64, 0x68, 0x70, 0x78, 0x6C, 0x66, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0C, 0x00, + 0x00, 0xFC, 0xD6, 0xD6, 0xD6, 0xD6, 0xC6, 0x00, + 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, + 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, + 0x00, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, + 0x00, 0x3E, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x06, + 0x00, 0x6C, 0x70, 0x60, 0x60, 0x60, 0x60, 0x00, + 0x00, 0x3C, 0x72, 0x38, 0x1C, 0x4E, 0x3C, 0x00, + 0x18, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x0C, 0x00, + 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, + 0x00, 0x66, 0x66, 0x66, 0x66, 0x64, 0x78, 0x00, + 0x00, 0xC6, 0xC6, 0xD6, 0xD6, 0xD6, 0xFC, 0x00, + 0x00, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x66, 0x00, + 0x00, 0x66, 0x66, 0x66, 0x26, 0x1E, 0x46, 0x3C, + 0x00, 0x7E, 0x0E, 0x1C, 0x38, 0x70, 0x7E, 0x00, + 0x0E, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0E, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x70, 0x18, 0x18, 0x0C, 0x18, 0x18, 0x70, 0x00, + 0x00, 0x60, 0xF2, 0x9E, 0x0C, 0x00, 0x00, 0x00, + 0x10, 0x10, 0x28, 0x28, 0x44, 0x44, 0x82, 0xFE, + 0xFF, 0xFF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, + 0x24, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3E, 0x00, + 0xFF, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xFF, 0xFF, + 0x24, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFF, + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, + 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0xC0, 0xC0, 0xC0, 0xFF, 0xFF, 0xC0, 0xC0, 0xC0, + 0x03, 0x03, 0x03, 0xFF, 0xFF, 0x03, 0x03, 0x03, + 0x24, 0x00, 0x3C, 0x66, 0x7E, 0x66, 0x66, 0x00, + 0xFF, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0xFF, + 0x00, 0x00, 0x7E, 0x1B, 0x7F, 0xD8, 0x7E, 0x00, + 0x3F, 0x78, 0xD8, 0xDE, 0xF8, 0xD8, 0xDF, 0x00, + 0x18, 0x34, 0x00, 0x3C, 0x66, 0x66, 0x3C, 0x00, + 0x24, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, + 0x30, 0x18, 0x00, 0x3C, 0x66, 0x66, 0x3C, 0x00, + 0x18, 0x24, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x00, + 0x30, 0x18, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x00, + 0x66, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x46, 0x3C, + 0x66, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, + 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, + 0x18, 0x3C, 0x62, 0x60, 0x60, 0x62, 0x3C, 0x18, + 0x1C, 0x3A, 0x30, 0x7C, 0x30, 0x30, 0x7E, 0x00, + 0x66, 0x66, 0x3C, 0x18, 0x3C, 0x18, 0x18, 0x00, + 0x3C, 0x66, 0x66, 0x6C, 0x66, 0x66, 0xEC, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x0C, 0x18, 0x00, 0x3C, 0x06, 0x7E, 0x3E, 0x00, + 0x0C, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x0C, 0x18, 0x00, 0x3C, 0x66, 0x66, 0x3C, 0x00, + 0x0C, 0x18, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x00, + 0x34, 0x58, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x00, + 0x1A, 0x2C, 0x62, 0x72, 0x5A, 0x4E, 0x46, 0x00, + 0x00, 0x3C, 0x46, 0x3E, 0x66, 0x3E, 0x00, 0x7E, + 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x7E, + 0x00, 0x18, 0x00, 0x18, 0x30, 0x60, 0x66, 0x3C, + 0x00, 0x00, 0x00, 0x3E, 0x30, 0x30, 0x30, 0x00, + 0x00, 0x00, 0x00, 0x7C, 0x0C, 0x0C, 0x0C, 0x00, + 0x62, 0xE4, 0x68, 0x76, 0x2B, 0x43, 0x86, 0x0F, + 0x62, 0xE4, 0x68, 0x76, 0x2E, 0x56, 0x9F, 0x06, + 0x00, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x1B, 0x36, 0x6C, 0xD8, 0x6C, 0x36, 0x1B, 0x00, + 0xD8, 0x6C, 0x36, 0x1B, 0x36, 0x6C, 0xD8, 0x00, + 0x34, 0x58, 0x00, 0x3C, 0x06, 0x7E, 0x3E, 0x00, + 0x34, 0x58, 0x00, 0x3C, 0x66, 0x66, 0x3C, 0x00, + 0x02, 0x3C, 0x66, 0x6E, 0x76, 0x66, 0x3C, 0x40, + 0x00, 0x02, 0x3C, 0x6E, 0x76, 0x66, 0x3C, 0x40, + 0x00, 0x00, 0x7E, 0xDB, 0xDE, 0xD8, 0x7F, 0x00, + 0x00, 0x7E, 0xD8, 0xD8, 0xFC, 0xD8, 0xD8, 0xDE, + 0x20, 0x10, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, + 0x34, 0x58, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, + 0x34, 0x58, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x3C, + 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0C, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x10, 0x10, 0x10, 0x00, 0x00, + 0x7A, 0xCA, 0xCA, 0xCA, 0x7A, 0x0A, 0x0A, 0x0A, + 0x3C, 0x42, 0x99, 0xB5, 0xB1, 0x9D, 0x42, 0x3C, + 0x3C, 0x42, 0xB9, 0xB5, 0xB9, 0xB5, 0x42, 0x3C, + 0xF1, 0x5B, 0x55, 0x51, 0x51, 0x00, 0x00, 0x00, + 0x66, 0x00, 0xE6, 0x66, 0x66, 0xF6, 0x06, 0x1C, + 0xF6, 0x66, 0x66, 0x66, 0x66, 0xF6, 0x06, 0x1C, + 0x00, 0x66, 0x76, 0x3C, 0x6E, 0x66, 0x00, 0x00, + 0x00, 0x7C, 0x0C, 0x0C, 0x0C, 0x7E, 0x00, 0x00, + 0x00, 0x1E, 0x06, 0x0E, 0x1E, 0x36, 0x00, 0x00, + 0x00, 0x7E, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x00, + 0x00, 0x7C, 0x06, 0x66, 0x66, 0x66, 0x00, 0x00, + 0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x00, + 0x00, 0x1E, 0x0C, 0x06, 0x06, 0x06, 0x00, 0x00, + 0x00, 0x7E, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, + 0x60, 0x6E, 0x66, 0x66, 0x66, 0x7E, 0x00, 0x00, + 0x00, 0x3C, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3E, 0x06, 0x06, 0x06, 0x3E, 0x00, 0x00, + 0x60, 0x7E, 0x06, 0x06, 0x06, 0x0E, 0x00, 0x00, + 0x00, 0x6C, 0x3E, 0x66, 0x66, 0x6E, 0x00, 0x00, + 0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, 0x00, + 0x00, 0x3E, 0x36, 0x36, 0x36, 0x1C, 0x00, 0x00, + 0x00, 0x36, 0x36, 0x36, 0x36, 0x7E, 0x00, 0x00, + 0x00, 0x7E, 0x66, 0x76, 0x06, 0x7E, 0x00, 0x00, + 0x00, 0x66, 0x66, 0x3C, 0x0E, 0x7E, 0x00, 0x00, + 0x00, 0x3E, 0x06, 0x36, 0x36, 0x34, 0x30, 0x00, + 0x00, 0x78, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x00, + 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x00, 0x00, + 0x00, 0x7C, 0x6C, 0x6C, 0x6C, 0xEC, 0x00, 0x00, + 0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, + 0x00, 0x3E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, + 0x00, 0xFE, 0x66, 0x66, 0x66, 0x7E, 0x00, 0x00, + 0x00, 0x7E, 0x66, 0x76, 0x06, 0x06, 0x06, 0x00, + 0x00, 0x36, 0x36, 0x1C, 0x0C, 0x0C, 0x0C, 0x00, + 0x1C, 0x32, 0x3C, 0x66, 0x66, 0x3C, 0x4C, 0x38, + 0x00, 0x10, 0x38, 0x6C, 0xC6, 0x82, 0x00, 0x00, + 0x66, 0xF7, 0x99, 0x99, 0xEF, 0x66, 0x00, 0x00, + 0x00, 0x00, 0x76, 0xDC, 0xC8, 0xDC, 0x76, 0x00, + 0x1C, 0x36, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x60, + 0x00, 0xFE, 0x66, 0x62, 0x60, 0x60, 0x60, 0xF8, + 0x00, 0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x6C, 0x48, + 0xFE, 0x66, 0x30, 0x18, 0x30, 0x66, 0xFE, 0x00, + 0x00, 0x1E, 0x38, 0x6C, 0x6C, 0x6C, 0x38, 0x00, + 0x00, 0x00, 0x6C, 0x6C, 0x6C, 0x6C, 0x7F, 0xC0, + 0x00, 0x00, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x10, + 0x3C, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x3C, + 0x00, 0x3C, 0x66, 0x7E, 0x66, 0x66, 0x3C, 0x00, + 0x00, 0x3C, 0x66, 0x66, 0x66, 0x24, 0x66, 0x00, + 0x1C, 0x36, 0x78, 0xDC, 0xCC, 0xEC, 0x78, 0x00, + 0x0C, 0x18, 0x38, 0x54, 0x54, 0x38, 0x30, 0x60, + 0x00, 0x10, 0x7C, 0xD6, 0xD6, 0xD6, 0x7C, 0x10, + 0x3E, 0x70, 0x60, 0x7E, 0x60, 0x70, 0x3E, 0x00, + 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, + 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, + 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00, + 0x30, 0x18, 0x0C, 0x18, 0x30, 0x00, 0x7E, 0x00, + 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x00, 0x7E, 0x00, + 0x00, 0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70, 0x00, + 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x32, 0x4C, 0x00, 0x32, 0x4C, 0x00, 0x00, + 0x38, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x7C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x0F, 0x18, 0xD8, 0x70, 0x30, 0x00, + 0x38, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, + 0x38, 0x6C, 0x18, 0x30, 0x7C, 0x00, 0x00, 0x00, + 0x78, 0x0C, 0x38, 0x0C, 0x78, 0x00, 0x00, 0x00, + 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +static inline void output_char(console *co, char c) { + if(co->y == co->height) { + char *adr = (char *) co->s->data; +#if USE_BLITTER + blitmove(adr+co->width*8,adr,co->width*(co->height-1)*8); + blitset(adr+co->width*(co->height-1)*8,0,co->width*8); +#else + bcopy(adr+co->width*8,adr,co->width*(co->height-1)*8); + bzero(adr+co->width*(co->height-1)*8,co->width*8); +#endif + co->y--; + } + + switch(c) { + case '\n': { + co->x = 0; + output_char(co,'\f'); + /* + while(co->x != 0) { + output_char(co,' '); + } + */ + /* + co->x = 0; + if(++(co->y) == co->height) { + co->y = 0; + } + */ + break; + } + case '\f': { + if(++(co->y) == co->height) { + // co->y = 0; + } + break; + } + case '\r': { + co->x = 0; + break; + } + case '\t': { + int i = 4; + i -= co->x % 4; + for(;i > 0; i--) { + output_char(co,' '); + } + break; + } + default: { + char *adr = (char *) co->s->data; + char *scr = adr + (co->x + co->y * co->width * 8); + char *chr = ascii_fnt + 8*c; + int i; + for(i = 0; i < 8; i++) { + *scr = *chr++; + scr += co->width; + } + if(++(co->x) == co->width) { + co->x = 0; + if(++(co->y) == co->height) { + // co->y = 0; + } + } + } + } +} + +static inline void output_string(console *co,const char *s) { + while(*s != 0) { + output_char(co,*s++); + } +} + +static int putc(FILE *stream, char c) { + console *co = stream->data; + if(co != NULL) { + output_char(co,c); + return 0; + } + return EOF; +} + +static int puts(FILE *stream, const char *s) { + console *co = stream->data; + if(co != NULL) { + output_string(co,s); + return 0; + } + return EOF; +} + +static size_t write(FILE *stream, const void *ptr, size_t size, size_t nmemb) { + console *co = stream->data; + if(co != NULL) { + int i; + char *s = (char *) ptr; + for(i = 0; i < nmemb * size; i++) { + putc(stream,*s++); + } + } + return 0; +} + +static int close(FILE *fp) { + console *co = fp->data; + if(co != NULL) { + sprite *s = co->s; + detach_sprite_from_display(s); + free(s->data); + free(s); + free(co); + fp->data = NULL; + return 0; + } + return EOF; +} + +static int eof(FILE *fp) { + console *co = fp->data; + return (co != NULL); +} + +FILE *open_custom_console(display *d, int x, int y, int idx, int width, int height, int layer) { + if(width % 8 != 0) { + width += 8-(width % 8); + } + console *co = malloc(sizeof(console)); + phrase *scr_addr = calloc(8,(width / 8) * (height * 8)); + sprite *s = new_sprite(width*8,height*8,x,y,DEPTH1,scr_addr); + s->trans = 0; + s->index = idx; + co->x = 0; + co->y = 0; + co->width = width; + co->height = height; + co->s = s; + attach_sprite_to_display_at_layer(s,d,layer); + SET_CLUT_RGB(idx,0,0,0); + SET_CLUT_RGB(idx+1,255,255,255); + // SET_SHORT_INT(0,(CLUT+2*idx)); + // SET_SHORT_INT(0xffff,(CLUT+2*idx+2)); + FILE *fp = malloc(sizeof(FILE)); + fp->data = co; + fp->eof = eof; + fp->putc = putc; + fp->puts = puts; + fp->write = write; + fp->flush = NULL; + fp->close = close; + return fp; +} + diff --git a/display/Makefile b/display/Makefile new file mode 100644 index 0000000..213d2af --- /dev/null +++ b/display/Makefile @@ -0,0 +1,45 @@ +JAGPATH=$(HOME)/Jaguar +CROSSPATH=/usr/local/m68k-aout/m68k-aout +MADMAC=$(JAGPATH)/bin/mac +CC=$(CROSSPATH)/bin/gcc +AR=$(CROSSPATH)/bin/ar + +SWAPMETHOD=1 + +MACFLAGS=-fb -v -dDISPLAY_SWAP_METHOD=$(SWAPMETHOD) +CFLAGS=-mc68000 -Wall -fomit-frame-pointer -O2 -msoft-float -DDISPLAY_SWAP_METHOD=$(SWAPMETHOD) + +SRCC= +SRCS=display.s +SRCH=display.h +OBJS=$(SRCC:.c=.o) $(SRCS:.s=.o) + +DISTFILES=Makefile $(SRCC) $(SRCH) $(SRCS) display_def.s display_cfg.s jaguar.inc +INSTALLH=display.h +INSTALLLIB=display.o + +# all: .depend $(OBJS) +all: $(OBJS) + +%.o: %.s + $(MADMAC) $(MACFLAGS) $< + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +clean: + rm -f *~ $(OBJS) .depend + +dist-files: + @echo $(DISTFILES) + +install-h: + @echo $(INSTALLH) + +install-lib: + @echo $(INSTALLLIB) + +# .depend: $(SRCC) +# $(CC) -MM $(SRCC) > .depend + +# -include .depend diff --git a/display/display.h b/display/display.h new file mode 100644 index 0000000..ee73967 --- /dev/null +++ b/display/display.h @@ -0,0 +1,138 @@ +/* The Removers'Library */ +/* Copyright (C) 2006 Seb/The Removers */ +/* http://removers.atari.org/ */ + +/* This library is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU Lesser General Public */ +/* License as published by the Free Software Foundation; either */ +/* version 2.1 of the License, or (at your option) any later version. */ + +/* This library 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 */ +/* Lesser General Public License for more details. */ + +/* You should have received a copy of the GNU Lesser General Public */ +/* License along with this library; if not, write to the Free Software */ +/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** \file display.h + * \brief Display manager. + */ +#ifndef _DISPLAY_H +#define _DISPLAY_H + +#ifndef DISPLAY_USE_LEGACY_ANIMATION +#define DISPLAY_USE_LEGACY_ANIMATION 0 +#endif + +#ifndef DISPLAY_SWAP_METHOD +#define DISPLAY_SWAP_METHOD 1 +#endif + +#ifndef DISPLAY_USE_OP_IT +#define DISPLAY_USE_OP_IT 1 +#endif + +#define DISPLAY_NB_LAYER 4 + +#include + +#define RGBCOLOR(r,g,b) (((((r) >> 3) & 0x1f) << 11) | ((((b) >> 3) & 0x1f) << 6) | (((g) >> 2) & 0x3f)) +#define CRYCOLOR(c,r,y) ((((c) & 0xf) << 12) | (((r) & 0xf) << 8) | ((y) & 0xff)) + +#define SET_BG_RGB(r,g,b) { SET_SHORT_INT(RGBCOLOR(r,g,b),BG); } +#define SET_BG_CRY(c,r,y) { SET_SHORT_INT(CRYCOLOR(c,r,y),BG); } +#define SET_CLUT_RGB(idx,r,g,b) { SET_SHORT_INT(RGBCOLOR(r,g,b),CLUT+2*((idx) & 0xff)); } +#define SET_CLUT_CRY(idx,c,r,y) { SET_SHORT_INT(CRYCOLOR(c,r,y),CLUT+2*((idx) & 0xff)); } +#define SET_BG(c) { SET_SHORT_INT(c,BG); } +#define SET_CLUT(idx,c) { SET_SHORT_INT(c,CLUT+2*((idx) & 0xff)); } + +typedef struct _sprite_header { + struct _sprite_header *previous; + struct _sprite_header *next; +} sprite_header; + +typedef struct { + struct { + unsigned long reserved : 31; + unsigned long visible : 1; + } attribute; + short int y; + short int x; + sprite_header sprites; +} layer_desc; + +typedef struct { + op_branch_object ob1; + op_branch_object ob2; + op_branch_object ob3; + op_branch_object ob4; +#if DISPLAY_USE_OP_IT + op_gpu_object ob5; +#else + op_branch_object ob5; +#endif + op_branch_object ob6; + op_stop_object ob7; +} display_list_header; + +/** The display type */ +typedef struct { + qphrase *phys; + qphrase *log; + // phrase + /** Y coordinate of display */ + short int y; + /** X coordinate of display */ + short int x; +#if DISPLAY_SWAP_METHOD + char _pad0[8-((4+4+2+2) % 8)]; + // dphrase + display_list_header h; + // phrase +#else + // long +#endif + + // sprite_header layer[1<HE|6YO5c0gVpu=T5W0RJe-Y!SE3&#(~*By zPw>;*D1IfjXyZ#K|&WCex z99@fMQ#4+_T3>tBd@h=6YcJ4oJDN}W;pA#Nx_u>@8}$Fp7Y(u1*h1rO)SHik$qZ2Z zS7K)r_>&jg;S4P&F_4(~GYs)c9Ql)e((|VQ8czMIAbBO8tB)sfKLCoYq! E=zk zKLp4YMtiv_wlKdojYe6&^Kcv_P9OQ(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